string GetWcKey();
void SetWcKey(in string wcKey);
+
+ string GetWalltime();
+ void SetWalltime(in string walltime);
};
};
aMesh.GetMeshDS()->Modified();
+ // Cleanup done here as in Python the destructor is not called
+ aParMesh.cleanup();
+
return ret;
#endif
};
#include <utilities.h>
-#ifdef _DEBUG_
-static int MYDEBUG = 1;
-#else
-static int MYDEBUG = 0;
-#endif
-
SMESH_ParallelMesh::SMESH_ParallelMesh(int theLocalId,
SMESH_Gen* theGen,
bool theIsEmbeddedMode,
};
SMESH_ParallelMesh::~SMESH_ParallelMesh()
+{
+ cleanup();
+};
+
+void SMESH_ParallelMesh::cleanup()
{
DeletePoolThreads();
- if(!MYDEBUG)
+ std::cout << "Keeping tmp folder" << keepingTmpFolfer() << std::endl;
+ if(!keepingTmpFolfer())
+ {
+ MESSAGE("Set SMESH_KEEP_TMP to > 0 to keep temporary folders")
DeleteTmpFolder();
+ }
};
+//=============================================================================
+/*!
+ * \brief Checking if we should keep the temporary folder
+ * They are kept if the variable SMESH_KEEP_TMP is set to higher than 0
+ */
+//=============================================================================
+bool SMESH_ParallelMesh::keepingTmpFolfer()
+{
+ const char* envVar = std::getenv("SMESH_KEEP_TMP");
+ std::cout << "smesh_keep_tmp: " << envVar << std::endl;
+
+ if (envVar && (envVar[0] != '\0'))
+ {
+ try
+ {
+ const long long numValue = std::stoll(envVar);
+ return numValue > 0;
+ }
+ catch(const std::exception& e)
+ {
+ std::cerr << e.what() << '\n';
+ }
+ }
+
+ return false;
+};
//=============================================================================
void SMESH_ParallelMesh::DeleteTmpFolder()
{
#ifndef WIN32
+ MESSAGE("Deleting temporary folder" << tmp_folder.string());
fs::remove_all(tmp_folder);
#endif
}
bool theIsEmbeddedMode,
SMESHDS_Document* theDocument);
- virtual ~SMESH_ParallelMesh();
+ ~SMESH_ParallelMesh();
// Locking mechanism
void Lock() override {_my_lock.lock();};
int GetPoolNbThreads();
// Temporary folder
+ bool keepingTmpFolfer();
void CreateTmpFolder();
void DeleteTmpFolder();
boost::filesystem::path GetTmpFolder() {return tmp_folder;};
+ void cleanup();
//
bool IsParallel() override {return true;};
std::string GetWcKey() {return _wcKey;};
void SetWcKey(std::string wcKey) {_wcKey = wcKey;};
+ std::string GetWalltime() {return _walltime;};
+ void SetWalltime(std::string walltime) {_walltime = walltime;};
+
// Parallel computation
bool ComputeSubMeshes(
SMESH_Gen* gen,
int _nbNode = 1;
std::string _resource = "";
std::string _wcKey = "P11N0:SALOME";
+ std::string _walltime = "01:00:00";
};
#endif
void SMESH_ParallelMesh_i::SetWcKey(const char* wcKey){
DownCast()->SetWcKey(std::string(wcKey));
}
+
+//=============================================================================
+/*!
+ * \brief Get the walltime to use on ressource
+ */
+//=============================================================================
+char* SMESH_ParallelMesh_i::GetWalltime(){
+ return CORBA::string_dup(DownCast()->GetWalltime().c_str());
+}
+
+//=============================================================================
+/*!
+ * \brief Set the walltime to use on ressource
+ */
+//=============================================================================
+void SMESH_ParallelMesh_i::SetWalltime(const char* walltime){
+ DownCast()->SetWalltime(std::string(walltime));
+}
char* GetWcKey();
void SetWcKey(const char* wcKey);
+ char* GetWalltime();
+ void SetWalltime(const char* walltime);
+
private:
::SMESH_ParallelMesh* DownCast();
};
"""
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
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
launcher.getJobResults(job_id, "")
# Delete remote working dir
+ 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
+
launcher.clearJobWorkingDir(job_id)
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)")
""" Get Number of Node """
return self._mesh.mesh.GetWcKey()
+ def SetWalltime(self, walltime):
+ """ Set the number of Node for multinode """
+ self._mesh.mesh.SetWalltime(walltime)
+
+ def GetWalltime(self):
+ """ Get Number of Node """
+ return self._mesh.mesh.GetWalltime()
+
def __str__(self):
""" str conversion """
string = "\nParameter for MultiNode parallelism:\n"
string += "NbProcPerNode: {}\n".format(self.GetNbProcPerNode())
string += "NbNode: {}\n".format(self.GetNbNode())
string += "WcKey: {}\n".format(self.GetWcKey())
+ string += "Walltime: {}\n".format(self.GetWalltime())
return string