Re: Is there a bug for NCL 5.1.0?

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu, 26 Mar 2009 17:57:40 -0600

Hi Xuguang,

Thanks for reporting this bug. I have just checked in a fix and I
will try to explain when it occurs and also a workaround.

This bug is limited to "cat" mode aggregation where the aggregated
dimension has only a single element in the first file in the list.
The "time" dimension in the case of your files meets this condition.
The bug was that if the first "chunk" of the aggregation contains
only a single element, then it initially has a 'SCALAR' flag attached
to it. In the outgoing aggregated variable this flag is not being
changed to indicate that it is now multi-dimensional. The consequence
is that, under some conditions (but not all), when the variable gets
assigned it is treated as a scalar (i.e. all values of the target
variable are given the value of the first element).

I have corrected this in the latest check-in and we will be able to
provide you with a new binary soon. In the meantime, here is a work-
around that will put the correct values into your output NetCDF file.
I'm sorry if it seems a bit convoluted. Rather than reading the
'time' variable directly you need to read the coordinate variable of
a variable in the file, and you must read it into a previously
undefined variable.

    fns = systemfunc("ls 1948-??.nc")
    system("rm -f ./test.nc")

    in = addfiles(fns,"r")
    ListSetType(in,"cat")

    ncdf = addfile("test.nc","c")

    oro = in[:]->ORO ; read any multi-dimensional variable in the
file that has time as the leftmost dimension

    time = oro&time ; assign the coordinate 'time' to a previously
undefined variable

    print(time) ; Should be (/30, 61, 91, 122/)

    ncdf->time= time

    ; the output file should now contain the correct values for the
'time' variable.

Hope this helps.
  -dave

On Mar 22, 2009, at 11:53 PM, Xuguang Sun wrote:

>
> Dear everyone,
>
> I have a list of NetCDF files, like
>
> 1948-09.nc
> 1948-10.nc
> 1948-11.nc
> 1948-12.nc
>
> and I'd like to open them by addfiles function, and then write them
> to one file. The script is like the follow,
> +++++++++++++++++++
> ;*************************************************
> ; NCL tutorial script: vert_1.ncl
> ;************************************************
> 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"
> ;************************************************
> begin
> ;************************************************
> ; file handling
> ;************************************************
> fns = systemfunc("ls 1948-??.nc")
> in = addfiles(fns,"r") ; open netcdf file
> ListSetType(in,"cat") ;specify type of
> merge
>
> system("rm -f ./test.nc")
> ncdf=addfile("test.nc","c") ;out put file
> ncdf->time=in[:]->time
>
> print(in[:]->time)
> print(ncdf->time)
> end
> +++++++++++++++++++
>
> When I run this script under the environment of NCL 5.0.0, the
> output information is
>
> Copyright (C) 1995-2007 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.0.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> (0) 30
> (1) 61
> (2) 91
> (3) 122
>
>
> Variable: time (file variable)
> Type: double
> Total Size: 32 bytes
> 4 values
> Number of Dimensions: 1
> Dimensions and sizes: [ncl0 | 4]
> Coordinates:
> Number Of Attributes: 0
> (0) 30
> (1) 61
> (2) 91
> (3) 122
>
> but under the environment of NCL 5.1.0, it is
>
> Copyright (C) 1995-2009 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.1.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
>
>
> Variable: time (file variable)
> Type: double
> Total Size: 32 bytes
> 4 values
> Number of Dimensions: 1
> Dimensions and sizes: [time | 4]
> Coordinates:
> time: [ 30.. 122]
> Number Of Attributes: 2
> long_name : time
> units : days since 1948-09-01 00:00:00
> (0) 30
> (1) 61
> (2) 91
> (3) 122
>
>
> Variable: time (file variable)
> Type: double
> Total Size: 32 bytes
> 4 values
> Number of Dimensions: 1
> Dimensions and sizes: [time | 4]
> Coordinates:
> time: [ 30.. 30]
> Number Of Attributes: 2
> long_name : time
> units : days since 1948-09-01 00:00:00
> (0) 30
> (1) 30
> (2) 30
> (3) 30
>
> The problem is that the assignment fails in NCL 5.1.0 but succeeds
> in NCL 5.0.0, so why? Is that a bug?
>
> Thanks in advance.
>
> Best Regards
>
> Xuguang
>
> 2009-3-23
> ===================================
> SUN Xuguang
>
> School of Atmospheric Sciences, Nanjing University
> 22 Hankou Road, Nanjing 210093
> China
> Tel: +86-025-83597203 (O)
> Email: sunxg007_at_yahoo.com.cn
>
>
> ___________________________________________________________
> 好玩贺卡等你发,邮箱贺卡全新上线!
> http://card.mail.cn.yahoo.com/
> _______________________________________________
> 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 Thu Mar 26 2009 - 17:57:40 MDT

This archive was generated by hypermail 2.2.0 : Mon Apr 06 2009 - 10:23:30 MDT