Thanks Ashley about those useful tips.
I'm now adapting my zaxreplace script for other applications (see
attached), but I have again issues on saving the output. I think the
problem is that the grid is too large for some models, and Ferret
complains by saying
**ERROR: request exceeds memory setting: A negative number of words
were requested.
*** NOTE: The current grid is most likely too large
So I'm subsetting the variable to select only the region I need, and
the computation works. But when I'm saving the generated field into
netcdf at line 52, Ferret comes out with the good ol' error
**TMAP ERR: error in line definition
file coords dont match variable coords on axis LAT77_203
It doesn't change whether I'm using RESHAPE or not. I also tried to
adapt my RESHAPE call according to what I read here
(https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/XPRESSIONS),
but with no luck. Can you please help me again about this?
Cheers,
Giorgio
----Messaggio originale----
Da: ansley.b.manke@xxxxxxxx
Data: 20-mag-2020 18.52
A: "Giorgio Graffino"<g.graffino@xxxxxx>
Cc: <ferret_users@xxxxxxxx>
Ogg: Re: [ferret_users] Problems with netcdf output and zaxreplace
Hi,
You could pass into the script the number of models
> ferret -script scriptname.jnl 7
The script then does a repeat loop that would start like this.
let nmodel = ($1)
repeat/range=1:($1)/name=r (\
use /home/data/model`r`.nc;\
...
There are details on the grave-accent evaluation
<https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/EMBEDDED-XPRESSIONS#_VPINDEXENTRY_562>that
give you some flexibility. For instance if the models are named
model01.nc, model02.nc, ... use the "precision" specifier to ask
for the value to be replaced with zero-filled numbers, here 2-digits.
let nmodel = ($1)
repeat/range=1:`nmodel`/name=r (\
use /home/data/model`r,p=z2`.nc;
Or, you could use a unix foreach loop and write your script to
operate on just one model if that makes sense for what you are
doing. Here I've made a script myscript.jnl with:
! myscript.jnl
echo ($1)
This is csh, other shells will have other syntax.
/home/users/ansley> set flist = 'model_run_7.nc
ocean_model_run5.nc http://address/climate.nc'
/home/users/ansley> foreach fname ($flist)
foreach? ferret -script myscript.jnl $fname
foreach? end
model_run_7.nc
ocean_model_run5.nc
http://address/data/climate.nc
On 5/18/2020 10:47 AM, Giorgio Graffino wrote:
Hi Ashley,
thanks for your suggestion.
I preferred to implement the other method because it involved a
single Ferret call, but I haven't thought about passing all
variables in that way. You are suggesting something like
ferret -script scriptname.jnl model1 model2 model3
which would be great to have, but I should find a way to loop
across all models from inside the jnl script. Now my jnl script
includes
define symbol model = ($01)
to read the argument, because I'm parsing only one argument at a
time. How can I loop over all models from inside the jnl script?
Cheers,
Giorgio
----Messaggio originale----
Da: ansley.b.manke@xxxxxxxx
Data: 12-mag-2020 19.55
A: <ferret_users@xxxxxxxx>
Ogg: Re: [ferret_users] Problems with netcdf output and
zaxreplace
Hi Giorgio,
Another method for sending Ferret/PyFerret a set of commands
is to use the -script option on startup.
> pyferret -script my_script.jnl [arguments]
This is generally more flexible than piping commands. The
startup option -batch for Ferret or -nodisplay for PyFerret
are also useful when you don't want to have graphics windows
display. Note that -script must appear last among command
line switches so that the script arguments will be parsed
correctly.
Unix command-line switches
<https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/introduction/GETTING-STARTED#_VPID_8>
On 5/9/2020 3:19 AM, Giorgio Graffino wrote:
Hi Ryo,
thanks to your "quote" suggestion I could successfully run
my bash script.
Cheers,
Giorgio
----Messaggio originale----
Da: furue@xxxxxxxxxx
Data: 28-apr-2020 14.28
A: "Giorgio Graffino" <g.graffino@xxxxxx>
Cc: "Ferret" <ferret_users@xxxxxxxx>
Ogg: Re: [ferret_users] Problems with netcdf output and
zaxreplace
Hi Giorgio,
On Tue, Apr 28, 2020 at 7:09 PM Giorgio Graffino <
g.graffino@xxxxxx <invalidurl.gif>> wrote:
!-> REPEAT: I=1
**ERROR: command syntax: II = ???
define symbol ii
Compare this line with the one in the original shell
script:
ferret << STOP
. . .
define symbol ii `i`
. . .
STOP
Where did `i` go?
In the shell script as well as in the ferret script, the
backquote construct is evaluated. In the above shell
script, the shell tries to run a command named "i". It
fails and is replaced with an empty string. I
suppose you saw this error message on your screen
. . . i: command not found
To prevent the shell from interpreting the backquote
construct, you "quote" the here-document by
ferret <<'STOP'
. . .
STOP
Ryo
--------------------
To see what's going on, run this kind of test shell script
echo date
echo `date`
echo "abc `date` def"
echo 'abc `date` def'
cat <<EOF
date
`date`
EOF
cat <<'EOF'
date
`date`
EOF
--
Ansley Manke
Science Data Integration Group
NOAA Pacific Marine Environmental Laboratory
7600 Sand Point Way NE
Seattle WA 98115
I am currently teleworking and am available Tue-Wed-Thu.
--
Ansley Manke
Science Data Integration Group
NOAA Pacific Marine Environmental Laboratory
7600 Sand Point Way NE
Seattle WA 98115
I am currently teleworking and am available Tue-Wed-Thu.