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