[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 20021216: Is utopen open?
- Subject: Re: 20021216: Is utopen open?
- Date: Mon, 16 Dec 2002 09:41:02 -0700
Tony,
> 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.
*/
int
utIsInit()
{
return initialized;
}
/*
* FORTRAN interface to the above function.
*/
FCALLSCFUN0(INT,utIsInit,UTISOPEN,utisopen)
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
...
else
...
end
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.
Regards,
Steve Emmerson <http://www.unidata.ucar.edu>