Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 30th, 2012  |  syntax: None  |  size: 0.73 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Mixed Programming Fortran and C
  2. MODULE my_fortran
  3.   USE iso_c_binding
  4.   IMPLICIT NONE
  5.   CONTAINS
  6.   SUBROUTINE my_subroutine(a,b) BIND(C,name="my_sub")
  7.     INTEGER(c_int),INTENT(in),VALUE :: a
  8.     REAL(C_DOUBLE),INTENT(out) :: b
  9.     ...
  10.   END SUBROUTINE
  11. END MODULE
  12.        
  13. void my_sub(int, double *);
  14.        
  15. #include "my_sub.h"
  16.  
  17. int main(){
  18.   double b;
  19.   int a=3;
  20.   my_sub(a,&b);
  21.   ...
  22. }
  23.        
  24. double   x, y;
  25.    ..................
  26.    x = 2.0;
  27.    y = gamma_(&x)
  28.        
  29. float  --- REAL     (this is typical, but not always the case)
  30. double --- REAL*8
  31.        
  32. extern void read_(int *small, float *medium, double *large);
  33.        
  34. read_(&small, &medium, &large);
  35.        
  36. SUBROUTINE READ(small,medium,large)
  37.  
  38.   INTEGER       small
  39.   REAL          medium
  40.   DOUBLE        large