--- trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2004/05/27 00:48:12 1198 +++ trunk/OOPSE/libmdtools/mpiSimulation_module.F90 2004/05/27 18:59:17 1203 @@ -7,7 +7,7 @@ !! !! @author Charles F. Vardeman II !! @author Matthew Meineke -!! @version $Id: mpiSimulation_module.F90,v 1.13 2004-05-27 00:48:12 tim Exp $, $Date: 2004-05-27 00:48:12 $, $Name: not supported by cvs2svn $, $Revision: 1.13 $ +!! @version $Id: mpiSimulation_module.F90,v 1.14 2004-05-27 18:59:15 gezelter Exp $, $Date: 2004-05-27 18:59:15 $, $Name: not supported by cvs2svn $, $Revision: 1.14 $ module mpiSimulation use definitions @@ -139,45 +139,46 @@ contains contains -!! Sets up mpiComponentPlan with structure passed from C++. - subroutine setupSimParallel(thisComponentPlan,nAtomTags,atomTags,status) -! Passed Arguments + !! Sets up mpiComponentPlan with structure passed from C++. + subroutine setupSimParallel(thisComponentPlan, nAtomTags, atomTags, & + status) + !! Passed Arguments !! mpiComponentPlan struct from C type (mpiComponentPlan), intent(inout) :: thisComponentPlan -!! Number of tags passed, nlocal + !! Number of tags passed integer, intent(in) :: nAtomTags -!! Result status, 0 = normal, -1 = error + !! Result status, 0 = normal, -1 = error integer, intent(out) :: status integer :: localStatus -!! Global reference tag for local particles - integer, dimension(nAtomTags),intent(inout) :: atomTags + !! Global reference tag for local particles + integer, dimension(nAtomTags), intent(inout) :: atomTags - write(*,*) 'mpiSim_mod thinks node', thisComponentPlan%myNode, & - ' has atomTags(1) = ', atomTags(1) - + !write(*,*) 'mpiSim_mod thinks node', thisComponentPlan%myNode, & + ! ' has atomTags(1) = ', atomTags(1) + status = 0 if (componentPlanSet) then return endif componentPlanSet = .true. - !! copy c component plan to fortran + !! copy c component plan to fortran mpiSim = thisComponentPlan - write(*,*) "Seting up simParallel" - + !write(*,*) "Seting up simParallel" + call make_Force_Grid(mpiSim, localStatus) if (localStatus /= 0) then write(default_error,*) "Error creating force grid" status = -1 return endif - + call updateGridComponents(mpiSim, localStatus) if (localStatus /= 0) then write(default_error,*) "Error updating grid components" status = -1 return - endif + endif !! initialize gather and scatter plans used in this simulation call plan_gather_scatter(1, mpiSim%nAtomsLocal, & @@ -267,13 +268,13 @@ contains end subroutine replanSimParallel -!! Updates number of row and column components for long range forces. - subroutine updateGridComponents(thisComponentPlan,status) + !! Updates number of row and column components for long range forces. + subroutine updateGridComponents(thisComponentPlan, status) type (mpiComponentPlan) :: thisComponentPlan !! mpiComponentPlan - -!! Status return -!! - 0 Success -!! - -1 Failure + + !! Status return + !! - 0 Success + !! - -1 Failure integer, intent(out) :: status integer :: nAtomsLocal integer :: nAtomsInRow = 0 @@ -291,6 +292,7 @@ contains return endif if (thisComponentPlan%nGroupsLocal == 0) then + write(*,*) 'tcp%ngl = ', thisComponentPlan%nGroupsLocal status = -1 return endif @@ -334,13 +336,13 @@ contains end subroutine updateGridComponents -!! Creates a square force decomposition of processors into row and column -!! communicators. + !! Creates a square force decomposition of processors into row and column + !! communicators. subroutine make_Force_Grid(thisComponentPlan,status) type (mpiComponentPlan) :: thisComponentPlan integer, intent(out) :: status !! status returns -1 if error - integer :: nColumnsMax !! Maximum number of columns - integer :: nWorldProcessors !! Total number of processors in World comm. + integer :: nColumnsMax !! Maximum number of columns + integer :: nWorldProcessors !! Total number of processors in World comm. integer :: rowIndex !! Row for this processor. integer :: columnIndex !! Column for this processor. integer :: nRows !! Total number of rows. @@ -355,8 +357,8 @@ contains if (.not. ComponentPlanSet) return status = 0 -!! We make a dangerous assumption here that if numberProcessors is -!! zero, then we need to get the information from MPI. + !! We make a dangerous assumption here that if numberProcessors is + !! zero, then we need to get the information from MPI. if (thisComponentPlan%nProcessors == 0 ) then call mpi_comm_size( MPI_COMM_WORLD, nWorldProcessors,mpiErrors) if ( mpiErrors /= 0 ) then @@ -368,29 +370,29 @@ contains status = -1 return endif - + else nWorldProcessors = thisComponentPlan%nProcessors myWorldRank = thisComponentPlan%myNode endif - + nColumnsMax = nint(sqrt(real(nWorldProcessors,kind=dp))) - + do i = 1, nColumnsMax if (mod(nWorldProcessors,i) == 0) nColumns = i end do - + nRows = nWorldProcessors/nColumns - + rowIndex = myWorldRank/nColumns - + call mpi_comm_split(mpi_comm_world,rowIndex,0,rowCommunicator,mpiErrors) if ( mpiErrors /= 0 ) then write(default_error,*) "MPI comm split failed at row communicator" status = -1 return endif - + columnIndex = mod(myWorldRank,nColumns) call mpi_comm_split(mpi_comm_world,columnIndex,0,columnCommunicator,mpiErrors) if ( mpiErrors /= 0 ) then @@ -398,8 +400,8 @@ contains status = -1 return endif - -! Set appropriate components of thisComponentPlan + + ! Set appropriate components of thisComponentPlan thisComponentPlan%rowComm = rowCommunicator thisComponentPlan%columnComm = columnCommunicator thisComponentPlan%rowIndex = rowIndex @@ -408,7 +410,7 @@ contains thisComponentPlan%nColumns = nColumns end subroutine make_Force_Grid - + !! initalizes a gather scatter plan subroutine plan_gather_scatter( nDim, nObjects, thisComponentPlan, & thisComm, this_plan, status)