Skip to content

Commit 4c81e2a

Browse files
committed
Apply packages to individual hydrometeors in the init_atmosphere core
This commit defines new packages for hydrometeors, one package per hydrometeor, in the init_atmosphere core, and it provides two means of activating these packages. 1) If the new namelist option config_active_hydrometeors is set to 'detect_automatically', packages will be set up by scanning through the fields in the initial intermediate file, with packages being activated only for those hydrometeors that are present in the file. 2) Alternatively, and to avoid the need to scan through all fields in the initial intermediate file, config_active_hydrometeors may be set to to a semicolon-separated list of zero or more hydrometeor names (e.g., 'qc;qr'). Packages for those specified hydrometeors to be active, and the packages for all unspecified hydrometeors will be inactive. A new subroutine, setup_hydrometeor_packages, handles the details of the hydrometeor package setup, and this routine is called from init_atm_setup_packages only if config_init_case is 7 or 9, and if met_stage_out is true.
1 parent f49b11f commit 4c81e2a

2 files changed

Lines changed: 205 additions & 5 deletions

File tree

‎src/core_init_atmosphere/Registry.xml‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@
217217
description="Whether to use specific-humidity as the first-guess moisture variable. If this option is False, relative humidity will be used."
218218
possible_values="true or false"/>
219219

220+
<nml_option name="config_active_hydrometeors" type="character" default_value="detect_automatically"
221+
units="-"
222+
description="The set of hydrometeor species that are to be processed from input intermediate files when generating ICs and LBCs for real-data simulations."
223+
possible_values="`detect_automatically', or a semicolon-separated list of hydrometeor names (e.g., `qc;qr'"/>
224+
220225
</nml_record>
221226

222227
<nml_record name="vertical_grid" in_defaults="true">
@@ -387,6 +392,8 @@
387392
<package name="first_guess_field" description="3-d atmospheric or land-surface fields on first-guess levels"/>
388393
<package name="mp_thompson_aers_in" description="initialization of GOCART-based Thompson water- and ice-friendly aerosols"/>
389394
<package name="noahmp" description="Whether to process, read, and write static fields only required by Noah-MP"/>
395+
<package name="qc" description="Whether QC is available for inclusion in ICs and LBCs"/>
396+
<package name="qr" description="Whether QR is available for inclusion in ICs and LBCs"/>
390397
</packages>
391398

392399

@@ -1159,10 +1166,12 @@
11591166
description="Water vapor mixing ratio"/>
11601167

11611168
<var name="qc" array_group="moist" units="kg kg^{-1}"
1162-
description="Cloud water mixing ratio"/>
1169+
description="Cloud water mixing ratio"
1170+
packages="qc"/>
11631171

11641172
<var name="qr" array_group="moist" units="kg kg^{-1}"
1165-
description="Rain water mixing ratio"/>
1173+
description="Rain water mixing ratio"
1174+
packages="qr"/>
11661175

11671176
<var name="nifa" array_group="number" units="nb kg^{-1}"
11681177
description="Gocart ice-friendly aerosol number concentration"
@@ -1203,10 +1212,12 @@
12031212
description="Water vapor mixing ratio on lateral boundary cells"/>
12041213

12051214
<var name="lbc_qc" array_group="moist" units="kg kg^{-1}"
1206-
description="Cloud water mixing ratio on lateral boundary cells"/>
1215+
description="Cloud water mixing ratio on lateral boundary cells"
1216+
packages="qc"/>
12071217

12081218
<var name="lbc_qr" array_group="moist" units="kg kg^{-1}"
1209-
description="Rain water mixing ratio on lateral boundary cells"/>
1219+
description="Rain water mixing ratio on lateral boundary cells"
1220+
packages="qr"/>
12101221

12111222
<var name="lbc_nifa" array_group="number" units="nb kg^{-1}"
12121223
description="Gocart ice-friendly aerosol number concentration on lateral boundary cells"

‎src/core_init_atmosphere/mpas_init_atm_core_interface.F‎

Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module init_atm_core_interface
1414
use mpas_io_units
1515
use mpas_log, only : mpas_log_write
1616

