Listing 4. Script to Set $TMPDIR Inside Batch Jobs

#!/bin/csh
#
# /etc/profile.d/tmpdir.csh
#
# If PBS_ENVIRONMENT exists and is "PBS_BATCH" of
#  "PBS_INTERACTIVE",
# set TMPDIR
if ( $?PBS_ENVIRONMENT ) then
  if ( "$PBS_ENVIRONMENT" == "PBS_BATCH" ||
       "$PBS_ENVIRONMENT" == "PBS_INTERACTIVE") then
    setenv TMPDIR /tmp/pbstmp.$PBS_JOBID
  endif
endif