PHYEX 0.9.5
PHYsique EXternalisée
Loading...
Searching...
No Matches
ini_phyex.F90
Go to the documentation of this file.
1SUBROUTINE ini_phyex(D, HPROGRAM, TPFILE, LDNEEDNAM, KLUOUT, KFROM, KTO, &
2 &PTSTEP, PDZMIN, &
3 &CMICRO, CSCONV, CTURB, &
4 &PHYAERO, &
5 &LDCHANGEMODEL, LDDEFAULTVAL, LDREADNAM, LDCHECK, &
6 &KPRINT, LDINIT, &
7 &PHYEX_IN, PHYEX_OUT)
8!
9!IMPORTANT NOTE ON HOW TO DEAL WITH KEYS USED IN THE PHYSICS *AND* IN THE HOST MODEL
10!
11!When this situation occurs:
12!For example, if a physics option (eg logical switch) has an impact on the model setup, this
13!option must be accessible in the host model *and* in the physics.
14!
15!The prefered solution (when it is possible):
16!The option is implemented in a module and in a namelist of PHYEX. And, after the initialisation
17!is done, the option is available in the PHYEX_OUT structure (in addition to the PHYEX module) for use
18!by the host model.
19!
20!When the physics option is needed in the host model before the PHYEX initialisation, or if the physics
21!option must be computed from other options known by the host model, there are several solutions:
22!
23! If this situation is specific to only one host model:
24! The option is declared (module) and initialised (namelist) twice: once in the host model, once in PHYEX;
25! and a consistency check is added after the physics initialisation.
26! This solution is preferred to overwriting the variable stored in the PHYEX module, because between
27! initialization and overwriting, the variable may have been used to initialize a parameterization.
28!
29! If this issue is common to all the host models:
30! The option is declared and initialised in the host model. Then, the value is given, through INI_PHYEX, to
31! the parametrisation INIT subroutine (eg TURBN_INIT). In the INIT subroutine the value is assigned
32! to a module variable specific to PHYEX (in order to be accessible from inside the parametrisations).
33! In this case the variable *must not* be added in a PHYEX namelist.
34! An alternative to this solution is not to copy the variable inside a PHYEX module but add it directly
35! to the parametrisation call arguments.
36!
37USE parkind1, ONLY: jprb
38USE modd_precision, ONLY: mnhreal
40!
41USE modd_phyex, ONLY: phyex_t
43USE modd_cst, ONLY: cst, print_cst
49USE modd_tiwmx, ONLY: tiwmx, ini_tiwmx
59USE modd_nsv, ONLY: tnsv, nsv_associate
61!
62USE mode_ini_cst, ONLY: ini_cst
65USE mode_ini_turb, ONLY: ini_turb
68USE mode_ini_lima, ONLY: ini_lima
69!
70USE mode_msg, ONLY: print_msg
71!
72!!
73!! *INI_PHYEX* - PHYEX initialisation routine
74!!
75!! PURPOSE
76!! -------
77!! The purpose of this routine is to initialise (default values, namelist, checks, prints)
78!! the different modules used by the physics
79!!
80!!
81!! AUTHOR
82!! ------
83!! S. Riette
84!!
85!! MODIFICATIONS
86!! -------------
87!!
88!! - Original Fev 2023
89!!
90!-------------------------------------------------------------------------------
91!
92!** DECLARATIONS
93!
94IMPLICIT NONE
95
96TYPE(dimphyex_t), INTENT(IN) :: D !< Dimensions of the physical domain
97CHARACTER(LEN=6), INTENT(IN) :: HPROGRAM !< Current program
98TYPE(tfiledata), INTENT(IN) :: TPFILE !< Namelist file
99LOGICAL, INTENT(IN) :: LDNEEDNAM !< True to abort if namelist is absent
100INTEGER, INTENT(IN) :: KLUOUT !< Logical unit for outputs
101INTEGER, INTENT(IN) :: KFROM !< Old model number
102INTEGER, INTENT(IN) :: KTO !< New model number
103REAL, INTENT(IN) :: PTSTEP !< Timestep
104REAL, INTENT(IN) :: PDZMIN !< Minimum thickness
105CHARACTER(LEN=4), INTENT(IN) :: CMICRO !< Microphysical scheme to use
106CHARACTER(LEN=4), INTENT(IN) :: CSCONV !< Shallow convection scheme to use
107CHARACTER(LEN=4), INTENT(IN) :: CTURB !< Turbulence scheme to use
108LOGICAL, OPTIONAL, INTENT(IN) :: LDCHANGEMODEL!< Must we change the active model
109LOGICAL, OPTIONAL, INTENT(IN) :: LDDEFAULTVAL !< Must we initialize variables with default values (defaults to .TRUE.)
110LOGICAL, OPTIONAL, INTENT(IN) :: LDREADNAM !< Must we read the namelist (defaults to .TRUE.)
111LOGICAL, OPTIONAL, INTENT(IN) :: LDCHECK !< Must we perform some checks on values (defaults to .TRUE.)
112INTEGER, OPTIONAL, INTENT(IN) :: KPRINT !< Print level (defaults to 0): 0 for no print, 1 to safely print namelist,
113 !! 2 to print informative messages
114LOGICAL, OPTIONAL, INTENT(IN) :: LDINIT !< Must we call the init routines
115TYPE(phyex_t), OPTIONAL, INTENT(IN) :: PHYEX_IN !< Structure for constants (IN)
116TYPE(phyex_t), OPTIONAL, INTENT(INOUT) :: PHYEX_OUT !< Structure for constants (OUT)
117TYPE(phyex_aero_t), OPTIONAL, INTENT(INOUT) :: PHYAERO !< Aerosol properties
118
119!IMPORTANT NOTE on PHYEX_OUT arguments.
120!Logically this argument should be declared with INTENT(OUT) but in this case ifort (at least) breaks the
121!execution when the same structure is given for the PHYEX_IN and the PHYEX_OUT argument.
122!When INITENT(INOUT) is used, execution is OK on ifort.
123
124LOGICAL :: LLINIT, LLCHANGEMODEL, LLCHECK
125INTEGER :: IPRINT
126REAL :: Z_DEFAULT_KIND
127!
128!** ARGUMENTS
129!
130llinit=.true.
131IF(PRESENT(ldinit)) llinit=ldinit
132llcheck=.true.
133IF(PRESENT(ldcheck)) llcheck=ldcheck
134llchangemodel=.true.
135IF(PRESENT(ldchangemodel)) llchangemodel=ldchangemodel
136iprint=0
137IF(PRESENT(kprint)) iprint=kprint
138!
139!** PRECISION CHECK
140!
141IF(kind(z_default_kind) /= jprb .OR. kind(z_default_kind) /= mnhreal) THEN
142 print*, "Inconsistent compilation option"
143 print*, " PARKIND1 has been compiled with kind=", jprb
144 print*, " MODD_PRECISION has been compiled with kind=", mnhreal
145 print*, " PHYEX has been compiled with kind=", kind(z_default_kind)
146 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', "Inconsistent compilation option")
147ENDIF
148!
149!** CST
150!
151IF(llinit) THEN
152 IF(iprint==2) WRITE(unit=kluout,fmt='('' MODD_CST '')')
153 IF(PRESENT(phyex_in)) cst=phyex_in%CST
154 CALL ini_cst()
155 IF(iprint==2) CALL print_cst(kluout)
156 IF(PRESENT(phyex_out)) phyex_out%CST=cst
157ENDIF
158!
159!** MICROPHYSICS SCHEME
160!
161IF(cmicro=='ICE3' .OR. cmicro=='ICE4' .OR. cmicro=='LIMA') THEN
162 !The LIMA scheme makes use of the condensation routine of the ICE3/ICE4 scheme
163 !It is why the ICE3/ICE4 initialisation is needed in for the LIMA scheme
164 IF(iprint==2) WRITE(unit=kluout,fmt='('' MODD_PARAM_ICEN, MODD_RAIN_ICE_DESCRN, MODD_RAIN_ICE_PARAMN, MODD_CLOUDPARN '')')
165 IF(llchangemodel) THEN
166 CALL cloudpar_goto_model(kfrom, kto)
167 CALL param_ice_goto_model(kfrom, kto)
168 CALL rain_ice_descr_goto_model(kfrom, kto)
169 CALL rain_ice_param_goto_model(kfrom, kto)
170 IF(cmicro=='LIMA') THEN
172 ENDIF
173
174 CALL icet_param_goto_model(kto)
175
176 ENDIF
177 IF(PRESENT(phyex_in)) THEN
178 param_icen=phyex_in%PARAM_ICEN
179 rain_ice_descrn=phyex_in%RAIN_ICE_DESCRN
180 rain_ice_paramn=phyex_in%RAIN_ICE_PARAMN
181 cloudparn=phyex_in%CLOUDPARN
182 IF(cmicro=='LIMA') THEN
183 param_lima=phyex_in%PARAM_LIMA
184 param_lima_warm=phyex_in%PARAM_LIMA_WARM
185 param_lima_cold=phyex_in%PARAM_LIMA_COLD
186 param_lima_mixed=phyex_in%PARAM_LIMA_MIXED
187 ENDIF
188 ice_t_parameters = phyex_in%ICE_T_PARAM
189 ENDIF
190
191 CALL param_icen_init(hprogram, tpfile, ldneednam, kluout, &
192 &lddefaultval, ldreadnam, ldcheck, kprint)
193 IF(cmicro=='LIMA') THEN
194 CALL param_lima_init(hprogram, tpfile, ldneednam, kluout, &
195 &lddefaultval, ldreadnam, ldcheck, kprint)
196 ENDIF
197
198 IF(llinit) THEN
199 CALL ini_rain_ice(d, hprogram, kluout, ptstep, pdzmin, cloudparn%NSPLITR, cmicro, ice_t_parameters)
200 CALL ini_tiwmx
202 IF(cmicro=='LIMA') THEN
203 IF (.NOT. PRESENT(phyaero)) THEN
204 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
205 &"PHYAERO must be present to initialialise aerosols.")
206 ENDIF
207 CALL init_aerosol_properties(phyaero)
208 CALL ini_lima(ptstep, pdzmin, cloudparn%NSPLITR, cloudparn%NSPLITG)
209 ENDIF
210 ENDIF
211
212 IF(PRESENT(phyex_out)) THEN
213 phyex_out%PARAM_ICEN=param_icen
214 phyex_out%RAIN_ICE_DESCRN=rain_ice_descrn
215 phyex_out%RAIN_ICE_PARAMN=rain_ice_paramn
216 phyex_out%CLOUDPARN=cloudparn
217 IF(cmicro=='LIMA') THEN
218 phyex_out%PARAM_LIMA=param_lima
219 phyex_out%PARAM_LIMA_WARM=param_lima_warm
220 phyex_out%PARAM_LIMA_COLD=param_lima_cold
221 phyex_out%PARAM_LIMA_MIXED=param_lima_mixed
222 ENDIF
223 phyex_out%ICE_T_PARAM = ice_t_parameters
224 ENDIF
225ENDIF
226!
227!** NSV init (must be after LIMA init)
228!
229IF(llinit) THEN
230 IF(llchangemodel) CALL nsv_associate()
231 IF(PRESENT(phyex_in)) tnsv=phyex_in%TNSV
232 tnsv%NSV=0
233 CALL lima_update_nsv(param_lima, tnsv, odinit=.true., kmi=kto, ksv=tnsv%NSV, &
234 &hdcloud=cmicro, odupdate=.true.)
235 tnsv%NSV=tnsv%NSV_LIMA
236 IF(PRESENT(phyex_out)) phyex_out%TNSV=tnsv
237ENDIF
238!
239!** CLOUD SCHEME
240!
241! Must be before microphysics (consistency checks in PARAM_LIMA_INIT)
242IF(.true.) THEN !Placeholder for configuration without cloud scheme or a different one
243 IF(iprint==2) WRITE(unit=kluout,fmt='('' MODD_NEB_n '')')
244 IF(llchangemodel) CALL neb_goto_model(kfrom, kto)
245 IF(PRESENT(phyex_in)) nebn=phyex_in%NEBN
246
247 CALL nebn_init(hprogram, tpfile, ldneednam, kluout, &
248 &lddefaultval, ldreadnam, ldcheck, kprint)
249 IF(llinit) THEN
250 !Nothing to do, everything is read from namelist
251 ENDIF
252
253 IF(PRESENT(phyex_out)) phyex_out%NEBN=nebn
254ENDIF
255!
256!** SHALLOW CONVECTION SCHEME
257!
258IF(csconv=='EDKF') THEN
259 IF(iprint==2) WRITE(unit=kluout,fmt='('' MODD_PARAM_MFSHALL_n '')')
260 IF(llchangemodel) CALL param_mfshall_goto_model(kfrom, kto)
261 IF(PRESENT(phyex_in)) param_mfshalln=phyex_in%PARAM_MFSHALLN
262
263 CALL param_mfshalln_init(hprogram, tpfile, ldneednam, kluout, &
264 &lddefaultval, ldreadnam, ldcheck, kprint)
265 IF(llinit) THEN
266 CALL ini_mfshall()
267 ENDIF
268
269 IF(PRESENT(phyex_out)) phyex_out%PARAM_MFSHALLN=param_mfshalln
270ENDIF
271!
272!** TURBULENCE SCHEME
273!
274IF(cturb=='TKEL') THEN
275 IF(iprint==2) WRITE(unit=kluout,fmt='('' MODD_TURB_n MODD_CTURB '')')
276 IF(llchangemodel) THEN
277 CALL turb_goto_model(kfrom, kto)
278 CALL cturb_associate()
279 ENDIF
280 IF(PRESENT(phyex_in)) THEN
281 turbn=phyex_in%TURBN
282 csturb=phyex_in%CSTURB
283 ENDIF
284
285 CALL turbn_init(hprogram, tpfile, ldneednam, kluout, &
286 &lddefaultval, ldreadnam, ldcheck, kprint)
287 IF(llinit) THEN
288 CALL ini_turb(hprogram)
289 ENDIF
290
291 IF(PRESENT(phyex_out)) THEN
292 phyex_out%TURBN=turbn
293 phyex_out%CSTURB=csturb
294 ENDIF
295ENDIF
296!
297!** GLOBAL CONSISTENCY TESTS
298!
299IF(llcheck) THEN
300 IF((cmicro=='ICE3' .OR. cmicro=='ICE4' .OR. cmicro=='LIMA') .AND. cturb=='TKEL') THEN
301 IF ((csubg_aucv_rc == 'ADJU' .OR. csubg_aucv_ri == 'ADJU') .AND. ccondens /= 'GAUS') THEN
302 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
303 &"CSUBG_AUCV_RC and/or CSUBG_AUCV_RI cannot be 'ADJU' if CCONDENS is not 'GAUS'")
304 ENDIF
305 IF ((csubg_aucv_rc == 'ADJU' .OR. csubg_aucv_ri == 'ADJU') .AND. cmicro=='LIMA') THEN
306 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
307 &"CSUBG_AUCV_RC and/or CSUBG_AUCV_RI cannot be 'ADJU' if CMICRO is 'LIMA'")
308 ENDIF
309 IF (.NOT. lharat .AND. lstatnw) THEN
310 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
311 &'LSTATNW only tested in combination with HARATU and EDMFm!')
312 ENDIF
313 ENDIF
314 !
315 IF(cmicro=='LIMA') THEN
316 IF (lsubg_cond .AND. (.NOT. lptsplit)) THEN
317 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
318 &"YOU MUST USE LPTSPLIT=T WITH CMICRO=LIMA AND LSUBG_COND")
319 END IF
320 IF (lsubg_cond .AND. (.NOT. ladj)) THEN
321 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
322 &"YOU MUST USE LADJ=t WITH CMICRO=LIMA AND LSUBG_COND")
323 END IF
324 IF (csconv=='EDKF') THEN
325 IF (param_mfshalln%LRELAX_ALPHA_MF) THEN !PARAM_MFSHALLN%LRELAX_ALPHA_MF undefined if CSCONV/=EDKF
326 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
327 &"YOU CANNOT USE LRELAX_ALPHA_MF when CMICRO is 'LIMA'")
328 ENDIF
329 ENDIF
330 IF(.NOT. nebn%LCONDBORN) THEN
331 CALL print_msg(nverb_fatal, 'GEN', 'INI_PHYEX', &
332 &"LCONDBORN (MODD_NEB_n) must be .TRUE. with LIMA")
333 ENDIF
334 ENDIF
335ENDIF
336
337END SUBROUTINE ini_phyex
subroutine ini_phyex(d, hprogram, tpfile, ldneednam, kluout, kfrom, kto, ptstep, pdzmin, cmicro, csconv, cturb, phyaero, ldchangemodel, lddefaultval, ldreadnam, ldcheck, kprint, ldinit, phyex_in, phyex_out)
Definition ini_phyex.F90:8
subroutine cloudpar_goto_model(kfrom, kto)
type(cloudpar_t), pointer, save cloudparn
subroutine print_cst(kulout)
Definition modd_cst.F90:257
type(cst_t), target, save cst
Definition modd_cst.F90:137
subroutine cturb_associate()
type(csturb_t), target, save csturb
subroutine icet_param_goto_model(kto)
type(icet_param_t), pointer, save ice_t_parameters
integer, parameter nverb_fatal
Definition modd_io.F90:6
logical, pointer lsubg_cond
Definition modd_nebn.F90:75
subroutine neb_goto_model(kfrom, kto)
Definition modd_nebn.F90:85
character(len=80), pointer ccondens
Definition modd_nebn.F90:69
subroutine nebn_init(hprogram, tfilenam, ldneednam, kluout, lddefaultval, ldreadnam, ldcheck, kprint)
type(neb_t), pointer, save nebn
Definition modd_nebn.F90:61
logical, pointer lstatnw
Definition modd_nebn.F90:71
type(nsv_t), target, save tnsv
Definition modd_nsv.F90:274
subroutine nsv_associate()
Definition modd_nsv.F90:450
subroutine param_icen_init(hprogram, tfilenam, ldneednam, kluout, lddefaultval, ldreadnam, ldcheck, kprint)
type(param_ice_t), pointer, save param_icen
subroutine param_ice_goto_model(kfrom, kto)
character(len=4), pointer csubg_aucv_rc
character(len=80), pointer csubg_aucv_ri
type(param_lima_cold_t), target, save param_lima_cold
type(param_lima_mixed_t), target param_lima_mixed
type(param_lima_warm_t), target, save param_lima_warm
logical, pointer ladj
logical, pointer lptsplit
subroutine param_lima_associate()
type(param_lima_t), target, save param_lima
subroutine param_lima_init(hprogram, tfilenam, odneednam, kluout, oddefaultval, odreadnam, odcheck, kprint)
subroutine param_mfshalln_init(hprogram, tfilenam, ldneednam, kluout, lddefaultval, ldreadnam, ldcheck, kprint)
type(param_mfshall_t), pointer, save param_mfshalln
subroutine param_mfshall_goto_model(kfrom, kto)
integer, parameter mnhreal
type(rain_ice_descr_t), pointer, save rain_ice_descrn
subroutine rain_ice_descr_goto_model(kfrom, kto)
type(rain_ice_param_t), pointer, save rain_ice_paramn
subroutine rain_ice_param_goto_model(kfrom, kto)
subroutine ini_tiwmx
type(tiwmx_t), target, save tiwmx
logical, pointer lharat
type(turb_t), pointer, save turbn
subroutine turb_goto_model(kfrom, kto)
subroutine turbn_init(hprogram, tfilenam, ldneednam, kluout, lddefaultval, ldreadnam, ldcheck, kprint)
subroutine ini_cst
subroutine ini_lima(ptstep, pdzmin, ksplitr, ksplitg)
subroutine ini_mfshall()
subroutine ini_rain_ice(d, hprogram, kluout, ptstep, pdzmin, ksplitr, hcloud, ice_t_parameters)
subroutine ini_turb(hprogram)
subroutine lima_update_nsv(limap, tnsv, odinit, kmi, ksv, hdcloud, odupdate)