[netcdfgroup] Question about using nf90_inquire_variable

Hi,

I'm wondering if it is possible to use the nf90_inquire_variable() function to 
find information about global attributes in a similar way to 
nf90_inquire_attribute()?
For example, should it be possible to set varid to be NF90_GLOBAL to find the 
number of global attributes? i.e.:
call check(nf90_inquire_variable(ncid, NF90_GLOBAL, nAtts = numAttr))

The reason for this query is because we have a code block (snippet shown below) 
which prints some header information by looping over an array of variables.
It first calls nf90_inquire_variable to get the number of attributes and then 
uses this to get more details about the attributes by calling 
nf90_inq_attname() and nf90_inquire_attribute().
These latter two functions accept NF90_GLOBAL as "varid" but an error is thrown 
when this is used for varid in nf90_inquire_variable().
Is this the expected behaviour of nf90_inquire_variable? If so, can you 
recommend the best alternative way to get the number of global attributes - 
nf90_inquire() perhaps?

do idxVar = varBegin, numVars

varName = varInfoArray%varInfoArr(idxVar)%varName

if( varName .eq. 'UNDEFINED' ) then
varid = nf90_global
else
varid = varInfoArray%varInfoArr(idxVar)%varId
end if

call check( nf90_inquire_variable( ncid, varid, nAtts = numAttr )
...
...
do idxAttr = 1, numAttr

! Get the names & details of the attributes
call check( nf90_inq_attname( ncid, varid, idxAttr, attrName ))

call check( nf90_inquire_attribute( ncid, varid, attrName, netCDFType, 
numAttrValues ))
end do
...
end do

Best regards,
Jim

______________________________________________________________________

 Fujitsu Laboratories of Europe Limited
 Hayes Park Central, Hayes End Road, Hayes, Middlesex, UB4 8FE
 Registered No. 4153469

 This e-mail and any attachments are for the sole use of addressee(s) and
 may contain information which is privileged and confidential. Unauthorised
 use or copying for disclosure is strictly prohibited. The fact that this
 e-mail has been scanned by Trendmicro Interscan does not guarantee that
 it has not been intercepted or amended nor that it is virus-free.
  • 2015 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: