read_reinit_config Subroutine

private subroutine read_reinit_config(self)

Uses

Reads in the reinit_knobs namelist and populates the member variables

Type Bound

reinit_config_type

Arguments

Type IntentOptional Attributes Name
class(reinit_config_type), intent(inout) :: self

Contents

Source Code


Source Code

  subroutine read_reinit_config(self)
    use file_utils, only: input_unit_exist, get_indexed_namelist_unit
    use mp, only: proc0
    implicit none
    class(reinit_config_type), intent(in out) :: self
    logical :: exist
    integer :: in_file

    ! Note: When this routine is in the module where these variables live
    ! we shadow the module level variables here. This is intentional to provide
    ! isolation and ensure we can move this routine to another module easily.    
    logical :: abort_rapid_time_step_change, in_memory
    real :: delt_adj, delt_cushion, delt_minimum, dt0

    namelist /reinit_knobs/ abort_rapid_time_step_change, delt_adj, delt_cushion, delt_minimum, dt0, in_memory

    ! Only proc0 reads from file
    if (.not. proc0) return

    ! First set local variables from current values
    abort_rapid_time_step_change = self%abort_rapid_time_step_change
    delt_adj = self%delt_adj
    delt_cushion = self%delt_cushion
    delt_minimum = self%delt_minimum
    dt0 = self%dt0
    in_memory = self%in_memory

    ! Now read in the main namelist
    in_file = input_unit_exist(self%get_name(), exist)
    if (exist) read(in_file, nml = reinit_knobs)

    ! Now copy from local variables into type members
    self%abort_rapid_time_step_change = abort_rapid_time_step_change
    self%delt_adj = delt_adj
    self%delt_cushion = delt_cushion
    self%delt_minimum = delt_minimum
    self%dt0 = dt0
    self%in_memory = in_memory

    self%exist = exist
  end subroutine read_reinit_config