ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/mdtools/mpi_implementation/mpiSimulation_module.F90
(Generate patch)

Comparing trunk/mdtools/mpi_implementation/mpiSimulation_module.F90 (file contents):
Revision 215 by chuckv, Thu Dec 19 21:59:51 2002 UTC vs.
Revision 253 by chuckv, Thu Jan 30 15:20:21 2003 UTC

# Line 5 | Line 5
5   !!
6   !! @author Charles F. Vardeman II
7   !! @author Matthew Meineke
8 < !! @version $Id: mpiSimulation_module.F90,v 1.1 2002-12-19 21:59:51 chuckv Exp $, $Date: 2002-12-19 21:59:51 $, $Name: not supported by cvs2svn $, $Revision: 1.1 $
8 > !! @version $Id: mpiSimulation_module.F90,v 1.4 2003-01-30 15:20:21 chuckv Exp $, $Date: 2003-01-30 15:20:21 $, $Name: not supported by cvs2svn $, $Revision: 1.4 $
9  
10  
11  
12  
13   module mpiSimulation  
14 < #ifdef MPI
14 > #ifdef IS_MPI
15    use mpi
16    implicit none
17    PRIVATE
# Line 23 | Line 23 | module mpiSimulation  
23    public :: gather, scatter
24    public :: setupSimParallel
25    public :: replanSimParallel
26 +  public :: getNcol
27 +  public :: getNrow
28 +  public :: isMPISimSet
29 +
30 +
31   !! PUBLIC  Subroutines contained in MPI module
32    public :: mpi_bcast
33    public :: mpi_allreduce
# Line 50 | Line 55 | module mpiSimulation  
55   !! generic mpi error declaration.
56    integer,public  :: mpi_err
57  
58 +
59 +
60   !! Include mpiComponentPlan type. mpiComponentPlan is a
61   !! dual header file for both c and fortran.
62   #define __FORTRAN90
63   #include "mpiComponentPlan.h"
64  
65 +
66 +
67 + !! Tags used during force loop for parallel simulation
68 +  integer, allocatable, dimension(:) :: tagLocal
69 +  integer, public, allocatable, dimension(:) :: tagRow
70 +  integer ,public, allocatable, dimension(:) :: tagColumn
71 +
72 + !! Logical set true if mpiSimulation has been initialized
73 +  logical :: isSimSet = .false.
74 +
75   !! gs_plan contains plans for gather and scatter routines
76    type, public :: gs_plan
77       private
# Line 97 | Line 114 | module mpiSimulation  
114    end interface
115  
116  
117 +
118   contains
119  
120   !! Sets up mpiComponentPlan with structure passed from C++.
121 <  subroutine setupSimParallel(thisComponentPlan,status)
121 >  subroutine setupSimParallel(thisComponentPlan,ntags,tags,status)
122   !  Passed Arguments
123   !    integer, intent(inout) :: nDim !! Number of dimensions
124      !! mpiComponentPlan struct from C
125 <    type (mpiComponentPlan), intent(inout) :: thisComponentPlan  
125 >    type (mpiComponentPlan), intent(inout) :: thisComponentPlan
126 > !! Number of tags passed, nlocal  
127 >    integer, intent(in) :: ntags
128 > !! Result status, 0 = normal, -1 = error
129      integer, intent(out) :: status
130 <    integer, intnet(out) :: localStatus
130 >    integer :: localStatus
131 > !! Global reference tag for local particles
132 >    integer, dimension(ntags),intent(inout) :: tags
133  
134      status = 0
135      if (componentPlanSet) then
# Line 137 | Line 160 | contains
160      call plan_gather_scatter(nDim,thisComponentPlan%nComponentsColumn,&
161           thisComponentPlan,col_comm,plan_col3d)
162  
163 <
164 <
163 > !  Initialize tags    
164 >    call setTags(tags,localStatus)
165 >    if (localStatus /= 0) then
166 >       status = -1
167 >       return
168 >    endif
169 >    isSimSet = .true.
170    end subroutine setupSimParallel
171  
172    subroutine replanSimParallel(thisComponentPlan,status)
# Line 146 | Line 174 | contains
174      !! mpiComponentPlan struct from C
175      type (mpiComponentPlan), intent(inout) :: thisComponentPlan  
176      integer, intent(out) :: status
177 <    integer, intnet(out) :: localStatus
177 >    integer, intent(out) :: localStatus
178  
179      status = 0
180  
# Line 258 | Line 286 | contains
286  
287      else
288         nWorldProcessors = thisComponentPlan%numberProcessors
289 <       myWorldRank = thisComponentPlan%myRank
289 >       myWorldRank = thisComponentPlan%myNode
290      endif
291  
292  
# Line 359 | Line 387 | contains
387      end if
388  
389     !! gather all the local sizes into a size # processors array.
390 <    call mpi_allgather(gs_plan%gsPlanSize,1,mpi_integer,this_plan%counts, &
390 >    call mpi_allgather(this_plan%gsPlanSize,1,mpi_integer,this_plan%counts, &
391           1,mpi_integer,comm,mpi_err)
392  
393      if (mpi_err /= 0) then
# Line 386 | Line 414 | contains
414      
415      
416      this_plan%gsComponentPlan => null()
417 <    call mpi_comm_free(this_plan%comm,mpi_err)
417 >    call mpi_comm_free(this_plan%myPlanComm,mpi_err)
418  
419      deallocate(this_plan%counts)
420      deallocate(this_plan%displs)
# Line 423 | Line 451 | contains
451      integer, intent(out), optional :: status
452  
453      if (present(status)) status = 0
454 <    noffset = this_plan%displs(this_plan%me)
454 >    noffset = this_plan%displs(this_plan%myPlanRank)
455  
456      call mpi_allgatherv(sbuffer,this_plan%gsPlanSize, mpi_double_precision, &
457           rbuffer,this_plan%counts,this_plan%displs,mpi_double_precision, &
# Line 495 | Line 523 | contains
523      endif
524  
525    end subroutine scatter_double_2d
526 +
527 +
528 +  subroutine setTags(tags,status)
529 +    integer, dimension(:) :: tags
530 +    integer :: status
531 +
532 +    integer :: alloc_stat
533 +    
534 +    integer :: ncol
535 +    integer :: nrow
536 +
537 +    status = 0
538 + ! allocate row arrays
539 +    nrow = getNrow(plan_row)
540 +    ncol = getNcol(plan_col)
541  
542 +    if (.not. allocated(tagRow)) then
543 +       allocate(tagRow(nrow),STAT=alloc_stat)
544 +       if (alloc_stat /= 0 ) then
545 +          status = -1
546 +          return
547 +       endif
548 +    else
549 +       deallocate(tagRow)
550 +       allocate(tagRow(nrow),STAT=alloc_stat)
551 +       if (alloc_stat /= 0 ) then
552 +          status = -1
553 +          return
554 +       endif
555 +
556 +    endif
557 + ! allocate column arrays
558 +    if (.not. allocated(tagCol)) then
559 +       allocate(tagColumn(ncol),STAT=alloc_stat)
560 +       if (alloc_stat /= 0 ) then
561 +          status = -1
562 +          return
563 +       endif
564 +    else
565 +       deallocate(tagColumn)
566 +       allocate(tagColumn(ncol),STAT=alloc_stat)
567 +       if (alloc_stat /= 0 ) then
568 +          status = -1
569 +          return
570 +       endif
571 +    endif
572 +    
573 +    call gather(tags,tagRow,plan_row)
574 +    call gather(tags,tagColumn,plan_col)
575 +
576 +
577 +  end subroutine setTags
578 +
579 +  pure function getNcol(thisplan) result(ncol)
580 +    type (gs_plan), intent(in) :: thisplan
581 +    integer :: ncol
582 +    ncol = thisplan%gsComponentPlan%nComponentsColumn
583 +  end function getNcol
584 +
585 +  pure function getNrow(thisplan) result(ncol)
586 +    type (gs_plan), intent(in) :: thisplan
587 +    integer :: ncol
588 +    ncol = thisplan%gsComponentPlan%nComponentsrow
589 +  end function getNrow
590 +
591 +  function isMPISimSet() result(isthisSimSet)
592 +    logical :: isthisSimSet
593 +    if (isSimSet) then
594 +       isthisSimSet = .true.
595 +    else
596 +       isthisSimSet = .false.
597 +    endif
598 +  end function isMPISimSet
599    
600 +
601 +  
602   #endif
603   end module mpiSimulation
604  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines