arg_in_segment_list Function

private pure function arg_in_segment_list(a, seg_list) result(res)

Check if the ginve integer is within any of specified segments in a list.

This function determins whether the integer a falls within any of the ranges defined by the min and max value of the segment_t type in the provided list of segments.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: a
type(segment_t), intent(in) :: seg_list(:)

Return Value logical


Source Code

   pure function arg_in_segment_list(a, seg_list) result(res)
      implicit none
      integer(int32),  intent(in) :: a
      type(segment_t), intent(in) :: seg_list(:)
      logical :: res
      integer :: i

      ! Initialize
      res = .false.

      ! Scan the list of segments
      do i = 1, ubound(seg_list, dim=1)
         res = res .or. (seg_list(i)%min <= a .and. a <= seg_list(i)%max)
      end do
   end function arg_in_segment_list