Keith Bierman wrote:
> another example of why having the Fortran standard be intrinsically
> bound to Posix would be handy ;>
Seriously!
NAG for example has a POSIX binding (module), which includes their own
version of ATEXIT, but this is what the manual says: "If the program
terminates due to an error, or by executing a STOP statement or main
program END statement, whether these soubroutines [atexit callbacks]
will be invoked is undefined". What exactly "is undefined" is supposed
to mean I am not sure.
Anyway, actual experiments show that even if one registers callbacks via
the C atexit, they do *not* get called back upon executing STOP (On
Lahey's compiler they do get invoked). This is weird, particularly
considering the compiler actually uses gcc to generate the executable.
With NAG, registering them with their own ATEXIT does seem to
work---they are invoked upon executing a STOP (I guess this fits under
"undefined" above) or "CALL EXIT()" (from their POSIX module), or even
an error termination such as WRITE(-1,*) (which happens to generate a
useful traceback also), or even if one calls the C exit(), which is
what I ultimately want.
But why do I have to spend hours trying to figure out what each compiler
is doing (and not clear I really have figured it out)??? The words Dick
quoted at least guarantee that in F2003 implementations exit() and
"normal program termination" (such as executing a STOP) must behave the
same and thus both call atexit() callbacks. At least one small benefit.
But far from enough, and at that it seems a rather random addition into
Fortran 2003...
Aleks
|