Welcome, Guest
Username: Password: Remember me

TOPIC: run in telemac 2d

run in telemac 2d 9 years 11 months ago #15304

  • amira
  • amira's Avatar
hi,
we can run three or four hydrodynamic calculation in telemac 2d simultaneously in a single computer.
The administrator has disabled public write access.

run in telemac 2d 9 years 11 months ago #15330

  • riadh
  • riadh's Avatar
Hello
is it a question ?
if you change the name of steering file or/and the fortran file, the name of the exe generated by the Perl version is different, and then more than one exe can exist simultaneously.
For the python version, I don't know.
with my best regards
Riadh
The administrator has disabled public write access.

run in telemac 2d 9 years 11 months ago #15334

Hello Amira,

As long as your computer has a multi-core processor then you can run simultaneous simulations on a local machine in an "embarrassingly parallel" fashion (e.g., 8 scalar simulations using a 4-core, hyper-threaded cpu). As Riadh mentioned, each individual simulation will need to have a unique steering file name, or be ran from a different directory. Once the simulations are prepared each simulation can be launched on an independent thread using either a batch script (e.g., *.bat, *.py) or by manually starting each simulation in a new "Command Prompt" window. It should also be noted that while you can theoretically run as many concurrent simulations as your machine's memory can handle, computational performance will decrease as more simulations are launched.

I will post a couple of example scripts later on today.

Cheers,
Chris
The administrator has disabled public write access.
The following user(s) said Thank You: amira

run in telemac 2d 9 years 11 months ago #15342

Please see the attached parallel batch script for running a series of concurrent scalar T2D simulations.



Follow the header notes, list the full pathname to each T2D steering file, and then run the batch script in a new command prompt window. This script assumes a Python/Windows installation.

Cheers,
Chris
The administrator has disabled public write access.
The following user(s) said Thank You: amira

run in telemac 2d 9 years 10 months ago #15355

Apparently the script didn't attach in my previous post (perhaps *.bat files aren't allowed?). Here is a second attempt to attach the script:

File Attachment:

File Name: TELEMAC2D_BATCH_FILE.txt
File Size: 5 KB


To use the script, simply change the file extension from *.txt to *.bat and update the path/names of your simulations.

If it still doesn't attach, please see the parallel batch script code pasted below:


::===============================================================
:: TELEMAC2D_BATCH_FILE( /0 , maxProc, hpg_id )
::===============================================================
:: TELEMAC-2D Performance Graph Batch File
:: Date created:  09/16/13
:: Date modified: 09/16/13

:: Modified By: Chris Gifford-Miears
:: Purpose: run the telemac2d simulations in an "embarrassingly parallel" 
:: fashion starting an independent simulation on each respective thread.
:: modified from:
:: http://stackoverflow.com/questions/672719/parallel-execution-of-shell-processes
:: example of running on DOS prompt: 
:: 1. >cd *batch_file_directory
:: 2. batch_file_directory>TELEMAC2D_BATCH_FILE /O 4 HPG-4

@echo off
setlocal enableDelayedExpansion
TITLE "T2D BATCH SIMULATION - %3"
:: Display the output of each process if the /O option is used
:: else ignore the output of each process
if /i "%~1" equ "/O" (
  set "lockHandle=1"
  set "showOutput=1"
) else (
  set "lockHandle=1^>nul 9"
  set "showOutput="
)
::-----------------------------------------------------------------------------
:: List of commands goes here. Each command is prefixed with :::
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_1.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_2.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_3.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_4.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_5.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_6.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_7.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_8.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_9.cas
::: telemac2d.py C:\0_GiffordMiears\SVNs\00_2D_HPG_checkout\hpg_r2_cas_files\t2d_input\fraser_hpg_r2_0_10.cas

::-----------------------------------------------------------------------------
:: Define the maximum number of parallel processes to run.
:: Each process number can optionally be assigned to a particular server
:: and/or cpu via psexec specs (untested).
set "maxProc=%2"

:: Optional - Define CPU targets in terms of PSEXEC specs
::           (everything but the command)
::
:: If a cpu is not defined for a proc, then it will be run on the local machine.
:: I haven't tested this feature, but it seems like it should work.
::
:: set cpu1=psexec \\server1 ...
:: set cpu2=psexec \\server1 ...
:: set cpu3=psexec \\server2 ...
:: etc.

:: For this demo force all cpu specs to undefined (local machine)
for /l %%N in (1 1 %maxProc%) do set "cpu%%N="

:: Get a unique base lock name for this particular instantiation.
:: Incorporate a timestamp from WMIC if possible, but don't fail if
:: WMIC not available. Also incorporate a random number.
  set "lock="
  for /f "skip=1 delims=-+ " %%T in ('2^>nul wmic os get localdatetime') do (
    set "lock=%%T"
    goto :break
  )
  :break
  set "lock=%temp%\lock%lock%_%random%_"

:: Initialize the counters
  set /a "startCount=0, endCount=0"

:: Clear any existing end flags
  for /l %%N in (1 1 %maxProc%) do set "endProc%%N="

:: Launch the commands in a loop
  set launch=1
  for /f "tokens=* delims=:" %%A in ('findstr /b ":::" "%~f0"') do (
    if !startCount! lss %maxProc% (
      set /a "startCount+=1, nextProc=startCount"
    ) else (
      call :wait
    )
    set cmd!nextProc!=%%A
    if defined showOutput echo -------------------------------------------------------------------------------
    echo !time! - proc!nextProc!: starting %%A
    2>nul del %lock%!nextProc!
    %= Redirect the lock handle to the lock file. The CMD process will     =%
    %= maintain an exclusive lock on the lock file until the process ends. =%
    start /b "" cmd /c %lockHandle%^>"%lock%!nextProc!" 2^>^&1 !cpu%%N! %%A
  )
  set "launch="

:wait
:: Wait for procs to finish in a loop
:: If still launching then return as soon as a proc ends
:: else wait for all procs to finish
  :: redirect stderr to null to suppress any error message if redirection
  :: within the loop fails.
  for /l %%N in (1 1 %startCount%) do (
    %= Redirect an unused file handle to the lock file. If the process is    =%
    %= still running then redirection will fail and the IF body will not run =%
    if not defined endProc%%N if exist "%lock%%%N" (
      %= Made it inside the IF body so the process must have finished =%
      if defined showOutput echo ===============================================================================
      echo !time! - proc%%N: finished !cmd%%N!
      if defined showOutput type "%lock%%%N"
      if defined launch (
        set nextProc=%%N
        exit /b
      )
      set /a "endCount+=1, endProc%%N=1"
    ) 9>>"%lock%%%N"
  ) 2>nul
  if %endCount% lss %startCount% (
    1>nul 2>nul ping /n 2 ::1
    goto :wait
  )

2>nul del %lock%*
if defined showOutput echo ===============================================================================
echo ======================================================
echo Cheers^^!
echo CGM
echo ======================================================
EXIT /b

Cheers,
Chris
The administrator has disabled public write access.

run in telemac 2d 6 years 2 months ago #31515

  • smk.svks
  • smk.svks's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 93
  • Thank you received: 1
Hi,

Do we have any script for Linux (Ubuntu) version??

Thanks
The administrator has disabled public write access.
Moderators: pham

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