Append vertical outline segments at strip edge e.
Spans of y covered by exactly one of the two adjacent models' interval sets. Values are
exact copies of mbound reals, so membership tests are exact.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=real64), | intent(in) | :: | alo(:) |
Intervals of the models left ( |
||
| real(kind=real64), | intent(in) | :: | ahi(:) |
Intervals of the models left ( |
||
| integer(kind=int32), | intent(in) | :: | na |
Number of |
||
| real(kind=real64), | intent(in) | :: | blo(:) |
Intervals of the models left ( |
||
| real(kind=real64), | intent(in) | :: | bhi(:) |
Intervals of the models left ( |
||
| integer(kind=int32), | intent(in) | :: | nb |
Number of |
||
| integer(kind=int32), | intent(in) | :: | e |
Number of |
||
| real(kind=real64), | intent(inout) | :: | bp(:) |
Breakpoint scratch, at least |
||
| integer(kind=int32), | intent(inout), | allocatable | :: | se0(:) |
Strip edge of each segment's first and second end. |
|
| integer(kind=int32), | intent(inout), | allocatable | :: | se1(:) |
Strip edge of each segment's first and second end. |
|
| real(kind=real64), | intent(inout), | allocatable | :: | sy0(:) |
y of each segment's first and second end. |
|
| real(kind=real64), | intent(inout), | allocatable | :: | sy1(:) |
y of each segment's first and second end. |
|
| integer(kind=int32), | intent(inout) | :: | ns |
Number of segments, incremented per appended segment. |
subroutine symdiff_append(alo, ahi, na, blo, bhi, nb, e, bp, & se0, se1, sy0, sy1, ns) !! Append vertical outline segments at strip edge `e`. !! !! Spans of y covered by exactly one of the two adjacent models' interval sets. Values are !! exact copies of `mbound` reals, so membership tests are exact. ! Arguments real(real64), intent(in) :: alo(:), ahi(:), blo(:), bhi(:) !! Intervals of the models left (`a`) and right (`b`) of the edge. integer(int32), intent(in) :: na, nb, e !! Number of `a` intervals; number of `b` intervals; strip edge. real(real64), intent(inout) :: bp(:) !! Breakpoint scratch, at least `2*(na + nb)` long. integer(int32), allocatable, intent(inout) :: se0(:), se1(:) !! Strip edge of each segment's first and second end. real(real64), allocatable, intent(inout) :: sy0(:), sy1(:) !! y of each segment's first and second end. integer(int32), intent(inout) :: ns !! Number of segments, incremented per appended segment. integer(int32) :: k, p, nbp real(real64) :: y0, y1, v logical :: ina, inb nbp = 0 do k = 1, na if (ahi(k) > alo(k)) then nbp = nbp + 1; bp(nbp) = alo(k) nbp = nbp + 1; bp(nbp) = ahi(k) end if end do do k = 1, nb if (bhi(k) > blo(k)) then nbp = nbp + 1; bp(nbp) = blo(k) nbp = nbp + 1; bp(nbp) = bhi(k) end if end do if (nbp < 2) return ! insertion sort: the lists are tiny and already mostly ordered do p = 2, nbp v = bp(p) k = p - 1 do while (k >= 1) if (bp(k) <= v) exit bp(k + 1) = bp(k) k = k - 1 end do bp(k + 1) = v end do do p = 1, nbp - 1 y0 = bp(p); y1 = bp(p + 1) if (y1 <= y0) cycle ina = .false. do k = 1, na if (alo(k) <= y0 .and. y1 <= ahi(k)) then ina = .true.; exit end if end do inb = .false. do k = 1, nb if (blo(k) <= y0 .and. y1 <= bhi(k)) then inb = .true.; exit end if end do if (ina .neqv. inb) then ! merge with the previous segment when contiguous if (ns > 0) then if (se0(ns) == e .and. se1(ns) == e .and. sy1(ns) == y0) then sy1(ns) = y1 cycle end if end if call seg_append(se0, se1, sy0, sy1, ns, e, e, y0, y1) end if end do end subroutine symdiff_append