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

Last change on this file since 3978 was 3978, checked in by dubos, 8 years ago

DYNAMICO_ESM/OLD_PHYSIC : updated XML/DEF + helper scripts

  • Property svn:executable set to *
File size: 5.1 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
151cp *.def *.xml job.sh store/
152mv apbp.nc hist*.nc xios_*.err xios_*.out gcm.log store/
153ls -l > store/ls
154# cleanup
155rm -f *.nc
156EOF
157}
158
159#------------ Batch jobs : machine-dependent main script : X64_CURIE  --------------
160
161function batch_X64_CURIE_ce0l() {
162cat <<EOF
163#!/bin/bash
164## Request name
165#MSUB -r aqua_ce0l_mpi
166#MSUB -q standard
167#MSUB -A gen7548
168#MSUB -x
169## Number of tasks (=MPI processes) to use
170#MSUB -n 16
171## Elapsed time limit in seconds
172#MSUB -T 600
173## Quality of Service required (long [3 days], normal [1 day], test [30 min])
174#MSUB -Q normal
175
176$( prologue_all )
177date > gcm.log
178export OMP_NUM_THREADS=1
179ccc_mprun $ICOSA_LMDZ >> gcm.log
180date >> gcm.log
181$( epilogue_ce0l )
182$( epilogue_all )
183EOF
184}
185
186function batch_X64_CURIE_first() {
187batch_X64_CURIE first
188}
189
190function batch_X64_CURIE_next() {
191batch_X64_CURIE next
192}
193
194function batch_X64_CURIE() { # $1 = first or next
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 176
204## Elapsed time limit in seconds
205#MSUB -T 7200
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 )
211date > gcm.log
212export OMP_NUM_THREADS=1
213ccc_mprun -f mpmd.conf >> gcm.log
214date >> gcm.log
215$( epilogue_$1 )
216$( epilogue_all )
217EOF
218
219cat <<EOF > $MYDIR/mpmd.conf
220160 $ICOSA_LMDZ
22116 $XIOS_SERVER
222EOF
223
224}
225
226#--------------------- Main --------------------
227
228echo
229echo
230echo "Your command : $0 $*"
231echo "Working directory : $PWD"
232
233check_env || exit 1
234
235XIOS_SERVER=$(fullpath "$ESM_ROOT/XIOS/bin/xios_server.exe")
236ICOSA_LMDZ=$(fullpath "$ESM_ROOT/ICOSA_LMDZ/bin/icosa_lmdz.exe")
237
238TYPE=$1
239readargs_$TYPE $*
240
241# avoid destroying xml and def files in case of mistake
242chmod a-w *.def *.xml
243
244MYSED=$(mktemp)
245sed_$TYPE > $MYSED
246cat $MYSED
247for FILE in *.def *.xml ; do
248    sed -f $MYSED $FILE > $MYDIR/$FILE
249done
250rm -f $MYSED
251
252chmod u+w *.def *.xml
253
254cd $MYDIR
255batch_${ARCH}_${TYPE} > job.sh
256
257#ls -l $MYDIR
258grep using_server iodef.xml
259grep dom_out context_lmdz.xml
260for KEY in read_start iflag_phys etat0 run_length; do
261    grep $KEY *.def
262done
Note: See TracBrowser for help on using the repository browser.