INQUIRE - FORM vs. (UN)FORMATTED
- From: "Tobias Burnus" <burnus@xxxxxxxx>
- Date: 8 Dec 2006 01:16:17 -0800
Hello,
I'm trying to understand the FORM, FORMATTED and UNFORMATTED specifiers
of INQUIRE.
Let's start with FORM:
"The scalar-default-char-variable in the FORM= specifier is assigned
the value FORMATTED if the file is connected for formatted
input/output, and is assigned the value UNFORMATTED if the file is
connected for unformatted input/output. If there is no connection, it
is assigned the value UNDEFINED."
Ok, this is clear to me. Especially, it means given a UNIT (or a FILE
name) I can determine whether a file is connected and, if yes, whether
I need to access it as unformatted or formatted. I see many uses for
procedures where the UNIT is passed.
Ok, now comes the specifiers for which I don't understand what is (a)
exactly the purpose and (b) what value should be assigned when. (I talk
about FORMATTED below, but with UNFORMATTED I have exactly the same
problems.)
"The scalar-default-char-variable in the FORMATTED= specifier is
assigned the value YES if FORMATTED is included in the set of allowed
forms for the file, NO if FORMATTED is not included in the set of
allowed forms for the file, and UNKNOWN if the processor is unable to
determine whether or not FORMATTED is included in the set of allowed
forms for the file."
First case: INQUIRE(NAME=existing_file,...), which is not
connected/opened. Well, "UNKNOWN" can of cause always returned, but are
there scenarios where one would return FORMATTED="YES" or "NO"?
For a directory, one could e.g. return "NO". And in principle if a file
is readable, writtable and seekable there should be no problem opening
it - either as FORMATTED or as UNFORMATTED, whether one can read
something from the file is another question.
gfortran and g95 currently return for non-opened files: UNIT: "UNKNOWN"
NAME: Does not exists "UNKNOWN", directory "NO", File (regular,
block/character device, named pipe) "YES", else "UNKNOWN".
NAG f95, ifort and sunf95 return "UNKNOWN" which is always right.
Is the behaviour of gfortran/g95 correct?
Second case: The file is opened.
What should be returned for (UN)FORMATTED? Simply FORMATTED = "YES" if
FORM="FORMATTED" and otherwise "NO"? If this is the case, what is the
purpose of the FORMATTED vs. UNFORMATTED?
Or should be returned whether it is in principle possible to open the
file as (UN)FORMATTED? Then one would always return "YES" (I'm ignoring
issues like whether a file is seekable.)?
gfortran/g95 return always "YES" in this case,
ifort/NAG f95/sunf95 return FORMATTED="YES", UNFORMATTED="NO" if the
file is opened as FORMATTED.
In total, my problem is: What is meant by "in the set of allowed forms
for the file"? Depending how I understand it, I would either expect the
g* behaviour or the ifort/(sun)f95 behaviour.
Especially, for the ifort/sunf95/f95 behaviour I completely miss the
purpose of the (UN)FORMATTED specifier as they provide effectively the
same information as the FORM specifier.
Tobias
PS: Besides an interpretation of the standard, I'm also interested what
would be useful to return - as "this is implementation dependent" has
also somehow to be implemented.
.
- Follow-Ups:
- Re: INQUIRE - FORM vs. (UN)FORMATTED
- From: robert . corbett
- Re: INQUIRE - FORM vs. (UN)FORMATTED
- From: Tobias Burnus
- Re: INQUIRE - FORM vs. (UN)FORMATTED
- From: Richard Maine
- Re: INQUIRE - FORM vs. (UN)FORMATTED
- Prev by Date: Re: Fortran 90/95 code obfuscator?
- Next by Date: Re: command for measuring computing time in milli sec.
- Previous by thread: printing in fortran
- Next by thread: Re: INQUIRE - FORM vs. (UN)FORMATTED
- Index(es):
Relevant Pages
|