[1] You do not need to load libraries if you are not going
to use them.
[2] Don't use (:,:) when you are reading in an entire array.
precip = f-> CPRAT_P8_L1_GGA0_avg ; don't use (:,:) slower
[3] I don't know what you are doing here
do id = 1, 30
if ( id.lt.10 ) then id = 0 + "id" ; ??? 0id
do it = 0, 18, 6
if (it.lt.10) then it = 0 + "it"
Maybe use ... sprinti
http://www.ncl.ucar.edu/Document/Functions/Built-in/sprinti.shtml
yy = 2010
mm = 8
do dd=1,30
do hh=0,18,6
yymmddhh = yy + sprinti("%0.2i", mm) \
+ sprinti("%0.2i", dd) + sprinti("%0.2i", hh)
fname = flxf01.gdas."+yymmddhh+".grb2"
[4] Don't do this, it is inefficient when using entire array
avgprecip(:,:) = avgprecip(:,:) + precip(:,:)
avgprecip(:,:) = avgprecip(:,:)/30./4.
Use
avgprecip = avgprecip + f->CPRAT_P8_L1_GGA0_avg
avgprecip = avgprecip/30./4.
====
f = addfile
("/data14/cluo/WRFV3.2.1/WRFDATA/CFSR/201008/flxf01.gdas.2010080100.grb2",
"r")
precip = f-> CPRAT_P8_L1_GGA0_avg(:,:)
avgprecip = precip
avgprecip(:,:) = 0.
;;;do loop for month files
do id = 1, 30
if ( id.lt.10 ) then id = 0 + "id"
do it = 0, 18, 6
if (it.lt.10) then it = 0 + "it"
fname = "id" + "it"
f = addfile
("/data14/cluo/WRFV3.2.1/WRFDATA/CFSR/201008/flxf01.gdas.201008+"fname","r")
===
There is no file extension ".grb"
===
prcip = f->CPRAT_P8_L1_GGA0_avg(:,:) ; total precipitation
avgprecip(:,:) = avgprecip(:,:) + precip(:,:)
end do
end do
avgprecip(:,:) = avgprecip(:,:)/30./4.
end
On 11/09/2011 04:55 PM, Chao Luo wrote:
> Hi,
>
> I want to average one parameter in CFSR files. The file name like:
> gdas.2010080100.grb2, gads.2010080106.grbs, gads.2010080112.grb, gads.2010080118.grb2
> gdas.2010080200.grb2, gads.2010080206.grbs, gads.2010080212.grb, gads.2010080218.grb2
> ...
>
> The NCL script I wrote as follows, but it dosn't work. Any help is very apprciated!
>
> Thanks much!
>
> Chao
>
> ------------------------
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> begin
> f = addfile ("/data14/cluo/WRFV3.2.1/WRFDATA/CFSR/201008/flxf01.gdas.2010080100.grb2", "r")
> precip = f-> CPRAT_P8_L1_GGA0_avg(:,:)
> avgprecip = precip
> avgprecip(:,:) = 0.
>
> ;;;do loop for month files
>
> do id = 1, 30
> if ( id.lt.10 ) then id = 0 + "id"
> do it = 0, 18, 6
> if (it.lt.10) then it = 0 + "it"
> fname = "id" + "it"
> f = addfile ("/data14/cluo/WRFV3.2.1/WRFDATA/CFSR/201008/flxf01.gdas.201008+"fname","r")
> prcip = f->CPRAT_P8_L1_GGA0_avg(:,:) ; total precipitation
> avgprecip(:,:) = avgprecip(:,:) + precip(:,:)
> end do
> end do
> avgprecip(:,:) = avgprecip(:,:)/30./4.
> end
> ------------------------
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 9 17:52:58 2011
This archive was generated by hypermail 2.1.8 : Mon Nov 14 2011 - 10:41:55 MST