Changeset 3083 for trunk/LMDZ.TITAN/libf/muphytitan/mmp_gcm.f90
- Timestamp:
- Oct 12, 2023, 10:30:22 AM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.TITAN/libf/muphytitan/mmp_gcm.f90
r1926 r3083 1 ! Copyright 2017 Université de Reims Champagne-Ardenne 1 ! Copyright 2017 Université de Reims Champagne-Ardenne 2 2 ! Contributor: J. Burgalat (GSMA, URCA) 3 3 ! email of the author : jeremie.burgalat@univ-reims.fr 4 ! 4 ! 5 5 ! This software is a computer program whose purpose is to compute 6 6 ! microphysics processes using a two-moments scheme. 7 ! 7 ! 8 8 ! This library is governed by the CeCILL license under French law and 9 ! abiding by the rules of distribution of free software. You can use, 9 ! abiding by the rules of distribution of free software. You can use, 10 10 ! modify and/ or redistribute the software under the terms of the CeCILL 11 11 ! license as circulated by CEA, CNRS and INRIA at the following URL 12 ! "http://www.cecill.info". 13 ! 12 ! "http://www.cecill.info". 13 ! 14 14 ! As a counterpart to the access to the source code and rights to copy, 15 15 ! modify and redistribute granted by the license, users are provided only 16 16 ! with a limited warranty and the software's author, the holder of the 17 17 ! economic rights, and the successive licensors have only limited 18 ! liability. 19 ! 18 ! liability. 19 ! 20 20 ! In this respect, the user's attention is drawn to the risks associated 21 21 ! with loading, using, modifying and/or developing or reproducing the … … 25 25 ! professionals having in-depth computer knowledge. Users are therefore 26 26 ! encouraged to load and test the software's suitability as regards their 27 ! requirements in conditions enabling the security of their systems and/or 28 ! data to be ensured and, more generally, to use and operate it in the 29 ! same conditions as regards security. 30 ! 27 ! requirements in conditions enabling the security of their systems and/or 28 ! data to be ensured and, more generally, to use and operate it in the 29 ! same conditions as regards security. 30 ! 31 31 ! The fact that you are presently reading this means that you have had 32 32 ! knowledge of the CeCILL license and that you accept its terms. … … 44 44 IMPLICIT NONE 45 45 46 CONTAINS 47 46 CONTAINS 47 48 48 SUBROUTINE mmp_initialize(dt,p_prod,tx_prod,rc_prod,rplanet,g0, air_rad,air_mmol,clouds,cfgpath) 49 49 !! Initialize global parameters of the model. 50 !! 50 !! 51 51 !! The function initializes all the global parameters of the model from direct input. 52 !! Boolean (and Fiadero) parameters are optional as they are rather testing parameters. Their 53 !! default values are suitable for production runs. 52 !! Boolean (and Fiadero) parameters are optional as they are rather testing parameters. Their 53 !! default values are suitable for production runs. 54 54 !! @note 55 55 !! If the subroutine fails to initialize parameters, the run is aborted. 56 56 !! 57 57 !! @warning 58 !! If OpenMP is activated, this subroutine must be called in an $OMP SINGLE statement as it 58 !! If OpenMP is activated, this subroutine must be called in an $OMP SINGLE statement as it 59 59 !! initializes global variable that are not thread private. 60 60 !! … … 87 87 88 88 INTEGER :: coag_choice 89 REAL(kind=mm_wp) :: fiad_max, 90 LOGICAL :: w_h_prod, w_h_sed, w_h_coag, w_c_sed,w_c_nucond, &91 no_fiadero, fwsed_m0,fwsed_m389 REAL(kind=mm_wp) :: fiad_max,fiad_min,df,rm,rho_aer 90 LOGICAL :: w_h_prod,w_h_sed,w_h_coag,w_c_sed,w_c_nucond, & 91 no_fiadero,fwsed_m0,fwsed_m3 92 92 TYPE(error) :: err 93 93 INTEGER :: i … … 96 96 CHARACTER(len=st_slen), DIMENSION(:), ALLOCATABLE :: species 97 97 REAL(kind=mm_wp), DIMENSION(:), ALLOCATABLE :: tmp 98 REAL(kind=mm_wp) :: m0as_min,rcs_min,m0af_min,rcf_min,m0n_min 99 LOGICAL :: wdebug 98 100 99 101 w_h_prod = .true. … … 104 106 fwsed_m0 = .true. 105 107 fwsed_m3 = .false. 106 no_fiadero = . false.108 no_fiadero = .true. 107 109 fiad_min = 0.1_mm_wp 108 110 fiad_max = 10._mm_wp 109 111 coag_choice = 7 112 wdebug = .false. 113 m0as_min = 1e-10_mm_wp 114 rcs_min = 1e-9_mm_wp 115 m0af_min = 1e-10_mm_wp 116 rcf_min = 1e-9_mm_wp 117 m0n_min = 1e-10_mm_wp 110 118 111 119 WRITE(*,'(a)') "##### MMP_GCM SPEAKING #####" 112 WRITE(*,'(a)') "I will initialize ze microphysics model in moments YAMMS"120 WRITE(*,'(a)') "I will initialize the microphysics model in moments YAMMS" 113 121 WRITE(*,'(a)') "On error I will simply abort the program. Stay near your computer !" 114 122 WRITE(*,*) 115 123 WRITE(*,'(a)') "Reading muphys configuration file ("//trim(cfgpath)//")..." 116 err = cfg_read_config(cparser,TRIM(cfgpath),.true.) 124 err = cfg_read_config(cparser,TRIM(cfgpath),.true.) 117 125 IF (err /= 0) THEN 118 126 ! RETURN AN ERROR !! 119 127 call abort_program(err) 120 128 ENDIF 121 129 122 130 ! YAMMS internal parameters: 123 131 err = mm_check_opt(cfg_get_value(cparser,"rm",rm),rm,50e-9_mm_wp,mm_log) … … 126 134 ! the following parameters are primarily used to test and debug YAMMS. 127 135 ! They are set in an optional configuration file and default to suitable values for production runs. 128 err = mm_check_opt(cfg_get_value(cparser,"haze_production",w_h_prod) ,w_h_prod ,.true. ,mm_log) 129 err = mm_check_opt(cfg_get_value(cparser,"haze_sedimentation",w_h_sed) ,w_h_sed ,.true. ,mm_log) 130 err = mm_check_opt(cfg_get_value(cparser,"haze_coagulation",w_h_coag) ,w_h_coag ,.true. ,mm_log) 131 err = mm_check_opt(cfg_get_value(cparser,"clouds_sedimentation",w_c_sed),w_c_sed ,clouds ,mm_log) 132 err = mm_check_opt(cfg_get_value(cparser,"clouds_nucl_cond",w_c_nucond) ,w_c_nucond ,clouds ,mm_log) 133 err = mm_check_opt(cfg_get_value(cparser,"wsed_m0",fwsed_m0) ,fwsed_m0 ,.true. ,mm_log) 134 err = mm_check_opt(cfg_get_value(cparser,"wsed_m3",fwsed_m3) ,fwsed_m3 ,.false. ,mm_log) 135 err = mm_check_opt(cfg_get_value(cparser,"no_fiadero",no_fiadero) ,no_fiadero ,.false. ,mm_log) 136 err = mm_check_opt(cfg_get_value(cparser,"fiadero_min_ratio",fiad_min) ,fiad_min ,0.1_mm_wp,mm_log) 137 err = mm_check_opt(cfg_get_value(cparser,"fiadero_max_ratio",fiad_max) ,fiad_max ,10._mm_wp,mm_log) 138 err = mm_check_opt(cfg_get_value(cparser,"haze_coag_interactions",coag_choice),coag_choice,7,mm_log) 139 140 ! optic look-up table file path. 141 mmp_optic_file = '' 142 opt_file = '' 143 err = mm_check_opt(cfg_get_value(cparser,"optics/optic_file",opt_file),opt_file,'',mm_log) 144 IF (err /= 0) THEN 145 WRITE(*,'(a)') "Warning: I was unable to retrieve the path of the optic look-up table file:" 146 WRITE(*,'(a)') " The GCM may abort if it uses YAMMS optical properties calculation module !" 147 ELSE 148 mmp_optic_file = TRIM(opt_file) 149 ENDIF 136 err = mm_check_opt(cfg_get_value(cparser,"haze_production",w_h_prod) ,w_h_prod ,.true. ,mm_log) 137 err = mm_check_opt(cfg_get_value(cparser,"haze_sedimentation",w_h_sed) ,w_h_sed ,.true. ,mm_log) 138 err = mm_check_opt(cfg_get_value(cparser,"haze_coagulation",w_h_coag) ,w_h_coag ,.true. ,mm_log) 139 err = mm_check_opt(cfg_get_value(cparser,"clouds_sedimentation",w_c_sed) ,w_c_sed ,clouds ,mm_log) 140 err = mm_check_opt(cfg_get_value(cparser,"clouds_nucl_cond",w_c_nucond) ,w_c_nucond ,clouds ,mm_log) 141 err = mm_check_opt(cfg_get_value(cparser,"wsed_m0",fwsed_m0) ,fwsed_m0 ,.true. ,mm_log) 142 err = mm_check_opt(cfg_get_value(cparser,"wsed_m3",fwsed_m3) ,fwsed_m3 ,.false. ,mm_log) 143 err = mm_check_opt(cfg_get_value(cparser,"no_fiadero",no_fiadero) ,no_fiadero ,.true. ,mm_log) 144 err = mm_check_opt(cfg_get_value(cparser,"fiadero_min_ratio",fiad_min) ,fiad_min ,0.1_mm_wp ,mm_log) 145 err = mm_check_opt(cfg_get_value(cparser,"fiadero_max_ratio",fiad_max) ,fiad_max ,10._mm_wp ,mm_log) 146 err = mm_check_opt(cfg_get_value(cparser,"haze_coag_interactions",coag_choice),coag_choice,7 ,mm_log) 147 err = mm_check_opt(cfg_get_value(cparser,"m0as_min",m0as_min) ,m0as_min ,1e-10_mm_wp,mm_log) 148 err = mm_check_opt(cfg_get_value(cparser,"rcs_min",rcs_min) ,rcs_min ,1e-9_mm_wp ,mm_log) 149 err = mm_check_opt(cfg_get_value(cparser,"m0af_min",m0af_min) ,m0af_min ,1e-10_mm_wp,mm_log) 150 err = mm_check_opt(cfg_get_value(cparser,"rcf_min",rcf_min) ,rcf_min ,rm ,mm_log) 151 err = mm_check_opt(cfg_get_value(cparser,"m0n_min",m0n_min) ,m0n_min ,1e-10_mm_wp,mm_log) 152 err = mm_check_opt(cfg_get_value(cparser,"debug",wdebug) ,wdebug ,.false. ,mm_log) 150 153 151 154 ! Retrieve clouds species configuration file … … 156 159 ENDIF 157 160 158 ! YAMMS initialization. 159 err = mm_global_init_0(dt,df,rm,rho_aer,p_prod,tx_prod,rc_prod,rplanet,g0, & 160 air_rad,air_mmol,coag_choice,clouds,spcpath, & 161 w_h_prod,w_h_sed,w_h_coag,w_c_nucond, & 162 w_c_sed,fwsed_m0,fwsed_m3, & 163 no_fiadero,fiad_min,fiad_max) 164 IF (err /= 0) call abort_program(err) 165 166 ! Extra initialization (needed for YAMMS method interfaces) 167 err = mm_check_opt(cfg_get_value(cparser, "transfert_probability", mmp_w_ps2s), mmp_w_ps2s, wlog=mm_log) 168 IF (err/=0) call abort_program(err) 169 err = mm_check_opt(cfg_get_value(cparser, "electric_charging" , mmp_w_qe ), mmp_w_qe, wlog=mm_log) 170 IF (err/=0) call abort_program(err) 171 172 ! initialize transfert probabilities look-up tables 173 IF (mm_w_haze_coag .AND. mmp_w_ps2s) THEN 174 err = mm_check_opt(cfg_get_value(cparser, "ps2s_file", pssfile), pssfile) 175 IF (err /= 0) call abort_program(err) 176 177 IF (.NOT.read_dset(pssfile,'p_m0_co',mmp_pco0p)) THEN 178 call abort_program(error("Cannot get 'p_m0_co' from "//pssfile,-1)) 179 ENDIF 180 IF (.NOT.read_dset(pssfile,'p_m3_co',mmp_pco3p)) THEN 181 call abort_program(error("Cannot get 'p_m3_co' from "//pssfile,-1)) 182 ENDIF 183 IF (.NOT.read_dset(pssfile,'p_m0_fm',mmp_pfm0p)) THEN 184 call abort_program(error("Cannot get 'p_m0_fm' from "//pssfile,-1)) 185 ENDIF 186 IF (.NOT.read_dset(pssfile,'p_m3_fm',mmp_pfm3p)) THEN 187 call abort_program(error("Cannot get 'p_m3_fm' from "//pssfile,-1)) 188 ENDIF 189 ENDIF 190 ! initialize mean electric correction look-up tables 191 IF (mm_w_haze_coag .AND. mmp_w_qe) THEN 192 err = mm_check_opt(cfg_get_value(cparser, "mq_file", mqfile), mqfile) 193 IF (err /= 0) call abort_program(err) 194 195 IF (.NOT.read_dset(mqfile,'qbsf0',mmp_qbsf0)) THEN 196 call abort_program(error("Cannot get 'qbsf0' from "//mqfile,-1)) 197 ELSE 198 mmp_qbsf0_e(1,1) = MINVAL(mmp_qbsf0%x) 199 mmp_qbsf0_e(1,2) = MAXVAL(mmp_qbsf0%x) 200 mmp_qbsf0_e(2,1) = MINVAL(mmp_qbsf0%y) 201 mmp_qbsf0_e(2,2) = MAXVAL(mmp_qbsf0%y) 202 ENDIF 203 IF (.NOT.read_dset(mqfile,'qbsf3',mmp_qbsf3)) THEN 204 call abort_program(error("Cannot get 'qbsf3' from "//mqfile,-1)) 205 ELSE 206 mmp_qbsf3_e(1,1) = MINVAL(mmp_qbsf3%x) 207 mmp_qbsf3_e(1,2) = MAXVAL(mmp_qbsf3%x) 208 mmp_qbsf3_e(2,1) = MINVAL(mmp_qbsf3%y) 209 mmp_qbsf3_e(2,2) = MAXVAL(mmp_qbsf3%y) 210 ENDIF 211 IF (.NOT.read_dset(mqfile,'qbff0',mmp_qbff0)) THEN 212 call abort_program(error("Cannot get 'qbff0' from "//mqfile,-1)) 213 ELSE 214 mmp_qbff0_e(1,1) = MINVAL(mmp_qbff0%x) 215 mmp_qbff0_e(1,2) = MAXVAL(mmp_qbff0%x) 216 mmp_qbff0_e(2,1) = MINVAL(mmp_qbff0%y) 217 mmp_qbff0_e(2,2) = MAXVAL(mmp_qbff0%y) 218 ENDIF 219 ENDIF 161 ! Setup alpha function: THEY ARE REQUIRED IN YAMMS global initialization ! 220 162 ! spherical mode inter-moments function parameters 221 163 IF (.NOT.cfg_has_section(cparser,'alpha_s')) call abort_program(error("Cannot find [alpha_s] section",-1)) … … 227 169 IF (err /= 0) call abort_program(error("alpha_s: "//TRIM(err%msg),-1)) 228 170 229 ! get size-distribution laws parameters 230 IF (.NOT.cfg_has_section(cparser,'dndr_s')) call abort_program(error("Cannot find [dndr_s] section",-2)) 231 err = read_nprm(cparser,'dndr_s',mmp_pns) 232 IF (err /= 0) call abort_program(error("dndr_s: "//TRIM(err%msg),-2)) 233 IF (.NOT.cfg_has_section(cparser,'dndr_f')) call abort_program(error("Cannot find [dndr_f] section",-2)) 234 err = read_nprm(cparser,'dndr_f',mmp_pnf) 235 IF (err /= 0) call abort_program(error("dndr_f: "//TRIM(err%msg),-2)) 171 ! YAMMS initialization. 172 err = mm_global_init_0(dt,df,rm,rho_aer,p_prod,tx_prod,rc_prod,rplanet,g0, & 173 air_rad,air_mmol,coag_choice,clouds,spcpath, & 174 w_h_prod,w_h_sed,w_h_coag,w_c_nucond, & 175 w_c_sed,fwsed_m0,fwsed_m3, & 176 no_fiadero,fiad_min,fiad_max, & 177 m0as_min,rcs_min,m0af_min,rcf_min,m0n_min,wdebug) 178 IF (err /= 0) call abort_program(err) 179 180 ! Extra initialization (needed for YAMMS method interfaces) 181 err = mm_check_opt(cfg_get_value(cparser, "transfert_probability", mmp_w_ps2s), mmp_w_ps2s, wlog=mm_log) 182 IF (err/=0) call abort_program(err) 183 err = mm_check_opt(cfg_get_value(cparser, "electric_charging" , mmp_w_qe ), mmp_w_qe, wlog=mm_log) 184 IF (err/=0) call abort_program(err) 185 186 ! initialize transfert probabilities look-up tables 187 IF (mm_w_haze_coag .AND. mmp_w_ps2s) THEN 188 err = mm_check_opt(cfg_get_value(cparser, "ps2s_file", pssfile), pssfile) 189 IF (err /= 0) call abort_program(err) 190 191 IF (.NOT.read_dset(pssfile,'p_m0_co',mmp_pco0p)) THEN 192 call abort_program(error("Cannot get 'p_m0_co' from "//pssfile,-1)) 193 ENDIF 194 IF (.NOT.read_dset(pssfile,'p_m3_co',mmp_pco3p)) THEN 195 call abort_program(error("Cannot get 'p_m3_co' from "//pssfile,-1)) 196 ENDIF 197 IF (.NOT.read_dset(pssfile,'p_m0_fm',mmp_pfm0p)) THEN 198 call abort_program(error("Cannot get 'p_m0_fm' from "//pssfile,-1)) 199 ENDIF 200 IF (.NOT.read_dset(pssfile,'p_m3_fm',mmp_pfm3p)) THEN 201 call abort_program(error("Cannot get 'p_m3_fm' from "//pssfile,-1)) 202 ENDIF 203 ENDIF 204 ! initialize mean electric correction look-up tables 205 IF (mm_w_haze_coag .AND. mmp_w_qe) THEN 206 err = mm_check_opt(cfg_get_value(cparser, "mq_file", mqfile), mqfile) 207 IF (err /= 0) call abort_program(err) 208 209 IF (.NOT.read_dset(mqfile,'qbsf0',mmp_qbsf0)) THEN 210 call abort_program(error("Cannot get 'qbsf0' from "//mqfile,-1)) 211 ELSE 212 mmp_qbsf0_e(1,1) = MINVAL(mmp_qbsf0%x) 213 mmp_qbsf0_e(1,2) = MAXVAL(mmp_qbsf0%x) 214 mmp_qbsf0_e(2,1) = MINVAL(mmp_qbsf0%y) 215 mmp_qbsf0_e(2,2) = MAXVAL(mmp_qbsf0%y) 216 ENDIF 217 IF (.NOT.read_dset(mqfile,'qbsf3',mmp_qbsf3)) THEN 218 call abort_program(error("Cannot get 'qbsf3' from "//mqfile,-1)) 219 ELSE 220 mmp_qbsf3_e(1,1) = MINVAL(mmp_qbsf3%x) 221 mmp_qbsf3_e(1,2) = MAXVAL(mmp_qbsf3%x) 222 mmp_qbsf3_e(2,1) = MINVAL(mmp_qbsf3%y) 223 mmp_qbsf3_e(2,2) = MAXVAL(mmp_qbsf3%y) 224 ENDIF 225 IF (.NOT.read_dset(mqfile,'qbff0',mmp_qbff0)) THEN 226 call abort_program(error("Cannot get 'qbff0' from "//mqfile,-1)) 227 ELSE 228 mmp_qbff0_e(1,1) = MINVAL(mmp_qbff0%x) 229 mmp_qbff0_e(1,2) = MAXVAL(mmp_qbff0%x) 230 mmp_qbff0_e(2,1) = MINVAL(mmp_qbff0%y) 231 mmp_qbff0_e(2,2) = MAXVAL(mmp_qbff0%y) 232 ENDIF 233 ENDIF 236 234 237 235 ! btk coefficients … … 249 247 WRITE(*,'(a,L2)') "electric_charging : ", mmp_w_qe 250 248 call mm_dump_parameters() 251 249 250 IF (clouds) THEN 251 DO i=1, size(mm_xESPS) 252 print*, TRIM(mm_xESPS(i)%name), " fmol2fmas = ", mm_xESPS(i)%fmol2fmas 253 ENDDO 254 ENDIF 255 252 256 END SUBROUTINE mmp_initialize 253 257 254 258 FUNCTION read_aprm(parser,sec,pp) RESULT(err) 255 !! Read and store [[mmp_gcm(module):aprm(type)]] parameters. 256 TYPE(cfgparser), INTENT(in) :: parser !! Configuration parser 259 !! Read and store [[mmp_gcm(module):aprm(type)]] parameters. 260 TYPE(cfgparser), INTENT(in) :: parser !! Configuration parser 257 261 CHARACTER(len=*), INTENT(in) :: sec !! Name of the section that contains the parameters. 258 262 TYPE(aprm), INTENT(out) :: pp !! [[mmp_gcm(module):aprm(type)]] object that stores the parameters values. … … 266 270 END FUNCTION read_aprm 267 271 268 FUNCTION read_nprm(parser,sec,pp) RESULT(err)269 !! Read and store [[mmp_gcm(module):nprm(type)]] parameters.270 TYPE(cfgparser), INTENT(in) :: parser !! Configuration parser271 CHARACTER(len=*), INTENT(in) :: sec !! Name of the section that contains the parameters.272 TYPE(nprm), INTENT(out) :: pp !! [[mmp_gcm(module):nprm(type)]] object that stores the parameters values.273 TYPE(error) :: err !! Error status of the function.274 err = cfg_get_value(parser,TRIM(sec)//'/rc',pp%rc) ; IF (err /= 0) RETURN275 err = cfg_get_value(parser,TRIM(sec)//'/a0',pp%a0) ; IF (err /= 0) RETURN276 err = cfg_get_value(parser,TRIM(sec)//'/c',pp%c) ; IF (err /= 0) RETURN277 err = cfg_get_value(parser,TRIM(sec)//'/a',pp%a) ; IF (err /= 0) RETURN278 err = cfg_get_value(parser,TRIM(sec)//'/b',pp%b) ; IF (err /= 0) RETURN279 IF (SIZE(pp%a) /= SIZE(pp%b)) &280 err = error("Inconsistent number of coefficients (a and b must have the same size)",3)281 RETURN282 END FUNCTION read_nprm283 284 272 END MODULE MMP_GCM 285 273
Note: See TracChangeset
for help on using the changeset viewer.