Run TUFLOW From a Batch-file: Difference between revisions

Content deleted Content added
No edit summary
Line 19:
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.
 
==Other Batch File Switches==
'''TIP:'''<br>
These switches are available in all batch files, they are not specific to TUFLOW.
 
===Pause===
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-AC\TUFLOW_iSP_w64.exe" "M01_5m_001.tcf"
pause</pre>
 
==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\2020-10-AC\TUFLOW_iSP_w64.exe" "M01_5m_003M01_5m_001.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\2020-10-AC\TUFLOW_iSP_w64.exe" M01_5m_003M01_5m_001.tcf
Start "TUFLOW" /wait "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" M01_2p5m_005M01_2.5m_001.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.
Line 52 ⟶ 53:
 
An example of a low priority simulation is:<br>
<pre>start "TUFLOW" /low "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" "M01_5m_003M01_5m_001.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.
 
===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-AC\TUFLOW_iSP_w64.exe" M01_5m_003M01_5m_001.tcf
Start "TUFLOW" /wait /min "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" M01_2p5m_005M01_2.5m_001.tcf</pre>
 
== TUFLOW switches in a batch file==
Line 65 ⟶ 66:
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-AC\TUFLOW_iSP_w64.exe" -t "M01_5m_003M01_5m_001.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\2020-10-AC\TUFLOW_iSP_w64.exe" -b "M01_5m_003M01_5m_001.tcf"</pre>
===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-AC\TUFLOW_iSP_w64.exe" -acf "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
 
===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-AC\TUFLOW_iSP_w64.exe" -nq "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
 
===Copy a TUFLOW model===
Line 90 ⟶ 91:
;* “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-AC\TUFLOW_iSP_w64.exe" -cp "C:\put_model_here" "C:\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</tt><br>
;* “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 115 ⟶ 116:
 
An example that copies all files (-ca switch) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -ca "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
An example that copies all files to an alternate path (-cap) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -cap "C:\Copy_of_model" "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
An example that copies all files to an alternate path, excluding any checkfilescheck files, (-capncf) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -capncf "C:\Copy_of_model" "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
 
===Package a TUFLOW model===
Line 144 ⟶ 145:
<br>
An example of package model that copies all files is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -pmAll "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
An example of package model that copies all files except .xf files, (-pmAll -xf0) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -pmAll -xf0 "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
An example of package model that copies all files with specified .ini file (-pmAllini) is:<br>
<pre>start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -pmAllini package.ini "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
An example of .ini file to overwrite the default base and destination folders, and specify events/scenarios for models with events/scenarios in filenames:<br>
<pre>
Line 159 ⟶ 160:
===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-AC\TUFLOW_iSP_w64.exe" -pu0 -pu2 "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_5m_003M01_5m_001.tcf"</pre>
 
===Event and Scenario Management===
The -e and -s switches can be used to manage multiple events and scenarios from a single tuflow control file. The -e and -s wildcard is replaced by the following entry specified in the batch file. For example, the following batch file commands will run two simulations in series:
* M01_Q050_24hr_2m_Dev_003M01_Q050_24hr_2m_Dev_001.tcf; and
* M01_Q100_24hr_2m_Dev_003M01_Q100_24hr_2m_Dev_001.tcf;
 
<pre>Start "TUFLOW" /wait "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -b -e1 Q050 -e2 24hr -s1 2m -s2 Dev "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_~e1~_~e2~_~s1~_s2~_003_001.tcf"
Start "TUFLOW" /wait "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -b -e1 Q100 -e2 24hr -s1 2m -s2 Dev "C:\TUFLOW\Tutorial_Wiki\TUFLOW\runs\M01_~e1~_~e2~_~s1~_s2~_003_001.tcf"</pre>
 
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 195 ⟶ 196:
<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-AC\TUFLOW_iSP_w64.exe" M01_5m_003M01_5m_001.tcf
call wait 60
Start "TUFLOW" /wait "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" M01_2p5m_005M01_2.5m_001.tcf</pre>
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].
 
===Variables===
Line 283 ⟶ 284:
FOR %%b in (%B%) DO (
call :do_while_loop_start
Start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -b -e1 %%a -s1 %%b M11_5m_M01_5m_~e1~_~s1~_001.tcf
)
)
Line 314 ⟶ 315:
SET /A Counter+=1
IF /i !Counter!==!P! (
Start "TUFLOW" /wait "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -b -e1 %%a -s1 %%b M11_5m_M01_5m_~e1~_~s1~_001.tcf
SET /A Counter=0
) ELSE (
Start "TUFLOW" "C:\TUFLOW\Releases\2020-10-AC\TUFLOW_iSP_w64.exe" -b -e1 %%a -s1 %%b M11_5m_M01_5m_~e1~_~s1~_001.tcf
)
)
Line 338 ⟶ 339:
set /a CPU_Cores=5
 
set tcf=M05_5m_M01_5m_~s1~_~e1~_~e2~_001.tcf
 
Set A=UDEF DEF