Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
data_streamer.F90
Go to the documentation of this file.
1! Copyright (c) 2020-2025, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
35 use num_types, only: rp, c_rp
36 use field, only: field_t
37 use coefs, only: coef_t
38 use utils, only: neko_warning
39 use comm, only : neko_comm
40 use mpi_f08, only : mpi_comm
41 use, intrinsic :: iso_c_binding
42 implicit none
43 private
44
54 type, public :: data_streamer_t
56 integer :: if_asynch
58 integer, allocatable :: lglel(:)
59 contains
61 procedure, pass(this) :: init => data_streamer_init
63 procedure, pass(this) :: free => data_streamer_free
65 procedure, pass(this) :: stream => data_streamer_stream
67 procedure, pass(this) :: recieve => data_streamer_recieve
68
69 end type data_streamer_t
70
71contains
72
79 subroutine data_streamer_init(this, coef, timeout_seconds)
80 class(data_streamer_t), intent(inout) :: this
81 type(coef_t), intent(inout) :: coef
82 integer, intent(in), optional :: timeout_seconds
83 integer :: nelb, nelv, nelgv, npts, gdim, timeout
84
85 !Assign the set up parameters
86 nelv = coef%msh%nelv
87 npts = coef%Xh%lx*coef%Xh%ly*coef%Xh%lz
88 nelgv = coef%msh%glb_nelv
89 nelb = coef%msh%offset_el
90 gdim = coef%msh%gdim
91 if (present(timeout_seconds)) then
92 timeout = timeout_seconds
93 else
94 timeout = 300
95 end if
96
97
98#ifdef HAVE_ADIOS2
99 call fortran_adios2_initialize(npts, nelv, nelb, nelgv, gdim, neko_comm, timeout)
100#else
101 call neko_warning('Is not being built with ADIOS2 support.')
102 call neko_warning('Not able to use stream/compression functionality')
103#endif
104
105
106 end subroutine data_streamer_init
107
110 subroutine data_streamer_free(this)
111 class(data_streamer_t), intent(inout) :: this
112
113#ifdef HAVE_ADIOS2
114 call fortran_adios2_finalize()
115#else
116 call neko_warning('Is not being built with ADIOS2 support.')
117 call neko_warning('Not able to use stream/compression functionality')
118#endif
119
120 end subroutine data_streamer_free
121
124 subroutine data_streamer_stream(this, fld)
125 class(data_streamer_t), intent(inout) :: this
126 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
127
128#ifdef HAVE_ADIOS2
129 call fortran_adios2_stream(fld)
130#else
131 call neko_warning('Is not being built with ADIOS2 support.')
132 call neko_warning('Not able to use stream/compression functionality')
133#endif
134
135 end subroutine data_streamer_stream
136
139 subroutine data_streamer_recieve(this, fld)
140 class(data_streamer_t), intent(inout) :: this
141 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
142
143#ifdef HAVE_ADIOS2
144 call fortran_adios2_recieve(fld)
145#else
146 call neko_warning('Is not being built with ADIOS2 support.')
147 call neko_warning('Not able to use stream/compression functionality')
148#endif
149
150 end subroutine data_streamer_recieve
151
152
153#ifdef HAVE_ADIOS2
154
165 subroutine fortran_adios2_initialize(npts, nelv, nelb, nelgv, gdim, &
166 comm, timeout)
167 use, intrinsic :: iso_c_binding
168 implicit none
169 integer, intent(in) :: npts, nelv, nelb, nelgv, gdim
170 integer, intent(in) :: timeout
171 type(mpi_comm) :: comm
172
173 interface
174
179 subroutine c_adios2_initialize(npts, nelv, nelb, nelgv, gdim, &
180 comm, timeout) bind(C,name="adios2_initialize_")
181 use, intrinsic :: iso_c_binding
182 import c_rp
183 implicit none
184 integer(kind=C_INT) :: npts
185 integer(kind=C_INT) :: nelv
186 integer(kind=C_INT) :: nelb
187 integer(kind=C_INT) :: nelgv
188 integer(kind=C_INT) :: gdim
189 type(*) :: comm
190 integer(kind=C_INT) :: timeout
191 end subroutine c_adios2_initialize
192 end interface
193
194 call c_adios2_initialize(npts, nelv, nelb, nelgv, gdim, comm, timeout)
195 end subroutine fortran_adios2_initialize
196
199 subroutine fortran_adios2_finalize()
200 use, intrinsic :: iso_c_binding
201 implicit none
202
203 interface
204
205 subroutine c_adios2_finalize() bind(C,name="adios2_finalize_")
206 use, intrinsic :: iso_c_binding
207 implicit none
208 end subroutine c_adios2_finalize
209 end interface
210
211 call c_adios2_finalize()
212 end subroutine fortran_adios2_finalize
213
219 subroutine fortran_adios2_stream(fld)
220 use, intrinsic :: iso_c_binding
221 implicit none
222 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
223
224 interface
225
226 subroutine c_adios2_stream(fld) &
227 bind(C,name="adios2_stream_")
228 use, intrinsic :: iso_c_binding
229 import c_rp
230 implicit none
231 real(kind=c_rp), intent(INOUT) :: fld(*)
232 end subroutine c_adios2_stream
233 end interface
234
235 call c_adios2_stream(fld)
236 end subroutine fortran_adios2_stream
237
243 subroutine fortran_adios2_recieve(fld)
244 use, intrinsic :: iso_c_binding
245 implicit none
246 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
247
248 interface
249
250 subroutine c_adios2_recieve(fld) &
251 bind(C,name="adios2_recieve_")
252 use, intrinsic :: iso_c_binding
253 import c_rp
254 implicit none
255 real(kind=c_rp), intent(INOUT) :: fld(*)
256 end subroutine c_adios2_recieve
257 end interface
258
259 call c_adios2_recieve(fld)
260 end subroutine fortran_adios2_recieve
261
262#endif
263
264end module data_streamer
Coefficients.
Definition coef.f90:34
Definition comm.F90:1
type(mpi_comm), public neko_comm
MPI communicator.
Definition comm.F90:43
Implements type data_streamer_t.
subroutine data_streamer_init(this, coef, timeout_seconds)
Constructor Wraps the adios2 set-up.
subroutine data_streamer_recieve(this, fld)
reciever
subroutine data_streamer_stream(this, fld)
streamer
subroutine data_streamer_free(this)
Destructor wraps the adios2 finalize routine. Closes insitu writer.
Defines a field.
Definition field.f90:34
integer, parameter, public c_rp
Definition num_types.f90:13
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:346
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:62
Provides access to data streaming by interfacing with c++ ADIOS2 subroutines.