> This is probably a very simple question, but I cound not manage to figure
> out.
>
> I have to read data from a set of files named as
> olrpred_2002_2005_lead0.nc
> olrpred_2002_2005_lead1.nc
> olrpred_2002_2005_lead2.nc
> ...
> olrpred_2002_2005_lead10.nc
>
> and to store them to variables
> olrpred_lead0
> olrpred_lead1
> olrpred_lead2
> ...
> olrpred_lead10
>
> How can I use a 'do while' loop for this pupose?
> How do I assign the loop indices to the variable names?
=========================
To read the files ...
fils = systemfunc("ls olrpred_2002_2005_lead*.nc")
nfils = dimsizes(fils)
do nf=0,nfils-1
f = addfile (fils(nf), "r")
...
end do
not sure of the structure of your data ...
but if you want to put a variable dimensioned, say, (nlat x mlon) in an array
fils = systemfunc("ls olrpred_2002_2005_lead*.nc")
nfils = dimsizes(fils)
x = new ( (/nfils,nlat,mlon/), "float") ; create array to hold variables
do nf=0,nfils-1
f = addfile (fils(nf), "r")
x(nf,:,:) = f->X
...
end do
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat Feb 04 2006 - 07:59:55 MST
This archive was generated by hypermail 2.2.0 : Sun Feb 05 2006 - 19:54:15 MST