[ncl-talk] Passing a variable value from NCL to bash Script

Rick Brownrigg brownrig at ucar.edu
Wed Mar 1 06:59:18 MST 2017


Hi,

If I understand correctly, you can pass in the values on the command-line
invocation of NCL as:

   ncl w1=X  dw1=Y

where X and Y are the actual values.  To pass in string arguments, we tell
people to place quotes around the whole var=value pair, like:

   ncl 'myStringVar="foo"'

You can find more info about passing in arguments at:

   http://ncl.ucar.edu/Document/Manuals/Ref_Manual/NclCLO.shtml

Hope that helps...
Rick

On Wed, Mar 1, 2017 at 12:20 AM, Abheera Hazra <hazra.abheera at gmail.com>
wrote:

> Hi,
>
> I am using NCL to calculate a few terms for an optimization algorithm and
> I am calling the NCL function from within a 'while loop' in a bash script.
> The 'while loop' runs till a certain condition is met and for the condition
> to be met, the bash script needs to accept a new value for an existing
> variable from the NCL script. I have tried using system, systemfunc with
> even the export command but nothing seems to work. The code looks as
> follows:
>
> ------------------------------------------
> #!/bin/bash
>
> w1=0.4
> dw1=0.1
> inc=0.001
>
> while awk 'BEGIN { if ('$dw1'<'$inc') {exit 1}}'; do
>
> cat <<'EOF' >> opti.error.ncl
>
> ;;;;Perform certain computations on w1 and update the w1 and dw1
> w1=nw1
> dw1=ndw1
>
>       system("w1=" + w1)
>       system("dw1=" + dw1)
>
> ;;;;w1 and dw1 need to be passed to the bash script
>
> EOF
>
>
>  ncl k1=${w1}  dw11=${dw1}  opti.error.ncl
>
> echo $w1
> echo $dw1
>
> done
> ------------------------------------------
>
> But this does not update w1 and dw1 values. Any input would be greatly
> appreciated.
>
> Thanks,
> Abheera
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20170301/57ced6b7/attachment.html 


More information about the ncl-talk mailing list