1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SALOME_ResourcesManager.hxx"
21 //#include "SALOME_Container_i.hxx"
22 #include "Utils_ExceptHandlers.hxx"
39 #include <sys/types.h>
41 #include "utilities.h"
43 #define MAX_SIZE_FOR_HOSTNAME 256;
47 //=============================================================================
51 //=============================================================================
53 SALOME_ResourcesManager::
54 SALOME_ResourcesManager(CORBA::ORB_ptr orb,
55 const char *xmlFilePath) :
56 _path_resources(xmlFilePath)
58 _NS = new SALOME_NamingService(orb);
62 //=============================================================================
64 * Standard constructor, parse resource file.
65 * - if ${APPLI} exists in environment,
66 * look for ${HOME}/*{APPLI}/CatalogResources.xml
67 * - else look for default:
68 * ${KERNEL_ROOT_DIR}/share/salome/resources/kernel/CatalogResources.xml
69 * - parse XML resource file.
71 //=============================================================================
73 SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb)
75 _NS = new SALOME_NamingService(orb);
76 _isAppliSalomeDefined = (getenv("APPLI") != 0);
79 if (_isAppliSalomeDefined)
81 _path_resources = getenv("HOME");
82 _path_resources += "/";
83 _path_resources += getenv("APPLI");
84 _path_resources += "/CatalogResources.xml";
89 _path_resources = getenv("KERNEL_ROOT_DIR");
90 _path_resources += "/share/salome/resources/kernel/CatalogResources.xml";
96 //=============================================================================
100 //=============================================================================
102 SALOME_ResourcesManager::~SALOME_ResourcesManager()
107 //=============================================================================
109 * get the list of name of ressources fitting for the specified module.
110 * If hostname specified, check it is local or known in resources catalog.
113 * - select first machines with corresponding OS (all machines if
114 * parameter OS empty),
115 * - then select the sublist of machines on witch the module is known
116 * (if the result is empty, that probably means that the inventory of
117 * modules is probably not done, so give complete list from previous step)
119 //=============================================================================
122 SALOME_ResourcesManager::
123 GetFittingResources(const Engines::MachineParameters& params,
124 const char *moduleName)
125 throw(SALOME_Exception)
127 // MESSAGE("ResourcesManager::GetFittingResources");
128 vector <std::string> ret;
131 // --- To be sure that we search in a correct list.
134 const char *hostname = (const char *)params.hostname;
135 MESSAGE("GetFittingResources " << hostname << " " << GetHostname().c_str());
137 if (hostname[0] != '\0')
139 // MESSAGE("ResourcesManager::GetFittingResources : hostname specified" );
141 if ( strcmp(hostname, "localhost") == 0 ||
142 strcmp(hostname, GetHostname().c_str()) == 0 )
144 // MESSAGE("ResourcesManager::GetFittingResources : localhost" );
145 ret.push_back(GetHostname().c_str());
146 // MESSAGE("ResourcesManager::GetFittingResources : " << ret.size());
149 else if (_resourcesList.find(hostname) != _resourcesList.end())
151 // --- params.hostname is in the list of resources so return it.
152 ret.push_back(hostname);
157 // Cas d'un cluster: nombre de noeuds > 1
159 for (map<string, ParserResourcesType>::const_iterator iter = _resourcesList.begin(); iter != _resourcesList.end(); iter++){
160 if( (*iter).second.DataForSort._nbOfNodes > 1 ){
161 if( strncmp(hostname,(*iter).first.c_str(),strlen(hostname)) == 0 ){
162 ret.push_back((*iter).first.c_str());
163 //cout << "SALOME_ResourcesManager::GetFittingResources vector["
164 // << cpt << "] = " << (*iter).first.c_str() << endl ;
170 // --- user specified an unknown hostame so notify him.
171 MESSAGE("ResourcesManager::GetFittingResources : SALOME_Exception");
172 throw SALOME_Exception("unknown host");
178 // --- Search for available resources sorted by priority
180 SelectOnlyResourcesWithOS(ret, params.OS);
182 KeepOnlyResourcesWithModule(ret, moduleName);
185 SelectOnlyResourcesWithOS(ret, params.OS);
187 // --- set wanted parameters
188 ResourceDataToSort::_nbOfNodesWanted = params.nb_node;
190 ResourceDataToSort::_nbOfProcPerNodeWanted = params.nb_proc_per_node;
192 ResourceDataToSort::_CPUFreqMHzWanted = params.cpu_clock;
194 ResourceDataToSort::_memInMBWanted = params.mem_mb;
198 list<ResourceDataToSort> li;
200 for (vector<string>::iterator iter = ret.begin();
203 li.push_back(_resourcesList[(*iter)].DataForSort);
209 for (list<ResourceDataToSort>::iterator iter2 = li.begin();
212 ret[i++] = (*iter2)._hostName;
215 // MESSAGE("ResourcesManager::GetFittingResources : return" << ret.size());
219 //=============================================================================
221 * add an entry in the ressources catalog xml file.
222 * Return 0 if OK (KERNEL found in new resources modules) else throw exception
224 //=============================================================================
227 SALOME_ResourcesManager::
228 AddResourceInCatalog(const Engines::MachineParameters& paramsOfNewResources,
229 const map<string, string>& modulesOnNewResources,
230 const char *environPathOfPrerequired,
232 const char *userName,
234 AccessProtocolType prot)
235 throw(SALOME_Exception)
237 map<string, string>::const_iterator iter =
238 modulesOnNewResources.find("KERNEL");
240 if (iter != modulesOnNewResources.end())
242 ParserResourcesType newElt;
243 newElt.DataForSort._hostName = paramsOfNewResources.hostname;
244 newElt.Alias = alias;
245 newElt.Protocol = prot;
247 newElt.UserName = userName;
248 newElt.ModulesPath = modulesOnNewResources;
249 newElt.PreReqFilePath = environPathOfPrerequired;
250 newElt.OS = paramsOfNewResources.OS;
251 newElt.DataForSort._memInMB = paramsOfNewResources.mem_mb;
252 newElt.DataForSort._CPUFreqMHz = paramsOfNewResources.cpu_clock;
253 newElt.DataForSort._nbOfNodes = paramsOfNewResources.nb_node;
254 newElt.DataForSort._nbOfProcPerNode =
255 paramsOfNewResources.nb_proc_per_node;
256 _resourcesList[newElt.DataForSort._hostName] = newElt;
261 throw SALOME_Exception("KERNEL is not present in this resource");
264 //=============================================================================
266 * Deletes a resource from the catalog
268 //=============================================================================
270 void SALOME_ResourcesManager::DeleteResourceInCatalog(const char *hostname)
272 _resourcesList.erase(hostname);
275 //=============================================================================
277 * write the current data in memory in file.
279 //=============================================================================
281 void SALOME_ResourcesManager::WriteInXmlFile()
283 const char* aFilePath = _path_resources.c_str();
285 FILE* aFile = fopen(aFilePath, "w");
289 INFOS("Error opening file !");
293 xmlDocPtr aDoc = xmlNewDoc(BAD_CAST "1.0");
294 xmlNewDocComment(aDoc, BAD_CAST "ResourcesCatalog");
296 SALOME_ResourcesCatalog_Handler* handler =
297 new SALOME_ResourcesCatalog_Handler(_resourcesList);
298 handler->PrepareDocToXmlFile(aDoc);
301 int isOk = xmlSaveFile(aFilePath, aDoc);
304 INFOS("Error while XML file saving.");
309 // Free the global variables that may have been allocated by the parser
314 MESSAGE("WRITING DONE!");
317 //=============================================================================
319 * parse the data type catalog
321 //=============================================================================
323 const MapOfParserResourcesType& SALOME_ResourcesManager::ParseXmlFile()
325 SALOME_ResourcesCatalog_Handler* handler =
326 new SALOME_ResourcesCatalog_Handler(_resourcesList);
328 const char* aFilePath = _path_resources.c_str();
329 FILE* aFile = fopen(aFilePath, "r");
333 xmlDocPtr aDoc = xmlReadFile(aFilePath, NULL, 0);
336 handler->ProcessXmlDocument(aDoc);
338 INFOS("ResourcesManager: could not parse file "<<aFilePath);
343 // Free the global variables that may have been allocated by the parser
348 INFOS("ResourcesManager: file "<<aFilePath<<" is not readable.");
352 return _resourcesList;
355 //=============================================================================
357 * consult the content of the list
359 //=============================================================================
361 const MapOfParserResourcesType& SALOME_ResourcesManager::GetList() const
363 return _resourcesList;
367 //=============================================================================
369 * dynamically obtains the first machines
371 //=============================================================================
374 SALOME_ResourcesManager::FindFirst(const Engines::MachineList& listOfMachines)
376 return _dynamicResourcesSelecter.FindFirst(listOfMachines);
379 //=============================================================================
381 * dynamically obtains the best machines
383 //=============================================================================
386 SALOME_ResourcesManager::FindNext(const Engines::MachineList& listOfMachines)
388 return _dynamicResourcesSelecter.FindNext(listOfMachines,_NS);
390 //=============================================================================
392 * dynamically obtains the best machines
394 //=============================================================================
397 SALOME_ResourcesManager::FindBest(const Engines::MachineList& listOfMachines)
399 return _dynamicResourcesSelecter.FindBest(listOfMachines);
404 //=============================================================================
406 * This is no longer valid (C++ container are also python containers)
408 //=============================================================================
410 bool isPythonContainer(const char* ContainerName)
413 int len = strlen(ContainerName);
416 if (strcmp(ContainerName + len - 2, "Py") == 0)
423 //=============================================================================
425 * Builds the script to be launched
427 * If SALOME Application not defined ($APPLI),
428 * see BuildTempFileToLaunchRemoteContainer()
430 * Else rely on distant configuration. Command is under the form (example):
431 * ssh user@machine distantPath/runRemote.sh hostNS portNS \
432 * SALOME_Container containerName &"
434 * - where user is ommited if not specified in CatalogResources,
435 * - where distant path is always relative to user@machine $HOME, and
436 * equal to $APPLI if not specified in CatalogResources,
437 * - where hostNS is the hostname of CORBA naming server (set by scripts to
438 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
439 * - where portNS is the port used by CORBA naming server (set by scripts to
440 * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh)
442 //=============================================================================
445 SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer
446 (const string& machine,
447 const Engines::MachineParameters& params, const long id)
451 char idc[3*sizeof(long)];
453 if ( ! _isAppliSalomeDefined )
454 command = BuildTempFileToLaunchRemoteContainer(machine, params);
458 const ParserResourcesType& resInfo = _resourcesList[machine];
462 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
464 else if ( params.nb_node == 0 )
465 nbproc = params.nb_proc_per_node;
466 else if ( params.nb_proc_per_node == 0 )
467 nbproc = params.nb_node;
469 nbproc = params.nb_node * params.nb_proc_per_node;
472 // "ssh user@machine distantPath/runRemote.sh hostNS portNS \
473 // SALOME_Container containerName &"
475 if (resInfo.Protocol == rsh)
477 else if (resInfo.Protocol == ssh)
480 throw SALOME_Exception("Unknown protocol");
482 if (resInfo.UserName != "")
484 command += resInfo.UserName;
491 if (resInfo.AppliPath != "")
492 command += resInfo.AppliPath; // path relative to user@machine $HOME
495 ASSERT(getenv("APPLI"));
496 command += getenv("APPLI"); // path relative to user@machine $HOME
499 command += "/runRemote.sh ";
501 ASSERT(getenv("NSHOST"));
502 command += getenv("NSHOST"); // hostname of CORBA name server
505 ASSERT(getenv("NSPORT"));
506 command += getenv("NSPORT"); // port of CORBA name server
510 command += " mpirun -np ";
511 std::ostringstream o;
515 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
517 command += " SALOME_MPIContainer ";
520 command += " SALOME_Container ";
522 command += _NS->ContainerName(params);
524 sprintf(idc,"%ld",id);
527 AddOmninamesParams(command);
528 command += " > /tmp/";
529 command += _NS->ContainerName(params);
531 command += GetHostname();
533 command += getenv( "USER" ) ;
534 command += ".log 2>&1 &" ;
536 MESSAGE("command =" << command);
543 //=============================================================================
545 * builds the command to be launched.
547 //=============================================================================
550 SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer
551 (const Engines::MachineParameters& params, const long id)
556 char idc[3*sizeof(long)];
560 command = "mpirun -np ";
562 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
564 else if ( params.nb_node == 0 )
565 nbproc = params.nb_proc_per_node;
566 else if ( params.nb_proc_per_node == 0 )
567 nbproc = params.nb_node;
569 nbproc = params.nb_node * params.nb_proc_per_node;
571 std::ostringstream o;
577 command += "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
580 if (isPythonContainer(params.container_name))
581 command += "pyMPI SALOME_ContainerPy.py ";
583 command += "SALOME_MPIContainer ";
588 if (isPythonContainer(params.container_name))
589 command = "SALOME_ContainerPy.py ";
591 command = "SALOME_Container ";
594 command += _NS->ContainerName(params);
596 sprintf(idc,"%ld",id);
599 AddOmninamesParams(command);
600 command += " > /tmp/";
601 command += _NS->ContainerName(params);
603 command += GetHostname();
605 command += getenv( "USER" ) ;
606 command += ".log 2>&1 &" ;
607 MESSAGE("Command is ... " << command);
612 //=============================================================================
614 * removes the generated temporary file in case of a remote launch.
616 //=============================================================================
618 void SALOME_ResourcesManager::RmTmpFile()
620 if (_TmpFileName != "")
623 string command = "rm ";
625 string command = "del /F ";
627 command += _TmpFileName;
628 char *temp = strdup(command.c_str());
629 int lgthTemp = strlen(temp);
630 temp[lgthTemp - 3] = '*';
631 temp[lgthTemp - 2] = '\0';
638 //=============================================================================
640 * builds the script to be launched
642 //=============================================================================
645 SALOME_ResourcesManager::BuildCommand
646 (const string& machine,
647 const char *containerName)
649 // rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 &
650 const ParserResourcesType& resInfo = _resourcesList[machine];
651 bool pyCont = isPythonContainer(containerName);
655 if (resInfo.Protocol == rsh)
656 command = "rsh -n " ;
657 else if (resInfo.Protocol == ssh)
658 command = "ssh -f -n ";
660 throw SALOME_Exception("Not implemented yet...");
664 string path = (*(resInfo.ModulesPath.find("KERNEL"))).second;
666 command += "/bin/salome/";
669 command += "SALOME_ContainerPy.py ";
671 command += "SALOME_Container ";
673 command += containerName;
675 AddOmninamesParams(command);
676 command += " > /tmp/";
677 command += containerName;
681 command += getenv( "USER" ) ;
682 command += ".log 2>&1 &" ;
688 //=============================================================================
690 * Gives a sublist of machines with matching OS.
691 * If parameter OS is empty, gives the complete list of machines
693 //=============================================================================
695 // Warning need an updated parsed list : _resourcesList
697 SALOME_ResourcesManager::SelectOnlyResourcesWithOS
698 ( vector<string>& hosts,
699 const char *OS) const
700 throw(SALOME_Exception)
704 for (map<string, ParserResourcesType>::const_iterator iter =
705 _resourcesList.begin();
706 iter != _resourcesList.end();
709 if ( (*iter).second.OS == base || base.size() == 0)
710 hosts.push_back((*iter).first);
715 //=============================================================================
717 * Gives a sublist of machines on which the module is known.
719 //=============================================================================
721 //Warning need an updated parsed list : _resourcesList
723 SALOME_ResourcesManager::KeepOnlyResourcesWithModule
724 ( vector<string>& hosts,
725 const char *moduleName) const
726 throw(SALOME_Exception)
728 for (vector<string>::iterator iter = hosts.begin(); iter != hosts.end();)
730 MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter);
731 const map<string, string>& mapOfModulesOfCurrentHost =
732 (((*it).second).ModulesPath);
734 if (mapOfModulesOfCurrentHost.find(moduleName) ==
735 mapOfModulesOfCurrentHost.end())
743 //=============================================================================
745 * add to command all options relative to naming service.
747 //=============================================================================
749 void SALOME_ResourcesManager::AddOmninamesParams(string& command) const
751 // If env variable OMNIORB_CONFIG is not defined or the file is more complex than one line
753 // Even if we use it we have to check if env variable exists
754 //string omniORBcfg( getenv( "OMNIORB_CONFIG" ) ) ;
755 //ifstream omniORBfile( omniORBcfg.c_str() ) ;
756 //char ORBInitRef[11] ;
758 //char nameservice[132] ;
759 //omniORBfile >> ORBInitRef ;
760 //command += "ORBInitRef " ;
761 //omniORBfile >> egal ;
762 //omniORBfile >> nameservice ;
763 //omniORBfile.close() ;
764 //char * bsn = strchr( nameservice , '\n' ) ;
768 //command += nameservice ;
770 char *iorstr = _NS->getIORaddr();
771 command += "ORBInitRef NameService=";
776 //=============================================================================
778 * add to command all options relative to naming service.
780 //=============================================================================
782 void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const
784 fileStream << "ORBInitRef NameService=";
785 fileStream << _NS->getIORaddr();
789 //=============================================================================
791 * generate a file name in /tmp directory
793 //=============================================================================
795 string SALOME_ResourcesManager::BuildTemporaryFileName() const
797 //build more complex file name to support multiple salome session
798 char *temp = new char[19];
799 strcpy(temp, "/tmp/command");
800 strcat(temp, "XXXXXX");
807 itoa(getpid(), aPID, 10);
811 string command(temp);
818 //=============================================================================
820 * Builds in a temporary file the script to be launched.
822 * Used if SALOME Application ($APPLI) is not defined.
823 * The command is build with data from CatalogResources, in which every path
824 * used on remote computer must be defined.
826 //=============================================================================
829 SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer
830 (const string& machine,
831 const Engines::MachineParameters& params)
833 _TmpFileName = BuildTemporaryFileName();
834 ofstream tempOutputFile;
835 tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
836 const ParserResourcesType& resInfo = _resourcesList[machine];
837 tempOutputFile << "#! /bin/sh" << endl;
841 tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
843 for (map<string, string>::const_iterator iter = resInfo.ModulesPath.begin();
844 iter != resInfo.ModulesPath.end();
847 string curModulePath((*iter).second);
848 tempOutputFile << (*iter).first << "_ROOT_DIR=" << curModulePath << endl;
849 tempOutputFile << "export " << (*iter).first << "_ROOT_DIR" << endl;
850 tempOutputFile << "LD_LIBRARY_PATH=" << curModulePath
851 << "/lib/salome" << ":${LD_LIBRARY_PATH}" << endl;
852 tempOutputFile << "PYTHONPATH=" << curModulePath << "/bin/salome:"
853 << curModulePath << "/lib/salome:" << curModulePath
854 << "/lib/python${PYTHON_VERSION}/site-packages/salome:";
855 tempOutputFile << curModulePath
856 << "/lib/python${PYTHON_VERSION}/site-packages/salome/shared_modules:${PYTHONPATH}"
860 tempOutputFile << "export LD_LIBRARY_PATH" << endl;
861 tempOutputFile << "export PYTHONPATH" << endl;
862 tempOutputFile << "export SALOME_trace=local" << endl; // mkr : 27.11.2006 : PAL13967 - Distributed supervision graphs - Problem with "SALOME_trace"
863 //tempOutputFile << "source " << resInfo.PreReqFilePath << endl;
869 tempOutputFile << "mpirun -np ";
872 if ( (params.nb_node <= 0) && (params.nb_proc_per_node <= 0) )
874 else if ( params.nb_node == 0 )
875 nbproc = params.nb_proc_per_node;
876 else if ( params.nb_proc_per_node == 0 )
877 nbproc = params.nb_node;
879 nbproc = params.nb_node * params.nb_proc_per_node;
881 std::ostringstream o;
883 tempOutputFile << nbproc << " ";
885 tempOutputFile << "-x PATH,LD_LIBRARY_PATH,OMNIORB_CONFIG,SALOME_trace ";
889 tempOutputFile << (*(resInfo.ModulesPath.find("KERNEL"))).second
894 if (isPythonContainer(params.container_name))
895 tempOutputFile << "pyMPI SALOME_ContainerPy.py ";
897 tempOutputFile << "SALOME_MPIContainer ";
902 if (isPythonContainer(params.container_name))
903 tempOutputFile << "SALOME_ContainerPy.py ";
905 tempOutputFile << "SALOME_Container ";
908 tempOutputFile << _NS->ContainerName(params) << " -";
909 AddOmninamesParams(tempOutputFile);
910 tempOutputFile << " &" << endl;
911 tempOutputFile.flush();
912 tempOutputFile.close();
913 chmod(_TmpFileName.c_str(), 0x1ED);
919 if (resInfo.Protocol == rsh)
922 string commandRcp = "rcp ";
923 commandRcp += _TmpFileName;
925 commandRcp += machine;
927 commandRcp += _TmpFileName;
928 system(commandRcp.c_str());
931 else if (resInfo.Protocol == ssh)
934 string commandRcp = "scp ";
935 commandRcp += _TmpFileName;
937 commandRcp += machine;
939 commandRcp += _TmpFileName;
940 system(commandRcp.c_str());
943 throw SALOME_Exception("Unknown protocol");
946 _CommandForRemAccess = command;
948 command += _TmpFileName;
951 command += _NS->ContainerName(params);
955 command += getenv( "USER" ) ;
956 command += ".log 2>&1 &";
963 //=============================================================================
964 /*! Creates a command line that the container manager uses to launch
965 * a parallel container.
967 //=============================================================================
969 SALOME_ResourcesManager::BuildCommandToLaunchLocalParallelContainer(const std::string& exe_name,
970 const Engines::MachineParameters& params,
971 const std::string& log)
973 // This method knows the differences between the proxy and the nodes.
974 // nb_component_nodes is not used in the same way if it is a proxy or
978 string parallelLib(CORBA::string_dup(params.parallelLib));
979 string hostname(CORBA::string_dup(params.hostname));
980 int par = exe_name.find("Proxy");
981 int nbproc = params.nb_component_nodes;
983 sprintf(buffer,"%d",nbproc);
985 Engines::MachineParameters_var rtn = new Engines::MachineParameters();
986 rtn->container_name = params.container_name;
987 rtn->hostname = params.hostname;
989 rtn->mem_mb = params.mem_mb;
990 rtn->cpu_clock = params.cpu_clock;
991 rtn->nb_proc_per_node = params.nb_proc_per_node;
992 rtn->nb_node = params.nb_node;
993 rtn->isMPI = params.isMPI;
995 string real_exe_name = exe_name + parallelLib;
997 if (parallelLib == "Dummy")
999 //command = "gdb --args ";
1000 //command = "valgrind --tool=memcheck --log-file=val_log ";
1001 //command += real_exe_name;
1003 command = real_exe_name;
1005 command += " " + _NS->ContainerName(rtn);
1006 command += " " + parallelLib;
1007 command += " " + hostname;
1009 AddOmninamesParams(command);
1012 if (parallelLib == "Mpi")
1014 // Step 1 : check if MPI is started
1015 if (_MpiStarted == false)
1024 command = "mpiexec -np " + string(buffer) + " ";
1025 // command += "gdb --args ";
1026 command += real_exe_name;
1027 command += " " + _NS->ContainerName(rtn);
1028 command += " " + parallelLib;
1029 command += " " + hostname;
1031 AddOmninamesParams(command);
1036 command = "mpiexec -np 1 ";
1037 command += real_exe_name;
1038 command += " " + _NS->ContainerName(rtn);
1039 command += " " + string(buffer);
1040 command += " " + parallelLib;
1041 command += " " + hostname;
1043 AddOmninamesParams(command);
1048 if (log == "default")
1050 command += " > /tmp/";
1051 command += _NS->ContainerName(rtn);
1053 command += GetHostname();
1055 command += getenv( "USER" ) ;
1056 command += ".log 2>&1 &" ;
1060 command = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH; "
1061 + command + " \" &";
1062 // + command + "; echo $LD_LIBRARY_PATH; cat \" &";
1066 /* if (log == "xterm")
1068 command = "/usr/X11R6/bin/xterm -e \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; export PATH=$PATH; echo $LD_LIBRARY_PATH; echo $PATH; " + command + "; cat \" &";
1071 /* command = "cd ; rm " + fichier_commande + "; touch " + \
1072 fichier_commande + "; echo \" export LD_LIBRARY_PATH=$LD_LIBRARY_PATH; " + \
1073 command + " >& /tmp/ribes_" + fichier_commande + " & \" > " + fichier_commande + ";";
1074 command += "ssh cn01 sh " + fichier_commande + " &";
1075 cerr << "La commande : " << command << endl;
1079 void SALOME_ResourcesManager::startMPI()
1081 cerr << "----------------------------------------------" << endl;
1082 cerr << "----------------------------------------------" << endl;
1083 cerr << "----------------------------------------------" << endl;
1084 cerr << "-Only Lam on Localhost is currently supported-" << endl;
1085 cerr << "----------------------------------------------" << endl;
1086 cerr << "----------------------------------------------" << endl;
1087 cerr << "----------------------------------------------" << endl;
1089 int status = system("lamboot");
1092 INFOS("lamboot failed : system command status -1");
1094 else if (status == 217)
1096 INFOS("lamboot failed : system command status 217");