| 5 |
|
!! |
| 6 |
|
!! @author Charles F. Vardeman II |
| 7 |
|
!! @author Matthew Meineke |
| 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 $ |
| 8 |
> |
!! @version $Id: mpiSimulation_module.F90,v 1.5 2003-01-30 20:03:37 chuckv Exp $, $Date: 2003-01-30 20:03:37 $, $Name: not supported by cvs2svn $, $Revision: 1.5 $ |
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
module mpiSimulation |
| 14 |
< |
#ifdef IS_MPI |
| 14 |
> |
use definitions |
| 15 |
|
use mpi |
| 16 |
|
implicit none |
| 17 |
|
PRIVATE |
| 131 |
|
!! Global reference tag for local particles |
| 132 |
|
integer, dimension(ntags),intent(inout) :: tags |
| 133 |
|
|
| 134 |
+ |
|
| 135 |
|
status = 0 |
| 136 |
|
if (componentPlanSet) then |
| 137 |
|
return |
| 138 |
|
endif |
| 138 |
– |
|
| 139 |
|
componentPlanSet = .true. |
| 140 |
< |
|
| 140 |
> |
|
| 141 |
> |
|
| 142 |
|
call make_Force_Grid(thisComponentPlan,localStatus) |
| 143 |
|
if (localStatus /= 0) then |
| 144 |
+ |
write(default_error,*) "Error creating force grid" |
| 145 |
|
status = -1 |
| 146 |
|
return |
| 147 |
|
endif |
| 148 |
|
|
| 149 |
|
call updateGridComponents(thisComponentPlan,localStatus) |
| 150 |
|
if (localStatus /= 0) then |
| 151 |
+ |
write(default_error,*) "Error updating grid components" |
| 152 |
|
status = -1 |
| 153 |
|
return |
| 154 |
|
endif |
| 155 |
|
|
| 156 |
+ |
|
| 157 |
|
!! initialize gather and scatter plans used in this simulation |
| 158 |
|
call plan_gather_scatter(1,thisComponentPlan%nComponentsRow,& |
| 159 |
< |
thisComponentPlan,row_comm,plan_row) |
| 159 |
> |
thisComponentPlan,thisComponentPlan%rowComm,plan_row) |
| 160 |
|
call plan_gather_scatter(nDim,thisComponentPlan%nComponentsRow,& |
| 161 |
< |
thisComponentPlan,row_comm,plan_row3d) |
| 161 |
> |
thisComponentPlan,thisComponentPlan%rowComm,plan_row3d) |
| 162 |
|
call plan_gather_scatter(1,thisComponentPlan%nComponentsColumn,& |
| 163 |
< |
thisComponentPlan,col_comm,plan_col) |
| 163 |
> |
thisComponentPlan,thisComponentPlan%columnComm,plan_col) |
| 164 |
|
call plan_gather_scatter(nDim,thisComponentPlan%nComponentsColumn,& |
| 165 |
< |
thisComponentPlan,col_comm,plan_col3d) |
| 165 |
> |
thisComponentPlan,thisComponentPlan%columnComm,plan_col3d) |
| 166 |
|
|
| 167 |
|
! Initialize tags |
| 168 |
|
call setTags(tags,localStatus) |
| 178 |
|
!! mpiComponentPlan struct from C |
| 179 |
|
type (mpiComponentPlan), intent(inout) :: thisComponentPlan |
| 180 |
|
integer, intent(out) :: status |
| 181 |
< |
integer, intent(out) :: localStatus |
| 182 |
< |
|
| 181 |
> |
integer :: localStatus |
| 182 |
> |
integer :: mpierror |
| 183 |
|
status = 0 |
| 184 |
|
|
| 185 |
|
call updateGridComponents(thisComponentPlan,localStatus) |
| 197 |
|
|
| 198 |
|
!! initialize gather and scatter plans used in this simulation |
| 199 |
|
call plan_gather_scatter(1,thisComponentPlan%nComponentsRow,& |
| 200 |
< |
thisComponentPlan,row_comm,plan_row) |
| 200 |
> |
thisComponentPlan,thisComponentPlan%rowComm,plan_row) |
| 201 |
|
call plan_gather_scatter(nDim,thisComponentPlan%nComponentsRow,& |
| 202 |
< |
thisComponentPlan,row_comm,plan_row3d) |
| 202 |
> |
thisComponentPlan,thisComponentPlan%rowComm,plan_row3d) |
| 203 |
|
call plan_gather_scatter(1,thisComponentPlan%nComponentsColumn,& |
| 204 |
< |
thisComponentPlan,col_comm,plan_col) |
| 204 |
> |
thisComponentPlan,thisComponentPlan%columnComm,plan_col) |
| 205 |
|
call plan_gather_scatter(nDim,thisComponentPlan%nComponentsColumn,& |
| 206 |
< |
thisComponentPlan,col_comm,plan_col3d) |
| 206 |
> |
thisComponentPlan,thisComponentPlan%rowComm,plan_col3d) |
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 219 |
|
integer, intent(out) :: status |
| 220 |
|
integer :: nComponentsLocal |
| 221 |
|
integer :: nComponentsRow = 0 |
| 222 |
< |
integer :: nComponensColumn = 0 |
| 222 |
> |
integer :: nComponentsColumn = 0 |
| 223 |
|
integer :: mpiErrors |
| 224 |
|
|
| 225 |
|
status = 0 |
| 233 |
|
nComponentsLocal = thisComponentPlan%myNlocal |
| 234 |
|
|
| 235 |
|
call mpi_allreduce(nComponentsLocal,nComponentsRow,1,mpi_integer,& |
| 236 |
< |
mpi_sum,thisComponentPlan%rowComm,mpiError) |
| 236 |
> |
mpi_sum,thisComponentPlan%rowComm,mpiErrors) |
| 237 |
|
if (mpiErrors /= 0) then |
| 238 |
|
status = -1 |
| 239 |
|
return |
| 240 |
|
endif |
| 241 |
|
|
| 242 |
|
call mpi_allreduce(nComponentsLocal,nComponentsColumn,1,mpi_integer, & |
| 243 |
< |
mpi_sum,thisComponentPlan%columnComm,mpiError) |
| 243 |
> |
mpi_sum,thisComponentPlan%columnComm,mpiErrors) |
| 244 |
|
if (mpiErrors /= 0) then |
| 245 |
|
status = -1 |
| 246 |
|
return |
| 273 |
|
|
| 274 |
|
if (.not. ComponentPlanSet) return |
| 275 |
|
status = 0 |
| 276 |
< |
|
| 276 |
> |
|
| 277 |
|
!! We make a dangerous assumption here that if numberProcessors is |
| 278 |
|
!! zero, then we need to get the information from MPI. |
| 279 |
|
if (thisComponentPlan%numberProcessors == 0 ) then |
| 305 |
|
nRows = nWorldProcessors/nColumns |
| 306 |
|
|
| 307 |
|
rowIndex = myWorldRank/nColumns |
| 308 |
< |
call mpi_comm_split(mpi_comm_world,rowIndex,0,rowCommunicator,mpiError) |
| 308 |
> |
|
| 309 |
> |
|
| 310 |
> |
|
| 311 |
> |
call mpi_comm_split(mpi_comm_world,rowIndex,0,rowCommunicator,mpiErrors) |
| 312 |
|
if ( mpiErrors /= 0 ) then |
| 313 |
+ |
write(default_error,*) "MPI comm split failed at row communicator" |
| 314 |
|
status = -1 |
| 315 |
|
return |
| 316 |
|
endif |
| 317 |
|
|
| 318 |
|
columnIndex = mod(myWorldRank,nColumns) |
| 319 |
< |
call mpi_comm_split(mpi_comm_world,columnIndex,0,columnCommunicator,mpiError) |
| 319 |
> |
call mpi_comm_split(mpi_comm_world,columnIndex,0,columnCommunicator,mpiErrors) |
| 320 |
|
if ( mpiErrors /= 0 ) then |
| 321 |
+ |
write(default_error,*) "MPI comm split faild at columnCommunicator" |
| 322 |
|
status = -1 |
| 323 |
|
return |
| 324 |
|
endif |
| 357 |
|
!! WARNING this could be dangerous since thisComponentPlan was origionally |
| 358 |
|
!! allocated in C++ and there is a significant difference between c and |
| 359 |
|
!! f95 pointers.... |
| 360 |
< |
gsComponentPlan => thisComponetPlan |
| 360 |
> |
this_plan%gsComponentPlan => thisComponentPlan |
| 361 |
|
|
| 362 |
|
! Set this plan size for displs array. |
| 363 |
|
this_plan%gsPlanSize = nDim * nComponents |
| 397 |
|
|
| 398 |
|
!! gather all the local sizes into a size # processors array. |
| 399 |
|
call mpi_allgather(this_plan%gsPlanSize,1,mpi_integer,this_plan%counts, & |
| 400 |
< |
1,mpi_integer,comm,mpi_err) |
| 400 |
> |
1,mpi_integer,thisComm,mpi_err) |
| 401 |
|
|
| 402 |
|
if (mpi_err /= 0) then |
| 403 |
|
if (present(status)) status = -1 |
| 564 |
|
|
| 565 |
|
endif |
| 566 |
|
! allocate column arrays |
| 567 |
< |
if (.not. allocated(tagCol)) then |
| 567 |
> |
if (.not. allocated(tagColumn)) then |
| 568 |
|
allocate(tagColumn(ncol),STAT=alloc_stat) |
| 569 |
|
if (alloc_stat /= 0 ) then |
| 570 |
|
status = -1 |
| 608 |
|
|
| 609 |
|
|
| 610 |
|
|
| 611 |
< |
#endif |
| 611 |
> |
|
| 612 |
|
end module mpiSimulation |
| 613 |
|
|