]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
improvement for batch on ccrt
authorrahuel <rahuel@opencascade.com>
Tue, 5 Jun 2007 07:51:58 +0000 (07:51 +0000)
committerrahuel <rahuel@opencascade.com>
Tue, 5 Jun 2007 07:51:58 +0000 (07:51 +0000)
bin/launchConfigureParser.py
bin/runSalome.py
idl/SALOME_ContainerManager.idl
resources/CatalogResources.xml.in
salome_adm/unix/config_files/check_mpi.m4
src/Container/Makefile.am
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/ResourcesManager/SALOME_ResourcesManager.cxx
src/ResourcesManager/SALOME_ResourcesManager.hxx

index ac9b89fd9765e572a689dba603ed183b881b56e1..112908c027590c9111378fe3106a50aeaa36dfdc 100755 (executable)
@@ -48,6 +48,7 @@ key_nam        = "key"
 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)
@@ -307,6 +308,13 @@ def CreateOptionParser (theAdditionalOptions=[]):
                           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",
@@ -489,6 +497,7 @@ def CreateOptionParser (theAdditionalOptions=[]):
     # 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
@@ -671,9 +680,14 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"):
 
     # 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:
index 1aa76c4c6237b2afb90b7d63c1affe410040c1d3..886ada9f8493819956e212b4a0e57b2c3c8eacc5 100755 (executable)
@@ -149,6 +149,10 @@ def set_env(args, modules_list, modules_root_dir):
     
     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"] 
@@ -712,7 +716,7 @@ def startSalome(args, modules_list, modules_root_dir):
     # 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)
@@ -859,6 +863,7 @@ def useSalome(args, modules_list, modules_root_dir):
         i = 0
         while i < len( toimport ) :
             if toimport[ i ] == 'killall':
+                clt.showNS()
                 killAllPorts()
                 import sys
                 sys.exit(0)
@@ -967,6 +972,8 @@ def no_main():
 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
index cdd128f72d73008ab16bc72e8f4920c56de44cf2..487d11b9b523900f1e089c1cd80ebd0201308374 100644 (file)
@@ -46,6 +46,7 @@ struct MachineParameters
 */
   typedef sequence<string> MachineList;
   typedef sequence<string> CompoList;
+  typedef sequence<string> FilesToExportList;
 
 /*!
     exception thrown if a computer is not found in the catalog
@@ -68,6 +69,15 @@ struct MachineParameters
                              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,
index c83cafac53f7e1e8dea1e99ec4c8002fe8708baf..874d32492f1d158e325475ae32baf477440f96f4 100644 (file)
@@ -1,48 +1,43 @@
 <!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>
index 57b796b729d46a609821b9e5c0134ef5f76d9a8b..914a47949cd523ddaeb218988a89f23ec8c081d9 100644 (file)
@@ -24,6 +24,10 @@ AC_DEFUN([CHECK_MPI],[
 
 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")
@@ -51,6 +55,10 @@ if test x"$MPIREQUESTED" = xyes; then
     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")
@@ -69,7 +77,7 @@ if test x"$MPIREQUESTED" = xyes; then
 
   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
index a41b9009b88961d97dd0dd82e23f89e3ca7881b8..3aa89538033d095067a002d08864e8c125b7e55c 100644 (file)
@@ -64,6 +64,7 @@ COMMON_CPPFLAGS=\
        @MPI_INCLUDES@ \
        @CAS_CPPFLAGS@ @CAS_CXXFLAGS@ \
        @QT_MT_INCLUDES@ \
+       -I$(srcdir)/../Batch \
        -I$(srcdir)/../Basics \
        -I$(srcdir)/../SALOMELocalTrace \
        -I$(srcdir)/../NamingService \
@@ -84,6 +85,7 @@ COMMON_LIBS =\
        ../Utils/libOpUtil.la \
        ../SALOMELocalTrace/libSALOMELocalTrace.la \
        ../Basics/libSALOMEBasics.la \
+       ../Batch/libSalomeBatch.la \
        $(top_builddir)/idl/libSalomeIDLKernel.la\
        @MPI_LIBS@ \
        @CORBA_LIBS@
@@ -133,7 +135,8 @@ SALOME_Container_CPPFLAGS =\
 SALOME_Container_LDADD =\
        libSalomeContainer.la \
        $(COMMON_LIBS) \
-       ../Basics/libSALOMEBasics.la
+       ../Basics/libSALOMEBasics.la \
+       ../Batch/libSalomeBatch.la
 
 
 SALOME_ContainerManagerServer_SOURCES =\
@@ -146,4 +149,5 @@ SALOME_ContainerManagerServer_LDADD =\
        libSalomeContainer.la \
        $(COMMON_LIBS) \
        ../Basics/libSALOMEBasics.la
+       ../Batch/libSalomeBatch.la
 
index 0bbea7465c9e5446fadc6a3175f0b6adb452a1f9..0acec7e1c48f67669b7b304fbbf8489540dcb5e0 100644 (file)
 #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";
 
@@ -154,10 +159,6 @@ SALOME_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;
@@ -293,6 +294,106 @@ StartContainer(const Engines::MachineParameters& params,
   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");
+}
+
 //=============================================================================
 /*! 
  * 
@@ -405,3 +506,18 @@ Engines::MachineParameters* SALOME_ContainerManager::GetMachineParameters(const
 {
   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();
+}
index 42f727c125a32189663b91e49aa20b0d5391d828..4bacf2c341fa2f748d8e7a5a358d8f15f67444d7 100644 (file)
@@ -64,8 +64,18 @@ public:
 
   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,
@@ -89,11 +99,15 @@ protected:
   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
index ab84068df192536bee829494c012b3b69d76f5fe..8c8de44a227767c175ba0a6940cacc46ae23160c 100644 (file)
@@ -228,6 +228,21 @@ Engines::Component_ptr
 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))
@@ -264,7 +279,7 @@ SALOME_LifeCycleCORBA::FindOrLoad_Component(const char *containerName,
 //   SCRUTE(params->isMPI);
   free(stContainer);
   return FindOrLoad_Component(params,componentName);
-  
+  //#endif  
 }
 
 //=============================================================================
index 72073dbfa630dc6121bd837b2a401f2924e51692..fee0979012d853a5394fdb7a6739a252b081e5e4 100644 (file)
@@ -509,6 +509,356 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer
   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;
+}
 
 //=============================================================================
 /*!
index 5cd69615627b45972f813ceb565835ecbe501ce8..b4a8e5cb1e8baedbb062bfc842fbadd82e0487c5 100644 (file)
@@ -76,6 +76,24 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesManager
     (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);