diff --git a/cylc/flow/etc/job.sh b/cylc/flow/etc/job.sh index 1a20a88071f..2355edd2677 100644 --- a/cylc/flow/etc/job.sh +++ b/cylc/flow/etc/job.sh @@ -73,6 +73,10 @@ cylc__job__main() { export CYLC_WORKFLOW_LOG_DIR="${CYLC_WORKFLOW_RUN_DIR}/log/scheduler" export CYLC_WORKFLOW_SHARE_DIR="${CYLC_WORKFLOW_RUN_DIR}/share" export CYLC_WORKFLOW_WORK_DIR="${CYLC_WORKFLOW_RUN_DIR}/work" + # Make sure the 'raw' version of SHARE and WORK are defined. + # Default to the ones defined above. + export CYLC_WORKFLOW_SHARE_DIR_RAW="${CYLC_WORKFLOW_SHARE_DIR_RAW:-"${CYLC_WORKFLOW_SHARE_DIR}"}" + export CYLC_WORKFLOW_WORK_DIR_RAW="${CYLC_WORKFLOW_WORK_DIR_RAW:-"${CYLC_WORKFLOW_WORK_DIR}"}" export CYLC_TASK_CYCLE_POINT="${CYLC_TASK_JOB%%/*}" export CYLC_TASK_NAME="${CYLC_TASK_JOB#*/}" CYLC_TASK_NAME="${CYLC_TASK_NAME%/*}" @@ -95,6 +99,7 @@ cylc__job__main() { CYLC_TASK_WORK_DIR_BASE="${CYLC_TASK_CYCLE_POINT}/${CYLC_TASK_NAME}" fi export CYLC_TASK_WORK_DIR="${CYLC_WORKFLOW_WORK_DIR}/${CYLC_TASK_WORK_DIR_BASE}" + export CYLC_TASK_WORK_DIR_RAW="${CYLC_WORKFLOW_WORK_DIR_RAW}/${CYLC_TASK_WORK_DIR_BASE}" typeset contact="${CYLC_WORKFLOW_RUN_DIR}/.service/contact" if [[ -f "${contact}" ]]; then # (contact file not present for polled platforms) @@ -134,9 +139,8 @@ cylc__job__main() { export PATH="${CYLC_WORKFLOW_RUN_DIR}/share/bin:${CYLC_WORKFLOW_RUN_DIR}/bin:${PATH}" export PYTHONPATH="${CYLC_WORKFLOW_RUN_DIR}/share/lib/python:${CYLC_WORKFLOW_RUN_DIR}/lib/python:${PYTHONPATH:-}" # Create share and work directories - mkdir -p "${CYLC_WORKFLOW_SHARE_DIR}" || true - mkdir -p "$(dirname "${CYLC_TASK_WORK_DIR}")" || true - mkdir -p "${CYLC_TASK_WORK_DIR}" + mkdir -p "${CYLC_WORKFLOW_SHARE_DIR_RAW}" || true + mkdir -p "${CYLC_TASK_WORK_DIR_RAW}" cd "${CYLC_TASK_WORK_DIR}" # Env-Script, User Environment, Pre-Script, Script and Post-Script # Run user scripts in subshell to protect cylc job script from interference. diff --git a/cylc/flow/job_file.py b/cylc/flow/job_file.py index 930331dc5a4..ac194acd47d 100644 --- a/cylc/flow/job_file.py +++ b/cylc/flow/job_file.py @@ -205,6 +205,14 @@ def _write_workflow_environment(self, handle, job_conf): if var not in ('CYLC_DEBUG', 'CYLC_VERBOSE', 'CYLC_WORKFLOW_ID'): handle.write('\n export %s="%s"' % (var, val)) + for dir_ in ("share", "work"): + val = job_conf["symlink_dirs"].get(dir_, None) + if val is not None: + handle.write( + '\n ' + f'export CYLC_WORKFLOW_{dir_.upper()}_DIR_RAW="{val}"' + ) + if str(self.workflow_env.get('CYLC_UTC')) == 'True': handle.write('\n export TZ="UTC"') diff --git a/cylc/flow/task_job_mgr.py b/cylc/flow/task_job_mgr.py index 6651488b4b9..40e00ed2d85 100644 --- a/cylc/flow/task_job_mgr.py +++ b/cylc/flow/task_job_mgr.py @@ -55,7 +55,10 @@ pdeepcopy, poverride ) -from cylc.flow.pathutil import get_remote_workflow_run_job_dir +from cylc.flow.pathutil import ( + get_dirs_to_symlink, + get_remote_workflow_run_job_dir, +) from cylc.flow.platforms import ( get_host_from_platform, get_install_target_from_platform, @@ -1345,6 +1348,9 @@ def get_job_conf( 'pre-script': rtconfig['pre-script'], 'script': rtconfig['script'], 'submit_num': itask.submit_num, + 'symlink_dirs': get_dirs_to_symlink( + itask.platform['install target'], workflow + ), 'flow_nums': itask.flow_nums, 'workflow_name': workflow, 'task_id': itask.identity,