File size: 2,413 Bytes
43b3e9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
# MIT License, Bryan Cheng, 2026. Part of PANGEA/READOUT.
#
# Slurm array job running the electrostatics ground truth over a shard of the fragment
# library. The solver work is embarrassingly parallel, one fragment at a time, so the
# array index selects a contiguous row range of the library TSV.
#
# Usage:
#   sbatch --array=0-99 scripts/slurm_apbs_array.sh <library.tsv> <outdir> <rows_per_task> [stratum] [conditions]
#
# Example, the composition-control stratum across all nine ionic conditions:
#   sbatch --array=0-21 scripts/slurm_apbs_array.sh \
#       /home/bjc75/scratch/pangea/fragments/library_v1.tsv \
#       /home/bjc75/scratch/pangea/apbs/compctrl 30 compctrl
#
#SBATCH --job-name=pangea-pb
#SBATCH --requeue
#SBATCH --partition=day,scavenge
#SBATCH --time=03:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=2
#SBATCH --mem=16G
#SBATCH --output=logs/slurm/pb_%A_%a.out
#SBATCH --error=logs/slurm/pb_%A_%a.err

set -uo pipefail

LIBRARY="${1:?library tsv required}"
OUTDIR="${2:?output directory required}"
ROWS_PER_TASK="${3:-50}"
STRATUM="${4:-}"
CONDITIONS="${5:-}"

source /home/bjc75/other/biophyschem/scripts/env.sh
eval "$(conda shell.bash hook)"
conda activate "${CONDA_ENVS_PATH}/phys"
cd /home/bjc75/other/biophyschem

IDX="${SLURM_ARRAY_TASK_ID:-0}"
LO=$(( IDX * ROWS_PER_TASK ))
HI=$(( LO + ROWS_PER_TASK - 1 ))

# Keep solver scratch on the node's local disk; APBS writes large OpenDX maps that are
# read back immediately and then deleted, so they should never touch shared storage.
WORKROOT="${SLURM_TMPDIR:-/tmp}/pangea_pb_${SLURM_JOB_ID:-$$}_${IDX}"
mkdir -p "$WORKROOT" "$OUTDIR" logs/slurm

export OMP_NUM_THREADS="${SLURM_CPUS_PER_TASK:-4}"
export OPENBLAS_NUM_THREADS=1
export MKL_NUM_THREADS=1

echo "host=$(hostname) task=${IDX} rows=${LO}-${HI} cpus=${OMP_NUM_THREADS}"
echo "library=${LIBRARY}"
echo "workroot=${WORKROOT}"

ARGS=(--library "$LIBRARY" --rows "${LO}-${HI}" --out "$OUTDIR" --workroot "$WORKROOT")
[ -n "$STRATUM" ]    && ARGS+=(--stratum "$STRATUM")
[ -n "$CONDITIONS" ] && ARGS+=(--conditions "$CONDITIONS")
# EXTRA_ARGS: further run_fragment.py flags, e.g. "--min-iterations 20000 --min-tolerance 1.0"
[ -n "${EXTRA_ARGS:-}" ] && read -r -a _extra <<< "$EXTRA_ARGS" && ARGS+=("${_extra[@]}")

python "${CODE_ROOT:-.}/src/physics/run_fragment.py" "${ARGS[@]}"
rc=$?

rm -rf "$WORKROOT"
echo "exit=${rc}"
exit "$rc"