Commit bfc14aca authored by Simon Brass's avatar Simon Brass
Browse files

mpi-box.f08: check on visited boxes

parent 2ec54643
......@@ -6,6 +6,8 @@ program main
integer :: k, ierr, nprocs, myrank
! Box coord
integer :: n_boxes
integer :: i_par_box
integer :: root_i_par_box
logical :: success
real, dimension(5) :: box
! Results
......@@ -34,10 +36,13 @@ program main
! --------------------------------------------------
n_boxes = 3
n_boxes = 5
box = 1
success = .true.
print *, "total number of boxes = ", n_boxes**5
print *, "(overall) total number of boxes = ", n_boxes**5
print *, "total number of perpendicular boxes = ", n_boxes**3
do k = 1, myrank
call increment_box_coord (box(1:2), success)
end do
......@@ -50,9 +55,10 @@ program main
root_total = 0.
root_total_sq = 0.
par: do while (success)
print *, "box (par) = ", box(1:2)
! print *, "box (par) = ", box(1:2)
i_par_box = i_par_box + 1
perp: do while (success)
print *, "box (perp) = ", box(3:5)
! print *, "box (perp) = ", box(3:5)
total = total + 1.5
total_sq = total_sq + 1.5**2
call increment_box_coord (box(3:5), success)
......@@ -63,11 +69,16 @@ program main
end do
end do par
print *, "total number of visited parallel boxes = ", i_par_box
print *, "total number of visited boxes = ", i_par_box * n_boxes**3
call MPI_Reduce (total, root_total, 1, MPI_REAL, MPI_SUM, 0, MPI_COMM_WORLD)
call MPI_Reduce (total_sq, root_total_sq, 1, MPI_REAL, MPI_SUM, 0, MPI_COMM_WORLD)
call MPI_Reduce (i_par_box, root_i_par_box, 1, MPI_INTEGER, MPI_SUM, 0, MPI_COMM_WORLD)
if (myrank == 0) then
print *, "total = ", root_total, " (", n_boxes**5 * 1.5, " )"
print *, "total_sq = ", root_total_sq, " (", n_boxes**5 * 1.5**2, " )"
print *, "n_total_boxes = ", root_i_par_box * n_boxes**3, " (", n_boxes**5, " )"
end if
! --------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment