63 use mpi_f08,
only : mpi_min, mpi_max, mpi_sum, mpi_in_place, mpi_integer, &
70 real(kind=
rp),
public,
parameter ::
neko_eps = epsilon(1.0_rp)
78 real(kind=
rp),
public,
parameter ::
pi = 4._rp*atan(1._rp)
83 module procedure qabscmp
106 module procedure qrelcmp
113 vcross,
vdot2,
vdot3,
vlsc3,
vlsc2,
add2,
add3,
add4,
sub2,
sub3, &
130 real(kind=
sp),
intent(in) :: x
131 real(kind=
sp),
intent(in) :: y
132 real(kind=
sp),
intent(in),
optional :: tol
135 if (
present(tol))
then
145 real(kind=
dp),
intent(in) :: x
146 real(kind=
dp),
intent(in) :: y
147 real(kind=
dp),
intent(in),
optional :: tol
150 if (
present(tol))
then
160 pure function qabscmp(x, y, tol)
161 real(kind=
qp),
intent(in) :: x
162 real(kind=
qp),
intent(in) :: y
163 real(kind=
qp),
intent(in),
optional :: tol
166 if (
present(tol))
then
167 qabscmp = abs(x - y) .lt. tol
178 real(kind=
sp),
intent(in) :: x
179 real(kind=
sp),
intent(in) :: y
180 real(kind=
sp),
intent(in),
optional :: eps
182 if (
present(eps))
then
183 srelcmp = abs(x - y) .le. eps*abs(y)
193 real(kind=
dp),
intent(in) :: x
194 real(kind=
dp),
intent(in) :: y
195 real(kind=
dp),
intent(in),
optional :: eps
197 if (
present(eps))
then
198 drelcmp = abs(x - y) .le. eps*abs(y)
208 pure function qrelcmp(x, y, eps)
209 real(kind=
qp),
intent(in) :: x
210 real(kind=
qp),
intent(in) :: y
211 real(kind=
qp),
intent(in),
optional :: eps
213 if (
present(eps))
then
214 qrelcmp = abs(x - y)/abs(y) .lt. eps
216 qrelcmp = abs(x - y)/abs(y) .lt.
neko_eps
228 real(kind=
rp),
intent(in) :: x
229 integer,
intent(in) :: niter
234 if (x == 0.0_rp)
then
239 a = 1.0_rp / (1.0_rp + 0.5_rp * log(1.0_rp + x))
240 w = log(1.0_rp + a * x)
242 do k = 1,
max(niter, 0)
243 w = w / (1.0_rp + w) * (1.0_rp + log(x / w))
249 integer,
intent(in) :: n
250 real(kind=
rp),
dimension(n),
intent(inout) :: a
263 integer,
intent(in) :: n
264 integer,
dimension(n),
intent(inout) :: a
277 integer,
intent(in) :: m, n, e
278 real(kind=
rp),
intent(inout) :: a(m,n)
291 integer,
intent(in) :: n
292 real(kind=
rp),
dimension(n),
intent(inout) :: a
305 integer,
intent(in) :: n
306 real(kind=
rp),
dimension(n),
intent(in) :: b
307 real(kind=
rp),
dimension(n),
intent(inout) :: a
326 integer,
intent(in) :: n, n_mask
327 real(kind=
rp),
dimension(n),
intent(in) :: b
328 real(kind=
rp),
dimension(n),
intent(inout) :: a
329 integer,
dimension(0:n_mask) ::
mask
349 integer,
intent(in) :: n, n_mask
350 real(kind=
rp),
dimension(n),
intent(in) :: b
351 real(kind=
rp),
dimension(n),
intent(inout) :: a
352 integer,
dimension(n_mask) ::
mask
374 integer,
intent(in) :: n, n_mask
375 real(kind=
rp),
dimension(n),
intent(in) :: b
376 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
377 integer,
dimension(0:n_mask) ::
mask
399 integer,
intent(in) :: lx, ly, lz, n_mask
400 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
401 real(kind=
rp),
dimension(:, :, :, :),
intent(in) :: b
402 integer,
dimension(0:n_mask),
intent(in) ::
mask
403 integer,
dimension(0:n_mask),
intent(in) :: facet
411 select case (facet(l))
413 a(l) = b(idx(2), idx(3), facet(l), idx(4))
415 a(l) = b(idx(1), idx(3), facet(l), idx(4))
417 a(l) = b(idx(1), idx(2), facet(l), idx(4))
434 integer,
intent(in) :: n, n_mask
435 real(kind=
rp),
dimension(n),
intent(in) :: b
436 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
437 integer,
dimension(n_mask) ::
mask
459 integer,
intent(in) :: n, n_mask
460 real(kind=
rp),
dimension(n_mask),
intent(in) :: b
461 real(kind=
rp),
dimension(n),
intent(inout) :: a
462 integer,
dimension(0:n_mask) ::
mask
484 integer,
intent(in) :: n, n_mask
485 real(kind=
rp),
dimension(n_mask),
intent(in) :: b
486 real(kind=
rp),
dimension(n),
intent(inout) :: a
487 integer,
dimension(n_mask) ::
mask
502 integer,
intent(in) :: n, n_mask
503 real(kind=
rp),
dimension(n),
intent(inout) :: a
504 real(kind=
rp),
intent(in) :: c
505 integer,
dimension(n_mask),
intent(in) ::
mask
518 integer,
intent(in) :: n
519 real(kind=
rp),
dimension(n),
intent(inout) :: a
520 real(kind=
rp),
intent(in) :: c
533 integer,
intent(in) :: n
534 real(kind=
rp),
dimension(n),
intent(inout) :: a
535 real(kind=
rp),
dimension(n),
intent(in) :: b
536 real(kind=
rp),
intent(in) :: c
549 integer,
intent(in) :: n
550 real(kind=
rp),
dimension(n),
intent(inout) :: a
551 real(kind=
rp),
intent(in) :: c
564 integer,
intent(in) :: n
565 real(kind=
rp),
dimension(n),
intent(inout) :: a
566 real(kind=
rp),
dimension(n),
intent(in) :: b
567 real(kind=
rp),
intent(in) :: c
580 integer,
intent(in) :: n
581 real(kind=
rp),
dimension(n),
intent(inout) :: a
582 real(kind=
rp),
intent(in) :: s
595 integer,
intent(in) :: n
596 real(kind=
rp),
dimension(n),
intent(inout) :: a
597 real(kind=
rp),
dimension(n),
intent(in) :: b
598 real(kind=
rp),
intent(in) :: s
611 integer,
intent(in) :: n
612 real(kind=
rp),
dimension(n),
intent(inout) :: a
613 real(kind=
rp),
intent(in) :: c
625 subroutine cwrap(a, min_val, max_val, n)
626 integer,
intent(in) :: n
627 real(kind=
rp),
dimension(n),
intent(inout) :: a
628 real(kind=
rp),
intent(in) :: min_val, max_val
631 if (n .lt. 1 .or. max_val .le. min_val)
return
635 a(i) = modulo(a(i) - min_val, max_val - min_val) + min_val
643 integer,
intent(in) :: n
644 real(kind=
rp),
dimension(n) :: a
656 call mpi_allreduce(mpi_in_place, tmp, 1, &
664 integer,
intent(in) :: n
665 real(kind=
rp),
dimension(n) :: a
676 call mpi_allreduce(tmp,
glmax, 1, &
684 integer,
intent(in) :: n
685 real(kind=
rp),
dimension(n) :: a
692 tmp =
max(tmp, abs(a(i)))
696 call mpi_allreduce(tmp,
glamax, 1, &
703 integer,
intent(in) :: n
704 integer,
dimension(n) :: a
715 call mpi_allreduce(tmp,
glimax, 1, &
722 integer,
intent(in) :: n
723 real(kind=
rp),
dimension(n) :: a
734 call mpi_allreduce(tmp,
glmin, 1, &
741 integer,
intent(in) :: n
742 integer,
dimension(n) :: a
753 call mpi_allreduce(tmp,
glimin, 1, &
760 integer,
intent(in) :: n
761 real(kind=
rp),
dimension(n),
intent(inout) :: a
775 real(kind=
rp),
intent(in) :: vec(n)
776 real(kind=
rp) :: tamax
781 tamax =
max(tamax, abs(vec(i)))
790 real(kind=
rp),
intent(in) :: vec(n)
791 real(kind=
rp) :: tmax
796 tmax =
max(tmax, vec(i))
804 integer,
intent(in) :: n
805 real(kind=
rp),
intent(in) :: vec(n)
806 real(kind=
rp) :: tmin
812 tmin = min(tmin, vec(i))
820 integer,
intent(in) :: n
821 real(kind=
rp),
dimension(n),
intent(inout) :: a
826 a(i) = 1.0_xp /
real(a(i),
xp)
834 integer,
intent(in) :: n
835 real(kind=
rp),
dimension(n),
intent(inout) :: a
836 real(kind=
rp),
dimension(n),
intent(in) :: b, c
841 a(i) =
real(b(i),
xp) / c(i)
849 integer,
intent(in) :: n
850 real(kind=
rp),
dimension(n),
intent(inout) :: a
851 real(kind=
rp),
dimension(n),
intent(in) :: b
856 a(i) = 1.0_xp /
real(b(i),
xp)
864 subroutine vcross(u1, u2, u3, v1, v2, v3, w1, w2, w3, n)
865 integer,
intent(in) :: n
866 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2, v3
867 real(kind=
rp),
dimension(n),
intent(in) :: w1, w2, w3
868 real(kind=
rp),
dimension(n),
intent(out) :: u1, u2, u3
873 u1(i) = v2(i)*w3(i) - v3(i)*w2(i)
874 u2(i) = v3(i)*w1(i) - v1(i)*w3(i)
875 u3(i) = v1(i)*w2(i) - v2(i)*w1(i)
883 subroutine vdot2(dot, u1, u2, v1, v2, n)
884 integer,
intent(in) :: n
885 real(kind=
rp),
dimension(n),
intent(in) :: u1, u2
886 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2
887 real(kind=
rp),
dimension(n),
intent(out) :: dot
892 dot(i) = u1(i)*v1(i) + u2(i)*v2(i)
900 subroutine vdot3(dot, u1, u2, u3, v1, v2, v3, n)
901 integer,
intent(in) :: n
902 real(kind=
rp),
dimension(n),
intent(in) :: u1, u2, u3
903 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2, v3
904 real(kind=
rp),
dimension(n),
intent(out) :: dot
909 dot(i) = u1(i)*v1(i) + u2(i)*v2(i) + u3(i)*v3(i)
916 function vlsc3(u, v, w, n)
result(s)
917 integer,
intent(in) :: n
918 real(kind=
rp),
dimension(n),
intent(in) :: u, v, w
925 s = s + u(i)*v(i)*w(i)
933 integer,
intent(in) :: n
934 real(kind=
rp),
dimension(n),
intent(in) :: u, v
949 integer,
intent(in) :: n
950 real(kind=
rp),
dimension(n),
intent(inout) :: a
951 real(kind=
rp),
dimension(n),
intent(in) :: b
964 integer,
intent(in) :: n
965 real(kind=
rp),
dimension(n),
intent(inout) :: a
966 real(kind=
rp),
dimension(n),
intent(in) :: b
967 real(kind=
rp),
dimension(n),
intent(in) :: c
980 integer,
intent(in) :: n
981 real(kind=
rp),
dimension(n),
intent(out) :: a
982 real(kind=
rp),
dimension(n),
intent(in) :: d
983 real(kind=
rp),
dimension(n),
intent(in) :: c
984 real(kind=
rp),
dimension(n),
intent(in) :: b
989 a(i) = b(i) + c(i) + d(i)
997 integer,
intent(in) :: n
998 real(kind=
rp),
dimension(n),
intent(inout) :: a
999 real(kind=
rp),
dimension(n),
intent(in) :: b
1012 integer,
intent(in) :: n
1013 real(kind=
rp),
dimension(n),
intent(inout) :: a
1014 real(kind=
rp),
dimension(n),
intent(in) :: b
1015 real(kind=
rp),
dimension(n),
intent(in) :: c
1030 integer,
intent(in) :: n
1031 real(kind=
rp),
dimension(n),
intent(inout) :: a
1032 real(kind=
rp),
dimension(n),
intent(in) :: b
1033 real(kind=
rp),
intent(in) :: c1
1038 a(i) = c1 * a(i) + b(i)
1047 integer,
intent(in) :: n
1048 real(kind=
rp),
dimension(n),
intent(inout) :: a
1049 real(kind=
rp),
dimension(n),
intent(in) :: b
1050 real(kind=
rp),
intent(in) :: c1
1055 a(i) = a(i) + c1 * b(i)
1063 integer,
intent(in) :: n
1064 real(kind=
rp),
dimension(n),
intent(inout) :: a
1065 real(kind=
rp),
dimension(n),
intent(in) :: b
1066 real(kind=
rp),
intent(in) :: c1
1071 a(i) = a(i) + c1 * ( b(i) * b(i) )
1079 integer,
intent(in) :: n
1080 real(kind=
rp),
dimension(n),
intent(inout) :: a
1081 real(kind=
rp),
dimension(n),
intent(in) :: b
1086 a(i) =
real(a(i),
xp) / b(i)
1095 integer,
intent(in) :: n
1096 real(kind=
rp),
dimension(n),
intent(inout) :: a
1097 real(kind=
rp),
dimension(n),
intent(in) :: b
1110 integer,
intent(in) :: n
1111 real(kind=
rp),
dimension(n),
intent(inout) :: a
1112 real(kind=
rp),
dimension(n),
intent(in) :: b
1113 real(kind=
rp),
dimension(n),
intent(in) :: c
1126 integer,
intent(in) :: n
1127 real(kind=
rp),
dimension(n),
intent(inout) :: a
1128 real(kind=
rp),
dimension(n),
intent(in) :: b
1129 real(kind=
rp),
dimension(n),
intent(in) :: c
1134 a(i) = a(i) - b(i) * c(i)
1142 integer,
intent(in) :: n
1143 real(kind=
rp),
dimension(n),
intent(inout) :: a
1144 real(kind=
rp),
dimension(n),
intent(in) :: b
1145 real(kind=
rp),
dimension(n),
intent(in) :: c
1146 real(kind=
rp),
intent(in) :: c1, c2
1151 a(i) = c1 * b(i) + c2 * c(i)
1159 integer,
intent(in) :: n
1160 real(kind=
rp),
dimension(n),
intent(inout) :: a
1161 real(kind=
rp),
dimension(n),
intent(in) :: b
1162 real(kind=
rp),
dimension(n),
intent(in) :: c
1163 real(kind=
rp),
dimension(n),
intent(in) :: d
1164 real(kind=
rp),
intent(in) :: c1, c2, c3
1169 a(i) = c1 * b(i) + c2 * c(i) + c3 * d(i)
1176 subroutine add5s4(a, b, c, d, e, c1, c2, c3, c4, n)
1177 integer,
intent(in) :: n
1178 real(kind=
rp),
dimension(n),
intent(inout) :: a
1179 real(kind=
rp),
dimension(n),
intent(in) :: b
1180 real(kind=
rp),
dimension(n),
intent(in) :: c
1181 real(kind=
rp),
dimension(n),
intent(in) :: d
1182 real(kind=
rp),
dimension(n),
intent(in) :: e
1183 real(kind=
rp),
intent(in) :: c1, c2, c3, c4
1188 a(i) = a(i) + c1 * b(i) + c2 * c(i) + c3 * d(i) + c4 * e(i)
1196 integer,
intent(in) :: n
1197 real(kind=
rp),
dimension(n),
intent(inout) :: a
1198 real(kind=
rp),
dimension(n),
intent(in) :: b
1199 real(kind=
rp),
dimension(n),
intent(in) :: c
1200 real(kind=
rp),
dimension(n),
intent(in) :: d
1205 a(i) = a(i) - b(i) * c(i) * d(i)
1213 integer,
intent(in) :: n
1214 real(kind=
rp),
dimension(n),
intent(inout) :: a
1215 real(kind=
rp),
dimension(n),
intent(in) :: b
1216 real(kind=
rp),
dimension(n),
intent(in) :: c
1221 a(i) = a(i) + b(i) * c(i)
1229 integer,
intent(in) :: n
1230 real(kind=
rp),
dimension(n),
intent(inout) :: a
1231 real(kind=
rp),
dimension(n),
intent(in) :: b
1232 real(kind=
rp),
dimension(n),
intent(in) :: c
1233 real(kind=
rp),
dimension(n),
intent(in) :: d
1238 a(i) = a(i) + b(i) * c(i) * d(i)
1246 integer,
intent(in) :: n
1247 real(kind=
rp),
dimension(n),
intent(inout) :: a
1248 real(kind=
rp),
dimension(n),
intent(in) :: b
1249 real(kind=
rp),
dimension(n),
intent(in) :: c
1250 real(kind=
rp),
intent(in) :: s
1255 a(i) = a(i) + s * b(i) * c(i)
1263 integer,
intent(in) :: n
1264 real(kind=
rp),
dimension(n),
intent(inout) :: a
1265 real(kind=
rp),
dimension(n),
intent(in) :: b
1266 real(kind=
rp),
dimension(n),
intent(in) :: c
1267 real(kind=
rp),
dimension(n),
intent(in) :: d
1268 real(kind=
rp),
dimension(n),
intent(in) :: e
1273 a(i) = b(i)*c(i) - d(i)*e(i)
1281 integer,
intent(in) :: n
1282 real(kind=
rp),
dimension(n),
intent(inout) :: a
1283 real(kind=
rp),
dimension(n),
intent(in) :: b
1284 real(kind=
rp),
dimension(n),
intent(in) :: c
1285 real(kind=
rp),
intent(in) :: c1, c2
1290 a(i) = b(i) + c1*(a(i)-c2*c(i))
1298 integer,
intent(in) :: n
1299 real(kind=
rp),
dimension(n),
intent(inout) :: a
1300 real(kind=
rp),
dimension(n),
intent(in) :: b
1301 real(kind=
rp),
dimension(n),
intent(in) :: c
1302 real(kind=
rp),
intent(in) :: c1, c2
1307 a(i) = a(i) + c1*b(i)+c2*c(i)
1315 integer,
intent(in) :: n
1316 real(kind=
rp),
dimension(n),
intent(in) :: a
1317 real(kind=
rp),
dimension(n),
intent(in) :: b
1319 real(kind=
xp) :: tmp
1325 tmp = tmp + a(i) * b(i)
1329 call mpi_allreduce(mpi_in_place, tmp, 1, &
1336 integer,
intent(in) :: n
1337 real(kind=
rp),
dimension(n),
intent(in) :: a
1338 real(kind=
rp),
dimension(n),
intent(in) :: b
1339 real(kind=
rp),
dimension(n),
intent(in) :: c
1341 real(kind=
xp) :: tmp
1347 tmp = tmp + a(i) * b(i) * c(i)
1351 call mpi_allreduce(mpi_in_place, tmp, 1, &
1357 integer,
intent(in) :: n
1358 real(kind=
rp),
dimension(n),
intent(in) :: a
1359 real(kind=
rp),
dimension(n),
intent(in) :: b
1360 real(kind=
rp),
dimension(n),
intent(in) :: c
1361 real(kind=
rp),
dimension(n),
intent(in) :: d
1363 real(kind=
xp) :: tmp
1369 tmp = tmp + a(i) * b(i) * c(i) * d(i)
1373 call mpi_allreduce(mpi_in_place, tmp, 1, &
1382 integer,
intent(in) :: n
1383 real(kind=
rp),
dimension(n),
intent(in) :: a
1384 real(kind=
rp),
dimension(n),
intent(in) :: b
1386 real(kind=
xp) :: tmp
1392 tmp = tmp + (a(i) - b(i))**2
1396 call mpi_allreduce(mpi_in_place, tmp, 1, &
1408 integer,
intent(in) :: n
1409 real(kind=
rp),
intent(inout) :: a(n)
1410 integer,
intent(out) :: ind(n)
1412 integer :: j, ir, i, ii, l
1418 if (n .le. 1)
return
1442 do while (j .le. ir)
1444 if ( a(j) .lt. a(j+1) ) j = j + 1
1446 if (aa .lt. a(j))
then
1466 integer,
intent(in) :: n
1467 integer(i4),
intent(inout) :: a(n)
1468 integer,
intent(out) :: ind(n)
1470 integer :: j, ir, i, ii, l
1476 if (n .le. 1)
return
1499 do while (j .le. ir)
1501 if ( a(j) .lt. a(j + 1) ) j = j + 1
1503 if (aa .lt. a(j))
then
1522 integer,
intent(in) :: n
1523 real(kind=
rp),
intent(inout) :: b(n)
1524 integer,
intent(in) :: ind(n)
1525 real(kind=
rp) :: temp(n)
1549 integer,
intent(in) :: n
1550 integer(i4),
intent(inout) :: b(n)
1551 integer,
intent(in) :: ind(n)
1552 integer(i4) :: temp(n)
1576 integer,
intent(in) :: n
1577 real(kind=
rp),
intent(inout) :: b(n)
1578 integer,
intent(in) :: ind(n)
1579 real(kind=
rp) :: temp(n)
1603 integer,
intent(in) :: n
1604 integer(i4),
intent(inout) :: b(n)
1605 integer,
intent(in) :: ind(n)
1606 integer(i4) :: temp(n)
1630 integer,
intent(in) :: n
1631 real(kind=
rp),
intent(inout) :: b(n)
1632 integer,
intent(inout) :: ind(n)
1633 real(kind=
rp) :: temp(n)
1634 integer :: tempind(n)
1642 tempind(jj) = ind(i)
1660 integer,
intent(in) :: n
1661 integer(i4),
intent(inout) :: b(n)
1662 integer,
intent(inout) :: ind(n)
1663 integer(i4) :: temp(n)
1664 integer :: tempind(n)
1672 tempind(jj) = ind(i)
1689 integer,
intent(in) :: n
1690 real(kind=
rp),
dimension(n),
intent(inout) :: a
1706 integer,
intent(in) :: n
1707 real(kind=
rp),
dimension(n),
intent(inout) :: a
1708 real(kind=
rp),
dimension(n),
intent(in) :: b
1713 a(i) =
max(a(i), b(i))
1721 integer,
intent(in) :: n
1722 real(kind=
rp),
dimension(n),
intent(inout) :: a
1723 real(kind=
rp),
dimension(n),
intent(in) :: b, c
1728 a(i) =
max(b(i), c(i))
1736 integer,
intent(in) :: n
1737 real(kind=
rp),
dimension(n),
intent(inout) :: a
1738 real(kind=
rp),
intent(in) :: b
1751 integer,
intent(in) :: n
1752 real(kind=
rp),
dimension(n),
intent(inout) :: a
1753 real(kind=
rp),
dimension(n),
intent(in) :: b
1754 real(kind=
rp),
intent(in) :: c
1767 integer,
intent(in) :: n
1768 real(kind=
rp),
dimension(n),
intent(inout) :: a
1769 real(kind=
rp),
dimension(n),
intent(in) :: b
1774 a(i) = min(a(i), b(i))
1782 integer,
intent(in) :: n
1783 real(kind=
rp),
dimension(n),
intent(inout) :: a
1784 real(kind=
rp),
dimension(n),
intent(in) :: b, c
1789 a(i) = min(b(i), c(i))
1797 integer,
intent(in) :: n
1798 real(kind=
rp),
dimension(n),
intent(inout) :: a
1799 real(kind=
rp),
intent(in) :: b
1812 integer,
intent(in) :: n
1813 real(kind=
rp),
dimension(n),
intent(inout) :: a
1814 real(kind=
rp),
dimension(n),
intent(in) :: b
1815 real(kind=
rp),
intent(in) :: c
1829 function matinv39(a11, a12, a13, a21, a22, a23, a31, a32, a33) &
1831 real(kind=
rp),
intent(in) :: a11, a12, a13, a21, a22, a23, a31, a32, a33
1852 real(kind=
xp),
intent(in) :: a(3,3)
1853 real(kind=
xp) :: b(3,3)
1854 real(kind=
xp) :: detinv
1858 detinv = 1.0_xp /
real(a(1,1)*a(2,2)*a(3,3) - a(1,1)*a(2,3)*a(3,2) &
1859 - a(1,2)*a(2,1)*a(3,3) + a(1,2)*a(2,3)*a(3,1)&
1860 + a(1,3)*a(2,1)*a(3,2) - a(1,3)*a(2,2)*a(3,1),
xp)
1863 b(1,1) = +detinv * (a(2,2)*a(3,3) - a(2,3)*a(3,2))
1864 b(2,1) = -detinv * (a(2,1)*a(3,3) - a(2,3)*a(3,1))
1865 b(3,1) = +detinv * (a(2,1)*a(3,2) - a(2,2)*a(3,1))
1866 b(1,2) = -detinv * (a(1,2)*a(3,3) - a(1,3)*a(3,2))
1867 b(2,2) = +detinv * (a(1,1)*a(3,3) - a(1,3)*a(3,1))
1868 b(3,2) = -detinv * (a(1,1)*a(3,2) - a(1,2)*a(3,1))
1869 b(1,3) = +detinv * (a(1,2)*a(2,3) - a(1,3)*a(2,2))
1870 b(2,3) = -detinv * (a(1,1)*a(2,3) - a(1,3)*a(2,1))
1871 b(3,3) = +detinv * (a(1,1)*a(2,2) - a(1,2)*a(2,1))
1877 real(kind=
rp),
intent(in) :: x
1878 real(kind=
rp) :: val
1879 real(kind=
rp),
parameter :: xdmin = 0.0001_rp
1880 real(kind=
rp),
parameter :: xdmax = 0.9999_rp
1883 if (x <= xdmin)
then
1886 else if (x >= xdmax)
then
1891 g = (1.0_rp / (x - 1.0_rp)) + (1.0_rp / x)
1894 val = 1.0_rp / (1.0_rp + exp(g))
1900 real(kind=
rp),
intent(in) :: x
1901 real(kind=
rp) :: val
1902 real(kind=
rp),
parameter :: xdmin = 0.0001_rp
1903 real(kind=
rp),
parameter :: xdmax = 0.9999_rp
1904 real(kind=
rp) :: arg, g, dg, s_val
1906 if (x <= xdmin .or. x >= xdmax)
then
1913 g = (1.0_rp / (x - 1.0_rp)) + (1.0_rp / x)
1916 dg = -(1.0_rp / ((x - 1.0_rp)**2)) - (1.0_rp / (x**2))
1919 s_val = 1.0_rp / (1.0_rp + exp(g))
1921 val = -s_val * (1.0_rp - s_val) * dg
1927 integer,
intent(in) :: n
1928 real(kind=
rp),
dimension(n),
intent(inout) :: a
1941 integer,
intent(in) :: n
1942 real(kind=
rp),
dimension(n),
intent(inout) :: ap
1943 real(kind=
rp),
dimension(n),
intent(in) :: a
1944 real(kind=
rp),
intent(in) :: p
1953 end subroutine power
1962 real(kind=
dp),
intent(in) :: a11, a22, a12
1963 real(kind=
dp),
intent(out) :: e1, e2
1964 real(kind=
dp) :: t, d, s
1967 d = a11 * a22 - a12 * a12
1968 s = sqrt(
max(0.0_dp, 0.25_dp * t * t - d))
1971 if (e1 .gt. 0.0_dp)
then
2012 pure subroutine eig_sym3(a11, a22, a33, a12, a13, a23, e1, e2, e3)
2013 real(kind=
dp),
intent(in) :: a11, a22, a33, a12, a13, a23
2014 real(kind=
dp),
intent(out) :: e1, e2, e3
2015 real(kind=
dp) :: p1, p2, q, p, r, phi
2016 real(kind=
dp) :: b11, b22, b33, b12, b13, b23
2017 real(kind=
dp),
parameter :: third = 1.0_dp / 3.0_dp
2018 real(kind=
dp),
parameter :: pi_third = 1.0471975511965976_dp
2019 real(kind=
dp),
parameter :: twopi_third = 2.0943951023931953_dp
2021 p1 = a12 * a12 + a13 * a13 + a23 * a23
2023 q = (a11 + a22 + a33) * third
2024 p2 = (a11 - q)**2 + (a22 - q)**2 + (a33 - q)**2 + 2.0_dp * p1
2025 p = sqrt(p2 / 6.0_dp)
2027 if (p .le. 0.0_dp)
then
2029 e1 =
max(a11,
max(a22, a33))
2030 e3 = min(a11, min(a22, a33))
2031 e2 = a11 + a22 + a33 - e1 - e3
2042 r = 0.5_dp * (b11 * (b22 * b33 - b23 * b23) &
2043 - b12 * (b12 * b33 - b23 * b13) &
2044 + b13 * (b12 * b23 - b22 * b13))
2047 if (r .le. -1.0_dp)
then
2049 else if (r .ge. 1.0_dp)
then
2052 phi = acos(r) * third
2055 e1 = q + 2.0_dp * p * cos(phi)
2056 e3 = q + 2.0_dp * p * cos(phi + twopi_third)
2057 e2 = 3.0_dp * q - e1 - e3
type(mpi_datatype), public mpi_real_precision
MPI type for working precision of REAL types.
type(mpi_comm), public neko_comm
MPI communicator.
type(mpi_datatype), public mpi_extra_precision
Object for handling masks in Neko.
subroutine, public cmult(a, c, n)
Multiplication by constant c .
subroutine, public cmult2(a, b, c, n)
Multiplication by constant c .
subroutine, public row_zero(a, m, n, e)
Sets row e to 0 in matrix a.
subroutine, public invcol2(a, b, n)
Vector division .
real(kind=rp) function, public vlsc2(u, v, n)
Compute multiplication sum .
pure logical function, public dabscmp(x, y, tol)
Return double precision absolute comparison .
pure subroutine, public eig_sym3(a11, a22, a33, a12, a13, a23, e1, e2, e3)
Eigenvalues of a symmetric 3x3 matrix, descending.
real(kind=rp), parameter, public pi
subroutine, public sqrt_inplace(a, n)
Sqrt a vector .
real(kind=rp) function, public glsc3(a, b, c, n)
Weighted inner product .
subroutine, public ascol5(a, b, c, d, e, n)
Returns .
subroutine, public addcol3s2(a, b, c, s, n)
Returns .
real(kind=rp) function, public glamax(a, n)
Max of the absolute value of a vector of length n.
subroutine, public masked_scatter_copy(a, b, mask, n, n_mask)
Scatter a contigous vector to masked positions in a target array .
subroutine, public invers2(a, b, n)
Compute inverted vector .
subroutine, public cadd2(a, b, s, n)
Add a scalar to vector .
subroutine, public face_masked_gather_copy_0(a, b, mask, facet, lx, ly, lz, n_mask)
Gather values from a face-local SEM field to a reduced contiguous vector.
real(rp) function, dimension(3, 3), public matinv39(a11, a12, a13, a21, a22, a23, a31, a32, a33)
subroutine, public cadd(a, s, n)
Add a scalar to vector .
subroutine, public masked_copy(a, b, mask, n, n_mask)
Copy a masked vector .
subroutine reorddp(b, ind, n)
reorder double precision array - inverse of swap
pure subroutine, public eig_sym2(a11, a22, a12, e1, e2)
Eigenvalues of a symmetric 2x2 matrix, descending.
subroutine, public addsqr2s2(a, b, c1, n)
Returns .
subroutine, public cwrap(a, min_val, max_val, n)
Wrap value around a range [min, max).
real(kind=rp) function, public glsc4(a, b, c, d, n)
subroutine, public cdiv2(a, b, c, n)
Division of constant c by elements of a .
real(kind=rp) function, public math_stepf(x)
Smooth step function S(x) Returns 0 for x <= 0, 1 for x >= 1, and smooth transition in between.
subroutine swapdp(b, ind, n)
sort double precision array acording to ind vector
subroutine flipvi4(b, ind, n)
Flip single integer vector b and ind.
subroutine, public add2s1(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on first argument).
subroutine, public cpwmin2(a, b, n)
Point-wise minimum of scalar and vector .
real(kind=rp) function, public glsc2(a, b, n)
Weighted inner product .
subroutine, public masked_scatter_copy_0(a, b, mask, n, n_mask)
Scatter a contigous vector to masked positions in a target array .
subroutine, public subcol3(a, b, c, n)
Returns .
subroutine, public rone(a, n)
Set all elements to one.
subroutine flipvdp(b, ind, n)
Flip double precision vector b and ind.
subroutine, public cpwmin3(a, b, c, n)
Point-wise minimum of scalar and vector .
subroutine, public pwmax3(a, b, c, n)
Point-wise maximum of two vectors .
subroutine, public masked_gather_copy(a, b, mask, n, n_mask)
Gather a masked vector to reduced contigous vector .
subroutine, public x_update(a, b, c, c1, c2, n)
Returns .
subroutine, public add3(a, b, c, n)
Vector addition .
subroutine swapi4(b, ind, n)
sort single integer array acording to ind vector
integer function, public glimin(a, n)
Min of an integer vector of length n.
real(kind=rp) function, public glsum(a, n)
Sum a vector of length n.
subroutine, public sub3(a, b, c, n)
Vector subtraction .
subroutine, public addcol4(a, b, c, d, n)
Returns .
subroutine, public add2(a, b, n)
Vector addition .
subroutine, public cfill(a, c, n)
Set all elements to a constant c .
subroutine, public absval(a, n)
Take the absolute value of an array.
subroutine, public invcol3(a, b, c, n)
Invert a vector .
subroutine, public add3s2(a, b, c, c1, c2, n)
Returns .
real(kind=xp) function, dimension(3, 3), public matinv3(a)
Performs a direct calculation of the inverse of a 3×3 matrix. M33INV and M44INV by David G....
subroutine, public pwmax2(a, b, n)
Point-wise maximum of two vectors .
subroutine, public pwmin2(a, b, n)
Point-wise minimum of two vectors .
subroutine, public masked_gather_copy_0(a, b, mask, n, n_mask)
Gather a masked vector to reduced contigous vector .
subroutine, public subcol4(a, b, c, d, n)
Returns .
subroutine sorti4(a, ind, n)
Heap Sort for single integer arrays.
subroutine, public addcol3(a, b, c, n)
Returns .
subroutine, public invcol1(a, n)
Invert a vector .
subroutine, public cdiv(a, c, n)
Division of constant c by elements of a .
real(kind=rp), parameter, public neko_m_ln2
subroutine, public chsign(a, n)
Change sign of vector .
subroutine, public cpwmax3(a, b, c, n)
Point-wise maximum of scalar and vector .
subroutine, public col2(a, b, n)
Vector multiplication .
subroutine, public izero(a, n)
Zero an integer vector.
real(kind=rp) function, public glmax(a, n)
Max of a vector of length n.
real(kind=sp), parameter, public neko_eps_sp
subroutine, public copy(a, b, n)
Copy a vector .
subroutine, public add4s3(a, b, c, d, c1, c2, c3, n)
Returns .
subroutine, public add4(a, b, c, d, n)
Vector addition .
real(kind=rp) function, public vlamax(vec, n)
maximum absolute value of a vector of length n, rank-local
subroutine, public col3(a, b, c, n)
Vector multiplication with 3 vectors .
subroutine, public add5s4(a, b, c, d, e, c1, c2, c3, c4, n)
Returns .
real(kind=rp) function, public math_dstepf(x)
Derivative of math_stepf with respect to x: d(stepf)/dx.
pure logical function drelcmp(x, y, eps)
Return double precision relative comparison .
real(kind=rp), parameter, public neko_eps
Machine epsilon .
subroutine, public vdot3(dot, u1, u2, u3, v1, v2, v3, n)
Compute a dot product (3-d version) assuming vector components etc.
pure logical function, public sabscmp(x, y, tol)
Return single precision absolute comparison .
subroutine, public rzero(a, n)
Zero a real vector.
real(kind=rp) function, public glsubnorm(a, b, n)
Returns the norm of the difference of two vectors .
subroutine, public vdot2(dot, u1, u2, v1, v2, n)
Compute a dot product (2-d version) assuming vector components etc.
subroutine, public cpwmax2(a, b, n)
Point-wise maximum of scalar and vector .
real(kind=dp), parameter, public neko_eps_dp
real(kind=rp) function, public vlmin(vec, n)
minimun value of a vector of length n
subroutine, public cfill_mask(a, c, n, mask, n_mask)
Fill a constant to a masked vector. .
real(kind=rp) function, public vlmax(vec, n)
maximum value of a vector of length n
integer function, public glimax(a, n)
Max of an integer vector of length n.
subroutine sortrp(a, ind, n)
Heap Sort for double precision arrays.
subroutine, public sub2(a, b, n)
Vector substraction .
subroutine, public pwmin3(a, b, c, n)
Point-wise minimum of two vectors .
subroutine, public add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument).
real(kind=rp) function, public glmin(a, n)
Min of a vector of length n.
subroutine, public masked_copy_0(a, b, mask, n, n_mask)
Copy a masked vector .
subroutine, public vcross(u1, u2, u3, v1, v2, v3, w1, w2, w3, n)
Compute a cross product assuming vector components etc.
pure logical function srelcmp(x, y, eps)
Return single precision relative comparison .
pure real(kind=rp) function, public lambert_w0(x, niter)
Approximate the principal real branch of the Lambert W function for non-negative real x.
real(kind=rp) function, public vlsc3(u, v, w, n)
Compute multiplication sum .
subroutine, public power(ap, a, p, n)
Take the power of a vector .
subroutine reordi4(b, ind, n)
reorder single integer array - inverse of swap
subroutine, public p_update(a, b, c, c1, c2, n)
Returns .
integer, parameter, public qp
integer, parameter, public i4
integer, parameter, public xp
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.
pure integer function, dimension(4), public nonlinear_index(linear_index, lx, ly, lz)
Compute (i,j,k,l) array given linear index with sizes (1:lx, 1:ly, 1:lz, :).