Running Player Files from the Command Line

In some cases, it may be useful to run the GoldSim Player directly from the command line.

This, for example, could be done by selecting Run from the Windows Start menu, which displays the following dialog:

You must enter the full path to the GoldSim Player executable (which may, of course, be different than that shown above), followed by the GoldSim file that you want to open. If no filename is specified, GoldSim simply opens the Player and displays the splash screen.

   Note: If no path is specified for a filename, GoldSim Player looks in the same directory as the Player executable. Hence, it is highly recommended that you provide a full path for the filename.

The primary reason for running the Player from the command line is to take advantage of a number of command line parameters that cause the Player to execute in a specific manner.

The command line parameters are summarized in the following table. Note that the parameters are entered after the executable and before the model file name.

Parameter

Description

Comments

 -r

-run

Opens the GoldSim Player file and immediately runs the simulation.

 -x

Closes GoldSim after all other options have been executed.

Note that unless the –sv parameter is also used, the GoldSim Player file will NOT be saved when the application is closed.

-sv [filename]

-save [filename]

Saves the Player file using either the optionally provided output filename, or the input filename (if an output file is not provided).

This option can be used to run and save a Player file.


Examples of how these parameters would commonly be used are provided below.  Note that these parameter strings would follow the name (and path) of the GoldSim Player executable (GSPlayer.exe).

 

Command line

Comments

-r test1.gsp

Opens test1.gsp, executes pre-run checks and starts the simulation.  GoldSim Player remains open after the simulation. 

-r –sv test1.gsp

Opens test1.gsp, executes pre-run checks and starts the simulation.  At the end of the simulation, the Player file is saved. GoldSim Player remains open after the simulation. 

-r –sv –x test1.gsp

Opens test1.gsp, executes pre-run checks and starts the simulation.  At the end of the simulation, the Player file is saved. GoldSim Player is then closed. 

-r –sv test1res.gsp test1.gsp

Opens test1.gsp, executes pre-run checks and starts the simulation.  At the end of the simulation, the Player file is saved to test1res.gsp. GoldSim Player remains open after the simulation. 

In most cases, it is likely that you will want to “stack” a number of GoldSim runs by creating a batch file that you run from the command line.  However, if you simply stack command lines and then run a batch file, all GoldSim Player calls would be launched in parallel (e.g., if you had 10 command lines that ran GoldSim Player, 10 instances of GoldSim Player would open and run simultaneously).

To avoid this problem and force the commands to run in series, you can use the Start/Wait command provided by Windows.  An example batch file that utilizes this is shown below:


CD c:\Program Files\GTG\GoldSim 10.5

Start /wait GSPlayer.exe -r -sv -x  c:\runs\input1.gsp

Start /wait GSPlayer.exe -r -sv -x  c:\runs\input2.gsp

Start /wait GSPlayer.exe -r -sv -x  c:\runs\input3.gsp

Start /wait GSPlayer.exe -r -sv -x  c:\runs\input4.gsp

The first line simply sets the directory to the location of the GoldSim executable. The next line opens a GoldSim Player file called input1.gsp.  The Player runs the model, saves the results and then closes.  After closing, the next GoldSim Player command is implemented (open input2.gsp, run and save the model). This continues until all four GoldSim runs are complete.

Related Topics…