If a parent module has an IMPLICIT NONE statement and this module is accessed through a USE statement in a descendant module without an IMPLICIT NONE statement, does the IMPLICIT NONE apply to descendant module? In my recent experience, the implicit none does not. As a result, some of my legacy code generates compilation errors or worse still, continues executing with unrealistic numbers. This seems to be irrespective of compiler settings. An example is included below. Any help would be greatly appreciated.
integer(kind = 4) :: a, b
a = 1
b = 2
! c = 3 ! generates compilation error since c is not declared
print *, 'a = ', a
print *, 'b = ', b
! print *, 'c = ', c ! generates compilation error since c is not declared
end subroutine psub
end module parent
d = 4 ! does not generate compilation error even though d is not declared
print *, 'd = ', d ! prints d as a single precision number 4.000000
end subroutine dsub
integer(kind = 4) :: i
print *, 'In tsub: i = ', i ! prints i = -858993460 since expected argument is mismatched in type
end subroutine tsub
end module descendant
end program main
It does not carry into the scope of the contained routine or other module. This was discussed in part (your variable c) in an earlier thread, https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/287958.
Specifically regarding inheritance through USE, Advice from others is, it does not. USE makes declared entities accessible, but it doesn’t carry along other aspects of the module such as IMPLICIT.
Thanks, @Kevin D. So to be clear, with reference to my example above
1. the implicit none declared in module parent will apply to any subroutines or functions contained in the parent module.
2. the implicit none declared in module parent will not apply to any module such as module descendant that invokes parent through a use statement.