Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!m.cs.uiuc.edu!ibma0.cs.uiuc.edu!ux1.cso.uiuc.edu!aquifer.geology.uiuc.edu!jeffb From: jeffb@aquifer.geology.uiuc.edu (Jeffrey Biesiadecki) Newsgroups: comp.sys.sgi Subject: f77 REWIND bug Keywords: fortran Message-ID: <1991Mar21.193634.13881@ux1.cso.uiuc.edu> Date: 21 Mar 91 19:36:34 GMT Sender: usenet@ux1.cso.uiuc.edu (News) Distribution: comp Organization: University of Illinois at Urbana Lines: 53 Hi - We are having trouble with the f77 "REWIND" statement on our 4D/20 {TG,G} and our 4D/25 TG running IRIX 3.3.1. We have a program that writes output to a file. It is convenient to look at that file from another window while the program is running. Sometimes, the program has reason to "REWIND" the output file, and start writing over it from the beginning. Here's the bug: if there is less stuff written to the file after the REWIND than there was before the rewind, then the extra data stays in the file until it is closed. I've tried using the ENDFILE statment, and that didn't seem to help, and other options for the OPEN statment (such as SHARED) but those didn't help either. One fix is to close and reopen the file after the REWIND, but hopefully there is a less kludgy way to solve our problem. I'm not sure what the Fortran 77 standard says about this behavior, but it doesn't seem to happen on other machines that we run the program on. Here's a sample program: ------------------------------------------------------------ program rewbug c c program that illustrates rewind bug c open (1,file='afile') write (1,*) 'this is the first line of afile ' write (1,*) 'this is the second line of afile' c rewind 1 write (1,*) 'this should be the only line now' call flush (1) c c when the pause statement is reached, look at 'afile' from another window, c or press CTRL-Z and look at afile. only after the program continues is c the junk at the end of 'afile' (the second line) cleaned up. c pause close (1) c end ------------------------------------------------------------ Thanks for any suggestions you may have, Jeff -- /******************************************************************************* ** Jeff Biesiadecki ** University of Illinois, Urbana-Champaign ** ** jeffb@aquifer.geology.uiuc.edu ** Depts. of Geology and Computer Science ** *******************************************************************************/