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_add4s3(a_d, b_d, c_d, d_d, c1, c2, c3, n, strm) &
211 bind(c, name = 'hip_add4s3')
212 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
213 import c_rp
214 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
215 real(c_rp) :: c1, c2, c3
216 integer(c_int) :: n
217 end subroutine hip_add4s3
218
219 subroutine hip_add5s4(a_d, b_d, c_d, d_d, e_d, c1, c2, c3, c4, n, strm) &
220 bind(c, name = 'hip_add5s4')
221 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
222 import c_rp
223 type(c_ptr), value :: a_d, b_d, c_d, d_d, e_d, strm
224 real(c_rp) :: c1, c2, c3, c4
225 integer(c_int) :: n
226 end subroutine hip_add5s4
227
228 subroutine hip_invcol1(a_d, n, strm) &
229 bind(c, name = 'hip_invcol1')
230 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
231 type(c_ptr), value :: a_d, strm
232 integer(c_int) :: n
233 end subroutine hip_invcol1
234
235 subroutine hip_invcol2(a_d, b_d, n, strm) &
236 bind(c, name = 'hip_invcol2')
237 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
238 type(c_ptr), value :: a_d, b_d, strm
239 integer(c_int) :: n
240 end subroutine hip_invcol2
241
242 subroutine hip_invcol3(a_d, b_d, c_d, n, strm) &
243 bind(c, name = 'hip_invcol3')
244 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
245 type(c_ptr), value :: a_d, b_d, c_d, strm
246 integer(c_int) :: n
247 end subroutine hip_invcol3
248
249 subroutine hip_col2(a_d, b_d, n, strm) &
250 bind(c, name = 'hip_col2')
251 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
252 type(c_ptr), value :: a_d, b_d, strm
253 integer(c_int) :: n
254 end subroutine hip_col2
255
256 subroutine hip_col3(a_d, b_d, c_d, n, strm) &
257 bind(c, name = 'hip_col3')
258 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
259 type(c_ptr), value :: a_d, b_d, c_d, strm
260 integer(c_int) :: n
261 end subroutine hip_col3
262
263 subroutine hip_subcol3(a_d, b_d, c_d, n, strm) &
264 bind(c, name = 'hip_subcol3')
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_subcol3
269
270 subroutine hip_sub2(a_d, b_d, n, strm) &
271 bind(c, name = 'hip_sub2')
272 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
273 type(c_ptr), value :: a_d, b_d, strm
274 integer(c_int) :: n
275 end subroutine hip_sub2
276
277 subroutine hip_sub3(a_d, b_d, c_d, n, strm) &
278 bind(c, name = 'hip_sub3')
279 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
280 type(c_ptr), value :: a_d, b_d, c_d, strm
281 integer(c_int) :: n
282 end subroutine hip_sub3
283
284 subroutine hip_add3(a_d, b_d, c_d, n, strm) &
285 bind(c, name = 'hip_add3')
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_add3
290
291 subroutine hip_addcol3(a_d, b_d, c_d, n, strm) &
292 bind(c, name = 'hip_addcol3')
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_addcol3
297
298 subroutine hip_addcol4(a_d, b_d, c_d, d_d, n, strm) &
299 bind(c, name = 'hip_addcol4')
300 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
301 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
302 integer(c_int) :: n
303 end subroutine hip_addcol4
304
305 subroutine hip_addcol3s2(a_d, b_d, c_d, s, n, strm) &
306 bind(c, name = 'hip_addcol3s2')
307 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
308 import c_rp
309 type(c_ptr), value :: a_d, b_d, c_d, strm
310 real(c_rp) :: s
311 integer(c_int) :: n
312 end subroutine hip_addcol3s2
313
314 subroutine hip_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, n, strm) &
315 bind(c, name = 'hip_vdot3')
316 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
317 type(c_ptr), value :: dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, strm
318 integer(c_int) :: n
319 end subroutine hip_vdot3
320
321 subroutine hip_vcross(u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
322 w1_d, w2_d, w3_d, n, strm) &
323 bind(c, name = 'hip_vcross')
324 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
325
326 type(c_ptr), value :: u1_d, u2_d, u3_d
327 type(c_ptr), value :: v1_d, v2_d, v3_d
328 type(c_ptr), value :: w1_d, w2_d, w3_d
329 type(c_ptr), value :: strm
330 integer(c_int) :: n
331 end subroutine hip_vcross
332
333 real(c_rp) function hip_vlsc3(u_d, v_d, w_d, n, strm) &
334 bind(c, name = 'hip_vlsc3')
335 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
336 import c_rp
337 type(c_ptr), value :: u_d, v_d, w_d, strm
338 integer(c_int) :: n
339 end function hip_vlsc3
340
341 subroutine hip_add2s2_many(y_d, x_d_d, a_d, j, n, strm) &
342 bind(c, name = 'hip_add2s2_many')
343 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
344 import c_rp
345 type(c_ptr), value :: y_d, x_d_d, a_d, strm
346 integer(c_int) :: j, n
347 end subroutine hip_add2s2_many
348
349 real(c_rp) function hip_glsc3(a_d, b_d, c_d, n, strm) &
350 bind(c, name = 'hip_glsc3')
351 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
352 import c_rp
353 type(c_ptr), value :: a_d, b_d, c_d, strm
354 integer(c_int) :: n
355 end function hip_glsc3
356
357 subroutine hip_glsc3_many(h, w_d, v_d_d, mult_d, j, n, strm) &
358 bind(c, name = 'hip_glsc3_many')
359 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
360 import c_rp
361 type(c_ptr), value :: w_d, v_d_d, mult_d, strm
362 integer(c_int) :: j, n
363 real(c_rp) :: h(j)
364 end subroutine hip_glsc3_many
365
366 real(c_rp) function hip_glsc2(a_d, b_d, n, strm) &
367 bind(c, name = 'hip_glsc2')
368 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
369 import c_rp
370 type(c_ptr), value :: a_d, b_d, strm
371 integer(c_int) :: n
372 end function hip_glsc2
373
374 real(c_rp) function hip_glsubnorm2(a_d, b_d, n, strm) &
375 bind(c, name = 'hip_glsubnorm2')
376 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
377 import c_rp
378 type(c_ptr), value :: a_d, b_d, strm
379 integer(c_int) :: n
380 end function hip_glsubnorm2
381
382 real(c_rp) function hip_glsum(a_d, n, strm) &
383 bind(c, name = 'hip_glsum')
384 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
385 import c_rp
386 type(c_ptr), value :: a_d, strm
387 integer(c_int) :: n
388 end function hip_glsum
389
390 subroutine hip_absval(a_d, n, strm) &
391 bind(c, name = 'hip_absval')
392 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
393 import c_rp
394 type(c_ptr), value :: a_d, strm
395 integer(c_int) :: n
396 end subroutine hip_absval
397 end interface
398
399 ! ========================================================================== !
400 ! Interfaces for the pointwise operations.
401
402 interface
403 subroutine hip_pwmax_vec2(a_d, b_d, n, strm) &
404 bind(c, name = 'hip_pwmax_vec2')
405 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
406 type(c_ptr), value :: a_d, b_d, strm
407 integer(c_int) :: n
408 end subroutine hip_pwmax_vec2
409
410 subroutine hip_pwmax_vec3(a_d, b_d, c_d, n, strm) &
411 bind(c, name = 'hip_pwmax_vec3')
412 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
413 type(c_ptr), value :: a_d, b_d, c_d, strm
414 integer(c_int) :: n
415 end subroutine hip_pwmax_vec3
416
417 subroutine hip_pwmax_sca2(a_d, c_d, n, strm) &
418 bind(c, name = 'hip_pwmax_sca2')
419 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
420 import c_rp
421 type(c_ptr), value :: a_d, strm
422 real(c_rp) :: c_d
423 integer(c_int) :: n
424 end subroutine hip_pwmax_sca2
425
426 subroutine hip_pwmax_sca3(a_d, b_d, c_d, n, strm) &
427 bind(c, name = 'hip_pwmax_sca3')
428 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
429 import c_rp
430 type(c_ptr), value :: a_d, b_d, strm
431 real(c_rp) :: c_d
432 integer(c_int) :: n
433 end subroutine hip_pwmax_sca3
434
435 subroutine hip_pwmin_vec2(a_d, b_d, n, strm) &
436 bind(c, name = 'hip_pwmin_vec2')
437 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
438 type(c_ptr), value :: a_d, b_d, strm
439 integer(c_int) :: n
440 end subroutine hip_pwmin_vec2
441
442 subroutine hip_pwmin_vec3(a_d, b_d, c_d, n, strm) &
443 bind(c, name = 'hip_pwmin_vec3')
444 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
445 type(c_ptr), value :: a_d, b_d, c_d, strm
446 integer(c_int) :: n
447 end subroutine hip_pwmin_vec3
448
449 subroutine hip_pwmin_sca2(a_d, c_d, n, strm) &
450 bind(c, name = 'hip_pwmin_sca2')
451 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
452 import c_rp
453 type(c_ptr), value :: a_d, strm
454 real(c_rp) :: c_d
455 integer(c_int) :: n
456 end subroutine hip_pwmin_sca2
457
458 subroutine hip_pwmin_sca3(a_d, b_d, c_d, n, strm) &
459 bind(c, name = 'hip_pwmin_sca3')
460 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
461 import c_rp
462 type(c_ptr), value :: a_d, b_d, strm
463 real(c_rp) :: c_d
464 integer(c_int) :: n
465 end subroutine hip_pwmin_sca3
466
467 end interface
468
469 ! ========================================================================== !
470 ! Interfaces for integer operations.
471
472 interface
473
474 subroutine hip_iadd(a_d, c, n, strm) &
475 bind(c, name = 'hip_iadd')
476 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
477 import c_rp
478 type(c_ptr), value :: a_d, strm
479 integer(c_int) :: c
480 integer(c_int) :: n
481 end subroutine hip_iadd
482
483 end interface
484end 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