<div dir="ltr">Dave<div><br></div><div>Thanks. And I'll bring this up to Russ and the crew at Unidata!</div><div><br></div><div>We'll test.</div><div><br></div><div>Gerry</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 23, 2015 at 12:49 AM, David Brown <span dir="ltr"><<a href="mailto:dbrown@ucar.edu" target="_blank">dbrown@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Gerry,<br>
I have a work-around fix for you, which is to change the line:<br>
<span class=""><br>
var_mod = new((/1,dimz,dimy,dimx/),"float")<br>
</span>to<br>
var_mod = new((/1,dimz,dimy,dimx/),"float","No_FillValue")<br>
<br>
Alternately you could say<br>
delete(var_mod@_FillValue)<br>
after the 'new' statement.<br>
<br>
The issue is that NCL creates _FillValue attributes for variables by<br>
default, and these get propagated when the variable is written to a<br>
file. And while coordinates and most attributes are not passed along<br>
when you do a value-only assignment (using (/ .../) syntax), the<br>
_FillValue is. This was never a problem with traditional NetCDF.<br>
<br>
But in NetCDF4 it seems the _FillValue attribute can only be written<br>
when "the file is still in initial define mode" (according to<br>
<a href="http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c/nc_005fput_005fatt_005f-type.html#nc_005fput_005fatt_005f-type" rel="noreferrer" target="_blank">http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c/nc_005fput_005fatt_005f-type.html#nc_005fput_005fatt_005f-type</a>).<br>
<br>
I think this means that _FillValue attributes cannot be added to<br>
variables that did not have them originally. We will need to account<br>
for this in NCL, but in the meantime you can make things work by<br>
eliminating the _FillValue attribute from the variable you are using<br>
to replace the original QRAIN variable in the file.<br>
<br>
Hope this helps.<br>
-dave<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
On Mon, Jun 22, 2015 at 5:41 PM, David Brown <<a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a>> wrote:<br>
> Hi Gerry,<br>
> I have been able to duplicate this seg fault and I am looking into it now.<br>
> -dave<br>
><br>
> On Mon, Jun 22, 2015 at 4:14 PM, Gerry Creager - NOAA Affiliate<br>
> <<a href="mailto:gerry.creager@noaa.gov">gerry.creager@noaa.gov</a>> wrote:<br>
>> David<br>
>><br>
>> Looks like it may not have been fixed quite yet. Mary sent me a version and<br>
>> I finally fooled the system into working today, when testing began. The<br>
>> short script included, inline below, can be run against the netcdf (wrfout)<br>
>> I uploaded recently (advise if I need to upload it again), results in a seg<br>
>> fault.<br>
>><br>
>><br>
>> ;=============<br>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"<br>
>> ;=============<br>
>> begin<br>
>><br>
>> dimx = 225<br>
>> dimy = 225<br>
>> dimz = 55<br>
>><br>
>> a = addfile("<a href="http://wrfinput_d02.nc" rel="noreferrer" target="_blank">wrfinput_d02.nc</a>", "w")<br>
>> var_orig=a->QRAIN<br>
>> var_mod = new((/1,dimz,dimy,dimx/),"float")<br>
>> var_mod = 5.<br>
>><br>
>> print(dimsizes(var_orig))<br>
>> print(dimsizes(var_mod))<br>
>><br>
>> a->QRAIN = (/var_mod/)<br>
>><br>
>> end<br>
>><br>
>><br>
>> On Mon, Jun 8, 2015 at 9:00 PM, David Brown <<a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a>> wrote:<br>
>>><br>
>>> Dustan and Gerry,<br>
>>> This issue relating to writing a variable with chunking in an existing<br>
>>> NetCDF4 file has been fixed. Also a secondary issue involving<br>
>>> re-writing existing variable attributes has been addressed as well.<br>
>>> Let us know if you need a version with these fixes and we will try to<br>
>>> accommodate you as soon as possible.<br>
>>> Thanks for letting us know of this problem.<br>
>>> -dave<br>
>>><br>
>>><br>
>>> On Wed, Jun 3, 2015 at 8:50 AM, David Brown <<a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a>> wrote:<br>
>>> > Hi Dustin and Gerry,<br>
>>> > I have confirmed there is a problem. It has been partially but not<br>
>>> > completely fixed in the development version of the code. I am looking<br>
>>> > into the remaining issue and will let you know when it has been fixed.<br>
>>> > -dave<br>
>>> ><br>
>>> > On Tue, Jun 2, 2015 at 10:34 AM, Gerry Creager - NOAA Affiliate<br>
>>> > <<a href="mailto:gerry.creager@noaa.gov">gerry.creager@noaa.gov</a>> wrote:<br>
>>> >> Additional information: If we do an addfile("<filename>","r"), we can<br>
>>> >> open<br>
>>> >> and read the file. If we use "w", well, we can open the file but<br>
>>> >> assigning<br>
>>> >> an existing variable to an internal variable fails on the assign (var =<br>
>>> >> a->QRAIN). Of course, because it fails there, we can't see if it'd also<br>
>>> >> fail<br>
>>> >> on write.<br>
>>> >><br>
>>> >> Thanks<br>
>>> >> Gerry<br>
>>> >><br>
>>> >> On Mon, Jun 1, 2015 at 7:15 PM, Gerry Creager - NOAA Affiliate<br>
>>> >> <<a href="mailto:gerry.creager@noaa.gov">gerry.creager@noaa.gov</a>> wrote:<br>
>>> >>><br>
>>> >>> I've started looking at this with Dusty. Appreciate any thought you<br>
>>> >>> might<br>
>>> >>> have as to why we're failing.<br>
>>> >>><br>
>>> >>> I've uploaded the input file (wrfinput_d02) to the FTP incoming site.<br>
>>> >>> I'm<br>
>>> >>> testing with the script:<br>
>>> >>><br>
>>> >>> var = "QRAIN"<br>
>>> >>> print(var)<br>
>>> >>> a=addfile("<a href="http://wrfinput_d02.nc" rel="noreferrer" target="_blank">wrfinput_d02.nc</a>", "w")<br>
>>> >>> var_orig=a->QRAIN<br>
>>> >>> print(var_orig)<br>
>>> >>><br>
>>> >>><br>
>>> >>> The result looks like:gerry@loki:~/NEWSe/NCL> ncl test.ncl<br>
>>> >>> Copyright (C) 1995-2015 - All Rights Reserved<br>
>>> >>> University Corporation for Atmospheric Research<br>
>>> >>> NCAR Command Language Version 6.3.0<br>
>>> >>> The use of this software is governed by a License Agreement.<br>
>>> >>> See <a href="http://www.ncl.ucar.edu/" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/</a> for more details.<br>
>>> >>><br>
>>> >>><br>
>>> >>> Variable: var<br>
>>> >>> Type: string<br>
>>> >>> Total Size: 8 bytes<br>
>>> >>> 1 values<br>
>>> >>> Number of Dimensions: 1<br>
>>> >>> Dimensions and sizes: [1]<br>
>>> >>> Coordinates:<br>
>>> >>> (0) QRAIN<br>
>>> >>> fatal:["NclNetCDF4.c":3073]:NclNetCDF4.c: Error in nc_def_var_chunking<br>
>>> >>> in<br>
>>> >>> file (<a href="http://wrfinput_d02.nc" rel="noreferrer" target="_blank">wrfinput_d02.nc</a>) for writing, at line: 3073<br>
>>> >>><br>
>>> >>> line 3074 of NclNetCDF4.c: NetCDF: Attempt to define var properties,<br>
>>> >>> like<br>
>>> >>> deflate, after enddef.<br>
>>> >>><br>
>>> >>><br>
>>> >>> On Fri, May 29, 2015 at 8:54 PM, Dustan Wheatley - NOAA Affiliate<br>
>>> >>> <<a href="mailto:dustan.wheatley@noaa.gov">dustan.wheatley@noaa.gov</a>> wrote:<br>
>>> >>>><br>
>>> >>>> I am trying to overwrite a netcdf4 file analogous to what is shown at<br>
>>> >>>> <a href="http://www.ncl.ucar.edu/Applications/change_netCDF.shtml" rel="noreferrer" target="_blank">http://www.ncl.ucar.edu/Applications/change_netCDF.shtml</a>. In the<br>
>>> >>>> attached<br>
>>> >>>> ncl script, I open the file to be modified at line 35 and attempt the<br>
>>> >>>> modification at line 73 (with a lot of calculations in between).<br>
>>> >>>> While I<br>
>>> >>>> have double-checked that the modified field (var_mod) has the same<br>
>>> >>>> dimensionality as the original variable (QRAIN), I am still get a<br>
>>> >>>> segmentation fault/core dump. Never had this problem when I tried to<br>
>>> >>>> manipulate netcdf3 files. Could it possibly be related to the<br>
>>> >>>> netcdf4<br>
>>> >>>> compression? It’s possible I may be trying to do something that’s no<br>
>>> >>>> longer<br>
>>> >>>> possible.<br>
>>> >>>><br>
>>> >>>> Thanks in advance for any suggestions.<br>
>>> >>>><br>
>>> >>>> -Dusty Wheatley<br>
>>> >>>><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>
>>> >>><br>
>>> >>><br>
>>> >>><br>
>>> >>> --<br>
>>> >>> Gerry Creager<br>
>>> >>> NSSL/CIMMS<br>
>>> >>> <a href="tel:405.325.6371" value="+14053256371">405.325.6371</a><br>
>>> >>> ++++++++++++++++++++++<br>
>>> >>> “Big whorls have little whorls,<br>
>>> >>> That feed on their velocity;<br>
>>> >>> And little whorls have lesser whorls,<br>
>>> >>> And so on to viscosity.”<br>
>>> >>> Lewis Fry Richardson (1881-1953)<br>
>>> >><br>
>>> >><br>
>>> >><br>
>>> >><br>
>>> >> --<br>
>>> >> Gerry Creager<br>
>>> >> NSSL/CIMMS<br>
>>> >> <a href="tel:405.325.6371" value="+14053256371">405.325.6371</a><br>
>>> >> ++++++++++++++++++++++<br>
>>> >> “Big whorls have little whorls,<br>
>>> >> That feed on their velocity;<br>
>>> >> And little whorls have lesser whorls,<br>
>>> >> And so on to viscosity.”<br>
>>> >> Lewis Fry Richardson (1881-1953)<br>
>>> >><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>
>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Gerry Creager<br>
>> NSSL/CIMMS<br>
>> <a href="tel:405.325.6371" value="+14053256371">405.325.6371</a><br>
>> ++++++++++++++++++++++<br>
>> “Big whorls have little whorls,<br>
>> That feed on their velocity;<br>
>> And little whorls have lesser whorls,<br>
>> And so on to viscosity.”<br>
>> Lewis Fry Richardson (1881-1953)<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Gerry Creager<div>NSSL/CIMMS</div><div>405.325.6371</div><div>++++++++++++++++++++++</div><div><div>“Big whorls have little whorls,</div><div>That feed on their velocity; </div><div>And little whorls have lesser whorls, </div><div>And so on to viscosity.” </div><div>Lewis Fry Richardson (1881-1953)</div></div></div></div>
</div>