syntax of reading netCDF4 files with groups

From: Wenshan Wang <wenshanw_at_nyahnyahspammersnyahnyah>
Date: Fri Jan 04 2013 - 16:15:52 MST

Dear all,

I am trying to read netCDF4 files with groups, following the example given
on the page of 'getfilegrpnames'.
Here it is:

f = *addfile* <>
("" , "r") ; could also have ccm, grb or hdf suffux
    gNames = *getfilegrpnames* (f) ; get names of all groups on file

    nNames = *dimsizes*
(gNames) ; number of groups on the file

    *print* <>
(nNames) ; print all group names on file

    do n=0,nNames-1 ; loop thru each group
       v = f->$gNames(n)$ ; read the group to memory

       dimv = *dimsizes*
       ; dimension size of the group
       rank = *dimsizes*
    ; rank [ie: number of dimensions]


       delete (v)
       delete (rank)
   end do

However, if I followed the example and use:

v = f->$gNames(n)$

It will result in:
(snc_LImon_bcc-csm1-1_historical_all-ens_clm) is not in file (fin)

Instead, if I use:
gg = fin=>$gn(j)$
dd = gg->$var(i)$
It can read what I want, but there is an error message:
fatal:NclNetCDF4: Could not reopen the file
for reading

So, what syntax should I use to read variables in groups?

Thank you very much!
Happy New Year!


ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Fri Jan 4 16:16:18 2013

This archive was generated by hypermail 2.1.8 : Mon Jan 07 2013 - 08:57:08 MST