Re: Bug & side-effect when using print (solved: damn saved variables !!)
- From: Ken Fairfield <my.full.name@xxxxxxxxx>
- Date: Tue, 12 Jul 2005 09:19:43 -0700
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 .
- References:
- Bug & side-effect when using print
- From: Nicolas Girard
- Re: Bug & side-effect when using print (solved: damn saved variables !!)
- From: Nicolas Girard
- Re: Bug & side-effect when using print (solved: damn saved variables !!)
- From: Ken Fairfield
- Re: Bug & side-effect when using print (solved: damn saved variables !!)
- From: David Flower
- Bug & side-effect when using print
- Prev by Date: preprocessor
- Next by Date: Re: preprocessor
- Previous by thread: Re: Bug & side-effect when using print (solved: damn saved variables !!)
- Next by thread: Re: MODULEand USE versus Argument Passing
- Index(es):
Relevant Pages
|