ClampCell Function

public pure function ClampCell(rIdx, nCells) result(c)

Convert a (signed, possibly out-of-range) real cell index to an integer cell index clamped to [0, nCells-1].

Arguments

TypeIntentOptionalAttributesName
real(kind=prec), intent(in) :: rIdx
integer, intent(in) :: nCells

Return Value integer


Called by

proc~~clampcell~~CalledByGraph proc~clampcell ClampCell proc~locatepoints_2d_points_t LocatePoints_2D_Points_t proc~locatepoints_2d_points_t->proc~clampcell proc~locatepoints_3d_points_t LocatePoints_3D_Points_t proc~locatepoints_3d_points_t->proc~clampcell

Contents

Source Code


Source Code

  pure function ClampCell(rIdx,nCells) result(c)
    !! Convert a (signed, possibly out-of-range) real cell index to an integer
    !! cell index clamped to [0, nCells-1].
    implicit none
    real(prec),intent(in) :: rIdx
    integer,intent(in) :: nCells
    integer :: c

    c = int(floor(rIdx))
    if(c < 0) c = 0
    if(c > nCells-1) c = nCells-1

  endfunction ClampCell