Path: utzoo!attcan!uunet!cs.utexas.edu!uwm.edu!bionet!ames!skipper!elxsi!maine From: maine@elxsi.dfrf.nasa.gov (Richard Maine) Newsgroups: comp.lang.fortran Subject: Re: record length for direct access files (corrected) Message-ID: Date: 2 Oct 90 16:55:38 GMT References: <2146@key.COM> <2151@key.COM> <2152@key.COM> Sender: news@skipper.dfrf.nasa.gov Organization: NASA Dryden, Edwards, Cal. Lines: 60 In-reply-to: sjc@key.COM's message of 1 Oct 90 23:50:19 GMT On 1 Oct 90 23:50:19 GMT, sjc@key.COM (Steve Correll) said: Steve> Thanks for bringing INQUIRE/IOLENGTH to my attention. I have a couple of Steve> questions for Fortran 90 experts: I'm not sure I qualify as an "expert". The number of Fortran 90 programs that I have gotten to compile to date seems a little low to justify the term. :-) But I'll give the questions a try anyway. Steve> 1. Is there anything in the Fortran 90 standard which forbids Steve> the following? (The intent is to write an element-count "icnt" Steve> followed by that number of elements of an array). Steve> ... (part omitted) Steve> read *, icnt Steve> inquire(iolength=record_length) icnt, (x(j), j=1, icnt) Steve> ... (etc) Steve> 2. If that example is legal, then I believe it's not possible Steve> to compute at compilation time how long the records will Steve> actually be. Is it intended that the INQUIRE/IOLENGTH construct Steve> be computed at execution time rather than at compilation time? Looks legal to me, and I agree with your conclusion that it's not required to be computed at execution time. I can't find anything in the standard that requires that. (That doesn't *guarantee* that it isn't there, but I can't find it). Steve> 3. Now suppose another program wants to read the file back in. Steve> Is there anything in the Fortran 90 standard that forbids the Steve> following example? Steve> Steve> inquire(iolength=record_length) icnt, (x(j), j=1, icnt) Steve> open(unit=ii, file='myfile', form='unformatted', & Steve> access='direct', recl=record_length, & Steve> status='old', action='readwrite', iostat=iostat) Steve> read(unit=ii) icnt, (x(j), j=1, icnt) Yes, at least the way I read it. The standard says that the iolist in the inquire is an output list and that it gives the value that would result from the use of the same output list in an unformatted output statement. Admittedly, it then procedes to mention input/output lists and statements. I'm not at all sure that 2 such identical appearing i/o lists would count as the "same list" if the values of icnt were different. Doesn't seem like they "reasonably" should, but I haven't spent much time contemplating the precise semantics of the wording used in the standard in that area. Basically, the above example "has to" be illegal because it otherwise would imply that you could read 2 different records with 2 different lengths from the same direct access file in the same open; just add a second read, which specifies rec=2. That is pretty explicitly illegal. (Oh yes, I just noticed you left the rec= specifier out above; that's illegal, but I assume that was just an accidental omission and not the point you were asking about). -- Richard Maine maine@elxsi.dfrf.nasa.gov [130.134.64.6]