wrong results somehow related to addfiles

From: Keith Lindsay <klindsay_at_nyahnyahspammersnyahnyah>
Date: Fri, 19 Jun 2009 15:29:03 -0600 (MDT)

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




_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Fri Jun 19 2009 - 15:29:03 MDT

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