Difference between revisions of "Run TUFLOW From a Batch-file"
Line 22: | Line 22: | ||
==Other Batch File Switches== | ==Other Batch File Switches== | ||
+ | These switches are available in all batch files, they are not specific to TUFLOW. | ||
+ | ===Starting process in new window=== | ||
+ | In order to run multiple simulations at the same time, each simulation needs be started in a new console window. To do this begin the batch file line with the "Start" command, a for the window is then added. For example, to start the simulation above in a new window titled "TUFLOW" the following would be used. | ||
+ | |||
+ | <pre>Start "TUFLOW" "C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" "M01_5m_003.tcf"</pre> | ||
+ | ===Wait=== | ||
+ | If multiple simulations are to be run, it is often desirable to run these in series, i.e. the second simulation starts after the first has finished. a /wait switch can be added which makes the batch file wait until the process is finished before moving onto the next command.<br> | ||
+ | An example of this is:<br> | ||
+ | <pre>Start "TUFLOW" /wait "C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" M01_5m_003.tcf | ||
+ | Start "TUFLOW" /wait "C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" M01_2p5m_005.tcf</pre> | ||
+ | Without the wait command, both simulations would start at the same time.<br> | ||
+ | '''Note:''' Unless there is a third simulation in the batch file the /wait command in the second line is not required, this prevents the batchfile from moving onto the third line. | ||
===Setting a priority=== | ===Setting a priority=== | ||
The priority of a process (such a TUFLOW simulation) can be specified within a batch file. This can be useful for a number of reasons: | The priority of a process (such a TUFLOW simulation) can be specified within a batch file. This can be useful for a number of reasons: | ||
Line 36: | Line 48: | ||
*/REALTIME | */REALTIME | ||
− | An example of a low priority simulation is: | + | An example of a low priority simulation is:<br> |
− | <pre> | + | <pre>start "TUFLOW" /low C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" "M01_5m_003.tcf"</pre> |
− | + | '''TIP:''' The priority of a TUFLOW simulation can be changed at a later stage by using the '''Windows Task Manager''', navigate to the '''Processes''' tab and right click on the TUFLOW process (e.g. TUFLOW_iSP_w64.exe) and select the set priority option. | |
+ | == TUFLOW switches in a batch file== | ||
+ | These switches are specific to TUFLOW simulations. | ||
===Testing a simulation=== | ===Testing a simulation=== | ||
+ | The -t (test) switch is very useful for testing the data input without running the simulation. It is good practice to use this switch before carrying out the simulations, as this will tell you whether there are any data input problems. The -t switch runs TUFLOW to just before it starts the hydrodynamic computations. | ||
+ | An example is:<br> | ||
+ | <pre>start "TUFLOW" C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" -t "M01_5m_003.tcf"</pre> | ||
+ | ===Batch mode in TUFLOW=== | ||
+ | The use of the –b (batch) switch which suppresses the need to press the return key at the end of a simulation. This ensures that one simulation proceeds on to the next without any need for user input. This is required for running multiple simulations in series (one after the other). | ||
+ | An example is:<br> | ||
+ | <pre>start "TUFLOW" C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" -b "M01_5m_003.tcf"</pre> | ||
===Copy a TUFLOW model=== | ===Copy a TUFLOW model=== | ||
− | + | TUFLOW can be run in copy mode. This copies all TUFLOW inputs for the simulation into a subdirectory where the .tcf is located (generally TUFLOW\runs\). There are two copy options: -c and -ca.<br> | |
+ | -c copies only the files read by TUFLOW, for example the .mif and . mid files are read by TUFLOW, but the MapInfo format files (.tab, .id, .dat and .map) are not read by TUFLOW and these files will not be copied.<br> | ||
+ | -ca copies all files with the same name (regardless of extension), if the 2d_code_M01_003.MIF and 2d_code_M01_003.MID files are copied all of the MapInfo files (2d_code_M01_003.DAT, 2d_code_M01_003.ID, 2d_code_M01_003.MAP and 2d_code_M01_003.TAB), will all be copied.<br> | ||
+ | An example that copies all files is:<br> | ||
+ | <pre>start "TUFLOW" C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" -ca "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003.tcf"</pre> | ||
==Advanced Batch Files== | ==Advanced Batch Files== | ||
− | ===Creating a | + | ===Creating a delay=== |
Revision as of 08:41, 7 October 2011
TUFLOW simulations can also be started from a batch file. Batch files are text files which contain a series of commands. Batch files allow a large degree of flexibility in starting TUFLOW simulations, advanced batch files can be used to:
- Run multiple simulations
- Set CPU priority for TUFLOW simulations
- Create a wait (e.g. start a simulation in 1 hour)
- Test simulation input
- Copy a TUFLOW model
- Post process results after simulation has finished.
Match file for Tutorial Model Module 1
To use a batch file, create a new text file in the TUFLOW\runs directory. The name is arbitrary but the file must have the extension ".bat". For example the file name could be _run_TUFLOW.bat.
Open this file in a text editor and add the following line.
"C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" "M01_5m_001.tcf"
This is the simplest command line for starting TUFLOW, the line above contains only two arguments, the first is the path to the TUFLOW executable and the second argument "M01_5m_001.tcf" is the simulation file name. Depending on the location of the executable the above command line will need to be modified. The quotations around the TUFLOW executable and the .tcf file name are only required if there are spaces in the file names. However, it is recommended to include these to avoid problems.
TIP:
A second line with the text "pause" can be added, this will prompt the user to press a key at the end of the batch file. This is useful if the DOS window disappears from the screen, before you can read the output, the pause command will keep the window open.
"C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" "M01_5m_001.tcf" pause
Other Batch File Switches
These switches are available in all batch files, they are not specific to TUFLOW.
Starting process in new window
In order to run multiple simulations at the same time, each simulation needs be started in a new console window. To do this begin the batch file line with the "Start" command, a for the window is then added. For example, to start the simulation above in a new window titled "TUFLOW" the following would be used.
Start "TUFLOW" "C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" "M01_5m_003.tcf"
Wait
If multiple simulations are to be run, it is often desirable to run these in series, i.e. the second simulation starts after the first has finished. a /wait switch can be added which makes the batch file wait until the process is finished before moving onto the next command.
An example of this is:
Start "TUFLOW" /wait "C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" M01_5m_003.tcf Start "TUFLOW" /wait "C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" M01_2p5m_005.tcf
Without the wait command, both simulations would start at the same time.
Note: Unless there is a third simulation in the batch file the /wait command in the second line is not required, this prevents the batchfile from moving onto the third line.
Setting a priority
The priority of a process (such a TUFLOW simulation) can be specified within a batch file. This can be useful for a number of reasons:
- Lowering the priority of a simulation to allow you to continue working;
- Setting a high priority for critical runs; or
- Making sure you runs are high priority on a shared computing resource!
The following are valid priority switches (in increasing order of priority):
- /LOW
- /BELOWNORMAL
- /NORMAL
- /ABOVENORMAL
- /HIGH
- /REALTIME
An example of a low priority simulation is:
start "TUFLOW" /low C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" "M01_5m_003.tcf"
TIP: The priority of a TUFLOW simulation can be changed at a later stage by using the Windows Task Manager, navigate to the Processes tab and right click on the TUFLOW process (e.g. TUFLOW_iSP_w64.exe) and select the set priority option.
TUFLOW switches in a batch file
These switches are specific to TUFLOW simulations.
Testing a simulation
The -t (test) switch is very useful for testing the data input without running the simulation. It is good practice to use this switch before carrying out the simulations, as this will tell you whether there are any data input problems. The -t switch runs TUFLOW to just before it starts the hydrodynamic computations.
An example is:
start "TUFLOW" C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" -t "M01_5m_003.tcf"
Batch mode in TUFLOW
The use of the –b (batch) switch which suppresses the need to press the return key at the end of a simulation. This ensures that one simulation proceeds on to the next without any need for user input. This is required for running multiple simulations in series (one after the other).
An example is:
start "TUFLOW" C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" -b "M01_5m_003.tcf"
Copy a TUFLOW model
TUFLOW can be run in copy mode. This copies all TUFLOW inputs for the simulation into a subdirectory where the .tcf is located (generally TUFLOW\runs\). There are two copy options: -c and -ca.
-c copies only the files read by TUFLOW, for example the .mif and . mid files are read by TUFLOW, but the MapInfo format files (.tab, .id, .dat and .map) are not read by TUFLOW and these files will not be copied.
-ca copies all files with the same name (regardless of extension), if the 2d_code_M01_003.MIF and 2d_code_M01_003.MID files are copied all of the MapInfo files (2d_code_M01_003.DAT, 2d_code_M01_003.ID, 2d_code_M01_003.MAP and 2d_code_M01_003.TAB), will all be copied.
An example that copies all files is:
start "TUFLOW" C:\TUFLOW\Releases\2011-09\w32\TUFLOW_iSP_w32.exe" -ca "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003.tcf"