Re: [netcdfgroup] Question about using nf90_inquire_variable

Seems like your code should simply be changed to this, which seems fine,
you need the distinction between UNDEFINED and non-global anyway.

if( varName .eq. 'UNDEFINED' ) then

varid = nf90_global

... nf90_inquire(ncid, nAttributes=numAttr) ...

else

varid = varInfoArray%varInfoArr(idxVar)%varId

call check( nf90_inquire_variable( ncid, varid, nAtts = numAttr )

end if


... (delete first encountered line)


May I also suggest you this project, which eases the mingling of netcdf
creation etc. through a unified API, and all interaction through character
variables.

https://github.com/zerothi/ncdf


Disclaimer, I am the developer and uses it heavily in my development.




2015-07-14 16:13 GMT+00:00 <Jim.Enright@xxxxxxxxxxxxxx>:

> 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.
>
>
> _______________________________________________
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe,  visit:
> http://www.unidata.ucar.edu/mailing_lists/
>



-- 
Kind regards Nick
  • 2015 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: