[ncl-talk] number variable transfer into ncl script

Alan Brammer abrammer at albany.edu
Fri Oct 10 10:11:55 MDT 2014


Another option, ditch the "  and could even ditch the ' .  I think you only
need them when you're passings strings in.  Which is what you're
inadvertently doing at the moment which is why it fails.  Below should
treat you fine if the vars are numeric.

Throw in a print(timeb) at the top, and you'll see at the moment it's of
string type using the quotes.

ncl timeb=$var1  timee=$var2  timed=$var3   abc.ncl

~Alan



On Fri, Oct 10, 2014 at 11:58 AM, Rick Brownrigg <brownrig at ucar.edu> wrote:

> Hi Mark,
>
> I take it your $var1, $var2, etc., are shell variables?
>
> Try      ncl timeb=\"$var1\" ....
>
> HTH,
> Rick
>
>
> On Fri, Oct 10, 2014 at 9:38 AM, Mark Chan <cym263 at yahoo.com> wrote:
>
>> Dear NCL users,
>>
>> I have a ncl script as in the below with name as "abc.ncl", and I would
>> run it as:
>>
>> ncl    'timeb="'$var1'"'     'timee="'$var2'"'       'timed="'$var3'"'
>> abc.ncl
>>
>> here var1=31; var2=32; var3=31.5  (this is examples and the values would
>> be calculated)
>>
>> The operation above doesn't work, however the following operation works:
>>
>> ncl   'timeb=31'    'timee=32'    'timed=31.5'   abc.ncl
>>
>> Can one kindly give any suggestion?
>>
>> Thanks very much in advance!
>> Mark
>>
>> -------abc.ncl--------------
>> begin
>>  time_bnds=new((/1,2/),"double","No_FillValue")
>>  write_file=addfile("./rub.nc","w")
>>  time_bnds(0,0:1) = (/timeb,timee/)
>>  time = (/timed/)
>>  write_file->time_bnds=time_bnds(0:0,0:1)
>>  write_file->time=time
>> end
>>
>>
>>
>> _______________________________________________
>> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141010/d0933529/attachment.html 


More information about the ncl-talk mailing list