-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/hera_port This commit references #1.
Baseline the batch submission wrappers per request of global workflow group. These are used by the chgres script. Previously, they resided in the glopara home directories on each machine.
- Loading branch information
1 parent
3241cfa
commit 2044db3
Showing
3 changed files
with
668 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
#!/bin/ksh | ||
set -x | ||
usage="\ | ||
Usage: $0 [options] executable [args] | ||
where the options are: | ||
-a account account (default: none) | ||
-b binding run smt binding or not (default:NO) | ||
-d dirin initial directory (default: cwd) | ||
-e envars copy comma-separated environment variables | ||
-g group group name | ||
-i append standard input to command file | ||
-j jobname specify jobname (default: executable basename) | ||
-m machine machine on which to run (default: current) | ||
-n write command file to stdout rather than submitting it | ||
-o output specify output file (default: jobname.out) | ||
-p procs[/nodes[/ppreq] | ||
number of MPI tasks and optional nodes or Bblocking and | ||
ppreq option (N or S) (defaults: serial, Bunlimited, S) | ||
-q queue[/qpreq] queue name and optional requirement, e.g. dev/P | ||
(defaults: 1 if serial or dev if parallel and none) | ||
(queue 3 or 4 is dev or prod with twice tasks over ip) | ||
(options: P=parallel, B=bigmem, b=batch) | ||
-r rmem[/rcpu] resources memory and cpus/task (default: '1024 mb', 1) | ||
-t timew wall time limit in [[hh:]mm:]ss format (default: 900) | ||
-u userid userid to run under (default: self) | ||
-v verbose mode | ||
-w when when to run, in yyyymmddhh[mm], +hh[mm], thh[mm], or | ||
Thh[mm] (full, incremental, today or tomorrow) format | ||
(default: now) | ||
Function: This command submits a job to the batch queue." | ||
subcmd="$*" | ||
stdin=NO | ||
nosub=NO | ||
account="" | ||
binding="NO" | ||
dirin="" | ||
envars="para" | ||
group="" | ||
jobname="" | ||
machine="" | ||
output="" | ||
procs=0 | ||
nodes="" | ||
ppreq="N" | ||
queue="" | ||
qpreq="" | ||
rmem="1200" | ||
rcpu="1" | ||
timew="900" | ||
userid="" | ||
verbose=NO | ||
when="" | ||
while getopts a:b:d:e:g:ij:m:no:p:q:r:t:u:vw: opt;do | ||
case $opt in | ||
a) account="$OPTARG";; | ||
b) binding="$OPTARG";; | ||
d) dirin="$OPTARG";; | ||
e) envars="$OPTARG";; | ||
g) group="$OPTARG";; | ||
i) stdin=YES;; | ||
j) jobname=$OPTARG;; | ||
m) machine="$OPTARG";; | ||
n) nosub=YES;; | ||
o) output=$OPTARG;; | ||
p) procs=$(echo $OPTARG/|cut -d/ -f1);nodes=$(echo $OPTARG/|cut -d/ -f2);ppreq=$(echo $OPTARG/|cut -d/ -f3);; | ||
q) queue=$(echo $OPTARG/|cut -d/ -f1);qpreq=$(echo $OPTARG/|cut -d/ -f2);; | ||
r) rmem=$(echo $OPTARG/|cut -d/ -f1);rcpu=$(echo $OPTARG/|cut -d/ -f2);; | ||
t) timew=$OPTARG;; | ||
u) userid=$OPTARG;; | ||
v) verbose=YES;; | ||
w) when=$OPTARG;; | ||
\?) echo $0: invalid option >&2;echo "$usage" >&2;exit 1;; | ||
esac | ||
done | ||
shift $(($OPTIND-1)) | ||
if [[ $# -eq 0 ]];then | ||
echo $0: missing executable name >&2;echo "$usage" >&2;exit 1 | ||
fi | ||
exec=$1 | ||
if [[ ! -s $exec ]]&&which $exec >/dev/null 2>&1;then | ||
exec=$(which $exec) | ||
fi | ||
shift | ||
args="$*" | ||
bn=$(basename $exec) | ||
jobname=${jobname:-$bn} | ||
output=${output:-$jobname.out} | ||
myuser=$LOGNAME | ||
myhost=$(hostname) | ||
|
||
DATA=${DATA:-/scratch4/NCEPDEV/stmp4/$LOGNAME/sub} | ||
mkdir -p $DATA | ||
|
||
partition=${partition:-service} | ||
queue=${queue:-batch} | ||
timew=${timew:-01:20:00} | ||
task_node=${procs:-12} | ||
ntasks=$((nodes*task_node)) | ||
envars=$envars | ||
|
||
#export TZ=GMT | ||
export TZ="America/New_York" | ||
cfile=$DATA/sub$$ | ||
> $cfile | ||
echo "#!/bin/ksh " >> $cfile | ||
echo "#SBATCH -A $account" >> $cfile | ||
echo "#SBATCH -o $output" >> $cfile | ||
echo "#SBATCH -e $output" >> $cfile | ||
echo "#SBATCH -J $jobname" >> $cfile | ||
echo "#SBATCH -q $queue" >> $cfile | ||
echo "#SBATCH -p $partition" >> $cfile | ||
##echo "#SBATCH -v $envars" >> $cfile | ||
echo "#SBATCH --nodes=$nodes --ntasks=$ntasks" >> $cfile | ||
echo "#SBATCH -t $timew" >> $cfile | ||
echo "/bin/ksh --login -x $exec $args" >> $cfile | ||
|
||
if [[ $stdin = YES ]];then | ||
cat | ||
fi >>$cfile | ||
if [[ $nosub = YES ]];then | ||
cat $cfile | ||
exit | ||
elif [[ $verbose = YES ]];then | ||
set -x | ||
cat $cfile | ||
fi | ||
|
||
sbatch=${sbatch:-/apps/slurm/default/bin/sbatch} | ||
|
||
ofile=$DATA/subout$$ | ||
>$ofile | ||
chmod 777 $ofile | ||
$sbatch $cfile >$ofile | ||
rc=$? | ||
cat $ofile | ||
if [[ -w $SUBLOG ]];then | ||
jobn=$(grep -i submitted $ofile|head -n1|cut -d\" -f2) | ||
# date -u +"%Y%m%d%H%M%S : $subcmd : $jobn" >>$SUBLOG | ||
date +"%Y%m%d%H%M%S : $subcmd : $jobn" >>$SUBLOG | ||
fi | ||
#exit | ||
#rm $cfile $ofile | ||
[[ $MKDATA = YES ]] && rmdir $DATA | ||
exit $rc |
Oops, something went wrong.