FUNCTION pairing (list1, list2, fbpt, last) RESULT (paired)
use cell_test, except_this_one => pairing
IMPLICIT NONE
LOGICAL paired
TYPE (cell), TARGET, INTENT(IN):: list1, list2
TYPE (cell), POINTER, INTENT(INOUT):: fbpt
TYPE (cell), POINTER, INTENT(INOUT):: last
LOGICAL :: found = .FALSE.
INTEGER :: i, j, k
INTEGER, DIMENSION(2):: tedge
TYPE (cell), POINTER :: pt1, pt2
found = .FALSE.
paired = .FALSE.
pt1 => list1
pt2 => list2
!print *, "pairng #1"
tedge = (/0,0/)
loop2:DO while(associated(pt2))
if(pt2%vertex(1) .eq. Tagged) then
pt2=> pt2%next
end if
if(pt1%myself%index .eq. pt2%myself%index) then
pt2 => pt2%next
end if
if (.not. associated(pt2)) then
found = .FALSE.
paired = .FALSE.
exit loop2
end if
call find_fedge (pt1%myself%vertex, pt2%myself%vertex, pt1%myself%vsize, pt2%myself%vsize, found, tedge)
if (found) then
write (7,*) "paring:: found, the edge is =", (tedge(i), i=1, 2)
write ( 7, '(A8,8x,I3,1x,I3,1x,A4,1x,I3,1x,I3)') &
"paring::",pt1%index,pt1%myself%index,"cell", pt2%index,pt2%myself%index
write ( 7, '(A9,7x,15I5)') "paring:1:",(pt1%myself%vertex(i), i=1, pt1%myself%vsize)
write ( 7, '(A9,7x,15I5)') "paring:2:",(pt2%myself%vertex(i), i=1, pt2%myself%vsize)
tedge = (/0,0/)
allocate(fbpt%myself)
fbpt => fbpt%myself
nullify(fbpt%prev)
nullify(fbpt%next)
nullify(fbpt%myself)
!print *, "pairng:: #8 %next => pt2, %prev => pt1"
fbpt%next => pt2
fbpt%prev => pt1
fbpt%next%vertex(1) = Tagged
fbpt%prev%vertex(1) = Tagged
last => pt2
paired = .TRUE.
exit loop2
else
found = .FALSE.
paired = .FALSE.
pt2 =>pt2%next
end if
END DO loop2
END FUNCTION pairing