Xref: utzoo comp.lang.fortran:2376 comp.os.vms:16988 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!sun-barr!newstop!sun!road!khb From: khb@road.Sun.COM (Keith Bierman - Advanced Languages - Floating Point Group ) Newsgroups: comp.lang.fortran,comp.os.vms Subject: Re: Question about variables local to subroutine Keywords: Local variables, subroutines Message-ID: <123145@sun.Eng.Sun.COM> Date: 23 Aug 89 07:10:15 GMT References: <24891@iuvax.cs.indiana.edu> Sender: news@sun.Eng.Sun.COM Reply-To: khb@sun.UUCP (Keith Bierman - Advanced Languages - Floating Point Group ) Organization: Sun Microsystems, Mountain View Lines: 42 In article <24891@iuvax.cs.indiana.edu> templon@silver.bacs.indiana.edu (jeffrey templon) writes: > >I would like to know one simple (I hope) thing: what happens if you set >the value of a variable (local) in a subroutine, exit the subroutine, and >come back later? Is it the same value, zero, or worse? I read all TFMs >I could find and saw no answer to this one. I am using VAX Fortran, >whatever version runs on VMS V4.6. Thanks for any help you can send. > > Jeff Templon Well, if you read the standards document (:> turgid prose at best), you will find that if you declare your variable subroutine sub(stuff) real your_var ! extended fortran, for long var name and underscore save your_var ! not to mention lower case and ! the standard assures you that your_var has the result from the last invocation. If you don't employ save, vendor gets to do whatever they want. DEC VMS FORTRAN happens to make all variables SAVEd for you anyway. UNIVAC (used to) gives you junk. Sun (well me) strongly advises use of the SAVE, if you really want your old value back. I know of no one who promises you zero ... many machines (dec, sun) give you zero the first time through ... second time zero is about the least likely number. -- Keith H. Bierman |*My thoughts are my own. !! kbierman@sun.com It's Not My Fault | MTS --Only my work belongs to Sun* I Voted for Bill & | Advanced Languages/Floating Point Group Opus | "When the going gets Weird .. the Weird turn PRO" Keith H. Bierman |*My thoughts are my own. !! kbierman@sun.com It's Not My Fault | MTS --Only my work belongs to Sun* I Voted for Bill & | Advanced Languages/Floating Point Group Opus | "When the going gets Weird .. the Weird turn PRO"