Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!haven!purdue!mentor.cc.purdue.edu!s.cc.purdue.edu!ags From: ags@s.cc.purdue.edu (Dave Seaman) Newsgroups: comp.lang.fortran Subject: Re: ERR= and END= Message-ID: <3836@s.cc.purdue.edu> Date: 1 Mar 89 13:49:54 GMT References: <2291@unmvax.unm.edu> <91480@sun.uucp> <3234@ttrdc.UUCP> Reply-To: ags@s.cc.purdue.edu (Dave Seaman) Distribution: usa Organization: Purdue University Lines: 40 In article <3234@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >In article <91480@sun.uucp>, khb%fatcity@Sun.COM (fatcity) writes: >< do i = 1, max >< read(ilun,'(your format)',IOSTAT=istat) your variable list >< if (istat .EQ. EOF) then >< EXIT >< else if (istat .NE. OK) then >< call abort('your favorite abort messages',istat) >< endif >< your processing goes here >< end do > >Nice idea, but isn't it kind of environment dependent? Like, where does the >value of the EOF parameter come from? A good point. To make it environment-independent, change the condition if (istat .EQ. EOF) then to read if (istat .LT. 0) then which is guaranteed to be .TRUE. if and only if an end-of-file condition was encountered on the preceding read, because of paragraph 12.7 in the standard. By the same token, the condition else if (istat .NE. OK) then would be better expressed as else if (istat .GT. 0) then for detecting error conditions. This also demonstrates why end-of-file is definitely not an error condition: the IOSTAT= return would have to be simultaneously positive and negative! -- Dave Seaman ags@j.cc.purdue.edu