diff --git a/example/ALL_test_f_obj.F90 b/example/ALL_test_f_obj.F90 index 952db1961f0a9fd612ce3afcceae44f60db5bbdd..a5e50971d7693d848181079c212768c84ea1654b 100644 --- a/example/ALL_test_f_obj.F90 +++ b/example/ALL_test_f_obj.F90 @@ -50,19 +50,19 @@ program ALL_test_f integer :: error integer :: rank, n_ranks real(8),dimension(:,:),allocatable :: new_vertices - integer :: i + integer :: i,j type(ALL_t) :: lb call MPI_INIT(error) - call MPI_COMM_RANK(MPI_COMM_WORLD,rank,error) - call MPI_COMM_SIZE(MPI_COMM_WORLD,n_ranks,error) + call MPI_COMM_RANK(MPI_COMM_WORLD, rank, error) + call MPI_COMM_SIZE(MPI_COMM_WORLD, n_ranks, error) ! create cartesian communicator dims = 0 period = .true. - call MPI_DIMS_CREATE(n_ranks,3,dims, error) + call MPI_DIMS_CREATE(n_ranks, 3, dims, error) call MPI_CART_CREATE(MPI_COMM_WORLD, 3, dims, period, .true., cart_comm, error) ! compute cell length @@ -82,29 +82,32 @@ program ALL_test_f end if end do + ! set up balancer call lb%init(ALL_STAGGERED, 3, 4.0d0) call lb%set_proc_tag(rank) - call lb%set_work(real( product(coords,1)*64,8)) call lb%set_vertices(vertices) - ! if using a non cartesian communicator, this call would be required + ! if using a non cartesian communicator, this call would be required instead ! call lb%set_proc_grid_params(coords,dims) call lb%set_communicator(cart_comm) - call lb%setup() - call lb%balance() - ! If not allocatable as target, must use - ! lb%get_new_number_of_vertices and lb%get_vertices instead! - call lb%get_vertices_alloc(new_vertices) + do j = 1, 2 + call lb%set_work(real( product(coords,1)*64,8)) + call lb%balance() - do i = 0, n_ranks-1 - if (i == rank) then - write(*,"(2(a,i7),2(a,3es14.7))") "rank: ", rank, " ", size(new_vertices,2), " new vertices: ", new_vertices(:,1), & - ", ", new_vertices(:,2) - call MPI_BARRIER(cart_comm, error) - else - call MPI_BARRIER(cart_comm, error) - end if + ! If not allocatable as target, must use + ! lb%get_new_number_of_vertices and lb%get_vertices instead! + call lb%get_vertices_alloc(new_vertices) + + do i = 0, n_ranks-1 + if (i == rank) then + write(*,"(2(a,i7),2(a,3es14.7))") "rank: ", rank, " ", size(new_vertices,2), " new vertices: ", new_vertices(:,1), & + ", ", new_vertices(:,2) + call MPI_BARRIER(cart_comm, error) + else + call MPI_BARRIER(cart_comm, error) + end if + end do end do deallocate(new_vertices) call MPI_FINALIZE(error);