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/2012/dev_NOC_MERCATOR_2012/NEMOGCM/SETTE – NEMO

source: branches/2012/dev_NOC_MERCATOR_2012/NEMOGCM/SETTE/prepare_job.sh @ 3651

Last change on this file since 3651 was 3651, checked in by cbricaud, 11 years ago

merge dev_MERCATOR_2012_rev3555 into dev_NOC_MERCATOR_2012 ; see ticket 1020

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