Re: Bug & side-effect when using print (solved: damn saved variables !!)



David Flower wrote:
You state:

 If a variable is not specified in a SAVE statement, its status
is *undefined* on entry to the procedure (note that if the variable
appears in a DATA statement, or the F90 version of that, this implies
SAVE).

This is incorrect; the relevant section of the F77 standard states
(17.3.6):

[F77 quote elided]

    The text you quoted has been lifted out of context.  The context
of the original post to which I was replying was F90.  Clearly.
The OP was complaining that SAVE made his program fail.

    In the process of explaining why I thought it highly unlikely
that SAVE, in and of itself, would cause valid code to fail, I tried
to provide some illustrative examples, and in that context, I used an
example with DATA since that avoided a side-track into F90 declaration
syntax.  It also occurred to me that some people new to Fortran
expect variables given initial values in a DATA statement to take
those values on _each_ entry to the routine, i.e., to be reinitialized
on entry.  I was making the point to the OP that such DATA statements,
in the context of F90 which he is using, implies SAVE for those
variables.

    The F77 standard regarding SAVE is irrelevant to this discussion.
FWIW, most F77 compilers I encoutered from the early 80's through the
late 90's did save variables appearing in DATA statements.  Indeed,
it was unusual for any local variables NOT to be saved.  There was a
gradual appearance of (non-F77-standard) automatic variables, and local
variables on the stack, in compilers during the 90's that brought to
light the need for SAVE in old programs which omitted it...

	Regards, Ken
--
I don't speak for Intel, Intel doesn't speak for me...

Ken Fairfield
D1C Automation VMS System Support
who:   kenneth dot h dot fairfield
where: intel dot com
.



Relevant Pages

  • Re: Bug & side-effect when using print (solved: damn saved variables !!)
    ... Actually I reused some code from a colleague and converted it from f77 to f90; while doing this I managed to get rid of all 'save'd variables except this one, and for whatever reason I left it like this and forgot it. ... or that it would take on the value from the DATA statement? ... "garbage" value, i.e., whatever was left on the stack before entry to ...
    (comp.lang.fortran)
  • Re: Semi-OT: little-known/well-known terms in monolingual dictionaries
    ... of knowing how best to translate this word. ... of a word -- taking the context into account of course. ... Googling would help to some extent, but when I create my own user entries ... I'll mark the entries in my user entry so I know which dictionary/version ...
    (sci.lang.translation)
  • Re: "right click" and desktop
    ... when I removed the video card from the AGP slot and used the ... You have a problem with a context menu entry. ... error and ask me the same thing (if I want to send an error repport). ...
    (microsoft.public.windowsxp.newusers)
  • Re: Cant Remove Right Click Entry
    ... You probably won't find an entry in the registry with a key word ... added to the Context Menu at the time of the right-click. ... there's an entry called "Terminate" at bottom under ...
    (microsoft.public.windowsxp.customize)
  • Re: dll error message
    ... It means a context menu entry is calling that library file and it's either ... so reinstalling that ... Associate Expert - WindowsXP Expert Zone ...
    (microsoft.public.windowsxp.newusers)