Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/core_atmosphere/Registry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,15 @@
possible_values="`mpas_dmpar', `mpas_halo'"/>
</nml_record>

#ifdef MPAS_USE_MUSICA
<nml_record name="musica" in_defaults="true">
<nml_option name="config_micm_file" type="character" default_value=""
units="-"
description="MICM configuration file name"
possible_values="Any valid filename"/>
</nml_record>
#endif

<!-- **************************************************************************************** -->
<!-- ************************************** Packages ************************************** -->
<!-- **************************************************************************************** -->
Expand Down
22 changes: 12 additions & 10 deletions src/core_atmosphere/chemistry/mpas_atm_chemistry.F
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,19 @@ subroutine chemistry_init(configs, dimensions)
use mpas_musica, only: musica_init
#endif
use mpas_log, only : mpas_log_write
use mpas_derived_types, only: mpas_pool_type
use mpas_derived_types, only: mpas_pool_type, MPAS_LOG_CRIT
use mpas_kind_types, only: StrKIND
use mpas_pool_routines, only: mpas_pool_get_config, mpas_pool_get_dimension

type (mpas_pool_type), intent(in) :: configs
type (mpas_pool_type), intent(in) :: dimensions

#ifdef MPAS_USE_MUSICA
integer :: error_code
character(len=:), allocatable :: error_message
integer :: nVertLevels
integer, pointer :: nVertLevels_ptr
! MUSICA will get the MICM JSON config from a namelist
! hardcode filepath for now
character(len=StrKIND) :: filepath = 'chapman.json'
character(len=StrKIND), pointer :: filepath_ptr
integer :: error_code
character(len=:), allocatable :: error_message
integer :: nVertLevels
integer, pointer :: nVertLevels_ptr
#endif

call mpas_log_write('Initializing chemistry packages...')
Expand All @@ -66,9 +64,13 @@ subroutine chemistry_init(configs, dimensions)
call mpas_pool_get_dimension(dimensions, 'nVertLevels', nVertLevels_ptr)
nVertLevels = nVertLevels_ptr

call musica_init(filepath, nVertLevels, error_code, error_message)
call mpas_pool_get_config(configs, 'config_micm_file', filepath_ptr)

! TODO check error_code and generate MPAS error log message
call musica_init(filepath_ptr, nVertLevels, error_code, error_message)

if (error_code /= 0) then
call mpas_log_write(error_message, messageType=MPAS_LOG_CRIT)
end if
#endif

end subroutine chemistry_init
Expand Down
6 changes: 5 additions & 1 deletion src/core_atmosphere/chemistry/musica/mpas_musica.F
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ subroutine musica_init(filename_of_micm_configuration, &

type(error_t) :: error
type(string_t) :: micm_version

! TEMPORARY: Hard-coded options for the MICM solver
integer :: solver_type = RosenbrockStandardOrder
integer :: i_species

micm_version = get_micm_version()

Expand All @@ -77,6 +77,10 @@ subroutine musica_init(filename_of_micm_configuration, &
state => micm%get_state(number_of_grid_cells, error)
if (has_error_occurred(error, error_message, error_code)) return

do i_species = 1, state%species_ordering%size()
call mpas_log_write('MICM species: ' // state%species_ordering%name(i_species))
end do

end subroutine musica_init

!------------------------------------------------------------------------
Expand Down