read_normalisations_config Subroutine

private subroutine read_normalisations_config(self)

Uses

Reads in the normalisations_knobs namelist and populates the member variables

Type Bound

normalisations_config_type

Arguments

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

Contents


Source Code

  subroutine read_normalisations_config(self)
    use file_utils, only: input_unit_exist, get_indexed_namelist_unit
    use mp, only: proc0
    implicit none
    class(normalisations_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.    
    real :: aref, bref, mref, nref, rhoref, tref, vref, zref

    namelist /normalisations_knobs/ aref, bref, mref, nref, rhoref, tref, vref, zref

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

    ! First set local variables from current values
    aref = self%aref
    bref = self%bref
    mref = self%mref
    nref = self%nref
    rhoref = self%rhoref
    tref = self%tref
    vref = self%vref
    zref = self%zref

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

    ! Now copy from local variables into type members
    self%aref = aref
    self%bref = bref
    self%mref = mref
    self%nref = nref
    self%rhoref = rhoref
    self%tref = tref
    self%vref = vref
    self%zref = zref

    self%exist = exist
  end subroutine read_normalisations_config