<
herrman...@gmail.com> wrote:
> On Monday, May 16, 2016 at 12:10:46 PM UTC-7, Lewis Lloyd wrote:
> > Sadly, gfortran was kind enough to inform us that having multiple
> > logical units connected to a single file (/dev/null in this case) is not
> > allowed by the Fortran standard. The Intel compiler has had no problem
> > allowing us to do this (even with -stand f08). The gfotran compiler
> > appears to be quite adamant about not allowing this.
>
> Since /dev/null isn't a file, but a device, I would say that rule
> shouldn't apply.
It is a file to Fortran. See the OPEN statement; that's what it does is
connect a unit to a "file". Whatever it might be considered from other
perspectives, it is a file by definition in Fortran. Since the rule in
question is a Fortran rule, that's particularly relevant. Compilers
might or might not enforce it, but I don't think there are any grounds
for claiming that the rule somehow doesn't apply and that compilers
can't enforce it.
> It is nice of the compiler (actually, run time library) to check, as the
> result of writing to a one disk file with two units open at the same time
> is likely to be bad.
Yep. And I've known other compilers to check. I don't recall whether it
was for /dev/null, but certainly for "real" files and possibly also for
devices.
> You could try symbolic links from different names to /dev/null, it might
> be that it doesn't figure that out.
I seem to recall trying tricks like that with symlinks once and finding
that the compiler I was using at th etime wasn't adequately fooled.
Might have been for a "real" file instead of /dev/null; I don't recall
that much detail. Perhaps it checked the inode or some such thing.
But for the particular case of /dev/null on a Unix system, Louis Krupp's
idea seems likely to work. I haven't tried it either, but it seems
likely. I will note that if he is worried about eficiency, there's a lot
to be said for catching things earlier in the code to avoid the write
statements instead of writing to a null file. Formatted writes in
particular can eat a lot of processing power even before hitting the
physical disk.
--
Richard Maine
email: last name at domain . net
dimnain: summer-triangle