Darima Lamazhapova writes:
> In Microsoft extension to ANSI Fortran 90 standart there are intrinsic
> EOF function. Is it possible to write similar function in fortran
> language for IRIX and HP machines?
This "Microsoft extension to f90" is an f66 extension used by some
vendors in the late 60's to early 70's. It's certainly not some new
innovation. It was basically obsoleted by the introduction of the
standard eof= and iostat= specifiers on the READ statement in f77.
Few vendors have supported EOF() since then.
In general, no it is not practical to duplicate the same
functionaility. The EOF() function tested *BEFORE* the read whether
an end-of-file would be encountered on the read. There is no
reasonable way to duplicate that part of the EOF()
functionality... particularly for things like interactive reads, where
it really isn't possible to tell before the fact whether there will be
data or not. For reading from a file, one could possibly do something
like try a READ with and end-of-file test, and then either save the
data so read in a temp buffer, or backspace and do the READ for "real"
later. However, this would be quite a bother, and either
1. Have severe performance problems and some portability issues if you
use the backspace idea.
2. Require recoding all the actual READs as internal READS from the
temp buffer if you used the buffer idea.
I do not recommend either of these. They are awfully big penalties
to pay just to be able to use a DO WHILE. I suggest using a style
more natural to the language, which detects the end-of-file condition
when you try to read instead of ahead of time. A typical READ loop
looks something more like
loop: do
read(....,iostat=iostat) ...
if (iostat /= 0) exit loop
!...process the data
end do loop
You can also use end= instead of iostat= if you prefer (I don't, but
that's just my taste). And you can distinguish between error and eof
handling if you want to do that.
--
Richard Maine
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|