17-
private :: mpas_split_string_new
17+
private :: setup_hydrometeor_packages, &
18+
mpas_split_string_new
1819

1920
contains
2021

@@ -318,9 +319,197 @@ function init_atm_setup_packages(configs, streamInfo, packages, iocontext, dminf
318319
return
319320
end if
320321

322+
if (config_init_case == 7 .or. config_init_case == 9) then
323+
if (met_stage_out) then
324+
call setup_hydrometeor_packages(packages, configs, dminfo, ierr)
325+
end if
326+
end if
327+
321328
end function init_atm_setup_packages
322329

323330

331+
!***********************************************************************
332+
!
333+
! function setup_hydrometeor_packages
334+
!
335+
!> \brief Set up packages for hydrometeors based on contents of intermediate file
336+
!> \author Michael Duda
337+
!> \date 27 May 2026
338+
!> \details
339+
!> This routine is responsible for setting up packages for hydrometeor species (qc,
340+
!> qr, etc.) based on the contents of the initial intermediate file (i.e., the
341+
!> intermediate file valid at the start time of a simmulation; the assumption is
342+
!> that all intermediate files contain the same set of fields. A hydrometeor
343+
!> packages is set to true if and only if the intermediate file contains the
344+
!> corresponding hydrometeor.
345+
!>
346+
!> If the setup of all hydrometeor packages is successful, a value of 0 is returned
347+
!> in the ierr output argument; otherwise, a non-zero value is returned.
348+
!
349+
!-----------------------------------------------------------------------
350+
subroutine setup_hydrometeor_packages(packages, configs, dminfo, ierr)
351+
352+
use init_atm_read_met, only : read_met_init, read_next_met_field, read_met_close, met_data
353+
use mpas_timer, only : mpas_timer_start, mpas_timer_stop
354+
355+
implicit none
356+
357+
type (mpas_pool_type), intent(inout) :: packages
358+
type (mpas_pool_type), intent(in) :: configs
359+
type (dm_info), intent(in) :: dminfo
360+
integer, intent(out) :: ierr
361+
362+
character(len=StrKIND), pointer :: config_active_hydrometeors
363+
character(len=StrKIND), pointer :: config_met_prefix, config_start_time
364+
integer :: istatus
365+
type (met_data) :: field
366+
367+
integer :: i
368+
character(len=:), dimension(:), allocatable :: hydrometeors
369+
370+
logical, pointer :: qc, qr
371+
372+
373+
call mpas_timer_start('setup_hydrometeor_packages')
374+
375+
ierr = 0
376+
377+
call mpas_pool_get_config(configs, 'config_active_hydrometeors', config_active_hydrometeors)
378+
379+
if (.not. associated(config_active_hydrometeors)) then
380+
call mpas_log_write("The namelist option 'config_active_hydrometeors' could not be found when setting up hydrometeor packages.", &
381+
messageType=MPAS_LOG_ERR)
382+
383+
ierr = 1
384+
call mpas_timer_stop('setup_hydrometeor_packages')
385+
return
386+
end if
387+
388+
if (trim(config_active_hydrometeors) == 'detect_automatically') then
389+
390+
call mpas_pool_get_config(configs, 'config_met_prefix', config_met_prefix)
391+
call mpas_pool_get_config(configs, 'config_start_time', config_start_time)
392+
393+
call mpas_pool_get_package(packages, 'qcActive', qc)
394+
call mpas_pool_get_package(packages, 'qrActive', qr)
395+
396+
if (.not. associated(config_met_prefix) &
397+
.or. .not. associated(config_start_time) &
398+
.or. .not. associated(qc) &
399+
.or. .not. associated(qr) &
400+
) then
401+
402+
call mpas_log_write('One or more namelist options or packages could not be found when setting up hydrometeor packages.', &
403+
messageType=MPAS_LOG_ERR)
404+
405+
ierr = 1
406+
call mpas_timer_stop('setup_hydrometeor_packages')
407+
return
408+
end if
409+
410+
qc = .false.
411+
qr = .false.
412+
413+
call mpas_log_write('Setting up hydrometeor packages from '//trim(config_met_prefix)//':'//config_start_time(1:13))
414+
415+
if (dminfo % my_proc_id == IO_NODE) then
416+
call read_met_init(trim(config_met_prefix), .false., config_start_time(1:13), ierr)
417+
418+
if (ierr == 0) then
419+
call read_next_met_field(field, istatus)
420+
else
421+
call mpas_log_write('Could not open intermediate file ' &
422+
//trim(config_met_prefix)//':'//config_start_time(1:13) &
423+
//' to set up hydrometeor packages.', &
424+
messageType=MPAS_LOG_ERR)
425+
istatus = 1
426+
end if
427+
428+
do while (istatus == 0)
429+
if (trim(field % field) == 'QC') then
430+
qc = .true.
431+
else if (trim(field % field) == 'QR') then
432+
qr = .true.
433+
end if
434+
435+
deallocate(field % slab)
436+
437+
! Possible optimization: if all packages are true, there is no point in scanning through
438+
! the rest of the intermediate file, since this loop over fields can only switch packages
439+
! from false to true.
440+
441+
call read_next_met_field(field, istatus)
442+
end do
443+
444+
call read_met_close()
445+
446+
call mpas_dmpar_bcast_int(dminfo, ierr)
447+
call mpas_dmpar_bcast_logical(dminfo, qc)
448+
call mpas_dmpar_bcast_logical(dminfo, qr)
449+
else
450+
call mpas_dmpar_bcast_int(dminfo, ierr)
451+
call mpas_dmpar_bcast_logical(dminfo, qc)
452+
call mpas_dmpar_bcast_logical(dminfo, qr)
453+
end if
454+
455+
else
456+
457+
call mpas_pool_get_package(packages, 'qcActive', qc)
458+
call mpas_pool_get_package(packages, 'qrActive', qr)
459+
460+
if (.not. associated(qc) &
461+
.or. .not. associated(qr) &
462+
) then
463+
464+
call mpas_log_write('One or more packages could not be found when setting up hydrometeor packages.', &
465+
messageType=MPAS_LOG_ERR)
466+
467+
ierr = 1
468+
call mpas_timer_stop('setup_hydrometeor_packages')
469+
return
470+
end if
471+
472+
qc = .false.
473+
qr = .false.
474+
475+
call mpas_log_write('Setting up hydrometeor packages from config_active_hydrometeors list: ' &
476+
//trim(config_active_hydrometeors))
477+
478+
call mpas_split_string_new(trim(config_active_hydrometeors), ';', hydrometeors)
479+
480+
do i = 1, size(hydrometeors)
481+
select case (trim(hydrometeors(i)))
482+
case ('qc')
483+
qc = .true.
484+
case ('qr')
485+
qr = .true.
486+
case default
487+
call mpas_log_write('Unrecognized hydrometeor '//trim(hydrometeors(i)) &
488+
//'found in config_active_hydrometeors', &
489+
messageType=MPAS_LOG_WARN)
490+
end select
491+
end do
492+
493+
deallocate(hydrometeors)
494+
495+
end if
496+
497+
if (ierr /= 0) then
498+
call mpas_log_write('Failed to set up hydrometeor packages.', messageType=MPAS_LOG_ERR)
499+
call mpas_timer_stop('setup_hydrometeor_packages')
500+
return
501+
end if
502+
503+
call mpas_log_write(' QC = $l', logicArgs=[qc])
504+
call mpas_log_write(' QR = $l', logicArgs=[qr])
505+
call mpas_log_write('----- done setting up hydrometeor packages -----')
506+
call mpas_log_write('')
507+
508+
call mpas_timer_stop('setup_hydrometeor_packages')
509+
510+
end subroutine setup_hydrometeor_packages
511+
512+
324513
!***********************************************************************
325514
!
326515
! function init_atm_setup_clock

0 commit comments

Comments
 (0)