-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathio_gather.F90
More file actions
214 lines (178 loc) · 7.43 KB
/
io_gather.F90
File metadata and controls
214 lines (178 loc) · 7.43 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
module io_gather_module
USE MOD_PARTIT
USE MOD_PARSUP
implicit none
public init_io_gather, gather_nod2D, gather_real4_nod2D, gather_elem2D, gather_real4_elem2D
private
logical, save :: nod2D_lists_initialized = .false.
integer, save :: rank0Dim_nod2D
integer, save, allocatable, dimension(:) :: rank0List_nod2D
logical, save :: elem2D_lists_initialized = .false.
integer, save :: rank0Dim_elem2D
integer, save, allocatable, dimension(:) :: rank0List_elem2D
contains
subroutine init_io_gather(partit)
type(t_partit), intent(inout), target :: partit
! EO parameters
if(.not. nod2D_lists_initialized) call init_nod2D_lists(partit)
if(.not. elem2D_lists_initialized) call init_elem2D_lists(partit)
end subroutine init_io_gather
subroutine init_nod2D_lists(partit)
implicit none
type(t_partit), intent(inout), target :: partit
#include "associate_part_def.h"
#include "associate_part_ass.h"
! EO args
! todo: initialize with the other comm arrays, probably in "init_gatherLists" subroutine
if(mype /= 0) then
if(.not. allocated(partit%remPtr_nod2D)) allocate(partit%remPtr_nod2D(npes))
#include "associate_part_ass.h"
end if
call MPI_Bcast(remPtr_nod2D, size(remPtr_nod2D), MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
if(mype /= 0) then
if(.not. allocated(partit%remList_nod2D)) allocate(partit%remList_nod2D(remPtr_nod2D(npes)))
#include "associate_part_ass.h"
end if
call MPI_Bcast(remList_nod2D, size(remList_nod2D), MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
if(mype == 0) rank0Dim_nod2D = myDim_nod2D
call mpi_bcast(rank0Dim_nod2D, 1, MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
if(mype == 0) then
allocate(rank0List_nod2D(0))
call mpi_bcast(myList_nod2D, myDim_nod2D, MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
else
allocate(rank0List_nod2D(rank0Dim_nod2D))
call mpi_bcast(rank0List_nod2D, size(rank0List_nod2D), MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
end if
nod2D_lists_initialized = .true.
end subroutine init_nod2D_lists
subroutine init_elem2D_lists(partit)
USE MOD_PARTIT
USE MOD_PARSUP
implicit none
type(t_partit), intent(inout), target :: partit
#include "associate_part_def.h"
#include "associate_part_ass.h"
! EO args
! todo: initialize with the other comm arrays, probably in "init_gatherLists" subroutine
if(mype /= 0) then
if(.not. allocated(partit%remPtr_elem2D)) allocate(partit%remPtr_elem2D(npes))
#include "associate_part_ass.h"
end if
call MPI_Bcast(remPtr_elem2D, size(remPtr_elem2D), MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
if(mype /= 0) then
if(.not. allocated(partit%remList_elem2D)) allocate(partit%remList_elem2D(remPtr_elem2D(npes)))
#include "associate_part_ass.h"
end if
call MPI_Bcast(remList_elem2D, size(remList_elem2D), MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
if(mype == 0) rank0Dim_elem2D = myDim_elem2D
call mpi_bcast(rank0Dim_elem2D, 1, MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
if(mype == 0) then
allocate(rank0List_elem2D(0))
call mpi_bcast(myList_elem2D, myDim_elem2D, MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
else
allocate(rank0List_elem2D(rank0Dim_elem2D))
call mpi_bcast(rank0List_elem2D, size(rank0List_elem2D), MPI_INTEGER, 0, MPI_COMM_FESOM, MPIerr)
end if
elem2D_lists_initialized = .true.
end subroutine init_elem2D_lists
! thread-safe procedure
subroutine gather_nod2D(arr2D, arr2D_global, root_rank, tag, io_comm, partit)
USE MOD_PARTIT
USE MOD_PARSUP
use, intrinsic :: iso_fortran_env, only: real64
implicit none
type(t_partit), intent(inout), target :: partit
real(real64), intent(in) :: arr2D(:)
real(real64), intent(out) :: arr2D_global(:)
integer, intent(in) :: root_rank ! rank of receiving process
integer, intent(in) :: tag
integer io_comm
! EO args
integer :: remote_rank = -1
integer :: remote_node_count = -1
real(real64), allocatable :: sendbuf(:)
real(real64), allocatable :: recvbuf(:) ! todo: alloc only for root_rank
integer :: req(partit%npes-1)
integer :: request_index
integer :: mpi_precision = MPI_DOUBLE_PRECISION
#include "associate_part_def.h"
#include "associate_part_ass.h"
if(.not. nod2D_lists_initialized) stop "io_gather_module has not been initialized"
include "io_gather_nod.inc"
end subroutine gather_nod2D
! thread-safe procedure
subroutine gather_real4_nod2D(arr2D, arr2D_global, root_rank, tag, io_comm, partit)
USE MOD_PARTIT
USE MOD_PARSUP
use, intrinsic :: iso_fortran_env, only: real32
implicit none
type(t_partit), intent(inout), target :: partit
real(real32), intent(in) :: arr2D(:)
real(real32), intent(out) :: arr2D_global(:)
integer, intent(in) :: root_rank ! rank of receiving process
integer, intent(in) :: tag
integer io_comm
! EO args
integer :: remote_rank = -1
integer :: remote_node_count = -1
real(real32), allocatable :: sendbuf(:)
real(real32), allocatable :: recvbuf(:) ! todo: alloc only for root_rank
integer :: req(partit%npes-1)
integer :: request_index
integer :: mpi_precision = MPI_REAL
#include "associate_part_def.h"
#include "associate_part_ass.h"
if(.not. nod2D_lists_initialized) stop "io_gather_module has not been initialized"
include "io_gather_nod.inc"
end subroutine gather_real4_nod2D
! thread-safe procedure
subroutine gather_elem2D(arr2D, arr2D_global, root_rank, tag, io_comm, partit)
USE MOD_PARTIT
USE MOD_PARSUP
use, intrinsic :: iso_fortran_env, only: real64
implicit none
type(t_partit), intent(inout), target :: partit
real(real64), intent(in) :: arr2D(:)
real(real64), intent(out) :: arr2D_global(:)
integer, intent(in) :: root_rank ! rank of receiving process
integer, intent(in) :: tag
integer io_comm
! EO args
integer :: remote_rank = -1
integer :: remote_elem_count = -1
real(real64), allocatable :: sendbuf(:)
real(real64), allocatable :: recvbuf(:)
integer :: req(partit%npes-1)
integer :: request_index
integer :: mpi_precision = MPI_DOUBLE_PRECISION
#include "associate_part_def.h"
#include "associate_part_ass.h"
if(.not. elem2D_lists_initialized) stop "io_gather_module has not been initialized"
include "io_gather_elem.inc"
end subroutine gather_elem2D
! thread-safe procedure
subroutine gather_real4_elem2D(arr2D, arr2D_global, root_rank, tag, io_comm, partit)
USE MOD_PARTIT
USE MOD_PARSUP
use, intrinsic :: iso_fortran_env, only: real32
implicit none
type(t_partit), intent(inout), target :: partit
real(real32), intent(in) :: arr2D(:)
real(real32), intent(out) :: arr2D_global(:)
integer, intent(in) :: root_rank ! rank of receiving process
integer, intent(in) :: tag
integer io_comm
! EO args
integer :: remote_rank = -1
integer :: remote_elem_count = -1
real(real32), allocatable :: sendbuf(:)
real(real32), allocatable :: recvbuf(:)
integer :: req(partit%npes-1)
integer :: request_index
integer :: mpi_precision = MPI_REAL
#include "associate_part_def.h"
#include "associate_part_ass.h"
if(.not. elem2D_lists_initialized) stop "io_gather_module has not been initialized"
include "io_gather_elem.inc"
end subroutine gather_real4_elem2D
end module io_gather_module