[gradsusr] Sharing variables when running a script within another script

Camila Andrade camilabe at gmail.com
Wed Aug 1 14:31:42 EDT 2018

Hello all! Can anyone help me with a script to convert .bin files into .nc?

I am running the script "lats4d.gs" within a loop in another script (
I've defined one variable (_a) in myscript.gs before calling lats4d.gs, and
I want to use this variable in lats4d.gs to name the output files (the
output files should be named as prec_1.nc, prec_2.nc, and so on). However,
I can't get the variable recognized by lats4d.gs.

Here is myscript.gs:

_a = 1
while (_a <= 3)
'open C:/Users/XXX/Desktop/XXX/prec_2018_'%_a
'run C:/Users/XXX/Desktop/lats4d.gs'
_a = _a + 1

And here is the only part of lats4d.gs that I've changed (line 1253):

_ofname = 'C:/Users/XXX/Desktop/XXX/prec_'_a

Although myscript.gs is successfully running, the output file is saved as "
prec__a.nc" (and not prec_1.nc, prec_2.nc, as I expected).
The 'while' loop is working fine (I've tested it), but since the file name
is always "prec__a.nc", I end up with only one file saved.

Does anyone know how to fix this? I believe I "just" need to make lats4d.gs
understand "_a" as the variable defined in myscript.gs, but I am not sure
if this is really the case, and how to do it.

Any help is welcome!
Thanks in advance!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20180801/0b387cb0/attachment.html>

More information about the gradsusr mailing list