INTEGER FUNCTION GETDFILE( LNAME, RDONLY, FMTFLAG, RECLEN, CALLER ) CHARACTER*(*) LNAME ! logical file name LOGICAL RDONLY ! TRUE iff file is input-only LOGICAL FMTFLAG ! TRUE iff file should be formatted INTEGER RECLEN ! direct access record length CHARACTER*(*) CALLER ! caller-name for logging
int getdfilec( const char * fname , int rstatus, int fstatus, int reclen, const char * pname )
LNAME
from the environment, checks for existence
of a file whose file name is that value, then opens the file as a
Fortran direct access file with the indicated record length
RECLEN
, according to the LOGICAL
flags
RDONLY
(open for read-only iff TRUE
,
read/write if FALSE
) and FMTFLAG
(formatted iff TRUE
, else unformatted).
WARNING: interpretation of RECLEN
-- whether it
measures record length in words or in bytes -- is vendor-dependent
(and not always easy to dig out of the vendor's
documentation).
Logs the file-opening, together
with the CALLER
version, and returns the unit number
of the file opened, or -1 for failure.
Uses JUNIT() to get a unit number.
For Fortran-90 declarations and interface checking:
USE M3UTILIO
See also GETEFILE() for opening sequential Fortran files.
#include "iodecl3.h"
if called from C.
Logical name for the file set (else it will open a file with the indicated name in the current working directory).
If RDONLY, file must already exist.
If file already exists, record lengths must be consistent.
... INTEGER JDEV, KDEV, LDEV, MDEV INTEGER GETDFILE ... JDEV = GETDFILE( 'AFILE, .TRUE. , .TRUE. , 512, 'me' ) ! read-only formatted KDEV = GETDFILE( 'BFILE, .TRUE. , .FALSE., 512, 'me' ) ! read-only unformatted LDEV = GETDFILE( 'CFILE, .FALSE., .TRUE. , 512, 'me' ) ! read-write formatted MDEV = GETDFILE( 'DFILE, .FALSE., .FALSE., 512, 'me' ) ! read-write unformatted ... IF ( JDEV .LT. 0 ) THEN ! error opening AFILE: deal with it ... END IF ...etc... ...
... #include "iodecl3.h" ... integer jdev ; if ( 0 > ( jdev = getdfilec( "AFILE", 1, 1, 512, "me from C" ) ) ) { /* oops -- attempt to open file with logical name AFILE failed */ } ...
To: Models-3/EDSS I/O API: The Help Pages