Guest User

Untitled

a guest
Apr 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. module test1
  2.  
  3. implicit none
  4.  
  5. contains
  6.  
  7. subroutine x(ff,y)
  8.  
  9. interface
  10. real function ff(y)
  11. real, intent(in) :: y
  12. end function ff
  13. end interface
  14. real, intent(in) :: y
  15. integer z
  16.  
  17. z=ff(y)
  18.  
  19. end subroutine x
  20.  
  21. end module test1
  22.  
  23. program tester
  24. use test1
  25. implicit none
  26.  
  27. call x(f,1.0)
  28.  
  29. contains
  30.  
  31. real function f(y)
  32. real, intent(in) :: y
  33.  
  34. write(*,*) y
  35. f=y*y
  36. end function f
  37.  
  38. end program tester
  39.  
  40. gfortran-7 -ggdb test_fun_passing.f90 -o test
  41.  
  42. (gdb) bt
  43. #0 0x00007ffffffde320 in ?? ()
  44. #1 0x0000000000400734 in test1::x (ff=0x7ffffffde320, y=1) at test_fun_passing.f90:17
  45. #2 0x0000000000400829 in tester () at test_fun_passing.f90:31
  46. #3 0x0000000000400860 in main (argc=1, argv=0x7ffffffde64f) at test_fun_passing.f90:27
  47. #4 0x00007ffffec70830 in __libc_start_main (main=0x40082c <main>, argc=1, argv=0x7ffffffde448, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffffffde438) at ../csu/libc-start.c:291
  48.  
  49. #5 0x0000000000400669 in _start ()
  50.  
  51. module test1
  52.  
  53. implicit none
  54.  
  55. contains
  56.  
  57. subroutine x(ff,y)
  58.  
  59. interface
  60. real function ff(y)
  61. real, intent(in) :: y
  62. end function ff
  63. end interface
  64. real, intent(in) :: y
  65. integer z
  66.  
  67. z=ff(y)
  68.  
  69. end subroutine x
  70.  
  71. end module test1
  72.  
  73. module test2
  74.  
  75. implicit none
  76.  
  77. contains
  78.  
  79. real function f(y)
  80. real, intent(in) :: y
  81.  
  82. write(*,*) y
  83. f=y*y
  84. end function f
  85.  
  86. end module test2
  87.  
  88. program tester
  89. use test1
  90. use test2
  91. implicit none
  92.  
  93. call x(f,1.0)
  94.  
  95. end program tester
  96.  
  97.  
  98. gfortran-7 -ggdb test_fun_passing.f90 -o test && ./test
  99. 1.00000000
Add Comment
Please, Sign In to add comment