GETEFILE()

Fortran version:

    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

C version:

    int getefilec( const char          * fname ,
                   int                   rstatus,
                   int                   fstatus,
                   const char          * pname )

See also:

GETDFILE() for direct access files instead of sequential files, and PROMPTFFILE(), a wrapper around GETEFILE() that prompts the user for the file's logical name.

Summary:

Gets value of logical name LNAME from the environment, checks for existence of a file whose file name is that value, then opens the file as a Fortran sequential file on according to the LOGICAL flags RDONLY (open for read-only iff TRUE, read/write if FALSE) and FMTFLAG (formatted iff TRUE, else unformatted).

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.

Preconditions:

#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.

Fortran Usage:

    ...
    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...
    ...

C Usage:

    ...
    #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 */
        }
    ...


Previous: GETDFILE

Next: GETMENU

Up: Utility Routines

To: Models-3/EDSS I/O API: The Help Pages