@echo off
:: This sets the variables as local, so you can use another batch file with A and B variables
setlocal ENABLEDELAYEDEXPANSION

:: determine if 32 or 64 bit run
ECHO.%PROCESSOR_ARCHITECTURE% | FIND /I "64">Nul && ( set platform=w64) || ( set platform=w32)
IF %platform% == w32 (
	goto :break
) ELSE (
	echo Running with %platform% version of TUFLOW
)

:: set executable (relative path)
set exe=..\exe\2018-03-AA\TUFLOW_iSP_%platform%.exe
echo Executable: %exe%
::
echo getting system info using  get_computer_info_%platform%.bat
call get_computer_info_%platform%.bat
echo done getting system info
pause

echo.
echo Starting Classic Solver CPU simulations
set A=20.00m
:: Loop through each cell size
FOR %%a in (%A%) do (
    echo Running %%a model with CPU solver
    Start "TUFLOW" /wait %exe% -b -s1 CLA -s2 CPU -s3 NT1 -s4 %%a FMA_T2_~s1~_~s2~_~s3~_~s4~_001.tcf
)

echo.
echo Starting HPC Solver CPU hardware simulations
::set maxcores=%NUMBER_OF_PROCESSORS%
set maxcores=2
set A=20.00m
:: Loop through number of cores
::FOR %%i in (0 1 2 3 4 5 6 7 8) do (
FOR %%i in (2 3 4 5 6 7 8) do (
	set power=%%i
    set /A "result = 1 << !power!"
	IF !result! GEQ %maxcores% (
		FOR %%a in (%A%) do (
			echo Running %%a model with HPC solver on CPU Hardware with %maxcores% cores
			Start "TUFLOW" /wait %exe% -b -s1 HPC -s2 CPU -s3 NT%maxcores% -s4 %%a -nt%maxcores% FMA_T2_~s1~_~s2~_~s3~_~s4~_001.tcf
		)
		goto :next
	) ELSE (
		FOR %%a in (%A%) do (
			echo Running %%a model with HPC solver on CPU Hardware with !result! cores
			Start "TUFLOW" /wait %exe% -b -s1 HPC -s2 CPU -s3 NT!result! -s4 %%a -nt!result! FMA_T2_~s1~_~s2~_~s3~_~s4~_001.tcf
		)
	)
)
:next

echo.
echo Starting HPC Solver GPU hardware simulations
set A=20.00m 10.00m
:: Loop through each cell size
FOR %%a in (%A%) do (
    echo Running %%a model with HPC GPU solver
    Start "TUFLOW" /wait %exe% -b -s1 HPC -s2 GPU -s3 PU1 -s4 %%a FMA_T2_~s1~_~s2~_~s3~_~s4~_001.tcf
)
echo Finished benchmarking runs
goto :end

:break
echo Unable to run benchmark tests. From release 2017-09-AA, TUFLOW no longer supports 32 bit architecture.

:end
pause
