On the original file, CO2 was type double (64 bits).
CO2 = f->CO2 ; double
You created:
CO2 = (/289.263, 289.263, 289.41739141755, 289.579855588959,
289.749383419994,\
....
533.483333333333/) ; float
which is type float (32 bits) which can handle 5-6 decimal places.
All the 'extra' precision is lost (truncated or rounded) to (say)
5 decimal places..
When you did
in->CO2=(/CO2/) ; float into double
you overwrote location reserved for 64-bits with 32 bit values.
It had to fill the spaces with something or, maybe
it used what remained before ... don't know.
Try with the 'd' suffix
O2 = (/289.263d, 289.263d, 289.41739141755d, 289.579855588959d,
289.749383419994d,\
....
533.483333333333d/) ; float
On 10/5/11 2:09 PM, Michael Notaro wrote:
> Try specifying as double.
> Maybe it defaulted as float.
>
>
> On Oct 5, 2011, at 3:06 PM, Madeleine Patterson wrote:
>
>> Hi,
>>
>> I am using the script on
>> http://www.ncl.ucar.edu/Applications/change_netCDF.shtml to overwrite
>> one value of a variable (i.e. just for one year).
>>
>> I change the value of this variable for one year to 478.919898945933,
>> and get the value 478.919891357422 when I check the file for the new
>> value (via ncdump).
>>
>> Similarly, the rest of the values for this variable have changed, e.g.
>>
>> in my script:
>>
>> CO2 = (/289.263, 289.263, 289.41739141755, 289.579855588959,
>> 289.749383419994,\
>> ....
>> 533.483333333333/)
>>
>>
>> But in the ncdump of the altered file (where I changed just one value
>> of this variable):
>>
>> CO2 = 289.263000488281, 289.263000488281, 289.417388916016,
>> ...
>> 533.483337402344, 533.483337402344, 533.483337402344 ;
>>
>> Can anyone tell me what is happening? And how I can fix the script so
>> that the overwritten variable has exactly the same values as the
>> original variable except for the value that my script wants to change?
>>
>> My script is included below...
>>
>> Thanks
>>
>> Madeleine.
>>
>>
>> **********************************************
>> **********************************************
>> begin
>>
>> ; loading libraries
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>>
>> ;*******************************************************************
>>
>> in = addfile("./ghgfile","w")
>>
>> CO2 = (/289.263, 289.263, 289.41739141755, 289.579855588959,
>> 289.749383419994,\
>>
>> ...
>> 533.483333333333/)
>>
>> in->CO2=(/CO2/)
>>
>> end
>> *****************************************************
>> *****************************************************
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 5 14:23:29 2011
This archive was generated by hypermail 2.1.8 : Sun Oct 09 2011 - 13:05:26 MDT