1 | #!/bin/bash |
---|
2 | |
---|
3 | #---------------------- Arguments ------------------ |
---|
4 | |
---|
5 | function fullpath() { |
---|
6 | mkdir -p $(dirname "$1") |
---|
7 | echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" |
---|
8 | } |
---|
9 | |
---|
10 | function 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 | |
---|
19 | function 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 | |
---|
29 | function 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 | |
---|
41 | function 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 | |
---|
60 | function def() { |
---|
61 | echo "s/$1/$2/g" |
---|
62 | } |
---|
63 | |
---|
64 | function 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 | |
---|
73 | function 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 | |
---|
82 | function 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 | |
---|
93 | function prologue_all() { |
---|
94 | cat <<EOF |
---|
95 | cd ${MYDIR} |
---|
96 | rm -rf gcm.log *.nc xios_*.err xios_*.out gcm.log logs |
---|
97 | |
---|
98 | cat <<END > killme.sh |
---|
99 | #!/bin/bash |
---|
100 | ccc_mdel \${BRIDGE_MSUB_JOBID} |
---|
101 | END |
---|
102 | chmod a+x killme.sh |
---|
103 | |
---|
104 | ulimit -s unlimited |
---|
105 | |
---|
106 | EOF |
---|
107 | cat $ESM_ROOT/ICOSA_LMDZ/arch.env |
---|
108 | } |
---|
109 | |
---|
110 | function prologue_first() { |
---|
111 | cat <<EOF |
---|
112 | cp -f store0/limit.nc store0/startphy.nc . |
---|
113 | EOF |
---|
114 | } |
---|
115 | |
---|
116 | function prologue_next() { |
---|
117 | cat <<EOF |
---|
118 | cp -f store0/limit.nc . |
---|
119 | cp -f store_prev/restartphy.nc startphy.nc |
---|
120 | cp -f store_prev/restart.nc start.nc |
---|
121 | EOF |
---|
122 | } |
---|
123 | |
---|
124 | function epilogue_ce0l(){ |
---|
125 | cat <<EOF |
---|
126 | # save useful files |
---|
127 | mv limit.nc startphy.nc store/ |
---|
128 | EOF |
---|
129 | } |
---|
130 | |
---|
131 | function epilogue_first(){ |
---|
132 | cat <<EOF |
---|
133 | # remove input files to avoid storing them a few lines below |
---|
134 | rm -f limit.nc startphy.nc |
---|
135 | # save useful files |
---|
136 | mv restartphy.nc restart.nc store/ |
---|
137 | EOF |
---|
138 | } |
---|
139 | |
---|
140 | function epilogue_next(){ |
---|
141 | cat <<EOF |
---|
142 | # remove input files to avoid storing them a few lines below |
---|
143 | rm -f limit.nc startphy.nc start.nc |
---|
144 | # save useful files |
---|
145 | mv restartphy.nc restart.nc store/ |
---|
146 | EOF |
---|
147 | } |
---|
148 | |
---|
149 | function epilogue_all() { |
---|
150 | cat <<EOF |
---|
151 | cp *.def *.xml job.sh store/ |
---|
152 | mv apbp.nc hist*.nc xios_*.err xios_*.out gcm.log store/ |
---|
153 | ls -l > store/ls |
---|
154 | # cleanup |
---|
155 | rm -f *.nc |
---|
156 | EOF |
---|
157 | } |
---|
158 | |
---|
159 | #------------ Batch jobs : machine-dependent main script : X64_CURIE -------------- |
---|
160 | |
---|
161 | function batch_X64_CURIE_ce0l() { |
---|
162 | cat <<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 ) |
---|
177 | date > gcm.log |
---|
178 | export OMP_NUM_THREADS=1 |
---|
179 | ccc_mprun $ICOSA_LMDZ >> gcm.log |
---|
180 | date >> gcm.log |
---|
181 | $( epilogue_ce0l ) |
---|
182 | $( epilogue_all ) |
---|
183 | EOF |
---|
184 | } |
---|
185 | |
---|
186 | function batch_X64_CURIE_first() { |
---|
187 | batch_X64_CURIE first |
---|
188 | } |
---|
189 | |
---|
190 | function batch_X64_CURIE_next() { |
---|
191 | batch_X64_CURIE next |
---|
192 | } |
---|
193 | |
---|
194 | function batch_X64_CURIE() { # $1 = first or next |
---|
195 | cat <<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 ) |
---|
211 | date > gcm.log |
---|
212 | export OMP_NUM_THREADS=1 |
---|
213 | ccc_mprun -f mpmd.conf >> gcm.log |
---|
214 | date >> gcm.log |
---|
215 | $( epilogue_$1 ) |
---|
216 | $( epilogue_all ) |
---|
217 | EOF |
---|
218 | |
---|
219 | cat <<EOF > $MYDIR/mpmd.conf |
---|
220 | 160 $ICOSA_LMDZ |
---|
221 | 16 $XIOS_SERVER |
---|
222 | EOF |
---|
223 | |
---|
224 | } |
---|
225 | |
---|
226 | #--------------------- Main -------------------- |
---|
227 | |
---|
228 | echo |
---|
229 | echo |
---|
230 | echo "Your command : $0 $*" |
---|
231 | echo "Working directory : $PWD" |
---|
232 | |
---|
233 | check_env || exit 1 |
---|
234 | |
---|
235 | XIOS_SERVER=$(fullpath "$ESM_ROOT/XIOS/bin/xios_server.exe") |
---|
236 | ICOSA_LMDZ=$(fullpath "$ESM_ROOT/ICOSA_LMDZ/bin/icosa_lmdz.exe") |
---|
237 | |
---|
238 | TYPE=$1 |
---|
239 | readargs_$TYPE $* |
---|
240 | |
---|
241 | # avoid destroying xml and def files in case of mistake |
---|
242 | chmod a-w *.def *.xml |
---|
243 | |
---|
244 | MYSED=$(mktemp) |
---|
245 | sed_$TYPE > $MYSED |
---|
246 | cat $MYSED |
---|
247 | for FILE in *.def *.xml ; do |
---|
248 | sed -f $MYSED $FILE > $MYDIR/$FILE |
---|
249 | done |
---|
250 | rm -f $MYSED |
---|
251 | |
---|
252 | chmod u+w *.def *.xml |
---|
253 | |
---|
254 | cd $MYDIR |
---|
255 | batch_${ARCH}_${TYPE} > job.sh |
---|
256 | |
---|
257 | #ls -l $MYDIR |
---|
258 | grep using_server iodef.xml |
---|
259 | grep dom_out context_lmdz.xml |
---|
260 | for KEY in read_start iflag_phys etat0 run_length; do |
---|
261 | grep $KEY *.def |
---|
262 | done |
---|