<div dir="ltr">Dave,<div><br></div><div>With 6.3.0 on both yellowstone and my desktop linux box, I get</div><div><div><br></div><div> Copyright (C) 1995-2015 - All Rights Reserved</div><div> University Corporation for Atmospheric Research</div><div> NCAR Command Language Version 6.3.0</div><div> The use of this software is governed by a License Agreement.</div><div> See <a href="http://www.ncl.ucar.edu/" target="_blank">http://www.ncl.ucar.edu/</a> for more details.</div><div>netcdf file_var_metadata_clobber {</div><div>variables:</div><div><span style="white-space:pre-wrap">        </span>float testvar ;</div><div><span style="white-space:pre-wrap">                </span>testvar:long_name = "long_name" ;</div><div><span style="white-space:pre-wrap">                </span>testvar:units = "units" ;</div><div>}</div><div>netcdf file_var_metadata_clobber {</div><div>variables:</div><div><span style="white-space:pre-wrap">        </span>float testvar ;</div><div><span style="white-space:pre-wrap">                </span>testvar:_FillValue = -99.f ;</div><div>}</div></div><div><br></div><div>Based on your output, it seems like this behavior is fixed in 6.3.1.</div><div><br></div><div>Keith</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 3, 2015 at 12:14 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">Well yes that would definitely be a bug, But that is not what I was<br>
seeing with your script (I ran it only on my Mac with my 6.3.1<br>
development version).<br>
<br>
Here is the output of your test script on my system:<br>
<br>
ncl file_var_metadata_clobber.ncl<br>
Copyright (C) 1995-2015 - All Rights Reserved<br>
University Corporation for Atmospheric Research<br>
NCAR Command Language Version 6.3.1<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>
netcdf file_var_metadata_clobber {<br>
variables:<br>
float testvar ;<br>
testvar:long_name = "long_name" ;<br>
testvar:units = "units" ;<br>
}<br>
<br>
netcdf file_var_metadata_clobber {<br>
variables:<br>
float testvar ;<br>
testvar:long_name = "long_name" ;<br>
testvar:units = "units" ;<br>
testvar:_FillValue = -99.f ;<br>
}<br>
<br>
The copy & paste seems to have removed the indentation, but otherwise<br>
this seems like the expected output to me.<br>
<br>
Is the script giving different results somewhere else?<br>
-dave<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Mon, Nov 2, 2015 at 7:28 PM, Keith Lindsay <<a href="mailto:klindsay@ucar.edu">klindsay@ucar.edu</a>> wrote:<br>
> Dave,<br>
><br>
> Thanks for your description of the subtleties of _FillValue and the<br>
> value-only assignment. Please note though that not only is the _FillValue<br>
> attribute getting added, the variable's pre-existing attributes are getting<br>
> lost. Do you consider this latter aspect a bug or feature? It is this that I<br>
> am more concerned about. Also, this removal of the pre-existing attributes<br>
> happens with NetCDF4 (for ncl version 6.3.0, but not 6.2.1) and not with<br>
> NetCDF3.<br>
><br>
> Keith<br>
><br>
> On Mon, Nov 2, 2015 at 5:13 PM, David Brown <<a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a>> wrote:<br>
>><br>
>> Hi Keith,<br>
>> I think that what you are seeing is actually documented (although<br>
>> poorly apparently) behavior. At least, if, as I am assuming from your<br>
>> test script, the only attribute that gets passed through the<br>
>> value-only assignment is the _FillValue. The NCL Reference Manual says<br>
>> this about value-only assignment:<br>
>><br>
>> "No dimension names, coordinate variables or attributes other than<br>
>> _FillValue are assigned. "<br>
>><br>
>> In fact the _FillValue is a special attribute that even values (as<br>
>> opposed to variables) in NCL carry around. And it is propagated even<br>
>> through value-only assignment. That is because it is considered an<br>
>> essential component of the value.<br>
>><br>
>> If in fact you are seeing other attributes get propagated let us know.<br>
>> Your test script only showed the _FillValue propagation as far as I<br>
>> could tell.<br>
>> -dave<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> On Mon, Nov 2, 2015 at 9:03 AM, Keith Lindsay <<a href="mailto:klindsay@ucar.edu">klindsay@ucar.edu</a>> wrote:<br>
>> > Hi,<br>
>> > Thanks Dennis. For other users that run into this behavior, a workaround<br>
>> > to<br>
>> > avoid it is to ensure that the variable on the rhs of the problematic<br>
>> > assignment does not have the _FillValue attribute. I.e.<br>
>> > if (isatt(tmpvar, "_FillValue")) then<br>
>> > delete(tmpvar@_FillValue)<br>
>> > end if<br>
>> > Keith<br>
>> ><br>
>> ><br>
>> > On Mon, Nov 2, 2015 at 8:44 AM, Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br>
>> >><br>
>> >> A JIRA ticket [ NCL-2302 ] has been opened. THX<br>
>> >><br>
>> >> On Mon, Nov 2, 2015 at 8:06 AM, Keith Lindsay <<a href="mailto:klindsay@ucar.edu">klindsay@ucar.edu</a>><br>
>> >> wrote:<br>
>> >> > Hi,<br>
>> >> ><br>
>> >> > I have come across an instance where I'm writing a variable to a file<br>
>> >> > and<br>
>> >> > the variable metadata in the file is getting overwritten, even though<br>
>> >> > I'm<br>
>> >> > using (/ ... /) on the right-hand side of the write to file<br>
>> >> > statement.<br>
>> >> > That<br>
>> >> > is, the statement<br>
>> >> > f->$varname$ = (/ tmpvar /)<br>
>> >> > is overwriting the metadata for the file variable $varname$ in the<br>
>> >> > file<br>
>> >> > pointed to by f. The attached script demonstrates the problem. This<br>
>> >> > seems<br>
>> >> > like an ncl bug to me.<br>
>> >> ><br>
>> >> > Details of my script that seem to matter are:<br>
>> >> > 1) the file is NetCDF4<br>
>> >> > 2) the file variable whose metadata is getting overwritten has been<br>
>> >> > defined<br>
>> >> > in the file but not written to yet<br>
>> >> > 3) the file variable whose metadata is getting overwritten does not<br>
>> >> > have<br>
>> >> > the<br>
>> >> > _FillValue attribute<br>
>> >> > 4) the variable on rhs of write to file statement has _FillValue<br>
>> >> > attribute<br>
>> >> ><br>
>> >> > The problem happens with ncl 6.3.0 on yellowstone. It does not happen<br>
>> >> > with<br>
>> >> > ncl 6.2.1, though with 6.2.1 the _FillValue gets added to the file<br>
>> >> > variable's metadata, which is unexpected to me.<br>
>> >> ><br>
>> >> > Keith<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>
>> > 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>
</div></div></blockquote></div><br></div>