That's a messy area finally at least helped by f2003. (It is messy
> I'm not sure, but is using "write(6,*)" to write to standard output
> non-portable? Is it better practice to use "write(*,*)"? Still...
> using write(6,*) on my system works fine without any segmentation
> fault - so I know I may not be helping.
enough that it can't be completely solved without compatibility
problems, but at least it can be helped for future codes).
No, using 6 as equivalent to * isn't strictly portable. First, the
number 6 is non-portable, although that's the right number for most
current compilers. Second, some compilers have fine points of
distinction between 6 and *. For example, there are compilers where both
6 and * appear to go to the same place in simple situations, but they
get separated if you do command-line redirection. I personally find that
behavior annoying, but other people like it.
There are big reasons to want to use a unit number in some codes. (Well,
a non-numeric handle would be better in my opinion, but the language
doesn't have that; that's an issue that has been proposed/discussed here
before). A major reason is that if you use a unit number, you can select
the appropriate file just by setting the value of the number. There are
many cases where you have some output that you might want to go either
to the screen or to some other file. With a unit number, you can just
do, for example
and it will work in either case, given an appropriate lun. If you have
to use *, this turns into
if (some_condition) then
write (*, ...
This can turn into a big pain. (You might need hundreds of such tests,
making the code a mess).
Unfortunately, as you note, there is no portable way to know an
appropriate unit number for the screen. F2003 adds such a way.
But... that was a bit of a side excursion. I doubt that is related to
the OP's problem. I won't 100% rule it out, but I'd guess against it. In
most implementations, if 6 isn't teh right number for standard output,
that would probably just result in writing to a file with a default name
like fort.6, or some such thing.
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain