source: branches/2012/dev_r3327_MERCATOR1_BDY/NEMOGCM/SETTE/prepare_job.sh @ 3492

Last change on this file since 3492 was 3492, checked in by cbricaud, 9 years ago

add modifications in SETTE

  • Property svn:executable set to *
File size: 8.8 KB
Line 
1#####################################################
2# Author : Italo Epicoco for NEMO
3# Contact : italo.epicoco@unisalento.it
4#
5# Some scripts called by sette.sh
6# prepare_job.sh   : create the job script for running job
7######################################################
8#set -x
9set -o posix
10#set -u
11#set -e
12#
13#
14# ================
15# prepare_job.sh
16# ================
17#
18# --------------------------
19# create the job script for NEMO tests
20# --------------------------
21#
22# SYNOPSIS
23# ========
24#
25# ::
26#
27#  $ ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_INTERACT MPI_FLAG
28#
29#
30# DESCRIPTION
31# ===========
32#
33# Simple job for SET TESTS for NEMO (SETTE)
34#
35#   get input files (if needed) : tar file 
36#  (note this job needs to have an input_CONFIG.cfg in which can be found input tar file name)
37#
38#   runs job in interactive or batch mode : all jobs using 1 process are run interactive, and all MPP jobs are
39#
40#   run in batch (MPI_INTERACT="no") or interactive (MPI_INTERACT="yes") see sette.sh and BATCH_TEMPLATE directory
41#
42#   and call post_test_tidyup function (that moves in NEMO_VALIDATION_DIR solver.stat, tracer.stat (for LOBSTER & PISCES) & ocean.output)
43#
44# EXAMPLES
45# ========
46#
47# ::
48#
49#  $ ./fcm_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_INTERACT MPI_FLAG
50#
51#  run a job of config GYRE with 1 processor SHORT test ( 5 days ) using an interactive run without mpirun
52#  $ ./fcm_job.sh input_GYRE.cfg 1 SHORT yes no
53#
54#  run a job of config ORCA2_LIM_PISCES   with 8 processors test RESTARTABILITY submitting the job to the batch queue system and using mpirun
55#  $ ./fcm_job.sh input_ORCA2_LIM_PISCES.cfg 8 LONG no yes
56#
57#
58# TODO
59# ====
60#
61# option debug
62#
63#
64# EVOLUTIONS
65# ==========
66#
67# $Id: fcm_job.sh 3050 2011-11-07 14:11:34Z acc $
68#
69#
70#
71#   * creation
72#
73#-
74#
75
76usage=" Usage : ./fcm_job.sh input_CONFIG_NAME.cfg  NUMBER_OF_PROCS TEST_NAME INTERACT MPI_FLAG"
77usage=" example : ./fcm_job.sh input_ORCA2_LIM_PISCES.cfg 8 SHORT no/yes no/yes"
78
79
80minargcount=5
81        if [ ${#} -lt ${minargcount} ]
82        then
83                echo "not enought arguments for fcm_job.sh script"
84                echo "control number of argument of fcm_job.sh in sette.sh"
85                echo "${usage}"
86        exit 1
87        fi
88        unset minargcount
89   if [ ! -f ${SETTE_DIR}/output.sette ] ; then
90           touch ${SETTE_DIR}/output.sette
91   fi
92       
93#
94# set and export TEST_NAME. It will be used within the post_test_tidyup function
95#
96INPUTARFILE=$1
97NB_PROC=$2
98TEST_NAME=$3
99MPI_FLAG=$4
100JOB_FILE=$5
101
102# export EXE_DIR. This directory is used to execute model
103#
104export EXE_DIR
105#
106#
107echo "date: `date`" >> ${SETTE_DIR}/output.sette
108echo "" >> ${SETTE_DIR}/output.sette
109echo "running config: ${NEW_CONF}" >> ${SETTE_DIR}/output.sette
110echo "" >> ${SETTE_DIR}/output.sette
111echo "list of cpp_keys: " >> ${SETTE_DIR}/output.sette
112echo "`more ${SETTE_DIR}/../CONFIG/${NEW_CONF}/cpp_${NEW_CONF}.fcm`" >> ${SETTE_DIR}/output.sette
113echo "" >> ${SETTE_DIR}/output.sette
114echo "compiling with: ${CMP_NAM}" >> ${SETTE_DIR}/output.sette
115echo "" >> ${SETTE_DIR}/output.sette
116echo "executing script : \"fcm_job $@\" " >> ${SETTE_DIR}/output.sette
117echo "            " >> ${SETTE_DIR}/output.sette
118
119################################################################
120# SET INPUT
121# get the input tarfile if needed
122tar_file=$(sed -ne "1,1p" ${SETTE_DIR}/$INPUTARFILE)
123if [ "$(cat ${SETTE_DIR}/$INPUTARFILE | grep -c ".tar" )" -ne 0 ] ; then
124   echo "looking for tar file" >> ${SETTE_DIR}/output.sette
125   echo "            " >> ${SETTE_DIR}/output.sette
126   cp ${FORCING_DIR}/${tar_file} ${INPUT_DIR}/.
127   echo "file in ${INPUT_DIR}"
128   if [ ! -f ${INPUT_DIR}/${tar_file} ] ; then
129      echo "PROBLEM during copy of tar file" >> ${SETTE_DIR}/output.sette
130      echo "tar file IS NOT present in ${INPUT_DIR} directory " >> ${SETTE_DIR}/output.sette
131      echo "            " >> ${SETTE_DIR}/output.sette
132      echo "PROBLEM during copy of tar file" 
133      exit 1
134   else 
135      cd ${EXE_DIR} ; tar xvof ${INPUT_DIR}/*.tar ; gunzip -f *gz
136   fi
137fi
138
139if [ ! -f ${EXE_DIR}/namelist_ice ] ; then
140if [ -f ${EXE_DIR}/namelist_ice_lim2 ] ; then
141   echo "choosing for namelist ice " >> ${SETTE_DIR}/output.sette
142   echo "            " >> ${SETTE_DIR}/output.sette
143   cp ${EXE_DIR}/namelist_ice_lim2 ${EXE_DIR}/namelist_ice
144elif  [ -f ${EXE_DIR}/namelist_ice_lim3 ] ; then
145   cp ${EXE_DIR}/namelist_ice_lim3 ${EXE_DIR}/namelist_ice
146fi
147fi
148
149
150if [ "$(cat ${CONFIG_DIR}/${NEW_CONF}/cpp_${NEW_CONF}.fcm | grep -c "agrif" )" -ne 0 ] ; then
151   #- Namelist for ocean and ice (agrif fine grid)
152      echo "choosing for namelist for AGRIF" >> ${SETTE_DIR}/output.sette
153      echo "            " >> ${SETTE_DIR}/output.sette
154   cp ${EXE_DIR}/1_namelist_ice_lim2 ${EXE_DIR}/1_namelist_ice
155fi
156################################################################
157
158################################################################
159# RUN OPA
160cd ${EXE_DIR}
161if [ ! -r ${EXE_DIR}/opa ]
162    then
163    echo "executable opa does not exist"
164    echo "executable opa does not exist, exit"  >> ${SETTE_DIR}/output.sette
165    exit 1
166fi
167#if [ ${NB_PROC} == 1 ] ; then
168#    echo "running opa" >> ${SETTE_DIR}/output.sette
169#    echo "            " >> ${SETTE_DIR}/output.sette
170#    ./opa
171#
172# Tidy out output from this test and populate the NEMO_VALIDATION_DIR tree
173#
174#    post_test_tidyup
175#else
176#    echo "running opa in MPI" >> ${SETTE_DIR}/output.sette
177#    echo "            " >> ${SETTE_DIR}/output.sette
178
179#    if [ ${MPI_INTERACT} == "yes" ] ; then
180#  #
181#  # example for brodie (NEC SX8) machine
182#  #  mpirun -np ${NB_PROC} opa
183#  # example for dedale machine
184#  #  mpirun --mca btl self,tcp -np ${NB_PROC} opa
185#  # example for vargas (IBM Power6) machine
186#  mpiexec -n ${NB_PROC} opa
187#  #
188#  post_test_tidyup
189#    fi
190#
191# example for NOCS Altix system using PBS batch submission (requires ${SETTE_DIR}/sette_batch_template file)
192#
193  #  if [ ${MPI_INTERACT} == "no" ] ; then
194      case ${COMPILER} in
195         ALTIX_NAUTILUS_MPT)
196                                NB_REM=$( echo $NB_PROC | awk '{print $1 % 4}')
197               if [ ${NB_REM} == 0 ] ; then
198               # number of processes required is an integer multiple of 4
199               #
200               NB_NODES=$( echo $NB_PROC | awk '{print $1  $1 / 4}')
201            else
202               #
203               # number of processes required is not an integer multiple of 4
204               # round up the number of nodes required.
205               #
206               NB_NODES=$( echo $NB_PROC | awk '{printf("%d",$1 / 4 + 1 )}')
207                  fi
208            ;;
209                        ifort_MERCATOR_CLUSTER)
210                                echo NB_PROCS ${NB_PROC}
211                                echo NB_NODES ${NB_NODES}
212                                echo  NB_PROC ${NB_PROC} 
213                                if [ ${NB_PROC} -eq 1 ] ; then
214                                   NB_NODES=1
215                                   QUEUE=monoproc
216                                   NB_PROC_NODE=${NB_PROC} 
217                                else
218                                   if [ ${NB_PROC} -le 8 ] ; then
219                                      NB_NODES=1
220                                      QUEUE=mono
221                                      NB_PROC_NODE=${NB_PROC} 
222                                   else
223                                      NB_NODES=$( echo $NB_PROC | awk '{print $1 - $1 % 8}'  | awk '{print $1 / 8 }')
224                                      QUEUE=multi
225                                      NB_PROC_NODE=8
226                                  fi   
227                                fi   
228                                echo NB_PROCS     ${NB_PROC}
229                                echo NB_NODES     ${NB_NODES}
230                                echo NB_PROC_NODE ${NB_PROC_NODE} 
231            ;;
232         *)
233            NB_NODES=${NB_PROC}
234            ;;
235
236      esac
237#
238# Pass settings into job file by using sed to edit predefined strings
239#
240         ((mem=5*NB_PROC))
241         echo NB_NODES NB_PROC QUEUE ${NB_NODES} ${NB_PROC} ${QUEUE}
242        cat ${SETTE_DIR}/job_batch_template | sed -e"s/NODES/${NB_NODES}/" -e"s/NPROCSNODE/${NB_PROC_NODE}/" \
243             -e"s/NPROCS/${NB_PROC}/" \
244             -e"s/QUEUE/${QUEUE}/" -e"s/MEM/${mem}/" \
245             -e"s:DEF_SETTE_DIR:${SETTE_DIR}:" -e"s:DEF_INPUT_DIR:${INPUT_DIR}:" \
246             -e"s:DEF_EXE_DIR:${EXE_DIR}:" \
247             -e"s:DEF_CONFIG_DIR:${CONFIG_DIR}:" \
248             -e"s:MPI_FLAG:${MPI_FLAG}:" \
249             -e"s:DEF_NEMO_VALIDATION:${NEMO_VALIDATION_DIR}:" -e"s:DEF_NEW_CONF:${NEW_CONF}:" \
250             -e"s:DEF_CMP_NAM:${CMP_NAM}:" -e"s:DEF_TEST_NAME:${TEST_NAME}:" > run_sette_test.job
251   
252#
253# create the unique submission job script
254#
255   if [ ! -f $JOB_FILE ] ; then
256      mv run_sette_test.job $JOB_FILE
257   else
258       e=`grep -n "# END_BODY" ${JOB_FILE} | cut -d : -f 1`
259            e=$(($e - 1))
260       head -$e $JOB_FILE > ${JOB_FILE}_new
261       mv ${JOB_FILE}_new ${JOB_FILE}
262       l=`wc -l run_sette_test.job | sed -e "s:run_sette_test.job::"`
263       b=`grep -n "# BODY" run_sette_test.job | cut -d : -f 1`
264       t=$(($l - $b))
265       tail -$t run_sette_test.job >> $JOB_FILE
266   fi
267   
268   chmod a+x $JOB_FILE
269
270#fi
Note: See TracBrowser for help on using the repository browser.