Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!csun1!weyrich From: weyrich@csun1.UUCP (Orville Weyrich) Newsgroups: comp.lang.fortran Subject: Re: Question on DATA and SAVE. Message-ID: <116@csun1.UUCP> Date: 30 Jan 89 20:38:57 GMT References: <2482@garth.UUCP> Distribution: na Organization: Univ. of GA, CS Dept., Athens Lines: 31 From article <2482@garth.UUCP>, by smryan@garth.UUCP (s m ryan): > Does anyone have an opinion or knowledge of whether it is meaningful to > initialise a local variable of a subprogram with a DATA but not SAVE the > variable? It would seem the variable can become undefined on entry so that > the DATA would be ignored. Without the SAVE, you can count on a data-initialized variable to have the specified initial value the first time you enter the subroutine. If the subroutine changes the value of the data initialized variable, then the value which you find on subsequent entries into the subroutine is "undefined" by the FORTRAN standard. In practice, this means the value is "system-dependent". For example, IBM mainframe FORTRAN-G will allow the variable to retain its previous value between subroutine calls IF YOU DO NOT OVERLAY the subroutine. If the subroutine is overlayed and the overlay is swapped out, then when you enter the subroutine again, the initial data- initialized value is reincarnated. Some other compilers (Burroughs???) allocate variables which are not marked with a SAVE on a local stack and the values are garbage when you reenter (I know this only by hearsay, and am not sure what happens with DATA initialized variables on the Burroughs). The bottom line -- either use SAVE if variables need to preserve changes in their values across subroutine calls or else get real intimate with your particular implementation of FORTRAN (not recommended :-( ). -- Orville R. Weyrich, Jr. | UUCP : ...gatech!csun1!weyrich Department of Computer Science | INTERNET: weyrich@csun1.cs.uga.edu University of Georgia | Athens, GA 30602 USA | MA BELL : (404) 542-1082