From: A Watcher on
I'm supporting a giant legacy app that allocates memory in lots of
places. It sure would be handy to have a "deallocate all" function.
Does any version of fortran have such a thing?
From: robert.corbett on
On Jul 14, 9:07 pm, A Watcher <stocks...(a)earthlink.net> wrote:
> I'm supporting a giant legacy app that allocates memory in lots of
> places. It sure would be handy to have a "deallocate all" function.
> Does any version of fortran have such a thing?

I cannot tell exactly what you want. Does the legacy app
use standard Fortran pointers or LWG/Cray/DEC/Sun pointers
(which are nonstandard)? If it uses standard Fortran
pointers, do you expect pointers that pointed to targets
that were deallocated to be nullified? Would an
implementation that does garbage collection suffice for
your purposes?

Robert Corbett
From: robin on
A Watcher wrote in message ...
>I'm supporting a giant legacy app that allocates memory in lots of
>places. It sure would be handy to have a "deallocate all" function.
>Does any version of fortran have such a thing?

Yes; execute a STOP instruction.


From: Philipp E. Weidmann on
A Watcher wrote:
> I'm supporting a giant legacy app that allocates memory in lots of
> places. It sure would be handy to have a "deallocate all" function.
> Does any version of fortran have such a thing?


I'd imagine that, if the app is indeed big enough and the project budget
permits it, it would be possible to write a script that generates such a
deallocation routine.

That script would only need to parse the entire code, collect all
pointer-based variables and allocatable arrays, put them in a COMMON
block or MODULE if neccessary (so they are globally accessible) and then
generate a large DEALLOCATE statement.

If you're savvy enough, such a script could probably be written in
Python or the likes in a single day.


However, as others have pointed out, everything gets deallocated on exit
anyway, so you should seriously think about whether that is really
neccessary.

--
-- Philipp Emanuel Weidmann
From: Arjen Markus on
On 15 jul, 14:12, "Philipp E. Weidmann" <philipp.weidm...(a)gmx.de>
wrote:
> A Watcher wrote:
> > I'm supporting a giant legacy app that allocates memory in lots of
> > places.  It sure would be handy to have a "deallocate all" function.
> > Does any version of fortran have such a thing?
>
> I'd imagine that, if the app is indeed big enough and the project budget
> permits it, it would be possible to write a script that generates such a
> deallocation routine.
>
> That script would only need to parse the entire code, collect all
> pointer-based variables and allocatable arrays, put them in a COMMON
> block or MODULE if neccessary (so they are globally accessible) and then
> generate a large DEALLOCATE statement.
>
> If you're savvy enough, such a script could probably be written in
> Python or the likes in a single day.
>
> However, as others have pointed out, everything gets deallocated on exit
> anyway, so you should seriously think about whether that is really
> neccessary.
>
> --
> -- Philipp Emanuel Weidmann

If the allocation is done for ALLOCATABLE items and not for POINTER
items,
then garbage collection is automatic too.

Perhaps "A Watcher" should explain what the symptoms are of the
program
that prompted this question, because such gross memory management as
asked about seems unlikely to be useful, except, indeed at the end
of the program, but then the OS should take care of it.

Regards,

Arjen