SUBROUTINE NAMEVAL( LNAME, EQNAME )
CHARACTER*(*), INTENT(IN ) :: LNAME ! logical name to evaluate
CHARACTER*(*), INTENT( OUT) :: EQNAME ! value of LNAME from the environment
LNAME in the environment
and return it in EQNAME. This is not only used within the
I/O API internally (to deal with logical names of files) but
is also useful for retrieving the values of environment-variable
flags used to control the mode of operation of programs: since
you can call NAMEVAL() from anywhere, you don't have to make
special provisions to pass the flags from the program-initialization
module to the computational modules where they are actually used;
the computational modules can evalutate the flags directly.
Note that NAMEVAL() does not generate log-messages,
unlike the ENV*() routines below.
Returns EQNAME=LNAME in case of failure.
Case-sensitive for UNIX (but insensitive for VMS, where environment variable names themselves are case-insensitive).
See also specialized routines for getting DOUBLE PRECISION,
INTEGER, REAL, CHARACTER-STRING, or LOGICAL
values from the environment, respectively, together with
error-status and log-reporting:
ENVGET() (generic environment-value routine, I/O API-3.2 or later),
ENVLIST() (generic environment-list routine, I/O API-3.1 or later)
INTLIST(), REALIST(), STRLIST(): type specific environment-list routines,
ENVDBLE(),
ENVINT(),
ENVREAL(),
ENVSTR(),
ENVYN(); and
SETENVVAR() for setting environment variables from within a program
.
EQNAME long enough to hold LNAME's value.
Values with lengths of up to 65535 bytes for I/O API-3.2 or
later are supported. Values whose lengths exceed this limit will be
truncated safely. (NOTE: ...up to 512 bytes for I/O API-3.1 and
before; POSIX says that environment variables may have lengths this
long.)
...
CHARACTER*256 EQNAME
LOGICAL FLAG
...
CALL NAMEVAL( 'FOOFLAG', EQNAME ) ) THEN
IF ( EQNAME .EQ. 'FOOFLAG' ) THEN
!! ...NAMEVAL() failed, since EQNAME=LNAME. Maybe M3EXIT()?
FLAG = .FALSE.
ELSE
!! ...EQNAME contains value of environment variable "FOO"
CALL UPCASE( EQNAME ) ! makes it into ALLCAPS
IF ( EQNAME .EQ. 'ON' ) THEN
!! ...foo-flag should be set
FLAG = .TRUE.
ELSE
!! ...foo-flag should be turned off
FLAG = .FALSE.
END IF
END IF
...
To: Models-3/EDSS I/O API: The Help Pages