Batch File Scripting


Previous

HOME


Next

In the previous section hundreds of CONTROL files were created through the GUI and then the trajectory model was run for each file and the results analyzed; all under the cover of the GUI hidden from the user. In this section we will examine how these calculations can be run directly outside of the GUI using a Windows batch file script. Comparable scripting procedures exist under other operating systems.

  1. To start, go back to the previous section and recreate the CONTROL files for the 750 m trajectory as outlined in sections 1, 2, and 3 (through Step 2).

  2. From the \Tutorial\files directory, copy the two batch files batch_main.bat, batch_exec.bat into the \hysplit4\working directory. Although not required to run a batch file, open the Command Prompt by going to the Windows Start Menu, All Programs, Accessories, and the open the Command Prompt. From the command prompt change directory to the working directory: chdir \hysplit4\working.

  3. Open the main script batch_main.bat in notepad where you can see that it is composed of seven sections, each preceded by a REMarks line. The first line runs the trajectory model script, passing as an argument, the name of the CONTROL file, the second step creates the file of file names, the next step accumulates the trajectories on a grid to compute the frequency, the next step creates the custom labels for the plot, then the postscript plot is created, displayed, and finally unneeded files are deleted.

  4. Each of these commands could be typed line-by-line on the command line, or you could just simply type the name of the upper level batch file, batch_main.bat and windows knows to execute the commands in the file. Run this script and at its conclusion the final graphic will be similar but not identical to the one in the previous section because in this case the contours were customized to illustrate one of the advantages of scripting: providing for program options not always available through the GUI.

Other scripting examples can be found in \hysplit4\testing\xrun.bat, which runs through a series of different calculations. Example scripts for Windows, TCL, and UNIX, can be found in \hysplit4\examples\scripts. Command line options for various HYSPLIT programs can be found in the User's Guide and by typing the program name from the command prompt. All HYSPLIT programs are in the \exec directory so for example to see the options associated with concplot, type: ..\exec\concplot without any arguments. Batch file commands can also be displayed from the command prompt by typing help.