<div dir="ltr"><div>Hi,</div><div><br></div><div>Are you certain that file does not already exist? The error message you are getting is one that results when using addfile() with "c" mode and the file already exists; ex:<br></div><div><br></div><div>$ touch <a href="http://foo.nc">foo.nc</a></div><div>$ Copyright (C) 1995-2019 - All Rights Reserved<br> University Corporation for Atmospheric Research<br> NCAR Command Language Version 6.6.2<br> The use of this software is governed by a License Agreement.<br> See <a href="http://www.ncl.ucar.edu/">http://www.ncl.ucar.edu/</a> for more details.<br>ncl 0> f=addfile("<a href="http://foo.nc">foo.nc</a>","c")<br>fatal:Could not create (<a href="http://foo.nc">foo.nc</a>)<br>ncl1></div><div><br></div><div>Rick<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Dec 4, 2021 at 1:30 AM JETAL SUTARIYA via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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" target="_blank">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>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>