--- trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2003/08/13 21:20:20 694 +++ trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2003/12/17 20:13:33 882 @@ -7,12 +7,12 @@ !! !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: mpiSimulation_module.F90,v 1.6 2003-08-13 21:20:20 chuckv Exp $, $Date: 2003-08-13 21:20:20 $, $Name: not supported by cvs2svn $, $Revision: 1.6 $ +!! @version $Id: mpiSimulation_module.F90,v 1.10 2003-12-17 20:13:33 chuckv Exp $, $Date: 2003-12-17 20:13:33 $, $Name: not supported by cvs2svn $, $Revision: 1.10 $ module mpiSimulation use definitions #ifdef IS_MPI - use mpi + use oopseMPI implicit none PRIVATE @@ -32,7 +32,7 @@ module mpiSimulation !! PUBLIC Subroutines contained in MPI module public :: mpi_bcast public :: mpi_allreduce - public :: mpi_reduce +! public :: mpi_reduce public :: mpi_send public :: mpi_recv public :: mpi_get_processor_name @@ -52,16 +52,16 @@ module mpiSimulation !! Safety logical to prevent access to ComponetPlan until !! set by C++. - logical :: ComponentPlanSet = .false. + logical, save :: ComponentPlanSet = .false. !! generic mpi error declaration. - integer,public :: mpi_err + integer, public :: mpi_err #ifdef PROFILE public :: printCommTime - real(kind = dp ) :: commTime = 0.0_dp + real(kind = dp ), save :: commTime = 0.0_dp real(kind = dp ) :: commTimeInitial,commTimeFinal #endif @@ -73,15 +73,15 @@ module mpiSimulation !! Tags used during force loop for parallel simulation - integer, allocatable, dimension(:) :: tagLocal + integer, public, allocatable, dimension(:) :: tagLocal integer, public, allocatable, dimension(:) :: tagRow integer, public, allocatable, dimension(:) :: tagColumn !! Logical set true if mpiSimulation has been initialized - logical :: isSimSet = .false. + logical, save :: isSimSet = .false. - type (mpiComponentPlan) :: mpiSim + type (mpiComponentPlan), save :: mpiSim !! gs_plan contains plans for gather and scatter routines type, public :: gs_plan @@ -97,12 +97,12 @@ module mpiSimulation end type gs_plan ! plans for different decompositions - type (gs_plan), public :: plan_row - type (gs_plan), public :: plan_row3d - type (gs_plan), public :: plan_col - type (gs_plan), public :: plan_col3d - type(gs_plan), public :: plan_row_Rotation - type(gs_plan), public :: plan_col_Rotation + type (gs_plan), public, save :: plan_row + type (gs_plan), public, save :: plan_row3d + type (gs_plan), public, save :: plan_col + type (gs_plan), public, save :: plan_col3d + type (gs_plan), public, save :: plan_row_Rotation + type (gs_plan), public, save :: plan_col_Rotation type (mpiComponentPlan), pointer :: simComponentPlan @@ -471,9 +471,9 @@ contains subroutine gather_integer( sbuffer, rbuffer, this_plan, status) - type (gs_plan), intent(in) :: this_plan - integer, dimension(:), intent(in) :: sbuffer - integer, dimension(:), intent(in) :: rbuffer + type (gs_plan), intent(inout) :: this_plan + integer, dimension(:), intent(inout) :: sbuffer + integer, dimension(:), intent(inout) :: rbuffer integer :: noffset integer, intent(out), optional :: status integer :: i @@ -503,8 +503,8 @@ contains subroutine gather_double( sbuffer, rbuffer, this_plan, status) type (gs_plan), intent(in) :: this_plan - real( kind = DP ), dimension(:), intent(in) :: sbuffer - real( kind = DP ), dimension(:), intent(in) :: rbuffer + real( kind = DP ), dimension(:), intent(inout) :: sbuffer + real( kind = DP ), dimension(:), intent(inout) :: rbuffer integer :: noffset integer, intent(out), optional :: status @@ -531,8 +531,8 @@ contains subroutine gather_double_2d( sbuffer, rbuffer, this_plan, status) type (gs_plan), intent(in) :: this_plan - real( kind = DP ), dimension(:,:), intent(in) :: sbuffer - real( kind = DP ), dimension(:,:), intent(in) :: rbuffer + real( kind = DP ), dimension(:,:), intent(inout) :: sbuffer + real( kind = DP ), dimension(:,:), intent(inout) :: rbuffer integer :: noffset,i,ierror integer, intent(out), optional :: status @@ -563,8 +563,8 @@ contains subroutine scatter_double( sbuffer, rbuffer, this_plan, status) type (gs_plan), intent(in) :: this_plan - real( kind = DP ), dimension(:), intent(in) :: sbuffer - real( kind = DP ), dimension(:), intent(in) :: rbuffer + real( kind = DP ), dimension(:), intent(inout) :: sbuffer + real( kind = DP ), dimension(:), intent(inout) :: rbuffer integer, intent(out), optional :: status external mpi_reduce_scatter @@ -589,8 +589,8 @@ contains subroutine scatter_double_2d( sbuffer, rbuffer, this_plan, status) type (gs_plan), intent(in) :: this_plan - real( kind = DP ), dimension(:,:), intent(in) :: sbuffer - real( kind = DP ), dimension(:,:), intent(in) :: rbuffer + real( kind = DP ), dimension(:,:), intent(inout) :: sbuffer + real( kind = DP ), dimension(:,:), intent(inout) :: rbuffer integer, intent(out), optional :: status external mpi_reduce_scatter @@ -626,7 +626,26 @@ contains ! allocate row arrays nrow = getNrow(plan_row) ncol = getNcol(plan_col) + + if(.not. allocated(tagLocal)) then + allocate(tagLocal(size(tags)),STAT=alloc_stat) + if (alloc_stat /= 0 ) then + status = -1 + return + endif + else + deallocate(tagLocal) + allocate(tagLocal(size(tags)),STAT=alloc_stat) + if (alloc_stat /= 0 ) then + status = -1 + return + endif + endif + + tagLocal = tags + + if (.not. allocated(tagRow)) then allocate(tagRow(nrow),STAT=alloc_stat) if (alloc_stat /= 0 ) then @@ -661,15 +680,18 @@ contains call gather(tags,tagRow,plan_row) call gather(tags,tagColumn,plan_col) + end subroutine setTags - pure function getNcol(thisplan) result(ncol) +! pure function getNcol(thisplan) result(ncol) + function getNcol(thisplan) result(ncol) type (gs_plan), intent(in) :: thisplan integer :: ncol ncol = thisplan%gsComponentPlan%nComponentsColumn end function getNcol - pure function getNrow(thisplan) result(nrow) +! pure function getNrow(thisplan) result(nrow) + function getNrow(thisplan) result(nrow) type (gs_plan), intent(in) :: thisplan integer :: nrow nrow = thisplan%gsComponentPlan%nComponentsRow