1 | #!/bin/ksh |
---|
2 | ###################################################### |
---|
3 | # Original : C. Talandier for ESOPA |
---|
4 | # Contact : opatlod@locean-ipsl.upmc.fr |
---|
5 | # |
---|
6 | # INPUT ARGS: 3 + 1 optional |
---|
7 | # - CONF : configuration name (ORCA2_LIM, GYRE ..) |
---|
8 | # - MTIME : timing/no timing (timing or notiming) |
---|
9 | # - JOBTOL: jobs to launch: all, long, 1_short or gtime |
---|
10 | # - REFTAG: (optional): reference tag name to which current |
---|
11 | # version will be compare to |
---|
12 | # |
---|
13 | # WORK: This script aims to (for each standard configuration) : |
---|
14 | # |
---|
15 | # I. Take into account target's specificities |
---|
16 | # Variables below must be filled for a new target |
---|
17 | # - W_XX = name of target |
---|
18 | # - LAUN = name of jobs launcher command |
---|
19 | # - LLJOBS = name of jobs listing command |
---|
20 | # - LSUB = name of running command |
---|
21 | # - LPERF = name of timing command for the whole run |
---|
22 | # - LJTIM = required time for a one year run (/proc) |
---|
23 | # - LJTIMJ = required time for a one year run (job) |
---|
24 | # - CMDGET = name of specific command to retrieve files |
---|
25 | # - SYMBOL = identifier associated to a platform which |
---|
26 | # is used to name all outputs files |
---|
27 | # Ex: For Brodie, this symbol could be "B_" so |
---|
28 | # file names looks like B_solver.stat ... |
---|
29 | # |
---|
30 | # II. Build jobs |
---|
31 | # - based on specific header depending on target, it must |
---|
32 | # be provided for a new target following samples |
---|
33 | # jhd_[target_name]_mon for mono-processors runs |
---|
34 | # jhd_[target_name]_mpi for multi-processors MPI runs |
---|
35 | # jhd_[target_name]_omp for multi-processors OPen-MP runs |
---|
36 | # |
---|
37 | # III. Launch jobs |
---|
38 | # to test both reproductibility and restartability |
---|
39 | # for each configuration NAME_CONF |
---|
40 | # & for each run type [mon, mpi, omp] |
---|
41 | # 3 runs will be launched: |
---|
42 | # - LONG |
---|
43 | # - 1_SHORT |
---|
44 | # - 2_SHORT |
---|
45 | # |
---|
46 | # IV. Launch cron job |
---|
47 | # Since no jobs (for a given configuration) are in |
---|
48 | # the batch queue, this cron will launch the assessment.ksh |
---|
49 | # script |
---|
50 | # |
---|
51 | ########################################################## |
---|
52 | #set -xv |
---|
53 | ########################################################## |
---|
54 | ##### Begin Users modifications |
---|
55 | ########################################################## |
---|
56 | # IODIR : directory where to get ORCA2_LIM_nemo_v2.tar |
---|
57 | # PRC : total number of processors which will be used |
---|
58 | ########################################################## |
---|
59 | IODIR=/Volumes/FENUA/ORCA2_LIM_nemo_v2_IO |
---|
60 | PRC=8 |
---|
61 | TARGET=osxxlf |
---|
62 | ########################################################## |
---|
63 | ##### End Users modifications |
---|
64 | ########################################################## |
---|
65 | |
---|
66 | CONF=$1 |
---|
67 | MTIME=$2 |
---|
68 | JOBTOL=$3 |
---|
69 | REFTAG=$4 |
---|
70 | RUN=$(basename `pwd`) |
---|
71 | |
---|
72 | # Specific case of Zahir: |
---|
73 | if [ ${RUN} = 'mon' -a ${TARGET} = 'aix' ] ; then TARGET=ax_mono ; fi |
---|
74 | |
---|
75 | # --------------------------------------------------------------- |
---|
76 | # I. Take into account target's specificities |
---|
77 | # Select appropriate target lines in Job_${CONF}.ksh |
---|
78 | # --------------------------------------------------------------- |
---|
79 | if [ ${TARGET} = 'sx8brodie' ]; then |
---|
80 | W_XX='#-T- sx8brodie' |
---|
81 | LAUN='qsub ' |
---|
82 | LLJOBS=qstat |
---|
83 | LSUB="mpirun -np ${PRC}" |
---|
84 | LPERF= |
---|
85 | LJTIM='01:20:00' |
---|
86 | LJTIMJ='01:40:00' |
---|
87 | CMDGET=mfget |
---|
88 | SYMBOL=B_ |
---|
89 | elif [ ${TARGET} = 'aix' ]; then |
---|
90 | W_XX='#-T- aix' |
---|
91 | LAUN='llsubmit ' |
---|
92 | LLJOBS=Qstat |
---|
93 | LSUB= |
---|
94 | LPERF="poe hpmcount -o perfs_mpi.txt" |
---|
95 | LJTIM=4000 |
---|
96 | LJTIMJ= |
---|
97 | CMDGET=mfget |
---|
98 | SYMBOL=Z_ |
---|
99 | elif [ ${TARGET} = 'ax_mono' ]; then |
---|
100 | W_XX='#-T- ax_mono' |
---|
101 | LAUN='llsubmit ' |
---|
102 | LLJOBS=Qstat |
---|
103 | LSUB= |
---|
104 | LPERF="hpmcount -o perfs_mon.txt" |
---|
105 | LJTIM=30000 |
---|
106 | LJTIMJ= |
---|
107 | CMDGET=mfget |
---|
108 | SYMBOL=Z_ |
---|
109 | elif [ ${TARGET} = 'osxxlf' ]; then |
---|
110 | W_XX='#-T- osxxlf' |
---|
111 | LAUN='./' |
---|
112 | LLJOBS= |
---|
113 | LSUB="mpirun -np ${PRC}" |
---|
114 | LPERF= |
---|
115 | LJTIM= |
---|
116 | LJTIMJ= |
---|
117 | CMDGET=cp |
---|
118 | SYMBOL=D_ |
---|
119 | else |
---|
120 | echo ' #######################################' |
---|
121 | echo ' You must give a target name :' |
---|
122 | echo ' sx8brodie, aix, ax_mono or add one' |
---|
123 | echo ' Have a look in lance_batch.ksh script' |
---|
124 | echo ' #######################################' |
---|
125 | stop |
---|
126 | fi |
---|
127 | |
---|
128 | sed -e "s/^$W_XX *//" job_${CONF}.ksh | grep -v '^#-T- ' > job_${CONF}.$$ |
---|
129 | |
---|
130 | # -------------------------------------------------------------- |
---|
131 | # II. Build jobs |
---|
132 | # Adapt header (batch jobs) and concatanate it with core job |
---|
133 | # -------------------------------------------------------------- |
---|
134 | case ${TARGET} in |
---|
135 | 'osxxlf' ) |
---|
136 | cp jhd_${TARGET}_${RUN} jhd_${TARGET}_${RUN}_tmp ;; |
---|
137 | 'ax_mono' ) |
---|
138 | CAR_JNAM=$( grep '\# @ job_name' jhd_${TARGET}_${RUN} ) |
---|
139 | sed -e "s/$CAR_JNAM/\# @ job_name = ${RUN}${CONF}/" \ |
---|
140 | jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp ;; |
---|
141 | 'aix' ) |
---|
142 | CAR_JNAM=$( grep '\# @ job_name' jhd_${TARGET}_${RUN} ) |
---|
143 | CAR_JMPI=$( grep '\# @ total_tasks' jhd_${TARGET}_${RUN} ) |
---|
144 | sed -e "s/$CAR_JNAM/\# @ job_name = ${RUN}${CONF}/" \ |
---|
145 | -e "s/$CAR_JMPI/\# @ total_tasks = ${PRC}/" \ |
---|
146 | jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp ;; |
---|
147 | 'sx8brodie' ) |
---|
148 | CAR_JNAM=$( grep '\#PBS -N ' jhd_${TARGET}_${RUN} ) |
---|
149 | CAR_JNAMO=$( grep '\#PBS -o ' jhd_${TARGET}_${RUN} ) |
---|
150 | CAR_JNAME=$( grep '\#PBS -e ' jhd_${TARGET}_${RUN} ) |
---|
151 | if [ ${RUN} = 'mpi' -o ${RUN} = 'omp' ] ; then |
---|
152 | CAR_JMPI=$( grep '\#PBS -l cpunum_job' jhd_${TARGET}_${RUN} ) |
---|
153 | sed -e "s/$CAR_JNAM/\#PBS -N ${RUN}${CONF}/" \ |
---|
154 | -e "s/$CAR_JNAMO/\#PBS -o ${RUN}${CONF}_std/" \ |
---|
155 | -e "s/$CAR_JNAME/\#PBS -e ${RUN}${CONF}_err/" \ |
---|
156 | -e "s/$CAR_JMPI/\#PBS -l cpunum_job=${PRC}/" \ |
---|
157 | jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp |
---|
158 | else |
---|
159 | sed -e "s/$CAR_JNAM/\#PBS -N ${RUN}${CONF}/" \ |
---|
160 | -e "s/$CAR_JNAMO/\#PBS -o ${RUN}${CONF}_std/" \ |
---|
161 | -e "s/$CAR_JNAME/\#PBS -e ${RUN}${CONF}_err/" \ |
---|
162 | jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp |
---|
163 | fi ;; |
---|
164 | esac |
---|
165 | |
---|
166 | cat jhd_${TARGET}_${RUN}_tmp job_${CONF}.$$ > job_tmp_${RUN}.ksh |
---|
167 | rm -f job_${CONF}.$$ jhd_${TARGET}_${RUN}_tmp |
---|
168 | |
---|
169 | # ----------------------------------------------------------------------------- |
---|
170 | # III. Launch jobs |
---|
171 | # The 3 following jobs are created for the run [type]=mon,mpi,omp : |
---|
172 | # - "job_[type]_long.ksh" ---> long run |
---|
173 | # - "job_[type]_1_short.ksh" ---> stream 1 run |
---|
174 | # - "job_[type]_2_short.ksh" ---> stream 2 run |
---|
175 | # - "job_[type]_gtime.ksh" ---> one year run |
---|
176 | # The first 2 as the last one are immediatly launched whereas "job_[type]_2_short.ksh" |
---|
177 | # is launched only when the "job_[type]_1_short.ksh" short run is finished |
---|
178 | # ----------------------------------------------------------------------------- |
---|
179 | jobnam[0]=long ; jobnam[1]=1_short ; jobnam[2]=2_short ; jobnam[3]=gtime |
---|
180 | dirjob[0]=LONG ; dirjob[1]=1_SHORT ; dirjob[2]=2_SHORT ; dirjob[3]=GTIME |
---|
181 | |
---|
182 | case ${JOBTOL} in |
---|
183 | 'all' ) |
---|
184 | if [ ${MTIME} = 'timing' ] ; then |
---|
185 | ind=0 |
---|
186 | iloop=4 |
---|
187 | else |
---|
188 | ind=0 |
---|
189 | iloop=3 |
---|
190 | fi |
---|
191 | ;; |
---|
192 | 'long' ) |
---|
193 | ind=0 |
---|
194 | iloop=1 ;; |
---|
195 | 'short' ) |
---|
196 | ind=1 |
---|
197 | iloop=3 ;; |
---|
198 | 'gtime' ) |
---|
199 | ind=3 |
---|
200 | iloop=4 ;; |
---|
201 | esac |
---|
202 | |
---|
203 | while [ $ind -lt ${iloop} ] |
---|
204 | do |
---|
205 | CAR_TYPE_tmp=$( grep 'type=' job_tmp_${RUN}.ksh ) |
---|
206 | CAR_TYPE=`echo $CAR_TYPE_tmp | cut -f 1 -d " " ` |
---|
207 | CAR_RUN_tmp=$( grep 'RUN=xxx' job_tmp_${RUN}.ksh ) |
---|
208 | CAR_RUN=`echo $CAR_RUN_tmp | cut -f 1 -d " " ` |
---|
209 | CAR_MPP_tmp=$( grep 'NB_PROCS=xxx' job_tmp_${RUN}.ksh ) |
---|
210 | CAR_MPP=`echo $CAR_MPP_tmp | cut -f 1 -d " " ` |
---|
211 | CAR_SUB_tmp=$( grep 'LAUNCH=xxx' job_tmp_${RUN}.ksh ) |
---|
212 | CAR_SUB=`echo $CAR_SUB_tmp | cut -f 1 -d " " ` |
---|
213 | CAR_EXE_tmp=$( grep 'LEXE=xxx' job_tmp_${RUN}.ksh ) |
---|
214 | CAR_EXE=`echo $CAR_EXE_tmp | cut -f 1 -d " " ` |
---|
215 | CAR_PER_tmp=$( grep 'CPERF=xxx' job_tmp_${RUN}.ksh ) |
---|
216 | CAR_PER=`echo $CAR_PER_tmp | cut -f 1 -d " " ` |
---|
217 | CAR_MAN_tmp=$( grep 'MAINDIR=xxx' job_tmp_${RUN}.ksh ) |
---|
218 | CAR_MAN=`echo $CAR_MAN_tmp | cut -f 1 -d " " ` |
---|
219 | CAR_INP_tmp=$( grep 'D_INPUT=xxx' job_tmp_${RUN}.ksh ) |
---|
220 | CAR_INP=`echo $CAR_INP_tmp | cut -f 1 -d " " ` |
---|
221 | CAR_GET_tmp=$( grep 'D_GET=xxx' job_tmp_${RUN}.ksh ) |
---|
222 | CAR_GET=`echo $CAR_GET_tmp | cut -f 1 -d " " ` |
---|
223 | CAR_RTG_tmp=$( grep 'REF_TAG=xxx' job_tmp_${RUN}.ksh ) |
---|
224 | CAR_RTG=`echo $CAR_RTG_tmp | cut -f 1 -d " " ` |
---|
225 | CAR_TSY_tmp=$( grep 'TSYMB=xxx' job_tmp_${RUN}.ksh ) |
---|
226 | CAR_TSY=`echo $CAR_TSY_tmp | cut -f 1 -d " " ` |
---|
227 | |
---|
228 | sed -e "s/$CAR_TYPE/type=${jobnam[$ind]}/" \ |
---|
229 | -e "s/$CAR_RUN/RUN=$RUN/" \ |
---|
230 | -e "s/$CAR_MPP/NB_PROCS=$PRC/" \ |
---|
231 | -e "s@$CAR_SUB@LAUNCH='$LAUN'@" \ |
---|
232 | -e "s/$CAR_EXE/LEXE='$LSUB'/" \ |
---|
233 | -e "s/$CAR_PER/CPERF='$LPERF'/" \ |
---|
234 | -e "s?$CAR_INP?D_INPUT=$IODIR?" \ |
---|
235 | -e "s/$CAR_GET/D_GET=$CMDGET/" \ |
---|
236 | -e "s/$CAR_RTG/REF_TAG=$REFTAG/" \ |
---|
237 | -e "s/$CAR_TSY/TSYMB=$SYMBOL/" \ |
---|
238 | job_tmp_${RUN}.ksh > job_${RUN}_${jobnam[$ind]}.ksh |
---|
239 | |
---|
240 | if [ ${jobnam[$ind]} = 'gtime' ] ; then |
---|
241 | |
---|
242 | case ${TARGET} in |
---|
243 | 'ax_mono' | 'aix' ) |
---|
244 | CAR_JTIM=$( grep '\# @ cpu_limit' job_${RUN}_${jobnam[$ind]}.ksh ) |
---|
245 | sed -e "s/$CAR_JTIM/\# @ cpu_limit = ${LJTIM}/" \ |
---|
246 | job_${RUN}_${jobnam[$ind]}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp ;; |
---|
247 | 'sx8brodie' ) |
---|
248 | CAR_JTIMP=$( grep '\#PBS -l cputim_prc' job_${RUN}_${jobnam[$ind]}.ksh ) |
---|
249 | CAR_JTIMJ=$( grep '\#PBS -l cputim_job' job_${RUN}_${jobnam[$ind]}.ksh ) |
---|
250 | sed -e "s/$CAR_JTIMP/\#PBS -l cputim_prc=${LJTIM}/" \ |
---|
251 | -e "s/$CAR_JTIMJ/\#PBS -l cputim_job=${LJTIMJ}/" \ |
---|
252 | job_${RUN}_${jobnam[$ind]}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp ;; |
---|
253 | esac |
---|
254 | mv job_${RUN}_${jobnam[$ind]}.ksh_tmp job_${RUN}_${jobnam[$ind]}.ksh |
---|
255 | |
---|
256 | fi |
---|
257 | |
---|
258 | chmod 750 job_${RUN}_${jobnam[$ind]}.ksh |
---|
259 | mv job_${RUN}_${jobnam[$ind]}.ksh ${dirjob[$ind]}/. |
---|
260 | |
---|
261 | if [ ${jobnam[$ind]} != '2_short' ] ; then |
---|
262 | cd ${dirjob[$ind]} |
---|
263 | ${LAUN}job_${RUN}_${jobnam[$ind]}.ksh & |
---|
264 | cd ../ |
---|
265 | fi |
---|
266 | |
---|
267 | let ind=$ind+1 |
---|
268 | done |
---|
269 | rm -f job_tmp_${RUN}.ksh |
---|
270 | |
---|
271 | # List all jobs submitted |
---|
272 | ${LLJOBS} |
---|
273 | |
---|
274 | # ----------------------------------------------------------------------------- |
---|
275 | # IV. Launch cron to be able to launch the assessment step |
---|
276 | # ----------------------------------------------------------------------------- |
---|
277 | if [ ${RUN} == 'mon' ] ; then |
---|
278 | cd .. |
---|
279 | |
---|
280 | CAR_LJOB_tmp=$( grep 'LJOBS=' cron_jobs.ksh ) |
---|
281 | CAR_LJOB=`echo $CAR_LJOB_tmp | cut -f 1 -d " " ` |
---|
282 | |
---|
283 | sed -e "s/$CAR_LJOB/LJOBS=${LLJOBS}/" cron_jobs.ksh > cron_jobs.$$ |
---|
284 | mv cron_jobs.$$ cron_jobs.ksh && rm -rf cron_jobs.$$ |
---|
285 | chmod 744 cron_jobs.ksh |
---|
286 | |
---|
287 | if [ ${TARGET} != 'osxxlf' ]; then |
---|
288 | ./cron_jobs.ksh ${CONF} & |
---|
289 | fi |
---|
290 | fi |
---|