[Dart-dev] DART/branches Revision: 12408

dart at ucar.edu dart at ucar.edu
Tue Feb 20 15:17:10 MST 2018


hendric at ucar.edu
2018-02-20 15:17:09 -0700 (Tue, 20 Feb 2018)
181
refactoring code in order to make it easier to add groups
independintely of the array and or size. Would like to only
have public get and set routines for distributed static data.




Modified: DART/branches/rma_static_data/developer_tests/mpi_groups/tests/ftest_groups.f90
===================================================================
--- DART/branches/rma_static_data/developer_tests/mpi_groups/tests/ftest_groups.f90	2018-02-15 22:42:58 UTC (rev 12407)
+++ DART/branches/rma_static_data/developer_tests/mpi_groups/tests/ftest_groups.f90	2018-02-20 22:17:09 UTC (rev 12408)
@@ -55,35 +55,89 @@
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
 ! integer variables
-integer :: ierror, world_rank, world_size, group_rank, group_size, color, i, j
-integer :: MPI_ROW_COMM, MPI_COMM_GRID
-integer :: row_rank, row_size, subgroup, top, bottom
-integer, allocatable :: members(:)
+integer :: ierror, world_rank, world_size, group_rank, group_size
+integer :: i, j
+integer :: static_id
+
 logical :: do_print
+
 integer, parameter :: nxA = 10
 integer, parameter :: nyA = 10
-real :: A(nxA,nyA) = -1
+real, allocatable  :: A(:,:)
+
+integer(KIND=MPI_OFFSET_KIND) :: x_length, num_static_arrays
+integer(KIND=MPI_OFFSET_KIND) :: my_num_y_vals !< splitting up by we
+
 ! real :: B(nxA,nyA) = -1
 ! real :: C(nxA,nyA) = -1
 
+logical :: not_initialized = .true.
+
+allocate(A(nxA, nyA))
+A = -1.0
+
 group_size = 4
 
 ierror = -999
 call MPI_Init(ierror)
 
-world_rank = -1
-call MPI_Comm_rank(MPI_COMM_WORLD, world_rank, ierror)
+call get_world_rank(world_rank)
+do_print = (world_rank == 0)
 
-world_size = -1
-call MPI_Comm_size(MPI_COMM_WORLD, world_size, ierror)
+if (world_rank == 0) then
+   do i = 1,nxA
+     do j = 1,nyA
+        A(i,j) = i + (j-1)*nxA
+     enddo
+   enddo
+endif
+
+call split_groups()
+
+
+static_id = distribute_static_data(nxA, nyA, A) 
+
+ierror = -999
+call MPI_Finalize(ierror)
 if (ierror /= MPI_SUCCESS) then
-   print*, "MPI_Comm_size failed with error code", ierror
+   print *, "MPI_Finalize() did not succeed, error code = ", ierror
    stop
 endif
 
-do_print = (world_rank == 0)
-if (do_print) print *, "Total MPI tasks: ", world_size
+if (do_print) then
+   print *, "All MPI calls succeeded, test passed."
+   print *, "program end"
+endif
 
+contains
+
+!-------------------------------------------------------------------------------
+
+subroutine initialize_mpi()
+
+if (not_initialized) then
+   call MPI_Init(ierror)
+   not_initialized = .false.
+endif
+
+end subroutine initialize_mpi
+
+!-------------------------------------------------------------------------------
+
+subroutine split_groups()
+
+integer :: row_rank
+integer :: row_size
+integer :: MPI_ROW_COMM
+integer :: color
+integer :: world_rank
+integer :: world_size
+
+if( .not. not_initialized ) call initialize_mpi()
+
+call get_world_rank(world_rank)


More information about the Dart-dev mailing list