[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20021216: Is utopen open?


> To: <address@hidden>
> From: "Tony Simmers" <address@hidden>
> Subject: Is utopen open?
> Organization: MetService

The above message contained the following:

> Is there a way to tell if the udunits library has already been initialised?

Not really.  It would be pretty simple, however, to add a utisopen()
function to the API.  Just add the following

     *  Indicate if the units(3) package has been initialized.
     *  This function returns:
     *      0               if the units(3) package has not been initialized.
     *     !0               if the units(3) package has been initialized.
        return initialized;

     * FORTRAN interface to the above function.

to the file "lib/utlib.c" -- say, after the utOpen() function. Then,
rebuild and reinstall the package. From a Fortran-77 program, you would
then write

    if (utisopen()) begin

or something similar (my Fortran's pretty rusty).

> In a unit converting subroutine I would like to be able to check whether the
> unit definitions etc have been opened, and if not, open them.  At the moment
> a message like
> udunits(3): Already initialized from file ..." is printed out, since the
> utopen routine returns a zero status even though it is concerned enough to
> print a message.
> Alternatively, how much overhead is involved in opening then closing udunits
> many times?

The database would have to be parsed every time.  I'd add the utisopen()
function, instead.

Steve Emmerson   <http://www.unidata.ucar.edu>

NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.