<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'><font face="arial, helvetica, sans-serif"><span style="font-size: 12pt;">Dear All,</span></font><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">I am working on temperature interpolation from 36km to 4km by ESMF_regrid, and want to write out the TEMP2 at new resolution,</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">unfortunately the temp2 attribute didn't write out in netcdf file, I have tried to define TEMP2 attribute by:</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><br></div><div><div><font face="arial, helvetica, sans-serif"> temp2!0 = "time"</font></div><div><font face="arial, helvetica, sans-serif"> temp2!1 = "lay"</font></div><div><font face="arial, helvetica, sans-serif"> temp2!2 = "lat"</font></div><div><font face="arial, helvetica, sans-serif"> temp2!3 = "lon"</font></div><div><font face="arial, helvetica, sans-serif"> temp2@long_name = "TEMP2"</font></div><div><font face="arial, helvetica, sans-serif"> temp2@units = "k"</font></div><div><font face="arial, helvetica, sans-serif"> temp2@var_desc = "temperature at 2 m"</font></div></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">and by function of filevarattdef. Both didn't work. </font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Thanks very much for and help or suggestions!</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Here is the script I used:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif"><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/esmf/ESMF_regridding.ncl"</div><div><br></div><div>begin</div><div><br></div><div> diri_36 = "/data11/cluo/CMAQv5.0.1/scripts/mcip4.1/36km/201107/data/"</div><div> diri_4 = "/data12/cluo/smoke3.6.5/data/ge_dat/"</div><div> namei_36 = "GRIDCRO2D_148x112_20110701"</div><div> namei_4 = "geo_em.d01_1332x1008.nc"</div><div><br></div><div> f1 = addfile(diri_36+namei_36,"r")</div><div><br></div><div>;output lat/lon</div><div> lat2d_36km = f1->LAT(0,0,:,:) ; (TSTEP, LAY, ROW, COL) , 36km</div><div> lon2d_36km = f1->LON(0,0,:,:) ; (TSTEP, LAY, ROW, COL) , 36km</div><div><br></div><div> printVarSummary (lon2d_36km)</div><div> printMinMax(lon2d_36km,True)</div><div><br></div><div><br></div><div> f2 = addfile(diri_4+namei_4,"r")</div><div>;input lat/lon</div><div><br></div><div> lat2d_4km = f2->XLAT_M(0,:,:) ; 4km</div><div> lon2d_4km = f2->XLONG_M(0,:,:) ; 4km</div><div><br></div><div> printVarSummary (lon2d_4km)</div><div> printMinMax(lon2d_4km,True)</div><div><br></div><div> name_in = "METCRO2D_148x112_20110701"</div><div><br></div><div> nlay = 1</div><div> ntime = 25</div><div><br></div><div> time = new((/ntime/),integer)</div><div> time = ispan(0,ntime-1,1)</div><div><br></div><div> f3 = addfile(diri_36+name_in,"r") temp2_36 = f3->TEMP2(:,:,:,:) ;(TSTEP, LAY, ROW, COL)</div><div> TFLAG = f3->TFLAG(:,0,:)</div><div> temp2_36@_FillValue = 9.999e+36</div><div><br></div><div> printVarSummary (temp2_36)</div><div> printMinMax(temp2_36,True)</div><div><br></div><div> diro = "/data11/cluo/cmaq4.6/data/post/smk31_post/"</div><div> filo = "out.nc" ; input file name</div><div> fl_nm_out = diro+filo</div><div> system ("/bin/rm -f "+fl_nm_out) ; Remove any pre-existing file</div><div> ncdf = addfile(fl_nm_out,"c")</div><div><br></div><div></div><div>;---Set up options for regridding</div><div> Opt = True</div><div> </div><div><div> Opt@SrcGridLat = lat2d_36km ; source grid</div><div> Opt@SrcGridLon = lon2d_36km</div><div> Opt@DstGridLat = lat2d_4km ; destination grid</div><div> Opt@DstGridLon = lon2d_4km</div><div><br></div><div> Opt@SrcRegional = True ; Necessary if grids</div><div> Opt@DstRegional = True ; are regional</div><div><br></div><div> Opt@InterpMethod = "bilinear" ; "patch", "conserve"</div><div><br></div><div> Opt@ForceOverwrite = True ; Optional, but recommended.</div><div> Opt@PrintTimings = True ; Optional.</div><div> Opt@Debug = True ; Optional</div></div><div><br></div><div><div> temp2 = ESMF_regrid(temp2_36,Opt) ; Do the regridding</div><div><br></div><div> temp2!0 = "time"</div><div> temp2!1 = "lay"</div><div> temp2!2 = "lat"</div><div> temp2!3 = "lon"</div><div> temp2@long_name = "TEMP2"</div><div> temp2@units = "k"</div><div> temp2@var_desc = "temperature at 2 m"</div><div><br></div><div> printVarSummary (temp2)</div><div> printMinMax(temp2,True)</div><div><br></div><div>; filevarattdef(ncdf,"temp2",temp2)</div></div><div><div> </div><div> ncdf->TFLAG =TFLAG</div><div> ncdf->temp2 = (/temp2/)</div><div><br></div><div> end</div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><br></div></div></body></html>