Skip to content

MPAS MUSICA MICM Solver

David Fillmore edited this page Nov 18, 2025 · 6 revisions

MPAS MUSICA MICM Solver

MICM State Updates within MPAS

mpas_atm_chemistry module

  • Note type conversion from RKIND to real64 via assignment time_step = dt
    subroutine chemistry_step(dt)
    
#ifdef MPAS_USE_MUSICA
        use iso_fortran_env, only: real64
        use mpas_musica, only: musica_step
#endif
        use mpas_log, only : mpas_log_write
        use mpas_derived_types, only: MPAS_LOG_CRIT

        real (kind=RKIND), intent(in) :: dt

#ifdef MPAS_USE_MUSICA
        real(real64)                  :: time_step
        integer                       :: error_code
        character(len=:), allocatable :: error_message

        time_step = dt

        call mpas_log_write('Stepping chemistry packages...')

        call musica_step(time_step, 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_step

mpas_musica module

    subroutine musica_step(time_step, error_code, error_message)
        
        use iso_fortran_env, only: real64

        use musica_micm, only : solver_stats_t
        use musica_util, only : error_t, string_t

        use mpas_log, only : mpas_log_write

        real(real64), intent(in) :: time_step

        integer,                       intent(out) :: error_code
        character(len=:), allocatable, intent(out) :: error_message

        type(string_t)       :: solver_state
        type(solver_stats_t) :: solver_stats
        type(error_t)        :: error

        call mpas_log_write('[MUSICA] Stepping MICM solver...')

        call micm%solve(time_step, state, solver_state, solver_stats, error)
        if (has_error_occurred(error, error_message, error_code)) return

        if (solver_state%get_char_array() /= 'Converged') then
            call mpas_log_write('[MUSICA Warning] MICM solver failure')
        end if

    end subroutine musica_step

MPAS MICM State Coupling

  • Adapt update_micm_state and extract_mixing_ratios_from_state from CAM-SIMA MUSICA
  • CAM-SIMA MUSICA MICM

update_micm_state

extract_mixing_ratios_from_state

Clone this wiki locally