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 branches/dev_001_SBC/VALID/2INSTALL/JOBS – NEMO

source: branches/dev_001_SBC/VALID/2INSTALL/JOBS/lance_batch.ksh @ 815

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

dev_001_SBC: Merge of VALID/HEAD directories with the trunk -r 731:HEAD

  • Property svn:executable set to *
File size: 10.7 KB
Line 
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##########################################################
59IODIR=/Volumes/FENUA/ORCA2_LIM_nemo_v2_IO
60PRC=8
61TARGET=osxxlf
62##########################################################
63##### End   Users modifications
64##########################################################
65
66CONF=$1
67MTIME=$2
68JOBTOL=$3
69REFTAG=$4
70RUN=$(basename `pwd`)
71
72# Specific case of Zahir:
73if [ ${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# ---------------------------------------------------------------
79if   [ ${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_
89elif [ ${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_
99elif [ ${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_
109elif [ ${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_
119else
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
126fi
127
128sed -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# --------------------------------------------------------------
134case ${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 ;;
164esac
165
166cat jhd_${TARGET}_${RUN}_tmp job_${CONF}.$$ > job_tmp_${RUN}.ksh
167rm -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# -----------------------------------------------------------------------------
179jobnam[0]=long ; jobnam[1]=1_short ; jobnam[2]=2_short ; jobnam[3]=gtime
180dirjob[0]=LONG ; dirjob[1]=1_SHORT ; dirjob[2]=2_SHORT ; dirjob[3]=GTIME
181
182case ${JOBTOL} in
183     'all' )
184              if [ ${MTIME} = 'timing' ] ; then
185             ind=0 ; iloop=4 ;
186         else
187             ind=0 ; iloop=3 ;
188              fi ;;
189     'long' )
190              ind=0 ; iloop=1 ;;
191     'short' )
192              ind=1 ; iloop=3 ;;
193     'gtime' )
194              ind=3 ; iloop=4 ;;
195esac
196
197while [ $ind -lt ${iloop} ]
198do
199       CAR_TYPE_tmp=$( grep 'type=' job_tmp_${RUN}.ksh )
200       CAR_TYPE=`echo $CAR_TYPE_tmp | cut -f 1 -d " " `
201       CAR_RUN_tmp=$( grep 'RUN=xxx' job_tmp_${RUN}.ksh )
202       CAR_RUN=`echo $CAR_RUN_tmp | cut -f 1 -d " " `
203       CAR_MPP_tmp=$( grep 'NB_PROCS=xxx' job_tmp_${RUN}.ksh )
204       CAR_MPP=`echo $CAR_MPP_tmp | cut -f 1 -d " " `
205       CAR_SUB_tmp=$( grep 'LAUNCH=xxx' job_tmp_${RUN}.ksh )
206       CAR_SUB=`echo $CAR_SUB_tmp | cut -f 1 -d " " `
207       CAR_EXE_tmp=$( grep 'LEXE=xxx' job_tmp_${RUN}.ksh )
208       CAR_EXE=`echo $CAR_EXE_tmp | cut -f 1 -d " " `
209       CAR_PER_tmp=$( grep 'CPERF=xxx' job_tmp_${RUN}.ksh )
210       CAR_PER=`echo $CAR_PER_tmp | cut -f 1 -d " " `
211       CAR_MAN_tmp=$( grep 'MAINDIR=xxx' job_tmp_${RUN}.ksh )
212       CAR_MAN=`echo $CAR_MAN_tmp | cut -f 1 -d " " `
213       CAR_INP_tmp=$( grep 'D_INPUT=xxx' job_tmp_${RUN}.ksh )
214       CAR_INP=`echo $CAR_INP_tmp | cut -f 1 -d " " `
215       CAR_GET_tmp=$( grep 'D_GET=xxx' job_tmp_${RUN}.ksh )
216       CAR_GET=`echo $CAR_GET_tmp | cut -f 1 -d " " `
217       CAR_RTG_tmp=$( grep 'REF_TAG=xxx' job_tmp_${RUN}.ksh )
218       CAR_RTG=`echo $CAR_RTG_tmp | cut -f 1 -d " " `
219       CAR_TSY_tmp=$( grep 'TSYMB=xxx' job_tmp_${RUN}.ksh )
220       CAR_TSY=`echo $CAR_TSY_tmp | cut -f 1 -d " " `
221
222       sed    -e "s/$CAR_TYPE/type=${jobnam[$ind]}/" \
223       -e "s/$CAR_RUN/RUN=$RUN/" \
224       -e "s/$CAR_MPP/NB_PROCS=$PRC/" \
225       -e "s@$CAR_SUB@LAUNCH='$LAUN'@" \
226       -e "s/$CAR_EXE/LEXE='$LSUB'/" \
227       -e "s/$CAR_PER/CPERF='$LPERF'/" \
228       -e "s?$CAR_INP?D_INPUT=$IODIR?" \
229       -e "s/$CAR_GET/D_GET=$CMDGET/" \
230       -e "s/$CAR_RTG/REF_TAG=$REFTAG/" \
231       -e "s/$CAR_TSY/TSYMB=$SYMBOL/" \
232       job_tmp_${RUN}.ksh > job_${RUN}_${jobnam[$ind]}.ksh
233
234       if [ ${jobnam[$ind]} = 'gtime' ] ; then
235
236           case ${TARGET} in
237                'ax_mono' | 'aix' )
238                     CAR_JTIM=$( grep '\# @ cpu_limit' job_${RUN}_${jobnam[$ind]}.ksh )
239                     sed    -e "s/$CAR_JTIM/\# @ cpu_limit = ${LJTIM}/" \
240                     job_${RUN}_${jobnam[$ind]}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
241                'sx8brodie' )
242                     CAR_JTIMP=$( grep '\#PBS -l cputim_prc' job_${RUN}_${jobnam[$ind]}.ksh )
243                     CAR_JTIMJ=$( grep '\#PBS -l cputim_job' job_${RUN}_${jobnam[$ind]}.ksh )
244                     sed    -e "s/$CAR_JTIMP/\#PBS -l cputim_prc=${LJTIM}/" \
245                     -e "s/$CAR_JTIMJ/\#PBS -l cputim_job=${LJTIMJ}/" \
246                     job_${RUN}_${jobnam[$ind]}.ksh > job_${RUN}_${jobnam[$ind]}.ksh_tmp  ;;
247           esac
248           mv job_${RUN}_${jobnam[$ind]}.ksh_tmp job_${RUN}_${jobnam[$ind]}.ksh
249
250       fi
251
252       chmod 750 job_${RUN}_${jobnam[$ind]}.ksh
253       mv job_${RUN}_${jobnam[$ind]}.ksh ${dirjob[$ind]}/.
254
255       if [ ${jobnam[$ind]} != '2_short' ] ; then
256           cd ${dirjob[$ind]}
257           ${LAUN}job_${RUN}_${jobnam[$ind]}.ksh &
258           cd ../
259       fi
260
261       let ind=$ind+1
262done
263rm -f job_tmp_${RUN}.ksh
264
265# List all jobs submitted
266${LLJOBS}
267
268# -----------------------------------------------------------------------------
269# IV. Launch cron to be able to launch the assessment step
270# -----------------------------------------------------------------------------
271if [ ${RUN} == 'mon' ] ; then
272    cd ..
273   
274    CAR_LJOB_tmp=$( grep 'LJOBS=' cron_jobs.ksh )
275    CAR_LJOB=`echo $CAR_LJOB_tmp | cut -f 1 -d " " `
276   
277    sed    -e "s/$CAR_LJOB/LJOBS=${LLJOBS}/" cron_jobs.ksh > cron_jobs.$$
278    mv cron_jobs.$$ cron_jobs.ksh &&  rm -rf cron_jobs.$$
279    chmod 744 cron_jobs.ksh
280
281    if [ ${TARGET} != 'osxxlf' ]; then
282        ./cron_jobs.ksh ${CONF} &
283    fi
284fi
Note: See TracBrowser for help on using the repository browser.