[ncl-talk] appending values

Dennis Shea shea at ucar.edu
Wed Nov 25 13:07:57 MST 2015


'n' is an integer.

Why are you using 'dble2flt' ?

if n=5, then 1/5 is 0

Change:
    func(l)=dble2flt(1/n)
To:
   func(l)=dble2flt(1d/n)   ; th1 1d is 1.0 double

-----
actually, there is no need to pre-allocate memory or any looping

   func = 1.0/ispan(0,n-1,1)   ; func is dynamically allocated.
   print(func)


On Wed, Nov 25, 2015 at 11:30 AM, Aditya Nalam <aditya.nalam at gmail.com> wrote:
> Hi all
> I was having trouble in appending values in a newly created array array
> The code written for it:
> n=21
> func=new(n,float)
>     l=0
>     do while(l.lt.n)
>     func(l)=dble2flt(1/n)
>     l=l+1
>     end do
> print(func)
>
> The output:
>
> Variable: func
> Type: float
> Total Size: 84 bytes
>             21 values
> Number of Dimensions: 1
> Dimensions and sizes:    [21]
> Coordinates:
> Number Of Attributes: 2
>   typeConversion_op_ncl :    double converted to float
>   _FillValue :    9.96921e+36
> (0)     0
> (1)     0
> (2)     0
> (3)     0
> (4)     0
> (5)     0
> (6)     0
> (7)     0
> (8)     0
> (9)     0
> (10)     0
> (11)     0
> (12)     0
> (13)     0
> (14)     0
> (15)     0
> (16)     0
> (17)     0
> (18)     0
> (19)     0
> (20)     0
>
> Where am i going wrong? Kindly clarify.
>
> Thank you very much
>
>
> --
> Regards
> Adithya Nalam
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list