| [4065] | 1 | MODULE config |
|---|
| [3991] | 2 | !----------------------------------------------------------------------- |
|---|
| 3 | ! NAME |
|---|
| [4065] | 4 | ! config |
|---|
| [2980] | 5 | ! |
|---|
| [3991] | 6 | ! DESCRIPTION |
|---|
| 7 | ! Read and apply parameters for a PEM run from run_pem.def. |
|---|
| [2980] | 8 | ! |
|---|
| [3991] | 9 | ! AUTHORS & DATE |
|---|
| 10 | ! R. Vandemeulebrouck |
|---|
| 11 | ! JB Clement, 2023-2025 |
|---|
| 12 | ! |
|---|
| 13 | ! NOTES |
|---|
| 14 | ! |
|---|
| 15 | !----------------------------------------------------------------------- |
|---|
| [2980] | 16 | |
|---|
| [4065] | 17 | ! DEPENDENCIES |
|---|
| 18 | ! ------------ |
|---|
| 19 | use numerics, only: dp, di, k4, minieps |
|---|
| 20 | |
|---|
| [3991] | 21 | ! DECLARATION |
|---|
| 22 | ! ----------- |
|---|
| [3076] | 23 | implicit none |
|---|
| [2859] | 24 | |
|---|
| [4110] | 25 | character(7), parameter, private :: rundef_name = 'run.def' |
|---|
| 26 | character(11), parameter, private :: runPCMdef_name = 'run_pcm.def' |
|---|
| 27 | character(12), parameter :: callphys_name = 'callphys.def' |
|---|
| [4065] | 28 | |
|---|
| [3076] | 29 | contains |
|---|
| [3991] | 30 | !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|---|
| 31 | |
|---|
| [3076] | 32 | !======================================================================= |
|---|
| [4065] | 33 | SUBROUTINE read_rundef() |
|---|
| [3991] | 34 | !----------------------------------------------------------------------- |
|---|
| 35 | ! NAME |
|---|
| 36 | ! read_rundef |
|---|
| 37 | ! |
|---|
| 38 | ! DESCRIPTION |
|---|
| [4065] | 39 | ! Read PEM runtime configuration from getin keys, then set |
|---|
| 40 | ! module-scoped parameters accordingly. |
|---|
| [3991] | 41 | ! |
|---|
| 42 | ! AUTHORS & DATE |
|---|
| 43 | ! R. Vandemeulebrouck |
|---|
| 44 | ! JB Clement, 2023-2025 |
|---|
| 45 | ! |
|---|
| 46 | ! NOTES |
|---|
| 47 | ! |
|---|
| 48 | !----------------------------------------------------------------------- |
|---|
| [2859] | 49 | |
|---|
| [3991] | 50 | ! DEPENDENCIES |
|---|
| 51 | ! ------------ |
|---|
| [2864] | 52 | #ifdef CPP_IOIPSL |
|---|
| [4065] | 53 | use IOIPSL, only: getin |
|---|
| [2864] | 54 | #else |
|---|
| [4065] | 55 | ! If not using IOIPSL, we still need to use (a local version of) getin |
|---|
| 56 | use ioipsl_getincom, only: getin |
|---|
| [2864] | 57 | #endif |
|---|
| [4065] | 58 | use evolution, only: set_evolution_config |
|---|
| 59 | use stopping_crit, only: set_stopping_crit_config |
|---|
| 60 | use soil, only: set_soil_config |
|---|
| 61 | use sorption, only: set_sorption_config |
|---|
| 62 | use glaciers, only: set_glaciers_config |
|---|
| 63 | use surf_ice, only: set_surf_ice_config |
|---|
| 64 | use ice_table, only: set_ice_table_config |
|---|
| 65 | use layered_deposits, only: set_layered_deposits_config |
|---|
| 66 | use output, only: set_output_config |
|---|
| 67 | use orbit, only: set_orbit_config |
|---|
| 68 | use atmosphere, only: set_atmosphere_config |
|---|
| 69 | use stoppage, only: stop_clean |
|---|
| [4110] | 70 | use display, only: print_msg, LVL_NFO |
|---|
| [2893] | 71 | |
|---|
| [3991] | 72 | ! DECLARATION |
|---|
| 73 | ! ----------- |
|---|
| [3076] | 74 | implicit none |
|---|
| [3039] | 75 | |
|---|
| [3991] | 76 | ! LOCAL VARIABLES |
|---|
| 77 | ! --------------- |
|---|
| [4110] | 78 | logical(k4) :: here, evo_orbit_l, evo_obl_l, evo_ecc_l, evo_lsp_l, do_soil_l, reg_thprop_dependp_l, do_sorption_l, hybrid |
|---|
| [4065] | 79 | logical(k4) :: icetable_equilibrium_l, icetable_dynamic_l, h2oice_flow_l, co2ice_flow_l, do_layering_l, impose_dust_ratio_l |
|---|
| 80 | integer(di) :: output_rate_l |
|---|
| [4072] | 81 | integer(di) :: pem_ini_earth_date ! Initial year (in Earth years) of the PEM workflow defined in "run.def" |
|---|
| [4065] | 82 | real(dp) :: dt_l, nmax_yr_run_l, h2oice_crit_l, co2ice_crit_l, ps_crit_l, max_change_obl_l, max_change_ecc_l, max_change_lsp_l |
|---|
| 83 | real(dp) :: flux_geo_l, depth_breccia_l, depth_bedrock_l, threshold_h2oice_cap_l, h2oice_huge_ini_l, d_dust_l, dust2ice_ratio_l |
|---|
| [3076] | 84 | |
|---|
| [3991] | 85 | ! CODE |
|---|
| 86 | ! ---- |
|---|
| [4065] | 87 | inquire(file = rundef_name,exist = here) |
|---|
| 88 | if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//rundef_name//'" (PEM)!',1) |
|---|
| [4110] | 89 | call print_msg('> Reading "'//rundef_name//'"',LVL_NFO) |
|---|
| [2918] | 90 | |
|---|
| [4110] | 91 | ! Outputs |
|---|
| 92 | ! ~~~~~~~ |
|---|
| [4065] | 93 | output_rate_l = 1_di ! Default value: every year |
|---|
| 94 | call getin('output_rate',output_rate_l) |
|---|
| [3082] | 95 | |
|---|
| [4065] | 96 | ! Orbital parameters |
|---|
| 97 | ! ~~~~~~~~~~~~~~~~~~ |
|---|
| [4110] | 98 | evo_orbit_l = .false. |
|---|
| 99 | call getin('evo_orbit',evo_orbit_l) |
|---|
| [2918] | 100 | |
|---|
| [4065] | 101 | pem_ini_earth_date = 0_di |
|---|
| 102 | call getin('pem_ini_earth_date',pem_ini_earth_date) |
|---|
| [2859] | 103 | |
|---|
| [4110] | 104 | evo_obl_l = .true. |
|---|
| 105 | call getin('evo_obl',evo_obl_l) |
|---|
| [2859] | 106 | |
|---|
| [4110] | 107 | evo_ecc_l = .true. |
|---|
| 108 | call getin('evo_ecc',evo_ecc_l) |
|---|
| [2963] | 109 | |
|---|
| [4110] | 110 | evo_lsp_l = .true. |
|---|
| 111 | call getin('evo_lsp',evo_lsp_l) |
|---|
| [2963] | 112 | |
|---|
| [4065] | 113 | dt_l = 1._dp |
|---|
| 114 | call getin('dt',dt_l) |
|---|
| [2963] | 115 | |
|---|
| [4065] | 116 | ! Stopping criteria |
|---|
| 117 | ! ~~~~~~~~~~~~~~~~~ |
|---|
| 118 | nmax_yr_run_l = 100000000._dp |
|---|
| 119 | call getin('nmax_yr_run',nmax_yr_run_l) |
|---|
| [2859] | 120 | |
|---|
| [4065] | 121 | h2oice_crit_l = 0.2_dp |
|---|
| 122 | call getin('h2oice_crit',h2oice_crit_l) |
|---|
| [2893] | 123 | |
|---|
| [4065] | 124 | co2ice_crit_l = 0.2_dp |
|---|
| 125 | call getin('co2ice_crit',co2ice_crit_l) |
|---|
| [2888] | 126 | |
|---|
| [4065] | 127 | ps_crit_l = 0.15_dp |
|---|
| 128 | call getin('ps_crit',ps_crit_l) |
|---|
| [2859] | 129 | |
|---|
| [4065] | 130 | max_change_obl_l = 1._dp |
|---|
| 131 | call getin('max_change_obl',max_change_obl_l) |
|---|
| [2859] | 132 | |
|---|
| [4065] | 133 | max_change_ecc_l = 5.e-3_dp |
|---|
| 134 | call getin('max_change_ecc',max_change_ecc_l) |
|---|
| [2888] | 135 | |
|---|
| [4065] | 136 | max_change_lsp_l = 20._dp |
|---|
| 137 | call getin('max_change_lsp',max_change_lsp_l) |
|---|
| [2963] | 138 | |
|---|
| [4065] | 139 | ! Subsurface |
|---|
| 140 | ! ~~~~~~~~~~ |
|---|
| 141 | do_soil_l = .true. |
|---|
| 142 | call getin('do_soil',do_soil_l) |
|---|
| [2894] | 143 | |
|---|
| [4065] | 144 | do_sorption_l = .false. |
|---|
| 145 | call getin('do_sorption',do_sorption_l) |
|---|
| [2895] | 146 | |
|---|
| [4065] | 147 | reg_thprop_dependp_l = .false. |
|---|
| 148 | call getin('reg_thprop_dependp',reg_thprop_dependp_l) |
|---|
| [2895] | 149 | |
|---|
| [4065] | 150 | flux_geo_l = 0._dp |
|---|
| 151 | call getin('flux_geo',flux_geo_l) |
|---|
| [2961] | 152 | |
|---|
| [4065] | 153 | depth_breccia_l = 10._dp |
|---|
| 154 | call getin('depth_breccia',depth_breccia_l) |
|---|
| [2894] | 155 | |
|---|
| [4065] | 156 | depth_bedrock_l = 1000._dp |
|---|
| 157 | call getin('depth_bedrock',depth_bedrock_l) |
|---|
| [2895] | 158 | |
|---|
| [4065] | 159 | icetable_equilibrium_l = .true. |
|---|
| 160 | call getin('icetable_equilibrium',icetable_equilibrium_l) |
|---|
| [2895] | 161 | |
|---|
| [4065] | 162 | icetable_dynamic_l = .false. |
|---|
| 163 | call getin('icetable_dynamic',icetable_dynamic_l) |
|---|
| [2859] | 164 | |
|---|
| [4065] | 165 | ! Ice management |
|---|
| 166 | ! ~~~~~~~~~~~~~~ |
|---|
| 167 | h2oice_huge_ini_l = 9200._dp ! [kg/m^2]; Default = 10 m |
|---|
| 168 | call getin('h2oice_huge_ini',h2oice_huge_ini_l) |
|---|
| [3076] | 169 | |
|---|
| [4065] | 170 | threshold_h2oice_cap_l = 460._dp ! kg.m-2 (= 0.5 m) |
|---|
| 171 | call getin('threshold_h2oice_cap',threshold_h2oice_cap_l) |
|---|
| [3076] | 172 | |
|---|
| [4065] | 173 | h2oice_flow_l = .true. |
|---|
| 174 | call getin('h2oice_flow',h2oice_flow_l) |
|---|
| [3159] | 175 | |
|---|
| [4065] | 176 | co2ice_flow_l = .true. |
|---|
| 177 | call getin('co2ice_flow',co2ice_flow_l) |
|---|
| [3161] | 178 | |
|---|
| [4065] | 179 | ! Layering |
|---|
| 180 | ! ~~~~~~~~ |
|---|
| 181 | do_layering_l = .false. |
|---|
| 182 | call getin('do_layering',do_layering_l) |
|---|
| [3161] | 183 | |
|---|
| [4065] | 184 | d_dust_l = 5.78e-2_dp ! kg.m-2.y-1 (= 1.e-9 kg.m-2.s-1) |
|---|
| 185 | call getin('d_dust',d_dust_l) |
|---|
| [3319] | 186 | |
|---|
| [4065] | 187 | impose_dust_ratio_l = .false. |
|---|
| 188 | call getin('impose_dust_ratio',impose_dust_ratio_l) |
|---|
| [3821] | 189 | |
|---|
| [4065] | 190 | dust2ice_ratio_l = 0.01_dp |
|---|
| 191 | call getin('dust2ice_ratio',dust2ice_ratio_l) |
|---|
| [3821] | 192 | |
|---|
| [4065] | 193 | ! Setters |
|---|
| 194 | call set_output_config(output_rate_l) |
|---|
| [4110] | 195 | call set_orbit_config(evo_orbit_l,evo_obl_l,evo_ecc_l,evo_lsp_l,max_change_obl_l,max_change_ecc_l,max_change_lsp_l) |
|---|
| [4065] | 196 | call set_evolution_config(pem_ini_earth_date,dt_l,nmax_yr_run_l) |
|---|
| 197 | call set_stopping_crit_config(h2oice_crit_l,co2ice_crit_l,ps_crit_l) |
|---|
| 198 | call set_soil_config(do_soil_l,reg_thprop_dependp_l,flux_geo_l,depth_breccia_l,depth_bedrock_l) |
|---|
| 199 | call set_sorption_config(do_sorption_l) |
|---|
| 200 | call set_ice_table_config(icetable_equilibrium_l,icetable_dynamic_l) |
|---|
| 201 | call set_surf_ice_config(threshold_h2oice_cap_l,h2oice_huge_ini_l) |
|---|
| 202 | call set_glaciers_config(h2oice_flow_l,co2ice_flow_l) |
|---|
| 203 | call set_layered_deposits_config(do_layering_l,impose_dust_ratio_l,d_dust_l,dust2ice_ratio_l) |
|---|
| [3821] | 204 | |
|---|
| [4074] | 205 | ! Read "run_pcm.def" parameters |
|---|
| [4068] | 206 | hybrid = .true. ! Default |
|---|
| 207 | call get_hybrid(hybrid) |
|---|
| 208 | call set_atmosphere_config(hybrid) |
|---|
| [4065] | 209 | |
|---|
| 210 | ! Check incompatibilities |
|---|
| 211 | call check_config_incompatibility() |
|---|
| 212 | |
|---|
| [3989] | 213 | END SUBROUTINE read_rundef |
|---|
| [3991] | 214 | !======================================================================= |
|---|
| [3076] | 215 | |
|---|
| [4065] | 216 | !======================================================================= |
|---|
| 217 | SUBROUTINE check_config_incompatibility() |
|---|
| 218 | !----------------------------------------------------------------------- |
|---|
| 219 | ! NAME |
|---|
| 220 | ! check_config_incompatibility |
|---|
| 221 | ! |
|---|
| 222 | ! DESCRIPTION |
|---|
| 223 | ! Check incompatibilities in the PEM runtime configuration. |
|---|
| 224 | ! |
|---|
| 225 | ! AUTHORS & DATE |
|---|
| 226 | ! JB Clement, 02/2026 |
|---|
| 227 | ! |
|---|
| 228 | ! NOTES |
|---|
| 229 | ! |
|---|
| 230 | !----------------------------------------------------------------------- |
|---|
| 231 | |
|---|
| 232 | ! DEPENDENCIES |
|---|
| 233 | ! ------------ |
|---|
| 234 | use stoppage, only: stop_clean |
|---|
| 235 | use soil, only: do_soil, reg_thprop_dependp, flux_geo |
|---|
| 236 | use sorption, only: do_sorption |
|---|
| [4110] | 237 | use orbit, only: evo_orbit |
|---|
| [4065] | 238 | use evolution, only: pem_ini_date |
|---|
| 239 | use ice_table, only: icetable_equilibrium, icetable_dynamic |
|---|
| [4110] | 240 | use display, only: print_msg, LVL_WRN |
|---|
| [4065] | 241 | |
|---|
| 242 | ! DECLARATION |
|---|
| 243 | ! ----------- |
|---|
| 244 | implicit none |
|---|
| 245 | |
|---|
| 246 | ! CODE |
|---|
| 247 | ! ---- |
|---|
| 248 | ! Warnings (possible incompatibilities) |
|---|
| [4110] | 249 | if (evo_orbit .and. abs(pem_ini_date) < minieps) call print_msg('''evo_orbit = .true.'' but the initial date of the PEM is set to 0!',LVL_WRN) |
|---|
| [4065] | 250 | |
|---|
| 251 | ! Errors (true incompatibilities) |
|---|
| 252 | if (.not. do_soil) then |
|---|
| 253 | if (icetable_equilibrium .or. icetable_dynamic) call stop_clean(__FILE__,__LINE__,'ice table must be used when do_soil = true!',1) |
|---|
| 254 | if (abs(flux_geo) > minieps) call stop_clean(__FILE__,__LINE__,'soil is not activated but flux_geo /= 0!',1) |
|---|
| 255 | if (reg_thprop_dependp) call stop_clean(__FILE__,__LINE__,'regolith properties vary according to Ps only when soil = true!',1) |
|---|
| 256 | if (do_sorption) call stop_clean(__FILE__,__LINE__,'do_soil must be true when do_sorption = true!',1) |
|---|
| 257 | end if |
|---|
| 258 | |
|---|
| 259 | END SUBROUTINE check_config_incompatibility |
|---|
| 260 | !======================================================================= |
|---|
| 261 | |
|---|
| 262 | !======================================================================= |
|---|
| 263 | SUBROUTINE read_callphys() |
|---|
| 264 | !----------------------------------------------------------------------- |
|---|
| 265 | ! NAME |
|---|
| 266 | ! read_callphys |
|---|
| 267 | ! |
|---|
| 268 | ! DESCRIPTION |
|---|
| 269 | ! Read physics runtime configuration from getin keys, then set |
|---|
| 270 | ! module-scoped parameters accordingly. |
|---|
| 271 | ! |
|---|
| 272 | ! AUTHORS & DATE |
|---|
| 273 | ! JB Clement, 01/2026 |
|---|
| 274 | ! |
|---|
| 275 | ! NOTES |
|---|
| [4074] | 276 | ! To work, it needs that "run_pem.def" hols a line with |
|---|
| [4065] | 277 | ! "INCLUDEDEF=callphys.def". |
|---|
| 278 | !----------------------------------------------------------------------- |
|---|
| 279 | |
|---|
| 280 | ! DEPENDENCIES |
|---|
| 281 | ! ------------ |
|---|
| 282 | #ifdef CPP_IOIPSL |
|---|
| 283 | use IOIPSL, only: getin |
|---|
| 284 | #else |
|---|
| 285 | ! If not using IOIPSL, we still need to use (a local version of) getin |
|---|
| 286 | use ioipsl_getincom, only: getin |
|---|
| 287 | #endif |
|---|
| 288 | use stoppage, only: stop_clean |
|---|
| [4110] | 289 | use display, only: print_msg, LVL_NFO |
|---|
| 290 | use atmosphere, only: set_CO2cond_ps_PCM |
|---|
| [4065] | 291 | |
|---|
| 292 | ! DECLARATION |
|---|
| 293 | ! ----------- |
|---|
| 294 | implicit none |
|---|
| 295 | |
|---|
| 296 | ! LOCAL VARIABLES |
|---|
| 297 | ! --------------- |
|---|
| 298 | logical(k4) :: here |
|---|
| [4110] | 299 | real(dp) :: CO2cond_ps_PCM_l |
|---|
| [4065] | 300 | |
|---|
| 301 | ! CODE |
|---|
| 302 | ! ---- |
|---|
| 303 | inquire(file = callphys_name,exist = here) |
|---|
| 304 | if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//callphys_name//'"!',1) |
|---|
| [4110] | 305 | call print_msg('> Reading "'//callphys_name//'"',LVL_NFO) |
|---|
| [4065] | 306 | |
|---|
| [4110] | 307 | CO2cond_ps_PCM_l = 1._dp |
|---|
| 308 | call getin("CO2cond_ps",CO2cond_ps_PCM_l) |
|---|
| 309 | call set_CO2cond_ps_PCM(CO2cond_ps_PCM_l) |
|---|
| [4065] | 310 | |
|---|
| 311 | END SUBROUTINE read_callphys |
|---|
| 312 | !======================================================================= |
|---|
| 313 | |
|---|
| 314 | !======================================================================= |
|---|
| 315 | SUBROUTINE get_hybrid(hybrid) |
|---|
| 316 | !----------------------------------------------------------------------- |
|---|
| 317 | ! NAME |
|---|
| 318 | ! get_hybrid |
|---|
| 319 | ! |
|---|
| 320 | ! DESCRIPTION |
|---|
| [4074] | 321 | ! Get the key definition in "run_pcm.def". |
|---|
| [4065] | 322 | ! |
|---|
| 323 | ! AUTHORS & DATE |
|---|
| 324 | ! JB Clement, 12/2025 |
|---|
| 325 | ! |
|---|
| 326 | ! NOTES |
|---|
| 327 | ! |
|---|
| 328 | !----------------------------------------------------------------------- |
|---|
| 329 | |
|---|
| 330 | ! DEPENDENCIES |
|---|
| 331 | ! ------------ |
|---|
| 332 | use stoppage, only: stop_clean |
|---|
| [4110] | 333 | use display, only: print_msg, LVL_NFO, LVL_WRN |
|---|
| [4065] | 334 | use utility, only: bool2str |
|---|
| 335 | |
|---|
| 336 | ! DECLARATION |
|---|
| 337 | ! ----------- |
|---|
| 338 | implicit none |
|---|
| 339 | |
|---|
| 340 | ! ARGUMENTS |
|---|
| 341 | ! --------- |
|---|
| 342 | logical(k4), intent(inout) :: hybrid |
|---|
| 343 | |
|---|
| 344 | ! LOCAL VARIABLES |
|---|
| 345 | ! --------------- |
|---|
| 346 | integer(di) :: ierr, funit, eq_pos |
|---|
| 347 | logical(k4) :: here, found, hybrid_in |
|---|
| 348 | character(256) :: line |
|---|
| 349 | character(128) :: key, res |
|---|
| 350 | |
|---|
| 351 | ! CODE |
|---|
| 352 | ! ---- |
|---|
| [4110] | 353 | inquire(file = runPCMdef_name,exist = here) |
|---|
| 354 | if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//runPCMdef_name//'"!',1) |
|---|
| 355 | call print_msg('> Reading "'//runPCMdef_name//'"',LVL_NFO) |
|---|
| 356 | open(newunit = funit,file = runPCMdef_name,status = 'old',form = 'formatted',action = 'read',iostat = ierr) |
|---|
| 357 | if (ierr /= 0) call stop_clean(__FILE__,__LINE__,'error opening file "'//runPCMdef_name//'"!',ierr) |
|---|
| [4065] | 358 | |
|---|
| 359 | found = .false. |
|---|
| 360 | hybrid_in = hybrid |
|---|
| 361 | do |
|---|
| 362 | ! Read the line |
|---|
| 363 | read(funit,'(a)',iostat = ierr) line |
|---|
| 364 | if (ierr /= 0) exit |
|---|
| 365 | |
|---|
| 366 | ! Skip empty lines and comments |
|---|
| 367 | if (trim(line) == '') cycle |
|---|
| 368 | if (line(1:1) == '#' .or. line(1:1) == '!') cycle |
|---|
| 369 | |
|---|
| 370 | ! Get the position of equal sign |
|---|
| 371 | eq_pos = index(line,'=') |
|---|
| 372 | if (eq_pos == 0) cycle |
|---|
| 373 | |
|---|
| 374 | ! Get the key and its value/result |
|---|
| 375 | key = adjustl(trim(line(:eq_pos - 1))) |
|---|
| 376 | res = adjustl(trim(line(eq_pos + 1:))) |
|---|
| 377 | |
|---|
| 378 | ! Check the key |
|---|
| 379 | if (trim(key) == 'hybrid') then |
|---|
| 380 | read(res,*,iostat = ierr) hybrid |
|---|
| 381 | if (ierr == 0) found = .true. |
|---|
| 382 | exit |
|---|
| 383 | end if |
|---|
| 384 | end do |
|---|
| 385 | |
|---|
| 386 | close(funit) |
|---|
| 387 | |
|---|
| [4110] | 388 | if (.not. found) call print_msg('Key ''hybrid'' not found in the file "'//runPCMdef_name//'"!',LVL_WRN) |
|---|
| 389 | if (hybrid .eqv. hybrid_in) call print_msg('USING DEFAULTS : hybrid = '//bool2str(hybrid_in),LVL_NFO) |
|---|
| [4065] | 390 | |
|---|
| 391 | END SUBROUTINE get_hybrid |
|---|
| 392 | !======================================================================= |
|---|
| 393 | |
|---|
| 394 | !======================================================================= |
|---|
| [4110] | 395 | SUBROUTINE read_control_data() |
|---|
| [4065] | 396 | !----------------------------------------------------------------------- |
|---|
| 397 | ! NAME |
|---|
| [4110] | 398 | ! read_control_data |
|---|
| [4065] | 399 | ! |
|---|
| 400 | ! DESCRIPTION |
|---|
| 401 | ! Read 'controle' data in "startfi.nc". |
|---|
| 402 | ! |
|---|
| 403 | ! AUTHORS & DATE |
|---|
| 404 | ! JB Clement, 01/2026 |
|---|
| 405 | ! |
|---|
| 406 | ! NOTES |
|---|
| 407 | ! |
|---|
| 408 | !----------------------------------------------------------------------- |
|---|
| 409 | |
|---|
| 410 | ! DEPENDENCIES |
|---|
| 411 | ! ------------ |
|---|
| 412 | use io_netcdf, only: open_nc, close_nc, startfi_name, get_dim_nc, get_var_nc |
|---|
| 413 | use physics, only: init_physics |
|---|
| 414 | use orbit, only: init_orbit |
|---|
| 415 | use soil, only: volcapa |
|---|
| 416 | use stoppage, only: stop_clean |
|---|
| [4110] | 417 | use display, only: print_msg, LVL_NFO |
|---|
| [4065] | 418 | |
|---|
| 419 | ! DECLARATION |
|---|
| 420 | ! ----------- |
|---|
| 421 | implicit none |
|---|
| 422 | |
|---|
| 423 | ! LOCAL VARIABLES |
|---|
| 424 | ! --------------- |
|---|
| 425 | integer(di) :: nindex ! Size of dimension 'index' |
|---|
| 426 | real(dp), dimension(:), allocatable :: controle |
|---|
| 427 | |
|---|
| 428 | ! CODE |
|---|
| 429 | ! ---- |
|---|
| [4110] | 430 | call print_msg('> Reading control data ("'//startfi_name//'")',LVL_NFO) |
|---|
| [4065] | 431 | ! Open the "startfi.nc" file |
|---|
| 432 | call open_nc(startfi_name,'read') |
|---|
| 433 | |
|---|
| 434 | ! Get the dimension size of 'index' |
|---|
| 435 | call get_dim_nc('index',nindex) |
|---|
| 436 | |
|---|
| 437 | ! Get 'controle' |
|---|
| 438 | allocate(controle(nindex)) |
|---|
| 439 | call get_var_nc('controle',controle) |
|---|
| 440 | |
|---|
| 441 | ! Close the file |
|---|
| 442 | call close_nc(startfi_name) |
|---|
| 443 | |
|---|
| 444 | ! Initialize physical data |
|---|
| 445 | ! Arguments order: rad, g, mugaz, rcp |
|---|
| [4110] | 446 | call print_msg(' > Initializing physical constants',LVL_NFO) |
|---|
| [4065] | 447 | call init_physics(controle(5),controle(7),controle(8),controle(9)) |
|---|
| 448 | |
|---|
| 449 | ! Initialize soil data |
|---|
| [4110] | 450 | call print_msg(' > Initializing soil parameters',LVL_NFO) |
|---|
| [4065] | 451 | volcapa = controle(35) |
|---|
| 452 | if (abs(volcapa) < minieps) call stop_clean(__FILE__,__LINE__,'volcapa is 0 in "'//startfi_name//'"!',1) |
|---|
| 453 | |
|---|
| 454 | ! Initialize orbital data |
|---|
| 455 | ! Arguments order: Obliquity, Perihelion, Aphelion, Date of perihelion, Year length, Sol length |
|---|
| [4110] | 456 | call print_msg(' > Initializing orbital characteristics of the planet',LVL_NFO) |
|---|
| [4065] | 457 | call init_orbit(controle(18),controle(15),controle(16),controle(17),controle(14),controle(10)) |
|---|
| 458 | |
|---|
| 459 | deallocate(controle) |
|---|
| 460 | |
|---|
| [4110] | 461 | END SUBROUTINE read_control_data |
|---|
| [4065] | 462 | !======================================================================= |
|---|
| 463 | |
|---|
| [4110] | 464 | !======================================================================= |
|---|
| 465 | SUBROUTINE read_display_config() |
|---|
| 466 | !----------------------------------------------------------------------- |
|---|
| 467 | ! NAME |
|---|
| 468 | ! read_display_config |
|---|
| 469 | ! |
|---|
| 470 | ! DESCRIPTION |
|---|
| 471 | ! Read PEM runtime configuration for display from getin keys, then |
|---|
| 472 | ! set module-scoped parameters accordingly. |
|---|
| 473 | ! |
|---|
| 474 | ! AUTHORS & DATE |
|---|
| 475 | ! JB Clement, 03/2026 |
|---|
| 476 | ! |
|---|
| 477 | ! NOTES |
|---|
| 478 | ! |
|---|
| 479 | !----------------------------------------------------------------------- |
|---|
| 480 | |
|---|
| 481 | ! DEPENDENCIES |
|---|
| 482 | ! ------------ |
|---|
| 483 | #ifdef CPP_IOIPSL |
|---|
| 484 | use IOIPSL, only: getin |
|---|
| 485 | #else |
|---|
| 486 | ! If not using IOIPSL, we still need to use (a local version of) getin |
|---|
| 487 | use ioipsl_getincom, only: getin |
|---|
| 488 | #endif |
|---|
| 489 | use stoppage, only: stop_clean |
|---|
| 490 | use display, only: set_display_config, LVL_NFO |
|---|
| 491 | |
|---|
| 492 | ! DECLARATION |
|---|
| 493 | ! ----------- |
|---|
| 494 | implicit none |
|---|
| 495 | |
|---|
| 496 | ! LOCAL VARIABLES |
|---|
| 497 | ! --------------- |
|---|
| 498 | logical(k4) :: here, out2term_l, out2log_l |
|---|
| 499 | integer(di) :: verbosity_lvl_l |
|---|
| 500 | |
|---|
| 501 | ! CODE |
|---|
| 502 | ! ---- |
|---|
| 503 | inquire(file = rundef_name,exist = here) |
|---|
| 504 | if (.not. here) call stop_clean(__FILE__,__LINE__,'cannot find required file "'//rundef_name//'" (PEM)!',1) |
|---|
| 505 | |
|---|
| 506 | ! Display |
|---|
| 507 | ! ~~~~~~~ |
|---|
| 508 | out2term_l = .true. |
|---|
| 509 | call getin('out2term',out2term_l) |
|---|
| 510 | |
|---|
| 511 | out2log_l = .false. |
|---|
| 512 | call getin('out2log',out2log_l) |
|---|
| 513 | |
|---|
| 514 | verbosity_lvl_l = LVL_NFO |
|---|
| 515 | call getin('verbosity_lvl',verbosity_lvl_l) |
|---|
| 516 | |
|---|
| 517 | ! Setter |
|---|
| 518 | call set_display_config(out2term_l,out2log_l,verbosity_lvl_l) |
|---|
| 519 | |
|---|
| 520 | END SUBROUTINE read_display_config |
|---|
| 521 | !======================================================================= |
|---|
| 522 | |
|---|
| [4065] | 523 | END MODULE config |
|---|