INTEGER FUNCTION GETEFILE( LNAME, RDONLY, FMTFLAG, CALLER )
CHARACTER*(*), INTENT(IN ) :: LNAME ! logical file name
LOGICAL , INTENT(IN ) :: RDONLY ! TRUE iff file is input-only
LOGICAL , INTENT(IN ) :: FMTFLAG ! TRUE iff file should be formatted
CHARACTER*(*), INTENT(IN ) :: CALLER ! caller-name for logging
int getefilec( const char * fname ,
int rstatus,
int fstatus,
const char * pname )
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 GETDFILE() for opening direct-access 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.
...
INTEGER JDEV, KDEV, LDEV, MDEV
INTEGER GETEFILE
...
JDEV = GETEFILE( 'AFILE', .TRUE. , .TRUE. , 'me' ) ! read-only formatted
KDEV = GETEFILE( 'BFILE', .TRUE. , .FALSE., 'me' ) ! read-only unformatted
LDEV = GETEFILE( 'CFILE', .FALSE., .TRUE. , 'me' ) ! read-write formatted
MDEV = GETEFILE( 'DFILE', .FALSE., .FALSE., '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 = getefilec( "AFILE", 1, 1, "me from C" ) ) )
{
/* oops -- attempt to open file with logical name AFILE failed */
}
...
To: Models-3/EDSS I/O API: The Help Pages