1 | include(dom.inc)
2 |
3 | SUBROUTINE SCATTER(vect_cell, vect, ndata)
4 |
5 | USE mod_pmm
6 | USE mod_slave
7 | #ifdef USEPALM
8 | USE palmlib
9 | #endif
10 |
11 | IMPLICIT NONE
12 |
13 | ! IN
14 | DOM_INT :: ndata
15 | DOM_REAL, DIMENSION(ndata,is_ncells) :: vect_cell
16 |
17 | ! LOCAL
18 | DOM_INT :: j, i, k, inode !, ierr
19 | DOM_REAL, DIMENSION(ndata,is_nnodes) :: local_vect
20 | DOM_INT, DIMENSION(is_nnodes) :: nodecount,total_nodecount
21 |
22 | ! OUT
23 | DOM_REAL,DIMENSION(ndata,is_nnodes) :: vect
24 |
25 | vect = 0.
26 |
27 | ! -----------------------------!
28 | ! Initializing local cell data !
29 | ! -----------------------------!
30 |
31 | local_vect = 0.
32 | nodecount = 0
33 | total_nodecount = 0
34 |
35 | !$OMP PARALLEL DO &
36 | !$OMP& PRIVATE(k,inode) &
37 | !$OMP& SHARED(local_vect, nodecount)
38 |
39 | DO j= 1, is_ncells !is_cellb, is_cellf
40 | DO inode=1, is_cnodes(j)
41 | k = is_cnnode(inode,j)
42 | nodecount(k) = nodecount(k) + 1
43 | local_vect(:,k) = local_vect(:,k) + vect_cell(:,j)
44 | ENDDO
45 | ENDDO
46 |
47 | !$OMP END PARALLEL DO
48 |
49 | ! CALL MPI_ALLREDUCE(local_vect, vect, is_nnodes*ndata, &
50 | ! & MPI_DOUBLE_PRECISION,MPI_SUM, SUB_COMM , &
51 | ! & ierr)
52 |
53 | ! CALL MPI_ALLREDUCE(nodecount, total_nodecount, is_nnodes, &
54 | ! & MPI_INTEGER, MPI_SUM, SUB_COMM , &
55 | ! & ierr)
56 |
57 | vect = local_vect
58 | total_nodecount = nodecount
59 |
60 | DO i=1,ndata
61 | vect(i,:) = vect(i,:) / real(total_nodecount(:))
62 | ENDDO
63 |
64 | END SUBROUTINE SCATTER
scatter.F could be called by: