source: dynamico_lmdz/aquaplanet/CMIP5a/RUN_AQUAPLANET_DYNAMICO_LMDZ5/prepare.sh @ 4066

Last change on this file since 4066 was 4066, checked in by dubos, 7 years ago

Aquaplanet config : dom_out is always dom_regular

  • Property svn:executable set to *
File size: 5.3 KB
Line 
1#!/bin/bash
2
3#---------------------- Arguments ------------------
4
5function fullpath() {
6    mkdir -p $(dirname "$1")
7    echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
8}
9
10function readargs_ce0l() {
11    MYDIR=$(fullpath $2)
12    MYSTORE=$(fullpath $3)
13    mkdir -p $MYDIR
14    mkdir -p $MYSTORE
15    ln -sf $MYSTORE $MYDIR/store
16    echo "ce0l : MYDIR=$MYDIR MYSTORE=$MYSTORE"
17}
18
19function readargs_first() {
20    STORE0=$(fullpath $2)
21    MYDIR=$(fullpath $3)
22    MYSTORE=$(fullpath $4)
23    mkdir -p $MYDIR
24    mkdir -p $MYSTORE
25    ln -sf $STORE0 $MYDIR/store0
26    ln -sf $MYSTORE $MYDIR/store
27}
28
29function readargs_next() {
30    STORE0=$(fullpath $2)
31    STOREPREV=$(fullpath $3)
32    MYDIR=$(fullpath $4)
33    MYSTORE=$(fullpath $5)
34    mkdir -p $MYDIR
35    mkdir -p $MYSTORE
36    ln -sf $STORE0 $MYDIR/store0
37    ln -sf $STOREPREV $MYDIR/store_prev
38    ln -sf $MYSTORE $MYDIR/store
39}
40
41function check_env()
42{
43    if [ "$ARCH" == "" ] ; then
44        echo 'You must define environment variables ARCH and ESM_ROOT'
45        exit 1
46    fi
47    if [ "$ESM_ROOT" == "" ] ; then
48        echo 'You must define environment variables ARCH and ESM_ROOT'
49        exit 1
50    fi
51    XIOS_SERVER="${ESM_ROOT}/XIOS/bin/xios_server.exe"
52    if [ ! -f "${XIOS_SERVER}" ]; then
53        echo "${XIOS_SERVER} not found, check that ESM_ROOT=$ESM_ROOT points to the correct location"
54    fi
55   
56}
57
58#---------------- Keyword substitution -------------
59
60function def() {
61    echo "s/$1/$2/g"
62}
63
64function sed_ce0l() {
65    def USING_SERVER false
66    def CE0L yes
67    def READ_START no
68    def IFLAG_PHYS 103
69    def ETAT0 held_suarez
70}
71
72function sed_first() {
73    def USING_SERVER true
74    def CE0L no
75    def READ_START yes
76    def IFLAG_PHYS 1
77    def ETAT0 held_suarez
78}
79
80function sed_next() {
81    def USING_SERVER true
82    def CE0L no
83    def READ_START yes
84    def IFLAG_PHYS 1
85    def ETAT0 start_file
86}
87
88#------------ Batch jobs : machine-independent prologues and epilogues  --------------
89
90function prologue_all() {
91cat <<EOF
92cd ${MYDIR}
93rm -rf gcm.log *.nc xios_*.err xios_*.out gcm.log logs
94
95cat <<END  > killme.sh
96#!/bin/bash
97ccc_mdel \${BRIDGE_MSUB_JOBID}
98END
99chmod a+x killme.sh
100
101ulimit -s unlimited
102
103EOF
104cat $ESM_ROOT/ICOSA_LMDZ/arch.env
105}
106
107function prologue_first() {
108cat <<EOF
109cp -f store0/limit.nc store0/startphy.nc .
110EOF
111}
112
113function prologue_next() {
114cat <<EOF
115cp -f store0/limit.nc .
116cp -f store_prev/restartphy.nc startphy.nc
117cp -f store_prev/restart.nc start.nc
118EOF
119}
120
121function epilogue_ce0l(){
122    cat <<EOF
123# save useful files
124mv limit.nc startphy.nc store/
125EOF
126}
127
128function epilogue_first(){
129    cat <<EOF
130# remove input files to avoid storing them a few lines below
131rm -f limit.nc startphy.nc
132# save useful files
133mv restartphy.nc restart.nc store/
134EOF
135}
136
137function epilogue_next(){
138    cat <<EOF
139# remove input files to avoid storing them a few lines below
140rm -f limit.nc startphy.nc start.nc
141# save useful files
142mv restartphy.nc restart.nc store/
143EOF
144}
145
146function epilogue_all() {
147    cat <<EOF
148mkdir logs
149cp *.def *.xml job.sh logs/
150mv apbp.nc Ai.nc *.err *.out gcm.log logs/
151tar czf logs.tgz logs
152mv hist*.nc logs.tgz store/
153# cleanup
154rm -f *.nc
155EOF
156}
157
158#------------ Batch jobs : machine-dependent main script : X64_CURIE  --------------
159
160function batch_X64_CURIE_ce0l() {
161cat <<EOF
162#!/bin/bash
163## Request name
164#MSUB -r aqua_ce0l_mpi
165#MSUB -q standard
166#MSUB -A gen7548
167#MSUB -x
168## Number of tasks (=MPI processes) to use
169#MSUB -n $NB_MPI_CE0L
170## Elapsed time limit in seconds
171#MSUB -T 600
172## Quality of Service required (long [3 days], normal [1 day], test [30 min])
173#MSUB -Q normal
174
175$( prologue_all )
176date > gcm.log
177export OMP_NUM_THREADS=1
178ccc_mprun $ICOSA_LMDZ >> gcm.log
179date >> gcm.log
180$( epilogue_ce0l )
181$( epilogue_all )
182EOF
183}
184
185function batch_X64_CURIE_first() {
186batch_X64_CURIE first
187}
188
189function batch_X64_CURIE_next() {
190batch_X64_CURIE next
191}
192
193function batch_X64_CURIE() { # $1 = first or next
194NB_MPI_TOTAL=$(( $NB_MPI_DYNAMICO + $NB_MPI_XIOS ))
195cat <<EOF
196#!/bin/bash
197## Request name
198#MSUB -r aqua_$1_mpi
199#MSUB -q standard
200#MSUB -A gen7548
201#MSUB -x
202## Number of tasks (=MPI processes) to use
203#MSUB -n $NB_MPI_TOTAL
204## Elapsed time limit in seconds
205#MSUB -T $JOB_WALLTIME
206## Quality of Service required (long [3 days], normal [1 day], test [30 min])
207#MSUB -Q normal
208
209$( prologue_all )
210$( prologue_$1 )
211export OMP_NUM_THREADS=1
212ccc_mprun -f mpmd.conf
213$( epilogue_$1 )
214$( epilogue_all )
215EOF
216
217cat <<EOF > $MYDIR/mpmd.conf
218$NB_MPI_DYNAMICO ./gcm.sh
219$NB_MPI_XIOS $XIOS_SERVER
220EOF
221
222cat <<EOF > $MYDIR/gcm.sh
223#!/bin/bash
224ME=\${BRIDGE_MPRUN_RANKID}
225GCM=\$(printf 'dynamico.%04d' \$ME)
226date > \${GCM}.out
227$ICOSA_LMDZ >> \${GCM}.out 2>\${GCM}.err
228date >> \${GCM}.out
229EOF
230chmod a+x $MYDIR/gcm.sh
231}
232
233#--------------------- Main --------------------
234
235echo
236echo
237echo "Your command : $0 $*"
238echo "Working directory : $PWD"
239
240NB_MPI_DYNAMICO=160
241NB_MPI_XIOS=16
242NB_MPI_CE0L=16
243source ./config.sh
244
245check_env || exit 1
246
247XIOS_SERVER=$(fullpath "$ESM_ROOT/XIOS/bin/xios_server.exe")
248ICOSA_LMDZ=$(fullpath "$ESM_ROOT/ICOSA_LMDZ/bin/icosa_lmdz.exe")
249
250TYPE=$1
251readargs_$TYPE $*
252
253# avoid destroying xml and def files in case of mistake
254chmod a-w *.def *.xml
255
256MYSED=$(mktemp)
257sed_$TYPE > $MYSED
258cat $MYSED
259for FILE in *.def *.xml ; do
260    sed -f $MYSED $FILE > $MYDIR/$FILE
261done
262rm -f $MYSED
263
264chmod u+w *.def *.xml
265
266cd $MYDIR
267batch_${ARCH}_${TYPE} > job.sh
268
269#ls -l $MYDIR
270grep using_server iodef.xml
271for KEY in read_start iflag_phys etat0 run_length; do
272    grep $KEY *.def
273done
Note: See TracBrowser for help on using the repository browser.