Executing grads scripts in batch?

All other topics about postprocessing model data (GrADS and other software), about other numerical weather prediction software (including WRF-NMM and WRF-ARW discussion unrelated to UEMS/WRF EMS), and general meteorology talk go in this forum.
Post Reply
taylormade
Posts: 18
Joined: Fri Aug 26, 2011 9:36 pm

Executing grads scripts in batch?

Post by taylormade » Sun Oct 09, 2011 10:33 pm

Hello,
I am just starting out writing some scripts for grads and I have what appears to be a pretty simple problem. I have a simple grads script, which I think follows the correct grads scripting syntax, and when I call it from the command prompt, using #grads -blc "run script.gs file.ctl", grads launches, does not run the script, then quits, no error.

Here is the script:

Code: Select all

function exportShp(args)
filename = subwrd(args,1)
'open 'filename
'set gxout shp'
t = 1
while(i<24)
'set t 'i

'q time'
tstamp = subwrd(result,3)
'set shpattr time string 'tstamp
'
'set shp -pt -fmt 3 2 pressfc-'i
'd pressfc'
'clear'
i=i+1
endwhile

'quit'
return 0
The output is:

Code: Select all

Config: v2.0.a9.oga.1 little-endian readline printim grib2 netcdf hdf4-sds hdf5 opendap-grids,stn athena geotiff shapefile
Issue 'q config' command for more detailed configuration information
Loading User Defined Extensions table </opt/opengrads/Linux/Versions/2.0.a9.oga.1/x86_64/gex/udxt> ... ok.
GX Package Initialization: Size = 11 8.5 
Running in Batch mode
No hardcopy metafile open
GX package terminated 
What is the secret?

meteoadriatic
Posts: 1495
Joined: Wed Aug 19, 2009 10:05 am

Re: Executing grads scripts in batch?

Post by meteoadriatic » Mon Oct 10, 2011 5:44 pm

What do you expect as end result from this script? That is, how do you know that it doesn't run the script? You run it on batch mode, and there is no statment of writing to file or something, so there should not be any final result from this. Or I overlooked something?

taylormade
Posts: 18
Joined: Fri Aug 26, 2011 9:36 pm

Re: Executing grads scripts in batch?

Post by taylormade » Mon Oct 10, 2011 8:54 pm

Thanks for the reply.
The end result should be a shapefile for each time step.
I am setting gxout shp at the beginning, then calling 'd variable' which normally outputs the shapefile.

The only strange thing I noticed is 'No hardcopy metafile open'. I do not have to set anything like this interactively, are there additional steps when running in batch, or through the scripting language?

meteoadriatic
Posts: 1495
Joined: Wed Aug 19, 2009 10:05 am

Re: Executing grads scripts in batch?

Post by meteoadriatic » Tue Oct 11, 2011 5:00 am

I see now.

No hardcopy metafile open could mean that you might fail to set paths properly. When you do grads -blc "run script.gs file.ctl" from which directory you invoke that command? The file.ctl should be in that directory if you use relative paths. If it is not there, you should use absolute path:

Code: Select all

$ grads -blc "run script.gs /home/blah/path/to/your/file.ctl"

taylormade
Posts: 18
Joined: Fri Aug 26, 2011 9:36 pm

Re: Executing grads scripts in batch?

Post by taylormade » Thu Oct 13, 2011 12:38 am

I gave it a try using absolute path names, but it did not help.
I suspect it is something with the gxout.

Has anyone used gxout commands in a batch script before successfully, such as in generating a GeoTiff for example?

taylormade
Posts: 18
Joined: Fri Aug 26, 2011 9:36 pm

Re: Executing grads scripts in batch?

Post by taylormade » Thu Oct 13, 2011 12:39 am

What other grads forums do people recommend to check out for help? I have Googled the issue to death and cannot find much.

StefanD
Posts: 26
Joined: Wed Aug 17, 2011 7:50 pm

Re: Executing grads scripts in batch?

Post by StefanD » Thu Oct 13, 2011 3:12 am

There is a Grads user forum.

http://gradsusr.org/mailman/listinfo/gradsusr

Here is the archived material:
http://gradsusr.org/pipermail/gradsusr/

meteoadriatic
Posts: 1495
Joined: Wed Aug 19, 2009 10:05 am

Re: Executing grads scripts in batch?

Post by meteoadriatic » Thu Oct 13, 2011 7:56 am

StefanD wrote:There is a Grads user forum.

http://gradsusr.org/mailman/listinfo/gradsusr
Yes, that should be the best place to ask about more advanced GrADS stuff :)

taylormade
Posts: 18
Joined: Fri Aug 26, 2011 9:36 pm

Re: Executing grads scripts in batch?

Post by taylormade » Sat Oct 15, 2011 1:06 am

I have made a bit of progress debugging.
It looks as though the gxout shp function only works with an active X server. When I run in batch mode, without X, there is no output. However, if I run the script, not in batch, allowing it to connect to X, it works.
As a bit of a workaround, it should be possible to route the X to a virtual X frame buffer to allow it to run without an actual X connection.

I suspect that most gxout functions are fine, although the functions where it outputs to a file, such as a geotiff or a shapefile are probably affected.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests