dyn_readnl Subroutine

public subroutine dyn_readnl(namelist_path)

Uses

    • cam_logfile
    • shr_file_mod
    • cam_control_mod
    • string_utils
    • cam_abortutils
    • shr_pio_mod
    • time_manager
    • cam_instance
    • spmd_utils
    • shr_kind_mod
    • pio
  • proc~~dyn_readnl~~UsesGraph proc~dyn_readnl dyn_readnl cam_abortutils cam_abortutils proc~dyn_readnl->cam_abortutils cam_control_mod cam_control_mod proc~dyn_readnl->cam_control_mod cam_instance cam_instance proc~dyn_readnl->cam_instance cam_logfile cam_logfile proc~dyn_readnl->cam_logfile pio pio proc~dyn_readnl->pio shr_file_mod shr_file_mod proc~dyn_readnl->shr_file_mod shr_kind_mod shr_kind_mod proc~dyn_readnl->shr_kind_mod shr_pio_mod shr_pio_mod proc~dyn_readnl->shr_pio_mod spmd_utils spmd_utils proc~dyn_readnl->spmd_utils string_utils string_utils proc~dyn_readnl->string_utils time_manager time_manager proc~dyn_readnl->time_manager

Read MPAS namelist from the supplied path. Additionally, perform early initialization of MPAS dynamical core. (KCW, 2024-02-09)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: namelist_path

Calls

proc~~dyn_readnl~~CallsGraph proc~dyn_readnl dyn_readnl get_run_duration get_run_duration proc~dyn_readnl->get_run_duration get_start_date get_start_date proc~dyn_readnl->get_start_date get_stop_date get_stop_date proc~dyn_readnl->get_stop_date none~sec_to_hour_min_sec sec_to_hour_min_sec proc~dyn_readnl->none~sec_to_hour_min_sec proc~dyn_debug_print dyn_debug_print proc~dyn_readnl->proc~dyn_debug_print proc~dyn_mpas_init_phase1 mpas_dynamical_core_type%dyn_mpas_init_phase1 proc~dyn_readnl->proc~dyn_mpas_init_phase1 proc~dyn_mpas_init_phase2 mpas_dynamical_core_type%dyn_mpas_init_phase2 proc~dyn_readnl->proc~dyn_mpas_init_phase2 proc~dyn_mpas_read_namelist mpas_dynamical_core_type%dyn_mpas_read_namelist proc~dyn_readnl->proc~dyn_mpas_read_namelist shr_file_getunit shr_file_getunit proc~dyn_readnl->shr_file_getunit shr_pio_getiosys shr_pio_getiosys proc~dyn_readnl->shr_pio_getiosys timemgr_get_calendar_cf timemgr_get_calendar_cf proc~dyn_readnl->timemgr_get_calendar_cf stringify stringify proc~dyn_debug_print->stringify atm_setup_core atm_setup_core proc~dyn_mpas_init_phase1->atm_setup_core atm_setup_domain atm_setup_domain proc~dyn_mpas_init_phase1->atm_setup_domain mpas_allocate_domain mpas_allocate_domain proc~dyn_mpas_init_phase1->mpas_allocate_domain mpas_framework_init_phase1 mpas_framework_init_phase1 proc~dyn_mpas_init_phase1->mpas_framework_init_phase1 mpi_comm_rank mpi_comm_rank proc~dyn_mpas_init_phase1->mpi_comm_rank proc~dyn_mpas_debug_print mpas_dynamical_core_type%dyn_mpas_debug_print proc~dyn_mpas_init_phase1->proc~dyn_mpas_debug_print setup_log setup_log proc~dyn_mpas_init_phase1->setup_log define_packages define_packages proc~dyn_mpas_init_phase2->define_packages mpas_framework_init_phase2 mpas_framework_init_phase2 proc~dyn_mpas_init_phase2->mpas_framework_init_phase2 mpas_stream_inquiry_new_streaminfo mpas_stream_inquiry_new_streaminfo proc~dyn_mpas_init_phase2->mpas_stream_inquiry_new_streaminfo pio_iosystem_is_active pio_iosystem_is_active proc~dyn_mpas_init_phase2->pio_iosystem_is_active proc~dyn_mpas_init_phase2->proc~dyn_mpas_debug_print setup_clock setup_clock proc~dyn_mpas_init_phase2->setup_clock setup_decompositions setup_decompositions proc~dyn_mpas_init_phase2->setup_decompositions setup_packages setup_packages proc~dyn_mpas_init_phase2->setup_packages none~get_variable_pointer mpas_dynamical_core_type%get_variable_pointer proc~dyn_mpas_read_namelist->none~get_variable_pointer proc~dyn_mpas_read_namelist->proc~dyn_mpas_debug_print proc~stringify stringify proc~dyn_mpas_read_namelist->proc~stringify setup_namelist setup_namelist proc~dyn_mpas_read_namelist->setup_namelist proc~dyn_mpas_get_variable_pointer_c0 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_c0 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_c0 proc~dyn_mpas_get_variable_pointer_c1 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_c1 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_c1 proc~dyn_mpas_get_variable_pointer_i0 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_i0 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_i0 proc~dyn_mpas_get_variable_pointer_i1 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_i1 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_i1 proc~dyn_mpas_get_variable_pointer_i2 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_i2 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_i2 proc~dyn_mpas_get_variable_pointer_i3 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_i3 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_i3 proc~dyn_mpas_get_variable_pointer_l0 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_l0 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_l0 proc~dyn_mpas_get_variable_pointer_r0 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_r0 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_r0 proc~dyn_mpas_get_variable_pointer_r1 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_r1 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_r1 proc~dyn_mpas_get_variable_pointer_r2 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_r2 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_r2 proc~dyn_mpas_get_variable_pointer_r3 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_r3 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_r3 proc~dyn_mpas_get_variable_pointer_r4 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_r4 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_r4 proc~dyn_mpas_get_variable_pointer_r5 mpas_dynamical_core_type%dyn_mpas_get_variable_pointer_r5 none~get_variable_pointer->proc~dyn_mpas_get_variable_pointer_r5 proc~dyn_mpas_debug_print->proc~stringify mpas_pool_get_array mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_c0->mpas_pool_get_array mpas_pool_get_config mpas_pool_get_config proc~dyn_mpas_get_variable_pointer_c0->mpas_pool_get_config proc~dyn_mpas_get_pool_pointer mpas_dynamical_core_type%dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_c0->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_c1->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_c1->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_i0->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_i0->mpas_pool_get_config mpas_pool_get_dimension mpas_pool_get_dimension proc~dyn_mpas_get_variable_pointer_i0->mpas_pool_get_dimension proc~dyn_mpas_get_variable_pointer_i0->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_i1->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_i1->mpas_pool_get_dimension proc~dyn_mpas_get_variable_pointer_i1->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_i2->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_i2->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_i3->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_i3->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_l0->mpas_pool_get_config proc~dyn_mpas_get_variable_pointer_l0->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_r0->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_r0->mpas_pool_get_config proc~dyn_mpas_get_variable_pointer_r0->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_r1->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_r1->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_r2->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_r2->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_r3->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_r3->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_r4->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_r4->proc~dyn_mpas_get_pool_pointer proc~dyn_mpas_get_variable_pointer_r5->mpas_pool_get_array proc~dyn_mpas_get_variable_pointer_r5->proc~dyn_mpas_get_pool_pointer mpas_pool_get_subpool mpas_pool_get_subpool proc~dyn_mpas_get_pool_pointer->mpas_pool_get_subpool

Variables

Type Visibility Attributes Name Initial
character(len=len_cs), private :: cam_calendar
integer, private :: log_unit(2)
type(iosystem_desc_t), private, pointer :: pio_iosystem
integer, private :: run_duration(4)
integer, private :: sec_since_midnight
integer, private :: start_date_time(6)
integer, private :: stop_date_time(6)
character(len=*), private, parameter :: subname = 'dyn_comp::dyn_readnl'

Functions

pure function sec_to_hour_min_sec(sec) result(hour_min_sec)

Convert second(s) to hour(s), minute(s), and second(s). (KCW, 2024-02-07)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: sec

Return Value integer, (3)


Source Code

    subroutine dyn_readnl(namelist_path)
        ! Module(s) from CAM-SIMA.
        use cam_abortutils, only: endrun
        use cam_control_mod, only: initial_run
        use cam_instance, only: atm_id
        use cam_logfile, only: debug_output, debugout_debug, debugout_info, iulog
        use spmd_utils, only: mpicom
        use string_utils, only: stringify
        use time_manager, only: get_start_date, get_stop_date, get_run_duration, timemgr_get_calendar_cf
        ! Module(s) from CESM Share.
        use shr_file_mod, only: shr_file_getunit
        use shr_kind_mod, only: len_cs => shr_kind_cs
        use shr_pio_mod, only: shr_pio_getiosys
        ! Module(s) from external libraries.
        use pio, only: iosystem_desc_t

        character(*), intent(in) :: namelist_path

        character(*), parameter :: subname = 'dyn_comp::dyn_readnl'
        character(len_cs) :: cam_calendar
        integer :: log_unit(2)
        integer :: start_date_time(6), & ! YYYY, MM, DD, hh, mm, ss.
                   stop_date_time(6),  & ! YYYY, MM, DD, hh, mm, ss.
                   run_duration(4),    & ! DD, hh, mm, ss.
                   sec_since_midnight    ! Second(s) since midnight.
        type(iosystem_desc_t), pointer :: pio_iosystem

        call dyn_debug_print(debugout_debug, subname // ' entered')

        nullify(pio_iosystem)

        ! Get free units for MPAS so it can write its own log files, e.g., "log.atmosphere.0000.{out,err}".
        log_unit(1) = shr_file_getunit()
        log_unit(2) = shr_file_getunit()

        call dyn_debug_print(debugout_info, 'Initializing MPAS dynamical core (Phase 1/4)')

        ! Initialize MPAS framework with the supplied MPI communicator group, procedure pointer to terminate the model,
        ! log level, and units.
        call mpas_dynamical_core % init_phase1(mpicom, endrun, debug_output, iulog, log_unit)

        cam_calendar = timemgr_get_calendar_cf()

        call get_start_date(start_date_time(1), start_date_time(2), start_date_time(3), sec_since_midnight)
        start_date_time(4:6) = sec_to_hour_min_sec(sec_since_midnight)

        call get_stop_date(stop_date_time(1), stop_date_time(2), stop_date_time(3), sec_since_midnight)
        stop_date_time(4:6) = sec_to_hour_min_sec(sec_since_midnight)

        call get_run_duration(run_duration(1), sec_since_midnight)
        run_duration(2:4) = sec_to_hour_min_sec(sec_since_midnight)

        call dyn_debug_print(debugout_info, 'Reading namelist')

        ! Read MPAS-related namelist variables from `namelist_path`, e.g., "atm_in".
        call mpas_dynamical_core % read_namelist(namelist_path, &
            cam_calendar, start_date_time, stop_date_time, run_duration, initial_run)

        pio_iosystem => shr_pio_getiosys(atm_id)

        call dyn_debug_print(debugout_info, 'Initializing MPAS dynamical core (Phase 2/4)')

        ! Initialize MPAS framework with the supplied PIO system descriptor.
        call mpas_dynamical_core % init_phase2(pio_iosystem)

        nullify(pio_iosystem)

        call dyn_debug_print(debugout_debug, subname // ' completed')
    contains
        !> Convert second(s) to hour(s), minute(s), and second(s).
        !> (KCW, 2024-02-07)
        pure function sec_to_hour_min_sec(sec) result(hour_min_sec)
            integer, intent(in) :: sec
            integer :: hour_min_sec(3)

            ! These are all intended to be integer arithmetics.
            hour_min_sec(1) = sec / 3600
            hour_min_sec(2) = sec / 60 - hour_min_sec(1) * 60
            hour_min_sec(3) = sec - hour_min_sec(1) * 3600 - hour_min_sec(2) * 60
        end function sec_to_hour_min_sec
    end subroutine dyn_readnl