From 0d813b4aef28a0c73bd764d6d4f4fe971092b939 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Thu, 11 Dec 2014 17:22:52 +0100 Subject: [PATCH] The default value of the working directory of a job is set to the one of the ressource used. 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 | 7 +++++++ src/Launcher/Launcher_Job.cxx | 24 ++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl index c3ad69051..ca27ffa57 100644 --- a/idl/SALOME_Launcher.idl +++ b/idl/SALOME_Launcher.idl @@ -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; diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 83e007c0c..34c334756 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -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 -- 2.39.2