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

source: branches/2012/dev_NOC_2012_rev3555/NEMOGCM/SETTE/prepare_job.sh @ 3608

Last change on this file since 3608 was 3608, checked in by acc, 12 years ago

Branch dev_NOC_2012_r3555. #1006. Step 3: Merge in trunk changes between revision 3322 and 3337

  • Property svn:executable set to *
File size: 6.0 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 -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# RUN OPA
149cd ${EXE_DIR}
150if [ ! -r ${EXE_DIR}/opa ]
151    then
152    echo "executable opa does not exist"
153    echo "executable opa does not exist, exit"  >> ${SETTE_DIR}/output.sette
154    exit 1
155fi
156
157# example for NOCS Altix system using PBS batch submission (requires ${SETTE_DIR}/sette_batch_template file)
158#
159  #  if [ ${MPI_FLAG} == "no" ] ; then
160      case ${COMPILER} in
161         ALTIX_NAUTILUS_MPT)
162                                NB_REM=$( echo $NB_PROC | awk '{print $1 % 4}')
163               if [ ${NB_REM} == 0 ] ; then
164               # number of processes required is an integer multiple of 4
165               #
166               NB_NODES=$( echo $NB_PROC | awk '{print $1 / 4}')
167            else
168               #
169               # number of processes required is not an integer multiple of 4
170               # round up the number of nodes required.
171               #
172               NB_NODES=$( echo $NB_PROC | awk '{printf("%d",$1 / 4 + 1 )}')
173                  fi
174            ;;
175         *)
176            NB_NODES=${NB_PROC}
177            ;;
178
179      esac
180#
181# Pass settings into job file by using sed to edit predefined strings
182#
183        cat ${SETTE_DIR}/job_batch_template | sed -e"s/NODES/${NB_NODES}/" -e"s/NPROCS/${NB_PROC}/" \
184             -e"s:DEF_SETTE_DIR:${SETTE_DIR}:" -e"s:DEF_INPUT_DIR:${INPUT_DIR}:" \
185             -e"s:DEF_EXE_DIR:${EXE_DIR}:" \
186             -e"s:DEF_CONFIG_DIR:${CONFIG_DIR}:" \
187             -e"s:MPI_FLAG:${MPI_FLAG}:" \
188             -e"s:DEF_NEMO_VALIDATION:${NEMO_VALIDATION_DIR}:" -e"s:DEF_NEW_CONF:${NEW_CONF}:" \
189             -e"s:DEF_CMP_NAM:${CMP_NAM}:" -e"s:DEF_TEST_NAME:${TEST_NAME}:" > run_sette_test.job
190   
191#
192# create the unique submission job script
193#
194   if [ ! -f $JOB_FILE ] ; then
195      mv run_sette_test.job $JOB_FILE
196   else
197       e=`grep -n "# END_BODY" ${JOB_FILE} | cut -d : -f 1`
198            e=$(($e - 1))
199       head -$e $JOB_FILE > ${JOB_FILE}_new
200       mv ${JOB_FILE}_new ${JOB_FILE}
201       l=`wc -l run_sette_test.job | sed -e "s:run_sette_test.job::"`
202       b=`grep -n "# BODY" run_sette_test.job | cut -d : -f 1`
203       t=$(($l - $b))
204       tail -$t run_sette_test.job >> $JOB_FILE
205   fi
206   
207   chmod a+x $JOB_FILE ; echo "$JOB_FILE is ready"
208
209#fi
Note: See TracBrowser for help on using the repository browser.