Neko 1.99.3
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_gather_copy_aligned(a_d, b_d, mask_d, n, n_mask, &
61 strm) bind(c, name = 'hip_masked_gather_copy_aligned')
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
66
67 subroutine hip_masked_scatter_copy(a_d, b_d, mask_d, n, n_mask, strm) &
68 bind(c, name = 'hip_masked_scatter_copy')
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, n_mask
72 end subroutine hip_masked_scatter_copy
73
74 subroutine hip_masked_atomic_reduction(a_d, b_d, mask_d, n, m, strm) &
75 bind(c, name = 'hip_masked_atomic_reduction')
76 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
77 type(c_ptr), value :: a_d, b_d, mask_d, strm
78 integer(c_int) :: n, m
79 end subroutine hip_masked_atomic_reduction
80
81 subroutine hip_cfill_mask(a_d, c, n, mask_d, n_mask, strm) &
82 bind(c, name = 'hip_cfill_mask')
83 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
84 import c_rp
85 type(c_ptr), value :: a_d
86 real(c_rp) :: c
87 integer(c_int) :: n
88 type(c_ptr), value :: mask_d
89 integer(c_int) :: n_mask
90 type(c_ptr), value :: strm
91 end subroutine hip_cfill_mask
92
93 subroutine hip_cmult(a_d, c, n, strm) &
94 bind(c, name = 'hip_cmult')
95 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
96 import c_rp
97 type(c_ptr), value :: a_d, strm
98 real(c_rp) :: c
99 integer(c_int) :: n
100 end subroutine hip_cmult
101
102 subroutine hip_cmult2(a_d, b_d, c, n, strm) &
103 bind(c, name = 'hip_cmult2')
104 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
105 import c_rp
106 type(c_ptr), value :: a_d, b_d, strm
107 real(c_rp) :: c
108 integer(c_int) :: n
109 end subroutine hip_cmult2
110
111 subroutine hip_cdiv(a_d, c, n, strm) &
112 bind(c, name = 'hip_cdiv')
113 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
114 import c_rp
115 type(c_ptr), value :: a_d, strm
116 real(c_rp) :: c
117 integer(c_int) :: n
118 end subroutine hip_cdiv
119
120 subroutine hip_cdiv2(a_d, b_d, c, n, strm) &
121 bind(c, name = 'hip_cdiv2')
122 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
123 import c_rp
124 type(c_ptr), value :: a_d, b_d, strm
125 real(c_rp) :: c
126 integer(c_int) :: n
127 end subroutine hip_cdiv2
128
129 subroutine hip_radd(a_d, c, n, strm) &
130 bind(c, name = 'hip_radd')
131 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
132 import c_rp
133 type(c_ptr), value :: a_d, strm
134 real(c_rp) :: c
135 integer(c_int) :: n
136 end subroutine hip_radd
137
138 subroutine hip_cadd2(a_d, b_d, c, n, strm) &
139 bind(c, name = 'hip_cadd2')
140 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
141 import c_rp
142 type(c_ptr), value :: a_d
143 type(c_ptr), value :: b_d
144 type(c_ptr), value :: strm
145 real(c_rp) :: c
146 integer(c_int) :: n
147 end subroutine hip_cadd2
148
149 subroutine hip_cfill(a_d, c, n, strm) &
150 bind(c, name = 'hip_cfill')
151 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
152 import c_rp
153 type(c_ptr), value :: a_d, strm
154 real(c_rp) :: c
155 integer(c_int) :: n
156 end subroutine hip_cfill
157
158 subroutine hip_rzero(a_d, n, strm) &
159 bind(c, name = 'hip_rzero')
160 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
161 type(c_ptr), value :: a_d, strm
162 integer(c_int) :: n
163 end subroutine hip_rzero
164
165 subroutine hip_add2(a_d, b_d, n, strm) &
166 bind(c, name = 'hip_add2')
167 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
168 import c_rp
169 type(c_ptr), value :: a_d, b_d, strm
170 integer(c_int) :: n
171 end subroutine hip_add2
172
173 subroutine hip_add4(a_d, b_d, c_d, d_d, n, strm) &
174 bind(c, name = 'hip_add4')
175 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
176 import c_rp
177 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
178 integer(c_int) :: n
179 end subroutine hip_add4
180
181 subroutine hip_add2s1(a_d, b_d, c1, n, strm) &
182 bind(c, name = 'hip_add2s1')
183 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
184 import c_rp
185 type(c_ptr), value :: a_d, b_d, strm
186 real(c_rp) :: c1
187 integer(c_int) :: n
188 end subroutine hip_add2s1
189
190 subroutine hip_add2s2(a_d, b_d, c1, n, strm) &
191 bind(c, name = 'hip_add2s2')
192 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
193 import c_rp
194 type(c_ptr), value :: a_d, b_d, strm
195 real(c_rp) :: c1
196 integer(c_int) :: n
197 end subroutine hip_add2s2
198
199 subroutine hip_addsqr2s2(a_d, b_d, c1, n, strm) &
200 bind(c, name = 'hip_addsqr2s2')
201 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
202 import c_rp
203 type(c_ptr), value :: a_d, b_d, strm
204 real(c_rp) :: c1
205 integer(c_int) :: n
206 end subroutine hip_addsqr2s2
207
208 subroutine hip_add3s2(a_d, b_d, c_d, c1, c2, n, strm) &
209 bind(c, name = 'hip_add3s2')
210 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
211 import c_rp
212 type(c_ptr), value :: a_d, b_d, c_d, strm
213 real(c_rp) :: c1, c2
214 integer(c_int) :: n
215 end subroutine hip_add3s2
216
217 subroutine hip_add4s3(a_d, b_d, c_d, d_d, c1, c2, c3, n, strm) &
218 bind(c, name = 'hip_add4s3')
219 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
220 import c_rp
221 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
222 real(c_rp) :: c1, c2, c3
223 integer(c_int) :: n
224 end subroutine hip_add4s3
225
226 subroutine hip_add5s4(a_d, b_d, c_d, d_d, e_d, c1, c2, c3, c4, n, strm) &
227 bind(c, name = 'hip_add5s4')
228 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
229 import c_rp
230 type(c_ptr), value :: a_d, b_d, c_d, d_d, e_d, strm
231 real(c_rp) :: c1, c2, c3, c4
232 integer(c_int) :: n
233 end subroutine hip_add5s4
234
235 subroutine hip_invcol1(a_d, n, strm) &
236 bind(c, name = 'hip_invcol1')
237 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
238 type(c_ptr), value :: a_d, strm
239 integer(c_int) :: n
240 end subroutine hip_invcol1
241
242 subroutine hip_invcol2(a_d, b_d, n, strm) &
243 bind(c, name = 'hip_invcol2')
244 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
245 type(c_ptr), value :: a_d, b_d, strm
246 integer(c_int) :: n
247 end subroutine hip_invcol2
248
249 subroutine hip_invcol3(a_d, b_d, c_d, n, strm) &
250 bind(c, name = 'hip_invcol3')
251 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
252 type(c_ptr), value :: a_d, b_d, c_d, strm
253 integer(c_int) :: n
254 end subroutine hip_invcol3
255
256 subroutine hip_col2(a_d, b_d, n, strm) &
257 bind(c, name = 'hip_col2')
258 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
259 type(c_ptr), value :: a_d, b_d, strm
260 integer(c_int) :: n
261 end subroutine hip_col2
262
263 subroutine hip_col3(a_d, b_d, c_d, n, strm) &
264 bind(c, name = 'hip_col3')
265 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
266 type(c_ptr), value :: a_d, b_d, c_d, strm
267 integer(c_int) :: n
268 end subroutine hip_col3
269
270 subroutine hip_subcol3(a_d, b_d, c_d, n, strm) &
271 bind(c, name = 'hip_subcol3')
272 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
273 type(c_ptr), value :: a_d, b_d, c_d, strm
274 integer(c_int) :: n
275 end subroutine hip_subcol3
276
277 subroutine hip_sub2(a_d, b_d, n, strm) &
278 bind(c, name = 'hip_sub2')
279 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
280 type(c_ptr), value :: a_d, b_d, strm
281 integer(c_int) :: n
282 end subroutine hip_sub2
283
284 subroutine hip_sub3(a_d, b_d, c_d, n, strm) &
285 bind(c, name = 'hip_sub3')
286 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
287 type(c_ptr), value :: a_d, b_d, c_d, strm
288 integer(c_int) :: n
289 end subroutine hip_sub3
290
291 subroutine hip_add3(a_d, b_d, c_d, n, strm) &
292 bind(c, name = 'hip_add3')
293 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
294 type(c_ptr), value :: a_d, b_d, c_d, strm
295 integer(c_int) :: n
296 end subroutine hip_add3
297
298 subroutine hip_addcol3(a_d, b_d, c_d, n, strm) &
299 bind(c, name = 'hip_addcol3')
300 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
301 type(c_ptr), value :: a_d, b_d, c_d, strm
302 integer(c_int) :: n
303 end subroutine hip_addcol3
304
305 subroutine hip_addcol4(a_d, b_d, c_d, d_d, n, strm) &
306 bind(c, name = 'hip_addcol4')
307 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
308 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
309 integer(c_int) :: n
310 end subroutine hip_addcol4
311
312 subroutine hip_addcol3s2(a_d, b_d, c_d, s, n, strm) &
313 bind(c, name = 'hip_addcol3s2')
314 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
315 import c_rp
316 type(c_ptr), value :: a_d, b_d, c_d, strm
317 real(c_rp) :: s
318 integer(c_int) :: n
319 end subroutine hip_addcol3s2
320
321 subroutine hip_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, n, strm) &
322 bind(c, name = 'hip_vdot3')
323 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
324 type(c_ptr), value :: dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, strm
325 integer(c_int) :: n
326 end subroutine hip_vdot3
327
328 subroutine hip_vcross(u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
329 w1_d, w2_d, w3_d, n, strm) &
330 bind(c, name = 'hip_vcross')
331 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
332
333 type(c_ptr), value :: u1_d, u2_d, u3_d
334 type(c_ptr), value :: v1_d, v2_d, v3_d
335 type(c_ptr), value :: w1_d, w2_d, w3_d
336 type(c_ptr), value :: strm
337 integer(c_int) :: n
338 end subroutine hip_vcross
339
340 real(c_rp) function hip_vlsc3(u_d, v_d, w_d, n, strm) &
341 bind(c, name = 'hip_vlsc3')
342 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
343 import c_rp
344 type(c_ptr), value :: u_d, v_d, w_d, strm
345 integer(c_int) :: n
346 end function hip_vlsc3
347
348 subroutine hip_add2s2_many(y_d, x_d_d, a_d, j, n, strm) &
349 bind(c, name = 'hip_add2s2_many')
350 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
351 import c_rp
352 type(c_ptr), value :: y_d, x_d_d, a_d, strm
353 integer(c_int) :: j, n
354 end subroutine hip_add2s2_many
355
356 real(c_rp) function hip_glsc3(a_d, b_d, c_d, n, strm) &
357 bind(c, name = 'hip_glsc3')
358 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
359 import c_rp
360 type(c_ptr), value :: a_d, b_d, c_d, strm
361 integer(c_int) :: n
362 end function hip_glsc3
363
364 subroutine hip_glsc3_many(h, w_d, v_d_d, mult_d, j, n, strm) &
365 bind(c, name = 'hip_glsc3_many')
366 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
367 import c_rp
368 type(c_ptr), value :: w_d, v_d_d, mult_d, strm
369 integer(c_int) :: j, n
370 real(c_rp) :: h(j)
371 end subroutine hip_glsc3_many
372
373 real(c_rp) function hip_glsc2(a_d, b_d, n, strm) &
374 bind(c, name = 'hip_glsc2')
375 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
376 import c_rp
377 type(c_ptr), value :: a_d, b_d, strm
378 integer(c_int) :: n
379 end function hip_glsc2
380
381 real(c_rp) function hip_glsubnorm2(a_d, b_d, n, strm) &
382 bind(c, name = 'hip_glsubnorm2')
383 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
384 import c_rp
385 type(c_ptr), value :: a_d, b_d, strm
386 integer(c_int) :: n
387 end function hip_glsubnorm2
388
389 real(c_rp) function hip_glsum(a_d, n, strm) &
390 bind(c, name = 'hip_glsum')
391 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
392 import c_rp
393 type(c_ptr), value :: a_d, strm
394 integer(c_int) :: n
395 end function hip_glsum
396
397 real(c_rp) function hip_glmax(a_d, ninf, n, strm) &
398 bind(c, name = 'hip_glmax')
399 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
400 import c_rp
401 type(c_ptr), value :: a_d, strm
402 real(c_rp) :: ninf
403 integer(c_int) :: n
404 end function hip_glmax
405
406 real(c_rp) function hip_glmin(a_d, pinf, n, strm) &
407 bind(c, name = 'hip_glmin')
408 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
409 import c_rp
410 type(c_ptr), value :: a_d, strm
411 real(c_rp) :: pinf
412 integer(c_int) :: n
413 end function hip_glmin
414
415 subroutine hip_absval(a_d, n, strm) &
416 bind(c, name = 'hip_absval')
417 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
418 import c_rp
419 type(c_ptr), value :: a_d, strm
420 integer(c_int) :: n
421 end subroutine hip_absval
422 end interface
423
424 ! ========================================================================== !
425 ! Interfaces for the pointwise operations.
426
427 interface
428 subroutine hip_pwmax_vec2(a_d, b_d, n, strm) &
429 bind(c, name = 'hip_pwmax_vec2')
430 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
431 type(c_ptr), value :: a_d, b_d, strm
432 integer(c_int) :: n
433 end subroutine hip_pwmax_vec2
434
435 subroutine hip_pwmax_vec3(a_d, b_d, c_d, n, strm) &
436 bind(c, name = 'hip_pwmax_vec3')
437 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
438 type(c_ptr), value :: a_d, b_d, c_d, strm
439 integer(c_int) :: n
440 end subroutine hip_pwmax_vec3
441
442 subroutine hip_pwmax_sca2(a_d, c_d, n, strm) &
443 bind(c, name = 'hip_pwmax_sca2')
444 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
445 import c_rp
446 type(c_ptr), value :: a_d, strm
447 real(c_rp) :: c_d
448 integer(c_int) :: n
449 end subroutine hip_pwmax_sca2
450
451 subroutine hip_pwmax_sca3(a_d, b_d, c_d, n, strm) &
452 bind(c, name = 'hip_pwmax_sca3')
453 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
454 import c_rp
455 type(c_ptr), value :: a_d, b_d, strm
456 real(c_rp) :: c_d
457 integer(c_int) :: n
458 end subroutine hip_pwmax_sca3
459
460 subroutine hip_pwmin_vec2(a_d, b_d, n, strm) &
461 bind(c, name = 'hip_pwmin_vec2')
462 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
463 type(c_ptr), value :: a_d, b_d, strm
464 integer(c_int) :: n
465 end subroutine hip_pwmin_vec2
466
467 subroutine hip_pwmin_vec3(a_d, b_d, c_d, n, strm) &
468 bind(c, name = 'hip_pwmin_vec3')
469 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
470 type(c_ptr), value :: a_d, b_d, c_d, strm
471 integer(c_int) :: n
472 end subroutine hip_pwmin_vec3
473
474 subroutine hip_pwmin_sca2(a_d, c_d, n, strm) &
475 bind(c, name = 'hip_pwmin_sca2')
476 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
477 import c_rp
478 type(c_ptr), value :: a_d, strm
479 real(c_rp) :: c_d
480 integer(c_int) :: n
481 end subroutine hip_pwmin_sca2
482
483 subroutine hip_pwmin_sca3(a_d, b_d, c_d, n, strm) &
484 bind(c, name = 'hip_pwmin_sca3')
485 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
486 import c_rp
487 type(c_ptr), value :: a_d, b_d, strm
488 real(c_rp) :: c_d
489 integer(c_int) :: n
490 end subroutine hip_pwmin_sca3
491
492 end interface
493
494 ! ========================================================================== !
495 ! Interfaces for integer operations.
496
497 interface
498
499 subroutine hip_iadd(a_d, c, n, strm) &
500 bind(c, name = 'hip_iadd')
501 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
502 import c_rp
503 type(c_ptr), value :: a_d, strm
504 integer(c_int) :: c
505 integer(c_int) :: n
506 end subroutine hip_iadd
507
508 end interface
509end 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