Re: getting env. variables in gfortran...
- From: "George N. White III" <aa056@xxxxxxxxxxxxxx>
- Date: Fri, 14 Apr 2006 08:41:38 -0300
On Thu, 13 Apr 2006, icksa1@xxxxxxxxx wrote:
Hi:
I'm trying to compile a code in gfortran that needs to know the values
of several environment variables...I was wondering if there was a
function, like getenv, that would return the values, something like...
path = getenv("PATH") or
call getenv("PATH",path)
Be careful what you ask for.
Rather than ask: "how can I do XXX in gfortan/ifort/icc/...?" it is generally better to ask: "is there a well documented, well engineered, and portable library that provides the functionality I need across a reasonable set of platforms?". This should lead you to consider using:
subroutine pxfgetenv( name, lenname, value, lenval, ierror )
c subroutine pxfgetenv() is described in section 4.6.1. the
c character length conventions are described in section 2.3.2.4.
c
c name [in] environment variable to be matched.
c lenname [in] length of name. if 0, trim trailing spaces.
c value [out] value of the variable.
c lenval [out] length of value. if 0, name was matched but no value.
c ierror [out] return code. 0 for success.
c EINVAL if not in the environment list.
c ETRUNC if value required truncation.
c -1 for other errors.
c
Google for "pxfgetenv" gives pages of hits (curiously, "libpxf" gets none). SGI's http://techpubs.sgi.com is a good place to read the IRIX man pages.
Gfortran almost certainly implements "getenv" functionality in some idiosyncratic, undocumented, and potentially unsafe (in the sense of not checking that the buffer is long enough to hold "$PATH") way. Walter Spector recently asked on this list for expressions of interest in his implementation of the POSIX bindings for Fortran, libpxf.
Ron Shepard also implemented some of the pxf functions. I've used his library wqith g77 on OS/2, Win16, and NeXtStep, assorted unixes, and linux. Now I'm using it with g95 on linux.
--
George N. White III <aa056@xxxxxxxxxxxxxx>
.
- Follow-Ups:
- Re: getting env. variables in gfortran...
- From: Steven G. Kargl
- Re: getting env. variables in gfortran...
- References:
- getting env. variables in gfortran...
- From: icksa1
- getting env. variables in gfortran...
- Prev by Date: Re: Derived types with allocatable arrays; more problems
- Next by Date: Re: Derived types with allocatable arrays; more problems
- Previous by thread: Re: getting env. variables in gfortran...
- Next by thread: Re: getting env. variables in gfortran...
- Index(es):
Relevant Pages
|