Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
field_math.f90
Go to the documentation of this file.
1! Copyright (c) 2008-2020, UCHICAGO ARGONNE, LLC.
2!
3! The UChicago Argonne, LLC as Operator of Argonne National
4! Laboratory holds copyright in the Software. The copyright holder
5! reserves all rights except those expressly granted to licensees,
6! and U.S. Government license rights.
7!
8! Redistribution and use in source and binary forms, with or without
9! modification, are permitted provided that the following conditions
10! are met:
11!
12! 1. Redistributions of source code must retain the above copyright
13! notice, this list of conditions and the disclaimer below.
14!
15! 2. Redistributions in binary form must reproduce the above copyright
16! notice, this list of conditions and the disclaimer (as noted below)
17! in the documentation and/or other materials provided with the
18! distribution.
19!
20! 3. Neither the name of ANL nor the names of its contributors
21! may be used to endorse or promote products derived from this software
22! without specific prior written permission.
23!
24! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
28! UCHICAGO ARGONNE, LLC, THE U.S. DEPARTMENT OF
29! ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30! SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31! TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33! THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34! (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36!
37! Additional BSD Notice
38! ---------------------
39! 1. This notice is required to be provided under our contract with
40! the U.S. Department of Energy (DOE). This work was produced at
41! Argonne National Laboratory under Contract
42! No. DE-AC02-06CH11357 with the DOE.
43!
44! 2. Neither the United States Government nor UCHICAGO ARGONNE,
45! LLC nor any of their employees, makes any warranty,
46! express or implied, or assumes any liability or responsibility for the
47! accuracy, completeness, or usefulness of any information, apparatus,
48! product, or process disclosed, or represents that its use would not
49! infringe privately-owned rights.
50!
51! 3. Also, reference herein to any specific commercial products, process,
52! or services by trade name, trademark, manufacturer or otherwise does
53! not necessarily constitute or imply its endorsement, recommendation,
54! or favoring by the United States Government or UCHICAGO ARGONNE LLC.
55! The views and opinions of authors expressed
56! herein do not necessarily state or reflect those of the United States
57! Government or UCHICAGO ARGONNE, LLC, and shall
58! not be used for advertising or product endorsement purposes.
59!
62 use num_types, only : rp
63 use field, only : field_t
64 use mask, only : mask_t
65 use device, only : device_get_ptr
66 use math, only : rzero, rone, copy, cmult, cadd, cfill, invcol1, vdot3, &
69 glmax, glmin, &
86 use, intrinsic :: iso_c_binding, only : c_ptr
87 implicit none
88 private
89
103
104contains
105
107 subroutine field_rzero(a, n)
108 integer, intent(in), optional :: n
109 type(field_t), intent(inout) :: a
110 integer :: size
111
112 if (present(n)) then
113 size = n
114 else
115 size = a%size()
116 end if
117
118 if (neko_bcknd_device .eq. 1) then
119 call device_rzero(a%x_d, size)
120 else
121 call rzero(a%x, size)
122 end if
123 end subroutine field_rzero
124
126 subroutine field_rone(a, n)
127 integer, intent(in), optional :: n
128 type(field_t), intent(inout) :: a
129 integer :: size
130
131 if (present(n)) then
132 size = n
133 else
134 size = a%size()
135 end if
136
137 if (neko_bcknd_device .eq. 1) then
138 call device_rone(a%x_d, size)
139 else
140 call rone(a%x, size)
141 end if
142 end subroutine field_rone
143
145 subroutine field_copy(a, b, n)
146 integer, intent(in), optional :: n
147 type(field_t), intent(in) :: b
148 type(field_t), intent(inout) :: a
149 integer :: size
150
151 if (present(n)) then
152 size = n
153 else
154 size = a%size()
155 end if
156
157 if (neko_bcknd_device .eq. 1) then
158 call device_copy(a%x_d, b%x_d, size)
159 else
160 call copy(a%x, b%x, size)
161 end if
162 end subroutine field_copy
163
165 subroutine field_cmult(a, c, n)
166 integer, intent(in), optional :: n
167 type(field_t), intent(inout) :: a
168 real(kind=rp), intent(in) :: c
169 integer :: size
170
171 if (present(n)) then
172 size = n
173 else
174 size = a%size()
175 end if
176
177 if (neko_bcknd_device .eq. 1) then
178 call device_cmult(a%x_d, c, size)
179 else
180 call cmult(a%x, c, size)
181 end if
182 end subroutine field_cmult
183
185 subroutine field_cadd(a, s, n)
186 integer, intent(in), optional :: n
187 type(field_t), intent(inout) :: a
188 real(kind=rp), intent(in) :: s
189 integer :: size
190
191 if (present(n)) then
192 size = n
193 else
194 size = a%size()
195 end if
196
197 if (neko_bcknd_device .eq. 1) then
198 call device_cadd(a%x_d, s, size)
199 else
200 call cadd(a%x, s, size)
201 end if
202 end subroutine field_cadd
203
205 subroutine field_cfill(a, c, n)
206 integer, intent(in), optional :: n
207 type(field_t), intent(inout) :: a
208 real(kind=rp), intent(in) :: c
209 integer :: size
210
211 if (present(n)) then
212 size = n
213 else
214 size = a%size()
215 end if
216
217 if (neko_bcknd_device .eq. 1) then
218 call device_cfill(a%x_d, c, size)
219 else
220 call cfill(a%x, c, size)
221 end if
222 end subroutine field_cfill
223
225 subroutine field_invcol1(a, n)
226 integer, intent(in), optional :: n
227 type(field_t), intent(inout) :: a
228 integer :: size
229
230 if (present(n)) then
231 size = n
232 else
233 size = a%size()
234 end if
235
236 if (neko_bcknd_device .eq. 1) then
237 call device_invcol1(a%x_d, size)
238 else
239 call invcol1(a%x, size)
240 end if
241
242 end subroutine field_invcol1
243
245 subroutine field_invcol3(a, b, c, n)
246 integer, intent(in), optional :: n
247 type(field_t), intent(inout) :: a
248 type(field_t), intent(in) :: b
249 type(field_t), intent(in) :: c
250 integer :: size
251
252 if (present(n)) then
253 size = n
254 else
255 size = a%size()
256 end if
257
258 if (neko_bcknd_device .eq. 1) then
259 call device_invcol3(a%x_d, b%x_d, c%x_d, size)
260 else
261 call invcol3(a%x, b%x, c%x, size)
262 end if
263
264 end subroutine field_invcol3
265
268 subroutine field_vdot3(dot, u1, u2, u3, v1, v2, v3, n)
269 integer, intent(in), optional :: n
270 type(field_t), intent(in) :: u1, u2, u3
271 type(field_t), intent(in) :: v1, v2, v3
272 type(field_t), intent(inout) :: dot
273 integer :: size
274
275 if (present(n)) then
276 size = n
277 else
278 size = dot%size()
279 end if
280
281 if (neko_bcknd_device .eq. 1) then
282 call device_vdot3(dot%x_d, &
283 u1%x_d, u2%x_d, u3%x_d, &
284 v1%x_d, v2%x_d, v3%x_d, &
285 size)
286 else
287 call vdot3(dot%x, &
288 u1%x, u2%x, u3%x, &
289 v1%x, v2%x, v3%x, &
290 size)
291 end if
292
293 end subroutine field_vdot3
294
296 subroutine field_add2(a, b, n)
297 integer, intent(in), optional :: n
298 type(field_t), intent(inout) :: a
299 type(field_t), intent(in) :: b
300 integer :: size
301
302 if (present(n)) then
303 size = n
304 else
305 size = a%size()
306 end if
307
308 if (neko_bcknd_device .eq. 1) then
309 call device_add2(a%x_d, b%x_d, size)
310 else
311 call add2(a%x, b%x, size)
312 end if
313
314 end subroutine field_add2
315
317 subroutine field_add3(a, b, c, n)
318 integer, intent(in), optional :: n
319 type(field_t), intent(inout) :: a
320 type(field_t), intent(in) :: b, c
321 integer :: size
322
323 if (present(n)) then
324 size = n
325 else
326 size = a%size()
327 end if
328
329 if (neko_bcknd_device .eq. 1) then
330 call device_add3(a%x_d, b%x_d, c%x_d, size)
331 else
332 call add3(a%x, b%x, c%x, size)
333 end if
334
335 end subroutine field_add3
336
338 subroutine field_add4(a, b, c, d, n)
339 integer, intent(in), optional :: n
340 type(field_t), intent(inout) :: a
341 type(field_t), intent(in) :: b, c, d
342 integer :: size
343
344 if (present(n)) then
345 size = n
346 else
347 size = a%size()
348 end if
349
350 if (neko_bcknd_device .eq. 1) then
351 call device_add4(a%x_d, b%x_d, c%x_d, d%x_d, size)
352 else
353 call add4(a%x, b%x, c%x, d%x, size)
354 end if
355
356 end subroutine field_add4
357
359 subroutine field_sub2(a, b, n)
360 integer, intent(in), optional :: n
361 type(field_t), intent(inout) :: a
362 type(field_t), intent(inout) :: b
363 integer :: size
364
365 if (present(n)) then
366 size = n
367 else
368 size = a%size()
369 end if
370
371 if (neko_bcknd_device .eq. 1) then
372 call device_sub2(a%x_d, b%x_d, size)
373 else
374 call sub2(a%x, b%x, size)
375 end if
376
377 end subroutine field_sub2
378
380 subroutine field_sub3(a, b, c, n)
381 integer, intent(in), optional :: n
382 type(field_t), intent(inout) :: a
383 type(field_t), intent(in) :: b
384 type(field_t), intent(in) :: c
385 integer :: size
386
387 if (present(n)) then
388 size = n
389 else
390 size = a%size()
391 end if
392
393 if (neko_bcknd_device .eq. 1) then
394 call device_sub3(a%x_d, b%x_d, c%x_d, size)
395 else
396 call sub3(a%x, b%x, c%x, size)
397 end if
398
399 end subroutine field_sub3
400
401
404 subroutine field_add2s1(a, b, c1, n)
405 integer, intent(in), optional :: n
406 type(field_t), intent(inout) :: a
407 type(field_t), intent(inout) :: b
408 real(kind=rp), intent(in) :: c1
409 integer :: size
410
411 if (present(n)) then
412 size = n
413 else
414 size = a%size()
415 end if
416
417 if (neko_bcknd_device .eq. 1) then
418 call device_add2s1(a%x_d, b%x_d, c1, size)
419 else
420 call add2s1(a%x, b%x, c1, size)
421 end if
422
423 end subroutine field_add2s1
424
427 subroutine field_add2s2(a, b, c1, n)
428 integer, intent(in), optional :: n
429 type(field_t), intent(inout) :: a
430 type(field_t), intent(inout) :: b
431 real(kind=rp), intent(in) :: c1
432 integer :: size
433
434 if (present(n)) then
435 size = n
436 else
437 size = a%size()
438 end if
439
440 if (neko_bcknd_device .eq. 1) then
441 call device_add2s2(a%x_d, b%x_d, c1, size)
442 else
443 call add2s2(a%x, b%x, c1, size)
444 end if
445
446 end subroutine field_add2s2
447
449 subroutine field_addsqr2s2(a, b, c1, n)
450 integer, intent(in), optional :: n
451 type(field_t), intent(inout) :: a
452 type(field_t), intent(in) :: b
453 real(kind=rp), intent(in) :: c1
454 integer :: size
455
456 if (present(n)) then
457 size = n
458 else
459 size = a%size()
460 end if
461
462 if (neko_bcknd_device .eq. 1) then
463 call device_addsqr2s2(a%x_d, b%x_d, c1, size)
464 else
465 call addsqr2s2(a%x, b%x, c1, size)
466 end if
467
468 end subroutine field_addsqr2s2
469
471 subroutine field_cmult2(a, b, c, n)
472 integer, intent(in), optional :: n
473 type(field_t), intent(inout) :: a
474 type(field_t), intent(in) :: b
475 real(kind=rp), intent(in) :: c
476 integer :: size
477
478 if (present(n)) then
479 size = n
480 else
481 size = a%size()
482 end if
483
484 if (neko_bcknd_device .eq. 1) then
485 call device_cmult2(a%x_d, b%x_d, c, size)
486 else
487 call cmult2(a%x, b%x, c, size)
488 end if
489
490 end subroutine field_cmult2
491
493 subroutine field_invcol2(a, b, n)
494 integer, intent(in), optional :: n
495 type(field_t), intent(inout) :: a
496 type(field_t), intent(in) :: b
497 integer :: size
498
499 if (present(n)) then
500 size = n
501 else
502 size = a%size()
503 end if
504
505 if (neko_bcknd_device .eq. 1) then
506 call device_invcol2(a%x_d, b%x_d, size)
507 else
508 call invcol2(a%x, b%x, size)
509 end if
510
511 end subroutine field_invcol2
512
513
515 subroutine field_col2(a, b, n)
516 integer, intent(in), optional :: n
517 type(field_t), intent(inout) :: a
518 type(field_t), intent(in) :: b
519 integer :: size
520
521 if (present(n)) then
522 size = n
523 else
524 size = a%size()
525 end if
526
527 if (neko_bcknd_device .eq. 1) then
528 call device_col2(a%x_d, b%x_d, size)
529 else
530 call col2(a%x, b%x, size)
531 end if
532
533 end subroutine field_col2
534
536 subroutine field_col3(a, b, c, n)
537 integer, intent(in), optional :: n
538 type(field_t), intent(inout) :: a
539 type(field_t), intent(in) :: b
540 type(field_t), intent(in) :: c
541 integer :: size
542
543 if (present(n)) then
544 size = n
545 else
546 size = a%size()
547 end if
548
549 if (neko_bcknd_device .eq. 1) then
550 call device_col3(a%x_d, b%x_d, c%x_d, size)
551 else
552 call col3(a%x, b%x, c%x, size)
553 end if
554
555 end subroutine field_col3
556
558 subroutine field_subcol3(a, b, c, n)
559 integer, intent(in), optional :: n
560 type(field_t), intent(inout) :: a
561 type(field_t), intent(in) :: b
562 type(field_t), intent(in) :: c
563 integer :: size
564
565 if (present(n)) then
566 size = n
567 else
568 size = a%size()
569 end if
570
571 if (neko_bcknd_device .eq. 1) then
572 call device_subcol3(a%x_d, b%x_d, c%x_d, size)
573 else
574 call subcol3(a%x, b%x, c%x, size)
575 end if
576
577 end subroutine field_subcol3
578
580 subroutine field_add3s2(a, b, c, c1, c2, n)
581 integer, intent(in), optional :: n
582 type(field_t), intent(inout) :: a
583 type(field_t), intent(in) :: b
584 type(field_t), intent(in) :: c
585 real(kind=rp), intent(in) :: c1, c2
586 integer :: size
587
588 if (present(n)) then
589 size = n
590 else
591 size = a%size()
592 end if
593
594 if (neko_bcknd_device .eq. 1) then
595 call device_add3s2(a%x_d, b%x_d, c%x_d, c1, c2, size)
596 else
597 call add3s2(a%x, b%x, c%x, c1, c2, size)
598 end if
599
600 end subroutine field_add3s2
601
603 subroutine field_addcol3(a, b, c, n)
604 integer, intent(in), optional :: n
605 type(field_t), intent(inout) :: a
606 type(field_t), intent(in) :: b
607 type(field_t), intent(in) :: c
608 integer :: size
609
610 if (present(n)) then
611 size = n
612 else
613 size = a%size()
614 end if
615
616 if (neko_bcknd_device .eq. 1) then
617 call device_addcol3(a%x_d, b%x_d, c%x_d, size)
618 else
619 call addcol3(a%x, b%x, c%x, size)
620 end if
621
622 end subroutine field_addcol3
623
625 subroutine field_addcol3s2(a, b, c, s, n)
626 integer, intent(in), optional :: n
627 type(field_t), intent(inout) :: a
628 type(field_t), intent(in) :: b
629 type(field_t), intent(in) :: c
630 real(kind=rp), intent(in) :: s
631 integer :: size
632
633 if (present(n)) then
634 size = n
635 else
636 size = a%size()
637 end if
638
639 if (neko_bcknd_device .eq. 1) then
640 call device_addcol3s2(a%x_d, b%x_d, c%x_d, s, size)
641 else
642 call addcol3s2(a%x, b%x, c%x, s, size)
643 end if
644
645 end subroutine field_addcol3s2
646
648 subroutine field_addcol4(a, b, c, d, n)
649 integer, intent(in), optional :: n
650 type(field_t), intent(inout) :: a
651 type(field_t), intent(in) :: b
652 type(field_t), intent(in) :: c
653 type(field_t), intent(in) :: d
654 integer :: size
655
656 if (present(n)) then
657 size = n
658 else
659 size = a%size()
660 end if
661
662 if (neko_bcknd_device .eq. 1) then
663 call device_addcol4(a%x_d, b%x_d, c%x_d, d%x_d, size)
664 else
665 call addcol4(a%x, b%x, c%x, d%x, size)
666 end if
667
668 end subroutine field_addcol4
669
670 function field_glsum(a, n) result(sum)
671 integer, intent(in), optional :: n
672 type(field_t), intent(in) :: a
673 real(kind=rp) :: sum
674 integer :: size
675
676 if (present(n)) then
677 size = n
678 else
679 size = a%size()
680 end if
681
682 if (neko_bcknd_device .eq. 1) then
683 sum = device_glsum(a%x_d, size)
684 else
685 sum = glsum(a%x, size)
686 end if
687
688 end function field_glsum
689
691 function field_glmax(a, n) result(val)
692 integer, intent(in), optional :: n
693 type(field_t), intent(in) :: a
694 real(kind=rp) :: val
695 integer :: size
696
697 if (present(n)) then
698 size = n
699 else
700 size = a%size()
701 end if
702
703 if (neko_bcknd_device .eq. 1) then
704 val = device_glmax(a%x_d, size)
705 else
706 val = glmax(a%x, size)
707 end if
708
709 end function field_glmax
710
712 function field_glmin(a, n) result(val)
713 integer, intent(in), optional :: n
714 type(field_t), intent(in) :: a
715 real(kind=rp) :: val
716 integer :: size
717
718 if (present(n)) then
719 size = n
720 else
721 size = a%size()
722 end if
723
724 if (neko_bcknd_device .eq. 1) then
725 val = device_glmin(a%x_d, size)
726 else
727 val = glmin(a%x, size)
728 end if
729
730 end function field_glmin
731
732 function field_glsc2(a, b, n) result(norm)
733 integer, intent(in), optional :: n
734 type(field_t), intent(in) :: a, b
735 real(kind=rp) :: norm
736 integer :: size
737
738 if (present(n)) then
739 size = n
740 else
741 size = a%size()
742 end if
743
744 if (neko_bcknd_device .eq. 1) then
745 norm = device_glsc2(a%x_d, b%x_d, size)
746 else
747 norm = glsc2(a%x, b%x, size)
748 end if
749
750 end function field_glsc2
751
752 function field_glsc3(a, b, c, n) result(norm)
753 integer, intent(in), optional :: n
754 type(field_t), intent(in) :: a, b, c
755 real(kind=rp) :: norm
756 integer :: size
757
758 if (present(n)) then
759 size = n
760 else
761 size = a%size()
762 end if
763
764 if (neko_bcknd_device .eq. 1) then
765 norm = device_glsc3(a%x_d, b%x_d, c%x_d, size)
766 else
767 norm = glsc3(a%x, b%x, c%x, size)
768 end if
769
770 end function field_glsc3
771
772 function field_glsubnorm(a, b, n) result(norm)
773 integer, intent(in), optional :: n
774 type(field_t), intent(in) :: a, b
775 real(kind=rp) :: norm
776 integer :: size
777
778 if (present(n)) then
779 size = n
780 else
781 size = a%size()
782 end if
783
784 if (neko_bcknd_device .eq. 1) then
785 norm = device_glsubnorm(a%x_d, b%x_d, size)
786 else
787 norm = glsubnorm(a%x, b%x, size)
788 end if
789
790 end function field_glsubnorm
791
800 subroutine field_masked_gather_copy_0(a, b, mask, n, n_mask)
801 integer, intent(in) :: n, n_mask
802 real(kind=rp), dimension(n_mask), intent(inout) :: a
803 type(field_t) :: b
804 integer, dimension(0:n_mask) :: mask
805 type(c_ptr) :: mask_d, a_d
806
807 if (neko_bcknd_device .eq. 1) then
808 mask_d = device_get_ptr(mask)
809 a_d = device_get_ptr(a)
810 call device_masked_gather_copy_0(a_d, b%x_d, mask_d, n, n_mask)
811 else
812 call masked_gather_copy_0(a, b%x, mask, n, n_mask)
813 end if
814
815 end subroutine field_masked_gather_copy_0
816
823 subroutine field_masked_gather_copy(a, b, mask, n)
824 type(field_t), intent(inout) :: a
825 real(kind=rp), dimension(:), intent(inout) :: b
826 type(mask_t), intent(in) :: mask
827 integer, intent(in) :: n
828 type(c_ptr) :: mask_d, b_d
829
830 if (neko_bcknd_device .eq. 1) then
831 mask_d = mask%get_d()
832 b_d = device_get_ptr(b)
833 call device_masked_gather_copy_aligned(a%x_d, b_d, mask_d, n, &
834 mask%size())
835 else
836 call masked_gather_copy(a%x, b, mask%get(), n, mask%size())
837 end if
838
839 end subroutine field_masked_gather_copy
840
849 subroutine field_masked_scatter_copy_0(a, b, mask, n, n_mask)
850 integer, intent(in) :: n, n_mask
851 real(kind=rp), dimension(n_mask), intent(in) :: b
852 type(field_t), intent(inout) :: a
853 integer, dimension(0:n_mask) :: mask
854 type(c_ptr) :: mask_d, b_d
855
856 if (neko_bcknd_device .eq. 1) then
857 mask_d = device_get_ptr(mask)
858 b_d = device_get_ptr(b)
859 call device_masked_scatter_copy_0(a%x_d, b_d, mask_d, n, n_mask)
860 else
861 call masked_scatter_copy_0(a%x, b, mask, n, n_mask)
862 end if
863
864 end subroutine field_masked_scatter_copy_0
865
868 subroutine field_pwmax2(a, b, n)
869 integer, intent(in), optional :: n
870 type(field_t), intent(inout) :: a
871 type(field_t), intent(in) :: b
872 integer :: size, i
873
874 if (present(n)) then
875 size = n
876 else
877 size = a%size()
878 end if
879
880 if (neko_bcknd_device .eq. 1) then
881 call device_pwmax2(a%x_d, b%x_d, size)
882 else
883 call pwmax2(a%x, b%x, size)
884 end if
885
886 end subroutine field_pwmax2
887
890 subroutine field_pwmax3(a, b, c, n)
891 integer, intent(in), optional :: n
892 type(field_t), intent(inout) :: a
893 type(field_t), intent(in) :: b
894 type(field_t), intent(in) :: c
895 integer :: size, i
896
897 if (present(n)) then
898 size = n
899 else
900 size = a%size()
901 end if
902
903 if (neko_bcknd_device .eq. 1) then
904 call device_pwmax3(a%x_d, b%x_d, c%x_d, size)
905 else
906 call pwmax3(a%x, b%x, c%x, size)
907 end if
908 end subroutine field_pwmax3
909
912 subroutine field_cpwmax2(a, b, n)
913 integer, intent(in), optional :: n
914 type(field_t), intent(inout) :: a
915 real(kind=rp), intent(in) :: b
916 integer :: size, i
917
918 if (present(n)) then
919 size = n
920 else
921 size = a%size()
922 end if
923
924 if (neko_bcknd_device .eq. 1) then
925 call device_cpwmax2(a%x_d, b, size)
926 else
927 call cpwmax2(a%x, b, size)
928 end if
929
930 end subroutine field_cpwmax2
931
934 subroutine field_cpwmax3(a, b, c, n)
935 integer, intent(in), optional :: n
936 type(field_t), intent(inout) :: a
937 type(field_t), intent(in) :: b
938 real(kind=rp), intent(in) :: c
939 integer :: size, i
940
941 if (present(n)) then
942 size = n
943 else
944 size = a%size()
945 end if
946
947 if (neko_bcknd_device .eq. 1) then
948 call device_cpwmax3(a%x_d, b%x_d, c, size)
949 else
950 call cpwmax3(a%x, b%x, c, size)
951 end if
952
953 end subroutine field_cpwmax3
954
957 subroutine field_pwmin2(a, b, n)
958 integer, intent(in), optional :: n
959 type(field_t), intent(inout) :: a
960 type(field_t), intent(in) :: b
961 integer :: size, i
962
963 if (present(n)) then
964 size = n
965 else
966 size = a%size()
967 end if
968
969 if (neko_bcknd_device .eq. 1) then
970 call device_pwmin2(a%x_d, b%x_d, size)
971 else
972 call pwmin2(a%x, b%x, size)
973 end if
974
975 end subroutine field_pwmin2
976
979 subroutine field_pwmin3(a, b, c, n)
980 integer, intent(in), optional :: n
981 type(field_t), intent(inout) :: a
982 type(field_t), intent(in) :: b
983 type(field_t), intent(in) :: c
984 integer :: size, i
985
986 if (present(n)) then
987 size = n
988 else
989 size = a%size()
990 end if
991
992 if (neko_bcknd_device .eq. 1) then
993 call device_pwmin3(a%x_d, b%x_d, c%x_d, size)
994 else
995 call pwmin3(a%x, b%x, c%x, size)
996 end if
997 end subroutine field_pwmin3
998
1001 subroutine field_cpwmin2(a, b, n)
1002 integer, intent(in), optional :: n
1003 type(field_t), intent(inout) :: a
1004 real(kind=rp), intent(in) :: b
1005 integer :: size, i
1006
1007 if (present(n)) then
1008 size = n
1009 else
1010 size = a%size()
1011 end if
1012
1013 if (neko_bcknd_device .eq. 1) then
1014 call device_cpwmin2(a%x_d, b, size)
1015 else
1016 call cpwmin2(a%x, b, size)
1017 end if
1018
1019 end subroutine field_cpwmin2
1020
1023 subroutine field_cpwmin3(a, b, c, n)
1024 integer, intent(in), optional :: n
1025 type(field_t), intent(inout) :: a
1026 type(field_t), intent(in) :: b
1027 real(kind=rp), intent(in) :: c
1028 integer :: size, i
1029
1030 if (present(n)) then
1031 size = n
1032 else
1033 size = a%size()
1034 end if
1035
1036 if (neko_bcknd_device .eq. 1) then
1037 call device_cpwmin3(a%x_d, b%x_d, c, size)
1038 else
1039 call cpwmin3(a%x, b%x, c, size)
1040 end if
1041
1042 end subroutine field_cpwmin3
1043
1044end module field_math
Return the device pointer for an associated Fortran array.
Definition device.F90:113
subroutine, public device_pwmin2(a_d, b_d, n, strm)
Compute the point-wise minimum of two vectors .
subroutine, public device_add2s1(a_d, b_d, c1, n, strm)
subroutine, public device_sub3(a_d, b_d, c_d, n, strm)
Vector subtraction .
subroutine, public device_masked_scatter_copy_0(a_d, b_d, mask_d, n, n_mask, strm)
Scatter a masked vector .
subroutine, public device_add2s2(a_d, b_d, c1, n, strm)
Vector addition with scalar multiplication (multiplication on first argument)
real(kind=rp) function, public device_glmax(a_d, n, strm)
Max of a vector of length n.
subroutine, public device_add2(a_d, b_d, n, strm)
Vector addition .
subroutine, public device_addcol3(a_d, b_d, c_d, n, strm)
Returns .
real(kind=rp) function, public device_glsum(a_d, n, strm)
Sum a vector of length n.
subroutine, public device_pwmax3(a_d, b_d, c_d, n, strm)
Compute the point-wise maximum of two vectors .
subroutine, public device_invcol1(a_d, n, strm)
Invert a vector .
subroutine, public device_add3s2(a_d, b_d, c_d, c1, c2, n, strm)
Returns .
subroutine, public device_cpwmax3(a_d, b_d, c, n, strm)
Compute the point-wise maximum of a vector and a scalar .
subroutine, public device_rzero(a_d, n, strm)
Zero a real vector.
subroutine, public device_rone(a_d, n, strm)
Set all elements to one.
subroutine, public device_cmult(a_d, c, n, strm)
Multiplication by constant c .
subroutine, public device_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, n, strm)
Compute a dot product (3-d version) assuming vector components etc.
real(kind=rp) function, public device_glsubnorm(a_d, b_d, n, strm)
Returns the norm of the difference of two vectors .
subroutine, public device_sub2(a_d, b_d, n, strm)
Vector substraction .
subroutine, public device_copy(a_d, b_d, n, strm)
Copy a vector .
subroutine, public device_invcol3(a_d, b_d, c_d, n, strm)
Vector division .
subroutine, public device_pwmin3(a_d, b_d, c_d, n, strm)
Compute the point-wise minimum of two vectors .
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
subroutine, public device_masked_gather_copy_aligned(a_d, b_d, mask_d, n, n_mask, strm)
Gather a masked vector .
subroutine, public device_add4(a_d, b_d, c_d, d_d, n, strm)
subroutine, public device_cpwmax2(a_d, c, n, strm)
Compute the point-wise maximum of a vector and a scalar .
subroutine, public device_subcol3(a_d, b_d, c_d, n, strm)
Returns .
subroutine, public device_masked_gather_copy_0(a_d, b_d, mask_d, n, n_mask, strm)
Gather a masked vector .
subroutine, public device_invcol2(a_d, b_d, n, strm)
Vector division .
subroutine, public device_addsqr2s2(a_d, b_d, c1, n, strm)
Returns .
real(kind=rp) function, public device_glsc3(a_d, b_d, c_d, n, strm)
Weighted inner product .
subroutine, public device_cpwmin3(a_d, b_d, c, n, strm)
Compute the point-wise minimum of a vector and a scalar .
real(kind=rp) function, public device_glsc2(a_d, b_d, n, strm)
Weighted inner product .
subroutine, public device_cmult2(a_d, b_d, c, n, strm)
Multiplication by constant c .
subroutine, public device_col3(a_d, b_d, c_d, n, strm)
Vector multiplication with 3 vectors .
subroutine, public device_addcol4(a_d, b_d, c_d, d_d, n, strm)
Returns .
subroutine, public device_cfill(a_d, c, n, strm)
Set all elements to a constant c .
subroutine, public device_cpwmin2(a_d, c, n, strm)
Compute the point-wise minimum of a vector and a scalar .
subroutine, public device_add3(a_d, b_d, c_d, n, strm)
Vector addition .
real(kind=rp) function, public device_glmin(a_d, n, strm)
Min of a vector of length n.
subroutine, public device_addcol3s2(a_d, b_d, c_d, s, n, strm)
Returns .
subroutine, public device_pwmax2(a_d, b_d, n, strm)
Compute the point-wise maximum of two vectors .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
subroutine, public field_cpwmax2(a, b, n)
Point-wise max operation for field and constant .
subroutine, public field_add2s1(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on first argument)
subroutine, public field_cpwmin3(a, b, c, n)
Point-wise min operation for field and constant .
subroutine, public field_invcol2(a, b, n)
Vector division .
subroutine field_add4(a, b, c, d, n)
Vector addition .
subroutine, public field_cadd(a, s, n)
Add a scalar to vector .
subroutine, public field_invcol1(a, n)
Invert a vector .
subroutine, public field_col2(a, b, n)
Vector multiplication .
subroutine, public field_sub2(a, b, n)
Vector substraction .
subroutine, public field_sub3(a, b, c, n)
Vector subtraction .
real(kind=rp) function, public field_glmin(a, n)
Global minimum of all elements in a field .
subroutine, public field_cmult2(a, b, c, n)
Multiplication by constant c .
subroutine, public field_masked_gather_copy(a, b, mask, n)
Gather a field to reduced contiguous array .
real(kind=rp) function, public field_glsc2(a, b, n)
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
subroutine, public field_add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
real(kind=rp) function, public field_glmax(a, n)
Global maximum of all elements in a field .
real(kind=rp) function, public field_glsum(a, n)
subroutine, public field_rzero(a, n)
Zero a real vector.
subroutine, public field_addcol3(a, b, c, n)
Returns .
real(kind=rp) function, public field_glsubnorm(a, b, n)
subroutine, public field_rone(a, n)
Set all elements to one.
subroutine, public field_invcol3(a, b, c, n)
Invert a vector .
subroutine, public field_add3s2(a, b, c, c1, c2, n)
Returns .
subroutine, public field_add2(a, b, n)
Vector addition .
subroutine, public field_cpwmin2(a, b, n)
Point-wise min operation for field and constant .
subroutine, public field_pwmax2(a, b, n)
Point-wise max operation .
subroutine, public field_pwmin3(a, b, c, n)
Point-wise min operation .
subroutine, public field_col3(a, b, c, n)
Vector multiplication with 3 vectors .
subroutine, public field_copy(a, b, n)
Copy a vector .
subroutine, public field_subcol3(a, b, c, n)
Returns .
subroutine, public field_add3(a, b, c, n)
Vector addition .
subroutine, public field_pwmax3(a, b, c, n)
Point-wise max operation .
subroutine, public field_addcol3s2(a, b, c, s, n)
Returns .
subroutine, public field_cpwmax3(a, b, c, n)
Point-wise max operation for field and constant .
subroutine, public field_cmult(a, c, n)
Multiplication by constant c .
real(kind=rp) function, public field_glsc3(a, b, c, n)
subroutine, public field_addcol4(a, b, c, d, n)
Returns .
subroutine, public field_addsqr2s2(a, b, c1, n)
Returns .
subroutine, public field_vdot3(dot, u1, u2, u3, v1, v2, v3, n)
Compute a dot product (3-d version) assuming vector components etc.
subroutine, public field_pwmin2(a, b, n)
Point-wise min operation .
subroutine, public field_masked_scatter_copy_0(a, b, mask, n, n_mask)
Gather a contiguous array into a field .
subroutine, public field_masked_gather_copy_0(a, b, mask, n, n_mask)
Gather a field to reduced contiguous array .
Defines a field.
Definition field.f90:34
Object for handling masks in Neko.
Definition mask.f90:34
Definition math.F90:60
subroutine, public cmult(a, c, n)
Multiplication by constant c .
Definition math.F90:518
subroutine, public cmult2(a, b, c, n)
Multiplication by constant c .
Definition math.F90:533
subroutine, public invcol2(a, b, n)
Vector division .
Definition math.F90:1079
real(kind=rp) function, public glsc3(a, b, c, n)
Weighted inner product .
Definition math.F90:1336
subroutine, public addcol3s2(a, b, c, s, n)
Returns .
Definition math.F90:1246
subroutine, public cadd(a, s, n)
Add a scalar to vector .
Definition math.F90:580
subroutine, public addsqr2s2(a, b, c1, n)
Returns .
Definition math.F90:1063
subroutine, public add2s1(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on first argument)
Definition math.F90:1030
subroutine, public cpwmin2(a, b, n)
Point-wise minimum of scalar and vector .
Definition math.F90:1797
real(kind=rp) function, public glsc2(a, b, n)
Weighted inner product .
Definition math.F90:1315
subroutine, public masked_scatter_copy_0(a, b, mask, n, n_mask)
Scatter a contigous vector to masked positions in a target array .
Definition math.F90:459
subroutine, public subcol3(a, b, c, n)
Returns .
Definition math.F90:1126
subroutine, public rone(a, n)
Set all elements to one.
Definition math.F90:291
subroutine, public cpwmin3(a, b, c, n)
Point-wise minimum of scalar and vector .
Definition math.F90:1812
subroutine, public pwmax3(a, b, c, n)
Point-wise maximum of two vectors .
Definition math.F90:1721
subroutine, public masked_gather_copy(a, b, mask, n, n_mask)
Gather a masked vector to reduced contigous vector .
Definition math.F90:434
subroutine, public add3(a, b, c, n)
Vector addition .
Definition math.F90:964
real(kind=rp) function, public glsum(a, n)
Sum a vector of length n.
Definition math.F90:643
subroutine, public sub3(a, b, c, n)
Vector subtraction .
Definition math.F90:1012
subroutine, public addcol4(a, b, c, d, n)
Returns .
Definition math.F90:1229
subroutine, public add2(a, b, n)
Vector addition .
Definition math.F90:949
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
Definition math.F90:611
subroutine, public invcol3(a, b, c, n)
Invert a vector .
Definition math.F90:834
subroutine, public add3s2(a, b, c, c1, c2, n)
Returns .
Definition math.F90:1142
subroutine, public pwmax2(a, b, n)
Point-wise maximum of two vectors .
Definition math.F90:1706
subroutine, public pwmin2(a, b, n)
Point-wise minimum of two vectors .
Definition math.F90:1767
subroutine, public masked_gather_copy_0(a, b, mask, n, n_mask)
Gather a masked vector to reduced contigous vector .
Definition math.F90:374
subroutine, public addcol3(a, b, c, n)
Returns .
Definition math.F90:1213
subroutine, public invcol1(a, n)
Invert a vector .
Definition math.F90:820
subroutine, public cpwmax3(a, b, c, n)
Point-wise maximum of scalar and vector .
Definition math.F90:1751
subroutine, public col2(a, b, n)
Vector multiplication .
Definition math.F90:1095
real(kind=rp) function, public glmax(a, n)
Max of a vector of length n.
Definition math.F90:664
subroutine, public copy(a, b, n)
Copy a vector .
Definition math.F90:305
subroutine, public add4(a, b, c, d, n)
Vector addition .
Definition math.F90:980
subroutine, public col3(a, b, c, n)
Vector multiplication with 3 vectors .
Definition math.F90:1110
subroutine, public vdot3(dot, u1, u2, u3, v1, v2, v3, n)
Compute a dot product (3-d version) assuming vector components etc.
Definition math.F90:901
subroutine, public rzero(a, n)
Zero a real vector.
Definition math.F90:249
real(kind=rp) function, public glsubnorm(a, b, n)
Returns the norm of the difference of two vectors .
Definition math.F90:1382
subroutine, public cpwmax2(a, b, n)
Point-wise maximum of scalar and vector .
Definition math.F90:1736
subroutine, public sub2(a, b, n)
Vector substraction .
Definition math.F90:997
subroutine, public pwmin3(a, b, c, n)
Point-wise minimum of two vectors .
Definition math.F90:1782
subroutine, public add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
Definition math.F90:1047
real(kind=rp) function, public glmin(a, n)
Min of a vector of length n.
Definition math.F90:722
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Type for consistently handling masks in Neko. This type encapsulates the mask array and its associate...
Definition mask.f90:51