HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
INQUIRE
Chapter 10 383
The INQUIRE statement in this example returns the following information about the file
named my_file:
The EXIST= specifier determines if the file is connected.
The DIRECT= specifier determines if it is connected for direct access.
The READWRITE= specifier determines if it can be read and written.
LOGICAL :: exist
CHARACTER(LEN=9) :: dir_acc, rw_sts
INQUIRE (FILE='my_file', EXIST=exist, &
DIRECT=dir_acc, READWRITE=rw_sts)
Inquiry by unit
The following INQUIRE statement returns the following information about the file connected
to the unit in u_num:
The OPENED= specifier determines if the file is connected to u_num.
The NAMED= specifier determines if it is a named file or a scratch file.
The NAME= specifier returns its name.
LOGICAL :: opened, named
INTEGER :: u_num
CHARACTER(LEN=80) :: fname
...
INQUIRE (UNIT=u_num, NAMED=named, OPENED=opened, NAME=fname)
Inquiry by output list
When using the OPEN statement to create a direct-access file, you must specify the record
length for the file with the RECL= specifier. Previous to Fortran 90, you had to resort to a
nonportable strategy to determine record length. The Fortran 90 INQUIRE statement provides
a portable solution: use the INQUIRE statement to inquire by output list, and specify the
return value from the INQUIRE statement as the argument to the OPEN statement. The
following is an example:
INTEGER :: rec_len, ios
INQUIRE (IOLENGTH=rec_len) x, y, i, j
OPEN (UNIT=32, FILE='new_file', IOSTAT=ios, &
ACCESS='DIRECT', RECL=rec_len)
Related statements
OPEN