<p><b>duda</b> 2011-12-20 15:21:44 -0700 (Tue, 20 Dec 2011)</p><p>BRANCH COMMIT<br>
<br>
Make possible the use of an externally-provided MPI communicator, given <br>
as an optional argument to mpas_dmpar_init, in the dmpar module.<br>
<br>
Also, remove a couple of debugging print statements in test case module.<br>
<br>
<br>
M src/framework/mpas_dmpar.F<br>
M src/core_nhyd_atmos/mpas_atm_test_cases.F<br>
</p><hr noshade><pre><font color="gray">Modified: branches/cam_mpas_nh/src/core_nhyd_atmos/mpas_atm_test_cases.F
===================================================================
--- branches/cam_mpas_nh/src/core_nhyd_atmos/mpas_atm_test_cases.F        2011-12-20 22:04:36 UTC (rev 1268)
+++ branches/cam_mpas_nh/src/core_nhyd_atmos/mpas_atm_test_cases.F        2011-12-20 22:21:44 UTC (rev 1269)
@@ -96,7 +96,6 @@
stop
end if
- write(0,*) 'MGD BEFORE PHYSICS_IDEALIZED_INIT'
#ifdef DO_PHYSICS
!initialization of surface input variables technically not needed to run our current set of
@@ -112,8 +111,6 @@
endif
#endif
- write(0,*) 'MGD AFTER PHYSICS_IDEALIZED_INIT'
-
end subroutine atm_setup_test_case
!----------------------------------------------------------------------------------------------------------
Modified: branches/cam_mpas_nh/src/framework/mpas_dmpar.F
===================================================================
--- branches/cam_mpas_nh/src/framework/mpas_dmpar.F        2011-12-20 22:04:36 UTC (rev 1268)
+++ branches/cam_mpas_nh/src/framework/mpas_dmpar.F        2011-12-20 22:21:44 UTC (rev 1269)
@@ -20,6 +20,7 @@
type dm_info
integer :: nprocs, my_proc_id, comm, info
+ logical :: using_external_comm
end type dm_info
@@ -46,23 +47,30 @@
contains
- subroutine mpas_dmpar_init(dminfo)
+ subroutine mpas_dmpar_init(dminfo, mpi_comm)
implicit none
type (dm_info), intent(inout) :: dminfo
+ integer, intent(in), optional :: mpi_comm ! Optional: externally-supplied MPI communicator
#ifdef _MPI
integer :: mpi_rank, mpi_size
integer :: mpi_ierr
+ if (present(mpi_comm)) then
+ dminfo % comm = mpi_comm
+ dminfo % using_external_comm = .true.
+ else
+ call MPI_Init(mpi_ierr)
+ dminfo % comm = MPI_COMM_WORLD
+ dminfo % using_external_comm = .false.
+ end if
+`
! Find out our rank and the total number of processors
- call MPI_Init(mpi_ierr)
- call MPI_Comm_rank(MPI_COMM_WORLD, mpi_rank, mpi_ierr)
- call MPI_Comm_size(MPI_COMM_WORLD, mpi_size, mpi_ierr)
+ call MPI_Comm_rank(dminfo % comm, mpi_rank, mpi_ierr)
+ call MPI_Comm_size(dminfo % comm, mpi_size, mpi_ierr)
- dminfo % comm = MPI_COMM_WORLD
-
dminfo % nprocs = mpi_size
dminfo % my_proc_id = mpi_rank
@@ -76,6 +84,7 @@
dminfo % comm = 0
dminfo % my_proc_id = IO_NODE
dminfo % nprocs = 1
+ dminfo % using_external_comm = .false.
#endif
end subroutine mpas_dmpar_init
@@ -90,7 +99,9 @@
#ifdef _MPI
integer :: mpi_ierr
- call MPI_Finalize(mpi_ierr)
+ if (.not. dminfo % using_external_comm) then
+ call MPI_Finalize(mpi_ierr)
+ end if
#endif
end subroutine mpas_dmpar_finalize
</font>
</pre>