SPEED
EXCHANGE_INTEGER.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
34
35 subroutine exchange_integer(nsend,buff_send,nrecv,buff_recv,&
36 nproc,proc_send,proc_recv,&
37 comm,status,ierr,myid)
38
39 implicit none
40 include 'SPEED.MPI'
41
42 integer*4 :: nsend,nrecv,nproc,comm,ierr,tag,myid
43 integer*4 :: ip,ir,is
44
45 integer*4, dimension(nproc) :: proc_send,proc_recv
46 integer*4, dimension(SPEED_STATUS_SIZE) :: status
47 integer*4, dimension(nproc) :: request,requests
48
49! real*8, dimension(*) :: buff_send,buff_recv
50 integer*4, dimension(nsend) :: buff_send
51 integer*4, dimension(nrecv) :: buff_recv
52
53 tag=2120
54
55
56
57 is = 1
58 do ip = 1, nproc
59 if (proc_send(ip).gt.0) then
60 call mpi_isend(buff_send(is:(is +proc_send(ip) -1)),&
61 proc_send(ip),speed_integer,(ip -1),&
62 tag,comm,requests(ip),ierr)
63 endif
64 is = is +proc_send(ip)
65 enddo
66
67 ir = 1
68 do ip = 1, nproc
69 if (proc_recv(ip).gt.0) then
70 call mpi_irecv(buff_recv(ir:(ir +proc_recv(ip) -1)),&
71 proc_recv(ip),speed_integer,(ip -1),&
72 mpi_any_tag,comm,request(ip),ierr)
73 endif
74 ir = ir +proc_recv(ip)
75 enddo
76
77 do ip = 1, nproc
78 if (proc_send(ip).gt.0) then
79 call mpi_wait(requests(ip),status,ierr)
80 endif
81 enddo
82 do ip = 1, nproc
83 if (proc_recv(ip).gt.0) then
84 call mpi_wait(request(ip),status,ierr)
85 endif
86 enddo
87
88 speed_tag = speed_tag +1
89 if (speed_tag.gt.speed_tag_max) speed_tag = speed_tag_min
90
91 return
92
93 end subroutine exchange_integer
94
subroutine exchange_integer(nsend, buff_send, nrecv, buff_recv, nproc, proc_send, proc_recv, comm, status, ierr, myid)
Exchanges integers between MPI processes.