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