[ncl-talk] returning value to the shell

Jayant jayantkp2979 at gmail.com
Mon Oct 17 18:40:16 MDT 2022


Hi!
I have a shell script to start with where some variables (year,
month,tstep,variable name) are defined and passed to a ncl script. Next,
the ncl script performs further analysis (reading variables, analyzing).
The dimensionality (2-d or 3-d or 4-d) of the variable is determined inside
the ncl script, but I need this information back in the shell script. Is it
possible to get it? Roughly, I tried this
----------------------
myscript.ncl
yr=toint(getenv("YEAR"))
mn=toint(getenv("MON"))
varin=getenv("VNAME")
...
finp=addfile("modelout_"+yr+"_"+mn+".bin","r")
vinp=finp->varin
...
vdimin=dimsizes(varin)

*system("export VDIMS="+vdimin)  ; is it the correct way?*
...
----------------------
run_ncl.sh
#!/bin/sh
export YEAR=2019
export MON=8
export TSTEP=6
export VNAME="PREC"

ncl myscript.ncl

*echo $VDIMS    ; returning empty ???*
-----------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221017/4319624b/attachment.htm>


More information about the ncl-talk mailing list