PXFGETENV(3F) Last changed: 1-6-98
PXFGETENV - Returns a value for the environment name
SUBROUTINE PXFGETENV (name, lenname, value, lenval, ierror)
CHARACTER*n name, value
INTEGER lenname, lenval, ierror
UNICOS, UNICOS/mk, and IRIX systems
On IRIX systems, this routine is in libfortran.so which is linked by
default when compiling programs with the MIPSpro 7 Fortran 90 compiler
or when compiling programs with the -craylibs option to the MIPSpro
7.2 F77 compiler.
The PXFGETENV subroutine uses the getenv() function to search the
environment list for a name in a string of the form name=value.
If name matches a name in the list, the character representation of
value is stored in the value character argument and the number of
characters in value is stored in lenval. If the length of the value
to be placed in value is larger than the declared length of value, the
value string is truncated on the right and stored in value. The
nontruncated length is stored in lenval and ierror is set to etrunc.
If the length of the value is shorter than the declared size of value,
the value string is stored with left justification and filled with
blanks on the right. lenval is set to the shorter length of the value
string.
If name is found but has no value, blanks are stored in value and
lenval is set to zero. If name cannot be found, EINVAL is returned in
ierror.
When using the CF90 compiler or MIPSpro 7 Fortran 90 compiler on
UNICOS, UNICOS/mk, or IRIX systems, all arguments must be of default
kind unless documented otherwise. On UNICOS and UNICOS/mk, default
kind is KIND=8 for integer, real, complex, and logical arguments; on
IRIX, the default kind is KIND=4.
The following is a list of valid arguments for this routine:
name An input character variable or array element containing the
name of an environment variable.
lenname An input integer variable containing the length of name in
characters. If lenname is zero, the trailing blanks are
removed. The declared length of the input name is
decremented by the number of blanks removed. If lenname is
zero and name is all blanks, the input name is a null
string.
value An output character variable or array element containing the
value of the environment variable name.
lenval An output integer variable containing the length of value in
characters. If name is found but has no value, lenval is
zero and value contains all blanks to indicate a null
string. If the value representation is truncated to be
stored in value, lenval contains the nontruncated length of
value. If the value representation is shorter than the
length of value, lenval contains the shorter length.
ierror An output integer variable containing the status:
EINVAL If name is not in the environment list.
ETRUNC If the declared length of value is insufficient to
contain the string to be returned. The value of
name is truncated to fit in value, and lenval
contains the original length of the value of name
before truncation.
Zero getenv is successful (if name is found).
In this example, PXFGETENV searches for a string containing
SHELL=value.
program testpxf
character*24 namea, nameb
integer lena, lenb, ier
c set input arguments
ier = 0
lena=0
lenb=0
namea='SHELL'
nameb=' '
CALL PXFGETENV (namea, lena, nameb, lenb, ier)
print *,'TEST results:'
c print input arguments
print *,'namea=-',namea,'-'
print *,'lena=',lena
c print output arguments
print *,'nameb=-',nameb,'-'
print *,'lenb=',lenb
print *,'ier=',ier
end
If the string is found, it may return:
TEST results:
namea=-SHELL
lena=0
nameb=-/bin/csh
lenb=8
ier=0
getenv(3C)
Application Programmer's Library Reference Manual, publication SR2165,
for the printed version of this man page.
PXFGETENV(3F) Last changed: 1-6-98
PXFGETENV - Returns a value for the environment name
SUBROUTINE PXFGETENV (name, lenname, value, lenval, ierror)
CHARACTER*n name, value
INTEGER lenname, lenval, ierror
UNICOS, UNICOS/mk, and IRIX systems
On IRIX systems, this routine is in libfortran.so which is linked by
default when compiling programs with the MIPSpro 7 Fortran 90 compiler
or when compiling programs with the -craylibs option to the MIPSpro
7.2 F77 compiler.
The PXFGETENV subroutine uses the getenv() function to search the
environment list for a name in a string of the form name=value.
If name matches a name in the list, the character representation of
value is stored in the value character argument and the number of
characters in value is stored in lenval. If the length of the value
to be placed in value is larger than the declared length of value, the
value string is truncated on the right and stored in value. The
nontruncated length is stored in lenval and ierror is set to etrunc.
If the length of the value is shorter than the declared size of value,
the value string is stored with left justification and filled with
blanks on the right. lenval is set to the shorter length of the value
string.
If name is found but has no value, blanks are stored in value and
lenval is set to zero. If name cannot be found, EINVAL is returned in
ierror.
When using the CF90 compiler or MIPSpro 7 Fortran 90 compiler on
UNICOS, UNICOS/mk, or IRIX systems, all arguments must be of default
kind unless documented otherwise. On UNICOS and UNICOS/mk, default
kind is KIND=8 for integer, real, complex, and logical arguments; on
IRIX, the default kind is KIND=4.
The following is a list of valid arguments for this routine:
name An input character variable or array element containing the
name of an environment variable.
lenname An input integer variable containing the length of name in
characters. If lenname is zero, the trailing blanks are
removed. The declared length of the input name is
decremented by the number of blanks removed. If lenname is
zero and name is all blanks, the input name is a null
string.
value An output character variable or array element containing the
value of the environment variable name.
lenval An output integer variable containing the length of value in
characters. If name is found but has no value, lenval is
zero and value contains all blanks to indicate a null
string. If the value representation is truncated to be
stored in value, lenval contains the nontruncated length of
value. If the value representation is shorter than the
length of value, lenval contains the shorter length.
ierror An output integer variable containing the status:
EINVAL If name is not in the environment list.
ETRUNC If the declared length of value is insufficient to
contain the string to be returned. The value of
name is truncated to fit in value, and lenval
contains the original length of the value of name
before truncation.
Zero getenv is successful (if name is found).
In this example, PXFGETENV searches for a string containing
SHELL=value.
program testpxf
character*24 namea, nameb
integer lena, lenb, ier
c set input arguments
ier = 0
lena=0
lenb=0
namea='SHELL'
nameb=' '
CALL PXFGETENV (namea, lena, nameb, lenb, ier)
print *,'TEST results:'
c print input arguments
print *,'namea=-',namea,'-'
print *,'lena=',lena
c print output arguments
print *,'nameb=-',nameb,'-'
print *,'lenb=',lenb
print *,'ier=',ier
end
If the string is found, it may return:
TEST results:
namea=-SHELL
lena=0
nameb=-/bin/csh
lenb=8
ier=0
getenv(3C)
Application Programmer's Library Reference Manual, publication SR2165,
for the printed version of this man page.
[ Back ]
|