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

source: trunk/VALID/2INSTALL/JOBS/lance_batch.ksh @ 753

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

add quotes to the sed sequences for the LAUN variable, see ticket:#33

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