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