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 | mkdir logs |
---|
152 | cp *.def *.xml job.sh logs/ |
---|
153 | mv apbp.nc *.err *.out gcm.log logs/ |
---|
154 | tar czf logs.tgz logs |
---|
155 | mv hist*.nc logs.tgz store/ |
---|
156 | # cleanup |
---|
157 | rm -f *.nc |
---|
158 | EOF |
---|
159 | } |
---|
160 | |
---|
161 | #------------ Batch jobs : machine-dependent main script : X64_CURIE -------------- |
---|
162 | |
---|
163 | function batch_X64_CURIE_ce0l() { |
---|
164 | cat <<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 $NB_MPI_CE0L |
---|
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 ) |
---|
179 | date > gcm.log |
---|
180 | export OMP_NUM_THREADS=1 |
---|
181 | ccc_mprun $ICOSA_LMDZ >> gcm.log |
---|
182 | date >> gcm.log |
---|
183 | $( epilogue_ce0l ) |
---|
184 | $( epilogue_all ) |
---|
185 | EOF |
---|
186 | } |
---|
187 | |
---|
188 | function batch_X64_CURIE_first() { |
---|
189 | batch_X64_CURIE first |
---|
190 | } |
---|
191 | |
---|
192 | function batch_X64_CURIE_next() { |
---|
193 | batch_X64_CURIE next |
---|
194 | } |
---|
195 | |
---|
196 | function batch_X64_CURIE() { # $1 = first or next |
---|
197 | NB_MPI_TOTAL=$(( $NB_MPI_DYNAMICO + $NB_MPI_XIOS )) |
---|
198 | cat <<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 $JOB_WALLTIME |
---|
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 ) |
---|
214 | export OMP_NUM_THREADS=1 |
---|
215 | ccc_mprun -f mpmd.conf |
---|
216 | $( epilogue_$1 ) |
---|
217 | $( epilogue_all ) |
---|
218 | EOF |
---|
219 | |
---|
220 | cat <<EOF > $MYDIR/mpmd.conf |
---|
221 | $NB_MPI_DYNAMICO ./gcm.sh |
---|
222 | $NB_MPI_XIOS $XIOS_SERVER |
---|
223 | EOF |
---|
224 | |
---|
225 | cat <<EOF > $MYDIR/gcm.sh |
---|
226 | #!/bin/bash |
---|
227 | ME=\${BRIDGE_MPRUN_RANKID} |
---|
228 | GCM=\$(printf 'dynamico.%04d' \$ME) |
---|
229 | date > \${GCM}.out |
---|
230 | $ICOSA_LMDZ >> \${GCM}.out 2>\${GCM}.err |
---|
231 | date >> \${GCM}.out |
---|
232 | EOF |
---|
233 | chmod a+x $MYDIR/gcm.sh |
---|
234 | } |
---|
235 | |
---|
236 | #--------------------- Main -------------------- |
---|
237 | |
---|
238 | echo |
---|
239 | echo |
---|
240 | echo "Your command : $0 $*" |
---|
241 | echo "Working directory : $PWD" |
---|
242 | |
---|
243 | source ./config.sh |
---|
244 | |
---|
245 | check_env || exit 1 |
---|
246 | |
---|
247 | XIOS_SERVER=$(fullpath "$ESM_ROOT/XIOS/bin/xios_server.exe") |
---|
248 | ICOSA_LMDZ=$(fullpath "$ESM_ROOT/ICOSA_LMDZ/bin/icosa_lmdz.exe") |
---|
249 | |
---|
250 | NB_MPI_DYNAMICO=160 |
---|
251 | NB_MPI_XIOS=16 |
---|
252 | NB_MPI_CE0L=16 |
---|
253 | |
---|
254 | TYPE=$1 |
---|
255 | readargs_$TYPE $* |
---|
256 | |
---|
257 | # avoid destroying xml and def files in case of mistake |
---|
258 | chmod a-w *.def *.xml |
---|
259 | |
---|
260 | MYSED=$(mktemp) |
---|
261 | sed_$TYPE > $MYSED |
---|
262 | cat $MYSED |
---|
263 | for FILE in *.def *.xml ; do |
---|
264 | sed -f $MYSED $FILE > $MYDIR/$FILE |
---|
265 | done |
---|
266 | rm -f $MYSED |
---|
267 | |
---|
268 | chmod u+w *.def *.xml |
---|
269 | |
---|
270 | cd $MYDIR |
---|
271 | batch_${ARCH}_${TYPE} > job.sh |
---|
272 | |
---|
273 | #ls -l $MYDIR |
---|
274 | grep using_server iodef.xml |
---|
275 | grep dom_out context_lmdz.xml |
---|
276 | for KEY in read_start iflag_phys etat0 run_length; do |
---|
277 | grep $KEY *.def |
---|
278 | done |
---|