source: trunk/MESOSCALE/LMD_MM_MARS/SIMU/runmeso @ 482

Last change on this file since 482 was 482, checked in by aslmd, 13 years ago

MESOSCALE: forgot to update runmeso.

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