Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [tmp]» cat test.f90 (evan@aeroevan:~/src/tmp)
- program test
- use test_mod, only: func
- implicit none
- real :: a
- integer :: b
- a = func(1.0, 2.0)
- print *, a
- b = func(1, 2)
- print *, b
- end program test
- module test_mod
- interface func
- module procedure func_real, func_integer
- end interface func
- contains
- function func_real(x, y) result(z)
- real, intent(in) :: x, y
- real :: z
- print *, "Calling real function"
- z = x + y
- end function func_real
- function func_integer(x, y) result(z)
- integer, intent(in) :: x, y
- integer :: z
- print *, "Calling integer function"
- z = x + y
- end function func_integer
- end module test_mod
- [tmp]» gfortran -o test test.f90 (evan@aeroevan:~/src/tmp)
- [tmp]» ./test (evan@aeroevan:~/src/tmp)
- Calling real function
- 3.0000000
- Calling integer function
- 3
- [tmp]» (evan@aeroevan:~/src/tmp)
Advertisement
Add Comment
Please, Sign In to add comment