77# # Intel MPI. ##
88# # ##
99# # Usage: lpjsubmit [-class c] [-group g] [-wtime time] [-blocking n] ##
10- # # [-o output] [-e error] [-q] [-nocheck] ntask ##
11- # # [LPJargs...] ##
10+ # # [-o output] [-e error] [-q] [-nocheck] [-norun] ##
11+ # # ntask [LPJargs...] ##
1212# # ##
1313# # (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file ##
1414# # authors, and contributors see AUTHORS file ##
1818# # ##
1919# ################################################################################
2020
21- if [ $# -lt 1 ]
22- then
23- echo >&2 Error: Number of tasks missing
24- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
25- exit 1
26- fi
27-
2821if [ " $LPJROOT " = " " ]
2922then
3023 echo >&2 Error: environment variable LPJROOT is not set
3124 echo >&2 " Set by export LPJROOT=<path to lpjml directory>"
3225 exit 1
3326fi
3427
35- if [ $1 = " -class" ]
36- then
37- if [ $# -lt 2 ]
38- then
39- echo >&2 Error: class missing
40- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
41- exit 1
42- fi
43- shift 1
44- class=$1
45- shift 1
46- else
47- class=short
48- fi
49- if [ $1 = " -group" ]
50- then
51- if [ $# -lt 2 ]
52- then
53- echo >&2 Error: group missing
54- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
55- exit 1
56- fi
57- shift 1
58- group=$1
59- shift 1
60- else
61- group=" "
62- fi
63-
28+ class=short
29+ group=" "
6430wtime=" "
65- if [ $1 = " -wtime" ]
66- then
67- if [ $# -lt 2 ]
68- then
69- echo >&2 Error: wall clock time missing
70- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
71- exit 1
72- fi
73- shift 1
74- wtime=$1
75- shift 1
76- fi
7731blocking=" unlimited"
78- if [ $1 = " -blocking" ]
79- then
80- if [ $# -lt 2 ]
81- then
82- echo >&2 Error: blocking factor missing
83- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
84- exit 1
85- fi
86- shift 1
87- blocking=$1
88- shift 1
89- fi
9032output=" lpjml.%j.out"
91- if [ $1 = " -o" ]
92- then
93- if [ $# -lt 2 ]
94- then
95- echo >&2 Error: output filename missing
96- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
97- exit 1
98- fi
99- shift 1
100- output=$1
101- shift 1
102- fi
10333error=" lpjml.%j.err"
104- if [ $1 = " -e" ]
105- then
106- if [ $# -lt 2 ]
107- then
108- echo >&2 Error: error filename missing
109- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
110- exit 1
111- fi
112- shift 1
113- error=$1
114- shift 1
115- fi
34+ norun=0
35+
36+ while(( "$# " )) ; do
37+ case " $1 " in
38+ -class)
39+ if [ $# -lt 2 ]
40+ then
41+ echo >&2 Error: class missing
42+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
43+ exit 1
44+ fi
45+ shift 1
46+ class=$1
47+ shift 1
48+ ;;
49+ -group)
50+ if [ $# -lt 2 ]
51+ then
52+ echo >&2 Error: group missing
53+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
54+ exit 1
55+ fi
56+ shift 1
57+ group=$1
58+ shift 1
59+ ;;
60+ -wtime)
61+ if [ $# -lt 2 ]
62+ then
63+ echo >&2 Error: wall clock time missing
64+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
65+ exit 1
66+ fi
67+ shift 1
68+ wtime=$1
69+ shift 1
70+ ;;
71+ -blocking)
72+ if [ $# -lt 2 ]
73+ then
74+ echo >&2 Error: blocking factor missing
75+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
76+ exit 1
77+ fi
78+ shift 1
79+ blocking=$1
80+ shift 1
81+ ;;
82+ -o)
83+ if [ $# -lt 2 ]
84+ then
85+ echo >&2 Error: output filename missing
86+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
87+ exit 1
88+ fi
89+ shift 1
90+ output=$1
91+ shift 1
92+ ;;
93+ -e)
94+ if [ $# -lt 2 ]
95+ then
96+ echo >&2 Error: error filename missing
97+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
98+ exit 1
99+ fi
100+ shift 1
101+ error=$1
102+ shift 1
103+ ;;
104+ -q)
105+ shift 1
106+ quiet=" -Q"
107+ ;;
108+ -nocheck)
109+ shift 1
110+ nocheck=" -nocheck"
111+ ;;
112+ -norun)
113+ shift 1
114+ norun=1
115+ ;;
116+ -* )
117+ echo >&2 Invalid option $1
118+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
119+ exit 1
120+ ;;
121+ * )
122+ break
123+ ;;
124+ esac
125+ done
116126
117- if [ $1 = " -q" ]
118- then
119- shift 1
120- quiet=" -Q"
121- fi
122- if [ $1 = " -nocheck" ]
123- then
124- shift 1
125- nocheck=" -nocheck"
126- fi
127127if [ $# -lt 1 ]
128128then
129129 echo >&2 Error: Number of tasks missing
130- echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] ntasks [args ...]
130+ echo >&2 Usage: $0 [-class c] [-group g] [-wtime time] [-blocking n] [-o output] [-e error] [-q] [-nocheck] [-norun] ntasks [args ...]
131131 exit 1
132132fi
133133
@@ -141,7 +141,7 @@ if $LPJROOT/bin/lpjcheck $quiet $nocheck $args ;
141141then
142142# yes, create SLURM job control file
143143 cat << EOF >slurm.jcf
144- #!/bin/bash
144+ #!/bin/bash
145145###############################################################################
146146## ##
147147## s l u r m . j c f ##
154154## Created: $( date +" %d.%m.%Y" ) ##
155155## ##
156156###############################################################################
157-
157+
158158#SBATCH --ntasks=$ntask
159159#SBATCH --qos=$class
160160#SBATCH --signal=15@180
@@ -194,15 +194,18 @@ srun --propagate \$LPJROOT/bin/lpjml $args
194194rc=\$ ? # save return code of srun
195195exit \$ rc # exit with return code
196196EOF
197- # submit job
198- if sbatch $quiet slurm.jcf ;
197+ if [ " $norun " = " 0" ]
199198 then
200- if [ " $quiet " != " -Q" ]
199+ # submit job
200+ if sbatch $quiet slurm.jcf ;
201201 then
202- squeue -u $( whoami)
202+ if [ " $quiet " != " -Q" ]
203+ then
204+ squeue -u $( whoami)
205+ fi
206+ else
207+ exit 1
203208 fi
204- else
205- exit 1
206209 fi
207210else
208211 echo >&2 " Error in LPJ configuration, job not submitted"
0 commit comments