The program will crash if compile with version 4.4.3 or 4.3.2 but works with

Main program is written in C. (see the following)
 * C file passdouble.c
 * To compile the program, using the following command.
 *    gcc passdouble.c requestdouble.o -lgfortran
#include <stdio.h>
extern char* requestdouble_(double*,double*);
int main()
    double lat=10.0;
    double lon=20.0;
    return 0;

The Fortran function is in the file requestdouble.f90 shown below.

! gfortran -c -g -Wall requestdouble.f90
 FUNCTION requestdouble(rlat,rlng)
! Arguments
! Input scalars
  REAL(KIND=8), INTENT(IN) :: rlat ! - latitude -
  REAL(KIND=8), INTENT(IN) :: rlng ! - longitude -
  CHARACTER(LEN=16) :: requestdouble
  PRINT *, ' requestdouble rlat=',rlat,' rlng=',rlng
 END FUNCTION requestdouble

Here is how it compiled and ran.

gfortran -c -g -Wall requestdouble.f90
gcc passdouble.c requestdouble.o -lgfortran
Bus error

           Summary: Bus Error: C program calls Fortran Function which has
                    returned value as Character string
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Lulin dot Song at gmail dot com

Reply via email to