1 |
; bsub -Is -q geyser -W 5:00 -n 1 -P P35171148 ncl< NCEP.ncl |
2 |
|
3 |
yr=15; |
4 |
year=yr+2000; |
5 |
|
6 |
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" |
7 |
setfileoption("bin","WriteByteOrder","BigEndian") |
8 |
OOroot="NCEP_RG_" |
9 |
dirIn="/glade/p/rda/data/ds090.0/2D/" |
10 |
|
11 |
; grib input partial file names |
12 |
ifile = (/ "DLWRFsfc." , "DSWRFsfc." , "ICECsfc." , "LHTFLsfc." , \ |
13 |
"NLWRSsfc." , "NSWRSsfc." , "PRATEsfc." , "PRESmsl." , "SHTFLsfc." , \ |
14 |
"SPFHhag.2." , "TMPhag.2." , "TMPsfc." , "UFLXsfc." , "UGRDhag.10." , \ |
15 |
"VFLXsfc." , "VGRDhag.10." /) |
16 |
nvars=dimsizes (ifile) |
17 |
|
18 |
; output file partial names |
19 |
ofile = (/ "dlw" , "dsw" , "icec" , "lhf" , "lw" , "sw" , "rain" , \ |
20 |
"pres2.5" , "shf" , "spfh2m" , "tmp2m_degC" , "tmp_degC" , "ustr" , \ |
21 |
"u10m" , "vstr" , "v10m" /) |
22 |
|
23 |
; grib variable names |
24 |
; note pres is on 2.5 degree grid |
25 |
vnames=(/"DLWRF_GDS4_SFC_ave6h" , "DSWRF_GDS4_SFC_ave6h" , \ |
26 |
"ICE_C_GDS4_SFC" , "LHTFL_GDS4_SFC_ave6h" , \ |
27 |
"NLWRS_GDS4_SFC_ave6h" , "NSWRS_GDS4_SFC_ave6h" , \ |
28 |
"PRATE_GDS4_SFC_ave6h" , "PRES_2_MSL" , \ |
29 |
"SHTFL_GDS4_SFC_ave6h" , "SPFH_GDS4_HTGL" , \ |
30 |
"TMP_GDS4_HTGL" , "TMP_GDS4_SFC" , \ |
31 |
"U_FLX_GDS4_SFC_ave6h" , "U_GRD_GDS4_HTGL" , \ |
32 |
"V_FLX_GDS4_SFC_ave6h" , "V_GRD_GDS4_HTGL" /) |
33 |
|
34 |
offset = (/0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -273.15, -273.15, 0, 0, 0, 0/) |
35 |
scalef = (/1, 1, 1, 1, 1, 1, .001, 1, 1, 1, 1, 1, 1, 1, 1, 1 /) |
36 |
|
37 |
do nv=0,nvars-1 |
38 |
fils=systemfunc("ls " + dirIn + year + "/" + ifile(nv) + yr + "*") |
39 |
nfils=dimsizes(fils) |
40 |
|
41 |
filbin= OOroot + ofile(nv) + "_" + year ; name of binary output file |
42 |
system("/bin/rm -f "+filbin) ; remove if it already exist |
43 |
|
44 |
print("variable: "+ifile(nv)) |
45 |
|
46 |
do nf=0,nfils-1 |
47 |
f = addfile (fils(nf)+".grb", "r") ; open |
48 |
print(""+fils(nf)) |
49 |
x = f->$vnames(nv)$ |
50 |
; printVarSummary( x ) |
51 |
; dimx = dimsizes( x ) |
52 |
; print("dimx " + dimx) |
53 |
x = x*scalef(nv) + offset(nv) |
54 |
X = x(:,::-1,:) ; leftmost dimension is slowest varying |
55 |
; dimx = dimsizes( X ) |
56 |
; print("dimX " + dimx) |
57 |
fbindirwrite(filbin, X ) ; write to binary file |
58 |
|
59 |
delete( x ) |
60 |
delete ( X ) |
61 |
|
62 |
end do ; do nf |
63 |
end do ; do nv |