1 |
– |
#ifdef IS_MPI |
1 |
|
|
2 |
+ |
|
3 |
|
!! MPI support for long range forces using force decomposition |
4 |
|
!! on a square grid of processors. |
5 |
|
!! Corresponds to mpiSimunation.cpp for C++ |
7 |
|
!! |
8 |
|
!! @author Charles F. Vardeman II |
9 |
|
!! @author Matthew Meineke |
10 |
< |
!! @version $Id: mpiSimulation_module.F90,v 1.1.1.1 2003-03-21 17:42:12 mmeineke Exp $, $Date: 2003-03-21 17:42:12 $, $Name: not supported by cvs2svn $, $Revision: 1.1.1.1 $ |
10 |
> |
!! @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 $ |
11 |
|
|
12 |
|
module mpiSimulation |
13 |
|
use definitions |
14 |
+ |
#ifdef IS_MPI |
15 |
|
use mpi |
16 |
|
implicit none |
17 |
|
PRIVATE |
48 |
|
public :: mpi_status_size |
49 |
|
public :: mpi_any_source |
50 |
|
|
51 |
+ |
|
52 |
+ |
|
53 |
|
!! Safety logical to prevent access to ComponetPlan until |
54 |
|
!! set by C++. |
55 |
|
logical :: ComponentPlanSet = .false. |
58 |
|
!! generic mpi error declaration. |
59 |
|
integer,public :: mpi_err |
60 |
|
|
61 |
< |
|
61 |
> |
#ifdef PROFILE |
62 |
> |
public :: printCommTime |
63 |
|
|
64 |
+ |
real(kind = dp ) :: commTime = 0.0_dp |
65 |
+ |
real(kind = dp ) :: commTimeInitial,commTimeFinal |
66 |
+ |
#endif |
67 |
+ |
|
68 |
|
!! Include mpiComponentPlan type. mpiComponentPlan is a |
69 |
|
!! dual header file for both c and fortran. |
70 |
|
#define __FORTRAN90 |
145 |
|
!! Global reference tag for local particles |
146 |
|
integer, dimension(ntags),intent(inout) :: tags |
147 |
|
|
148 |
+ |
write(*,*) 'mpiSim_mod thinks node', thisComponentPlan%myNode, ' has tags(1) = ', tags(1) |
149 |
|
|
150 |
+ |
|
151 |
+ |
|
152 |
|
status = 0 |
153 |
|
if (componentPlanSet) then |
154 |
|
return |
265 |
|
|
266 |
|
nComponentsLocal = thisComponentPlan%myNlocal |
267 |
|
|
268 |
+ |
write(*,*) "UpdateGridComponents: myNlocal ", nComponentsLocal |
269 |
|
call mpi_allreduce(nComponentsLocal,nComponentsRow,1,mpi_integer,& |
270 |
|
mpi_sum,thisComponentPlan%rowComm,mpiErrors) |
271 |
|
if (mpiErrors /= 0) then |
282 |
|
|
283 |
|
thisComponentPlan%nComponentsRow = nComponentsRow |
284 |
|
thisComponentPlan%nComponentsColumn = nComponentsColumn |
285 |
< |
|
285 |
> |
write(*,*) "UpdateGridComponents: myNRow ",& |
286 |
> |
thisComponentPlan%nComponentsRow |
287 |
> |
write(*,*) "UpdateGridComponents: myNColumn ",& |
288 |
> |
thisComponentPlan%nComponentsColumn |
289 |
|
|
290 |
|
end subroutine updateGridComponents |
291 |
|
|
511 |
|
|
512 |
|
if (present(status)) status = 0 |
513 |
|
noffset = this_plan%displs(this_plan%myPlanRank) |
514 |
< |
|
514 |
> |
#ifdef PROFILE |
515 |
> |
commTimeInitial = mpi_wtime() |
516 |
> |
#endif |
517 |
|
call mpi_allgatherv(sbuffer,this_plan%gsPlanSize, mpi_double_precision, & |
518 |
|
rbuffer,this_plan%counts,this_plan%displs,mpi_double_precision, & |
519 |
|
this_plan%myPlanComm, mpi_err) |
520 |
+ |
#ifdef PROFILE |
521 |
+ |
commTimeFinal = mpi_wtime() |
522 |
+ |
commTime = commTime + commTimeFinal - commTimeInitial |
523 |
+ |
#endif |
524 |
|
|
525 |
|
if (mpi_err /= 0) then |
526 |
|
if (present(status)) status = -1 |
541 |
|
if (present(status)) status = 0 |
542 |
|
|
543 |
|
! noffset = this_plan%displs(this_plan%me) |
544 |
< |
|
544 |
> |
#ifdef PROFILE |
545 |
> |
commTimeInitial = mpi_wtime() |
546 |
> |
#endif |
547 |
> |
|
548 |
|
call mpi_allgatherv(sbuffer,this_plan%gsPlanSize, mpi_double_precision, & |
549 |
|
rbuffer,this_plan%counts,this_plan%displs,mpi_double_precision, & |
550 |
|
this_plan%myPlanComm, mpi_err) |
551 |
|
|
552 |
+ |
#ifdef PROFILE |
553 |
+ |
commTimeFinal = mpi_wtime() |
554 |
+ |
commTime = commTime + commTimeFinal - commTimeInitial |
555 |
+ |
#endif |
556 |
+ |
|
557 |
|
if (mpi_err /= 0) then |
558 |
|
if (present(status)) status = -1 |
559 |
|
endif |
570 |
|
|
571 |
|
if (present(status)) status = 0 |
572 |
|
|
573 |
+ |
#ifdef PROFILE |
574 |
+ |
commTimeInitial = mpi_wtime() |
575 |
+ |
#endif |
576 |
|
call mpi_reduce_scatter(sbuffer,rbuffer, this_plan%counts, & |
577 |
|
mpi_double_precision, MPI_SUM, this_plan%myPlanComm, mpi_err) |
578 |
+ |
#ifdef PROFILE |
579 |
+ |
commTimeFinal = mpi_wtime() |
580 |
+ |
commTime = commTime + commTimeFinal - commTimeInitial |
581 |
+ |
#endif |
582 |
|
|
583 |
|
if (mpi_err /= 0) then |
584 |
|
if (present(status)) status = -1 |
595 |
|
external mpi_reduce_scatter |
596 |
|
|
597 |
|
if (present(status)) status = 0 |
598 |
+ |
#ifdef PROFILE |
599 |
+ |
commTimeInitial = mpi_wtime() |
600 |
+ |
#endif |
601 |
+ |
|
602 |
|
call mpi_reduce_scatter(sbuffer,rbuffer, this_plan%counts, & |
603 |
|
mpi_double_precision, MPI_SUM, this_plan%myPlanComm, mpi_err) |
604 |
+ |
#ifdef PROFILE |
605 |
+ |
commTimeFinal = mpi_wtime() |
606 |
+ |
commTime = commTime + commTimeFinal - commTimeInitial |
607 |
+ |
#endif |
608 |
|
|
609 |
|
if (mpi_err /= 0) then |
610 |
|
if (present(status)) status = -1 |
669 |
|
ncol = thisplan%gsComponentPlan%nComponentsColumn |
670 |
|
end function getNcol |
671 |
|
|
672 |
< |
pure function getNrow(thisplan) result(ncol) |
672 |
> |
pure function getNrow(thisplan) result(nrow) |
673 |
|
type (gs_plan), intent(in) :: thisplan |
674 |
< |
integer :: ncol |
675 |
< |
ncol = thisplan%gsComponentPlan%nComponentsrow |
674 |
> |
integer :: nrow |
675 |
> |
nrow = thisplan%gsComponentPlan%nComponentsRow |
676 |
|
end function getNrow |
677 |
|
|
678 |
|
function isMPISimSet() result(isthisSimSet) |
706 |
|
write(default_error,*) "nBondGlobal: ", mpiSim%nBondsGlobal |
707 |
|
write(default_error,*) "nTorsionsGlobal: ", mpiSim%nTorsionsGlobal |
708 |
|
write(default_error,*) "nSRIGlobal: ", mpiSim%nSRIGlobal |
665 |
– |
write(default_error,*) "myMolStart: ", mpiSim%myMolStart |
666 |
– |
write(default_error,*) "myMolEnd: ", mpiSim%myMolEnd |
667 |
– |
write(default_error,*) "myMol: ", mpiSim%myMol |
709 |
|
write(default_error,*) "myNlocal: ", mpiSim%myNlocal |
710 |
|
write(default_error,*) "myNode: ", mpiSim%myNode |
711 |
|
write(default_error,*) "numberProcessors: ", mpiSim%numberProcessors |
725 |
|
myNode = mpiSim%myNode |
726 |
|
end function getMyNode |
727 |
|
|
728 |
+ |
#ifdef PROFILE |
729 |
+ |
subroutine printCommTime() |
730 |
|
|
731 |
< |
end module mpiSimulation |
731 |
> |
write(*,*) "MPI communication time is: ", commTime |
732 |
|
|
733 |
+ |
end subroutine printCommTime |
734 |
+ |
#endif |
735 |
+ |
|
736 |
|
#endif // is_mpi |
737 |
+ |
end module mpiSimulation |
738 |
+ |
|
739 |
+ |
|