An earlier thread concluded that IMPLICIT (NONE) in a module applied to all procedures defined in the scoping unit of the module.
Now we have SUBMODULES we need to consider the scope of IMPLICIT again. SUBMODULES inherit the scope of the parent module, i.e. they see all the type definitions, variable declarations and the procedures and more I expect. So until now I was assumming they have visibility the IMPLICIT statements too. But by accident I discovered they don't. This seams an odd choice to me and something worthy of making a note of in the help file.
module A implicit none contains subroutine bar() x = 1 end end module submodule(A) B contains subroutine foo() y = 1 end end
Intel Fortran complains correctly about X = 1, but ignores Y = 1, giving Y a default real type.
链接已复制
Maybe it was this thread....
https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/703123
The standard says "An IMPLICIT NONE statement can indicate that no implicit typing rules are to apply in a particular scoping unit..." The term "scoping unit" has a precise definition. It is easy to assume that because a submodule can "see" declarations in its parent module that an IMPLICIT is also inherited, but that's not the case. A submodule is its own scoping unit, not part of the parent module.
Yes I can see a submodule needs its own scoping unit. However I don't see why it does not inherit/copy the IMPLICIT definition like it does everything else from the parent module scope.
I dont have a copy of F2008 but I found these key statements in the IBM documentation:
"A submodule is a program unit that extends a module or another submodule."
and:
"A submodule has access to the entities that are declared and defined in its ancestor module or submodules by host association"
Maybe IMPLICIT just got forgotten but a sensible interpretation would be that IMPLICIT statements should carry over to the SUBMODULES scope. Then the module procedures see the same environment as the module procedure interfaces.
Andrew Smith wrote:
.. dont have a copy of F2008 but I found these key statements in the IBM documentation: ..
The standard effectively ties the IMPLICIT statement to a scoping unit and it indicates the SUBMODULE is a separate unit from the MODULE. SUBMODULE has access to data entities from its ancestors via host association which is a different concept per the standard.
