RE: Using fortran shared libraries from root

From: Fine, Valeri <>
Date: Fri, 10 Feb 2006 02:08:10 -0500

One extra advice :)  

If you anticipating calling more then one Fortran subroutine then you may regard creating some C++ class with the bunch of the static methods: one per each your FORTRAN subroutine. This way you simplify your RootCint dictionary creation because instead of editing your LinkDef.h each time you add / remove some FORTRAN subroutine you demand the dictionary for that single C++ class wrapper.  

class F {
private: F(){}
  static F1()'
  static F2();
  static FN()

#pragma link C++ class F;  

 extrern "C" {
  void fsub1_();
  void fsub2_();
 . . .
 void fsubn_();

 void F::F1() { fsub1_();} 
 void F::F2() { fsub2_();} 
 void F::F3() { fsub3_();} 


Now from the ROOT prompt you can call  

 root [0] F::F1();  

Cheers, Valeri

From: on behalf of Fine, Valeri Sent: Thu 2/9/2006 11:42 PM
To:; Subject: RE: [ROOT] Using fortran shared libraries from root

You should describe the interface to your FORTRAN subroutine using C-like header file and create the RootCint dictionary for that interface. One is advised to create a C-wrapper around of the Fortran call and create the RootCint dictionary for that wrapper.


 void MyFunction( int a)

extern "C" {
  void myRealFortran_(int *a);

void MyFunction(int a)
  int fA = a;
   // call the real fortran

The real life examples can be seen too:

ttp:// <>

Hope this helps.



From: on behalf of Dimitri Bourilkov Sent: Thu 2/9/2006 3:10 PM
Subject: [ROOT] Using fortran shared libraries from root


    I would like to call from the root command line functions/subroutines from a fortran shared library (.so) built with -fpic. Is this possible? I see in the root pages examples for calling cernlib, but as they are statically built one has to rebuild the root.exe. This is not what I want, I would like to make them accesible from the standard root prompt. Any advice is welcome.

    Best, Dimitri

        _/_/_/                             _/_/_/
       _/    _/   Dimitri  BOURILKOV      _/    _/
      _/    _/   University of Florida   _/_/_/
     _/    _/  _/    _/
    _/_/_/                             _/_/_/
Received on Fri Feb 10 2006 - 08:09:06 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET