Salome HOME
The default value of the working directory of a job is set to the one of the ressourc...
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 11 Dec 2014 16:22:52 +0000 (17:22 +0100)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Thu, 11 Dec 2014 16:22:52 +0000 (17:22 +0100)
If neither the job nor the ressource defines a working directory, we use the previous rule
to define a working directory, based on $HOME.
There was a bug in the previous version because $HOME was not considered an absolute path.
A temporary fix is to use "/$HOME" instead of "$HOME".

idl/SALOME_Launcher.idl
src/Launcher/Launcher_Job.cxx

index c3ad69051fbd8924ce36496e591289e4060ba27e..ca27ffa57191c9e03633835915ad2c1df0bbb54f 100644 (file)
@@ -93,6 +93,11 @@ struct JobParameters
       the stuff to run the job. Note that the job will be executed from within
       this directory. A change directory toward this working directory is done
       by the batch system before running the job.
+      If not specified (empty string), the launcher will use the working
+      directory of the chosen ressource and if this is also an empty string
+      the value used will be $HOME/Batch/workdir_"date" where $HOME is the
+      value of the environment variable on the remote ressource and "date" is
+      the current date.
   */
   string work_directory;
 
@@ -105,6 +110,8 @@ struct JobParameters
   //! Local directory where to get result files.
   /*! It must be used to specify where to download the output files on the
       local file system.
+      If not specified (empty string), the value of $HOME environment variable
+      will be used.
       \see SalomeLauncher::getJobResults
   */
   string result_directory;
index 83e007c0cde6b6954a97ee5680d8dc53ecaa1c51..34c33475638518e1f3ee50d7534a254a3456d4a4 100644 (file)
@@ -19,6 +19,7 @@
 
 // Author: AndrĂ© RIBES - EDF R&D
 //
+//#define _DEBUG_
 #include "Launcher_Job.hxx"
 #include "Launcher.hxx"
 
@@ -578,15 +579,22 @@ Launcher::Job::common_job_params()
     params[Batch::MEMPERCPU] = (long)_mem_per_cpu;
   }
 
-  // We define a default directory based on user time
+  // We define a default directory
   if (_work_directory == "")
   {
-    const size_t BUFSIZE = 32;
-    char date[BUFSIZE];
-    time_t curtime = time(NULL);
-    strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime));
-    _work_directory = std::string("$HOME/Batch/workdir_");
-    _work_directory += date;
+    if(!_resource_definition.working_directory.empty())
+    {
+      _work_directory = _resource_definition.working_directory;
+    }
+    else
+    {
+      const size_t BUFSIZE = 32;
+      char date[BUFSIZE];
+      time_t curtime = time(NULL);
+      strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime));
+      _work_directory = std::string("/$HOME/Batch/workdir_");
+      _work_directory += date;
+    }
   }
   params[Batch::WORKDIR] = _work_directory;
 
@@ -615,7 +623,7 @@ Launcher::Job::common_job_params()
 #ifndef WIN32
       local_file = _local_directory + "/" + file;
 #else
-         local_file = file;
+      local_file = file;
 #endif
     
     // remote file -> get only file name from in_files