Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Improve error message
[simgrid.git] / examples / smpi / NAS / LU / exchange_4.f
1
2 c---------------------------------------------------------------------
3 c---------------------------------------------------------------------
4
5       subroutine exchange_4(g,h,ibeg,ifin1,jbeg,jfin1)
6
7 c---------------------------------------------------------------------
8 c---------------------------------------------------------------------
9
10 c---------------------------------------------------------------------
11 c   compute the right hand side based on exact solution
12 c---------------------------------------------------------------------
13
14       implicit none
15
16       include 'mpinpb.h'
17       include 'applu.incl'
18
19 c---------------------------------------------------------------------
20 c  input parameters
21 c---------------------------------------------------------------------
22       double precision  g(0:isiz2+1,0:isiz3+1), 
23      >        h(0:isiz2+1,0:isiz3+1)
24       integer ibeg, ifin1
25       integer jbeg, jfin1
26
27 c---------------------------------------------------------------------
28 c  local variables
29 c---------------------------------------------------------------------
30       integer i, j
31       integer ny2
32       double precision  dum(1024)
33
34       integer msgid1, msgid3
35       integer STATUS(MPI_STATUS_SIZE)
36       integer IERROR
37
38
39
40       ny2 = ny + 2
41
42 c---------------------------------------------------------------------
43 c   communicate in the east and west directions
44 c---------------------------------------------------------------------
45
46 c---------------------------------------------------------------------
47 c   receive from east
48 c---------------------------------------------------------------------
49       if (jfin1.eq.ny) then
50         call MPI_IRECV( dum,
51      >                  2*nx,
52      >                  dp_type,
53      >                  MPI_ANY_SOURCE,
54      >                  from_e,
55      >                  MPI_COMM_WORLD,
56      >                  msgid3,
57      >                  IERROR )
58
59         call MPI_WAIT( msgid3, STATUS, IERROR )
60
61         do i = 1,nx
62           g(i,ny+1) = dum(i)
63           h(i,ny+1) = dum(i+nx)
64         end do
65
66       end if
67
68 c---------------------------------------------------------------------
69 c   send west
70 c---------------------------------------------------------------------
71       if (jbeg.eq.1) then
72         do i = 1,nx
73           dum(i) = g(i,1)
74           dum(i+nx) = h(i,1)
75         end do
76
77         call MPI_SEND( dum,
78      >                 2*nx,
79      >                 dp_type,
80      >                 west,
81      >                 from_e,
82      >                 MPI_COMM_WORLD,
83      >                 IERROR )
84
85       end if
86
87 c---------------------------------------------------------------------
88 c   communicate in the south and north directions
89 c---------------------------------------------------------------------
90
91 c---------------------------------------------------------------------
92 c   receive from south
93 c---------------------------------------------------------------------
94       if (ifin1.eq.nx) then
95         call MPI_IRECV( dum,
96      >                  2*ny2,
97      >                  dp_type,
98      >                  MPI_ANY_SOURCE,
99      >                  from_s,
100      >                  MPI_COMM_WORLD,
101      >                  msgid1,
102      >                  IERROR )
103
104         call MPI_WAIT( msgid1, STATUS, IERROR )
105
106         do j = 0,ny+1
107           g(nx+1,j) = dum(j+1)
108           h(nx+1,j) = dum(j+ny2+1)
109         end do
110
111       end if
112
113 c---------------------------------------------------------------------
114 c   send north
115 c---------------------------------------------------------------------
116       if (ibeg.eq.1) then
117         do j = 0,ny+1
118           dum(j+1) = g(1,j)
119           dum(j+ny2+1) = h(1,j)
120         end do
121
122         call MPI_SEND( dum,
123      >                 2*ny2,
124      >                 dp_type,
125      >                 north,
126      >                 from_s,
127      >                 MPI_COMM_WORLD,
128      >                 IERROR )
129
130       end if
131
132       return
133       end