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

Re: 970512: ncvarid call



>To: address@hidden
>cc: address@hidden
>From: address@hidden (Carrie Gonzalez)
>Subject: ncvarid call
>Organization: .
>Keywords: 199705122122.PAA29600

Hi Carrie,

> I have a question.  Is the call to ncvarid a costly one, in terms of speed?
> 
> I will be looping over the same set of variables n-many times, where n
> will vary.  I thought to make the call once for each variable and to
> save this value in a structure, but is the storage space vs. speed
> really an issue?  If not, I will just call ncvarid each time.

The call to ncvarid involves no I/O, so it is relatively fast.  The
library just does a linear search through an in-memory table of the
variable names in the associated open netCDF file and returns when it
finds a match.

Therefore, the only conditions under which the call would be expensive
are if you have a large number of variables or if the variable names are
very long.  In either of these cases, it might be worth it to cache the
varids.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu