Segmentation fault calling fortran function from c
burnus@ph2.uni-koeln.de
burnus@ph2.uni-koeln.de
Wed Jul 4 15:30:00 GMT 2007
asilter79 wrote:
> int a = 4;
> b = intgerigonder_(a);
>
> integer Function INTGERIGONDER (X)
> integer X
As FX already wrote there is a difference in the argument handling of C
and Fortran. In C call-by-value and in Fortran call-by-reference is used
by default.
Thus you can either pass the address of the variable 'a' to Fortran as FX
suggested: b = intgerigonder_(&a);
or you can tell Fortran to expect a VALUE not a reference:
integer Function INTGERIGONDER (X)
integer, VALUE :: X
The latter is part of the Fortran 2003 and only works with newer
compilers. (I think it is only in GCC 4.3 and not in 4.2.)
Tobias
More information about the Fortran
mailing list