Re: command line assignment

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 1 Nov 2006 19:06:38 -0700 (MST)

> Greetings,
> I am trying to use the nifty new command line feature of NCL from a
> shell script (bash). I'd like to preassign an NCL variable before
> calling a script. But I want to assign the NCL variable (basin) to the
> value of a shell script variable (shbasin) which has already been
> defined previously. If I try this interactively I get:
>
> --------------------------------
> [vigh_at_euler]$ shbasin="atlantic"
> [vigh_at_euler]$ echo $shbasin
> atlantic
> [vigh_at_euler]$ ncl basin=$shbasin
> Copyright (C) 1995-2006 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 4.2.0.a034
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> fatal: Assign: atlantic is undefined
> fatal:Execute: Error occurred at or near line 1 in
> file /tmp/ncl13631.ncl
>
> ncl 0> quit
> -------------------------------
>
> Is there any way to do this? Do I need do some sort of fancy escape
> sequence to make this work?
> _______________________________________________
>

I don't know the bash shell.

Under the C-shell, the following works:

%> setenv BASIN atlantic
%> cat >test.ncl
begin ; optional
  print( basin )
end ; only if 'begin' is present

%> ncl 'basin=getenv("BASIN")' test.ncl

yields

Variable: basin
Type: string
Total Size: 8 bytes
            1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) atlantic

=====

http://www.ncl.ucar.edu/Document/Functions/Built-in/getenv.shtml

Good luck
D
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 01 2006 - 19:06:38 MST

This archive was generated by hypermail 2.2.0 : Thu Nov 02 2006 - 16:23:51 MST