handle_circle_dect Subroutine

private subroutine handle_circle_dect(child, dects, counts, context, error)

Read in Circle_detector settings and initalise variable

Arguments

Type IntentOptional Attributes Name
type(toml_table), intent(in), pointer :: child

Detector table

type(circle_dect), intent(inout) :: dects(:)

Array ofcircle_dects

integer, intent(inout) :: counts

Number of circle_dects to create

type(toml_context), intent(in) :: context

Context handle for error reporting.

type(toml_error), intent(out), allocatable :: error

Error message


Source Code

    subroutine handle_circle_dect(child, dects, counts, context, error)
        !! Read in Circle_detector settings and initalise variable
        use detectors,     only : circle_dect
        use sim_state_mod, only : state

        !> Detector table
        type(toml_table), pointer,     intent(in)    :: child
        !> Array ofcircle_dects
        type(circle_dect),             intent(inout) :: dects(:)
        !> Number of circle_dects to create
        integer,                       intent(inout) :: counts
        !> Context handle for error reporting.
        type(toml_context),            intent(in)    :: context
        !> Error message
        type(toml_error), allocatable, intent(out)   :: error

        integer       :: layer, nbins
        real(kind=wp) :: maxval, radius
        type(vector)  :: pos, dir
        logical       :: trackHistory

        pos = get_vector(child, "position", context=context, error=error)
        dir = get_vector(child, "direction", default=vector(0.0, 0.0, -1.0), context=context, error=error)
        dir = dir%magnitude()
        call get_value(child, "layer", layer, 1)
        call get_value(child, "radius1", radius)
        call get_value(child, "nbins", nbins, 100)
        call get_value(child, "maxval", maxval, 100._wp)
        call get_value(child, "trackHistory", trackHistory, .false.)
        if(trackHistory)state%trackHistory=.true.
#ifdef _OPENMP
        if(trackHistory)then
            call make_error(error, "Track history currently incompatable with OpenMP!", -1)
            return
        end if
#endif
        dects(counts) = circle_dect(pos, dir, layer, radius, nbins, maxval, trackHistory)
        counts = counts + 1

    end subroutine handle_circle_dect