Re: wrong results somehow related to addfiles

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Fri, 19 Jun 2009 17:33:37 -0600

Hi Keith,

You are correct. There was another bug in the addfiles implementation
for 5.1.0 that was neglected in the release notes and the addfiles
doc. We will update the documentation and stress the importance of
upgrading.
For anyone curious about what this bug was: if the data extracted
from the first file of an aggregated variable reduced to a single
value, the returned variable was incorrectly internally tagged as a
scalar. When accessed without subscripts, this had the strange effect
of returning the proper number of elements but giving them all the
value of the first element (although, as the 'print' output shows,
not in every situation). Adding the subscript made it work correctly.
  -dave

On Jun 19, 2009, at 3:29 PM, Keith Lindsay wrote:

> Hi,
>
> I have discovered that an NCL script of mine is silently generating
> incorrect results. I've managed to boil it down to a fairly simple
> script and pair of netCDF files, which are attached.
>
> The incorrect results are with 5.1.0 on Linux and AIX. It's rather
> scary
> because there is no hint that things are going wrong.
>
> The script contents are:
>
> begin
> fnames = (/ "file01.nc", "file02.nc" /)
> fp = addfiles(fnames, "r")
> days = fp[:]->days
> print(days)
> days = days / sum(days)
> print(days)
> end
>
> The value printed with the first print are correct: 31 and 28. So it
> looks like the values are being read in correctly.
>
> However, after dividing the variable days by the sum of days, both
> values printed in the second print statement are identical. I get
> 0.5254237288135594 twice, instead of 0.5254237288135594 and
> 0.4745762711864407. Somehow the statement "days = days / sum(days)" is
> setting both values on the left hand side to the first value of the
> right hand side. When I experiment and add more files, the pattern is
> that the all values on the left hand sides are set to the first
> value of
> the right hand side.
>
> Additional info is that if there are 2 files with 2 timelevels
> each, the
> results of the division are correct, while if there are 4 files with 1
> timelevel each, the results are wrong.
>
> Also, if I change the statement "days = days / sum(days)" to
> "days(:) = days(:) / sum(days)", it works correctly.
>
> I'm not doing explicity striding, so I'm not sure if this is the same
> bug that is mentioned as being fixed in 5.1.1 with respect to
> addfiles.
>
> Keith
>
> --
> ******************************************************************
> Keith Lindsay http://www.cgd.ucar.edu/oce/klindsay/
> email: klindsay_at_ucar.edu phone: 303-497-1722 fax:
> 303-497-1700<multifile.ncl><file01.nc><file02.nc>_____________________
> __________________________
> 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 Fri Jun 19 2009 - 17:33:37 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 22 2009 - 15:36:10 MDT