This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>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