get_indices Subroutine

public subroutine get_indices(pos, ind)

Find closests beam_grid indices ind to position pos

Arguments

TypeIntentOptionalAttributesName
real(kind=Float64), intent(in), dimension(3):: pos

Position [cm]

integer(kind=Int32), intent(out), dimension(3):: ind

Closest indices to position


Called by

proc~~get_indices~~CalledByGraph proc~get_indices get_indices proc~store_fw_photons store_fw_photons proc~store_fw_photons->proc~get_indices proc~store_photons store_photons proc~store_photons->proc~get_indices proc~track track proc~track->proc~get_indices proc~npa_mc npa_mc proc~npa_mc->proc~get_indices proc~npa_f npa_f proc~npa_f->proc~get_indices proc~store_photon_birth store_photon_birth proc~store_photon_birth->proc~get_indices proc~dcx_spec dcx_spec proc~dcx_spec->proc~store_photons proc~store_fida_photons store_fida_photons proc~store_fida_photons->proc~store_photons proc~ndmc ndmc proc~ndmc->proc~track proc~store_nbi_photons store_nbi_photons proc~ndmc->proc~store_nbi_photons program~fidasim fidasim program~fidasim->proc~npa_mc program~fidasim->proc~npa_f program~fidasim->proc~dcx_spec program~fidasim->proc~ndmc proc~make_diagnostic_grids make_diagnostic_grids program~fidasim->proc~make_diagnostic_grids proc~dcx dcx program~fidasim->proc~dcx proc~fida_f fida_f program~fidasim->proc~fida_f proc~fida_mc fida_mc program~fidasim->proc~fida_mc proc~pfida_f pfida_f program~fidasim->proc~pfida_f proc~fida_weights_mc fida_weights_mc program~fidasim->proc~fida_weights_mc proc~halo halo program~fidasim->proc~halo proc~nbi_spec nbi_spec program~fidasim->proc~nbi_spec proc~halo_spec halo_spec program~fidasim->proc~halo_spec proc~cold_spec cold_spec program~fidasim->proc~cold_spec proc~pfida_mc pfida_mc program~fidasim->proc~pfida_mc proc~fida_weights_los fida_weights_los program~fidasim->proc~fida_weights_los proc~make_diagnostic_grids->proc~track proc~store_nbi_photons->proc~store_photons proc~dcx->proc~store_photons proc~dcx->proc~track proc~dcx->proc~store_photon_birth proc~fida_f->proc~track proc~fida_f->proc~store_photon_birth proc~fida_f->proc~store_fida_photons proc~fida_mc->proc~track proc~fida_mc->proc~store_photon_birth proc~fida_mc->proc~store_fida_photons proc~pfida_f->proc~store_photon_birth proc~pfida_f->proc~store_fida_photons proc~fida_weights_mc->proc~store_fw_photons proc~fida_weights_mc->proc~track proc~halo->proc~store_photons proc~halo->proc~track proc~halo->proc~store_photon_birth proc~nbi_spec->proc~store_photons proc~halo_spec->proc~store_photons proc~cold_spec->proc~store_photons proc~pfida_mc->proc~store_photon_birth proc~pfida_mc->proc~store_fida_photons proc~fida_weights_los->proc~track

Contents

Source Code


Source Code

subroutine get_indices(pos, ind)
    !+ Find closests [[libfida:beam_grid]] indices `ind` to position `pos`
    real(Float64),  dimension(3), intent(in)  :: pos
        !+ Position [cm]
    integer(Int32), dimension(3), intent(out) :: ind
        !+ Closest indices to position

    real(Float64),  dimension(3) :: mini
    integer(Int32), dimension(3) :: maxind
    integer :: i

    maxind(1) = beam_grid%nx
    maxind(2) = beam_grid%ny
    maxind(3) = beam_grid%nz

    mini(1) = minval(beam_grid%xc) - 0.5*beam_grid%dr(1)
    mini(2) = minval(beam_grid%yc) - 0.5*beam_grid%dr(2)
    mini(3) = minval(beam_grid%zc) - 0.5*beam_grid%dr(3)

    do i=1,3
        ind(i) = floor((pos(i)-mini(i))/beam_grid%dr(i)) + 1
        if (ind(i).gt.maxind(i)) ind(i)=maxind(i)
        if (ind(i).lt.1) ind(i)=1
    enddo

end subroutine get_indices