interp_nam = "interp"
except_nam = "noexcepthandler"
terminal_nam = "terminal"
+batch_nam = "batch"
# values in XML configuration file giving specific module parameters (<module_name> section)
# which are stored in opts with key <module_name>_<parameter> (eg SMESH_plugins)
dest="gui",
help=help_str)
+ help_str = "Launch in Batch Mode. (Without GUI on batch machine)"
+ o_b = optparse.Option("-b",
+ "--batch",
+ action="store_true",
+ dest="batch",
+ help=help_str)
+
help_str = "Launch in GUI mode [default]."
o_g = optparse.Option("-g",
"--gui",
# All options
opt_list = [o_t,o_g, # GUI/Terminal
o_d,o_o, # Desktop
+ o_b, # Batch
o_l,o_f, # Use logger or log-file
o_u, # Execute python scripts
o_r, # Configuration XML file
# GUI/Terminal, Desktop, Splash, STUDY_HDF
args["session_gui"] = False
+ args[batch_nam] = False
args["study_hdf"] = None
+ print 'launchConfigureParser cmd_opts',cmd_opts
if cmd_opts.gui is not None:
args[gui_nam] = cmd_opts.gui
+ if cmd_opts.batch is not None:
+ args[batch_nam] = True
+ print 'launchConfigureParser args[',batch_nam,']',args[batch_nam]
if args[gui_nam]:
args["session_gui"] = True
if cmd_opts.desktop is not None:
python_version="python%d.%d" % sys.version_info[0:2]
modules_root_dir_list = []
+ os.putenv('SALOME_BATCH','0')
+ if args["batch"] :
+ os.putenv('SALOME_BATCH','1')
+ print 'SALOME_BATCH :',os.getenv('SALOME_BATCH')
if args["gui"] :
modules_list = modules_list[:] + ["GUI"]
modules_list = modules_list[:] + ["KERNEL"]
# attente de la disponibilite du Container C++ local dans le Naming Service
#
- if ('cppContainer' in args['standalone']) | (args["gui"] == 0):
+ if ('cppContainer' in args['standalone']) :
myServer=ContainerCPPServer(args)
myServer.run()
clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID)
i = 0
while i < len( toimport ) :
if toimport[ i ] == 'killall':
+ clt.showNS()
killAllPorts()
import sys
sys.exit(0)
def main():
"""Salome launch as a main application"""
import sys
+ print "runSalome running on ",os.getenv('HOSTNAME')
+ print os.environ.itervalues
args, modules_list, modules_root_dir = get_config()
kill_salome(args)
save_config = True
*/
typedef sequence<string> MachineList;
typedef sequence<string> CompoList;
+ typedef sequence<string> FilesToExportList;
/*!
exception thrown if a computer is not found in the catalog
in ResPolicy policy,
in CompoList componentList );
+ Container GiveContainer( in MachineParameters params,
+ in ResPolicy policy,
+ in CompoList componentList );
+
+ long batchSalomeJob( in string fileToExecute ,
+ in FilesToExportList filesToExport ,
+ in long NumberOfProcessors ,
+ in MachineParameters params ) ;
+
string FindFirst(in MachineList possibleComputers);
MachineList GetFittingResources( in MachineParameters params,
<!DOCTYPE ResourcesCatalog>
<resources>
-<machine hostname="is111790" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL/salome.sh" >
-<modules modulePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL" moduleName="KERNEL" />
-<modules modulePath="/export/home/LGLS/Products/MED_@VERSION@" moduleName="MED" />
-<modules modulePath="/export/home/LGLS/Products/GEOM_@VERSION@" moduleName="GEOM" />
-<modules modulePath="/export/home/LGLS/Products/SMESH_@VERSION@" moduleName="SMESH" />
-<modules modulePath="/export/home/LGLS/Products/SUPERV_@VERSION@" moduleName="SUPERV" />
-<modules modulePath="/export/home/LGLS/Products/VISU_@VERSION@" moduleName="VISU" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYCOMPO_INSTALL" moduleName="MYCOMPO" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYMPICOMPO_INSTALL" moduleName="MYMPICOMPO" />
+<machine hostname="is111918" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/KERNEL_3.2.6" moduleName="KERNEL" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SUPERV_3.2.6" moduleName="SUPERV" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/VISU_3.2.6" moduleName="VISU" />
</machine>
-<machine hostname="is111915" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL/salome.sh" >
-<modules modulePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL" moduleName="KERNEL" />
-<modules modulePath="/export/home/LGLS/Products/MED_@VERSION@" moduleName="MED" />
-<modules modulePath="/export/home/LGLS/Products/GEOM_@VERSION@" moduleName="GEOM" />
-<modules modulePath="/export/home/LGLS/Products/SMESH_@VERSION@" moduleName="SMESH" />
-<modules modulePath="/export/home/LGLS/Products/SUPERV_@VERSION@" moduleName="SUPERV" />
-<modules modulePath="/export/home/LGLS/Products/VISU_@VERSION@" moduleName="VISU" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYCOMPO_INSTALL" moduleName="MYCOMPO" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYMPICOMPO_INSTALL" moduleName="MYMPICOMPO" />
+<machine hostname="is102430" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/KERNEL_3.2.6" moduleName="KERNEL" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SUPERV_3.2.6" moduleName="SUPERV" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/VISU_3.2.6" moduleName="VISU" />
</machine>
-<machine hostname="is111918" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL/salome.sh" >
-<modules modulePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL" moduleName="KERNEL" />
-<modules modulePath="/export/home/LGLS/Products/MED_@VERSION@" moduleName="MED" />
-<modules modulePath="/export/home/LGLS/Products/GEOM_@VERSION@" moduleName="GEOM" />
-<modules modulePath="/export/home/LGLS/Products/SMESH_@VERSION@" moduleName="SMESH" />
-<modules modulePath="/export/home/LGLS/Products/SUPERV_@VERSION@" moduleName="SUPERV" />
-<modules modulePath="/export/home/LGLS/Products/VISU_@VERSION@" moduleName="VISU" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYCOMPO_INSTALL" moduleName="MYCOMPO" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYMPICOMPO_INSTALL" moduleName="MYMPICOMPO" />
+<machine hostname="is125604" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/KERNEL_3.2.6" moduleName="KERNEL" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SUPERV_3.2.6" moduleName="SUPERV" />
+<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/VISU_3.2.6" moduleName="VISU" />
</machine>
-<machine hostname="is111996" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL/salome.sh" >
-<modules modulePath="/home/secher/SALOME2_INSTALL/KERNEL_INSTALL" moduleName="KERNEL" />
-<modules modulePath="/export/home/LGLS/Products/MED_@VERSION@" moduleName="MED" />
-<modules modulePath="/export/home/LGLS/Products/GEOM_@VERSION@" moduleName="GEOM" />
-<modules modulePath="/export/home/LGLS/Products/SMESH_@VERSION@" moduleName="SMESH" />
-<modules modulePath="/export/home/LGLS/Products/SUPERV_@VERSION@" moduleName="SUPERV" />
-<modules modulePath="/export/home/LGLS/Products/VISU_@VERSION@" moduleName="VISU" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYCOMPO_INSTALL" moduleName="MYCOMPO" />
-<modules modulePath="/home/secher/SALOME2_INSTALL/MYMPICOMPO_INSTALL" moduleName="MYMPICOMPO" />
+<machine hostname="tantal" alias="tantale.ccc.cea.fr" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="s" mode="b" nbOfNodes="236" nbOfProcPerNode="4" appliPath="/workdir/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/KERNEL_install" moduleName="KERNEL" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/NETGENPLUGIN_3.2.6" moduleName="NETGENPLUGIN" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/NETGENPLUGIN_3.2.6" moduleName="NETGENPLUGIN" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/YACS_install" moduleName="YACS" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/SRHEOLEFCPP_install" moduleName="SRHEOLEFCPP" />
+<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/SRHEOLEF_install" moduleName="SRHEOLEF" />
</machine>
</resources>
AC_REQUIRE([AC_PROG_CC])dnl
+AC_ARG_WITH(mpi_lib,
+ [AC_HELP_STRING([--with-mpi_lib=DIR],[directory path of MPICH lib installation])],
+ MPILIBREQUESTED="$withval")
+
AC_ARG_WITH(mpi,
[AC_HELP_STRING([--with-mpi=DIR],[root directory path of MPICH installation])],
MPIREQUESTED="yes",MPIREQUESTED="no")
fi
fi
+ if test x"$MPILIBREQUESTED" != x; then
+ MPI_LIBS="-L$MPILIBREQUESTED"
+ fi
+
CPPFLAGS_old="$CPPFLAGS"
CPPFLAGS="$MPI_INCLUDES $CPPFLAGS"
AC_CHECK_HEADER(mpi.h,WITHMPI="yes",WITHMPI="no")
if test "$WITHMPI" = "yes";then
mpi_ok=yes
- MPI_LIBS="$MPI_LIBS -lmpi"
+ MPI_LIBS="$MPI_LIBS -lmpi -lmpio -lmpiCC"
else
mpi_ok=no
fi
@MPI_INCLUDES@ \
@CAS_CPPFLAGS@ @CAS_CXXFLAGS@ \
@QT_MT_INCLUDES@ \
+ -I$(srcdir)/../Batch \
-I$(srcdir)/../Basics \
-I$(srcdir)/../SALOMELocalTrace \
-I$(srcdir)/../NamingService \
../Utils/libOpUtil.la \
../SALOMELocalTrace/libSALOMELocalTrace.la \
../Basics/libSALOMEBasics.la \
+ ../Batch/libSalomeBatch.la \
$(top_builddir)/idl/libSalomeIDLKernel.la\
@MPI_LIBS@ \
@CORBA_LIBS@
SALOME_Container_LDADD =\
libSalomeContainer.la \
$(COMMON_LIBS) \
- ../Basics/libSALOMEBasics.la
+ ../Basics/libSALOMEBasics.la \
+ ../Batch/libSalomeBatch.la
SALOME_ContainerManagerServer_SOURCES =\
libSalomeContainer.la \
$(COMMON_LIBS) \
../Basics/libSALOMEBasics.la
+ ../Batch/libSalomeBatch.la
#endif
#include <vector>
#include "Utils_CorbaException.hxx"
+#include "Batch_Date.hxx"
#define TIME_OUT_TO_LAUNCH_CONT 21
using namespace std;
+vector<Engines::Container_ptr> SALOME_ContainerManager::_batchLaunchedContainers;
+
+vector<Engines::Container_ptr>::iterator SALOME_ContainerManager::_batchLaunchedContainersIter;
+
const char *SALOME_ContainerManager::_ContainerManagerNameInNS =
"/ContainerManager";
FindOrStartContainer(const Engines::MachineParameters& params,
const Engines::MachineList& possibleComputers)
{
- long id;
- string containerNameInNS;
- char idc[3*sizeof(long)];
-
Engines::Container_ptr ret = FindContainer(params,possibleComputers);
if(!CORBA::is_nil(ret))
return ret;
return StartContainer(params,possibleComputers,policy);
}
+//=============================================================================
+/*! CORBA Method:
+ * Give a suitable Container in a list of machines
+ * \param params Machine Parameters required for the container
+ * \param possibleComputers list of machines usable for start
+ */
+//=============================================================================
+
+Engines::Container_ptr
+SALOME_ContainerManager::
+GiveContainer(const Engines::MachineParameters& params,
+ Engines::ResPolicy policy,
+ const Engines::CompoList& componentList)
+{
+ if(strcmp(getenv("SALOME_BATCH"),"1")==0)
+ {
+ if(_batchLaunchedContainers.empty())
+ fillBatchLaunchedContainers();
+ return *(_batchLaunchedContainersIter++);
+ }
+ return StartContainer(params,policy,componentList);
+}
+
+
+//=============================================================================
+/*! CORBA Method:
+ * Submit a batch job on a cluster and returns the JobId
+ * \param fileToExecute : .py/.exe/.sh/... to execute on the batch cluster
+ * \param filesToExport : to export on the batch cluster
+ * \param NumberOfProcessors : Number of processors needed on the batch cluster
+ * \param params : Constraints for the choice of the batch cluster
+ */
+//=============================================================================
+long SALOME_ContainerManager::batchSalomeJob(
+ const char * fileToExecute ,
+ const Engines::FilesToExportList& filesToExport ,
+ const long NumberOfProcessors ,
+ const Engines::MachineParameters& params)
+{
+ BEGIN_OF("SALOME_ContainerManager::batchSalomeJob");
+ // Determination provisoire de l'extension .py
+ // Il faudra une classe dans Utils pour gerer les Path FileNames et Extensions
+ int lenf = strlen( fileToExecute ) ;
+ if ( strcmp( &fileToExecute[lenf-3] ,".py" ) == NULL ) {
+ int i = lenf-1 ;
+ while ( i >= 0 && fileToExecute[i] != '/' ) {
+ i -= 1 ;
+ }
+ char * FileNameToExecute = new char[lenf-4-i] ;
+ strncpy(FileNameToExecute , &fileToExecute[i+1] , lenf-4-i) ;
+ string fileNameToExecute =string( FileNameToExecute ) ;
+ delete FileNameToExecute ;
+ SCRUTE(fileNameToExecute) ;
+// Le /tmp n'est pas le meme d'un noeud a un autre ===>
+ //string DirForTmpFiles = string("/tmp/")+string(getenv("USER"))+string("/") ;
+ string DirForTmpFiles = string(getenv("HOME"))+string("/Batch/") ;
+ Batch::Date date = Batch::Date(time(0)) ;
+ std::string thedate = date.str() ;
+ int lend = thedate.size() ;
+ i = 0 ;
+ while ( i < lend ) {
+ if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) {
+ thedate[i] = '_' ;
+ }
+ i++ ;
+ }
+ SCRUTE(thedate);
+ DirForTmpFiles += thedate ;
+ SCRUTE(DirForTmpFiles) ;
+ // Problemes avec ResourcesManager ...
+ // Solution pour l'instant :
+ // 31.05.107 : hostname : tantal
+ // Alias : tantale.ccc.cea.fr
+ Engines::CompoList aCompoList ;
+ Engines::MachineList aMachineList = *GetFittingResources( params , aCompoList ) ;
+ SCRUTE(aMachineList[0]) ;
+ std::string aCluster = FindFirst( aMachineList) ;
+ SCRUTE(aCluster) ;
+ //Creation of /tmp/$USER/date_hh_mn_ss/ and copy of FileNameToExecute
+ // and of filesToExport in that directory
+ _ResManager->CopyFileNamesToExecute(aCluster,DirForTmpFiles,fileToExecute,filesToExport) ;
+ //Creation of /tmp/$USER/date_hh_mn_ss/runSalome_'FileNameToExecute'_Batch.sh
+ string runSalome_Batch = _ResManager->BuildCmdrunSalomeBatch(aCluster,DirForTmpFiles,fileNameToExecute) ;
+ SCRUTE(runSalome_Batch) ;
+ //Creation of /tmp/$USER/date_hh_mn_ss/'FileNameToExecute'_Batch.sh
+ string FileNameToExecute_Batch = _ResManager->BuildCmdFileNameToExecute_Batch(aCluster,NumberOfProcessors,DirForTmpFiles,fileNameToExecute) ;
+ SCRUTE(FileNameToExecute_Batch) ;
+ //Creation of /tmp/$USER/date_hh_mn_ss/'FileNameToExecute'_bsub.sh
+ string FileNameToExecute_bsub = _ResManager->BuildCmdFileNameToExecute_bsub(aCluster,DirForTmpFiles,fileNameToExecute) ;
+ SCRUTE(FileNameToExecute_bsub) ;
+ //Launch of /tmp/$USER/date_hh_mn_ss/'FileNameToExecute'_bsub.sh on theCluster
+ string sshCommand = _ResManager->CmdToExecute_bsub(aCluster,DirForTmpFiles,fileNameToExecute) ;
+ SCRUTE(sshCommand) ;
+ }
+ else {
+ MESSAGE("SALOME_ContainerManager::batchSalomeJob unknown extension " << fileToExecute);
+ }
+ END_OF("SALOME_ContainerManager::batchSalomeJob");
+}
+
//=============================================================================
/*!
*
{
return _ResManager->GetMachineParameters(hostname);
}
+
+void SALOME_ContainerManager::fillBatchLaunchedContainers()
+{
+ _batchLaunchedContainers.clear();
+ _NS->Change_Directory("/Containers");
+ vector<string> vec = _NS->list_directory_recurs();
+ for(vector<string>::iterator iter = vec.begin();iter!=vec.end();iter++){
+ CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
+ Engines::Container_ptr cont=Engines::Container::_narrow(obj);
+ if(!CORBA::is_nil(cont)){
+ _batchLaunchedContainers.push_back(cont);
+ }
+ }
+ _batchLaunchedContainersIter=_batchLaunchedContainers.begin();
+}
Engines::Container_ptr
StartContainer(const Engines::MachineParameters& params,
- Engines::ResPolicy policy,
- const Engines::CompoList& componentList);
+ Engines::ResPolicy policy,
+ const Engines::CompoList& componentList);
+
+ Engines::Container_ptr
+ GiveContainer(const Engines::MachineParameters& params,
+ Engines::ResPolicy policy,
+ const Engines::CompoList& componentList);
+
+ long batchSalomeJob(const char * fileToExecute ,
+ const Engines::FilesToExportList& filesToExport ,
+ const long NumberOfProcessors ,
+ const Engines::MachineParameters& params);
Engines::MachineList *
GetFittingResources(const Engines::MachineParameters& params,
FindContainer(const Engines::MachineParameters& params,
const char *theMachine);
+ void fillBatchLaunchedContainers();
+
long GetIdForContainer(void);
long _id;
SALOME_ResourcesManager *_ResManager;
SALOME_NamingService *_NS;
+ static std::vector<Engines::Container_ptr> _batchLaunchedContainers;
+ static std::vector<Engines::Container_ptr>::iterator _batchLaunchedContainersIter;
};
#endif
SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName,
const char *componentName)
{
+ if(strcmp(getenv("SALOME_BATCH"),"1")==0)
+ {
+ MESSAGE("SALOME_LifeCycleCORBA::FindOrLoad_Component BATCH " << containerName << " " << componentName ) ;
+ _NS->Change_Directory("/Containers");
+ CORBA::Object_ptr obj=_NS->Resolve(containerName);
+ Engines::Container_var cont=Engines::Container::_narrow(obj);
+ bool isLoadable = cont->load_component_Library(componentName);
+ if (!isLoadable) return Engines::Component::_nil();
+
+ Engines::Component_ptr myInstance =
+ cont->create_component_instance(componentName, 0);
+ return myInstance;
+ }
+ MESSAGE("SALOME_LifeCycleCORBA::FindOrLoad_Component INTERACTIF " << containerName << " " << componentName ) ;
+ //#if 0
// --- Check if Component Name is known in ModuleCatalog
if (! isKnownComponentClass(componentName))
// SCRUTE(params->isMPI);
free(stContainer);
return FindOrLoad_Component(params,componentName);
-
+ //#endif
}
//=============================================================================
return command;
}
+//=============================================================================
+/*!
+ * Copy FileNameToExecute and filesToExport in DirForTmpFiles of machine
+ */
+//=============================================================================
+void SALOME_ResourcesManager::CopyFileNamesToExecute(const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& PathFileNameToExecute ,
+ const Engines::FilesToExportList& filesToExport) {
+ BEGIN_OF("SALOME_ResourcesManager::CopyFileNamesToExecute");
+ const ParserResourcesType& resInfo = _resourcesList[machine];
+ if (resInfo.Protocol == rsh)
+ {
+ string commandRcp;
+ commandRcp = "rsh ";
+ commandRcp += resInfo.Alias;
+ commandRcp += " mkdir -p ";
+ commandRcp += DirForTmpFiles ;
+ system(commandRcp.c_str());
+
+ commandRcp = "rcp ";
+ commandRcp += PathFileNameToExecute;
+ commandRcp += " ";
+ commandRcp += resInfo.Alias;
+ commandRcp += ":";
+ commandRcp += DirForTmpFiles ;
+ system(commandRcp.c_str());
+
+ int i ;
+ for ( i = 0 ; i < filesToExport.length() ; i++ ) {
+ commandRcp = "rcp ";
+ commandRcp += filesToExport[i] ;
+ commandRcp += " ";
+ commandRcp += resInfo.Alias;
+ commandRcp += ":";
+ commandRcp += DirForTmpFiles ;
+ system(commandRcp.c_str());
+ }
+ }
+
+ else if (resInfo.Protocol == ssh)
+ {
+ string commandSsh;
+ commandSsh = "ssh ";
+ commandSsh += resInfo.Alias;
+ commandSsh += " \"mkdir -p ";
+ commandSsh += DirForTmpFiles ;
+ commandSsh += "\"" ;
+ SCRUTE(commandSsh.c_str());
+ system(commandSsh.c_str());
+
+ commandSsh = "scp ";
+ commandSsh += PathFileNameToExecute ;
+ commandSsh += " ";
+ commandSsh += resInfo.Alias;
+ commandSsh += ":";
+ commandSsh += DirForTmpFiles ;
+ SCRUTE(commandSsh);
+ system(commandSsh.c_str());
+
+ int i ;
+ for ( i = 0 ; i < filesToExport.length() ; i++ ) {
+ commandSsh = "scp ";
+ commandSsh += filesToExport[i] ;
+ commandSsh += " ";
+ commandSsh += resInfo.Alias;
+ commandSsh += ":";
+ commandSsh += DirForTmpFiles ;
+ SCRUTE(commandSsh);
+ system(commandSsh.c_str());
+ }
+ }
+ else
+ throw SALOME_Exception("Unknown protocol");
+
+ END_OF("SALOME_ResourcesManager::CopyFileNamesToExecute");
+}
+
+//=============================================================================
+/*!
+ * builds the shell to create for runSalome Batch on a Cluster :
+ * #! /bin/sh -f
+ * source preReqFilePath
+ * export PYTHONPATH=/$HOME/Batch/date_hh_mn_ss:$PYTHONPATH
+ * if test $SLURM_PROCID = 0; then
+ * runSalome --terminal --batch --modules=ListOfModules --standalone=registry,study,moduleCatalog --execute='FileNameToExecute',killall --killall
+ * else
+ * sleep 10
+ * export SALOME_BATCH="1"
+ * SALOME_Container "YACS_Server_"${SLURM_PROCID}
+ * fi
+ *
+ * with preReqFilePath of CatalogResource for Salome environnement
+ * with ListOfModules of CatalogResource
+ * with FileNameToExecute as python script to execute
+ */
+//=============================================================================
+std::string SALOME_ResourcesManager::BuildCmdrunSalomeBatch(
+ const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) {
+ BEGIN_OF("SALOME_ResourcesManager::BuildCmdrunSalomeBatch");
+ _TmpFileName = BuildTemporaryFileName();
+ ofstream tempOutputFile;
+ tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
+ const ParserResourcesType& resInfo = _resourcesList[machine];
+ resInfo.Print() ;
+ tempOutputFile << "#! /bin/sh -f" << endl ;
+ tempOutputFile << "source " ;
+ tempOutputFile << resInfo.AppliPath << endl ;
+ tempOutputFile << "export PYTHONPATH=" ;
+ tempOutputFile << DirForTmpFiles ;
+ tempOutputFile << ":$PYTHONPATH" << endl ;
+ tempOutputFile << "if test $SLURM_PROCID = 0; then" << endl ;
+ tempOutputFile << " runSalome --terminal --batch --modules=" ;
+ int i ;
+ for ( i = 0 ; i < resInfo.ModulesList.size() ; i++ ) {
+ tempOutputFile << resInfo.ModulesList[i] ;
+ if ( i != resInfo.ModulesList.size()-1 )
+ tempOutputFile << "," ;
+ }
+ tempOutputFile << " --standalone=registry,study,moduleCatalog --execute=" ;
+ tempOutputFile << FileNameToExecute ;
+ tempOutputFile << ",killall --killall" << endl ;
+ tempOutputFile << "else" << endl ;
+ tempOutputFile << " sleep 10" << endl ;
+ tempOutputFile << " export SALOME_BATCH='1'" << endl ;
+ tempOutputFile << " SALOME_Container 'YACS_Server_'${SLURM_PROCID}" << endl ;
+ tempOutputFile << "fi" << endl ;
+ tempOutputFile.flush();
+ tempOutputFile.close();
+ chmod(_TmpFileName.c_str(), 0x1ED);
+ SCRUTE(_TmpFileName.c_str()) ;
+
+ if (resInfo.Protocol == rsh)
+ {
+ string commandRcp;
+ commandRcp = "rcp ";
+ commandRcp += _TmpFileName;
+ commandRcp += " ";
+ commandRcp += resInfo.Alias;
+ commandRcp += ":";
+ commandRcp += DirForTmpFiles ;
+ commandRcp += "/runSalome_" ;
+ commandRcp += FileNameToExecute ;
+ commandRcp += "_Batch.sh" ;
+ system(commandRcp.c_str());
+ RmTmpFile();
+ return commandRcp;
+ }
+
+ else if (resInfo.Protocol == ssh)
+ {
+ string commandSsh;
+ commandSsh = "scp ";
+ commandSsh += _TmpFileName;
+ commandSsh += " ";
+ commandSsh += resInfo.Alias;
+ commandSsh += ":";
+ commandSsh += DirForTmpFiles ;
+ commandSsh += "/runSalome_" ;
+ commandSsh += FileNameToExecute ;
+ commandSsh += "_Batch.sh" ;
+ system(commandSsh.c_str());
+ SCRUTE(commandSsh);
+ RmTmpFile();
+ return commandSsh;
+ }
+ else
+ throw SALOME_Exception("Unknown protocol");
+
+ END_OF("SALOME_ResourcesManager::BuildCmdrunSalomeBatch");
+ return string("");
+}
+
+//=============================================================================
+/*!
+ * builds the shell to create for runSalome Batch on a Cluster :
+ * #! /bin/sh -f
+ * #BSUB -n NumberOfProcessors
+ * #BSUB -o runSalome.log%J
+ * mpirun -srun /$HOME/Batch/date_hh_mn_ss/runSalome_'FileNameToExecute'_Batch.sh
+ * with NumberOfProcessors from params
+ * with FileNameToExecute as python script to execute
+ */
+//=============================================================================
+std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch(
+ const std::string& machine,
+ const long NumberOfProcessors,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) {
+ BEGIN_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch");
+ _TmpFileName = BuildTemporaryFileName();
+ ofstream tempOutputFile;
+ tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
+ const ParserResourcesType& resInfo = _resourcesList[machine];
+ resInfo.Print() ;
+ tempOutputFile << "#! /bin/sh -f" << endl ;
+ tempOutputFile << "#BSUB -n " ;
+ tempOutputFile << NumberOfProcessors << endl ;
+ tempOutputFile << "#BSUB -o runSalome.log%J" << endl ;
+ tempOutputFile << "mpirun -srun " ;
+ tempOutputFile << DirForTmpFiles ;
+ tempOutputFile << "/runSalome_" ;
+ tempOutputFile << FileNameToExecute ;
+ tempOutputFile << "_Batch.sh" << endl ;
+ tempOutputFile.flush();
+ tempOutputFile.close();
+ chmod(_TmpFileName.c_str(), 0x1ED);
+ SCRUTE(_TmpFileName.c_str()) ;
+
+ string commandRcp;
+ if (resInfo.Protocol == rsh)
+ {
+ commandRcp = "rcp ";
+ commandRcp += _TmpFileName;
+ commandRcp += " ";
+ commandRcp += resInfo.Alias;
+ commandRcp += ":";
+ commandRcp += DirForTmpFiles ;
+ commandRcp += "/" ;
+ commandRcp += FileNameToExecute ;
+ commandRcp += "_Batch.sh" ;
+ system(commandRcp.c_str());
+ }
+
+ else if (resInfo.Protocol == ssh)
+ {
+ commandRcp = "scp ";
+ commandRcp += _TmpFileName;
+ commandRcp += " ";
+ commandRcp += resInfo.Alias;
+ commandRcp += ":";
+ commandRcp += DirForTmpFiles ;
+ commandRcp += "/" ;
+ commandRcp += FileNameToExecute ;
+ commandRcp += "_Batch.sh" ;
+ system(commandRcp.c_str());
+ }
+ else
+ throw SALOME_Exception("Unknown protocol");
+
+ SCRUTE(commandRcp);
+ RmTmpFile();
+ END_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_Batch");
+
+ return commandRcp;
+}
+
+//=============================================================================
+/*!
+ * builds the shell to create for runSalome Batch on a Cluster :
+ * #! /bin/sh -f
+ * bsub < /$HOME/Batch/date_hh_mn_ss/'FileNameToExecute'_Batch.sh &
+ * with preReqFilePath of CatalogResource for Salome environnement
+ * with ListOfModules of CatalogResource
+ * with FileNameToExecute as python script to execute
+ */
+//=============================================================================
+std::string SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub(
+ const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) {
+ BEGIN_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub");
+ _TmpFileName = BuildTemporaryFileName();
+ ofstream tempOutputFile;
+ tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
+ const ParserResourcesType& resInfo = _resourcesList[machine];
+ resInfo.Print() ;
+ tempOutputFile << "#! /bin/sh -f" << endl ;
+ tempOutputFile << "bsub < " ;
+ tempOutputFile << DirForTmpFiles ;
+ tempOutputFile << "/" ;
+ tempOutputFile << FileNameToExecute ;
+ tempOutputFile << "_Batch.sh &" << endl ;
+ tempOutputFile.flush();
+ tempOutputFile.close();
+ chmod(_TmpFileName.c_str(), 0x1ED);
+ SCRUTE(_TmpFileName.c_str()) ;
+
+ string commandRcp;
+ if (resInfo.Protocol == rsh)
+ {
+ commandRcp = "rcp ";
+ commandRcp += _TmpFileName;
+ commandRcp += " ";
+ commandRcp += resInfo.Alias;
+ commandRcp += ":";
+ commandRcp += DirForTmpFiles ;
+ commandRcp += "/" ;
+ commandRcp += FileNameToExecute ;
+ commandRcp += "_bsub.sh" ;
+ system(commandRcp.c_str());
+ }
+
+ else if (resInfo.Protocol == ssh)
+ {
+ commandRcp = "scp ";
+ commandRcp += _TmpFileName;
+ commandRcp += " ";
+ commandRcp += resInfo.Alias;
+ commandRcp += ":";
+ commandRcp += DirForTmpFiles ;
+ commandRcp += "/" ;
+ commandRcp += FileNameToExecute ;
+ commandRcp += "_bsub.sh" ;
+ system(commandRcp.c_str());
+ }
+ else
+ throw SALOME_Exception("Unknown protocol");
+
+ SCRUTE(commandRcp);
+ RmTmpFile();
+ END_OF("SALOME_ResourcesManager::BuildCmdFileNameToExecute_bsub");
+
+ return commandRcp;
+}
+
+//=============================================================================
+/*!
+ * builds the rsh/ssh command for submitting of a batch job :
+ * ssh tantale.ccc.cea.fr /$HOME/Batch/date_hh_mn_ss/'FileNameToExecute'_bsub.sh
+ * with FileNameToExecute as python script to execute
+ */
+//=============================================================================
+std::string SALOME_ResourcesManager::CmdToExecute_bsub(
+ const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) {
+ BEGIN_OF("SALOME_ResourcesManager::CmdToExecute_bsub");
+ const ParserResourcesType& resInfo = _resourcesList[machine];
+ string command;
+ resInfo.Print() ;
+
+ if (resInfo.Protocol == rsh)
+ command = "rsh " ;
+ else if (resInfo.Protocol == ssh)
+ command = "ssh ";
+ command += resInfo.Alias;
+ command += " \"tcsh " ;
+ command += DirForTmpFiles ;
+ command += "/" ;
+ command += FileNameToExecute ;
+ command += "_bsub.sh\"" ;
+ system(command.c_str());
+ SCRUTE(command.c_str()) ;
+ END_OF("SALOME_ResourcesManager::CmdToExecute_bsub");
+
+ return command;
+}
//=============================================================================
/*!
(const std::string& machine,
const Engines::MachineParameters& params, const long id);
+ void CopyFileNamesToExecute(const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& PathFileNameToExecute ,
+ const Engines::FilesToExportList& filesToExport) ;
+ std::string BuildCmdrunSalomeBatch(const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) ;
+ std::string BuildCmdFileNameToExecute_Batch(const std::string& machine,
+ const long NumberOfProcessors,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) ;
+ std::string BuildCmdFileNameToExecute_bsub(const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) ;
+ std::string CmdToExecute_bsub(const std::string& machine,
+ const std::string& DirForTmpFiles ,
+ const std::string& FileNameToExecute ) ;
+
std::string BuildCommandToLaunchLocalContainer
(const Engines::MachineParameters& params, const long id);