<div dir="ltr"><div><div>Well, you have to do better than "... but got an error:".<br>ncl-tal wants the error message?<br></div><br></div><div>===<br>Im order to use the way ypu were wriying to the file would require that you had, apriori, defined the variable for the file via (say)<br> <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/filevardef.shtml">http://www.ncl.ucar.edu/Document/Functions/Built-in/filevardef.shtml</a><br>Then you could write into the predefined locations.<br><br><br></div><div>===<br><br></div><div>The following is easier. It uses the simple method to write netCDF:<br><br></div><div>      <a href="http://www.ncl.ucar.edu/Applications/method_1.shtml" target="_blank">http://www.ncl.ucar.edu/<wbr>Applications/method_1.shtml</a><br><br>=======<br> diri = "./"<br> fili = "wrfchemi_00z_d01_pow_Oct.nc"<br> a   = addfile(diri+fili,"r")<br><br> SO2 = a->E_SO2(:,0,:,:) ;;;;;EXTRACTING THE SURFACE EMISSIONS<br> printVarSummary(SO2)<br><br> dimSO2 = dimsizes(SO2)<br> print(dimSO2)<br><br> ntim  = dimSO2(0)<br> nlat  = dimSO2(1)<br> mlon  = dimSO2(2)<br> klev  = 8<br><br>;;NOW PARTITIONING INTO 8 LEVELS<br></div><div>;;E_SO2 MUST BE PRE-ALLOCATED <br><br></div><div> E_SO2 = new((/ntim,klev,nlat,mlon/),<wbr>typeof(SO2),getVarFillValue(<wbr>SO2))<br> E_SO2(:,0,:,:) = 0.0 * SO2<br> E_SO2(:,1,:,:) = 0.3 * SO2<br> E_SO2(:,2,:,:) = 0.3 * SO2<br> E_SO2(:,3,:,:) = 0.1 * SO2<br> E_SO2(:,4,:,:) = 0.1 * SO2<br> E_SO2(:,5,:,:) = 0.1 * SO2<br> E_SO2(:,6,:,:) = 0.05 * SO2<br> E_SO2(:,7,:,:) = 0.05 * SO2<br><br> copy_VarMeta(SO2, E_SO2)<br> printVarSummary(E_SO2)<br><br>;; add more meta data<br><br> lev           = ispan(1,klev,1)  ; ??????<br> lev!0        = "lev"<br> lev@long_name = "level"<br> lev@units    = "..."<br><br> E_SO2!1   = "lev"   ; add coordinate variable<br> E_SO2&lev = lev<br><br> E_SO2@long_name = "artificial: "+SO2@long_name<br> printVarSummary(E_SO2)<br><br> ;=============================<wbr>====<br> diro = "./"<br> filo = "<a href="http://dummy.nc" target="_blank">dummy.nc</a>"<br> ptho = diro+filo<br><br></div></div>