NAMEVAL()
Fortran version:
SUBROUTINE NAMEVAL( LNAME, EQNAME )
CHARACTER*(*) LNAME ! logical name to evaluate
CHARACTER*(*) EQNAME ! value of LNAME from the environment
NO C version:
!! just do the system call getenv() directly !!
Summary:
This routine is a FORTRAN-callable shell around the
getenv() system call: find the value of
shell variable/logical name
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.
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
ENVDBLE(),
ENVINT(),
ENVREAL(),
ENVSTR(), and
ENVYN(), for
getting DOUBLE PRECISION, INTEGER, REAL, CHARACTER-STRING, or
LOGICAL values from the environment, respectively.
Preconditions:
EQNAME long enough to hold LNAME's value. Values with lengths
of up to 256 are supported. (NOTE: POSIX says that
environment variables may have lengths this long.)
Fortran Usage:
a program-control flag which has value "ON" when set
and which defaults to FALSE:
...
CHARACTER*256 EQNAME
LOGICAL FLAG
...
CALL NAMEVAL( 'FOOFLAG', EQNAME ) ) THEN
IF ( EQNAME( 1:TRIMLEN( EQNAME ) ) .EQ. 'FOOFLAG' ) THEN
C ...NAMEVAL() failed, since EQNAME=LNAME.
FLAG = .FALSE.
ELSE
C ...EQNAME contains value of environment variable "FOO"
CALL UPCASE( EQNAME ) ! makes it into ALLCAPS
IF ( EQNAME( 1:2 ) .EQ. 'ON' ) THEN
C ...foo-flag should be set
FLAG = .TRUE.
ELSE
C ...foo-flag should be turned off
FLAG = .FALSE.
END IF
END IF
...
C Usage:
don't; use system call getenv() directly.
Previous: M3WARN
Next: POLY
Up: Utility Routines
To: Models-3/EDSS I/O API: The Help Pages