Re: Fwd: dimension size parameter error

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu, 7 Feb 2008 08:55:46 -0700 (MST)

"floor" (and "ceil") are C math library functions, and they were
probably added as a convenience for C programmers who are familiar
with them. Also, these functions return floats, which you sometimes
need (instead of an integer).

I mostly use these functions for truncation:

    w = 5.8
    x = 3.14
    y = floor(x) ; 3.0
    z = ceil(x) ; 4.0

--Mary

On Wed, 6 Feb 2008, Erik Noble wrote:

> Hi Mary.
> I understand. Thank you.
> I don't think that I would have figures this out unless I asked.
> When would the floor function be used, if its already implicit?
> -Erik
>
>
> On 2/6/08 6:10 PM, "Mary Haley" <haley_at_ucar.edu> wrote:
>
>>
>> Erik,
>>
>> You don't need to use a function here, if "ntimes" is already an
>> integer. Just use:
>>
>> nvtimes = (ntimes-1)/8
>>
>> When you do integer arithmetic on the right side of the equation, NCL
>> will return an integer. And, it will effectively do what "floor"
>> does for floats/doubles.
>>
>> Hence, "n = 5/3" will give you 1, "n = 2/3" will give you 0, etc.
>> "487/8 " will give you 60.
>>
>> --Mary
>>
>> On Wed, 6 Feb 2008, Erik Noble wrote:
>>
>>> Hi.
>>> I realize that this is a problem with the "floor' command. Any suggestions?
>>>
>>>
>>> ---------- Forwarded message ----------
>>> From: Erik Noble <enoble_at_giss.nasa.gov>
>>> Date: Feb 6, 2008 3:38 PM
>>> Subject: dimension size parameter error
>>> To: "ncl-talk_at_ucar.edu" <ncl-talk_at_ucar.edu>
>>>
>>>
>>> Hi.
>>> I am getting an error that says:
>>> "fatal:New: the dimension size parameter is the wrong type an integer
>>> value was expected"
>>>
>>> when i have this syntax in my code
>>> nvtimes = floor((ntimes-1)/8) ntimes = 487, nvtimes should equal "60"
>>> print(nvtimes)
>>> V925 = new((/nvtimes, 109, 139/),"float")
>>>
>>> But when I just state an integer, I do not get an error.
>>> nvtimes = 60
>>> print(nvtimes)
>>> V925 = new((/nvtimes, 109, 139/),"float")
>>>
>>> Variable: nvtimes
>>> Type: integer
>>> Total Size: 4 bytes
>>> 1 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes: [1]
>>> Coordinates:
>>> (0) 60
>>>
>>> How can I correct calling in the named dimension size parameter?
>>> -Erik
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk_at_ucar.edu
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>
>
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Feb 07 2008 - 08:55:46 MST

This archive was generated by hypermail 2.2.0 : Thu Feb 07 2008 - 08:58:57 MST