1 | #! /bin/bash |
---|
2 | |
---|
3 | ######################################################### |
---|
4 | # runmeso : # |
---|
5 | # utility to combine compilation + preprocessing + run # |
---|
6 | ######################################################### |
---|
7 | ############################### |
---|
8 | # Author: A. Spiga # |
---|
9 | # New version : December 2008 # |
---|
10 | # Modified : 2009-2010 # |
---|
11 | # New physics : 2011 # |
---|
12 | ############################### |
---|
13 | |
---|
14 | # TODO: - GCM compile |
---|
15 | # - NETCDF |
---|
16 | # - (modif registry) |
---|
17 | # - quick restart |
---|
18 | |
---|
19 | |
---|
20 | ########################################### |
---|
21 | ########################################### |
---|
22 | ########################################### |
---|
23 | |
---|
24 | changeregis=0 ## 1 if changed registry |
---|
25 | #changeregis=1 ## 1 if changed registry |
---|
26 | i_want_to_compile=1 |
---|
27 | |
---|
28 | scenario="" |
---|
29 | #scenario="storm" |
---|
30 | |
---|
31 | if [[ "${MESO}" = "" ]] |
---|
32 | then |
---|
33 | echo "Please initialize the variable MESO in your environnement (or modify scripts)" |
---|
34 | exit |
---|
35 | fi |
---|
36 | #################################### |
---|
37 | # A FEW DEFINITIONS YOU CAN MODIFY # |
---|
38 | #################################### |
---|
39 | main_folder=$MESO |
---|
40 | meso_folder=${main_folder}'/LMD_MM_MARS' |
---|
41 | calendar=${main_folder}'/LMD_MM_MARS/SIMU/calendar' |
---|
42 | simu_folder=$PWD |
---|
43 | |
---|
44 | ################ |
---|
45 | # WELCOME USER # |
---|
46 | ################ |
---|
47 | echo '**********************************************' |
---|
48 | echo '**** LMD Martian Mesoscale Model launcher ****' |
---|
49 | echo '**********************************************' |
---|
50 | #echo '** Hello '$(whoami)' on '$(hostname)' !' |
---|
51 | #echo '** ['$(uname -a)']' |
---|
52 | echo '** User >>> '$(whoami) |
---|
53 | echo '** Hostname >>> '$(hostname) |
---|
54 | echo '** Hardware >>> '$(uname -m) |
---|
55 | echo '** Processor >>> '$(uname -p) |
---|
56 | echo '**********************************************' |
---|
57 | |
---|
58 | ######## NEWPHYS ??? |
---|
59 | if [[ ! ( -f "run.def" ) ]] |
---|
60 | then |
---|
61 | newphys=0 |
---|
62 | else |
---|
63 | echo '** New LMD physics >>> YES [run.def is here]' |
---|
64 | echo '**********************************************' |
---|
65 | newphys=1 |
---|
66 | if [[ ! ("${scenario}" == "") ]] |
---|
67 | then |
---|
68 | echo '** Scenario >>>' ${scenario} |
---|
69 | echo '**********************************************' |
---|
70 | fi |
---|
71 | fi |
---|
72 | |
---|
73 | ########################## |
---|
74 | # GET INFO FROM NAMELIST # |
---|
75 | ########################## |
---|
76 | #echo '***********************' |
---|
77 | #echo '**** Your settings ****' |
---|
78 | #echo '***********************' |
---|
79 | echo '** Simulation directory >>> '${simu_folder} |
---|
80 | if [[ ! ( -f "namelist.input" ) ]] |
---|
81 | then |
---|
82 | echo 'no namelist.input file !' |
---|
83 | exit |
---|
84 | fi |
---|
85 | # |
---|
86 | # READ INFO NEEDED FOR INIT |
---|
87 | # |
---|
88 | year=$(more ${simu_folder}/namelist.input | grep start_year | awk '{print $3}' | sed s+','+''+g) |
---|
89 | month=$(more ${simu_folder}/namelist.input | grep start_month | awk '{print $3}' | sed s+','+''+g) |
---|
90 | day=$(more ${simu_folder}/namelist.input | grep start_day | awk '{print $3}' | sed s+','+''+g) |
---|
91 | hour=$(more ${simu_folder}/namelist.input | grep start_hour | awk '{print $3}' | sed s+','+''+g) |
---|
92 | wrf_date=${year}'-'${month}'-'${day}'_00:00:00' |
---|
93 | daygcm=$(more ${calendar} | grep ${wrf_date} | awk '{print $2}') |
---|
94 | lsubs=$(more ${calendar} | grep ${wrf_date} | awk '{print $3}') |
---|
95 | eyear=$(more ${simu_folder}/namelist.input | grep end_year | awk '{print $3}' | sed s+','+''+g) |
---|
96 | emonth=$(more ${simu_folder}/namelist.input | grep end_month | awk '{print $3}' | sed s+','+''+g) |
---|
97 | eday=$(more ${simu_folder}/namelist.input | grep end_day | awk '{print $3}' | sed s+','+''+g) |
---|
98 | ehour=$(more ${simu_folder}/namelist.input | grep end_hour | awk '{print $3}' | sed s+','+''+g) |
---|
99 | ewrf_date=${eyear}'-'${emonth}'-'${eday}'_00:00:00' |
---|
100 | edaygcm=$(more ${calendar} | grep ${ewrf_date} | awk '{print $2}') |
---|
101 | elsubs=$(more ${calendar} | grep ${ewrf_date} | awk '{print $3}') |
---|
102 | echo '** Start date >>> '${year}'-'${month}'-'${day}" [sol="${daygcm}", Ls="${lsubs}"]" |
---|
103 | echo '** End date >>> '${eyear}'-'${emonth}'-'${eday}" [sol="${edaygcm}", Ls="${elsubs}"]" |
---|
104 | # |
---|
105 | # READ INFO NEEDED FOR DOMAIN |
---|
106 | # |
---|
107 | interval_seconds="$(more ${simu_folder}/namelist.input | grep -e '[^!]*interval_seconds *=')" |
---|
108 | if [[ "${interval_seconds}" = "" ]] |
---|
109 | then |
---|
110 | interval_seconds="interval_seconds = 3700 !! (p2) Frequency of large-scale fields update (s)" |
---|
111 | fi |
---|
112 | # |
---|
113 | max_dom="$(more ${simu_folder}/namelist.input | grep -e '[^!]*max_dom *=')" |
---|
114 | if [[ "${max_dom}" = "" ]] |
---|
115 | then |
---|
116 | max_dom="max_dom = 1 !! (r)(n)(p2) Total number of domains" |
---|
117 | fi |
---|
118 | # |
---|
119 | parent_id="$(more ${simu_folder}/namelist.input | grep -e '[^!]*parent_id *=')" |
---|
120 | if [[ "${parent_id}" = "" ]] |
---|
121 | then |
---|
122 | parent_id="parent_id = 0, !! (n)(p2) Associated parent domain" |
---|
123 | fi |
---|
124 | # |
---|
125 | i_parent_start="$(more ${simu_folder}/namelist.input | grep -e '[^!]*i_parent_start *=')" |
---|
126 | if [[ "${i_parent_start}" = "" ]] |
---|
127 | then |
---|
128 | i_parent_start="i_parent_start = 0, !! (n)(p2) x-position of the bottom-left nest corner" |
---|
129 | fi |
---|
130 | # |
---|
131 | j_parent_start="$(more ${simu_folder}/namelist.input | grep -e '[^!]*j_parent_start *=')" |
---|
132 | if [[ "${j_parent_start}" = "" ]] |
---|
133 | then |
---|
134 | j_parent_start="j_parent_start = 0, !! (n)(p2) y-position of the bottom-left nest corner" |
---|
135 | fi |
---|
136 | # |
---|
137 | parent_grid_ratio="$(more ${simu_folder}/namelist.input | grep -e '[^!]*parent_grid_ratio *=')" |
---|
138 | if [[ "${parent_grid_ratio}" = "" ]] |
---|
139 | then |
---|
140 | parent_grid_ratio="parent_grid_ratio = 1, !! (n)(p2) Ratio of horizontal resolution parent/nest" |
---|
141 | fi |
---|
142 | # |
---|
143 | e_we="$(more ${simu_folder}/namelist.input | grep -e '[^!]*e_we *=')" |
---|
144 | e_sn="$(more ${simu_folder}/namelist.input | grep -e '[^!]*e_sn *=')" |
---|
145 | # |
---|
146 | dx="$(more ${simu_folder}/namelist.input | grep -e '[^!]*dx *=' | awk '{print $3}' | sed s+','+''+g)" |
---|
147 | dy="$(more ${simu_folder}/namelist.input | grep -e '[^!]*dy *=' | awk '{print $3}' | sed s+','+''+g)" |
---|
148 | |
---|
149 | |
---|
150 | # |
---|
151 | # READ INFO NEEDED FOR COMPILATION |
---|
152 | # |
---|
153 | nx=$(more ${simu_folder}/namelist.input | grep -e '[^!]*e_we *=' | awk '{print $3}' | sed s+','+''+g) |
---|
154 | ny=$(more ${simu_folder}/namelist.input | grep -e '[^!]*e_sn *=' | awk '{print $3}' | sed s+','+''+g) |
---|
155 | nz=$(more ${simu_folder}/namelist.input | grep -e '[^!]*e_vert *=' | awk '{print $3}' | sed s+','+''+g) |
---|
156 | nest=$(more ${simu_folder}/namelist.input | grep -e '[^!]*max_dom *=' | awk '{print $3}' | sed s+','+''+g) |
---|
157 | if [[ "${nest}" = "" ]] |
---|
158 | then |
---|
159 | nest='1' |
---|
160 | fi |
---|
161 | numcallphys=$(ls callphys*def | wc -l) |
---|
162 | if [[ ${numcallphys} -lt ${nest} ]] |
---|
163 | then |
---|
164 | echo '**********' |
---|
165 | echo You should have ${nest} callphys.def' file(s)' !! |
---|
166 | exit |
---|
167 | fi |
---|
168 | mars_scenario=$(more ${simu_folder}/namelist.input | grep mars | awk '{print $3}' | sed s+','+''+g) |
---|
169 | case ${mars_scenario} in |
---|
170 | 0) tracers='1' ;; |
---|
171 | 1) tracers='2' ;; |
---|
172 | 2) tracers='1' ;; |
---|
173 | 3) tracers='2' ;; |
---|
174 | 11) tracers='4' ;; |
---|
175 | *) tracers='1' ;; |
---|
176 | esac |
---|
177 | echo '** Domain(s) >>> '${nest} |
---|
178 | echo '** Tracer(s) >>> '${tracers} |
---|
179 | |
---|
180 | ############ SCATTERERS SCATTERERS ###### |
---|
181 | if [[ ${newphys} -eq 1 ]] |
---|
182 | then |
---|
183 | #### CHANGE THIS IF YOU ADD NEW SCENARIOS |
---|
184 | case ${mars_scenario} in |
---|
185 | 0) scat=1 ;; |
---|
186 | 1) echo "!! How many scatterers are you using : 1,2,..." ; read scat ;; |
---|
187 | 2) scat=1 ;; |
---|
188 | 3) scat=1 ;; |
---|
189 | 11) echo "!! How many scatterers are you using : 1,2,..." ; read scat ;; |
---|
190 | 20) scat=1 ;; |
---|
191 | *) scat=1 ;; |
---|
192 | esac |
---|
193 | echo '** Scatterers >>> '${scat} |
---|
194 | else |
---|
195 | #### USELESS here BUT COMPATIBILITY |
---|
196 | scat=1 |
---|
197 | fi |
---|
198 | ######################################### |
---|
199 | |
---|
200 | echo '** Grid points >>> '${nx}" x "${ny}" x "${nz} |
---|
201 | echo '** Horizontal resolution >>> '${dx} |
---|
202 | |
---|
203 | #echo "OK ? ('no' to exit, any key if OK)" ; read wellok |
---|
204 | # if [[ "${wellok}" = "no" ]] |
---|
205 | # then |
---|
206 | # exit |
---|
207 | # fi |
---|
208 | |
---|
209 | ########### |
---|
210 | # ACTIONS # |
---|
211 | ########### |
---|
212 | #echo '***********************' |
---|
213 | #echo '**** Steps ****' |
---|
214 | #echo '***********************' |
---|
215 | echo '**********************************************' |
---|
216 | echo "** This script will compile the model then :" |
---|
217 | echo "** <1> Prepare GCM inputs <-1> to skip compilation" |
---|
218 | echo "** <2> Perform WPS interpolations <-2> to skip compilation" |
---|
219 | echo "** <3> Execute real.exe <-3> to skip compilation" |
---|
220 | echo "** <4> Execute wrf.exe <-4> to skip compilation" |
---|
221 | echo "** <5> Exit" |
---|
222 | echo "** <9> Oops ! Exit now please." |
---|
223 | echo '**********************************************' |
---|
224 | #echo "Start at which step ? (1-4)" ; read step |
---|
225 | echo "Where shall we start ? 1, 2, 3, 4, 5 or 9" ; read step |
---|
226 | if [[ ${step} -lt 0 ]] |
---|
227 | then |
---|
228 | step=$(expr 0 - ${step}) |
---|
229 | i_want_to_compile=0 |
---|
230 | echo ".... ok, I skip the compiling & linking step. you'll just be asked the compiler you previously defined." |
---|
231 | fi |
---|
232 | case ${step} in |
---|
233 | 9) exit ;; |
---|
234 | 5) gcmstep=0 ; wpsstep=0 ; realstep=0 ; wrfstep=0 ;; |
---|
235 | 1) gcmstep=1 ; wpsstep=1 ; realstep=1 ; wrfstep=1 ;; |
---|
236 | 2) gcmstep=0 ; wpsstep=1 ; realstep=1 ; wrfstep=1 ;; |
---|
237 | 3) gcmstep=0 ; wpsstep=0 ; realstep=1 ; wrfstep=1 ;; |
---|
238 | 4) gcmstep=0 ; wpsstep=0 ; realstep=0 ; wrfstep=1 ;; |
---|
239 | *) echo "** I guess you do not know what to do. Let's start from the beginning." |
---|
240 | gcmstep=1 ; wpsstep=1 ; realstep=1 ; wrfstep=1 ;; |
---|
241 | esac |
---|
242 | |
---|
243 | |
---|
244 | ################################### |
---|
245 | # LINK THE EXECUTABLES OR COMPILE # |
---|
246 | ################################### |
---|
247 | echo '**********************************************' |
---|
248 | echo "** Compiling option " |
---|
249 | echo "** <1> pgf90" |
---|
250 | echo "** <2> g95" |
---|
251 | echo "** <3> mpi+pgf90" |
---|
252 | echo "** <4> ifort" |
---|
253 | echo "** <5> mpi+ifort" |
---|
254 | echo "** .... more in makemeso ...." |
---|
255 | echo '**********************************************' |
---|
256 | echo "Your choice ? (1-5)" ; read compilo |
---|
257 | if [[ "${compilo}" == "" || ${compilo} -lt 1 || ${compilo} -gt 5 ]] |
---|
258 | then |
---|
259 | echo "** well, let's try g95" |
---|
260 | compilo=2 |
---|
261 | fi |
---|
262 | if [[ ${compilo} -eq 3 || ${compilo} -eq 5 ]] |
---|
263 | then |
---|
264 | echo How many processors ? 1, 2, 4, 6, 8, 12, 16, 20, 24, 32 ; read numproc |
---|
265 | else |
---|
266 | numproc=1 |
---|
267 | fi |
---|
268 | #if [[ ${i_want_to_compile} -ge 1 ]] |
---|
269 | #then |
---|
270 | cd ${meso_folder} |
---|
271 | echo ${compilo} > tmp |
---|
272 | if [[ ${compilo} -eq 3 ]] |
---|
273 | then |
---|
274 | echo ${numproc} >> tmp |
---|
275 | fi |
---|
276 | echo ${nest} >> tmp |
---|
277 | |
---|
278 | if [[ ${newphys} -eq 0 ]] |
---|
279 | then |
---|
280 | ./makemeso -d < tmp > /dev/null |
---|
281 | else |
---|
282 | if [[ "${scenario}" == "" ]] |
---|
283 | then |
---|
284 | ./makemeso -d -p < tmp > /dev/null |
---|
285 | else |
---|
286 | ./makemeso -d -p -s ${scenario} < tmp > /dev/null |
---|
287 | fi |
---|
288 | fi |
---|
289 | \rm tmp 2> /dev/null |
---|
290 | work_folder=${meso_folder}'/'$(more what_folder) |
---|
291 | echo 'work_folder : '${work_folder} |
---|
292 | \rm what_folder 2> /dev/null |
---|
293 | |
---|
294 | ##################### NB: define the domain if was not done yet |
---|
295 | if [[ -f "${simu_folder}/namelist.wps" ]] |
---|
296 | then |
---|
297 | happy='y' |
---|
298 | else |
---|
299 | happy='' |
---|
300 | fi |
---|
301 | if [[ ${step} -le 2 ]] |
---|
302 | then |
---|
303 | while [[ "${happy}" != "y" ]] |
---|
304 | do |
---|
305 | #vi ${simu_folder}/namelist.input |
---|
306 | if [[ ! ( -d "${work_folder}/WPS" ) ]] |
---|
307 | then |
---|
308 | echo 'no WPS. you need to install it for your architecture' |
---|
309 | exit |
---|
310 | fi |
---|
311 | \rm ${simu_folder}/namelist.wps 2> /dev/null |
---|
312 | echo '**********************************************' |
---|
313 | echo " !!! NO namelist.wps FILE FOUND !!!" |
---|
314 | echo '**********************************************' |
---|
315 | echo 'Please define the domain (not for nests for the moment) : ' |
---|
316 | echo " - 1/4 Projection: polar lambert mercator ? previous is "${proj} ; read proj |
---|
317 | echo " - 2/4 Data source (multiple if nests): 'gcm' '32ppd' '64ppd' '64ppd_noHRti' '32ppd_HRalb' ? previous is "${data_source} ; read data_source |
---|
318 | echo " - 3/4 North Latitude of domain centre ? previous is "${lat} ; read lat |
---|
319 | echo " - 4/4 East Longitude of domain centre ? previous is "${lon} ; read lon |
---|
320 | ##### |
---|
321 | sed s+"__INTERVAL_SECONDS__"+"${interval_seconds}"+g ${meso_folder}/SIMU/namelist.wps | sed s+"__MAX_DOM__"+"${max_dom}"+g | sed s+"__PARENT_ID__"+"${parent_id}"+g | sed s+"__PARENT_GRID_RATIO__"+"${parent_grid_ratio}"+g | sed s+"__I_PARENT_START__"+"${i_parent_start}"+g | sed s+"__J_PARENT_START__"+"${j_parent_start}"+g | sed s+"__E_WE__"+"${e_we}"+g | sed s+"__E_SN__"+"${e_sn}"+g | sed s+"__DX__"+"${dx}"+g | sed s+"__DY__"+"${dy}"+g | sed s+"__PROJ__"+"${proj}"+g | sed s+"__DATA_SOURCE__"+"${data_source}"+g | sed s+"__LAT__"+"${lat}"+g | sed s+"__LON__"+"${lon}"+g | sed s+'0000-00-00_00:00:00'+${year}'-'${month}'-'${day}'_'${hour}':00:00'+g | sed s+'1111-11-11_11:11:11'+${eyear}'-'${emonth}'-'${eday}'_'${ehour}':00:00'+g > ${simu_folder}/namelist.wps |
---|
322 | #### |
---|
323 | ln -sf ${simu_folder}/namelist.wps ${work_folder}/WPS/namelist.wps |
---|
324 | #vi ${work_folder}/WPS/namelist.wps |
---|
325 | echo '**********************************************' |
---|
326 | echo OK, thank you. Please wait... ncview will pop up soon ! |
---|
327 | cd ${work_folder}/WPS/ |
---|
328 | \rm geo_em.d0*.nc 2> /dev/null |
---|
329 | ./geogrid.exe > /dev/null 2> /dev/null |
---|
330 | ncview geo_em.d01.nc > /dev/null 2> /dev/null & |
---|
331 | if [[ -f "geo_em.d02.nc" ]] |
---|
332 | then |
---|
333 | ncview geo_em.d02.nc > /dev/null 2> /dev/null & |
---|
334 | fi |
---|
335 | if [[ -f "geo_em.d03.nc" ]] |
---|
336 | then |
---|
337 | ncview geo_em.d03.nc > /dev/null 2> /dev/null & |
---|
338 | fi |
---|
339 | cd ${simu_folder}/ |
---|
340 | echo '**********************************************' |
---|
341 | echo 'Are you happy with the results ? type y if yes, any key if no' ; read happy |
---|
342 | done |
---|
343 | fi |
---|
344 | ##################### |
---|
345 | if [[ ${i_want_to_compile} -ge 1 ]] |
---|
346 | then |
---|
347 | cd ${simu_folder} |
---|
348 | ## corresponding executables |
---|
349 | wrfexe=${work_folder}/wrf_x${nx}_y${ny}_z${nz}_d${nest}_t${tracers}_p${numproc}_s${scat}.exe |
---|
350 | realexe=${work_folder}/real_x${nx}_y${ny}_z${nz}_d${nest}_t${tracers}_p${numproc}_s${scat}.exe |
---|
351 | if [[ -f ${wrfexe} ]] |
---|
352 | then |
---|
353 | echo '**********************************************' |
---|
354 | echo " !!! wrf.exe exists in ${work_folder}" |
---|
355 | echo '**********************************************' |
---|
356 | echo "Recompile ? ('yes' to accept, any key to refuse)" ; read reply |
---|
357 | else |
---|
358 | reply='yes' |
---|
359 | fi |
---|
360 | echo '********************************************** OK thanks. Now please wait...' |
---|
361 | echo ' ' |
---|
362 | if [[ "${reply}" == "yes" ]] |
---|
363 | then |
---|
364 | ##################### |
---|
365 | echo "** "Begin compilation process... |
---|
366 | \rm ${wrfexe} 2> /dev/null |
---|
367 | \rm ${realexe} 2> /dev/null |
---|
368 | # |
---|
369 | # CREATE makemeso_input |
---|
370 | # |
---|
371 | \rm ${simu_folder}/makemeso_input 2> /dev/null |
---|
372 | touch ${simu_folder}/makemeso_input |
---|
373 | echo ${compilo} >> ${simu_folder}/makemeso_input |
---|
374 | if [[ "${compilo}" = "3" || "${compilo}" = "5" ]] |
---|
375 | then |
---|
376 | echo ${numproc} >> ${simu_folder}/makemeso_input |
---|
377 | fi |
---|
378 | echo ${nx} >> ${simu_folder}/makemeso_input |
---|
379 | echo ${ny} >> ${simu_folder}/makemeso_input |
---|
380 | echo ${nz} >> ${simu_folder}/makemeso_input |
---|
381 | echo ${nest} >> ${simu_folder}/makemeso_input |
---|
382 | echo ${tracers} >> ${simu_folder}/makemeso_input |
---|
383 | if [[ ${newphys} -eq 1 ]] |
---|
384 | then |
---|
385 | echo ${scat} >> ${simu_folder}/makemeso_input |
---|
386 | #echo 'n' >> ${simu_folder}/makemeso_input |
---|
387 | fi |
---|
388 | # |
---|
389 | # COMPILE THE MODEL |
---|
390 | # |
---|
391 | cd ${meso_folder} |
---|
392 | if [[ "${changeregis}" = "1" ]] |
---|
393 | then |
---|
394 | cd ${work_folder}/WRFV2/Registry |
---|
395 | \rm Registry 2> /dev/null |
---|
396 | ./Registry.bash |
---|
397 | cd ../../.. |
---|
398 | fi |
---|
399 | |
---|
400 | ##****** |
---|
401 | if [[ ${newphys} -eq 0 ]] |
---|
402 | then |
---|
403 | ./makemeso -r < ${simu_folder}/makemeso_input |
---|
404 | else |
---|
405 | if [[ "${scenario}" == "" ]] |
---|
406 | then |
---|
407 | ./makemeso -r -p < ${simu_folder}/makemeso_input |
---|
408 | else |
---|
409 | ./makemeso -r -p -s ${scenario} < ${simu_folder}/makemeso_input |
---|
410 | fi |
---|
411 | fi |
---|
412 | ##****** |
---|
413 | |
---|
414 | |
---|
415 | if [[ -f ${wrfexe} ]] |
---|
416 | then |
---|
417 | echo "** "seems OK ... linking executables |
---|
418 | ln -sf ${wrfexe} ${simu_folder}/wrf.exe |
---|
419 | ln -sf ${realexe} ${simu_folder}/real.exe |
---|
420 | chmod a+x ${realexe} ${wrfexe} ## sait-on jamais |
---|
421 | cd $simu_folder |
---|
422 | else |
---|
423 | echo no ${wrfexe} |
---|
424 | echo problem with the compilation |
---|
425 | exit |
---|
426 | fi |
---|
427 | else |
---|
428 | #echo simply linking existing executables... |
---|
429 | ln -sf ${wrfexe} ${simu_folder}/wrf.exe |
---|
430 | ln -sf ${realexe} ${simu_folder}/real.exe |
---|
431 | chmod a+x ${realexe} ${wrfexe} ## sait-on jamais |
---|
432 | fi |
---|
433 | fi |
---|
434 | |
---|
435 | ###################################### |
---|
436 | # 1. RUN GCM FOR INIT/BDY CONDITIONS # |
---|
437 | ###################################### |
---|
438 | if [ ${gcmstep} -eq 1 ] |
---|
439 | then |
---|
440 | echo '************************************' |
---|
441 | echo '**** Step 1: Prepare GCM inputs ****' |
---|
442 | echo '************************************' |
---|
443 | # |
---|
444 | # run GCM |
---|
445 | # |
---|
446 | if [[ ${newphys} -eq 0 ]] |
---|
447 | then |
---|
448 | cd ${main_folder}'/LMDZ.MARS/myGCM' |
---|
449 | else |
---|
450 | cd ${main_folder}'/LMDZ.MARS.new/myGCM' |
---|
451 | fi |
---|
452 | #echo '(during the run, you might like to check domain settings in '${work_folder}'/WPS)' |
---|
453 | echo ${daygcm} | ./launch_gcm |
---|
454 | # |
---|
455 | # prepare files for WPS |
---|
456 | # |
---|
457 | cd ${work_folder} |
---|
458 | if [[ -f ${work_folder}/PREP_MARS/create_readmeteo.exe && -f ${work_folder}/PREP_MARS/readmeteo.exe ]] |
---|
459 | then |
---|
460 | cd ${work_folder}/PREP_MARS/ |
---|
461 | ./compile_and_exec |
---|
462 | #echo 1 | ./create_readmeteo.exe |
---|
463 | #./readmeteo.exe < readmeteo.def |
---|
464 | else |
---|
465 | echo please compile the PREP_MARS utilities in ${work_folder} |
---|
466 | exit |
---|
467 | fi |
---|
468 | fi |
---|
469 | |
---|
470 | ################################### |
---|
471 | # 2. RUN WRF PREPROCESSING SYSTEM # |
---|
472 | ################################### |
---|
473 | if [ ${wpsstep} -eq 1 ] |
---|
474 | then |
---|
475 | echo '*****************************************' |
---|
476 | echo '**** Step 2: Perform WPS interpolations *' |
---|
477 | echo '*****************************************' |
---|
478 | if [[ -f ${work_folder}/WPS/geogrid.exe && -f ${work_folder}/WPS/metgrid.exe ]] |
---|
479 | then |
---|
480 | \rm -rf ${simu_folder}/met_em 2> /dev/null |
---|
481 | mkdir ${simu_folder}/met_em |
---|
482 | cd ${work_folder}/WPS/ |
---|
483 | \rm -rf ${work_folder}/WPS/WRFFEED/current 2> /dev/null |
---|
484 | mkdir ${work_folder}/WPS/WRFFEED/current |
---|
485 | ln -sf ${simu_folder}/namelist.wps ${work_folder}/WPS/namelist.wps |
---|
486 | #mv namelist.wps namelist.wps.tmp |
---|
487 | #sed s+'0000-00-00_00:00:00'+${year}'-'${month}'-'${day}'_'${hour}':00:00'+g namelist.wps.tmp | sed s+'1111-11-11_11:11:11'+${eyear}'-'${emonth}'-'${eday}'_'${ehour}':00:00'+g > namelist.wps |
---|
488 | ./geogrid.exe |
---|
489 | ./metgrid.exe |
---|
490 | #mv namelist.wps ${simu_folder} |
---|
491 | #mv namelist.wps.tmp namelist.wps |
---|
492 | namedata=$(date +simu_%d%h%Y_%H%M) |
---|
493 | mv ${work_folder}/WPS/WRFFEED/current ${work_folder}'/WPS/WRFFEED/'${namedata} |
---|
494 | echo met_em files in $namedata |
---|
495 | cd ${simu_folder}/met_em |
---|
496 | ln -sf ${work_folder}/WPS/WRFFEED/${namedata}/* . |
---|
497 | cd ${simu_folder} |
---|
498 | else |
---|
499 | echo please compile the WPS utilities in ${work_folder} |
---|
500 | exit |
---|
501 | fi |
---|
502 | fi |
---|
503 | |
---|
504 | ################### |
---|
505 | # 3. RUN REAL.EXE # |
---|
506 | ################### |
---|
507 | if [ ${realstep} -eq 1 ] |
---|
508 | then |
---|
509 | echo '*******************************' |
---|
510 | echo '**** Step 3: Execute real.exe *' |
---|
511 | echo '*******************************' |
---|
512 | cd ${simu_folder} |
---|
513 | if [[ ! -d met_em ]] |
---|
514 | then |
---|
515 | ls |
---|
516 | echo "PB: no met_em files:" |
---|
517 | echo "mkdir met_em folder then link met_em** files !" |
---|
518 | exit |
---|
519 | fi |
---|
520 | cd ${simu_folder}/met_em |
---|
521 | ln -sf ${simu_folder}/namelist.input . |
---|
522 | ln -sf ${simu_folder}/real.exe . |
---|
523 | rm -rf ${simu_folder}/met_em/wrfbdy* 2> /dev/null |
---|
524 | rm -rf ${simu_folder}/met_em/wrfinput* 2> /dev/null |
---|
525 | if [[ ${compilo} -eq 3 ]] |
---|
526 | then |
---|
527 | rm -rf ${simu_folder}/met_em/rsl.* 2> /dev/null |
---|
528 | echo "check in "${simu_folder}"/met_em/rsl.out.0000" |
---|
529 | ./real.exe |
---|
530 | tail -n 4 ${simu_folder}"/met_em/rsl.out.0000" |
---|
531 | else |
---|
532 | rm -rf ${simu_folder}/met_em/log* 2> /dev/null |
---|
533 | echo "check in "${simu_folder}"/met_em/log_real" |
---|
534 | real.exe > log_real |
---|
535 | tail -n 4 ${simu_folder}"/met_em/log_real" |
---|
536 | fi |
---|
537 | if [[ -f ${simu_folder}/met_em/wrfinput_d01 && -f ${simu_folder}/met_em/wrfbdy_d01 ]] |
---|
538 | then |
---|
539 | echo ok... link ini and bdy conditions |
---|
540 | cd ${simu_folder} |
---|
541 | ln -sf ${simu_folder}/met_em/wrf*_d0* . |
---|
542 | else |
---|
543 | echo mmm... there was a problem, see log files in met_em |
---|
544 | exit |
---|
545 | fi |
---|
546 | fi |
---|
547 | |
---|
548 | ################## |
---|
549 | # 4. RUN WRF.EXE # |
---|
550 | ################## |
---|
551 | if [ ${wrfstep} -eq 1 ] |
---|
552 | then |
---|
553 | xeyes & |
---|
554 | echo '******************************' |
---|
555 | echo '**** Step 4: Execute wrf.exe *' |
---|
556 | echo '******************************' |
---|
557 | cd ${simu_folder} |
---|
558 | rm -rf ${simu_folder}/wrfout* |
---|
559 | if [[ ${compilo} -eq 3 ]] |
---|
560 | then |
---|
561 | rm -rf ${simu_folder}/rsl.* 2> /dev/null |
---|
562 | # ${WHERE_MPI}/mpirun -host smith -np ${numproc} wrf.exe < /dev/null & |
---|
563 | ${WHERE_MPI}/mpirun -np ${numproc} wrf.exe < /dev/null & |
---|
564 | else |
---|
565 | rm -rf ${simu_folder}/log* 2> /dev/null |
---|
566 | nohup wrf.exe > log_wrf & |
---|
567 | fi |
---|
568 | echo OK ! Simulation should be running now ! |
---|
569 | echo Check with the command: "ps -e -o '%u %p %C %x %c' | grep wrf.exe" |
---|
570 | echo '******************************' |
---|
571 | echo '**** End.' |
---|
572 | |
---|
573 | fi |
---|
574 | exit |
---|
575 | |
---|
576 | |
---|
577 | |
---|