Re: using environment variables in NCL script: arrays

From: Cathy Smith (NOAA Affiliate) <cathy.smith_at_nyahnyahspammersnyahnyah>
Date: Thu May 23 2013 - 08:35:49 MDT

Dave
The general idea works well. More specifically, the command should be as
below with the Perl calling code

$levelsstr="1000925850";
$ENV{'levelsstr'}=$levelsstr;

and in NCL

levels = stringtoint (str_split (getenv ("levelsstr"), " "))

Note slight syntax difference with the getenv and also I am using your latter suggested change of stringtoint instead of toint.

Thanks!

Cathy

On 5/22/13 5:03 PM, Dave Allured - NOAA Affiliate wrote:
> Cathy,
>
> In Perl, create a single long string containing numbers separated by
> spaces, e.g. "100 200 300". Assign this long string value to the
> environment variable. Other delimiters are possible, if space is not
> available for some reason.
>
> Then in NCL:
> levels = toint (str_split (getenv ("levels", " ")))
>
> --Dave
>
> On Wed, May 22, 2013 at 10:42 AM, Cathy Smith (NOAA Affiliate)
> <cathy.smith@noaa.gov> wrote:
>> NCL users
>> I call NCL scripts using Perl so I can change input parameters for the
>> script. For example, in Perl
>>
>> $ENV{'psname'}=$name;
>>
>> and in NCL
>>
>> psname=(getenv("psname"))
>>
>> I'd like to pass an array to NCL. How would I read this in NCL?
>>
>> Perl would have something like
>>
>> $ENV{'levels'}=@level_array;
>>
>> and the array size could vary (though I can guarantee it to have at least 1 value). I have done this in the past by sending a netCDF file filled with the array values but would prefer to avoid the extra file.
>>
>> Thanks for any suggestions!
>>
>> Cathy Smith

-- 
----------------------------------------------
NOAA/ESRL PSD and CU CIRES
303-497-6263
http://www.esrl.noaa.gov/psd/people/cathy.smith/
Emails about data/webpages may get quicker responses from emailing 
esrl.psd.data@noaa.gov

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu May 23 08:36:06 2013

This archive was generated by hypermail 2.1.8 : Thu May 30 2013 - 11:38:10 MDT