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* <http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml>
("X.nc" , "r") ; could also have ccm, grb or hdf suffux
gNames = *getfilegrpnames* (f) ; get names of all groups on file
nNames = *dimsizes*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>
(gNames) ; number of groups on the file
*print* <http://www.ncl.ucar.edu/Document/Functions/Built-in/print.shtml>
(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*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>(v)
; dimension size of the group
rank = *dimsizes*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>(dimv)
; rank [ie: number of dimensions]
[SNIP]
delete (v)
delete (rank)
end do
However, if I followed the example and use:
v = f->$gNames(n)$
It will result in:
fatal:["Execute.c":5709]:variable
(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
(~/data/cmip5/output/4plot/snd_LImon_all-model_historical_all-ens_clm.nc)
for reading
So, what syntax should I use to read variables in groups?
Thank you very much!
Happy New Year!
Best,
Wenshan
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
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