Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!usc!apple!agate!violet.berkeley.edu!jerry From: jerry@violet.berkeley.edu (Jerry Berkman) Newsgroups: comp.lang.fortran Subject: Re: File handling in Fortran 77 Message-ID: <1990Sep12.215551.16135@agate.berkeley.edu> Date: 12 Sep 90 21:55:51 GMT References: <46016@masscomp.ccur.com> Sender: usenet@agate.berkeley.edu (USENET Administrator) Organization: University of California, Berkeley Lines: 46 In article <46016@masscomp.ccur.com> andyo@masscomp.UUCP (Andy Oram) writes: >Questions about standard Fortran 77, from ravi@earth.ce.nwu.edu (Ravi Sinha): > >> (i) If you open an OLD file using status=UNKNOWN and write >> less no. of lines to it than is already there, should the >> new file have only the stuff written when it was opened >> last. Or should the write statement just overwrite >> the old file, thereby leaving rest of the old contents >> untouched. > >This depends on whether you use ACCESS='SEQUENTIAL' or ACCESS='DIRECT'. > >Sequential access positions the file at the beginning (the standard seems to >leave some leeway here, but paragraph 12.2.4.1 says that files are opened at >the first record). Furthermore, sequenitial access causes each write to be >last record (paragraph 12.9.4.1). Add it up and you can say "bye-bye old >data." The standard does not state, in general, whether files are opened at the beginning or end. For many years, the VAX UNIX f77 opened files at their end. The logic was that if you wanted to start at the beginning, you could issue a 'rewind'. However, if the file was opened at the beginning, there would be no easy way to get to the end. This caused endless confusion among users. In early 1983, a number of us managed to convince the BSD people to change the library to open disk files at their beginning. Even several years later, I heard of other system who opened files at their end. 12.2.4.1 says files discusses files which have both direct access and sequential access in the set of allowed access methods, which is not all files. Even though I would love the Fortran standard to specify opening disk files at their beginning, the Fortran standard makes no distinction between types of files. Thus it could only say all files are opened at their beginning. This would be a mess on tapes. What if I have positioned the tape at the 10,000 record of the 30th file on the tape. What would open at the beginning mean? - Jerry Berkman, U.C. Berkeley, (415)642-4804 jerry@violet.berkeley.edu (normal disclaimers: opinions are my own, not my employers, etc.)