1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
module present_04_mod
implicit none
integer, save :: called = 0
contains
subroutine s(f)
implicit none
external :: f
optional :: f
if (present(f)) call f()
end subroutine s
end module present_04_mod
program present_04
use present_04_mod, only: called, s
implicit none
external :: f
called = 0
call s()
if (called /= 0) error stop
call s(f)
if (called /= 1) error stop
end program present_04
subroutine f()
use present_04_mod, only: called
implicit none
called = called + 1
end subroutine f
|