[Dart-dev] DART/branches Revision: 12462

dart at ucar.edu dart at ucar.edu
Fri Mar 23 11:45:58 MDT 2018


hendric at ucar.edu
2018-03-23 11:45:58 -0600 (Fri, 23 Mar 2018)
48

adding optional communicator for task_count()




Modified: DART/branches/rma_distrib/assimilation_code/modules/utilities/mpi_utilities_mod.f90
===================================================================
--- DART/branches/rma_distrib/assimilation_code/modules/utilities/mpi_utilities_mod.f90	2018-03-23 17:38:12 UTC (rev 12461)
+++ DART/branches/rma_distrib/assimilation_code/modules/utilities/mpi_utilities_mod.f90	2018-03-23 17:45:58 UTC (rev 12462)
@@ -504,8 +504,8 @@
 !> Return the total number of MPI tasks.  e.g. if the number of tasks is 4,
 !> it returns 4.  (The actual task numbers are 0-3.)
 
-function task_count()
-
+function task_count(mpi_comm)
+integer, optional, intent(in) :: mpi_comm
 integer :: task_count
 
 if ( .not. module_initialized ) then
@@ -513,7 +513,14 @@
    call error_handler(E_ERR,'task_count', errstring, source, revision, revdate)
 endif
 
-task_count = total_tasks
+if (present(mpi_comm)) then
+   call MPI_Comm_size(mpi_comm, total_tasks, errcode)
+   if (errcode /= MPI_SUCCESS) then
+      write(errstring, '(a,i8)') 'MPI_Comm_rank returned error code ', errcode
+      call error_handler(E_ERR,'mpi_task_id', errstring, source, revision, revdate)
+   endif
+   task_count = total_tasks
+endif
 
 end function task_count
 
@@ -2059,7 +2066,6 @@
 call mpi_comm_create(my_local_comm, subgroup, mpi_group_comm, ierr)
 call mpi_group_size(subgroup, group_size, ierr)
 call mpi_group_rank(subgroup, group_rank, ierr)
-print*, 'group_rank ', local_group_rank, group_rank, group_size
 
 !if (verbose) then
 if (.true.) then

Modified: DART/branches/rma_distrib/developer_tests/mpi_groups/test_group_mean.f90
===================================================================
--- DART/branches/rma_distrib/developer_tests/mpi_groups/test_group_mean.f90	2018-03-23 17:38:12 UTC (rev 12461)
+++ DART/branches/rma_distrib/developer_tests/mpi_groups/test_group_mean.f90	2018-03-23 17:45:58 UTC (rev 12462)
@@ -16,7 +16,7 @@
 use     mpi_utilities_mod, only : initialize_mpi_utilities, finalize_mpi_utilities, &
                                   task_count, my_task_id, task_sync, set_group_size,&
                                   get_group_size, create_groups, set_group_size,    &
-                                  group_task_id, get_group_comm, get_group_id
+                                  group_task_id, get_dart_mpi_comm, get_group_comm, get_group_id
 
 use      time_manager_mod, only : time_type, set_time, print_date, operator(-), &
                                   NO_CALENDAR
@@ -200,6 +200,25 @@
    endif
 enddo
 
+do my_rank = 0, task_count(get_group_comm()) - 1
+   if (my_rank == my_task_id()) then
+      do my_index = 1, ens_handle%my_num_vars
+         print*, 'rank, my_index, ens_handle%copies(i) ', my_task_id(), my_index, ens_handle%copies(1,my_index)
+      enddo
+   else
+      call task_sync()
+   endif
+enddo
+do my_rank = 0, task_count() - 1
+   if (my_rank == my_task_id()) then
+      do my_index = 1, ens_handle%my_num_vars
+         print*, 'rank, my_index, ens_handle%copies(i) ', my_task_id(), my_index, ens_handle%copies(1,my_index)
+      enddo
+   else
+      call task_sync()
+   endif
+enddo
+
 ! do my_rank = 0, task_count() - 1
 ! enddo
 


More information about the Dart-dev mailing list