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 mesh, only : mesh_t
37 use space, only : space_t
38 use coefs, only : coef_t
39 use utils, only : neko_warning
40 use comm, only : neko_comm
41 use mpi_f08, only : mpi_comm
42 use logger, only : neko_log, neko_log_debug
43 use, intrinsic :: iso_c_binding
44 implicit none
45 private
46
56 type, public :: data_streamer_t
58 integer :: if_asynch
60 integer, allocatable :: lglel(:)
61 contains
63 generic :: init => init_coef, init_msh_xh, init_params
65 procedure, pass(this) :: init_coef => data_streamer_init_coef
67 procedure, pass(this) :: init_msh_xh => data_streamer_init_msh_xh
69 procedure, pass(this) :: init_params => data_streamer_init_params
71 procedure, pass(this) :: free => data_streamer_free
73 procedure, pass(this) :: stream => data_streamer_stream
75 procedure, pass(this) :: recieve => data_streamer_recieve
76
77 end type data_streamer_t
78
79contains
80
91 subroutine data_streamer_init_params(this, nelv, lx, ly, lz, glb_nelv, &
92 offset_el, gdim, timeout_seconds)
93 class(data_streamer_t), intent(inout) :: this
94 integer, intent(in) :: nelv, lx, ly, lz, glb_nelv, offset_el, gdim
95 integer, intent(in), optional :: timeout_seconds
96
97 integer :: npts, timeout
98
99 npts = lx*ly*lz
100
101 if (present(timeout_seconds)) then
102 timeout = timeout_seconds
103 else
104 timeout = 300
105 end if
106
107#ifdef HAVE_ADIOS2
108 call neko_log%message("Initializing ADIOS2", lvl = neko_log_debug)
109 call fortran_adios2_initialize(npts, nelv, offset_el, glb_nelv, gdim, &
110 neko_comm, timeout)
111 call neko_log%message("Done initializing ADIOS2", lvl = neko_log_debug)
112#else
113 call neko_warning('Is not being built with ADIOS2 support.')
114 call neko_warning('Not able to use stream/compression functionality')
115#endif
116
117 end subroutine data_streamer_init_params
118
121 subroutine data_streamer_free(this)
122 class(data_streamer_t), intent(inout) :: this
123
124#ifdef HAVE_ADIOS2
125 call neko_log%message("Finalizing ADIOS2", lvl = neko_log_debug)
126 call fortran_adios2_finalize()
127 call neko_log%message("Done finalizing ADIOS2", lvl = neko_log_debug)
128#else
129 call neko_warning('Is not being built with ADIOS2 support.')
130 call neko_warning('Not able to use stream/compression functionality')
131#endif
132
133 end subroutine data_streamer_free
134
137 subroutine data_streamer_stream(this, fld)
138 class(data_streamer_t), intent(inout) :: this
139 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
140
141#ifdef HAVE_ADIOS2
142 call neko_log%message("Streaming data", lvl = neko_log_debug)
143 call fortran_adios2_stream(fld)
144 call neko_log%message("Done streaming data", lvl = neko_log_debug)
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_stream
151
154 subroutine data_streamer_recieve(this, fld)
155 class(data_streamer_t), intent(inout) :: this
156 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
157
158#ifdef HAVE_ADIOS2
159 call neko_log%message("Receiving data", lvl = neko_log_debug)
160 call fortran_adios2_recieve(fld)
161 call neko_log%message("Done receiving data", lvl = neko_log_debug)
162#else
163 call neko_warning('Is not being built with ADIOS2 support.')
164 call neko_warning('Not able to use stream/compression functionality')
165#endif
166
167 end subroutine data_streamer_recieve
168
169
176 subroutine data_streamer_init_coef(this, coef, timeout_seconds)
177 class(data_streamer_t), intent(inout) :: this
178 type(coef_t), intent(inout) :: coef
179 integer, intent(in), optional :: timeout_seconds
180
181 call this%init_msh_Xh(coef%msh, coef%Xh, timeout_seconds)
182
183 end subroutine data_streamer_init_coef
184
191 subroutine data_streamer_init_msh_xh(this, msh, xh, timeout_seconds)
192 class(data_streamer_t), intent(inout) :: this
193 type(mesh_t), intent(in) :: msh
194 type(space_t), intent(in) :: xh
195 integer, intent(in), optional :: timeout_seconds
196
197 call this%init_params(msh%nelv, xh%lx, xh%ly, xh%lz, msh%glb_nelv, &
198 msh%offset_el, msh%gdim, timeout_seconds)
199
200 end subroutine data_streamer_init_msh_xh
201
202#ifdef HAVE_ADIOS2
203
214 subroutine fortran_adios2_initialize(npts, nelv, nelb, nelgv, gdim, &
215 comm, timeout)
216 use, intrinsic :: iso_c_binding
217 implicit none
218 integer, intent(in) :: npts, nelv, nelb, nelgv, gdim
219 integer, intent(in) :: timeout
220 type(mpi_comm) :: comm
221
222 interface
223
228 subroutine c_adios2_initialize(npts, nelv, nelb, nelgv, gdim, &
229 comm, timeout) bind(C, name = "adios2_initialize_")
230 use, intrinsic :: iso_c_binding
231 import c_rp
232 implicit none
233 integer(kind=C_INT) :: npts
234 integer(kind=C_INT) :: nelv
235 integer(kind=C_INT) :: nelb
236 integer(kind=C_INT) :: nelgv
237 integer(kind=C_INT) :: gdim
238 type(*) :: comm
239 integer(kind=C_INT) :: timeout
240 end subroutine c_adios2_initialize
241 end interface
242
243 call c_adios2_initialize(npts, nelv, nelb, nelgv, gdim, comm, timeout)
244 end subroutine fortran_adios2_initialize
245
248 subroutine fortran_adios2_finalize()
249 use, intrinsic :: iso_c_binding
250 implicit none
251
252 interface
253
254 subroutine c_adios2_finalize() bind(C, name = "adios2_finalize_")
255 use, intrinsic :: iso_c_binding
256 implicit none
257 end subroutine c_adios2_finalize
258 end interface
259
260 call c_adios2_finalize()
261 end subroutine fortran_adios2_finalize
262
268 subroutine fortran_adios2_stream(fld)
269 use, intrinsic :: iso_c_binding
270 implicit none
271 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
272
273 interface
274
275 subroutine c_adios2_stream(fld) &
276 bind(C, name = "adios2_stream_")
277 use, intrinsic :: iso_c_binding
278 import c_rp
279 implicit none
280 real(kind=c_rp), intent(INOUT) :: fld(*)
281 end subroutine c_adios2_stream
282 end interface
283
284 call c_adios2_stream(fld)
285 end subroutine fortran_adios2_stream
286
292 subroutine fortran_adios2_recieve(fld)
293 use, intrinsic :: iso_c_binding
294 implicit none
295 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
296
297 interface
298
299 subroutine c_adios2_recieve(fld) &
300 bind(C, name = "adios2_recieve_")
301 use, intrinsic :: iso_c_binding
302 import c_rp
303 implicit none
304 real(kind=c_rp), intent(INOUT) :: fld(*)
305 end subroutine c_adios2_recieve
306 end interface
307
308 call c_adios2_recieve(fld)
309 end subroutine fortran_adios2_recieve
310
311#endif
312
313end 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_recieve(this, fld)
reciever
subroutine data_streamer_init_coef(this, coef, timeout_seconds)
Constructor from a coef_t object. Kept for backwards compatibility. Wraps the adios2 set-up.
subroutine data_streamer_stream(this, fld)
streamer
subroutine data_streamer_init_params(this, nelv, lx, ly, lz, glb_nelv, offset_el, gdim, timeout_seconds)
Constructor from parameters.
subroutine data_streamer_init_msh_xh(this, msh, xh, timeout_seconds)
Constructor from a mesh and space.
subroutine data_streamer_free(this)
Destructor wraps the adios2 finalize routine. Closes insitu writer.
Logging routines.
Definition log.f90:34
integer, parameter, public neko_log_debug
Debug log level.
Definition log.f90:89
type(log_t), public neko_log
Global log stream.
Definition log.f90:79
Defines a mesh.
Definition mesh.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
Defines a function space.
Definition space.f90:34
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:392
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:63
Provides access to data streaming by interfacing with c++ ADIOS2 subroutines.
The function space for the SEM solution fields.
Definition space.f90:63