Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add POSTAMBLE_CMD into preamble postamble #2235

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions env/HERA.env
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export npe_node_max=40
export launcher="srun -l --export=ALL"
export mpmd_opt="--multi-prog --output=mpmd.%j.%t.out"

#export POSTAMBLE_CMD='report-mem'

# Configure MPI environment
#export I_MPI_ADJUST_ALLREDUCE=5
#export MPI_BUFS_PER_PROC=2048
Expand Down
20 changes: 20 additions & 0 deletions ush/preamble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# TRACE (YES/NO): Whether to echo every command (set -x) [default: "YES"]
# STRICT (YES/NO): Whether to exit immediately on error or undefined variable
# (set -eu) [default: "YES"]
# POSTAMBLE_CMD (empty/set): A command to run at the end of the job
# [default: empty]
#
#######
set +x
Expand Down Expand Up @@ -70,6 +72,24 @@ postamble() {
start_time="${2}"
rc="${3}"

# Execute postamble command
#
# Commands can be added to the postamble by appending them to $POSTAMBLE_CMD:
# POSTAMBLE_CMD="new_thing; ${POSTAMBLE_CMD:-}" # (before existing commands)
# POSTAMBLE_CMD="${POSTAMBLE_CMD:-}; new_thing" # (after existing commands)
#
# Always use this form so previous POSTAMBLE_CMD are not overwritten. This should
# only be used for commands that execute conditionally (i.e. on certain machines
# or jobs). Global changes should just be added to this function.
# These commands will be called when EACH SCRIPT terminates, so be mindful. Please
# consult with global-workflow CMs about permanent changes to $POSTAMBLE_CMD or
# this postamble function.
#

if [[ -v 'POSTAMBLE_CMD' ]]; then
${POSTAMBLE_CMD}
fi

# Calculate the elapsed time
end_time=$(date +%s)
end_time_human=$(date -d@"${end_time}" -u +%H:%M:%S)
Expand Down