source: trunk/mesoscale/LMD_MM_MARS/SIMU/runmeso @ 73

Last change on this file since 73 was 60, checked in by aslmd, 14 years ago

LMD_MM_MARS et LMD_LES_MARS: ajouts de scripts et modifications runmeso/makeles/makemeso pour faire tourner le modele sur iDataPlex. premiers tests en parallele fonctionnent tres bien. le run 16procs est bien 4fois rapide que le run 4procs sur la ferme planeto. resultats totalement similaires 4procs TESTCASE entre auric et gnome (a part amortissement vitesse verticale aux premiers pas de temps). le LES fonctionne bien lui aussi, cependant il y a un bug a corriger relatif a un flux de chaleur sensible nul aux points d'interfaces entre 4 tuiles. ------ petite remarque sur LMDZ5: un job 24proc est 10fois plus rapide qu'un job 8proc absolument equivalent sur ciclad.

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