source: dynamico_lmdz/aquaplanet/OLD_PHYSIC/RUN_AQUAPLANET_DYNAMICO_LMDZ5/prepare.sh @ 4037

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

Aquaplanet : updated scripts

  • Property svn:executable set to *
File size: 5.4 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 DOM_OUT dom_glo
67    def CE0L yes
68    def READ_START no
69    def IFLAG_PHYS 103
70    def ETAT0 held_suarez
71}
72
73function sed_first() {
74    def USING_SERVER true
75    def DOM_OUT dom_regular
76    def CE0L no
77    def READ_START yes
78    def IFLAG_PHYS 1
79    def ETAT0 held_suarez
80}
81
82function sed_next() {
83    def USING_SERVER true
84    def DOM_OUT dom_regular
85    def CE0L no
86    def READ_START yes
87    def IFLAG_PHYS 1
88    def ETAT0 start_file
89}
90
91#------------ Batch jobs : machine-independent prologues and epilogues  --------------
92
93function prologue_all() {
94cat <<EOF
95cd ${MYDIR}
96rm -rf gcm.log *.nc xios_*.err xios_*.out gcm.log logs
97
98cat <<END  > killme.sh
99#!/bin/bash
100ccc_mdel \${BRIDGE_MSUB_JOBID}
101END
102chmod a+x killme.sh
103
104ulimit -s unlimited
105
106EOF
107cat $ESM_ROOT/ICOSA_LMDZ/arch.env
108}
109
110function prologue_first() {
111cat <<EOF
112cp -f store0/limit.nc store0/startphy.nc .
113EOF
114}
115
116function prologue_next() {
117cat <<EOF
118cp -f store0/limit.nc .
119cp -f store_prev/restartphy.nc startphy.nc
120cp -f store_prev/restart.nc start.nc
121EOF
122}
123
124function epilogue_ce0l(){
125    cat <<EOF
126# save useful files
127mv limit.nc startphy.nc store/
128EOF
129}
130
131function epilogue_first(){
132    cat <<EOF
133# remove input files to avoid storing them a few lines below
134rm -f limit.nc startphy.nc
135# save useful files
136mv restartphy.nc restart.nc store/
137EOF
138}
139
140function epilogue_next(){
141    cat <<EOF
142# remove input files to avoid storing them a few lines below
143rm -f limit.nc startphy.nc start.nc
144# save useful files
145mv restartphy.nc restart.nc store/
146EOF
147}
148
149function epilogue_all() {
150    cat <<EOF
151mkdir logs
152cp *.def *.xml job.sh logs/
153mv apbp.nc *.err *.out gcm.log logs/
154tar czf logs.tgz logs
155mv hist*.nc logs.tgz store/
156# cleanup
157rm -f *.nc
158EOF
159}
160
161#------------ Batch jobs : machine-dependent main script : X64_CURIE  --------------
162
163function batch_X64_CURIE_ce0l() {
164cat <<EOF
165#!/bin/bash
166## Request name
167#MSUB -r aqua_ce0l_mpi
168#MSUB -q standard
169#MSUB -A gen7548
170#MSUB -x
171## Number of tasks (=MPI processes) to use
172#MSUB -n 16
173## Elapsed time limit in seconds
174#MSUB -T 600
175## Quality of Service required (long [3 days], normal [1 day], test [30 min])
176#MSUB -Q normal
177
178$( prologue_all )
179date > gcm.log
180export OMP_NUM_THREADS=1
181ccc_mprun $ICOSA_LMDZ >> gcm.log
182date >> gcm.log
183$( epilogue_ce0l )
184$( epilogue_all )
185EOF
186}
187
188function batch_X64_CURIE_first() {
189batch_X64_CURIE first
190}
191
192function batch_X64_CURIE_next() {
193batch_X64_CURIE next
194}
195
196function batch_X64_CURIE() { # $1 = first or next
197NB_MPI_TOTAL=$(( $NB_MPI_DYNAMICO + $NB_MPI_XIOS ))
198cat <<EOF
199#!/bin/bash
200## Request name
201#MSUB -r aqua_$1_mpi
202#MSUB -q standard
203#MSUB -A gen7548
204#MSUB -x
205## Number of tasks (=MPI processes) to use
206#MSUB -n $NB_MPI_TOTAL
207## Elapsed time limit in seconds
208#MSUB -T 10800
209## Quality of Service required (long [3 days], normal [1 day], test [30 min])
210#MSUB -Q normal
211
212$( prologue_all )
213$( prologue_$1 )
214export OMP_NUM_THREADS=1
215ccc_mprun -f mpmd.conf
216$( epilogue_$1 )
217$( epilogue_all )
218EOF
219
220cat <<EOF > $MYDIR/mpmd.conf
221$NB_MPI_DYNAMICO ./gcm.sh
222$NB_MPI_XIOS $XIOS_SERVER
223EOF
224
225cat <<EOF > $MYDIR/gcm.sh
226#!/bin/bash
227ME=\${BRIDGE_MPRUN_RANKID}
228GCM=\$(printf 'dynamico.%04d' \$ME)
229date > \${GCM}.out
230$ICOSA_LMDZ >> \${GCM}.out 2>\${GCM}.err
231date >> \${GCM}.out
232EOF
233chmod a+x $MYDIR/gcm.sh
234}
235
236#--------------------- Main --------------------
237
238echo
239echo
240echo "Your command : $0 $*"
241echo "Working directory : $PWD"
242
243check_env || exit 1
244
245XIOS_SERVER=$(fullpath "$ESM_ROOT/XIOS/bin/xios_server.exe")
246ICOSA_LMDZ=$(fullpath "$ESM_ROOT/ICOSA_LMDZ/bin/icosa_lmdz.exe")
247
248NB_MPI_DYNAMICO=160
249NB_MPI_XIOS=16
250
251TYPE=$1
252readargs_$TYPE $*
253
254# avoid destroying xml and def files in case of mistake
255chmod a-w *.def *.xml
256
257MYSED=$(mktemp)
258sed_$TYPE > $MYSED
259cat $MYSED
260for FILE in *.def *.xml ; do
261    sed -f $MYSED $FILE > $MYDIR/$FILE
262done
263rm -f $MYSED
264
265chmod u+w *.def *.xml
266
267cd $MYDIR
268batch_${ARCH}_${TYPE} > job.sh
269
270#ls -l $MYDIR
271grep using_server iodef.xml
272grep dom_out context_lmdz.xml
273for KEY in read_start iflag_phys etat0 run_length; do
274    grep $KEY *.def
275done
Note: See TracBrowser for help on using the repository browser.