<div dir="ltr">Hi Sun,<div>If you do want to create a netCDF file for each month from your files that contain 12 months of data, I would use the netCDF operators:</div><div><br></div><div>; Note: Script not tested, check that the results are as you would expect.</div><div><br></div><div>begin</div><div><br></div><div>year = (/"2007","2008","2009","2010","2011","2012","2013"/)</div><div>varname = "MFLUX_GDS0_ISBL_S130"<br></div><div>diri = "/Users/spark/vertical/00_DATA/20_JRA-55/"<br></div><div>filo = "fcst_phy3m125.231_mflux."</div><div>do gg = 0,dimsizes(year)-1</div><div> <span style="font-size:12.8px">fili = "fcst_phy3m125.231_mflux."+</span><span style="font-size:12.8px">year(gg)+"01_"+year(gg)+"12. </span><span style="font-size:12.8px"><a href="http://allen136024.nc">allen136024.nc</a>"</span></div><div> do hh = 1,12</div><div> en = sprinti("%2.2i",hh)) </div><div> print("ncks -v "+varname+" -d time,"+(hh-1)+","+(hh-1)+" "+diri+fili+" "+filo+year(gg)+en+".nc")</div><div>; system("ncks -v "+varname+"-d time,"+(hh-1)+","+(hh-1)+" "+diri+fili+" "+diri+filo+year(gg)+en+".nc")</div><div> end do</div><div> print("Now done with year = "+year(gg))</div><div>end do</div><div><br></div><div>end</div><div><br></div><div>If the print statements look good, then you could uncomment out the system statement.</div><div><br></div><div>Hope that helps.. If not, or if I totally misunderstood what you are after, please respond to the ncl-talk email list and not to me personally.</div><div>Adam</div><div><br></div><div><br></div><div> </div><div> </div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 20, 2015 at 11:59 PM, mireiyue <span dir="ltr"><<a href="mailto:mireiyue@gmail.com" target="_blank">mireiyue@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Dear NCL users<div><br></div><div>I have a file it contains 12 months data (ec550aer_aero_NorESM1-M_historicalExt_r1i1p1_<b>201201-201212</b>.nc). I want to make file for each month. What nil function I should use? I tried to use reshape but It gives me </div><div>fatal:_NclBuildArray: each element of a literal array must have the same dimension sizes, at least one item doesn’t (near L30). If I made mistake in the script please help me what I did wrong or if I have to use other function.</div><div><br></div><div>I do appreciate any helps. </div><div><br></div><div>year = (/"2007","2008","2009","2010","2011","2012","2013"/)</div><div>diri = "/Users/spark/vertical/00_DATA/20_JRA-55/" ; path to file</div><div>do ii=0,6</div><div><br></div><div> fili = "fcst_phy3m125.231_mflux."+year(ii)+"01_"+year(ii)+"12.allen136024"</div><div> varname = "MFLUX_GDS0_ISBL_S130"</div><div> filenc = addfile (diri+fili+".nc", "r") ; entire file</div><div> mf = filenc->$varname$ ; (time, ver, lat, lon)</div><div><br></div><div> time =filenc->initial_time0</div><div> lev =filenc->lv_ISBL1</div><div> lat =filenc->g0_lat_2</div><div> lon =filenc->g0_lon_3</div><div> mf@_FillValue=1e+20</div><div><br></div><div>printVarSummary(mf)</div><div><br></div><div> ntim = dimsizes(time)</div><div> nlev = dimsizes(lev)</div><div> nlat = dimsizes(lat)</div><div> nlon = dimsizes(lon)</div><div> nyears = ntim/12</div><div><br></div><div><b> mfreshape = reshape(mf,(/nyears,12,nlev,nlat,nlon/)) :an error occurs here</b></div><div> printVarSummary(mfreshape) </div><div><br></div><div>Thank you</div><div>Sun-</div><div><br></div></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist, </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a> </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</div>