]> SALOME platform Git repositories - modules/smesh.git/blobdiff - src/SMESH_SWIG/mesher_launcher.py
Salome HOME
Compute also dump a check on isDone through function CheckCompute
[modules/smesh.git] / src / SMESH_SWIG / mesher_launcher.py
index f29e4b5a74d20b774bb8cde0cd3c79b4da0b1bd9..b92a4b5bc6f17dbd916e8f0aba80f45e5035ffbc 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env python3
 # -*- coding: utf-8 -*-
-## Copyright (C) 2021-2023  CEA/DEN, EDF R&D, OPEN CASCADE
+## Copyright (C) 2021-2024  CEA/DEN, EDF R&D, OPEN CASCADE
 ##
 ## This library is free software; you can redistribute it and/or
 ## modify it under the terms of the GNU Lesser General Public
@@ -22,7 +22,6 @@
 """
 File to run mesher from command line
 """
-#TODO: Make the execution path independant (output files are written in current directory)
 from os import environ, path
 import sys
 import subprocess as sp
@@ -31,7 +30,7 @@ from argparse import ArgumentParser
 import pydefx
 import pylauncher
 
-MESHER_HANDLED = ["NETGEN3D"]
+MESHER_HANDLED = ["NETGEN3D","NETGEN2D","NETGEN1D","NETGEN1D2D","NETGEN1D2D","GMSH3D"]
 
 CMD_TEMPLATE = \
 """{runner} {mesher} {mesh_file} {shape_file} {param_file} {elem_orientation_file} {new_element_file} {output_mesh_file} > {log_file} 2>&1"""
@@ -95,11 +94,16 @@ def get_runner(mesher):
     else:
         ext = ""
 
-    if mesher in ['NETGEN3D']:
+    if mesher in ['NETGEN3D','NETGEN2D','NETGEN1D','NETGEN1D2D','NETGEN1D2D']:
         exe_path = path.join("${NETGENPLUGIN_ROOT_DIR}",
                              "bin",
                              "salome",
                              "NETGENPlugin_Runner"+ext)
+    elif mesher in ['GMSH3D']:
+        exe_path = path.join("${GMSHPLUGIN_ROOT_DIR}",
+                             "bin",
+                             "salome",
+                             "GMSHPlugin_Runner"+ext)
     else:
         raise Exception("Mesher {mesher} is not handled".format(mesher=mesher))
 
@@ -107,8 +111,6 @@ def get_runner(mesher):
 
 def run_local(args):
     """ Simple Local run """
-    print("Local run")
-    #TODO: Check on how to handle log for windows (through sp.check_output)
     cmd = CMD_TEMPLATE.format(\
         runner=get_runner(args.mesher),
         mesher=args.mesher,
@@ -119,8 +121,6 @@ def run_local(args):
         new_element_file=args.new_element_file,
         log_file=path.join(path.dirname(args.shape_file), "run.log"),
         output_mesh_file=args.output_mesh_file)
-    print("Executing:")
-    print(cmd)
     sp.check_output(cmd, shell=True, cwd=path.dirname(args.shape_file))
 
 def run_pylauncher(args):
@@ -157,6 +157,7 @@ def run_pylauncher(args):
     job_params.resource_required.nb_proc = args.nb_proc
     job_params.resource_required.nb_proc_per_node = args.nb_proc_per_node
     job_params.resource_required.nb_node = args.nb_node
+    job_params.maximum_duration = args.walltime
 
     # job_params.pre_command = pre_command # command to run on frontal
     # script to run in batch mode
@@ -241,7 +242,15 @@ def run_pylauncher(args):
     launcher.getJobResults(job_id, "")
 
     # Delete remote working dir
-    launcher.clearJobWorkingDir(job_id)
+    del_tmp_folder = True
+    try:
+       val = int(environ.get("SMESH_KEEP_TMP", "0"))
+       del_tmp_folder = val < 0
+    except Exception as e:
+        del_tmp_folder = True
+
+    if del_tmp_folder:
+        launcher.clearJobWorkingDir(job_id)
 
 def def_arg():
     """ Define and parse arguments for the script """
@@ -291,6 +300,9 @@ def def_arg():
                            default=1,
                            type=int,
                            help="Number of node")
+    run_param.add_argument("--walltime",
+                           default="01:00:00",
+                           help="walltime for job submission HH:MM:SS (default 01:00:00)")
     run_param.add_argument("--wc-key",
                            default="P11N0:SALOME",
                            help="wc-key for job submission (default P11N0:SALOME)")