read_optimisation_config Subroutine

private subroutine read_optimisation_config(self)

Uses

Reads in the optimisation_config namelist and populates the member variables

Type Bound

optimisation_config_type

Arguments

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

Contents


Source Code

  subroutine read_optimisation_config(self)
    use file_utils, only: input_unit_exist, get_indexed_namelist_unit
    use mp, only: proc0
    implicit none
    class(optimisation_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.    
    integer :: max_unused_procs, nstep_measure
    logical :: auto, estimate_timing_error, measure_all, on, warm_up
    real :: max_imbalance, min_efficiency

    namelist /optimisation_config/ auto, estimate_timing_error, max_imbalance, max_unused_procs, measure_all, min_efficiency, nstep_measure, on, warm_up

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

    ! First set local variables from current values
    auto = self%auto
    estimate_timing_error = self%estimate_timing_error
    max_imbalance = self%max_imbalance
    max_unused_procs = self%max_unused_procs
    measure_all = self%measure_all
    min_efficiency = self%min_efficiency
    nstep_measure = self%nstep_measure
    on = self%on
    warm_up = self%warm_up

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

    ! Now copy from local variables into type members
    self%auto = auto
    self%estimate_timing_error = estimate_timing_error
    self%max_imbalance = max_imbalance
    self%max_unused_procs = max_unused_procs
    self%measure_all = measure_all
    self%min_efficiency = min_efficiency
    self%nstep_measure = nstep_measure
    self%on = on
    self%warm_up = warm_up

    self%exist = exist
  end subroutine read_optimisation_config