This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re-examining PR61933 negative unit numbers
- From: Jerry DeLisle <jvdelisle at charter dot net>
- To: gfortran <fortran at gcc dot gnu dot org>
- Date: Sun, 28 Dec 2014 14:50:04 -0800
- Subject: Re-examining PR61933 negative unit numbers
- Authentication-results: sourceware.org; auth=none
I found some time during the Holidays to get back to this PR.
I think the solution depends on how we define whether or not a UNIT exists. All
the back and forth emails and c.l.f discussions did not help me much and were
leaning toward just letting any UNIT exist regardless except -1.
Combing through the standard I find the following:
"The unit identified by a NEWUNIT value shall not be preconnected."
To me this means I can do write(10,*) without explicitly connecting UNIT 10 with
an open statement, but I can not do write(-10,*).
Likewise, if iunit = -10, I can not do write(iunit, *) unless UNIT -10 was
previously connected with an OPEN(NEWUNIT=someunit, ...). I disregard whether or
not the programmer "knows" the value of the unit number somehow. I think that
if one tries to write to a negative unit that was not established with a NEWUNIT
specifier, then this is an error.
Elsewhere in the standard I find the following:
"At any given time, there is a processor-dependent set of external units that
exist for a program."
This is talking about UNIT existence being processor-dependent. To me this
means we have some flexibility regarding what we define as existence for a UNIT.
Proposed:
I would like to recommend that we define for gfortran that an external UNIT
exists if it is preconnected or if it does not require an explicit OPEN to be
connected, or if it has been connected via an OPEN (with or without NEWUNIT
being used).
With this suggested definition INQUIRE(UNIT=someunit, EXISTS=unit_exists) has
some meaningful usefulness. Further, this would allow a programmer to find out
what negative units have been connected or are still connected. I am not
suggesting that "usefulness" is some sort of universally understood thing or has
any implied correctness. I am just asking myself what is the point of testing
for existence of a UNIT if one does not define existence. And...I am trying to
get an agreed to definition at least for gfortran.
Is this definition OK with the gfortran team?
Regards,
Jerry