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 @ 1155

Last change on this file since 1155 was 1155, checked in by ctlod, 16 years ago

add svn Id

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