Run TUFLOW From a Batch-file: Difference between revisions
Content deleted Content added
No edit summary |
No edit summary |
||
Line 16:
Open this file in a text editor and add the following line.
<pre>"C:\TUFLOW\Releases\2020-10-
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\2020-10-
pause</pre>
Line 31:
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\2020-10-
===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\2020-10-
Start "TUFLOW" /wait "C:\TUFLOW\Releases\2020-10-
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 54:
An example of a low priority simulation is:<br>
<pre>start "TUFLOW" /low "C:\TUFLOW\Releases\2020-10-
'''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.
===Minimising the console window===
Using the /min switch will keep the console window for TUFLOW models minimised, so it doesn't pop up to the front every time when the next model starts.
<pre>Start "TUFLOW" /wait /min "C:\TUFLOW\Releases\2020-10-
Start "TUFLOW" /wait /min "C:\TUFLOW\Releases\2020-10-
== TUFLOW switches in a batch file==
Line 67:
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\2020-10-
===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\2020-10-
===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\2020-10-
===Suppress Queries in a TUFLOW model===
The use of the -nq (no queries) switch prevents the termination query dialog from displaying when Ctrl+C is pressed to terminate a simulation cleanly. If –nq is specified and Ctrl-C is pressed, the simulation terminates cleanly without a query dialog to check you are certain, so be careful! 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\2020-10-
===Copy a TUFLOW model===
Line 92:
;* “p” (path); and<br>
: The addition of the “p” flag (e.g. -cp) allows the user to specify an alternate path in which to copy the model. Without this flag, the location defaults to the .tcf’s location. For example, specifying the following, will place a copy of the model into a folder C:\put_model_here:<br>
:: <tt>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
;* “ncf” (no check files)<br>
: The addition of the “ncf” flag (e.g. -cncf) copies the essential input files and excludes all check files.<br>
Line 100:
Specifying '''-c''' on the TUFLOW command line creates a folder “<.tcf filename>_copy” (or “<.tcf filename>_copy_all” if the “a” flag is added) in the same location as the .tcf file. Under the folder, input files are copied (including the full folder structure), and any check files and output folders created. For example, specifying:<br>
: <tt>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
'''Note:'''
Line 117:
An example that copies all files (-ca switch) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
An example that copies all files to an alternate path (-cap) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
An example that copies all files to an alternate path, excluding any checkfiles, (-capncf) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
===Package a TUFLOW model===
Line 146:
<br>
An example of package model that copies all files is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
An example of package model that copies all files with specified .ini file (-pmAllini) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
An example of package model that copies all files except .xf files, (-pmAll -xf0) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
===GPU Module Control===
The -pu switch can be used to select which GPU card or cards to direct the simulation towards. –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\2020-10-
===Event and Scenario Management===
Line 161:
* M01_Q100_24hr_2m_Dev_003.tcf;
<pre>Start "TUFLOW" /wait "TUFLOW" "C:\TUFLOW\Releases\2020-10-
Start "TUFLOW" /wait "TUFLOW" "C:\TUFLOW\Releases\2020-10-
Please be aware that the % symbol is a special character in a batch file. If the % symbol is used within a wildcard, it will not be read when searching for that wildcard in TUFLOW.<br>
Line 190:
<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\2020-10-
call wait 60
Start "TUFLOW" /wait "C:\TUFLOW\Releases\2020-10-
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 199:
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\2020-10-
set RUN=start "TUFLOW" /wait "%TUFLOWEXE%" -b
%RUN% MR_H99_C25_Q100.tcf
Line 220:
FOR %%a in (%A%) do (
FOR %%b in (%B%) DO (
start "TUFLOW" /wait C:\TUFLOW\Releases\2020-10-
)
)
Line 226:
</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\Releases\2020-10-
With the following line:<br>
<tt><u>echo</u> start "TUFLOW" /wait C:\TUFLOW\Releases\2020-10-
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 278:
FOR %%b in (%B%) DO (
call :do_while_loop_start
Start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
)
)
Line 309:
SET /A Counter+=1
IF /i !Counter!==!P! (
Start "TUFLOW" /wait "C:\TUFLOW\Releases\2020-10-
SET /A Counter=0
) ELSE (
Start "TUFLOW" "C:\TUFLOW\Releases\2020-10-
)
)
Line 329:
rem ______________SET RUN VARIABLES_____________
set TUFLOWEXE=C:\TUFLOW\Releases\2020-10-
set RUN=start "TUFLOW" /low "%TUFLOWEXE%" -b
set /a CPU_Cores=5
| |||