S pouzitim modulov som to myslel takto:
modules.f95
module tmp_mod1
contains
subroutine t11
write(*, *) "t11"
end subroutine
subroutine t12
write(*, *) "t12 calls:"
call t11
end subroutine
end module tmp_mod1
module tmp_mod2
contains
subroutine t2
write(*, *) "t2"
end subroutine
end module tmp_mod2
module my_mod
use tmp_mod1
use tmp_mod2
contains
subroutine s
write(*, *) "s calls:"
call t11
call t12
call t2
end subroutine
end module my_mod
program main
use my_mod
write(*, *) "main calls:"
call t11
call t12
call t2
call s
end program main
Output:
$ gfortran modules.f95 -o modules
$ modules
main calls:
t11
t12 calls:
t11
t2
s calls:
t11
t12 calls:
t11
t2