<div dir="ltr"><div><div>Well, you have to do better than &quot;... but got an error:&quot;.<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 = &quot;./&quot;<br>  fili = &quot;wrfchemi_00z_d01_pow_Oct.nc&quot;<br>  a    = addfile(diri+fili,&quot;r&quot;)<br><br>  SO2  =  a-&gt;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         = &quot;lev&quot;<br>  lev@long_name = &quot;level&quot;<br>  lev@units     = &quot;...&quot;<br><br>  E_SO2!1     = &quot;lev&quot;    ; add coordinate variable<br>  E_SO2&amp;lev =  lev<br><br>  E_SO2@long_name = &quot;artificial: &quot;+SO2@long_name<br>  printVarSummary(E_SO2)<br><br>  ;=============================<wbr>====<br>  diro = &quot;./&quot;<br>  filo = &quot;<a href="http://dummy.nc" target="_blank">dummy.nc</a>&quot;<br>  ptho = diro+filo<br><br></div></div>