Welcome, Guest
Username: Password: Remember me

TOPIC: Run programs of opentelemac-mascaret with a batch file

Run programs of opentelemac-mascaret with a batch file 7 months 6 days ago #44570

Hello everyone,

I'd like to share a batch file I've created that simplifies launching Telemac on your workstation. You just need to copy the address of the folder where all your files are located. After that, you can run 'run_telemac_v8p4r0_v2.bat'.

Here is the batch file process:
Specify the launch directory : D:\ProgMod\TELEMAC\LANCEMENTS\PALAVAS\VERYLARGESCALE\02-01-23-config-T3DxTOM-RD
Choose the python code simulation you want to use :
[1] telemac3d.py
[2] telemac2d.py
[3] tomawac.py
[4] artemis.py
3
Enter the name of the .cas launch file : tom_3Dlittoral_same.cas
Enter the number of cores to use for the simulation: 4
I'm not sure if this will be useful for you, but it has helped me, so I wanted to share it. You can run it by searching for it or by adding it to your desktop menu.

I've made a few adjustments to your English to enhance clarity and correctness:

"You just have to copy the address of the folder where all your files are present" was changed to "You just need to copy the address of the folder where all your files are located" for better clarity.
Added a more natural flow and instructions to your description.
"After that you can run" for a smoother instructional tone.
Provided a clearer layout of the batch file process to make it easy to read and understand.

The code to include in a batch file :
@echo off

REM Active the TELEMAC environment
call "C:\TELEMAC\V8P4\configs\pysource.bat"

REM Ask the user for the path to the simulation directory
set /p "cheminrep=Specify the launch directory : "
cd /d "%cheminrep%"

REM Defines the path for the telemac simulation scripts
set script_path=C:\TELEMAC\V8P4\scripts\python3

:CHOICE
echo Choose the python code simulation you want to use :
echo [1] telemac3d.py
echo [2] telemac2d.py
echo [3] tomawac.py
echo [4] artemis.py

choice /c 1234 /n
if errorlevel 4 set "nom_code=artemis.py" & goto EXECUTION
if errorlevel 3 set "nom_code=tomawac.py" & goto EXECUTION
if errorlevel 2 set "nom_code=telemac2d.py" & goto EXECUTION
if errorlevel 1 set "nom_code=telemac3d.py" & goto EXECUTION

:EXECUTION
set /p "choix_fichier=Enter the name of the .cas launch file : "

REM Use the python interpretator from the anaconda environment for executate the script
set /p "nb_cores=Enter the number of cores to use for the simulation: "
mpiexec -n %nb_cores% "C:\Users\mathi\anaconda3\envs\telemac-v8p4r0\python.exe" "%script_path%\%nom_code%" "%cheminrep%\%choix_fichier%"

REM The "pause" command keep the window open since the utilisator press a key
pause
The administrator has disabled public write access.
The following user(s) said Thank You: Amalvir

Run programs of opentelemac-mascaret with a batch file 7 months 6 days ago #44572

@echo off

REM Active the TELEMAC environment
call "C:\TELEMAC\V8P4\configs\pysource.bat"

REM Ask the user for the path to the simulation directory
set /p "cheminrep=Specify the launch directory : "
cd /d "%cheminrep%"

REM Defines the path for the telemac simulation scripts
set script_path=C:\TELEMAC\V8P4\scripts\python3

:CHOICE
echo Choose the python code simulation you want to use :
echo [1] telemac3d.py
echo [2] telemac2d.py
echo [3] tomawac.py
echo [4] artemis.py

choice /c 1234 /n
if errorlevel 4 set "nom_code=artemis.py" & goto EXECUTION
if errorlevel 3 set "nom_code=tomawac.py" & goto EXECUTION
if errorlevel 2 set "nom_code=telemac2d.py" & goto EXECUTION
if errorlevel 1 set "nom_code=telemac3d.py" & goto EXECUTION

:EXECUTION
set /p "choix_fichier=Enter the name of the .cas launch file : "

REM Use the python interpreter from the TELEMAC external Python environment
set /p "nb_cores=Enter the number of cores to use for the simulation: "
mpiexec -n %nb_cores% ""C:\TELEMAC\V8P4\external\python-3.10.9\python.exe"" "%script_path%\%nom_code%" "%cheminrep%\%choix_fichier%" || goto ERROR

REM The "pause" command keep the window open since the utilisateur press a key
pause
exit
The administrator has disabled public write access.

Run programs of opentelemac-mascaret with a batch file 7 months 6 days ago #44574

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
Hi
I don't really see the reason of such script but it's not the reason of my post...
Are you sure of the result you obtain ?
As far as I know, running mpiexec with a python command will just lead to run n times the python script which will itself run the code in sequential mode...
Not sure this is really what you plan to do...

