[gradsusr] Input bash shell set of variables into grads script?
Uma Bhatt
usbhatt at alaska.edu
Sun Mar 8 22:31:05 EDT 2020
Hi Grads Users,
I am trying to automate the processing, calculations, and plotting of CFSv2 seasonal forecast products.
I have to loop through different time values and file names of CFSv2 files and it would be easier to loop through these in a bash shell. I am sure you can do it all in grads but I am less clear on how to do that.
I am using this version of grads:
Config: v2.1.0 little-endian readline grib2 netcdf hdf4-sds hdf5 opendap-grids,stn geotiff shapefile cairo
Issue 'q config' command for more detailed configuration information
In my script I loop through 8 ensemble members. The parameter name provides the name of when the particular ensemble starts. The tstart is the first time that I want to average over and tend is the last time I want to average over. I want to use these three variables in my grads script wind.gs (not included here for simplicity.
I am stuck on the syntax of this line where I run the grads script. I want to provide these three variables to wind.gs. I also call these variables in this script using $pref, $tw, and $te (something that works in fortran, but not here).
grads -bpcx "run wind.gs $pref $tw $te”
I added an export statement in the upper part of the bash shell but that did not work. I am sure I am doing something stupid.
Thanks,
Regards,
Uma Bhatt
My script looks like this:
#!/bin/bash
#name=("0100" "0106" "0112" "0118" "0200" "0206" "0212" "0218")
#tstart=(28 27 26 25 24 23 22 21 )
#tend=(55 54 53 52 51 50 49 48)
limit=1
for ((nvar=0;nvar <= limit; nvar++))
do
echo "$nvar"
pref=${name["$nvar"]}
echo "$pref"
tw=${tstart["$nvar"]}
echo "$tw"
te=${tend["$nvar"]}
echo "$te"
#export $pref
#export $tw
#export $te
cat << EOR > wind.gs
…….text snipped…...
EOR
echo "$pref"
grads -bpcx "run wind.gs $pref $tw $te"
# nvar=$(($nvar+1))
done
echo "Fin del script"
——————
A brand is what a business does, reputation is what people remember.
- Ted Rubin
Uma S. Bhatt
Professor of Atmospheric Sciences & Geophysical Institute,
Director Cooperative Institute for Alaska Research
physical location: Akasofu (IARC) Building (2158 Koyukuk Drive), office location: Room 315 Akasofu
mailing address:
University of Alaska Fairbanks
Geophysical Institute
2156 Koyukuk Drive
Fairbanks, Alaska 99775-7320
tel: (907) 474-2662 fax: (907) 474-2643
email: usbhatt at alaska.edu
web: http://ffden-2.phys.uaf.edu/usbhatt/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20200308/a9b4dc1b/attachment.html>
More information about the gradsusr
mailing list