@@ -132,24 +132,15 @@ end subroutine dyn_readnl
132
132
! Called by `cam_init` in `src/control/cam_comp.F90`.
133
133
module subroutine dyn_init (cam_runtime_opts , dyn_in , dyn_out )
134
134
! Module(s) from CAM-SIMA.
135
- use air_composition, only: thermodynamic_active_species_num, &
136
- thermodynamic_active_species_liq_num, &
137
- thermodynamic_active_species_ice_num, &
138
- thermodynamic_active_species_idx, thermodynamic_active_species_idx_dycore, &
139
- thermodynamic_active_species_liq_idx, thermodynamic_active_species_liq_idx_dycore, &
140
- thermodynamic_active_species_ice_idx, thermodynamic_active_species_ice_idx_dycore
141
135
use cam_abortutils, only: check_allocate
142
136
use cam_constituents, only: const_name, const_is_water_species, num_advected, readtrace
143
137
use cam_control_mod, only: initial_run
144
138
use cam_initfiles, only: initial_file_get_id, topo_file_get_id
145
139
use cam_logfile, only: debugout_debug, debugout_info
146
140
use cam_pio_utils, only: clean_iodesc_list
147
- use cam_thermo_formula, only: energy_formula_dycore, energy_formula_dycore_mpas
148
141
use dyn_coupling, only: dyn_exchange_constituent_states
149
142
use inic_analytic, only: analytic_ic_active
150
- use physics_types, only: dycore_energy_consistency_adjust
151
143
use runtime_obj, only: runtime_options
152
- use string_utils, only: stringify
153
144
use time_manager, only: get_step_size
154
145
! Module(s) from CCPP.
155
146
use phys_vars_init_check, only: std_name_len
@@ -174,14 +165,6 @@ module subroutine dyn_init(cam_runtime_opts, dyn_in, dyn_out)
174
165
nullify(pio_init_file)
175
166
nullify(pio_topo_file)
176
167
177
- ! Set the energy formula of dynamical core to MPAS for use in `cam_thermo`.
178
- energy_formula_dycore = energy_formula_dycore_mpas
179
-
180
- ! The total energy of dynamical core, which uses "MPAS formula" as set above, is not consistent with
181
- ! that of CAM physics, which uses "FV formula". Therefore, temperature and temperature tendency adjustments
182
- ! are needed at the end of each physics time step.
183
- dycore_energy_consistency_adjust = .true.
184
-
185
168
allocate (constituent_name(num_advected), stat= ierr)
186
169
call check_allocate(ierr, subname, ' constituent_name(num_advected)' , ' dyn_comp' , __LINE__)
187
170
@@ -195,41 +178,14 @@ module subroutine dyn_init(cam_runtime_opts, dyn_in, dyn_out)
195
178
196
179
call dyn_debug_print(debugout_info, ' Defining MPAS scalars and scalar tendencies' )
197
180
198
- ! Inform MPAS about constituent names and their corresponding waterness.
181
+ ! Inform MPAS about the constituent names and their corresponding waterness.
199
182
call mpas_dynamical_core % define_scalar(constituent_name, is_water_species)
200
183
201
184
deallocate (constituent_name)
202
185
deallocate (is_water_species)
203
186
204
- ! Provide mapping information between MPAS scalars and constituent names to CAM-SIMA.
205
- do i = 1 , thermodynamic_active_species_num
206
- thermodynamic_active_species_idx_dycore(i) = &
207
- mpas_dynamical_core % map_mpas_scalar_index(thermodynamic_active_species_idx(i))
208
- end do
209
-
210
- do i = 1 , thermodynamic_active_species_liq_num
211
- thermodynamic_active_species_liq_idx_dycore(i) = &
212
- mpas_dynamical_core % map_mpas_scalar_index(thermodynamic_active_species_liq_idx(i))
213
- end do
214
-
215
- do i = 1 , thermodynamic_active_species_ice_num
216
- thermodynamic_active_species_ice_idx_dycore(i) = &
217
- mpas_dynamical_core % map_mpas_scalar_index(thermodynamic_active_species_ice_idx(i))
218
- end do
219
-
220
- call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_num = ' // &
221
- stringify([thermodynamic_active_species_num]))
222
- call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_liq_num = ' // &
223
- stringify([thermodynamic_active_species_liq_num]))
224
- call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_ice_num = ' // &
225
- stringify([thermodynamic_active_species_ice_num]))
226
-
227
- call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_idx_dycore = [' // &
228
- stringify(thermodynamic_active_species_idx_dycore) // ' ]' )
229
- call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_liq_idx_dycore = [' // &
230
- stringify(thermodynamic_active_species_liq_idx_dycore) // ' ]' )
231
- call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_ice_idx_dycore = [' // &
232
- stringify(thermodynamic_active_species_ice_idx_dycore) // ' ]' )
187
+ call set_thermodynamic_active_species_mapping()
188
+ call set_thermodynamic_energy_formula()
233
189
234
190
pio_init_file = > initial_file_get_id()
235
191
pio_topo_file = > topo_file_get_id()
@@ -290,6 +246,79 @@ module subroutine dyn_init(cam_runtime_opts, dyn_in, dyn_out)
290
246
call dyn_debug_print(debugout_debug, subname // ' completed' )
291
247
end subroutine dyn_init
292
248
249
+ ! > Inform CAM-SIMA about the index mapping between MPAS scalars and CAM-SIMA constituents.
250
+ ! > (KCW, 2025-07-17)
251
+ subroutine set_thermodynamic_active_species_mapping ()
252
+ ! Module(s) from CAM-SIMA.
253
+ use air_composition, only: thermodynamic_active_species_num, &
254
+ thermodynamic_active_species_liq_num, &
255
+ thermodynamic_active_species_ice_num, &
256
+ thermodynamic_active_species_idx, thermodynamic_active_species_idx_dycore, &
257
+ thermodynamic_active_species_liq_idx, thermodynamic_active_species_liq_idx_dycore, &
258
+ thermodynamic_active_species_ice_idx, thermodynamic_active_species_ice_idx_dycore
259
+ use cam_logfile, only: debugout_debug
260
+ use string_utils, only: stringify
261
+
262
+ character (* ), parameter :: subname = ' dyn_comp::set_thermodynamic_active_species_mapping'
263
+ integer :: i
264
+
265
+ call dyn_debug_print(debugout_debug, subname // ' entered' )
266
+
267
+ do i = 1 , thermodynamic_active_species_num
268
+ thermodynamic_active_species_idx_dycore(i) = &
269
+ mpas_dynamical_core % map_mpas_scalar_index(thermodynamic_active_species_idx(i))
270
+ end do
271
+
272
+ do i = 1 , thermodynamic_active_species_liq_num
273
+ thermodynamic_active_species_liq_idx_dycore(i) = &
274
+ mpas_dynamical_core % map_mpas_scalar_index(thermodynamic_active_species_liq_idx(i))
275
+ end do
276
+
277
+ do i = 1 , thermodynamic_active_species_ice_num
278
+ thermodynamic_active_species_ice_idx_dycore(i) = &
279
+ mpas_dynamical_core % map_mpas_scalar_index(thermodynamic_active_species_ice_idx(i))
280
+ end do
281
+
282
+ call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_num = ' // &
283
+ stringify([thermodynamic_active_species_num]))
284
+ call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_liq_num = ' // &
285
+ stringify([thermodynamic_active_species_liq_num]))
286
+ call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_ice_num = ' // &
287
+ stringify([thermodynamic_active_species_ice_num]))
288
+
289
+ call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_idx_dycore = [' // &
290
+ stringify(thermodynamic_active_species_idx_dycore) // ' ]' )
291
+ call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_liq_idx_dycore = [' // &
292
+ stringify(thermodynamic_active_species_liq_idx_dycore) // ' ]' )
293
+ call dyn_debug_print(debugout_debug, ' thermodynamic_active_species_ice_idx_dycore = [' // &
294
+ stringify(thermodynamic_active_species_ice_idx_dycore) // ' ]' )
295
+
296
+ call dyn_debug_print(debugout_debug, subname // ' completed' )
297
+ end subroutine set_thermodynamic_active_species_mapping
298
+
299
+ ! > Set the thermodynamic energy formula of dynamical core to MPAS.
300
+ ! > (KCW, 2025-07-17)
301
+ subroutine set_thermodynamic_energy_formula ()
302
+ ! Module(s) from CAM-SIMA.
303
+ use cam_logfile, only: debugout_debug
304
+ use cam_thermo_formula, only: energy_formula_dycore, energy_formula_dycore_mpas
305
+ use physics_types, only: dycore_energy_consistency_adjust
306
+
307
+ character (* ), parameter :: subname = ' dyn_comp::set_thermodynamic_energy_formula'
308
+
309
+ call dyn_debug_print(debugout_debug, subname // ' entered' )
310
+
311
+ ! Set the thermodynamic energy formula of dynamical core to MPAS for use in `cam_thermo`.
312
+ energy_formula_dycore = energy_formula_dycore_mpas
313
+
314
+ ! The total energy of dynamical core, which uses "MPAS formula" as set above, is not consistent with
315
+ ! that of CAM physics, which uses "FV formula". Therefore, temperature and temperature tendency adjustments
316
+ ! are needed at the end of each physics time step.
317
+ dycore_energy_consistency_adjust = .true.
318
+
319
+ call dyn_debug_print(debugout_debug, subname // ' completed' )
320
+ end subroutine set_thermodynamic_energy_formula
321
+
293
322
! > Check for consistency in topography data. The presence of topography file is inferred from the `pio_file` pointer.
294
323
! > If topography file is used, check that the "PHIS" variable, which denotes surface geopotential,
295
324
! > is consistent with the surface geometric height in MPAS.
0 commit comments