Re: problem with filedimdef function

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Sun Apr 03 2011 - 17:57:01 MDT

Donna,

Your original code (March 30) contains this:

    logical_FillValue = 0
    dimUnlim = new(ndims,"logical",logical_FillValue)

Assigning an *integer* to be the _FillValue for a *logical* is
undocumented usage, and bad practice (IMO). I am sure this was not
intentional. However, this was undoubtedly the source of your
original error. There are clues in your print(dimUnlim) below.

Either of the following is safe usage that should do exactly what
you want. Note that in both cases, there is no redefining of the
default _FillValue for type logical.

    dimUnlim = new(ndims,"logical")
    dimUnlim(:) = False ; clear the unlimited array
    dimUnlim(0) = True ; make "recordcount" the unlimited dimension
    filedimdef(fout,dimNames,dimSizes,dimUnlim)

With Rick B's syntax, using an array constructor:

    dimUnlim = (/True,False,False/)
    filedimdef(fout,dimNames,dimSizes,dimUnlim)

I want to suggest to the NCL team that any attempt to assign any
non-logical as the missing value of a logical variable be caught as
a type error, in new() or elsewhere. Thanks for your consideration.

--Dave

On 3/31/2011 10:49 AM, donna Cote wrote:
> Many thanks to Rick B! He suggested doing a print on dimSizes so I did
> that and the other vars used by filedimdef. The values all looked
> correct. Then, for the heck of it, tried this filedimdef statement and
>
> It is working!!! LOL
>
> filedimdef(fout,dimNames,dimSizes,(/False,False,False/))
>
> Why I tried that (just a whim) and why it works, I don't know!
> Still thanks guys!
>
> Donna
>
> Note: print(dimUnlim) shows:
>
> Variable: dimUnlim
> Type: logical
> Total Size: 12 bytes
> 3 values
> Number of Dimensions: 1
> Dimensions and sizes: [3]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : False
> False
> False
> False
>
>
> _______________________________________________
> 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 Sun Apr 3 17:57:11 2011

This archive was generated by hypermail 2.1.8 : Tue Apr 05 2011 - 09:01:21 MDT