forked from xcompact3d/Incompact3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmem_split.f90
92 lines (86 loc) · 2.44 KB
/
mem_split.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
!=======================================================================
! This is part of the 2DECOMP&FFT library
!
! 2DECOMP&FFT is a software framework for general-purpose 2D (pencil)
! decomposition. It also implements a highly scalable distributed
! three-dimensional Fast Fourier Transform (FFT).
!
! Copyright (C) 2009-2011 Ning Li, the Numerical Algorithms Group (NAG)
!
!=======================================================================
! This file contain duplicated code that gathers data from source to
! MPI_ALLTOALLV send buffer. It is 'included' by two subroutines in
! decomp_2d.f90
! Note:
! in --> source array
! out --> send buffer
! pos --> pointer for the send buffer
! - for normal ALLTOALLV, points to the beginning of send buffer (=1)
! - for shared memory code, note the send buffer is shared by all cores
! on same node, so 'pos' points to the correct location for this core
integer, intent(IN) :: ndir
integer, intent(IN) :: iproc
integer, dimension(0:iproc-1), intent(IN) :: dist
TYPE(DECOMP_INFO), intent(IN) :: decomp
integer :: i,j,k, m,i1,i2,pos
#ifndef SHM
pos = 1
#endif
do m=0,iproc-1
if (m==0) then
i1 = 1
i2 = dist(0)
else
i1 = i2+1
i2 = i1+dist(m)-1
endif
if (ndir==1) then
#ifdef SHM
pos = decomp%x1disp_o(m) + 1
#endif
do k=1,n3
do j=1,n2
do i=i1,i2
out(pos) = in(i,j,k)
pos = pos + 1
enddo
enddo
enddo
else if (ndir==2) then
#ifdef SHM
pos = decomp%y2disp_o(m) + 1
#endif
do k=1,n3
do j=i1,i2
do i=1,n1
out(pos) = in(i,j,k)
pos = pos + 1
enddo
enddo
enddo
else if (ndir==3) then
#ifdef SHM
pos = decomp%z2disp_o(m) + 1
#endif
do k=i1,i2
do j=1,n2
do i=1,n1
out(pos) = in(i,j,k)
pos = pos + 1
enddo
enddo
enddo
else if (ndir==4) then
#ifdef SHM
pos = decomp%y1disp_o(m) + 1
#endif
do k=1,n3
do j=i1,i2
do i=1,n1
out(pos) = in(i,j,k)
pos = pos + 1
enddo
enddo
enddo
endif
enddo