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

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

USERS: ajout 2 personnes

LMD_MM_MARS: changements mineurs

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