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 logger, only : neko_log, neko_log_debug
42 use, intrinsic :: iso_c_binding
43 implicit none
44 private
45
55 type, public :: data_streamer_t
57 integer :: if_asynch
59 integer, allocatable :: lglel(:)
60 contains
62 procedure, pass(this) :: init => data_streamer_init
64 procedure, pass(this) :: free => data_streamer_free
66 procedure, pass(this) :: stream => data_streamer_stream
68 procedure, pass(this) :: recieve => data_streamer_recieve
69
70 end type data_streamer_t
71
72contains
73
80 subroutine data_streamer_init(this, coef, timeout_seconds)
81 class(data_streamer_t), intent(inout) :: this
82 type(coef_t), intent(inout) :: coef
83 integer, intent(in), optional :: timeout_seconds
84 integer :: nelb, nelv, nelgv, npts, gdim, timeout
85
86 !Assign the set up parameters
87 nelv = coef%msh%nelv
88 npts = coef%Xh%lx*coef%Xh%ly*coef%Xh%lz
89 nelgv = coef%msh%glb_nelv
90 nelb = coef%msh%offset_el
91 gdim = coef%msh%gdim
92 if (present(timeout_seconds)) then
93 timeout = timeout_seconds
94 else
95 timeout = 300
96 end if
97
98#ifdef HAVE_ADIOS2
99 call neko_log%message("Initializing ADIOS2", lvl = neko_log_debug)
100 call fortran_adios2_initialize(npts, nelv, nelb, nelgv, gdim, neko_comm, &
101 timeout)
102 call neko_log%message("Done initializing ADIOS2", lvl = neko_log_debug)
103#else
104 call neko_warning('Is not being built with ADIOS2 support.')
105 call neko_warning('Not able to use stream/compression functionality')
106#endif
107
108
109 end subroutine data_streamer_init
110
113 subroutine data_streamer_free(this)
114 class(data_streamer_t), intent(inout) :: this
115
116#ifdef HAVE_ADIOS2
117 call neko_log%message("Finalizing ADIOS2", lvl = neko_log_debug)
118 call fortran_adios2_finalize()
119 call neko_log%message("Done finalizing ADIOS2", lvl = neko_log_debug)
120#else
121 call neko_warning('Is not being built with ADIOS2 support.')
122 call neko_warning('Not able to use stream/compression functionality')
123#endif
124
125 end subroutine data_streamer_free
126
129 subroutine data_streamer_stream(this, fld)
130 class(data_streamer_t), intent(inout) :: this
131 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
132
133#ifdef HAVE_ADIOS2
134 call neko_log%message("Streaming data", lvl = neko_log_debug)
135 call fortran_adios2_stream(fld)
136 call neko_log%message("Done streaming data", lvl = neko_log_debug)
137#else
138 call neko_warning('Is not being built with ADIOS2 support.')
139 call neko_warning('Not able to use stream/compression functionality')
140#endif
141
142 end subroutine data_streamer_stream
143
146 subroutine data_streamer_recieve(this, fld)
147 class(data_streamer_t), intent(inout) :: this
148 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
149
150#ifdef HAVE_ADIOS2
151 call neko_log%message("Receiving data", lvl = neko_log_debug)
152 call fortran_adios2_recieve(fld)
153 call neko_log%message("Done receiving data", lvl = neko_log_debug)
154#else
155 call neko_warning('Is not being built with ADIOS2 support.')
156 call neko_warning('Not able to use stream/compression functionality')
157#endif
158
159 end subroutine data_streamer_recieve
160
161
162#ifdef HAVE_ADIOS2
163
174 subroutine fortran_adios2_initialize(npts, nelv, nelb, nelgv, gdim, &
175 comm, timeout)
176 use, intrinsic :: iso_c_binding
177 implicit none
178 integer, intent(in) :: npts, nelv, nelb, nelgv, gdim
179 integer, intent(in) :: timeout
180 type(mpi_comm) :: comm
181
182 interface
183
188 subroutine c_adios2_initialize(npts, nelv, nelb, nelgv, gdim, &
189 comm, timeout) bind(C, name = "adios2_initialize_")
190 use, intrinsic :: iso_c_binding
191 import c_rp
192 implicit none
193 integer(kind=C_INT) :: npts
194 integer(kind=C_INT) :: nelv
195 integer(kind=C_INT) :: nelb
196 integer(kind=C_INT) :: nelgv
197 integer(kind=C_INT) :: gdim
198 type(*) :: comm
199 integer(kind=C_INT) :: timeout
200 end subroutine c_adios2_initialize
201 end interface
202
203 call c_adios2_initialize(npts, nelv, nelb, nelgv, gdim, comm, timeout)
204 end subroutine fortran_adios2_initialize
205
208 subroutine fortran_adios2_finalize()
209 use, intrinsic :: iso_c_binding
210 implicit none
211
212 interface
213
214 subroutine c_adios2_finalize() bind(C, name = "adios2_finalize_")
215 use, intrinsic :: iso_c_binding
216 implicit none
217 end subroutine c_adios2_finalize
218 end interface
219
220 call c_adios2_finalize()
221 end subroutine fortran_adios2_finalize
222
228 subroutine fortran_adios2_stream(fld)
229 use, intrinsic :: iso_c_binding
230 implicit none
231 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
232
233 interface
234
235 subroutine c_adios2_stream(fld) &
236 bind(C, name = "adios2_stream_")
237 use, intrinsic :: iso_c_binding
238 import c_rp
239 implicit none
240 real(kind=c_rp), intent(INOUT) :: fld(*)
241 end subroutine c_adios2_stream
242 end interface
243
244 call c_adios2_stream(fld)
245 end subroutine fortran_adios2_stream
246
252 subroutine fortran_adios2_recieve(fld)
253 use, intrinsic :: iso_c_binding
254 implicit none
255 real(kind=rp), dimension(:,:,:,:), intent(inout) :: fld
256
257 interface
258
259 subroutine c_adios2_recieve(fld) &
260 bind(C, name = "adios2_recieve_")
261 use, intrinsic :: iso_c_binding
262 import c_rp
263 implicit none
264 real(kind=c_rp), intent(INOUT) :: fld(*)
265 end subroutine c_adios2_recieve
266 end interface
267
268 call c_adios2_recieve(fld)
269 end subroutine fortran_adios2_recieve
270
271#endif
272
273end 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
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
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.