Guest User

Untitled

a guest
May 30th, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment