Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!dali.cs.montana.edu!masscomp!andyo From: andyo@masscomp.ccur.com (Andy Oram) Newsgroups: comp.lang.fortran Subject: Re: File handling in Fortran 77 Message-ID: <46017@masscomp.ccur.com> Date: 29 Aug 90 15:33:18 GMT Reply-To: andyo@masscomp.UUCP (Andy Oram) Followup-To: comp.lang.fortran Organization: Concurrent Computer Corporation - Westford, Ma Lines: 52 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." (Although this behavior is reasonable, it annoys me that the standard prevents systems with back-up and versioning systems, like VAX/VMS, from providing that feature when FORTRAN programs overwrite old files.) Under direct access, untouched records keep their old contents. > (ii) Can you open a file with status=NEW if the file already > exists. No (paragraph 12.10.1, under STATUS specifier). > others which allow you > to open existing files with status=NEW (vax/vms). . . . > (iii) (i) if an old file is opened with status=NEW qualifier. I haven't worked on VAX/VMS for a while, but I bet what it's doing is giving you a new, higher-numbered version of the file. > (iv) Are any of these issues dependent on whether your > file is binary or ASCII. Not officially. I can't think of any circumstances where you'd see differences -- a record is a record is a record, and that's the granularity with which FORTRAN I/O operates. (For instance, you can't change one part of an existing record and leave another part intact.) Disclaimer: I've used the standard a lot while writing a FORTRAN manual. I answered the posting in the hope of saving time for busier people with more expertise in the standard. Please forgive me if I have slipped up, either because the standard has a subtle loophole, or because I got too loose trying to map formal requirements (the standard) onto useful, real-life operation.