-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpi_transfer.f90
executable file
·78 lines (66 loc) · 2.24 KB
/
mpi_transfer.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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Module for MPI communication
!
! Last update: December 12, 2008
! Author: Keita Ando
! Department of Mechanical Engineering
! Division of Engineering and Applied Science
! California Institute of Technology, Pasadena CA 91125
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MODULE mpi_transfer
USE mpi_setup
USE m_globalvar
IMPLICIT NONE
CONTAINS
!========================================================================
SUBROUTINE s_mpi_transfer( qgvn )
TYPE(coordinate), DIMENSION(Nv), INTENT(INOUT) :: qgvn
INTEGER :: i
INTEGER :: iv
INTEGER :: arg
REAL(KIND(0.D0)), DIMENSION(Nv*padding) :: qsendu
REAL(KIND(0.D0)), DIMENSION(Nv*padding) :: qsendd
REAL(KIND(0.D0)), DIMENSION(Nv*padding) :: qrecvd
REAL(KIND(0.D0)), DIMENSION(Nv*padding) :: qrecvu
DO iv = 1,Nv
DO i = 1,padding
arg = padding*( iv-1 ) + i
qsendu(arg) = qgvn(iv)%f(Nx-2*padding+i)
END DO
END DO
DO iv = 1,Nv
DO i = 1,padding
arg = padding*( iv-1 ) + i
qsendd(arg) = qgvn(iv)%f(i+padding)
END DO
END DO
! send to the right and recieve from the left
CALL MPI_SENDRECV( qsendu(1),Nv*padding,MPI_DOUBLE_PRECISION,iup,0, &
qrecvd(1),Nv*padding,MPI_DOUBLE_PRECISION,idown,0, &
MPI_COMM_WORLD,istatus,mpi_err )
! send to the left and recieve from the right
CALL MPI_SENDRECV( qsendd(1),Nv*padding,MPI_DOUBLE_PRECISION,idown,0, &
qrecvu(1),Nv*padding,MPI_DOUBLE_PRECISION,iup,0, &
MPI_COMM_WORLD,istatus,mpi_err )
! pad
IF ( mpi_rank/=0 ) THEN
DO iv = 1,Nv
DO i = 1,padding
arg = padding*( iv-1 ) + i
qgvn(iv)%f(i) = qrecvd(arg)
END DO
END DO
END IF
IF ( mpi_rank/=mpi_size-1 ) THEN
DO iv = 1,Nv
DO i = 1,padding
arg = padding*( iv-1 ) + i
qgvn(iv)%f(Nx-padding+i) = qrecvu(arg)
END DO
END DO
END IF
END SUBROUTINE s_mpi_transfer
!========================================================================
END MODULE mpi_transfer