Skip to content

Commit bcd15ef

Browse files
committed
fixed issues if changing vertex metadata
some cleanups
1 parent 6b49fa7 commit bcd15ef

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/dag_module.F90

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,11 @@ subroutine dag_set_vertex_info(me,ivertex,label,attributes,metadata)
459459

460460
if (present(label)) me%vertices(ivertex)%label = label
461461
if (present(attributes)) me%vertices(ivertex)%attributes = attributes
462-
if (present(metadata)) allocate(me%vertices(ivertex)%metadata, source=metadata)
463-
462+
if (present(metadata)) then
463+
if (allocated(me%vertices(ivertex)%metadata)) &
464+
deallocate(me%vertices(ivertex)%metadata)
465+
allocate(me%vertices(ivertex)%metadata, source=metadata)
466+
end if
464467
end subroutine dag_set_vertex_info
465468
!*******************************************************************************
466469

@@ -961,10 +964,10 @@ recursive subroutine quicksort(ilow,ihigh)
961964
if ( ihigh-ilow<=max_size_for_insertion_sort .and. ihigh>ilow ) then
962965

963966
! do insertion sort:
964-
do i = ilow + 1,ihigh
965-
do j = i,ilow + 1,-1
966-
if ( ivec(j)%ivertex < ivec(j-1)%ivertex ) then
967-
call swap(ivec(j),ivec(j-1))
967+
do i = ilow + 1_ip,ihigh
968+
do j = i,ilow + 1_ip,-1_ip
969+
if ( ivec(j)%ivertex < ivec(j-1_ip)%ivertex ) then
970+
call swap(ivec(j),ivec(j-1_ip))
968971
else
969972
exit
970973
end if
@@ -993,11 +996,11 @@ subroutine partition(ilow,ihigh,ipivot)
993996

994997
integer(ip) :: i,ii
995998

996-
call swap(ivec(ilow),ivec((ilow+ihigh)/2))
999+
call swap(ivec(ilow),ivec((ilow+ihigh)/2_ip))
9971000
ii = ilow
998-
do i = ilow + 1, ihigh
1001+
do i = ilow + 1_ip, ihigh
9991002
if ( ivec(i)%ivertex < ivec(ilow)%ivertex ) then
1000-
ii = ii + 1
1003+
ii = ii + 1_ip
10011004
call swap(ivec(ii),ivec(i))
10021005
end if
10031006
end do

0 commit comments

Comments
 (0)