Aleksandar Donev asked:
> I am wondering if anyone can clarify the effect of the SAVE attribute
> for global data (i.e. data declared in modules). For example:
>
> program main
> use routines, only : routine
> call routine()
> ...
> call routine()
> end program main
>
> module routines
> use shared, only : value
> contains
> subroutine routine()
> write(*,*) value
> value=value+1
> end subroutine routine
> end module routines
>
> module shared
> integer, SAVE :: value
> end module shared
>
> Does it matter that there is a SAVE on value. If not, when does it
> matter.
The standard allows non-saved module variables to disappear when there
is no procedure accessing the module by use association. In your case,
any nonsaved variables in the "shared" module could in principle disappear
between calls to "routine" because there is no "use shared" in your main
program. I don't know if any compilers take advantage of this feature
of the standard.
Best regards,
Van Snyder
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|