Re: save statement in a module



jel wrote:
(snip)

I'm not sure this applies to the code I posted. Note that I have
IMPLICIT NONE both at the module level and for the ACCUM procedure.
The variable X is not declared within ACCUM, so the variable X always
refers to the module level variable X (otherwise I would have gotten a
compile time error). So, adding the SAVE to the ACCUM procedure
doesn't magically declare a local variable X (or does it? I hope
not.).

It does with X on the SAVE statement, otherwise
it doesn't. I assumed that it wasn't, Richard assumed that
it was.

As mentioned here recently, C does not have implicit declaration
in the Fortran sense. C89, though, does have something similar.
If you declare a variable with some other attribute it will
be implicitly declared as int. (But all the other keywords
are longer than int so it doesn't save typing.)

The statement SAVE X in a module subroutine would declare
a new real variable X separate from the module variable.

On a happy note, I did find an error that was causing the "real"
problem but it is far too embarrassing to confess.

Most likely not worse than any of us have done, and
it would help others not to do the same if you explained it.

-- glen

.



Relevant Pages

  • Re: save statement in a module
    ... declare a *DIFFERENT* variable of that name in that procedure. ... IMPLICIT NONE both at the module level and for the ACCUM procedure. ... compile time error). ...
    (comp.lang.fortran)
  • Re: FOR070.DAT files appearing
    ... > in the header then they couldn't be picked up. ... Nothing should be left to implicit. ... since Fortran has required. ... Declare before use. ...
    (comp.os.vms)
  • Re: Is cast operator unary or binary? How many operands?
    ... using implicit int AND implicit extern. ... distinguishable from other identifiers by context. ... declare f as function taking one argument of type int, ... If one attempts to use a conventional scanner and parser generator ...
    (comp.lang.c)
  • When to Declare an External Function as EXTERNAL in a Module ??
    ... End Subroutine Test ... implicit double precision ... then DO NOT declare the function ...
    (comp.lang.fortran)
  • Re: source check
    ... The whole idea behind 'implicit none' is to force you to declare ... The compiler will catch the substitution of 'rl' for 'r1' ... ... Only by seeing how it was used in the code could I deduce ...
    (comp.lang.fortran)