Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In addition to all its interactive functionality, Metview can be run in a purely batch mode from the command line. Of course, in this mode we cannot have an interactive plot window, but we can save plots in various formats (see Working with graphical output) and we can save computed data into files of various formats (see Processing Data).

Running Metview in Batch Mode

Metview runs in batch mode when the option -b is specified when you first call it. You can run Metview in batch mode while having a Metview interactive session up and running - they will not interfere with each other. To run a macro in batch mode simply specify its name on the command line after the -b option:

...

Info
Note that the additional command-line argument  -slog tells Metview to provide more output - this can be useful to diagnose problems. This argument (and indeed all other arguments) must come before the -b, and anything after it will be interpreted as an argument to your macro.

Getting Environment Variables

Environment variables can be queried, not only in batch mode but also in interactive mode. This can be an alternative way to pass information to a macro.

...

Code Block
languagepy
machine = getenv('HOST')
print('Running on ', machine)

 

Detecting Whether Metview is Running in Batch Mode

The macro function runmode() returns a string which tells us the mode in which it has been run. If the return value is "batch" then Metview has been invoked in batch mode.

...

If running in interactive mode (i.e. not "batch") then plot the data to an interactive Display Window. If in batch mode, plot the data to a PostScript file called my_field.ps. See Working with graphical output for more detail if required.

Invoking Metview's Data Examiners from the Command Line

Metview has a special shortcut specifically for invoking the data examiners from the command line for quick data inspection.

...

This works for GRIB, BUFR, ODB and netCDF files. The file type must be the first argument.

Extra Work

Take some of the macros you've already written and convert them so that they can run in batch mode. In most cases it will not require much work - here are the main things to consider:

...