Adriaan Joubert wrote:
>
> Jaehoon Seol wrote:
>
> > I am trying to call a fortran subroutine from C++. The difficulty which I
> > am facing is the following.
> >
> > Inside C++, I am calling a fortran subroutine;
> >
> > void testfortran(double) ;
> > .......................
> > testfortran(1.0);
>
> Parameters are always passed by reference in Fortran. So no way you could
> pass 1.0:
Look at the address:
http://hpcf.nersc.gov/software/prgenv/howto/interlanguage/
Fortran routines can be called from C++ programs. The procedure is
similar to calling Fortran from C. The only difference is that the
Fortran routine must
be declared extern "C".
Here's a simple code that performs the same task as does the C program
above :
/* FILENAME: c++_main.C
Shows how to call a FORTRAN routine from C++
*/
extern "C" void CALC_DIST(double *, double *, double *, double *);
void main()
{
double p1_x,p1_y,p2_x,p2_y;
p1_x = 0.0;
p1_y = 0.0;
p2_x = 3.0;
p2_y = 4.0;
CALC_DIST(&p1_x,&p1_y,&p2_x,&p2_y);
}
I found a lot of informations for portability at the Carsten Arnholm's
homepage:
http://home.sol.no/~arnholm/
Laurence
--
Laurence VIRY
Centre Charles Hermite http://www.loria.fr/serveurs/CCH/
Batiment LORIA - bureau B004
Tel: (33) 03 83 59 20 55
Fax: (33) 03 83 27 83 19
e-mail: [log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|