Run TUFLOW From a Batch-file: Difference between revisions
Content deleted Content added
Teegan.Burke (talk | contribs) |
Teegan.Burke (talk | contribs) No edit summary |
||
Line 13:
Open this file in a text editor and add the following line.
<pre>"C:\TUFLOW\Releases\
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:'''<br>
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.
<pre>"C:\TUFLOW\Releases\
pause</pre>
Line 28:
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\
===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\
Start "TUFLOW" /wait "C:\TUFLOW\Releases\
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.
Line 51:
An example of a low priority simulation is:<br>
<pre>start "TUFLOW" /low "C:\TUFLOW\Releases\
'''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.
Line 59:
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\
===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\
===Automatically Create Folders in a TUFLOW model===
The use of the -acf (automatically create folders) switch prevents the dialog prompt from appearing when encountering non-existent folders (ie. results folders), and creates these folders automatically. If for any reason the folder can't be created, a dialog will appear. This feature was first introduced for Build 2012-05-AC and is not available for TUFLOW builds prior to this. For models simulated with Build 2013-12-AA or later, non-existent folders are now automatically created. If you would prefer to have the create folder query dialog to appear, you can specify the –qcf run time option (stands for query create folders).<br>
An example is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\
===Suppress Queries in a TUFLOW model===
The use of the -nq (no queries) switch prevents any queries from displaying when simulating a TUFLOW model. At this stage, the only query not displayed if this option is used is if you press Ctrl-C to terminate a simulation cleanly. If –nq is specified and Ctrl-C is pressed, the simulation terminates cleanly without a query dialog.. This feature was first introduced for Build 2012-05-AC and is not available for TUFLOW builds prior to this.<br>
An example is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\
===Copy a TUFLOW model===
TUFLOW can be run in copy mode, which can be useful for transferring a model to another site or for making an archive of the
Line 120:
===GPU Solver Control===
The -pu switch can be used to select which processing units to direct the simulation towards. At present this only applies to the GPU solver where a simulation is to be directed to a particular GPU card or cards. –pu must be specified once for each device. For example, to direct the simulation to GPU devices 0 and 2, specify -pu0 -pu2. (Note: the GPU device numbering starts a 0, not 1). For example:
<pre>start "TUFLOW" "C:\TUFLOW\Releases\
===Event and Scenario Management===
Line 127:
* M01_Q100_24hr_2m_Dev_003.tcf;
<pre>Start "TUFLOW" /wait "TUFLOW" "C:\TUFLOW\Releases\
Start "TUFLOW" /wait "TUFLOW" "C:\TUFLOW\Releases\
==Advanced Batch Files==
Line 145:
<pre>call wait <time in seconds.</pre>
In the example below, the first simulation is started and then 60 seconds later (using the wait.bat file) the second simulation is started. Note there is no /wait flag specified, if there was the batchfile would wait for 60 seconds after the first simulation had finished before starting the second simulation.
<pre>Start "TUFLOW" "C:\TUFLOW\Releases\
call wait 60
Start "TUFLOW" /wait "C:\TUFLOW\Releases\
For this to work the wait.bat file needs to be in the same folder as the batchfile calling it. You can put the file in a specific location and add this path as an environment variable. If this is done "call wait <time in seconds> can be added to any batch file.<br>
To set the environment variable, you will need to have administrator access to the machine, and add a colon (;) and then the batchfile location (e.g. ";C:\batch_files\" , without the quotes) in the '''path''' system variables. The separator character is a colon (;) this is added to specify a new path. For more details on modifying the environment please see here: [http://support.microsoft.com/kb/310519 http://support.microsoft.com/kb/310519].
Line 154:
Batch files can be easily setup so that they are more generic and easily customised when moving from one project to another. For example, in the below a variable, TUFLOWEXE, is used to define the path to the TUFLOW exe to be used, and a variable RUN is used to incorporate options such as the /wait so that the simulations run in series (one after the other).
<pre>set TUFLOWEXE=C:\TUFLOW\Releases\
set RUN=start "TUFLOW" /wait "%TUFLOWEXE%" -b
%RUN% MR_H99_C25_Q100.tcf
Line 175:
FOR %%a in (%A%) do (
FOR %%b in (%B%) DO (
start "TUFLOW" /wait C:\TUFLOW\
)
)
Line 181:
</pre>
In order to test the syntax, you can test the batch file by replacing the following line:<br>
<tt>start "TUFLOW" /wait C:\TUFLOW\
With the following line:<br>
<tt><u>echo</u> start "TUFLOW" /wait C:\TUFLOW\
By using the echo in the command line, rather than starting the simulations the command line will be displayed in the DOS output. In the example above the DOS output is shown in the image below.
[[File:DOS nested batch output.png|frame|none]]
Line 233:
FOR %%b in (%B%) DO (
call :do_while_loop_start
Start "TUFLOW" "C:\TUFLOW\Releases\
)
)
Line 264:
SET /A Counter+=1
IF /i !Counter!==!P! (
Start "TUFLOW" /wait "C:\TUFLOW\Releases\
SET /A Counter=0
) ELSE (
Start "TUFLOW" "C:\TUFLOW\Releases\
)
)
Line 284:
rem ______________SET RUN VARIABLES_____________
set TUFLOWEXE=C:
set RUN=start "TUFLOW" /low "%TUFLOWEXE%" -b
set /a CPU_Cores=5
| |||