I do not want to use common blocks in my program. My main program calls a subroutine which calls a function. The function needs variables from the subroutine.
What a
What you care about here is association: you want to be able to associate entities in the function f with those in the subroutine condat. Storage association is one way to do this, which is what the common block is doing.
There are other forms of association which can be useful. These are
Argument association is described in haraldkl's answer.
Use association comes through modules like
module global_variables
implicit none ! I'm guessing on declarations, but that's not important
public ! Which is the default
real b1,c1,f1,g1,h1,d1,b2,c2,f2,g2,h2,p2,q2,r2,d2,xx2,yy2,zz2
integer iab11,iab22
end module
subroutine condat(i,j)
use global_variables ! Those public things are use associated
...
end subroutine
function f(x)
use global_variables ! And the same entities are accessible here
...
end function
Host association is having access to entities accessible to the host. A host here could usefully be a module or a program
module everything
integer iab11,...
real ...
contains
subroutine condat(i,j)
! iab11 available from the host module
end subroutine
function f(x)
! iab11 available from the host module
end function
end module
or even the subroutine itself
subroutine condat(i,j)
integer iab11,...
real ...
contains
function f(x)
! Host condat's iab11 is accessible here
end function
end subroutine