From: caremoli Date: Tue, 19 Feb 2008 10:11:57 +0000 (+0000) Subject: CCAR: add attributes to Container (logfilename, workingdir) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ac31f54f63fadf26ced18bc6e648b55e962f6134;p=modules%2Fkernel.git CCAR: add attributes to Container (logfilename, workingdir) - now SALOME Launcher put the Container in a working directory that can be set by the user through machineParameters (member workindir) - add complex, logical and strings to Datastream/Calcium DSC ports python interface --- diff --git a/bin/appliskel/runRemote.sh b/bin/appliskel/runRemote.sh index 6cd76ef46..522b6ddd7 100755 --- a/bin/appliskel/runRemote.sh +++ b/bin/appliskel/runRemote.sh @@ -37,7 +37,8 @@ # $0 : ${APPLI}/runRemote.sh: from arg name, rebuild and export $APPLI variable # $1 : computer name for CORBA name service (where SALOME was launched) # $2 : port for CORBA name service -# $3 and following : local command to execute, with args +# $3 : working directory +# $4 and following : local command to execute, with args # # --- retrieve APPLI path, relative to $HOME, set ${APPLI} @@ -60,9 +61,34 @@ export NSPORT initref="NameService=corbaname::"$1":$2" echo "ORBInitRef $initref" > $OMNIORB_CONFIG +#go to the requested working directory if any +if test "x$3" != x; then + if test "x$3" = "x\$TEMPDIR"; then + #create a temp working dir and change to it + WDIR=`mktemp -d` && { + cd $WDIR + } + else + if test -d $3; then + #the dir exists, go to it + cd $3 + else + if test -a $3; then + # It's a file do nothing + echo $3 "is an existing file. Can't use it as a working directory" + else + #It does not exists, create it + mkdir -p $3 && { + cd $3 + } + fi + fi + fi +fi + # --- execute the command in the SALOME environment -shift 2 +shift 3 # suppress --rcfile option because of problem on Mandriva2006 - B Secher mai 2007 #${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/sh --rcfile $HOME/$APPLI/.bashrc -c "$*" diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index f3139b6ec..0619ebfa0 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -132,6 +132,16 @@ module Engines */ readonly attribute string name ; + /*! + working directory of the %container + */ + readonly attribute string workingdir ; + + /*! + name of the %container log file (this has been set by the launcher) + */ + attribute string logfilename ; + /*! Shutdown the Container process. */ diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 7fcc66cf6..8d2258cf5 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -54,6 +54,7 @@ struct MachineParameters boolean isMPI; string mpiImpl; string batch; + string workingdir; // PaCO specific informations string parallelLib; diff --git a/salome_adm/unix/SALOMEconfig.ref.in b/salome_adm/unix/SALOMEconfig.ref.in index 20c03488b..78688bd88 100644 --- a/salome_adm/unix/SALOMEconfig.ref.in +++ b/salome_adm/unix/SALOMEconfig.ref.in @@ -55,10 +55,20 @@ #define SSH "@SSH@" // This is only to suppress warning messages with defines redefined (cause of omniORB that exports these names) +#ifdef PACKAGE_BUGREPORT #undef PACKAGE_BUGREPORT +#endif +#ifdef PACKAGE_NAME #undef PACKAGE_NAME +#endif +#ifdef PACKAGE_STRING #undef PACKAGE_STRING +#endif +#ifdef PACKAGE_TARNAME #undef PACKAGE_TARNAME +#endif +#ifdef PACKAGE_VERSION #undef PACKAGE_VERSION +#endif #endif diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index cdbef093f..5b7efac97 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -164,6 +164,8 @@ Engines_Component_i::~Engines_Component_i() { MESSAGE("Component destructor"); Engines_Container_i::decInstanceCnt(_interfaceName); + if(_myConnexionToRegistry)delete _myConnexionToRegistry; + if(_notifSupplier)delete _notifSupplier; } //============================================================================= diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index ea1c23c11..41e2b5b61 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -241,6 +241,35 @@ char* Engines_Container_i::name() return CORBA::string_dup(_containerName.c_str()) ; } +//============================================================================= +/*! + * CORBA attribute: Container working directory + */ +//============================================================================= + +char* Engines_Container_i::workingdir() +{ + char wd[256]; + getcwd (wd,256); + return CORBA::string_dup(wd) ; +} + +//============================================================================= +/*! + * CORBA attribute: Container log file name + */ +//============================================================================= + +char* Engines_Container_i::logfilename() +{ + return CORBA::string_dup(_logfilename.c_str()) ; +} + +void Engines_Container_i::logfilename(const char* name) +{ + _logfilename=name; +} + //============================================================================= /*! * CORBA method: Get the hostName of the Container (without domain extensions) diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 9e3ee1383..03234c307 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -29,6 +29,8 @@ #ifndef _SALOME_COMPONENT_I_HXX_ #define _SALOME_COMPONENT_I_HXX_ +#include + #include #include @@ -40,7 +42,6 @@ #include #include #include -#include #include CORBA_SERVER_HEADER(SALOME_Component) #include "NOTIFICATION.hxx" #include "Salome_file_i.hxx" diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index b74dda375..dd6ee5a30 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -278,6 +278,10 @@ StartContainer(const Engines::MachineParameters& params, //Engines::Container_var cont=Engines::Container::_narrow(obj); } + //redirect stdout and stderr in a file + string logFilename="/tmp/"+_NS->ContainerName(params)+"_"+GetHostname()+"_"+getenv( "USER" )+".log" ; + command += " > " + logFilename + " 2>&1 &"; + // launch container with a system call int status=system(command.c_str()); if (status == -1){ @@ -308,7 +312,16 @@ StartContainer(const Engines::MachineParameters& params, } if ( CORBA::is_nil(ret) ) - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed"); + { + MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed"); + } + else + { + logFilename=":"+logFilename; + logFilename="@"+GetHostname()+logFilename; + logFilename=getenv( "USER" )+logFilename; + ret->logfilename(logFilename.c_str()); + } return ret; } diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index f39a54c4b..153b381f8 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -83,6 +83,10 @@ public: virtual void ping(); char* name(); + char* workingdir(); + char* logfilename(); + void logfilename(const char* name); + virtual void Shutdown(); char* getHostName(); CORBA::Long getPID(); @@ -125,6 +129,7 @@ protected: SALOME_NamingService *_NS ; std::string _library_path; std::string _containerName; + std::string _logfilename; CORBA::ORB_var _orb; PortableServer::POA_var _poa; PortableServer::ObjectId * _id ; diff --git a/src/DSC/DSC_Python/calcium.i b/src/DSC/DSC_Python/calcium.i index beb704e77..dddf3aa06 100644 --- a/src/DSC/DSC_Python/calcium.i +++ b/src/DSC/DSC_Python/calcium.i @@ -39,10 +39,6 @@ struct omniORBpyAPI { omniORBpyAPI* api; -#define OMNIPY_CATCH_AND_HANDLE_SYSTEM_EXCEPTIONS \ -catch (const CORBA::SystemException& ex) { \ - return api->handleCxxSystemException(ex); \ -} %} @@ -67,11 +63,8 @@ catch (const CORBA::SystemException& ex) { \ %} %include -%include "carrays.i" -%array_class(int, intArray); -%array_class(float, floatArray); -%array_class(double, doubleArray); + /* * Most of this code is borrowed from numpy distribution @@ -115,13 +108,52 @@ char* pytype_string(PyObject* py_obj) { return "unkown type"; } +/* +For documentation only : numpy typecodes + +enum NPY_TYPECHAR { NPY_BOOLLTR = '?', + NPY_BYTELTR = 'b', + NPY_UBYTELTR = 'B', + NPY_SHORTLTR = 'h', + NPY_USHORTLTR = 'H', + NPY_INTLTR = 'i', + NPY_UINTLTR = 'I', + NPY_LONGLTR = 'l', + NPY_ULONGLTR = 'L', + NPY_LONGLONGLTR = 'q', + NPY_ULONGLONGLTR = 'Q', + NPY_FLOATLTR = 'f', + NPY_DOUBLELTR = 'd', + NPY_LONGDOUBLELTR = 'g', + NPY_CFLOATLTR = 'F', + NPY_CDOUBLELTR = 'D', + NPY_CLONGDOUBLELTR = 'G', + NPY_OBJECTLTR = 'O', + NPY_STRINGLTR = 'S', + NPY_STRINGLTR2 = 'a', + NPY_UNICODELTR = 'U', + NPY_VOIDLTR = 'V', + NPY_CHARLTR = 'c', + + NPY_INTPLTR = 'p', + NPY_UINTPLTR = 'P', + + NPY_GENBOOLLTR ='b', + NPY_SIGNEDLTR = 'i', + NPY_UNSIGNEDLTR = 'u', + NPY_FLOATINGLTR = 'f', + NPY_COMPLEXLTR = 'c' +}; +*/ + /* Given a Numeric typecode, return a string describing the type. */ char* typecode_string(int typecode) { - char* type_names[20] = {"char","unsigned byte","byte","short", - "unsigned short","int","unsigned int","long", - "float","double","complex float","complex double", - "object","ntype","unkown"}; + char* type_names[] = {"bool","byte","unsigned byte","short", + "unsigned short","int","unsigned int","long","unsigned long", + "longlong","unsigned longlong", + "float","double","long double","complex float","complex double","complex long double", + "object","string","unicode","void","ntypes","notype","char","unkown"}; return type_names[typecode]; } @@ -338,6 +370,45 @@ typedef PyObject ArrayObject; #endif %} +%include "carrays.i" + +%array_class(int, intArray); +%array_class(float, floatArray); +%array_class(double, doubleArray); + +/* special struct to handle string arrays */ +%inline %{ +struct stringArray +{ + stringArray(int nelements,int size=0) { + nelem=nelements; + data= new char*[nelements]; + for(int i=0;idata; +%#else + SWIG_exception(SWIG_TypeError, "complex array expected"); +%#endif + } +} +%typemap(freearg) float* ecpval { + if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); +} +/* End of Specific typemap for complex */ + +/* array of strings on input */ +%typemap(in) char** eval + (ArrayObject* array=NULL, int is_new_object) { + int size[1] = {-1}; + stringArray* sarray; + if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *),0)) == -1) + { +%#ifdef WITH_NUMPY + array = obj_to_array_contiguous_allow_conversion($input, PyArray_STRING, &is_new_object); + if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; + $1 = (char**) malloc(array_size(array,0)*sizeof(char*)); + for(int i=0;idata + i* array->strides[0]; +%#else + SWIG_exception(SWIG_TypeError, "string array expected"); +%#endif + } + else + { + $1=sarray->data; + } +} + +%typemap(freearg) char** eval { + if (array$argnum) free($1); + if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum); +} +/* End of array of strings on input */ + /* inplace typemaps This typemap can be used for input/output array objects. It accepts swig carray objects or numpy contiguous objects. @@ -404,94 +524,145 @@ TYPEMAP_INPLACE3(double, PyArray_DOUBLE) %apply float* INPLACE_ARRAY3 {float *lval}; %apply double* INPLACE_ARRAY3 {double *lval}; - -%typemap(in) CORBA::Boolean -{ - $1=(CORBA::Boolean)PyInt_AsLong($input); +/* typemap for complex inout */ +%typemap(in) float* lcpval + (ArrayObject* temp=NULL) { + if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1) + { +%#ifdef WITH_NUMPY + temp = obj_to_array_no_conversion($input,PyArray_CFLOAT); + if (!temp || !require_contiguous(temp)) SWIG_fail; + $1 = (float*) temp->data; +%#else + SWIG_exception(SWIG_TypeError, "complex array expected"); +%#endif + } } +/* End of typemap for complex inout */ -%typemap(in) CORBA::ORB_ptr -{ - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = CORBA::ORB::_narrow(obj); +/* typemap for array of strings on input/output */ +%typemap(in) char** lval + (ArrayObject* temp=NULL) { + stringArray* sarray; + if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *) ,0)) == -1) + { +%#ifdef WITH_NUMPY + temp = obj_to_array_no_conversion($input,PyArray_STRING); + if (!temp || !require_contiguous(temp)) SWIG_fail; + $1 = (char**) malloc(array_size(temp,0)*sizeof(char*)); + for(int i=0;idata+i*temp->strides[0]; +%#else + SWIG_exception(SWIG_TypeError, "string array expected"); +%#endif } - catch (...) { - PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); + else + { + $1=sarray->data; } } +%typemap(freearg) char** lval { + if (temp$argnum) free($1); +} +/* End of typemap for array of strings on input/output */ -%typemap(in) PortableServer::POA_ptr +%typemap(in) CORBA::Boolean { - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = PortableServer::POA::_narrow(obj); - } - catch (...) { - PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); - } + $1=(CORBA::Boolean)PyInt_AsLong($input); } -%typemap(in) Engines::Container_ptr +%define CORBAPTR(type) +%typemap(in) type##_ptr { - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = Engines::Container::_narrow(obj); + Py_BEGIN_ALLOW_THREADS + try + { + CORBA::Object_var obj = api->pyObjRefToCxxObjRef($input,0); + $1 = type##::_narrow(obj); } - catch (...) { + catch(...) + { + Py_BLOCK_THREADS PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); } + Py_END_ALLOW_THREADS +} +%typemap(freearg) type##_ptr { + CORBA::release($1); } +%enddef + +CORBAPTR(CORBA::ORB) +CORBAPTR(Ports::PortProperties) +CORBAPTR(Ports::Port) +CORBAPTR(Engines::Container) +CORBAPTR(PortableServer::POA) -%typemap(in) Ports::Port_ptr +%typemap(out) Ports::Port_ptr { - try { - CORBA::Object_ptr obj = api->pyObjRefToCxxObjRef($input,1); - $1 = Ports::Port::_narrow(obj); - } - catch (...) { - PyErr_SetString(PyExc_RuntimeError, "not a valid CORBA object ptr"); - } + $result = api->cxxObjRefToPyObjRef($1, 1); + //All output Ports::Port_ptr variables are duplicated by security. Need to release them for python . Explanation ?? + CORBA::release($1); } -%typemap(out) Ports::Port_ptr , Ports::PortProperties_ptr, Engines::Salome_file_ptr +%typemap(out) Ports::PortProperties_ptr, Engines::Salome_file_ptr { $result = api->cxxObjRefToPyObjRef($1, 1); } +%typemap(out) Engines::DSC::uses_port * +{ + $result = PyList_New($1->length()); + for (CORBA::ULong i=0; i < $1->length() ; i++) + PyList_SetItem($result,i,api->cxxObjRefToPyObjRef((*$1)[i], 1)); + //delete the copy (created by new) of uses port sequence + delete $1; +} + /* * Exception section */ // a general exception handler %exception { + Py_BEGIN_ALLOW_THREADS try { $action } catch(Engines::DSC::PortNotDefined& _e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Port not defined"); return NULL; } catch(Engines::DSC::PortNotConnected& _e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Port not connected"); return NULL; } catch(Engines::DSC::BadPortType& _e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Bad port type"); return NULL; } catch (SALOME_Exception &e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_RuntimeError,e.what()); return NULL; } catch (SALOME::SALOME_Exception &e) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_RuntimeError,e.details.text); return NULL; } - OMNIPY_CATCH_AND_HANDLE_SYSTEM_EXCEPTIONS + catch (const CORBA::SystemException& e) { + Py_BLOCK_THREADS + return api->handleCxxSystemException(e); + } catch(...) { + Py_BLOCK_THREADS PyErr_SetString(PyExc_ValueError,"Unknown exception"); return NULL; } + Py_END_ALLOW_THREADS } /* @@ -566,12 +737,22 @@ class PySupervCompo:public Superv_Component_i virtual Ports::PortProperties_ptr get_port_properties(const char* port_name); +// Interface for Salome_file Engines::Salome_file_ptr getInputFileToService(const char* service_name, const char* Salome_file_name); void checkInputFilesToService(const char* service_name); Engines::Salome_file_ptr setInputFileToService(const char* service_name, const char* Salome_file_name); Engines::Salome_file_ptr getOutputFileToService(const char* service_name, const char* Salome_file_name); void checkOutputFilesToService(const char* service_name); Engines::Salome_file_ptr setOutputFileToService(const char* service_name, const char* Salome_file_name); +// End of Interface for Salome_file + +// DSC interface for python components + virtual void add_provides_port(Ports::Port_ptr ref, const char* provides_port_name, Ports::PortProperties_ptr port_prop); + virtual void add_uses_port(const char* repository_id, const char* uses_port_name, Ports::PortProperties_ptr port_prop); + virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name); +// End of DSC interface for python components + + %extend { @@ -600,14 +781,17 @@ int cp_cd(Superv_Component_i *component,char *name); int cp_een(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); int cp_edb(Superv_Component_i *component,int dep,double t,int n,char *nom,int nval,double *eval); int cp_ere(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *eval); -int cp_ecp(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *eval); +int cp_ecp(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,float *ecpval); int cp_elo(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,int *eval); +int cp_ech(Superv_Component_i *component,int dep,float t,int n,char *nom,int nval,char** eval,int strSize); + int cp_len(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); int cp_ldb(Superv_Component_i *component,int dep,double *ti,double *tf,int *niter,char *nom,int nmax,int *nval,double *lval); int cp_lre(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); -int cp_lcp(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lval); +int cp_lcp(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,float *lcpval); int cp_llo(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,int *lval); +int cp_lch(Superv_Component_i *component,int dep,float *ti,float *tf,int *niter,char *nom,int nmax,int *nval,char** lval,int strSize); int cp_fin(Superv_Component_i *component,int cp_end); diff --git a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c index 46c4715a1..cba14ca11 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Calcium.c +++ b/src/DSC/DSC_User/Datastream/Calcium/Calcium.c @@ -94,7 +94,7 @@ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,); long _i=*i; \ fflush(stdout); \ fflush(stderr); \ - fprintf(stderr,"Beginning of cpl" #_name " : %s %d %f\n",nomvar,*i,*ti); \ + fprintf(stderr,"Beginning of cp_" #_name " : %s %d %f\n",nomvar,*i,*ti); \ \ if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; \ \ @@ -104,7 +104,7 @@ CALCIUM_EXT_LECT_INTERFACE_C_(lcp,float,float,cplx,); if(mode == CP_SEQUENTIEL) \ *i = _i; \ *nRead=_nRead; \ - fprintf(stderr,"End of cpl" #_name " : %s %d \n",nomvar,*i); \ + fprintf(stderr,"End of cp_" #_name " : %s %d \n",nomvar,*i); \ fflush(stdout); \ fflush(stderr); \ \ @@ -123,7 +123,7 @@ InfoType cp_lch(void * component, int mode, float * ti, float * tf, int * i, size_t _nRead; long _i=*i; fflush(stdout);fflush(stderr); - fprintf(stderr,"Beginning of cplch: %s %d %f\n",nomvar,*i,*ti); + fprintf(stderr,"Beginning of cp_lch: %s %d %f\n",nomvar,*i,*ti); if ( (data == NULL) || (bufferLength < 1) ) return CPNTNULL; @@ -133,7 +133,7 @@ InfoType cp_lch(void * component, int mode, float * ti, float * tf, int * i, if(mode == CP_SEQUENTIEL) *i = _i; *nRead=_nRead; - fprintf(stderr,"End of cplch: %s %d \n",nomvar,*i); + fprintf(stderr,"End of cp_lch: %s %d \n",nomvar,*i); fflush(stdout);fflush(stderr); return info; @@ -209,13 +209,13 @@ InfoType cp_fin (void * component, int code) { /*long _i=i;*/ \ fflush(stdout); \ fflush(stderr); \ - fprintf(stderr,"Beginning of cpe" #_name " : %s %d %f\n",nomvar,i,t); \ + fprintf(stderr,"Beginning of cp_" #_name " : %s %d %f\n",nomvar,i,t); \ if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; \ \ InfoType info = ecp_ecriture_##_typeName (component, mode, &t, i, \ nomvar, nbelem, \ data ); \ - fprintf(stderr,"End of cpe" #_name " : %s %d \n",nomvar,i); \ + fprintf(stderr,"End of cp_" #_name " : %s %d \n",nomvar,i); \ fflush(stdout); \ fflush(stderr); \ \ @@ -230,13 +230,13 @@ InfoType cp_ech(void * component, int mode, float t, int i, /*long _i=i;*/ fflush(stdout);fflush(stderr); - fprintf(stderr,"Beginning of cpech: %s %d %f\n",nomvar,i,t); + fprintf(stderr,"Beginning of cp_ech: %s %d %f\n",nomvar,i,t); if ( (data == NULL) || (nbelem < 1) ) return CPNTNULL; InfoType info = ecp_ecriture_str (component, mode, &t, i, nomvar, nbelem, data);/*, strSize );*/ - fprintf(stderr,"End of cpech: %s %d \n",nomvar,i); + fprintf(stderr,"End of cp_ech: %s %d \n",nomvar,i); fflush(stdout); fflush(stderr); diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index f282ac735..ea88da8f8 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -473,7 +473,7 @@ bool isPythonContainer(const char* ContainerName) * see BuildTempFileToLaunchRemoteContainer() * * Else rely on distant configuration. Command is under the form (example): - * ssh user@machine distantPath/runRemote.sh hostNS portNS \ + * ssh user@machine distantPath/runRemote.sh hostNS portNS workingdir \ * SALOME_Container containerName &" * - where user is ommited if not specified in CatalogResources, @@ -483,6 +483,7 @@ bool isPythonContainer(const char* ContainerName) * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh) * - where portNS is the port used by CORBA naming server (set by scripts to * use to launch SALOME and servers in $APPLI: runAppli.sh, runRemote.sh) + * - where workingdir is the requested working directory for the container */ //============================================================================= @@ -514,7 +515,7 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer nbproc = params.nb_node * params.nb_proc_per_node; } - // "ssh user@machine distantPath/runRemote.sh hostNS portNS \ + // "ssh user@machine distantPath/runRemote.sh hostNS portNS workingdir \ // SALOME_Container containerName &" if (resInfo.Protocol == rsh) @@ -550,6 +551,13 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer ASSERT(getenv("NSPORT")); command += getenv("NSPORT"); // port of CORBA name server + command += " '"; + std::string wdir=params.workingdir.in(); + if(wdir == "$TEMPDIR") + wdir="\\$TEMPDIR"; + command += wdir; // requested working directory + command += "'"; + if(params.isMPI) { command += " mpirun -np "; @@ -570,13 +578,6 @@ SALOME_ResourcesManager::BuildCommandToLaunchRemoteContainer command += idc; command += " -"; AddOmninamesParams(command); - command += " > /tmp/"; - command += _NS->ContainerName(params); - command += "_"; - command += GetHostname(); - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &" ; MESSAGE("command =" << command); } @@ -629,10 +630,32 @@ SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer else { + command=""; + std::string wdir=params.workingdir.in(); + std::cerr << wdir << std::endl; + if(wdir != "") + { + // a working directory is requested + if(wdir == "$TEMPDIR") + { + // a new temporary directory is requested + char dir[]="/tmp/salomeXXXXXX"; + char* mdir=mkdtemp(dir); + if(mdir==NULL) + std::cerr << "Problem in mkdtemp " << dir << " " << mdir << std::endl; + else + command="cd "+std::string(dir)+";"; + } + else + { + // a permanent directory is requested use it or create it + command="mkdir -p " + wdir + " && cd " + wdir + ";"; + } + } if (isPythonContainer(params.container_name)) - command = "SALOME_ContainerPy.py "; + command += "SALOME_ContainerPy.py "; else - command = "SALOME_Container "; + command += "SALOME_Container "; } command += _NS->ContainerName(params); @@ -641,13 +664,7 @@ SALOME_ResourcesManager::BuildCommandToLaunchLocalContainer command += idc; command += " -"; AddOmninamesParams(command); - command += " > /tmp/"; - command += _NS->ContainerName(params); - command += "_"; - command += GetHostname(); - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &" ; + MESSAGE("Command is ... " << command); return command; } @@ -717,13 +734,6 @@ SALOME_ResourcesManager::BuildCommand command += containerName; command += " -"; AddOmninamesParams(command); - command += " > /tmp/"; - command += containerName; - command += "_"; - command += machine; - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &" ; SCRUTE( command ); return command; @@ -823,11 +833,9 @@ void SALOME_ResourcesManager::AddOmninamesParams(string& command) const //} //command += nameservice ; - char *iorstr = _NS->getIORaddr(); + CORBA::String_var iorstr = _NS->getIORaddr(); command += "ORBInitRef NameService="; command += iorstr; - //It's in fact a CORBA::String allocated with new [] !!! - delete [] iorstr; } @@ -839,8 +847,9 @@ void SALOME_ResourcesManager::AddOmninamesParams(string& command) const void SALOME_ResourcesManager::AddOmninamesParams(ofstream& fileStream) const { + CORBA::String_var iorstr = _NS->getIORaddr(); fileStream << "ORBInitRef NameService="; - fileStream << _NS->getIORaddr(); + fileStream << iorstr; } @@ -987,14 +996,7 @@ SALOME_ResourcesManager::BuildTempFileToLaunchRemoteContainer _CommandForRemAccess = command; command += " "; command += _TmpFileName; - command += " > "; - command += "/tmp/"; - command += _NS->ContainerName(params); - command += "_"; - command += machine; - command += "_"; - command += getenv( "USER" ) ; - command += ".log 2>&1 &"; + SCRUTE(command); return command;