I have a short question about initializing derived types. I thought
initializing meant not having to add "save" to the declaration.
But the program below gives an error message on one compiler (nag):
Error: TestInit.f95, line 12: Default initialised module variable A
must be SAVEd
while another (lahey) compiles and runs with no problem. If I switch to
the commented type statement, both compilers are fine. It's not really
a big deal, but in the actual application I would like to avoid all the
extra saves if possible. Is this legal as it stands?
module t
type xy
integer :: mxy = -1
end type
end module t
module u
use t
type (xy) :: a = xy(2)
! type (xy), save :: a = xy(2)
end module u
program test
use u
write (*,*) a%mxy
end program test
David Smith
|