0

I want to use an integer variable (lets say xyz) defined in a f90 module (abc) in a c program. I have found that with gnu compilers it can be done like this:

extern int __abc_MOD_xyz;

But I could not find the corresponding syntax for Cray compilers.

Update

Following the friendly reminder to read the manual and the other comments, I was able to get it working. Here is the sample FORTRAN module:

module test
  use, intrinsic :: iso_c_binding
  integer :: ftnint = 100
  BIND(C) :: ftnint
end module test

and the C code:

#include <stdio.h>
#include <stdlib.h>
#include <ISO_Fortran_binding.h>
// variable that matches up with the FORTRAN module variable
int ftnint;

int main()
{
  printf(" var2 : %d\n", ftnint );
}

Compile with

ftn -c test_mod.f90
cc -c test.c
cc test.o test_mod.o
Jan
  • 1
  • 1

0 Answers0