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

Abheera Hazra hazra.abheera at gmail.com
Wed Mar 1 00:20:41 MST 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170301/a8f57119/attachment.html 


More information about the ncl-talk mailing list