I am trying to navigate my way around fortran 90 and I have this toy example using which I would like to ask a question
module foo
implicit none
contains
subroutine foobar()
print *,'foobar'
end subroutine foobar
end module foo
Then the main program -
program test
use foo
real a,b,c
a = 10.
b= 10.
c= 10.
print *,'hello world'
call abc(a,b,c)
end program test
subroutine abc(a,b,c)
call def(a,b,c)
end subroutine abc
subroutine def(a,b,c)
call foobar()
print *,'def'
end subroutine def
If I do not include the 'use foo' statement in subroutine def I get a linking error while linking test.o and foo.o-undefined reference. Why is that ? By declaring use foo at the 'main' level do the subroutines also not get access to the symbol foo ? I would guess not based on the compiler error. So this means the only way to move forward is to include the use foo statement in every subroutine. What is the motivation behind this ?