Dear Fortran Experts in the world,
A few days ago I stumbled on a question concerning
propagation of accessiblity PUBLIC vs. PRIVATE in
nested Modules.
Two systems (Compaq and Absoft) act differently from
a third (Salford) with the following program.
My first idea was, and Salford seems to confirm this,
that entities from M1 are available in PROGRAM TEST.
However, Compaq and Absoft complain about X and T
not being declared.
I tried to look up the "official" interpretation in
the Standard, specifically 11.3.1 and 11.3.2, but
could not find it there.
What is in your opinion the "official" interpretation?
The program compiles and runs correctly on all systems
if I put USE statements for both modules in the
main program.
! [JvO] 2000-09-06 Test-priv.f90
module M1 ! DATA
implicit NONE
PUBLIC
integer, parameter :: N = 10
character(len=N) :: T = " Hallo !"
real, dimension(N) :: X
end module M1
module M2 ! PROCEDURES
use M1
implicit NONE
PRIVATE ! QUESTION: Is M1 now PRIVATE too ?
public :: p
contains
subroutine p(z)
real, dimension(N) :: z
z = 1 ; z(N) = N
print*, z(1), z(N)
end subroutine
end module M2
program test
use M2 ! uses M1
implicit NONE
print *, t
call p(x)
end program test
! Thank you very much for your attention.
Jan van Oosterwijk
mailto:[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|