; bsub -Is -q geyser -W 5:00 -n 1 -P P35171148 ncl< NCEP.ncl yr=15; year=yr+2000; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" setfileoption("bin","WriteByteOrder","BigEndian") OOroot="NCEP_RG_" dirIn="/glade/p/rda/data/ds090.0/2D/" ; grib input partial file names ifile = (/ "DLWRFsfc." , "DSWRFsfc." , "ICECsfc." , "LHTFLsfc." , \ "NLWRSsfc." , "NSWRSsfc." , "PRATEsfc." , "PRESmsl." , "SHTFLsfc." , \ "SPFHhag.2." , "TMPhag.2." , "TMPsfc." , "UFLXsfc." , "UGRDhag.10." , \ "VFLXsfc." , "VGRDhag.10." /) nvars=dimsizes (ifile) ; output file partial names ofile = (/ "dlw" , "dsw" , "icec" , "lhf" , "lw" , "sw" , "rain" , \ "pres2.5" , "shf" , "spfh2m" , "tmp2m_degC" , "tmp_degC" , "ustr" , \ "u10m" , "vstr" , "v10m" /) ; grib variable names ; note pres is on 2.5 degree grid vnames=(/"DLWRF_GDS4_SFC_ave6h" , "DSWRF_GDS4_SFC_ave6h" , \ "ICE_C_GDS4_SFC" , "LHTFL_GDS4_SFC_ave6h" , \ "NLWRS_GDS4_SFC_ave6h" , "NSWRS_GDS4_SFC_ave6h" , \ "PRATE_GDS4_SFC_ave6h" , "PRES_2_MSL" , \ "SHTFL_GDS4_SFC_ave6h" , "SPFH_GDS4_HTGL" , \ "TMP_GDS4_HTGL" , "TMP_GDS4_SFC" , \ "U_FLX_GDS4_SFC_ave6h" , "U_GRD_GDS4_HTGL" , \ "V_FLX_GDS4_SFC_ave6h" , "V_GRD_GDS4_HTGL" /) offset = (/0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -273.15, -273.15, 0, 0, 0, 0/) scalef = (/1, 1, 1, 1, 1, 1, .001, 1, 1, 1, 1, 1, 1, 1, 1, 1 /) do nv=0,nvars-1 fils=systemfunc("ls " + dirIn + year + "/" + ifile(nv) + yr + "*") nfils=dimsizes(fils) filbin= OOroot + ofile(nv) + "_" + year ; name of binary output file system("/bin/rm -f "+filbin) ; remove if it already exist print("variable: "+ifile(nv)) do nf=0,nfils-1 f = addfile (fils(nf)+".grb", "r") ; open print(""+fils(nf)) x = f->$vnames(nv)$ ; printVarSummary( x ) ; dimx = dimsizes( x ) ; print("dimx " + dimx) x = x*scalef(nv) + offset(nv) X = x(:,::-1,:) ; leftmost dimension is slowest varying ; dimx = dimsizes( X ) ; print("dimX " + dimx) fbindirwrite(filbin, X ) ; write to binary file delete( x ) delete ( X ) end do ; do nf end do ; do nv