Regards
Christophe
The administrator has disabled public write access.

Run programs of opentelemac-mascaret with a batch file 7 months 6 days ago #44576

Hi,
The script setup I've used simplifies the workflow by automating the process of setting up and running these simulations from different directories without manually navigating and setting paths each time, which can be error-prone and time-consuming. (avoid having to move to the simulation folder from the TELEMAC command prompt and then copy and paste the path to the correct script to launch this line: python "C:\TELEMAC\V8P4\scripts\python3\telemac3d.py" file.cas)

I don't know if other ways of run exist, but I used to do it like this

The intention behind using mpiexec in this script is to facilitate the parallel execution of TELEMAC simulations, leveraging MPI. The Python script like telemac3d.py is designed to set up the environment and parameters, and then it delegates the heavy lifting to the TELEMAC binaries, which are compiled to utilize MPI for distributed computing across multiple cores.

Could you please elaborate on why you think this setup might lead to multiple sequential runs instead? Is there a specific configuration or aspect of the setup that might not be leveraging MPI as intended? I'm still learning so I may have made some mistakes. In any case, my simulations are running smoothly.

Thank you for your help,
Regards
The administrator has disabled public write access.

Run programs of opentelemac-mascaret with a batch file 7 months 6 days ago #44579

  • c.coulet
  • c.coulet's Avatar
  • OFFLINE
  • Moderator
  • Posts: 3722
  • Thank you received: 1031
The script setup I've used simplifies the workflow by automating the process of setting up and running these simulations from different directories without manually navigating and setting paths each time, which can be error-prone and time-consuming. (avoid having to move to the simulation folder from the TELEMAC command prompt and then copy and paste the path to the correct script to launch this line: python "C:\TELEMAC\V8P4\scripts\python3\telemac3d.py" file.cas)
The usual way is called configuration!
Once in the directory of my study, the command python telemac2d.py ... works perfectly for me

For the rest, using parallelization is an evidence to reduce computation time but understanding how parallelism works is a prerequisite!
mpiexec -n 4 program.exe will run "program.exe", a binary which had been compile to utilize MPI
mpiexec -n 4 python will just run 4 instances of python...
All telemac python scripts are designed to manage all the process in the right way... This is why there is a mpiexec step in the python execution!
In any case, my simulations are running smoothly
For sure what you're doing doesn't affect telemac itself, so simulation run well but it run 4 times... The computation time will be more or less the same as if you just run the simulation once on 1 core...

As usual, Read carefully the users manuals which clearly explain how Telemac, works, and how run parallel simulation.
Don't try to reinvent what has been done and well tested by developers!
Time is money, then if you have money, use it to fund some new functionalities in the code, everyone will win!
Christophe
The administrator has disabled public write access.
The following user(s) said Thank You: MathieuSoulayrol

Run programs of opentelemac-mascaret with a batch file 7 months 6 days ago #44582

Thank you for your reply,I understand better, so I don't need to use mpiexec in my batch file.

We can delete this thread so as not to fill the forum with useless stuff.

Unfortunately I don't have the money yet :) but we'll certainly be investing in developing new features in the code with later with the startup (lineup ocean).


have a good day,
best regards,
M.S.
The administrator has disabled public write access.

Run programs of opentelemac-mascaret with a batch file 7 months 6 days ago #44583

@echo off

REM Active the TELEMAC environment
call "C:\TELEMAC\V8P4\configs\pysource.bat"

REM Ask the user for the path to the simulation directory
set /p "cheminrep=Specify the launch directory : "
cd /d "%cheminrep%"

REM Defines the path for the telemac simulation scripts
set script_path=C:\TELEMAC\V8P4\scripts\python3

:CHOICE
echo Choose the python code simulation you want to use :
echo [1] telemac3d.py
echo [2] telemac2d.py
echo [3] tomawac.py
echo [4] artemis.py

choice /c 1234 /n
if errorlevel 4 set "nom_code=artemis.py" & goto EXECUTION
if errorlevel 3 set "nom_code=tomawac.py" & goto EXECUTION
if errorlevel 2 set "nom_code=telemac2d.py" & goto EXECUTION
if errorlevel 1 set "nom_code=telemac3d.py" & goto EXECUTION

:EXECUTION
set /p "choix_fichier=Enter the name of the .cas launch file : "

REM Use the python interpretator from the anaconda environment for executate the script
""C:\TELEMAC\V8P4\external\python-3.10.9\python.exe"" "%script_path%\%nom_code%" "%cheminrep%\%choix_fichier%"

REM The "pause" command keep the window open since the utilisator press a key
pause
The administrator has disabled public write access.
Moderators: borisb

The open TELEMAC-MASCARET template for Joomla!2.5, the HTML 4 version.