Question About Passing Environment Variables for PBS Job

@domd1: two things come to mind. The first is that at OSC we have similar /etc/profile.d's on our web nodes and our compute nodes so that the environments are available in the first place. The other is that for many scheduler clients we offer the ability to write wrappers without disturbing the primary installation. For example to set an environment variable and ensure that the entire environment is passed to jobs you could write the following wrapper:

#!/usr/bin/env bash
# Export arbitrary variables
export THE_ANSWER='42'
# Capture stdin, waiting only 0.1 seconds for input
read -t 0.1 -r -d '' STDIN_CONTENTS
# Point to the real qsub
QSUB=/opt/pbs/bin/qsub
# Switch on whether or not stdin was empty
# Pass -V to ensure that the entire environment is passed to the job
if [[ -z "$STDIN_CONTENTS" ]]; then
  exec "$QSUB" -V "$@"
else
  echo "$STDIN_CONTENTS" | exec "$QSUB" -V "$@"
fi
# Do not echo or print to STDOUT; the resource adapter parses qsub's
# stdout and changing that format is likely to break OnDemand.

You would then make the wrapper executable, and install it somewhere that makes sense; say /opt/pbs/bin_wrappers/qsub. Finally you would update your cluster configuration like so:

---
v2:
  # ...
  job:
    adapter: "pbspro"
    # ...
    bin_overrides:
      qsub: '/opt/pbs/bin_wrappers/qsub'