[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MAKE_ARRAY question



Hi Paul,

X = MAKE_ARRAY( n_pts, TYPE = 4 + KEYWORD_SET(DOUBLE), /NOZERO)

The above should get you the correct type of array (Double type is 5
while Float type is 4.)   I don't know if you can get into trouble with
simply passing the DOUBLE keyword along.  It works on this MAC (a float
is returned if DOUBLE = 0).

Ben

Paul van Delst wrote:
> 
> Hi there,
> 
> I want to create an array that by default should be FLOAT but can be specified as DOUBLE
> by the user as a keyword input to a function. Instead of the following:
> 
> FUNCTION my_func, n_pts, double = double
> 
>   IF ( KEYWORD_SET( double ) ) THEN $
>     x = MAKE_ARRAY( n_pts, /DOUBLE, /NOZERO ) $
>   ELSE $
>     x = MAKE_ARRAY( n_pts, /FLOAT, /NOZERO )
> 
> .....
> 
> END
> 
> can I rely on the fact that NO type keywords to MAKE_ARRAY means default FLOAT? I.e. :
> 
> FUNCTION my_func, n_pts, double = double
> 
>   x = MAKE_ARRAY( n_pts, DOUBLE = double, /NOZERO )
> 
> .....
> 
> END
> 
> The MAKE_ARRAY documentation does not specifically state that the default array created is
> a FLOAT. Does anyone know if this *is* documented anywhere so I'm not setting my function
> up (which I use *a lot*) to fall in a heap when IDL 5.5+ is released and RSI happened to
> decide a default LONG would be better?
> 
> Or is there some other natty way to do this?
> 
> Thanks for any help.
> 
> paulv
> 
> --
> Paul van Delst           A little learning is a dangerous thing;
> CIMSS @ NOAA/NCEP        Drink deep, or taste not the Pierian spring;
> Ph: (301)763-8000 x7274  There shallow draughts intoxicate the brain,
> Fax:(301)763-8545        And drinking largely sobers us again.
> paul.vandelst@noaa.gov                   Alexander Pope.

-- 
Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd.
W. Boothbay Harbor, ME 04575
btupper@bigelow.org