New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
lance_batch.ksh in trunk/NVTK/INSTALL/JOBS – NEMO

source: trunk/NVTK/INSTALL/JOBS/lance_batch.ksh @ 1412

Last change on this file since 1412 was 1412, checked in by smasson, 15 years ago

update NVTK and ioserver interafce, see ticket:420

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 12.3 KB
Line 
1#!/bin/ksh
2# $Id$
3######################################################
4# Original : C. Talandier for NEMO team
5# Contact  : nemo_st@locean-ipsl.upmc.fr
6#
7# INPUT ARGS: 8
8#     - CONF  : configuration name (ORCA2_LIM, GYRE ..)
9#     - MTIME : timing/no timing (timing or notiming)
10#     - JOBTOL: jobs to launch: all, long, 1_short or gtime
11#     - OWNEXP: name of the experience performed
12#     - REFTAG: reference tag name to be compare to
13#     - USE_IOMPUT: true of false (default false)
14#     - USE_IOSERVER: true of false (default false)
15#     - NB_PROCS_IOSERVER: (default 0)
16#
17# WORK: This script aims to (for each standard configuration) :
18#
19#    I.   Take into account target's specificities
20#         Variables below must be filled for a new target
21#         - W_XX   = name of target
22#         - LAUN   = name of jobs launcher command
23#         - LLJOBS = name of jobs listing command
24#         - LSUB   = name of running command
25#         - LPERF  = name of timing command for the whole run
26#         - LJTIM  = required time for a one year run (/proc)
27#         - LJTIMJ = required time for a one year run (job)
28#         - CMDGET = name of specific command to retrieve files
29#         - SYMBOL = identifier associated to a platform which
30#                    is used to name all outputs files
31#                    Ex: For Brodie, this symbol could be "B_" so
32#                    file names looks like B_solver.stat ...
33#
34#    II.  Build jobs
35#         - based on specific header depending on target, it must
36#           be provided for a new target following samples
37#           jhd_[target_name]_mon for mono-processors runs
38#           jhd_[target_name]_mpi for multi-processors MPI runs
39#           jhd_[target_name]_omp for multi-processors OPen-MP runs
40#
41#    III. Launch jobs
42#         to test both reproductibility and restartability
43#         for each configuration NAME_CONF
44#         & for each run type [mon, mpi, omp]
45#         3 runs will be launched:
46#              - LONG
47#              - 1_SHORT
48#              - 2_SHORT
49#
50#    IV. Launch cron job
51#         Since no jobs (for a given configuration) are in
52#         the batch queue, this cron will launch the assessment.ksh
53#         script
54#
55##########################################################
56#set -xv
57##########################################################
58##### Begin Users modifications
59##########################################################
60# IODIR     : directory where to get ORCA2_LIM_nemo_v3.1.tar
61# PRC       : total number of processors which will be used
62##########################################################
63IODIR=/u/rech/eee/reee512/NEMO/
64PRC=8
65TARGET=sx8brodie
66##########################################################
67##### End   Users modifications
68##########################################################
69
70CONF=$1
71MTIME=$2
72JOBTOL=$3
73OWNEXP=$4
74REFTAG=$5
75USE_IOMPUT=${6:-false}
76USE_IOSERVER=${7:-false}
77NB_PROCS_IOSERVER=${8:-0}
78[ "${USE_IOMPUT}" = "false" ] && USE_IOSERVER=false
79[ "${USE_IOSERVER}" = "false" ] && NB_PROCS_IOSERVER=0
80RUN=$(basename `pwd`)
81[ "${RUN}" = "mon" ] && PRC=1
82if [[ ( "${TARGET}" = "sx8brodie" ) || ( "${TARGET}" = "sx8mercure" ) ]]
83then
84    if [ $(( ${PRC} + ${NB_PROCS_IOSERVER} )) -gt 8 ]
85    then
86   echo NVTK is not made to use more than 1 node on SX8 machines...
87   echo please, reduce the number of cpu used by NEMO or/and the ioserver
88   exit 1
89    fi
90fi
91# ---------------------------------------------------------------
92#  I. Take into account target's specificities
93#     Select appropriate target lines in Job_${CONF}.ksh
94# ---------------------------------------------------------------
95if   [ ${TARGET} = 'sx8brodie' ]; then
96    W_XX='#-T- sx8brodie'
97    LAUN='qsub '
98    LLJOBS=qstat
99    LSUB="mpirun -np ${PRC}"
100    LPERF=
101    LJTIM='01:20:00'
102    LJTIMJ='01:40:00'
103    CMDGET=mfget
104    SYMBOL=B_
105elif [ ${TARGET} = 'sx8mercure' ]; then
106    W_XX='#-T- sx8mercure'
107    LAUN='qsub '
108    LLJOBS=qstat
109    LSUB="mpirun -np ${PRC}"
110    LPERF=
111    LJTIM='01:20:00'
112    LJTIMJ='01:40:00'
113    CMDGET=cp
114    SYMBOL=M_
115elif [ ${TARGET} = 'aix6' ]; then
116    W_XX='#-T- aix6'
117    LAUN='llsubmit '
118    LLJOBS=Qstat
119    LSUB=
120    LPERF="poe hpmcount -o perfs_mpi.txt" 
121    LJTIM='01:10:00'
122    LJTIMJ=
123    CMDGET=mfget
124    SYMBOL=V_
125elif [ ${TARGET} = 'osxxlf' ]; then
126    W_XX='#-T- osxxlf'
127    LAUN='./'
128    LLJOBS=
129    LSUB="mpirun -np ${PRC}"
130    LPERF=
131    LJTIM=
132    LJTIMJ=
133    CMDGET=cp
134    SYMBOL=D_
135else
136    echo '  #######################################'
137    echo '  You must give a target name :'
138    echo '  sx8brodie, aix6 or add one'
139    echo '  Have a look in lance_batch.ksh script'
140    echo '  #######################################'
141    stop
142fi
143
144sed -e "s%^$W_XX *%%" job_${CONF}.ksh | grep -v '^#-T- ' > job_${CONF}.$$
145
146# --------------------------------------------------------------
147# II. Build jobs
148#     Adapt header (batch jobs) and concatanate it with core job
149# --------------------------------------------------------------
150if [ ${CONF} == 'ORCA2_LIM' ] ; then
151CONFS=ORCA2
152elif [ ${CONF} == 'GYRE' ] ; then
153CONFS=GYREO
154elif [ ${CONF} == 'GYRE_LOBSTER' ] ; then
155CONFS=GYREL
156elif [ ${CONF} == 'ORCA2_LIM_PISCES' ] ; then
157CONFS=OR2LP
158elif [ ${CONF} == 'ORCA2_OFF_PISCES' ] ; then
159CONFS=OR2OP
160elif [ ${CONF} == 'ZAGRIF' ] ; then
161CONFS=ZAGRI
162else
163CONFS=${CONF}
164fi
165
166case ${TARGET} in
167     'osxxlf' )
168     cp jhd_${TARGET}_${RUN} jhd_${TARGET}_${RUN}_tmp  ;;
169     'aix6' )
170          CAR_JNAM=$( grep '\# @ job_name' jhd_${TARGET}_${RUN} )
171          CAR_JMPI=$( grep '\# @ total_tasks' jhd_${TARGET}_${RUN} )
172          sed    -e "s%$CAR_JNAM%\# @ job_name = ${RUN}${CONFS}%" \
173          -e "s%$CAR_JMPI%\# @ total_tasks = $(( ${PRC} + ${NB_PROCS_IOSERVER} ))%" \
174          jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp  ;;
175     'sx8brodie' )
176          CAR_JNAM=$( grep '\#PBS -N ' jhd_${TARGET}_${RUN} )
177          CAR_JNAMO=$( grep '\#PBS -o ' jhd_${TARGET}_${RUN} )
178          CAR_JNAME=$( grep '\#PBS -e ' jhd_${TARGET}_${RUN} )
179          if [ ${RUN} = 'mpi' -o ${RUN} = 'omp' ] ; then
180              CAR_JMPI=$( grep '\#PBS -l cpunum_job' jhd_${TARGET}_${RUN} )
181              sed    -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
182              -e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
183              -e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
184              -e "s%$CAR_JMPI%\#PBS -l cpunum_job=$(( ${PRC} + ${NB_PROCS_IOSERVER} ))%" \
185              jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
186          else
187              sed    -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
188              -e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
189              -e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
190              jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
191          fi ;;
192     'sx8mercure' )
193          CAR_JNAM=$( grep '\#PBS -N ' jhd_${TARGET}_${RUN} )
194          CAR_JNAMO=$( grep '\#PBS -o ' jhd_${TARGET}_${RUN} )
195          CAR_JNAME=$( grep '\#PBS -e ' jhd_${TARGET}_${RUN} )
196          if [ ${RUN} = 'mpi' -o ${RUN} = 'omp' ] ; then
197              CAR_JMPI=$( grep '\#PBS -l cpunum_job' jhd_${TARGET}_${RUN} )
198              sed    -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
199              -e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
200              -e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
201              -e "s%$CAR_JMPI%\#PBS -l cpunum_job=$(( ${PRC} + ${NB_PROCS_IOSERVER} ))%" \
202              jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
203          else
204              sed    -e "s%$CAR_JNAM%\#PBS -N  ${RUN}${CONFS}%" \
205              -e "s%$CAR_JNAMO%\#PBS -o  ${RUN}${CONFS}_std%" \
206              -e "s%$CAR_JNAME%\#PBS -e  ${RUN}${CONFS}_err%" \
207              jhd_${TARGET}_${RUN} > jhd_${TARGET}_${RUN}_tmp
208          fi ;;
209esac
210
211cat jhd_${TARGET}_${RUN}_tmp job_${CONF}.$$ > job_tmp_${RUN}.ksh
212rm -f job_${CONF}.$$ jhd_${TARGET}_${RUN}_tmp
213
214# -----------------------------------------------------------------------------
215# III. Launch jobs
216#      The 3 following jobs are created for the run [type]=mon,mpi,omp :
217#      - "job_[type]_long.ksh"      ---> long run
218#      - "job_[type]_1_short.ksh"   ---> stream 1 run
219#      - "job_[type]_2_short.ksh"   ---> stream 2 run
220#      - "job_[type]_gtime.ksh"     ---> one year run
221#      The first 2 as the last one are immediatly launched whereas "job_[type]_2_short.ksh"
222#      is launched only when the "job_[type]_1_short.ksh" short run is finished
223# -----------------------------------------------------------------------------
224jobnam[0]=long ; jobnam[1]=1_short ; jobnam[2]=2_short ; jobnam[3]=gtime
225dirjob[0]=LONG ; dirjob[1]=1_SHORT ; dirjob[2]=2_SHORT ; dirjob[3]=GTIME
226
227case ${JOBTOL} in
228     'all' )
229              if [ ${MTIME} = 'timing' ] ; then
230             ind=0
231        iloop=4
232         else
233             ind=0
234        iloop=3
235              fi 
236         ;;
237     'long' )
238              ind=0
239         iloop=1 ;;
240     'short' )
241              ind=1
242         iloop=3 ;;
243     'gtime' )
244              ind=3
245         iloop=4 ;;
246esac
247
248chwd () { 
249    word=$( grep "^ *${1}" job_tmp_${RUN}.ksh | cut -f 1 -d " " )
250    if [ "${word}" != "" ] 
251    then
252   sed -e "s@${word}@${1%=*}=\"${2}\"@" job_tmp_${RUN}.ksh > tmp$$
253   mv tmp$$ job_tmp_${RUN}.ksh
254    fi
255}
256
257while [ $ind -lt ${iloop} ]
258do
259
260       chwd "type="                "${jobnam[$ind]}"
261       chwd "RUN=xxx"              "${RUN}"
262       chwd "NB_PROCS=xxx"          ${PRC}
263       chwd "LAUNCH=xxx"           "${LAUN}"
264       chwd "LEXE=xxx"             "${LSUB}"
265       chwd "CPERF=xxx"            "${LPERF}"
266       chwd "D_INPUT=xxx"          "${IODIR}"
267       chwd "D_GET=xxx"            "${CMDGET}"
268       chwd "REF_TAG=xxx"          "${REFTAG}" 
269       chwd "MYO_EXP=xxx"          "${OWNEXP}"
270       chwd "TSYMB=xxx"            "${SYMBOL}"
271       chwd "USE_IOMPUT=xxx"        ${USE_IOMPUT}
272       chwd "USE_IOSERVER=xxx"      ${USE_IOSERVER}
273       chwd "NB_PROCS_IOSERVER=xxx" ${NB_PROCS_IOSERVER}
274
275       mv job_tmp_${RUN}.ksh job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh
276
277       if [ ${jobnam[$ind]} = 'gtime' ] ; then
278
279           case ${TARGET} in
280                'aix6' )
281                     CAR_JTIM=$( grep '\# @ wall_clock_limit' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
282                     sed    -e "s%$CAR_JTIM%\# @ wall_clock_limit = ${LJTIM}%" \
283                     job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
284                'sx8brodie' )
285                     CAR_JTIMP=$( grep '\#PBS -l cputim_prc' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
286                     CAR_JTIMJ=$( grep '\#PBS -l cputim_job' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
287                     sed    -e "s%$CAR_JTIMP%\#PBS -l cputim_prc=${LJTIM}%" \
288                     -e "s%$CAR_JTIMJ%\#PBS -l cputim_job=${LJTIMJ}%" \
289                     job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
290                'sx8mercure' )
291                     CAR_JTIMP=$( grep '\#PBS -l cputim_prc' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
292                     CAR_JTIMJ=$( grep '\#PBS -l cputim_job' job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh )
293                     sed    -e "s%$CAR_JTIMP%\#PBS -l cputim_prc=${LJTIM}%" \
294                     -e "s%$CAR_JTIMJ%\#PBS -l cputim_job=${LJTIMJ}%" \
295                     job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
296           esac
297           mv job_${RUN}_${jobnam[$ind]}.ksh_tmp job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh
298
299       fi
300
301       chmod 750 job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh
302
303       if [ ! -d ${dirjob[$ind]}/$OWNEXP ] ;  then
304           mkdir ${dirjob[$ind]}/$OWNEXP
305       fi
306       mv job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh ${dirjob[$ind]}/${OWNEXP}/.
307
308       if [ ${jobnam[$ind]} != '2_short' ] ; then
309           cd ${dirjob[$ind]}/${OWNEXP}
310           ${LAUN}job_${RUN}_${jobnam[$ind]}_${OWNEXP}.ksh &
311           cd ../..
312       fi
313
314       let ind=$ind+1
315done
316rm -f job_tmp_${RUN}.ksh
317
318# List all jobs submitted
319${LLJOBS}
320
321# -----------------------------------------------------------------------------
322# IV. Launch cron to be able to launch the assessment step
323# -----------------------------------------------------------------------------
324if [ ${RUN} == 'mon' ] ; then
325    cd ..
326   
327    CAR_LJOB_tmp=$( grep 'LJOBS=' cron_jobs.ksh )
328    CAR_LJOB=`echo $CAR_LJOB_tmp | cut -f 1 -d " " `
329   
330    sed    -e "s%$CAR_LJOB%LJOBS=${LLJOBS}%" cron_jobs.ksh > cron_jobs.$$
331    mv cron_jobs.$$ cron_jobs.ksh &&  rm -rf cron_jobs.$$
332    chmod 744 cron_jobs.ksh
333
334    if [ ${TARGET} != 'osxxlf' ]; then
335        ./cron_jobs.ksh ${CONF} ${CONFS} &
336    fi
337fi
Note: See TracBrowser for help on using the repository browser.