handle_camera Subroutine

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

Read in Camera settings and initalise variable

Arguments

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

Detector table

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

Array of cameras

integer, intent(inout) :: counts

Number of cameras 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_camera(child, dects, counts, context, error)
        !! Read in Camera settings and initalise variable
        use detectors,     only : camera
        use sim_state_mod, only : state

        !> Detector table
        type(toml_table), pointer,     intent(in)    :: child
        !> Array of cameras
        type(camera),                  intent(inout) :: dects(:)
        !> Number of cameras 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
        type(vector)  :: p1, p2, p3
        logical       :: trackHistory

        p1 = get_vector(child, "p1", default=vector(-1.0, -1.0, -1.0), context=context, error=error)
        p2 = get_vector(child, "p2", default=vector(2.0, 0.0, 0.0), context=context, error=error)
        p3 = get_vector(child, "p3", default=vector(0.0, 2.0, 0.0), context=context, error=error)

        call get_value(child, "layer", layer, 1)
        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) = camera(p1, p2, p3, layer, nbins, maxval, trackHistory)
        counts = counts + 1

    end subroutine handle_camera