Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
hip_math.f90
Go to the documentation of this file.
1! Copyright (c) 2024-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!
34 use num_types, only: rp, c_rp
35 implicit none
36 public
37
38 interface
39 subroutine hip_copy(a_d, b_d, n, strm) &
40 bind(c, name = 'hip_copy')
41 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
42 type(c_ptr), value :: a_d, b_d, strm
43 integer(c_int) :: n
44 end subroutine hip_copy
45
46 subroutine hip_masked_copy(a_d, b_d, mask_d, n, n_mask, strm) &
47 bind(c, name = 'hip_masked_copy')
48 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
49 type(c_ptr), value :: a_d, b_d, mask_d, strm
50 integer(c_int) :: n, n_mask
51 end subroutine hip_masked_copy
52
53 subroutine hip_masked_gather_copy(a_d, b_d, mask_d, n, n_mask, strm) &
54 bind(c, name = 'hip_masked_gather_copy')
55 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
56 type(c_ptr), value :: a_d, b_d, mask_d, strm
57 integer(c_int) :: n, n_mask
58 end subroutine hip_masked_gather_copy
59
60 subroutine hip_masked_scatter_copy(a_d, b_d, mask_d, n, n_mask, strm) &
61 bind(c, name = 'hip_masked_scatter_copy')
62 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
63 type(c_ptr), value :: a_d, b_d, mask_d, strm
64 integer(c_int) :: n, n_mask
65 end subroutine hip_masked_scatter_copy
66
67 subroutine hip_masked_atomic_reduction(a_d, b_d, mask_d, n, m, strm) &
68 bind(c, name = 'hip_masked_atomic_reduction')
69 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
70 type(c_ptr), value :: a_d, b_d, mask_d, strm
71 integer(c_int) :: n, m
72 end subroutine hip_masked_atomic_reduction
73
74 subroutine hip_cfill_mask(a_d, c, n, mask_d, n_mask, strm) &
75 bind(c, name = 'hip_cfill_mask')
76 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
77 import c_rp
78 type(c_ptr), value :: a_d
79 real(c_rp) :: c
80 integer(c_int) :: n
81 type(c_ptr), value :: mask_d
82 integer(c_int) :: n_mask
83 type(c_ptr), value :: strm
84 end subroutine hip_cfill_mask
85
86 subroutine hip_cmult(a_d, c, n, strm) &
87 bind(c, name = 'hip_cmult')
88 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
89 import c_rp
90 type(c_ptr), value :: a_d, strm
91 real(c_rp) :: c
92 integer(c_int) :: n
93 end subroutine hip_cmult
94
95 subroutine hip_cmult2(a_d, b_d, c, n, strm) &
96 bind(c, name = 'hip_cmult2')
97 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
98 import c_rp
99 type(c_ptr), value :: a_d, b_d, strm
100 real(c_rp) :: c
101 integer(c_int) :: n
102 end subroutine hip_cmult2
103
104 subroutine hip_cdiv(a_d, c, n, strm) &
105 bind(c, name = 'hip_cdiv')
106 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
107 import c_rp
108 type(c_ptr), value :: a_d, strm
109 real(c_rp) :: c
110 integer(c_int) :: n
111 end subroutine hip_cdiv
112
113 subroutine hip_cdiv2(a_d, b_d, c, n, strm) &
114 bind(c, name = 'hip_cdiv2')
115 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
116 import c_rp
117 type(c_ptr), value :: a_d, b_d, strm
118 real(c_rp) :: c
119 integer(c_int) :: n
120 end subroutine hip_cdiv2
121
122 subroutine hip_radd(a_d, c, n, strm) &
123 bind(c, name = 'hip_radd')
124 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
125 import c_rp
126 type(c_ptr), value :: a_d, strm
127 real(c_rp) :: c
128 integer(c_int) :: n
129 end subroutine hip_radd
130
131 subroutine hip_cadd2(a_d, b_d, c, n, strm) &
132 bind(c, name = 'hip_cadd2')
133 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
134 import c_rp
135 type(c_ptr), value :: a_d
136 type(c_ptr), value :: b_d
137 type(c_ptr), value :: strm
138 real(c_rp) :: c
139 integer(c_int) :: n
140 end subroutine hip_cadd2
141
142 subroutine hip_cfill(a_d, c, n, strm) &
143 bind(c, name = 'hip_cfill')
144 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
145 import c_rp
146 type(c_ptr), value :: a_d, strm
147 real(c_rp) :: c
148 integer(c_int) :: n
149 end subroutine hip_cfill
150
151 subroutine hip_rzero(a_d, n, strm) &
152 bind(c, name = 'hip_rzero')
153 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
154 type(c_ptr), value :: a_d, strm
155 integer(c_int) :: n
156 end subroutine hip_rzero
157
158 subroutine hip_add2(a_d, b_d, n, strm) &
159 bind(c, name = 'hip_add2')
160 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
161 import c_rp
162 type(c_ptr), value :: a_d, b_d, strm
163 integer(c_int) :: n
164 end subroutine hip_add2
165
166 subroutine hip_add4(a_d, b_d, c_d, d_d, n, strm) &
167 bind(c, name = 'hip_add4')
168 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
169 import c_rp
170 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
171 integer(c_int) :: n
172 end subroutine hip_add4
173
174 subroutine hip_add2s1(a_d, b_d, c1, n, strm) &
175 bind(c, name = 'hip_add2s1')
176 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
177 import c_rp
178 type(c_ptr), value :: a_d, b_d, strm
179 real(c_rp) :: c1
180 integer(c_int) :: n
181 end subroutine hip_add2s1
182
183 subroutine hip_add2s2(a_d, b_d, c1, n, strm) &
184 bind(c, name = 'hip_add2s2')
185 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
186 import c_rp
187 type(c_ptr), value :: a_d, b_d, strm
188 real(c_rp) :: c1
189 integer(c_int) :: n
190 end subroutine hip_add2s2
191
192 subroutine hip_addsqr2s2(a_d, b_d, c1, n, strm) &
193 bind(c, name = 'hip_addsqr2s2')
194 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
195 import c_rp
196 type(c_ptr), value :: a_d, b_d, strm
197 real(c_rp) :: c1
198 integer(c_int) :: n
199 end subroutine hip_addsqr2s2
200
201 subroutine hip_add3s2(a_d, b_d, c_d, c1, c2, n, strm) &
202 bind(c, name = 'hip_add3s2')
203 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
204 import c_rp
205 type(c_ptr), value :: a_d, b_d, c_d, strm
206 real(c_rp) :: c1, c2
207 integer(c_int) :: n
208 end subroutine hip_add3s2
209
210 subroutine hip_invcol1(a_d, n, strm) &
211 bind(c, name = 'hip_invcol1')
212 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
213 type(c_ptr), value :: a_d, strm
214 integer(c_int) :: n
215 end subroutine hip_invcol1
216
217 subroutine hip_invcol2(a_d, b_d, n, strm) &
218 bind(c, name = 'hip_invcol2')
219 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
220 type(c_ptr), value :: a_d, b_d, strm
221 integer(c_int) :: n
222 end subroutine hip_invcol2
223
224 subroutine hip_invcol3(a_d, b_d, c_d, n, strm) &
225 bind(c, name = 'hip_invcol3')
226 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
227 type(c_ptr), value :: a_d, b_d, c_d, strm
228 integer(c_int) :: n
229 end subroutine hip_invcol3
230
231 subroutine hip_col2(a_d, b_d, n, strm) &
232 bind(c, name = 'hip_col2')
233 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
234 type(c_ptr), value :: a_d, b_d, strm
235 integer(c_int) :: n
236 end subroutine hip_col2
237
238 subroutine hip_col3(a_d, b_d, c_d, n, strm) &
239 bind(c, name = 'hip_col3')
240 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
241 type(c_ptr), value :: a_d, b_d, c_d, strm
242 integer(c_int) :: n
243 end subroutine hip_col3
244
245 subroutine hip_subcol3(a_d, b_d, c_d, n, strm) &
246 bind(c, name = 'hip_subcol3')
247 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
248 type(c_ptr), value :: a_d, b_d, c_d, strm
249 integer(c_int) :: n
250 end subroutine hip_subcol3
251
252 subroutine hip_sub2(a_d, b_d, n, strm) &
253 bind(c, name = 'hip_sub2')
254 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
255 type(c_ptr), value :: a_d, b_d, strm
256 integer(c_int) :: n
257 end subroutine hip_sub2
258
259 subroutine hip_sub3(a_d, b_d, c_d, n, strm) &
260 bind(c, name = 'hip_sub3')
261 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
262 type(c_ptr), value :: a_d, b_d, c_d, strm
263 integer(c_int) :: n
264 end subroutine hip_sub3
265
266 subroutine hip_add3(a_d, b_d, c_d, n, strm) &
267 bind(c, name = 'hip_add3')
268 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
269 type(c_ptr), value :: a_d, b_d, c_d, strm
270 integer(c_int) :: n
271 end subroutine hip_add3
272
273 subroutine hip_addcol3(a_d, b_d, c_d, n, strm) &
274 bind(c, name = 'hip_addcol3')
275 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
276 type(c_ptr), value :: a_d, b_d, c_d, strm
277 integer(c_int) :: n
278 end subroutine hip_addcol3
279
280 subroutine hip_addcol4(a_d, b_d, c_d, d_d, n, strm) &
281 bind(c, name = 'hip_addcol4')
282 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
283 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
284 integer(c_int) :: n
285 end subroutine hip_addcol4
286
287 subroutine hip_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, n, strm) &
288 bind(c, name = 'hip_vdot3')
289 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
290 type(c_ptr), value :: dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, strm
291 integer(c_int) :: n
292 end subroutine hip_vdot3
293
294 subroutine hip_vcross(u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
295 w1_d, w2_d, w3_d, n, strm) &
296 bind(c, name = 'hip_vcross')
297 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
298
299 type(c_ptr), value :: u1_d, u2_d, u3_d
300 type(c_ptr), value :: v1_d, v2_d, v3_d
301 type(c_ptr), value :: w1_d, w2_d, w3_d
302 type(c_ptr), value :: strm
303 integer(c_int) :: n
304 end subroutine hip_vcross
305
306 real(c_rp) function hip_vlsc3(u_d, v_d, w_d, n, strm) &
307 bind(c, name = 'hip_vlsc3')
308 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
309 import c_rp
310 type(c_ptr), value :: u_d, v_d, w_d, strm
311 integer(c_int) :: n
312 end function hip_vlsc3
313
314 subroutine hip_add2s2_many(y_d, x_d_d, a_d, j, n, strm) &
315 bind(c, name = 'hip_add2s2_many')
316 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
317 import c_rp
318 type(c_ptr), value :: y_d, x_d_d, a_d, strm
319 integer(c_int) :: j, n
320 end subroutine hip_add2s2_many
321
322 real(c_rp) function hip_glsc3(a_d, b_d, c_d, n, strm) &
323 bind(c, name = 'hip_glsc3')
324 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
325 import c_rp
326 type(c_ptr), value :: a_d, b_d, c_d, strm
327 integer(c_int) :: n
328 end function hip_glsc3
329
330 subroutine hip_glsc3_many(h, w_d, v_d_d, mult_d, j, n, strm) &
331 bind(c, name = 'hip_glsc3_many')
332 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
333 import c_rp
334 type(c_ptr), value :: w_d, v_d_d, mult_d, strm
335 integer(c_int) :: j, n
336 real(c_rp) :: h(j)
337 end subroutine hip_glsc3_many
338
339 real(c_rp) function hip_glsc2(a_d, b_d, n, strm) &
340 bind(c, name = 'hip_glsc2')
341 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
342 import c_rp
343 type(c_ptr), value :: a_d, b_d, strm
344 integer(c_int) :: n
345 end function hip_glsc2
346
347 real(c_rp) function hip_glsubnorm2(a_d, b_d, n, strm) &
348 bind(c, name = 'hip_glsubnorm2')
349 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
350 import c_rp
351 type(c_ptr), value :: a_d, b_d, strm
352 integer(c_int) :: n
353 end function hip_glsubnorm2
354
355 real(c_rp) function hip_glsum(a_d, n, strm) &
356 bind(c, name = 'hip_glsum')
357 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
358 import c_rp
359 type(c_ptr), value :: a_d, strm
360 integer(c_int) :: n
361 end function hip_glsum
362
363 subroutine hip_absval(a_d, n, strm) &
364 bind(c, name = 'hip_absval')
365 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
366 import c_rp
367 type(c_ptr), value :: a_d, strm
368 integer(c_int) :: n
369 end subroutine hip_absval
370 end interface
371
372 ! ========================================================================== !
373 ! Interfaces for the pointwise operations.
374
375 interface
376 subroutine hip_pwmax_vec2(a_d, b_d, n, strm) &
377 bind(c, name = 'hip_pwmax_vec2')
378 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
379 type(c_ptr), value :: a_d, b_d, strm
380 integer(c_int) :: n
381 end subroutine hip_pwmax_vec2
382
383 subroutine hip_pwmax_vec3(a_d, b_d, c_d, n, strm) &
384 bind(c, name = 'hip_pwmax_vec3')
385 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
386 type(c_ptr), value :: a_d, b_d, c_d, strm
387 integer(c_int) :: n
388 end subroutine hip_pwmax_vec3
389
390 subroutine hip_pwmax_sca2(a_d, c_d, n, strm) &
391 bind(c, name = 'hip_pwmax_sca2')
392 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
393 import c_rp
394 type(c_ptr), value :: a_d, strm
395 real(c_rp) :: c_d
396 integer(c_int) :: n
397 end subroutine hip_pwmax_sca2
398
399 subroutine hip_pwmax_sca3(a_d, b_d, c_d, n, strm) &
400 bind(c, name = 'hip_pwmax_sca3')
401 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
402 import c_rp
403 type(c_ptr), value :: a_d, b_d, strm
404 real(c_rp) :: c_d
405 integer(c_int) :: n
406 end subroutine hip_pwmax_sca3
407
408 subroutine hip_pwmin_vec2(a_d, b_d, n, strm) &
409 bind(c, name = 'hip_pwmin_vec2')
410 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
411 type(c_ptr), value :: a_d, b_d, strm
412 integer(c_int) :: n
413 end subroutine hip_pwmin_vec2
414
415 subroutine hip_pwmin_vec3(a_d, b_d, c_d, n, strm) &
416 bind(c, name = 'hip_pwmin_vec3')
417 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
418 type(c_ptr), value :: a_d, b_d, c_d, strm
419 integer(c_int) :: n
420 end subroutine hip_pwmin_vec3
421
422 subroutine hip_pwmin_sca2(a_d, c_d, n, strm) &
423 bind(c, name = 'hip_pwmin_sca2')
424 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
425 import c_rp
426 type(c_ptr), value :: a_d, strm
427 real(c_rp) :: c_d
428 integer(c_int) :: n
429 end subroutine hip_pwmin_sca2
430
431 subroutine hip_pwmin_sca3(a_d, b_d, c_d, n, strm) &
432 bind(c, name = 'hip_pwmin_sca3')
433 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
434 import c_rp
435 type(c_ptr), value :: a_d, b_d, strm
436 real(c_rp) :: c_d
437 integer(c_int) :: n
438 end subroutine hip_pwmin_sca3
439
440 end interface
441
442 ! ========================================================================== !
443 ! Interfaces for integer operations.
444
445 interface
446
447 subroutine hip_iadd(a_d, c, n, strm) &
448 bind(c, name = 'hip_iadd')
449 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
450 import c_rp
451 type(c_ptr), value :: a_d, strm
452 integer(c_int) :: c
453 integer(c_int) :: n
454 end subroutine hip_iadd
455
456 end interface
457end module hip_math
integer, parameter, public c_rp
Definition num_types.f90:13
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12