[194] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | function print() |
---|
| 4 | { |
---|
| 5 | # prints one comment line followed by any number of "key = value" lines |
---|
| 6 | echo "# $1 : $2 (default=$3)" |
---|
| 7 | shift; shift; shift; |
---|
| 8 | while (($# > 0)) ; do |
---|
| 9 | echo "$1 = $2" |
---|
| 10 | shift; shift; |
---|
| 11 | done |
---|
| 12 | echo |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | ################################### Planet ####################################### |
---|
| 16 | |
---|
[215] | 17 | function radius { print 'Planetary radius' real 6371220 radius $1 |
---|
[194] | 18 | } |
---|
| 19 | function g { print Gravity real 9.80616 g $1 |
---|
| 20 | } |
---|
| 21 | function omega { print 'Planetary rotation rate' real 7.292E-5 omega $1 |
---|
| 22 | } |
---|
| 23 | function kappa { print 'kappa=Rd/cpp' real 0.2857143 kappa $1 |
---|
| 24 | } |
---|
| 25 | function cpp { print 'Heat capacity at constant pressure' real 1004.70885 cpp $1 |
---|
| 26 | } |
---|
| 27 | function preff { print 'Reference pressure' real 101325 preff $1 |
---|
| 28 | } |
---|
| 29 | function scale_factor { print 'Scale factor for small planet experiment' real 1. scale_factor $1 |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | ##################################### Mesh ##################################### |
---|
| 33 | |
---|
| 34 | function nbp { print 'Number of subdivisions on a main triangle' integer 40 nbp $1 |
---|
| 35 | } |
---|
| 36 | function split { print 'Sub splitting of main rhombus' integer 1 nsplit_i $1 nsplit_j $2 |
---|
| 37 | } |
---|
| 38 | function llm { print 'Number of vertical layers' integer 19 llm $1 |
---|
| 39 | } |
---|
[195] | 40 | function disvert { print 'Vertical grid' '[std|ncar|ncarl30]' std disvert $1 |
---|
[194] | 41 | } |
---|
| 42 | function ncar_dz { print 'Model layer thickness in m, used if disvert=ncar' real 300 ncar_dz $1 |
---|
| 43 | } |
---|
| 44 | function optim_it { print 'Mesh optimisation : number of iterations' integer 0 optim_it $1 |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | ################################# Numerics ################################### |
---|
| 48 | |
---|
| 49 | function scheme { print 'Time-stepping scheme' '[euler|leapfrog_matsuno|runge_kutta]' runge_kutta scheme $1 |
---|
| 50 | } |
---|
| 51 | function time_step { print 'Time step in s' real 480 dt $1 |
---|
| 52 | } |
---|
| 53 | function matsuno { print 'Matsuno period' integer 5 matsuno_period $1 |
---|
| 54 | } |
---|
| 55 | function itau_adv { print 'Advection called every itau_adv time steps' integer 2 itau_adv $1 |
---|
| 56 | } |
---|
[217] | 57 | function nqtot { print 'Number of tracers' integer 1 nqtot $1 |
---|
[194] | 58 | } |
---|
| 59 | function caldyn { print 'Equations solved' '[gcm|adv]' gcm caldyn $1 |
---|
| 60 | } |
---|
[195] | 61 | function caldyn_conserv { print 'Discretization of Coriolis term' '[energy|enstophy]' energy caldyn_conserv $1 |
---|
[194] | 62 | } |
---|
| 63 | function caldyn_eta { print 'Vertical coordinate' '[eta_mass|eta_lag]' mass caldyn_eta $1 |
---|
| 64 | } |
---|
| 65 | function boussinesq { print 'Boussinesq approximation, requires eta_lag' '[.FALSE.|.TRUE.]' .FALSE. boussinesq $1 |
---|
| 66 | } |
---|
| 67 | ############################### Time and output ############################### |
---|
| 68 | |
---|
| 69 | function time_style() { print 'Time style' '[none|lmd]' lmd time_style $1 |
---|
| 70 | } |
---|
| 71 | function ndays() { print 'Number of days' integer ?? ndays $1 |
---|
| 72 | } |
---|
| 73 | function run_length() { print 'Run length in s' real ?? run_length $1 |
---|
| 74 | } |
---|
| 75 | function day_step { print 'Number of time steps per day' integer ?? day_step $1 |
---|
| 76 | } |
---|
| 77 | function write_period { print 'Interval in s between two outputs' integer ?? write_period $1 |
---|
| 78 | } |
---|
| 79 | function out_pressure_level { print 'Pressure level to which interpolate T' real 0 out_pression_level $1 |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | ################################ Physics ###################################### |
---|
| 83 | |
---|
| 84 | function etat0 { |
---|
| 85 | OPTS=$(printf '\n# [jablonowsky06|academic|dcmip[1-4]|heldsz|dcmip2_schaer_noshear|dcmip3]') |
---|
[217] | 86 | print 'Initial state' "$OPTS" jablonowsky06 etat0 $1 |
---|
[194] | 87 | } |
---|
| 88 | function dissip |
---|
| 89 | { |
---|
| 90 | print 'Dissipation time for grad(div)' real 5000 tau_graddiv $1 |
---|
| 91 | print 'Exponent of grad(div) disspation' integer 1 nitergdiv $2 |
---|
| 92 | print 'Dissipation time for curl(curl)' real 5000 tau_gradrot $3 |
---|
[195] | 93 | print 'Exponent of curl(curl) disspation' integer 1 nitergrot $4 |
---|
| 94 | print 'Dissipation time for div(grad)' real 5000 tau_divgrad $5 |
---|
| 95 | print 'Exponent of div(grad) disspation' integer 1 niterdivgrad $6 |
---|
[194] | 96 | } |
---|
| 97 | function guided_type { print 'Type of guiding terms' '[none|dcmip1]' none guided_type $1 |
---|
| 98 | } |
---|
| 99 | |
---|
[217] | 100 | function physics { print 'Physics package' '[none|held_suarez|dcmip]' none physics $1 |
---|
[194] | 101 | } |
---|
| 102 | |
---|
[215] | 103 | function itau_physics { print 'Call physics every itau_physics time steps' 'integer' 1 itau_physics $1 |
---|
| 104 | } |
---|
| 105 | |
---|
[194] | 106 | #################################### DCMIP ################################# |
---|
[197] | 107 | |
---|
[194] | 108 | function dcmip1_def() |
---|
| 109 | { |
---|
[249] | 110 | etat0 dcmip1 |
---|
[194] | 111 | OPTS=$(printf '\n# [const|slotted_cyl|cos_bell|dbl_cos_bell_q1|dbl_cos_bell_q2|complement|hadley|dcmip11]') |
---|
| 112 | print 'DCMIP 1.1 advection test, initial tracer field' "$OPTS" cos_bell dcmip1_shape $1 |
---|
[249] | 113 | print 'DCMIP 1.1 advection test, wind field' '[solid|deform|hadley]' deform dcmip1_wind $2 |
---|
[194] | 114 | } |
---|
| 115 | function dcmip_refs() |
---|
| 116 | { |
---|
| 117 | print 'Reference temperature T0 for DCMIP test cases' real 300 ncar_T0 $1 |
---|
| 118 | print 'Reference pressure p0 for DCMIP test cases, used by disvert if disver=ncar' real 1e5 ncar_p0 $2 |
---|
| 119 | print 'Exponent for B(eta), used by disvert if disvert=ncar' integer 1 ncar_disvert_c $3 |
---|
| 120 | } |
---|
| 121 | function dcmip_physics() |
---|
| 122 | { |
---|
| 123 | physics dcmip |
---|
| 124 | print 'DCMIP physics' '[0|1]' 1 dcmip_physics $1 |
---|
| 125 | } |
---|
| 126 | function dcmip4_testcase { print 'DCMIP 4 Test case' '[1|2]' 1 dcmip4_testcase $1 |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | ####################### Functions generating parameter files #################### |
---|
| 130 | |
---|
| 131 | function params { |
---|
| 132 | # executes any number of "command arg" commands |
---|
| 133 | while (($# > 0)) ; do |
---|
| 134 | $1 $2 |
---|
| 135 | shift; shift; |
---|
| 136 | done |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | function group { |
---|
| 140 | # prints one separation line then executes any number of "command arg" commands |
---|
| 141 | echo |
---|
| 142 | echo "#---------------- $1 ----------------" |
---|
| 143 | echo |
---|
| 144 | shift |
---|
| 145 | params $* |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | function williamson91() |
---|
| 149 | { |
---|
| 150 | group 'Mesh' nbp 40 llm 1 optim_it 100 ; split 2 2 |
---|
[197] | 151 | group 'Numerics' time_step 480 caldyn_conserv enstrophy |
---|
[194] | 152 | group 'Time and output' out_pressure_level 85000 write_period 21600 run_length 864000 |
---|
| 153 | group 'Physical parameters' radius 6.37122e6 g 9.80616 caldyn_eta eta_lag boussinesq .TRUE. etat0 williamson91.6 |
---|
| 154 | dissip 5000 2 5000 2 5000 2 |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | function held_suarez() |
---|
| 158 | { |
---|
| 159 | group 'Mesh' nbp 40 llm 19 disvert std optim_it 1000 ; split 2 2 |
---|
[197] | 160 | group 'Numerics' itau_adv 1 day_step 180 |
---|
[194] | 161 | group 'Time' time_style lmd ndays 1200 write_period 86400 |
---|
[197] | 162 | group 'Planet' radius 6.371e6 g 9.8 omega 7.292e-5 kappa 0.2857143 cpp 1004 preff 1e5 |
---|
[217] | 163 | group 'Physical parameters' etat0 held_suarez physics held_suarez |
---|
[194] | 164 | dissip 50000 2 50000 2 50000 2 |
---|
| 165 | } |
---|
| 166 | |
---|
| 167 | function const_dcmip |
---|
| 168 | { |
---|
| 169 | group 'Planet' radius 6.37122e6 g 9.80616 kappa 0.2857143 cpp 1004.5 preff 1e5 omega $1 |
---|
| 170 | group 'Constants' ; dcmip_refs 300 1e5 1 |
---|
| 171 | } |
---|
| 172 | |
---|
| 173 | function dcmip11 |
---|
| 174 | { |
---|
| 175 | echo 'INCLUDEDEF = const.def' |
---|
| 176 | group 'Mesh' nbp 80 llm 60 disvert ncar ncar_dz 200 optim_it 100 ; split 2 2 |
---|
[197] | 177 | group 'Numerics' caldyn adv time_step 180 |
---|
[194] | 178 | group 'Time' run_length 1036800 write_period 86400 |
---|
[249] | 179 | group 'Physical parameters' nqtot 5 guided_type dcmip1 ; dcmip1_def dcmip11 deform |
---|
[194] | 180 | } |
---|
| 181 | |
---|
| 182 | function dcmip21 |
---|
| 183 | { |
---|
| 184 | echo 'INCLUDEDEF = const.def' |
---|
| 185 | group 'Mesh' nbp 64 llm 60 disvert ncar ncar_dz 500 optim_it 100 ; split 2 2 |
---|
[197] | 186 | group 'Numerics' time_step 300 |
---|
[194] | 187 | dissip 1800 1 1800 2 1800 2 |
---|
| 188 | group 'Time' run_length 3.6e6 write_period 50000 |
---|
[217] | 189 | group 'Physical parameters' scale_factor 500 guided_type dcmip1 etat0 dcmip2_schaer_noshear |
---|
[194] | 190 | } |
---|
| 191 | |
---|
| 192 | function dcmip3 |
---|
| 193 | { |
---|
| 194 | const_dcmip 0 |
---|
| 195 | group 'Mesh' nbp 80 llm 10 disvert ncar ncar_dz 1000 optim_it 100 ; split 2 2 |
---|
[197] | 196 | group 'Numerics' time_step 240 |
---|
[194] | 197 | dissip 1800 1 1800 2 1800 2 |
---|
| 198 | group 'Time' run_length 4.5e5 write_period 12500 |
---|
[217] | 199 | group 'Physical parameters' omega 0 scale_factor 125 etat0 dcmip3 |
---|
[194] | 200 | } |
---|
| 201 | |
---|
[197] | 202 | function dcmip4x |
---|
[194] | 203 | { |
---|
| 204 | echo 'INCLUDEDEF = const.def' |
---|
[195] | 205 | group 'Mesh' nbp 80 llm 30 disvert ncarl30 optim_it 100 ; split 2 2 |
---|
[197] | 206 | group 'Numerics' time_step 240 |
---|
[194] | 207 | dissip 1800 1 1800 2 1800 2 |
---|
| 208 | group 'Time' run_length 3.6e6 write_period 21600 |
---|
[197] | 209 | group 'Physical parameters' nqtot 2 etat0 dcmip4 dcmip4_testcase $1 |
---|
[194] | 210 | } |
---|
| 211 | |
---|
[197] | 212 | function dcmip42 |
---|
[194] | 213 | { |
---|
[197] | 214 | dcmip4x 2 |
---|
| 215 | dcmip_physics 1 |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | function dcmip51 |
---|
| 219 | { |
---|
[194] | 220 | echo 'INCLUDEDEF = const.def' |
---|
[195] | 221 | group 'Mesh' nbp 64 llm 30 disvert ncarl30 optim_it 1000 ; split 2 2 |
---|
[197] | 222 | group 'Numerics' time_step 300 |
---|
[194] | 223 | dissip 10800 1 10800 2 10800 2 |
---|
| 224 | group 'Time' run_length 864000 write_period 7200 |
---|
[215] | 225 | group 'Physical parameters' nqtot 1 etat0 dcmip5 dcmip_physics 0 itau_physics 6 |
---|
[194] | 226 | } |
---|
| 227 | |
---|
| 228 | ########## Main program : generate all *.def files in param_sets ############## |
---|
| 229 | |
---|
| 230 | function mkcd { cd $ROOT ; mkdir -p $1 ; cd $1 |
---|
| 231 | } |
---|
| 232 | |
---|
| 233 | set -o errexit |
---|
| 234 | ROOT=$PWD |
---|
| 235 | |
---|
| 236 | mkcd climate/Held_Suarez |
---|
| 237 | held_suarez > run.def |
---|
| 238 | |
---|
| 239 | mkcd shallow_water/williamson91 |
---|
| 240 | williamson91 > run6.def |
---|
| 241 | |
---|
| 242 | mkcd dcmip2012 |
---|
| 243 | const_dcmip 7.292e-5 > const.def |
---|
| 244 | dcmip11 > run11.def |
---|
| 245 | dcmip21 > run21.def |
---|
| 246 | dcmip3 > run3.def |
---|
[197] | 247 | dcmip4x 1 > run41.def |
---|
[194] | 248 | dcmip42 > run42.def |
---|
[197] | 249 | dcmip51 > run51.def |
---|