True, but you can rename the type instance. So If I have several modules with a variable “constants”
I can do
use some_mode1 only : k=>constants
use some_mode2, only: x=>constants
and
associate ( pi=> constants%pi)
write(*,*)pi
end associate
works. Not perfect, but avoids some of the problems with public variables. instead of renaming if the value is a constant a redeclaration can be useful, as in
real,parameter :: pi=constants%pi
allthough not particulary useful if you want to change the public value. Not perfect, but neither are the alternatives.
I am probably missing something. The variable c didn’t exist in the former version of the code (test1.f90?), so what do you mean by “the variable c gets defined automatically inside legrout because of the implicit typing”?
In the latter version (test2.f90?), c is available by use-association because of the unqualified use mod2. If you comment this line out, the compiler will give you errors for all variables not declared locally. You can then disposition them one-by-one to decide if they should be local variables, or brought in by use-association from the module by adding use mod2, only: b, c, etc.
This makes ../fpt_output/legrout1.f with everything declared. It keeps all the comments, the layouts etc. but pretty-prints the code. The whole story is at http://simconglobal.com/fortranimplicituse.tar.gz - the forum won’t let me upload it here.