SPEED
EXCHANGE_DOUBLE.f90
Go to the documentation of this file.
1! Copyright (C) 2012 The SPEED FOUNDATION
2! Author: Ilario Mazzieri
3!
4! This file is part of SPEED.
5!
6! SPEED is free software; you can redistribute it and/or modify it
7! under the terms of the GNU Affero General Public License as
8! published by the Free Software Foundation, either version 3 of the
9! License, or (at your option) any later version.
10!
11! SPEED is distributed in the hope that it will be useful, but
12! WITHOUT ANY WARRANTY; without even the implied warranty of
13! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14! Affero General Public License for more details.
15!
16! You should have received a copy of the GNU Affero General Public License
17! along with SPEED. If not, see <http://www.gnu.org/licenses/>.
18
19
35
36 subroutine exchange_double(nsend,buff_send,nrecv,buff_recv,&
37 nproc,proc_send,proc_recv,&
38 comm,status,ierr,myid)
39
40 implicit none
41 include 'SPEED.MPI'
42
43 integer*4 :: nsend,nrecv,nproc,comm,ierr,tag,myid
44 integer*4 :: ip,ir,is
45
46 integer*4, dimension(nproc) :: proc_send,proc_recv
47 integer*4, dimension(SPEED_STATUS_SIZE) :: status
48 integer*4, dimension(nproc) :: request,requests
49
50! real*8, dimension(*) :: buff_send,buff_recv
51 real*8, dimension(nsend) :: buff_send
52 real*8, dimension(nrecv) :: buff_recv
53
54 tag=2120
55
56 is = 1
57 do ip = 1, nproc
58 if (proc_send(ip).gt.0) then
59 call mpi_isend(buff_send(is:(is +proc_send(ip) -1)),&
60 proc_send(ip),speed_double,(ip -1),&
61 tag,comm,requests(ip),ierr)
62 endif
63 is = is +proc_send(ip)
64 enddo
65
66 ir = 1
67 do ip = 1, nproc
68 if (proc_recv(ip).gt.0) then
69 call mpi_irecv(buff_recv(ir:(ir +proc_recv(ip) -1)),&
70 proc_recv(ip),speed_double,(ip -1),&
71 mpi_any_tag,comm,request(ip),ierr)
72 endif
73 ir = ir +proc_recv(ip)
74 enddo
75
76 do ip = 1, nproc
77 if (proc_send(ip).gt.0) then
78 call mpi_wait(requests(ip),status,ierr)
79 endif
80 enddo
81 do ip = 1, nproc
82 if (proc_recv(ip).gt.0) then
83 call mpi_wait(request(ip),status,ierr)
84 endif
85 enddo
86
87 speed_tag = speed_tag +1
88 if (speed_tag.gt.speed_tag_max) speed_tag = speed_tag_min
89
90 return
91
92 end subroutine exchange_double
93
subroutine exchange_double(nsend, buff_send, nrecv, buff_recv, nproc, proc_send, proc_recv, comm, status, ierr, myid)
Exchanges double between MPI processes.