read_parameters Subroutine

private subroutine read_parameters(driver_config_in, stir_config_in)

FIXME : Add documentation

Arguments

Type IntentOptional Attributes Name
type(driver_config_type), intent(in), optional :: driver_config_in
type(stir_config_type), intent(in), optional, dimension(:), allocatable :: stir_config_in

Contents

Source Code


Source Code

  subroutine read_parameters(driver_config_in, stir_config_in)
    use file_utils, only: open_output_file
    use mp, only: proc0
    use antenna_data, only: init_antenna_data
    use gs2_save, only: init_ant_amp
    use warning_helpers, only: not_exactly_equal
    implicit none
    type(driver_config_type), intent(in), optional :: driver_config_in
    type(stir_config_type), intent(in), dimension(:), allocatable, optional :: stir_config_in
    complex :: a, b
    integer :: kx, ky, kz, i
    logical :: travel, ant_off

    if (present(driver_config_in)) driver_config = driver_config_in

    call driver_config%init(name = 'driver', requires_index = .false.)

    ! Copy out internal values into module level parameters
    associate(self => driver_config)
#include "driver_copy_out_auto_gen.inc"
    end associate

    ! If the namelist wasn't present, or if [[driver_config:ant_off]]
    ! was explicitly set to true, then we won't be using the antenna,
    ! so for consistency, we turn it off in this case
    no_driver = driver_config%ant_off .or. .not. driver_config%exist &
         .or. driver_config%nk_stir < 1
    driver_config%ant_off = no_driver

    if (no_driver) return

    call init_antenna_data (nk_stir)
    allocate (kx_stir(nk_stir))
    allocate (ky_stir(nk_stir))
    allocate (kz_stir(nk_stir))
    allocate (trav(nk_stir))

    ! BD
    ! get initial antenna amplitudes from restart file
    !
    ! TO DO: need to know if there IS a restart file to check...
    !
    if (restarting) call init_ant_amp (a_ant, b_ant, nk_stir)

    if (present(stir_config_in)) stir_config = stir_config_in

    if (.not.allocated(stir_config)) allocate(stir_config(nk_stir))
    if (size(stir_config) /= nk_stir) then
      if (proc0) print*,"Warning: inconsistent config size in antenna"
    end if

    do i = 1, nk_stir
      call stir_config(i)%init(name = 'stir', requires_index = .true., index = i)

      ! Copy out internal values into module level parameters
      associate(self => stir_config(i))
#include "stir_copy_out_auto_gen.inc"
      end associate

      kx_stir(i) = kx
      ky_stir(i) = ky
      kz_stir(i) = kz
      trav(i) = travel
      ! If a, b are not specified in the input file:
      if (not_exactly_equal(a, cmplx(-1.0,0.0)) .or. not_exactly_equal(b, cmplx(-1.0,0.0))) then
         ! Note a and b are declared real in the input, but a_ant / b_ant are complex
        a_ant(i) = a
        b_ant(i) = b
      end if
    end do

    if (proc0) call open_output_file (out_unit, ".antenna")
  end subroutine read_parameters