~adigitoleo/geobits

e1dc472ad2cebcfeb7244f5ad3e1aa5c437d484c — adigitoleo 8 months ago
Initial commit
5 files changed, 77 insertions(+), 0 deletions(-)

A LICENSE
A README.md
A tools/mktar.sh
A tools/q,del.sh
A tools/q,stat.sh
A  => LICENSE +6 -0
@@ 1,6 @@
BSD Zero Clause License

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


A  => README.md +1 -0
@@ 1,1 @@
Various utilities for computational geodynamics

A  => tools/mktar.sh +38 -0
@@ 1,38 @@
#!/bin/sh
set -eu
helpf() {
    echo 'mktar LOG OUTDIR'
    echo
    echo 'Create compressed tar archive of simulation results.'
    echo 'The plain text LOG file should contain a line with'
    echo '  Resource Usage on <date> <time>:'
    echo '(case insensitive) where <date> is in YYYY-MM-DD format and'
    echo '<time> is in HH:mm:ss format.'
    echo 'The output directory OUTDIR should contain all output files.'
}
warn() { 1>&2 printf 'mktar: %s\n' "$1"; }

DATESTAMP=
mkisodate() {
    DATESTAMP="$(sed -n 's/.*resource usage on \([0-9-]*\) \([0-9:]*\)/\1T\2/Ip' "$1"|tr -d '-'|tr -d ':')"
}

while getopts "h" OPT; do
    case "$OPT" in h ) helpf; exit 0;; * ) helpf; exit 1;; esac
done
shift $(( OPTIND - 1 ))

[ $# -eq 2 ] || { warn "2 arguments required, see mktar -h"; exit 1; }
[ -d "$2" ] || { warn "OUTDIR=${2} is not a directory"; exit 1; }
LOGFILE="$1"
OUTDIR="$2"
ERRFILE="${LOGFILE%%.log}.err"
[ -f "$LOGFILE" ] || { warn "LOGFILE=${LOGFILE} not found"; exit 1; }
cp "$LOGFILE" "$OUTDIR"
[ -f "$ERRFILE" ] || { warn "ERRFILE=${ERRFILE} not found"; exit 1; }
cp "$ERRFILE" "$OUTDIR"

mkisodate "$LOGFILE"
[ -n "$DATESTAMP" ] || { warn "empty DATESTAMP for ${LOGFILE}"; exit 1; }
OUTDIRNEW="${OUTDIR%%/}_${DATESTAMP}"
tar --transform="s/$OUTDIR/$OUTDIRNEW/" --exclude="{__pycache__,.mypy_cache,.pytest_cache}" -vcaf "$OUTDIRNEW".tar.gz "$OUTDIR"

A  => tools/q,del.sh +16 -0
@@ 1,16 @@
#!/bin/sh
set -eu
helpf() { echo 'q,del <REFFILE> -- delete/abort PBS job using ID read from REFFILE' }
is_command() {
    if 1>/dev/null 2>&1 command -v "$1"; then
        return 0
    else
        >&2 printf '%s\n' "$HOME/.zprofile: command '$1' not found"; return 1
    fi
}
warn() { >&2 printf '%s\n' "$SCRIPTNAME: $1"; }
is_command qdel || { warn 'missing required executable: qdel'; exit 1; }

[ $# -eq 0 ] && { helpf; exit 1; }
[ $1 = "-h" ] && { helpf; exit 1; }
qdel $(cat "$1")

A  => tools/q,stat.sh +16 -0
@@ 1,16 @@
#!/bin/sh
set -eu
helpf() { echo 'q,stat <REFFILE> -- show PBS job status of job ID read from REFFILE' }
is_command() {
    if 1>/dev/null 2>&1 command -v "$1"; then
        return 0
    else
        >&2 printf '%s\n' "$HOME/.zprofile: command '$1' not found"; return 1
    fi
}
warn() { >&2 printf '%s\n' "$SCRIPTNAME: $1"; }
is_command qstat || { warn 'missing required executable: qstat'; exit 1; }

[ $# -eq 0 ] && { helpf; exit 1; }
[ $1 = "-h" ] && { helpf; exit 1; }
qstat -s1x $(cat "$1")