Skip to content

Commit 80ed4cc

Browse files
committed
updates array initialization for scotch partitioning
1 parent 2a5e4d1 commit 80ed4cc

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/decompose_mesh/partition_scotch.F90

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ subroutine lts_partition_scotch()
244244
adjncy_tmp(1:nb_edges+1), &
245245
stat=ier)
246246
if (ier /= 0) stop 'Error allocating array part_tmp,...'
247+
! initializes
248+
part_tmp(:) = 0
249+
elmnts_load_tmp(:) = 0
250+
ispec_global(:) = 0
251+
ispec_local(:) = 0
252+
xadj_tmp(:) = -1
253+
adjncy_tmp(:) = 0
247254

248255
! partitions each p-level separately
249256
do ilevel = 1,num_p_level
@@ -330,7 +337,7 @@ subroutine lts_partition_scotch()
330337
print *,' p-level partitioning: p-level =',ilevel,'p =',p,'elements =',nspec_p !,'edges =',nb_edges_tmp
331338

332339
! scotch partitioning
333-
! arguments: #(1) graph_structure #(2)baseval (either 0/1) #(3)vertnbr (number_of_vertices)
340+
! arguments: #(1)graph_structure #(2)baseval (either 0/1) #(3)vertnbr (number_of_vertices)
334341
! #(4)verttab (adjacency_index_array) #(5)vendtab (adjacency_end_index_array (optional))
335342
! #(6)velotab (vertex_load_array (optional)) #(7)vlbltab (vertex_label_array)
336343
! #(7)edgenbr (number_of_arcs) #(8)edgetab (adjacency_array)
@@ -427,7 +434,7 @@ subroutine remap_partitions(part)
427434
integer :: current_partition
428435
logical, dimension(:), allocatable :: partition_available
429436
integer, dimension(:), allocatable :: part_remap, part_remap_inverse
430-
integer :: ipart, unused_count, best_choice, ilevel
437+
integer :: ipart, unused_count, best_choice, ilevel, ier
431438
integer :: p, ispec
432439

433440
! Try to reconnect the individually partitioned levels in a
@@ -436,9 +443,17 @@ subroutine remap_partitions(part)
436443
! should be sufficient.
437444

438445
if (SCOTCH_P_REMAP) then
439-
allocate(partition_available(0:nparts-1))
440-
allocate(part_remap(0:nparts-1))
441-
allocate(part_remap_inverse(0:nparts-1))
446+
allocate(partition_available(0:nparts-1),stat=ier)
447+
if (ier /= 0) stop 'Error allocating partition_available array'
448+
partition_available(:) = .true.
449+
450+
allocate(part_remap(0:nparts-1),stat=ier)
451+
if (ier /= 0) stop 'Error allocating part_remap array'
452+
part_remap(:) = -1
453+
454+
allocate(part_remap_inverse(0:nparts-1),stat=ier)
455+
if (ier /= 0) stop 'Error allocating part_remap_inverse array'
456+
part_remap_inverse(:) = -1
442457

443458
do ilevel = 1,num_p_level-1
444459
part_remap(:) = -1
@@ -490,6 +505,9 @@ subroutine remap_partitions(part)
490505

491506
enddo ! ilevel
492507

508+
! free temporary arrays
509+
deallocate(partition_available,part_remap,part_remap_inverse)
510+
493511
endif
494512

495513
end subroutine remap_partitions

0 commit comments

Comments
 (0)