Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module test1
- implicit none
- contains
- subroutine x(ff,y)
- interface
- real function ff(y)
- real, intent(in) :: y
- end function ff
- end interface
- real, intent(in) :: y
- integer z
- z=ff(y)
- end subroutine x
- end module test1
- program tester
- use test1
- implicit none
- call x(f,1.0)
- contains
- real function f(y)
- real, intent(in) :: y
- write(*,*) y
- f=y*y
- end function f
- end program tester
- gfortran-7 -ggdb test_fun_passing.f90 -o test
- (gdb) bt
- #0 0x00007ffffffde320 in ?? ()
- #1 0x0000000000400734 in test1::x (ff=0x7ffffffde320, y=1) at test_fun_passing.f90:17
- #2 0x0000000000400829 in tester () at test_fun_passing.f90:31
- #3 0x0000000000400860 in main (argc=1, argv=0x7ffffffde64f) at test_fun_passing.f90:27
- #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
- #5 0x0000000000400669 in _start ()
- module test1
- implicit none
- contains
- subroutine x(ff,y)
- interface
- real function ff(y)
- real, intent(in) :: y
- end function ff
- end interface
- real, intent(in) :: y
- integer z
- z=ff(y)
- end subroutine x
- end module test1
- module test2
- implicit none
- contains
- real function f(y)
- real, intent(in) :: y
- write(*,*) y
- f=y*y
- end function f
- end module test2
- program tester
- use test1
- use test2
- implicit none
- call x(f,1.0)
- end program tester
- gfortran-7 -ggdb test_fun_passing.f90 -o test && ./test
- 1.00000000
Add Comment
Please, Sign In to add comment