<div dir="ltr">
<div>Hi NCL Community, <br></div><div><br></div><div>I am trying to
regrid the NCEP 4 km Stage-4 data to NLDAS grid (1/8th degree). But, I
get error while writing netcdf files output. <br></div><div>Error: fatal:Could not create (/<a href="http://20150101.nc">20150101.nc</a>)</div><div><br></div><div>I
have attached few files here: 1) ncl script that I used to complete
this task, 2) Screenshots of the PrintVarSummary error, printminmax, and
ncdump of Stage-4 file and NLDAS file.<br></div><div><br></div><div>Any suggestions are helpful. <br></div><div>Thanks,</div><div>Jetal<br></div><div>Below is the script: <br></div><div>
<div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(106,153,85)">;This script converts Stage-4 PRECIP data to NLDAS data grid</span></div><div><span style="color:rgb(197,134,192)">begin</span></div><div><span style="color:rgb(212,212,212)"> diri= </span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(215,186,125)">.</span><span style="color:rgb(206,145,120)">/"</span></div><div><span style="color:rgb(212,212,212)"> fili = </span><span style="color:rgb(220,220,170)">systemfunc</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(206,145,120)">"cd "</span><span style="color:rgb(212,212,212)">+diri+</span><span style="color:rgb(206,145,120)">" ; ls *</span><span style="color:rgb(215,186,125)">.</span><span style="color:rgb(206,145,120)">nc"</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">print</span><span style="color:rgb(212,212,212)">(fili) </span><span style="color:rgb(106,153,85)">; all file names</span></div><div><span style="color:rgb(212,212,212)"> nfili = </span><span style="color:rgb(220,220,170)">dimsizes</span><span style="color:rgb(212,212,212)">(fili)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">print</span><span style="color:rgb(212,212,212)">(nfili) </span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">do</span><span style="color:rgb(212,212,212)"> nf=</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)">, nfili</span><span style="color:rgb(181,206,168)">-1</span></div><div><span style="color:rgb(212,212,212)"> a = </span><span style="color:rgb(220,220,170)">addfile</span><span style="color:rgb(212,212,212)">(diri+fili(nf),</span><span style="color:rgb(206,145,120)">"r"</span><span style="color:rgb(212,212,212)">) </span><span style="color:rgb(106,153,85)">; Read all Stage-4 data files </span></div><div><span style="color:rgb(212,212,212)"> b = </span><span style="color:rgb(220,220,170)">addfile</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(206,145,120)">"201907</span><span style="color:rgb(215,186,125)">.</span><span style="color:rgb(206,145,120)">nc"</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(206,145,120)">"r"</span><span style="color:rgb(212,212,212)">) </span><span style="color:rgb(106,153,85)">; Read one file with NLDAS data grid lat/lon</span></div><br><div><span style="color:rgb(212,212,212)"> le = a->PRECIP(:,:)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(220,220,170)">any</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(220,220,170)">isnan_ieee</span><span style="color:rgb(212,212,212)">(le))) </span><span style="color:rgb(197,134,192)">then</span></div><div><span style="color:rgb(212,212,212)"> le@_FillValue = -</span><span style="color:rgb(181,206,168)">9999</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">replace_ieeenan</span><span style="color:rgb(212,212,212)">(le,le@_FillValue,</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> </span></div><div><span style="color:rgb(212,212,212)"> le!</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"PRECIP_y"</span></div><div><span style="color:rgb(212,212,212)"> le&PRECIP_y = a->LAT(:,</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> le!</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"PRECIP_x"</span><span style="color:rgb(212,212,212)"> </span></div><div><span style="color:rgb(212,212,212)"> le&PRECIP_x = a->LON(</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)">,:)</span></div><br><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">printVarSummary</span><span style="color:rgb(212,212,212)">(le)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">printMinMax</span><span style="color:rgb(212,212,212)">(le, </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)">)</span></div><br><div><span style="color:rgb(212,212,212)"> lat = b->lat</span></div><div><span style="color:rgb(212,212,212)"> lon = b->lon</span></div><br><div><span style="color:rgb(212,212,212)"> lon!</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"lon"</span></div><div><span style="color:rgb(212,212,212)"> lon@long_name = </span><span style="color:rgb(206,145,120)">"longitude"</span></div><div><span style="color:rgb(212,212,212)"> lon@units = </span><span style="color:rgb(206,145,120)">"degrees_east"</span></div><div><span style="color:rgb(212,212,212)"> lon&lon = lon</span></div><div><span style="color:rgb(212,212,212)"> lat!</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"lat"</span></div><div><span style="color:rgb(212,212,212)"> lat@long_name = </span><span style="color:rgb(206,145,120)">"latitude"</span></div><div><span style="color:rgb(212,212,212)"> lat@units = </span><span style="color:rgb(206,145,120)">"degrees_north"</span></div><div><span style="color:rgb(212,212,212)"> lat&lat = lat</span></div><br><div><span style="color:rgb(212,212,212)"> flh = </span><span style="color:rgb(220,220,170)">linint2_Wrap</span><span style="color:rgb(212,212,212)">(le&PRECIP_x, le&PRECIP_y, le, </span><span style="color:rgb(86,156,214)">False</span><span style="color:rgb(212,212,212)">, lon, lat, </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">printVarSummary</span><span style="color:rgb(212,212,212)">(flh)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">printMinMax</span><span style="color:rgb(212,212,212)">(flh, </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)">)</span></div><br><div><span style="color:rgb(212,212,212)"> flh@unit = </span><span style="color:rgb(206,145,120)">"mm/hr"</span></div><div><span style="color:rgb(212,212,212)"> flh@long_name = </span><span style="color:rgb(206,145,120)">"Precipitation"</span></div><div><span style="color:rgb(212,212,212)"> flh!</span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"lat"</span></div><div><span style="color:rgb(212,212,212)"> flh&lat = lat</span></div><div><span style="color:rgb(212,212,212)"> flh!</span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)"> = </span><span style="color:rgb(206,145,120)">"lon"</span></div><div><span style="color:rgb(212,212,212)"> flh&lon = lon</span></div><div><span style="color:rgb(212,212,212)"> </span></div><div><span style="color:rgb(212,212,212)"> dimNames = (/</span><span style="color:rgb(206,145,120)">"lat"</span><span style="color:rgb(212,212,212)">,</span><span style="color:rgb(206,145,120)">"lon"</span><span style="color:rgb(212,212,212)">/)</span></div><div><span style="color:rgb(212,212,212)"> dimSizes = (/</span><span style="color:rgb(220,220,170)">dimsizes</span><span style="color:rgb(212,212,212)">(lat),</span><span style="color:rgb(220,220,170)">dimsizes</span><span style="color:rgb(212,212,212)">(lon)/)</span></div><div><span style="color:rgb(212,212,212)"> dimUnlim = (/</span><span style="color:rgb(86,156,214)">False</span><span style="color:rgb(212,212,212)">,</span><span style="color:rgb(86,156,214)">False</span><span style="color:rgb(212,212,212)">/)</span></div><br><div><span style="color:rgb(212,212,212)"> diroutt = </span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(215,186,125)">..</span><span style="color:rgb(206,145,120)">/"</span></div><div><span style="color:rgb(212,212,212)"> iy = </span><span style="color:rgb(181,206,168)">2</span></div><div><span style="color:rgb(212,212,212)"> yyyy = </span><span style="color:rgb(181,206,168)">2015</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">do</span><span style="color:rgb(212,212,212)"> mm = </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)">,</span><span style="color:rgb(181,206,168)">12</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">do</span><span style="color:rgb(212,212,212)"> dd = </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)">,iy</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> (mm .eq. </span><span style="color:rgb(181,206,168)">1</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">3</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">5</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">7</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">8</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">10</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">12</span><span style="color:rgb(212,212,212)">) </span><span style="color:rgb(197,134,192)">then</span></div><div><span style="color:rgb(212,212,212)"> iy = </span><span style="color:rgb(181,206,168)">31</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">else</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> (mm .eq. </span><span style="color:rgb(181,206,168)">4</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">6</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">9</span><span style="color:rgb(212,212,212)">) .or. (mm .eq. </span><span style="color:rgb(181,206,168)">11</span><span style="color:rgb(212,212,212)">) </span><span style="color:rgb(197,134,192)">then</span></div><div><span style="color:rgb(212,212,212)"> iy = </span><span style="color:rgb(181,206,168)">30</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">else</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> (</span><span style="color:rgb(220,220,170)">mod</span><span style="color:rgb(212,212,212)">(yyyy,</span><span style="color:rgb(181,206,168)">4</span><span style="color:rgb(212,212,212)">) .eq. </span><span style="color:rgb(181,206,168)">0</span><span style="color:rgb(212,212,212)">) </span><span style="color:rgb(197,134,192)">then</span></div><div><span style="color:rgb(212,212,212)"> iy = </span><span style="color:rgb(181,206,168)">29</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">else</span></div><div><span style="color:rgb(212,212,212)"> iy = </span><span style="color:rgb(181,206,168)">28</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> (dd .lt. </span><span style="color:rgb(181,206,168)">10</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> date = </span><span style="color:rgb(206,145,120)">"0"</span><span style="color:rgb(212,212,212)"> + dd</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">else</span></div><div><span style="color:rgb(212,212,212)"> date = dd</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> (mm .lt. </span><span style="color:rgb(181,206,168)">10</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> month = </span><span style="color:rgb(206,145,120)">"0"</span><span style="color:rgb(212,212,212)"> + mm</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">else</span></div><div><span style="color:rgb(212,212,212)"> month = mm </span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">if</span><span style="color:rgb(212,212,212)"> </span></div><div><span style="color:rgb(212,212,212)"> </span></div><div><span style="color:rgb(212,212,212)"> filoutt = yyyy + month + date + </span><span style="color:rgb(206,145,120)">"</span><span style="color:rgb(215,186,125)">.</span><span style="color:rgb(206,145,120)">nc"</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">system</span><span style="color:rgb(212,212,212)">(</span><span style="color:rgb(206,145,120)">"rm -f "</span><span style="color:rgb(212,212,212)">+diroutt+filoutt)</span></div><div><span style="color:rgb(212,212,212)"> foutt= </span><span style="color:rgb(220,220,170)">addfile</span><span style="color:rgb(212,212,212)">(diroutt+filoutt,</span><span style="color:rgb(206,145,120)">"c"</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">setfileoption</span><span style="color:rgb(212,212,212)">(foutt,</span><span style="color:rgb(206,145,120)">"DefineMode"</span><span style="color:rgb(212,212,212)">,</span><span style="color:rgb(86,156,214)">True</span><span style="color:rgb(212,212,212)">)</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">filedimdef</span><span style="color:rgb(212,212,212)">(foutt,dimNames,dimSizes,dimUnlim)</span></div><br><div><span style="color:rgb(212,212,212)"> foutt->lat = lat</span></div><div><span style="color:rgb(212,212,212)"> foutt->lon = lon</span></div><div><span style="color:rgb(212,212,212)"> foutt->PRECIP = flh</span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">do</span><span style="color:rgb(212,212,212)"> </span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">do</span><span style="color:rgb(212,212,212)"> </span></div><div><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(197,134,192)">do</span></div><div><span style="color:rgb(197,134,192)">end</span></div></div></div>
</div>