Re: Zero length array, possible bug report

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 26 2012 - 14:19:42 MST

Hi Dave,
Thanks for the report. No it is not an intentional departure from the policy. We will look into this issue.
 -dave

On Dec 22, 2012, at 2:38 PM, Dave Allured - NOAA Affiliate wrote:

> NCL team,
>
> I'm reporting a fairly simple case where NCL creates a zero length
> memory array. See log below. According to previous discussions, NCL
> should not be able to do this, so it's a bug. On the other hand, are
> you starting to sneak in support for zero length arrays? ;-)
>
> I report this as a curiosity only, since I can probably protect myself
> with something like getfilevardimsizes.
>
> --Dave
>
> On Wed, Feb 8, 2012 at 3:52 PM, David Brown <dbrown@ucar.edu> wrote
> [IN PRIVATE REPLY]:
>> Hi Dave,
>>
>> The answer is that it should not be possible in NCL to get an empty array. As you note for the ind() function, the correct response for NCL is to return a single element array (which in NCL is equivalent to a scalar) containing a missing value. If you encounter a situation where an empty, 0-sized array is created, then it is a bug. Interestingly, just this week I encountered this bug in the case of an HDF4 file that contains only image data and no scientific data sets. Since NCL cannot currently read the image data, from its perspective this file contains no variables and no dimensions. The functions getfilevarnames and getvardims were both returning empty arrays in this situation. This has now been fixed such that they return a single missing element.
>> Hope that answers your question.
>> -dave
>
> mac11:~/translate/era 12> ncdump -h -s uwind.1979-2011.nc
> netcdf uwind.1979-2011 {
> dimensions:
> time = UNLIMITED ; // (0 currently)
> variables:
> float time(time) ;
> time:long_name = "time" ;
> time:units = "days since 1960-01-01" ;
> time:_Storage = "chunked" ;
> time:_ChunkSizes = 16384 ;
> --- ETC. ---
> // global attributes:
> :_Format = "netCDF-4 classic model" ;
>
> mac11:~/translate/era 13> ncl
> Copyright (C) 1995-2012 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.1.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> ncl 0> f=addfile("uwind.1979-2011.nc","r")
> ncl 1> time=f->time
> warning:FileReadVar: time contains a 0 length dimension
> warning:FileReadVar: time contains a 0 length dimension
> ncl 2> print (dimsizes(time))
> (0) 0
> ncl 3> printVarSummary (time)
>
> Variable: time
> Type: float
> Total Size: 0 bytes
> 0 values
> Number of Dimensions: 1
> Dimensions and sizes: [time | 0]
> Coordinates:
> time: [no elements]
> Number Of Attributes: 5
> long_name : time
> units : days since 1960-01-01
> calendar : gregorian
> increment : 4 times daily
> actual_range : ( 9.999e+30, -9.999e+30 )
> ncl 4>
> _______________________________________________
> 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 Dec 26 14:19:51 2012

This archive was generated by hypermail 2.1.8 : Fri Jan 04 2013 - 15:32:29 MST