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.
prepare_job.sh in branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/BENCHMARK – NEMO

source: branches/2016/dev_HPC_Gyre_benchmark_test/NEMOGCM/BENCHMARK/prepare_job.sh @ 7795

Last change on this file since 7795 was 7230, checked in by timgraham, 8 years ago

Added modifications to instrument code and use perf_regions in GYRE_BENCHMARK

  • Property svn:executable set to *
File size: 11.8 KB
Line 
1#####################################################
2# Author : Simona Flavoni for NEMO
3# Contact : sflod@locean-ipsl.upmc.fr
4#
5# ----------------------------------------------------------------------
6# NEMO/SETTE , NEMO Consortium (2010)
7# Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
8# ----------------------------------------------------------------------
9#
10# Some scripts called by sette.sh
11# prepare_job.sh   : creates the job script for running job
12######################################################
13#set -vx
14set -o posix
15#set -u
16#set -e
17#+
18#
19# ================
20# prepare_job.sh
21# ================
22#
23# -------------------------------------------------
24# script that creates the job script for NEMO tests
25# -------------------------------------------------
26#
27# SYNOPSIS
28# ========
29#
30# ::
31#
32#  $ ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_FLAG JOB_FILE
33#
34#
35# DESCRIPTION
36# ===========
37#
38# Part of the SETTE package to run tests for NEMO
39#
40# prepare the script $JOB_FILE to run the tests
41#
42# EXAMPLES
43# ========
44#
45# ::
46#
47#  $ ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_FLAG $JOB_FILE
48#
49# prepare the $JOB_FILE for execution
50#
51#
52# TODO
53# ====
54#
55# option debug
56#
57#
58# EVOLUTIONS
59# ==========
60#
61# $Id: prepare_job.sh 3050 2011-11-07 14:11:34Z acc $
62#
63#
64#
65#   * creation
66#
67#-
68#
69
70usage=" Usage : ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_FLAG JOB_FILE NUM_XIO_SERVERS"
71usage=" example : ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg 8 SHORT no/yes $JOB_FILE 0"
72
73
74minargcount=6
75        if [ ${#} -lt ${minargcount} ]
76        then
77                echo "not enough arguments for prepare_job.sh script"
78                echo "control number of argument of prepare_job.sh in sette.sh"
79                echo "${usage}"
80        exit 1
81        fi
82        unset minargcount
83   if [ ! -f ${SETTE_DIR}/output.sette ] ; then
84           touch ${SETTE_DIR}/output.sette
85   fi
86       
87#
88# set and export TEST_NAME. It will be used within the post_test_tidyup function
89#
90INPUTARFILE=$1
91NB_PROC=$2
92TEST_NAME=$3
93MPI_FLAG=$4
94JOB_FILE=$5
95NXIO_PROC=$6
96
97# export EXE_DIR. This directory is used to execute model
98#
99#
100#
101echo "date: `date`" >> ${SETTE_DIR}/output.sette
102echo "" >> ${SETTE_DIR}/output.sette
103echo "running config: ${NEW_CONF}" >> ${SETTE_DIR}/output.sette
104echo "" >> ${SETTE_DIR}/output.sette
105echo "list of cpp_keys: " >> ${SETTE_DIR}/output.sette
106echo "`more ${SETTE_DIR}/../CONFIG/${NEW_CONF}/cpp_${NEW_CONF}.fcm`" >> ${SETTE_DIR}/output.sette
107echo "" >> ${SETTE_DIR}/output.sette
108echo "compiling with: ${CMP_NAM}" >> ${SETTE_DIR}/output.sette
109echo "" >> ${SETTE_DIR}/output.sette
110echo "executing script : \"fcm_job $@\" " >> ${SETTE_DIR}/output.sette
111echo "            " >> ${SETTE_DIR}/output.sette
112
113
114################################################################
115# RUN OPA
116cd ${EXE_DIR}
117if [ ! -r ${EXE_DIR}/opa ]
118    then
119    echo "executable opa does not exist"
120    echo "executable opa does not exist, exit"  >> ${SETTE_DIR}/output.sette
121    exit 1
122fi
123
124# example for NOCS ClusterVision system using SLURM batch submission (requires ${SETTE_DIR}/sette_batch_template file)
125#
126  #  if [ ${MPI_FLAG} == "no" ] ; then
127      case ${COMPILER} in
128         X64_MOBILIS)
129                                NB_REM=$( echo $NB_PROC $NXIO_PROC | awk '{print ( $1 + $2 ) % 16}')
130               if [ ${NB_REM} == 0 ] ; then
131               # number of processes required is an integer multiple of 16
132               #
133               NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{print ($1 + $2 ) / 16}')
134            else
135               #
136               # number of processes required is not an integer multiple of 16
137               # round up the number of nodes required.
138               #
139               NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{printf("%d",($1 + $2 ) / 16 + 1 )}')
140                  fi
141            ;;
142                        XC_ARCHER_INTEL)
143                                # ocean cores are packed 24 to a node
144                                NB_REM=$( echo $NB_PROC | awk '{print ( $1 % 24 ) }')
145                                if [ ${NB_REM} == 0 ] ; then
146                                        # number of processes required is an integer multiple of 24
147                                        #
148                                        NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{print ($1) / 24}')
149                                else
150                                        #
151                                        # number of processes required is not an integer multiple of 24
152                                        # round up the number of nodes required.
153                                        #
154                                        NB_NODES=$( echo $NB_PROC | awk '{printf("%d",($1) / 24 + 1 )}')
155                                fi
156                                # xios cores are sparsely packed at 4 to a node
157                                # but can not share nodes with the ocean cores
158                                NB_REM=$( echo $NXIO_PROC | awk '{print ( $2 % 4 ) }')
159                                if [ ${NB_REM} == 0 ] ; then
160                                        # number of processes required is an integer multiple of 4                           
161                                        #
162                                        NB_NODES=$( echo $NB_NODES $NXIO_PROC | awk '{print ($1 + ( $2 / 4 ))}')                   
163                                else
164                                        #
165                                        # number of processes required is not an integer multiple of 4                             
166                                        # round up the number of nodes required.
167                                        #
168                                        NB_NODES=$( echo $NB_NODES $NXIO_PROC | awk '{print ($1 + ( $2 / 4 ) + 1)}') 
169                                fi
170                                ;;
171                        XC40_METO*) #Setup for Met Office XC40 with any compiler
172                                # ocean cores are packed 32 to a node
173                                # If we need more than one node then have to use parallel queue and XIOS must have a node to itself
174                                NB_REM=$( echo $NB_PROC | awk '{print ( $1 % 32 ) }')
175                                if [ ${NB_REM} == 0 ] ; then
176                                        # number of processes required is an integer multiple of 32
177                                        #
178                                        NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{print ($1) / 32}')
179                                else
180                                        #
181                                        # number of processes required is not an integer multiple of 32
182                                        # round up the number of nodes required.
183                                        #
184                                        NB_NODES=$( echo $NB_PROC $NXIO_PROC | awk '{printf("%d",($1) / 32 + 1 )}')
185                                fi
186                                # xios cores are sparsely packed at 4 to a node
187                                if [ $NXIO_PROC == 0 ] ; then
188                                    NB_XNODES=0
189                                else
190                                    NB_REM=$( echo $NXIO_PROC | awk '{print ( $1 % 4 ) }')
191                                    if [ ${NB_REM} == 0 ] ; then
192                                            # number of processes required is an integer multiple of 4                           
193                                            #
194                                            NB_XNODES=$( echo $NXIO_PROC | awk '{print (( $1 / 4 ) + 1)}') 
195                                    else
196                                            #
197                                            # number of processes required is not an integer multiple of 4                             
198                                            # round up the number of nodes required.
199                                            #
200                                            NB_XNODES=$( echo $NXIO_PROC | awk '{printf("%d",($1) / 4 + 1) }')                   
201                                    fi
202                                fi
203                                if [ ${NB_XNODES} -ge 1 ] ; then
204                                   NB_NODES=$((NB_NODES+NB_XNODES))
205                                fi
206                                echo NB_XNODES=${NB_XNODES} 
207                                echo Total NB_NODES=${NB_NODES}
208                                QUEUE=normal
209                                SELECT="select=$NB_NODES"
210                                module unload cray-snplauncher #Make sure snplauncher module is not loaded
211                                ;;
212                        openmpi_NAVITI_MERCATOR)
213                                echo NB_PROCS ${NB_PROC}
214                                echo NB_NODES ${NB_NODES}
215                                echo  NB_PROC ${NB_PROC}
216                                if [ ${NB_PROC} -eq 1 ] ; then
217                                   NB_NODES=1
218                                   QUEUE=monoproc
219                                   NB_PROC_NODE=${NB_PROC}
220                                else
221                                   if [ ${NB_PROC} -le 16 ] ; then
222                                      NB_NODES=1
223                                      QUEUE=mono
224                                      NB_PROC_NODE=${NB_PROC}
225                                   else
226                                      NB_NODES=$( echo $NB_PROC | awk '{print $1 - $1 % 16}'  | awk '{print $1 / 16 }')
227                                      QUEUE=multi
228                                      NB_PROC_NODE=16
229                                  fi
230                                fi
231                                echo NB_PROCS     ${NB_PROC}
232                                echo NB_NODES     ${NB_NODES}
233                                echo NB_PROC_NODE ${NB_PROC_NODE}
234                                ;;
235         *)
236            NB_NODES=${NB_PROC}
237            ;;
238
239      esac
240#
241# Pass settings into job file by using sed to edit predefined strings
242#
243        TOTAL_NPROCS=$(( $NB_PROC + $NXIO_PROC ))
244        cat ${SETTE_DIR}/job_batch_template | sed -e"s/NODES/${NB_NODES}/" \
245             -e"s/TOTAL_NPROCS/${TOTAL_NPROCS}/" \
246             -e"s/NPROCS/${NB_PROC}/" \
247             -e"s/NXIOPROCS/${NXIO_PROC}/" \
248             -e"s:DEF_SETTE_DIR:${SETTE_DIR}:" -e"s:DEF_INPUT_DIR:${INPUT_DIR}:" \
249             -e"s:DEF_EXE_DIR:${EXE_DIR}:" \
250             -e"s:DEF_CONFIG_DIR:${CONFIG_DIR}:" \
251             -e"s:MPI_FLAG:${MPI_FLAG}:" \
252             -e"s:DEF_NEMO_VALIDATION:${NEMO_VALIDATION_DIR}:" -e"s:DEF_NEW_CONF:${NEW_CONF}:" \
253             -e"s:DEF_CMP_NAM:${CMP_NAM}:" -e"s:DEF_TEST_NAME:${TEST_NAME}:" \
254             -e"s:DEF_LD_LIB:${PERF_REGIONS_HOME}/build/:" -e"s:DEF_COUNTERS:${LIST_COUNTERS}:" \
255             -e"s:DEF_CORES_PER_NODE:$CORES_PER_NODE:" > run_sette_test.job
256
257        case ${COMPILER} in
258              openmpi_NAVITI_MERCATOR)
259                    cat run_sette_test.job | sed -e"s/NPROC_NODE/${NB_PROC_NODE}/" \
260                                                 -e"s:QUEUE:${QUEUE}:" > run_sette_test1.job
261                    mv run_sette_test1.job run_sette_test.job
262                    ;;
263              XC40_METO*)
264                    cat run_sette_test.job | sed -e"s/SELECT/${SELECT}/" > run_sette_test1.job
265                    mv run_sette_test1.job run_sette_test.job
266                    ;;
267   esac
268#
269# create the unique submission job script
270#
271   if [ ! -f $JOB_FILE ] ; then
272      mv run_sette_test.job $JOB_FILE
273   else
274       e=`grep -n "# END_BODY" ${JOB_FILE} | cut -d : -f 1`
275            e=$(($e - 1))
276       head -$e $JOB_FILE > ${JOB_FILE}_new
277       mv ${JOB_FILE}_new ${JOB_FILE}
278       l=`wc -l run_sette_test.job | sed -e "s:run_sette_test.job::"`
279       b=`grep -n "# BODY" run_sette_test.job | cut -d : -f 1`
280       t=$(($l - $b))
281       tail -$t run_sette_test.job >> $JOB_FILE
282   fi
283   
284   chmod a+x $JOB_FILE ; echo "$JOB_FILE is ready"
285
286#fi
Note: See TracBrowser for help on using the repository browser.