[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #DQA-136247]: globalattributes
- Subject: [netCDF #DQA-136247]: globalattributes
- Date: Mon, 30 Mar 2009 13:55:58 -0600
Hi Venkat,
> I have a netcdf which has 33 global attributes. The program I wrote in
> Fortran 90 showed the variable Nglobalatts as 33.
>
> But I am having difficulties to get the names and values of these
> attributes. I am able to handle dimensions and variables but not
> attributes.
>
> The only way I can get values for the global attributes is that I have
> to know the attribute name before I get the values. For now, I ran some
> other program ncbrowse to get the attribute names. I searched the f90
> interface userguide. I could not find the right routine to use. Can you
> please look into this problem?
To get the names of global attributes, you have to use
NF90_GLOBAL as a variable pseudo-ID. It's mentioned in the
F90 documentation in the Attributes Introduction section:
http://www.unidata.ucar.edu/netcdf/docs/netcdf-f90.html#Attributes
To find out how many global attributes there are, you can use
nf90_inquire(ncid, nDimensions, nVariables, nAttributes, unlimitedDimId,
formatNum)
where the "nAttributes" parameter returns the number of global attributes.
Then to find out the name of the Nth global attribute, use:
nf90_inq_attname(ncid, varid, attnum, name)
where varid is NF90_GLOBAL, attnum is N, and the name is returned
in the last parameter. Once you have the name, you can find the type and
length of the attribute by calling
nf90_inquire_attribute(ncid, varid, name, xtype, len, attnum)
again using NF90_GLOBAL as the varid. Finally to get the value(s) of the
attribute, use
nf90_get_att(ncid, varid, name, values)
Please let us know if this isn't clear.
--Russ
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: DQA-136247
Department: Support netCDF
Priority: Normal
Status: Closed