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

source: branches/2012/dev_r3438_LOCEAN15_PISLOB/NEMOGCM/SETTE/prepare_job.sh @ 3535

Last change on this file since 3535 was 3535, checked in by flavoni, 11 years ago

update sette.sh, see ticket: #941

  • Property svn:executable set to *
File size: 6.8 KB
Line 
1#####################################################
2# Author : Simona Flavoni for NEMO
3# Contact : sflod@locean-ipsl.upmc.fr
4#
5# Some scripts called by sette.sh
6# prepare_job.sh   : create the job script for running job
7######################################################
8#set -vx
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_FLAG JOB_FILE
28#
29#
30# DESCRIPTION
31# ===========
32#
33# Part of the SETTE package to run tests for NEMO
34#
35# prepare the script $JOB_FILE to run the tests
36#
37# EXAMPLES
38# ========
39#
40# ::
41#
42#  $ ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_FLAG $JOB_FILE
43#
44# prepare the $JOB_FILE for execution
45#
46#
47# TODO
48# ====
49#
50# option debug
51#
52#
53# EVOLUTIONS
54# ==========
55#
56# $Id: prepare_job.sh 3050 2011-11-07 14:11:34Z acc $
57#
58#
59#
60#   * creation
61#
62#-
63#
64
65usage=" Usage : ./prepare_job.sh INPUT_FILE_CONFIG_NAME NUMBER_PROC TEST_NAME MPI_FLAG JOB_FILE"
66usage=" example : ./prepare_job.sh input_ORCA2_LIM_PISCES.cfg 8 SHORT no/yes $JOB_FILE"
67
68
69minargcount=5
70        if [ ${#} -lt ${minargcount} ]
71        then
72                echo "not enough arguments for prepare_job.sh script"
73                echo "control number of argument of prepare_job.sh in sette.sh"
74                echo "${usage}"
75        exit 1
76        fi
77        unset minargcount
78   if [ ! -f ${SETTE_DIR}/output.sette ] ; then
79           touch ${SETTE_DIR}/output.sette
80   fi
81       
82#
83# set and export TEST_NAME. It will be used within the post_test_tidyup function
84#
85INPUTARFILE=$1
86NB_PROC=$2
87TEST_NAME=$3
88MPI_FLAG=$4
89JOB_FILE=$5
90
91# export EXE_DIR. This directory is used to execute model
92#
93export EXE_DIR
94#
95#
96echo "date: `date`" >> ${SETTE_DIR}/output.sette
97echo "" >> ${SETTE_DIR}/output.sette
98echo "running config: ${NEW_CONF}" >> ${SETTE_DIR}/output.sette
99echo "" >> ${SETTE_DIR}/output.sette
100echo "list of cpp_keys: " >> ${SETTE_DIR}/output.sette
101echo "`more ${SETTE_DIR}/../CONFIG/${NEW_CONF}/cpp_${NEW_CONF}.fcm`" >> ${SETTE_DIR}/output.sette
102echo "" >> ${SETTE_DIR}/output.sette
103echo "compiling with: ${CMP_NAM}" >> ${SETTE_DIR}/output.sette
104echo "" >> ${SETTE_DIR}/output.sette
105echo "executing script : \"fcm_job $@\" " >> ${SETTE_DIR}/output.sette
106echo "            " >> ${SETTE_DIR}/output.sette
107
108################################################################
109# SET INPUT
110# get the input tarfile if needed
111tar_file=$(sed -ne "1,1p" ${SETTE_DIR}/$INPUTARFILE)
112if [ "$(cat ${SETTE_DIR}/$INPUTARFILE | grep -c ".tar" )" -ne 0 ] ; then
113   echo "looking for tar file" >> ${SETTE_DIR}/output.sette
114   echo "            " >> ${SETTE_DIR}/output.sette
115   cp ${FORCING_DIR}/${tar_file} ${INPUT_DIR}/.
116   echo "file in ${INPUT_DIR}"
117   if [ ! -f ${INPUT_DIR}/${tar_file} ] ; then
118      echo "PROBLEM during copy of tar file" >> ${SETTE_DIR}/output.sette
119      echo "tar file IS NOT present in ${INPUT_DIR} directory " >> ${SETTE_DIR}/output.sette
120      echo "            " >> ${SETTE_DIR}/output.sette
121      echo "PROBLEM during copy of tar file" 
122      exit 1
123   else 
124      cd ${EXE_DIR} ; tar xvof ${INPUT_DIR}/*.tar ; gunzip -f *gz
125   fi
126fi
127
128if [ ! -f ${EXE_DIR}/namelist_ice ] ; then
129if [ -f ${EXE_DIR}/namelist_ice_lim2 ] ; then
130   echo "choosing for namelist ice " >> ${SETTE_DIR}/output.sette
131   echo "            " >> ${SETTE_DIR}/output.sette
132   cp ${EXE_DIR}/namelist_ice_lim2 ${EXE_DIR}/namelist_ice
133elif  [ -f ${EXE_DIR}/namelist_ice_lim3 ] ; then
134   cp ${EXE_DIR}/namelist_ice_lim3 ${EXE_DIR}/namelist_ice
135fi
136fi
137
138
139if [ "$(cat ${CONFIG_DIR}/${NEW_CONF}/cpp_${NEW_CONF}.fcm | grep -c "agrif" )" -ne 0 ] ; then
140   #- Namelist for ocean and ice (agrif fine grid)
141      echo "choosing for namelist for AGRIF" >> ${SETTE_DIR}/output.sette
142      echo "            " >> ${SETTE_DIR}/output.sette
143   cp ${EXE_DIR}/1_namelist_ice_lim2 ${EXE_DIR}/1_namelist_ice
144fi
145################################################################
146
147##########################################################################
148# COPY RESTART FILES (if needed; i.e. only for SHORT job in RESTART TESTS)
149# get the input tarfile if needed
150# SF : not ok for the moment because at this point is needed cn_exp variable,
151# SF : here it it not known.
152#\cd ${EXE_DIR}
153#if [ "$(echo ${TEST_NAME} | grep -c "SHORT" )" -ne 0 ] ; then
154#    for (( i=1; i<=${NB_PROC}; ${NB_PROC}++)) ; do
155#        L_NPROC=`printf "%04d\n" $i`
156#        ln -sf ../LONG/${NEW_CONF}_00000060_restart_${L_NPROC-1}.nc .
157#    done
158#fi
159## SF : other way
160##      for file in ../LONG/${NEW_CONF}_*restart_0*.nc ; do
161##              ncpu=`echo $file | awk -F '_' '{print $NF}' | cut -f 1 -d '.'`
162##              ln -sf ${file}  .
163##      done
164##fi
165##########################################################################
166
167################################################################
168# RUN OPA
169cd ${EXE_DIR}
170if [ ! -r ${EXE_DIR}/opa ]
171    then
172    echo "executable opa does not exist"
173    echo "executable opa does not exist, exit"  >> ${SETTE_DIR}/output.sette
174    exit 1
175fi
176
177# example for NOCS Altix system using PBS batch submission (requires ${SETTE_DIR}/sette_batch_template file)
178#
179  #  if [ ${MPI_FLAG} == "no" ] ; then
180      case ${COMPILER} in
181         ALTIX_NAUTILUS_MPT)
182                                NB_REM=$( echo $NB_PROC | awk '{print $1 % 4}')
183               if [ ${NB_REM} == 0 ] ; then
184               # number of processes required is an integer multiple of 4
185               #
186               NB_NODES=$( echo $NB_PROC | awk '{print $1 / 4}')
187            else
188               #
189               # number of processes required is not an integer multiple of 4
190               # round up the number of nodes required.
191               #
192               NB_NODES=$( echo $NB_PROC | awk '{printf("%d",$1 / 4 + 1 )}')
193                  fi
194            ;;
195         *)
196            NB_NODES=${NB_PROC}
197            ;;
198
199      esac
200#
201# Pass settings into job file by using sed to edit predefined strings
202#
203        cat ${SETTE_DIR}/job_batch_template | sed -e"s/NODES/${NB_NODES}/" -e"s/NPROCS/${NB_PROC}/" \
204             -e"s:DEF_SETTE_DIR:${SETTE_DIR}:" -e"s:DEF_INPUT_DIR:${INPUT_DIR}:" \
205             -e"s:DEF_EXE_DIR:${EXE_DIR}:" \
206             -e"s:DEF_CONFIG_DIR:${CONFIG_DIR}:" \
207             -e"s:MPI_FLAG:${MPI_FLAG}:" \
208             -e"s:DEF_NEMO_VALIDATION:${NEMO_VALIDATION_DIR}:" -e"s:DEF_NEW_CONF:${NEW_CONF}:" \
209             -e"s:DEF_CMP_NAM:${CMP_NAM}:" -e"s:DEF_TEST_NAME:${TEST_NAME}:" > run_sette_test.job
210   
211#
212# create the unique submission job script
213#
214   if [ ! -f $JOB_FILE ] ; then
215      mv run_sette_test.job $JOB_FILE
216   else
217       e=`grep -n "# END_BODY" ${JOB_FILE} | cut -d : -f 1`
218            e=$(($e - 1))
219       head -$e $JOB_FILE > ${JOB_FILE}_new
220       mv ${JOB_FILE}_new ${JOB_FILE}
221       l=`wc -l run_sette_test.job | sed -e "s:run_sette_test.job::"`
222       b=`grep -n "# BODY" run_sette_test.job | cut -d : -f 1`
223       t=$(($l - $b))
224       tail -$t run_sette_test.job >> $JOB_FILE
225   fi
226   
227   chmod a+x $JOB_FILE ; echo "$JOB_FILE is ready"
228
229#fi
Note: See TracBrowser for help on using the repository browser.