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)
106 vcross,
vdot2,
vdot3,
vlsc3,
vlsc2,
add2,
add3,
add4,
sub2,
sub3, &
123 real(kind=
sp),
intent(in) :: x
124 real(kind=
sp),
intent(in) :: y
125 real(kind=
sp),
intent(in),
optional :: tol
128 if (
present(tol))
then
138 real(kind=
dp),
intent(in) :: x
139 real(kind=
dp),
intent(in) :: y
140 real(kind=
dp),
intent(in),
optional :: tol
143 if (
present(tol))
then
153 real(kind=
qp),
intent(in) :: x
154 real(kind=
qp),
intent(in) :: y
155 real(kind=
qp),
intent(in),
optional :: tol
158 if (
present(tol))
then
169 real(kind=
sp),
intent(in) :: x
170 real(kind=
sp),
intent(in) :: y
171 real(kind=
sp),
intent(in),
optional :: eps
173 if (
present(eps))
then
174 srelcmp = abs(x - y) .le. eps*abs(y)
184 real(kind=
dp),
intent(in) :: x
185 real(kind=
dp),
intent(in) :: y
186 real(kind=
dp),
intent(in),
optional :: eps
188 if (
present(eps))
then
189 drelcmp = abs(x - y) .le. eps*abs(y)
199 real(kind=
qp),
intent(in) :: x
200 real(kind=
qp),
intent(in) :: y
201 real(kind=
qp),
intent(in),
optional :: eps
203 if (
present(eps))
then
204 qrelcmp = abs(x - y)/abs(y) .lt. eps
217 real(kind=
rp),
intent(in) :: x
218 integer,
intent(in) :: niter
223 if (x == 0.0_rp)
then
228 a = 1.0_rp / (1.0_rp + 0.5_rp * log(1.0_rp + x))
229 w = log(1.0_rp + a * x)
231 do k = 1,
max(niter, 0)
232 w = w / (1.0_rp + w) * (1.0_rp + log(x / w))
238 integer,
intent(in) :: n
239 real(kind=
rp),
dimension(n),
intent(inout) :: a
252 integer,
intent(in) :: n
253 integer,
dimension(n),
intent(inout) :: a
266 integer,
intent(in) :: m, n, e
267 real(kind=
rp),
intent(inout) :: a(m,n)
280 integer,
intent(in) :: n
281 real(kind=
rp),
dimension(n),
intent(inout) :: a
294 integer,
intent(in) :: n
295 real(kind=
rp),
dimension(n),
intent(in) :: b
296 real(kind=
rp),
dimension(n),
intent(inout) :: a
315 integer,
intent(in) :: n, n_mask
316 real(kind=
rp),
dimension(n),
intent(in) :: b
317 real(kind=
rp),
dimension(n),
intent(inout) :: a
318 integer,
dimension(0:n_mask) ::
mask
338 integer,
intent(in) :: n, n_mask
339 real(kind=
rp),
dimension(n),
intent(in) :: b
340 real(kind=
rp),
dimension(n),
intent(inout) :: a
341 integer,
dimension(n_mask) ::
mask
363 integer,
intent(in) :: n, n_mask
364 real(kind=
rp),
dimension(n),
intent(in) :: b
365 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
366 integer,
dimension(0:n_mask) ::
mask
388 integer,
intent(in) :: lx, ly, lz, n_mask
389 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
390 real(kind=
rp),
dimension(:, :, :, :),
intent(in) :: b
391 integer,
dimension(0:n_mask),
intent(in) ::
mask
392 integer,
dimension(0:n_mask),
intent(in) :: facet
400 select case (facet(l))
402 a(l) = b(idx(2), idx(3), facet(l), idx(4))
404 a(l) = b(idx(1), idx(3), facet(l), idx(4))
406 a(l) = b(idx(1), idx(2), facet(l), idx(4))
423 integer,
intent(in) :: n, n_mask
424 real(kind=
rp),
dimension(n),
intent(in) :: b
425 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
426 integer,
dimension(n_mask) ::
mask
448 integer,
intent(in) :: n, n_mask
449 real(kind=
rp),
dimension(n_mask),
intent(in) :: b
450 real(kind=
rp),
dimension(n),
intent(inout) :: a
451 integer,
dimension(0:n_mask) ::
mask
473 integer,
intent(in) :: n, n_mask
474 real(kind=
rp),
dimension(n_mask),
intent(in) :: b
475 real(kind=
rp),
dimension(n),
intent(inout) :: a
476 integer,
dimension(n_mask) ::
mask
491 integer,
intent(in) :: n, n_mask
492 real(kind=
rp),
dimension(n),
intent(inout) :: a
493 real(kind=
rp),
intent(in) :: c
494 integer,
dimension(n_mask),
intent(in) ::
mask
507 integer,
intent(in) :: n
508 real(kind=
rp),
dimension(n),
intent(inout) :: a
509 real(kind=
rp),
intent(in) :: c
522 integer,
intent(in) :: n
523 real(kind=
rp),
dimension(n),
intent(inout) :: a
524 real(kind=
rp),
dimension(n),
intent(in) :: b
525 real(kind=
rp),
intent(in) :: c
538 integer,
intent(in) :: n
539 real(kind=
rp),
dimension(n),
intent(inout) :: a
540 real(kind=
rp),
intent(in) :: c
553 integer,
intent(in) :: n
554 real(kind=
rp),
dimension(n),
intent(inout) :: a
555 real(kind=
rp),
dimension(n),
intent(in) :: b
556 real(kind=
rp),
intent(in) :: c
569 integer,
intent(in) :: n
570 real(kind=
rp),
dimension(n),
intent(inout) :: a
571 real(kind=
rp),
intent(in) :: s
584 integer,
intent(in) :: n
585 real(kind=
rp),
dimension(n),
intent(inout) :: a
586 real(kind=
rp),
dimension(n),
intent(in) :: b
587 real(kind=
rp),
intent(in) :: s
600 integer,
intent(in) :: n
601 real(kind=
rp),
dimension(n),
intent(inout) :: a
602 real(kind=
rp),
intent(in) :: c
614 subroutine cwrap(a, min_val, max_val, n)
615 integer,
intent(in) :: n
616 real(kind=
rp),
dimension(n),
intent(inout) :: a
617 real(kind=
rp),
intent(in) :: min_val, max_val
620 if (n .lt. 1 .or. max_val .le. min_val)
return
624 a(i) = modulo(a(i) - min_val, max_val - min_val) + min_val
632 integer,
intent(in) :: n
633 real(kind=
rp),
dimension(n) :: a
645 call mpi_allreduce(mpi_in_place, tmp, 1, &
653 integer,
intent(in) :: n
654 real(kind=
rp),
dimension(n) :: a
665 call mpi_allreduce(tmp,
glmax, 1, &
672 integer,
intent(in) :: n
673 integer,
dimension(n) :: a
684 call mpi_allreduce(tmp,
glimax, 1, &
691 integer,
intent(in) :: n
692 real(kind=
rp),
dimension(n) :: a
703 call mpi_allreduce(tmp,
glmin, 1, &
710 integer,
intent(in) :: n
711 integer,
dimension(n) :: a
722 call mpi_allreduce(tmp,
glimin, 1, &
729 integer,
intent(in) :: n
730 real(kind=
rp),
dimension(n),
intent(inout) :: a
744 real(kind=
rp),
intent(in) :: vec(n)
745 real(kind=
rp) :: tmax
750 tmax =
max(tmax, vec(i))
758 integer,
intent(in) :: n
759 real(kind=
rp),
intent(in) :: vec(n)
760 real(kind=
rp) :: tmin
766 tmin = min(tmin, vec(i))
774 integer,
intent(in) :: n
775 real(kind=
rp),
dimension(n),
intent(inout) :: a
780 a(i) = 1.0_xp /
real(a(i),
xp)
788 integer,
intent(in) :: n
789 real(kind=
rp),
dimension(n),
intent(inout) :: a
790 real(kind=
rp),
dimension(n),
intent(in) :: b, c
795 a(i) =
real(b(i),
xp) / c(i)
803 integer,
intent(in) :: n
804 real(kind=
rp),
dimension(n),
intent(inout) :: a
805 real(kind=
rp),
dimension(n),
intent(in) :: b
810 a(i) = 1.0_xp /
real(b(i),
xp)
818 subroutine vcross(u1, u2, u3, v1, v2, v3, w1, w2, w3, n)
819 integer,
intent(in) :: n
820 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2, v3
821 real(kind=
rp),
dimension(n),
intent(in) :: w1, w2, w3
822 real(kind=
rp),
dimension(n),
intent(out) :: u1, u2, u3
827 u1(i) = v2(i)*w3(i) - v3(i)*w2(i)
828 u2(i) = v3(i)*w1(i) - v1(i)*w3(i)
829 u3(i) = v1(i)*w2(i) - v2(i)*w1(i)
837 subroutine vdot2(dot, u1, u2, v1, v2, n)
838 integer,
intent(in) :: n
839 real(kind=
rp),
dimension(n),
intent(in) :: u1, u2
840 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2
841 real(kind=
rp),
dimension(n),
intent(out) :: dot
846 dot(i) = u1(i)*v1(i) + u2(i)*v2(i)
854 subroutine vdot3(dot, u1, u2, u3, v1, v2, v3, n)
855 integer,
intent(in) :: n
856 real(kind=
rp),
dimension(n),
intent(in) :: u1, u2, u3
857 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2, v3
858 real(kind=
rp),
dimension(n),
intent(out) :: dot
863 dot(i) = u1(i)*v1(i) + u2(i)*v2(i) + u3(i)*v3(i)
870 function vlsc3(u, v, w, n)
result(s)
871 integer,
intent(in) :: n
872 real(kind=
rp),
dimension(n),
intent(in) :: u, v, w
879 s = s + u(i)*v(i)*w(i)
887 integer,
intent(in) :: n
888 real(kind=
rp),
dimension(n),
intent(in) :: u, v
903 integer,
intent(in) :: n
904 real(kind=
rp),
dimension(n),
intent(inout) :: a
905 real(kind=
rp),
dimension(n),
intent(in) :: b
918 integer,
intent(in) :: n
919 real(kind=
rp),
dimension(n),
intent(inout) :: a
920 real(kind=
rp),
dimension(n),
intent(in) :: b
921 real(kind=
rp),
dimension(n),
intent(in) :: c
934 integer,
intent(in) :: n
935 real(kind=
rp),
dimension(n),
intent(out) :: a
936 real(kind=
rp),
dimension(n),
intent(in) :: d
937 real(kind=
rp),
dimension(n),
intent(in) :: c
938 real(kind=
rp),
dimension(n),
intent(in) :: b
943 a(i) = b(i) + c(i) + d(i)
951 integer,
intent(in) :: n
952 real(kind=
rp),
dimension(n),
intent(inout) :: a
953 real(kind=
rp),
dimension(n),
intent(in) :: b
966 integer,
intent(in) :: n
967 real(kind=
rp),
dimension(n),
intent(inout) :: a
968 real(kind=
rp),
dimension(n),
intent(in) :: b
969 real(kind=
rp),
dimension(n),
intent(in) :: c
984 integer,
intent(in) :: n
985 real(kind=
rp),
dimension(n),
intent(inout) :: a
986 real(kind=
rp),
dimension(n),
intent(in) :: b
987 real(kind=
rp),
intent(in) :: c1
992 a(i) = c1 * a(i) + b(i)
1001 integer,
intent(in) :: n
1002 real(kind=
rp),
dimension(n),
intent(inout) :: a
1003 real(kind=
rp),
dimension(n),
intent(in) :: b
1004 real(kind=
rp),
intent(in) :: c1
1009 a(i) = a(i) + c1 * b(i)
1017 integer,
intent(in) :: n
1018 real(kind=
rp),
dimension(n),
intent(inout) :: a
1019 real(kind=
rp),
dimension(n),
intent(in) :: b
1020 real(kind=
rp),
intent(in) :: c1
1025 a(i) = a(i) + c1 * ( b(i) * b(i) )
1033 integer,
intent(in) :: n
1034 real(kind=
rp),
dimension(n),
intent(inout) :: a
1035 real(kind=
rp),
dimension(n),
intent(in) :: b
1040 a(i) =
real(a(i),
xp) / b(i)
1049 integer,
intent(in) :: n
1050 real(kind=
rp),
dimension(n),
intent(inout) :: a
1051 real(kind=
rp),
dimension(n),
intent(in) :: b
1064 integer,
intent(in) :: n
1065 real(kind=
rp),
dimension(n),
intent(inout) :: a
1066 real(kind=
rp),
dimension(n),
intent(in) :: b
1067 real(kind=
rp),
dimension(n),
intent(in) :: c
1080 integer,
intent(in) :: n
1081 real(kind=
rp),
dimension(n),
intent(inout) :: a
1082 real(kind=
rp),
dimension(n),
intent(in) :: b
1083 real(kind=
rp),
dimension(n),
intent(in) :: c
1088 a(i) = a(i) - b(i) * c(i)
1096 integer,
intent(in) :: n
1097 real(kind=
rp),
dimension(n),
intent(inout) :: a
1098 real(kind=
rp),
dimension(n),
intent(in) :: b
1099 real(kind=
rp),
dimension(n),
intent(in) :: c
1100 real(kind=
rp),
intent(in) :: c1, c2
1105 a(i) = c1 * b(i) + c2 * c(i)
1113 integer,
intent(in) :: n
1114 real(kind=
rp),
dimension(n),
intent(inout) :: a
1115 real(kind=
rp),
dimension(n),
intent(in) :: b
1116 real(kind=
rp),
dimension(n),
intent(in) :: c
1117 real(kind=
rp),
dimension(n),
intent(in) :: d
1118 real(kind=
rp),
intent(in) :: c1, c2, c3
1123 a(i) = c1 * b(i) + c2 * c(i) + c3 * d(i)
1130 subroutine add5s4(a, b, c, d, e, c1, c2, c3, c4, n)
1131 integer,
intent(in) :: n
1132 real(kind=
rp),
dimension(n),
intent(inout) :: a
1133 real(kind=
rp),
dimension(n),
intent(in) :: b
1134 real(kind=
rp),
dimension(n),
intent(in) :: c
1135 real(kind=
rp),
dimension(n),
intent(in) :: d
1136 real(kind=
rp),
dimension(n),
intent(in) :: e
1137 real(kind=
rp),
intent(in) :: c1, c2, c3, c4
1142 a(i) = a(i) + c1 * b(i) + c2 * c(i) + c3 * d(i) + c4 * e(i)
1150 integer,
intent(in) :: n
1151 real(kind=
rp),
dimension(n),
intent(inout) :: a
1152 real(kind=
rp),
dimension(n),
intent(in) :: b
1153 real(kind=
rp),
dimension(n),
intent(in) :: c
1154 real(kind=
rp),
dimension(n),
intent(in) :: d
1159 a(i) = a(i) - b(i) * c(i) * d(i)
1167 integer,
intent(in) :: n
1168 real(kind=
rp),
dimension(n),
intent(inout) :: a
1169 real(kind=
rp),
dimension(n),
intent(in) :: b
1170 real(kind=
rp),
dimension(n),
intent(in) :: c
1175 a(i) = a(i) + b(i) * c(i)
1183 integer,
intent(in) :: n
1184 real(kind=
rp),
dimension(n),
intent(inout) :: a
1185 real(kind=
rp),
dimension(n),
intent(in) :: b
1186 real(kind=
rp),
dimension(n),
intent(in) :: c
1187 real(kind=
rp),
dimension(n),
intent(in) :: d
1192 a(i) = a(i) + b(i) * c(i) * d(i)
1200 integer,
intent(in) :: n
1201 real(kind=
rp),
dimension(n),
intent(inout) :: a
1202 real(kind=
rp),
dimension(n),
intent(in) :: b
1203 real(kind=
rp),
dimension(n),
intent(in) :: c
1204 real(kind=
rp),
intent(in) :: s
1209 a(i) = a(i) + s * b(i) * c(i)
1217 integer,
intent(in) :: n
1218 real(kind=
rp),
dimension(n),
intent(inout) :: a
1219 real(kind=
rp),
dimension(n),
intent(in) :: b
1220 real(kind=
rp),
dimension(n),
intent(in) :: c
1221 real(kind=
rp),
dimension(n),
intent(in) :: d
1222 real(kind=
rp),
dimension(n),
intent(in) :: e
1227 a(i) = b(i)*c(i) - d(i)*e(i)
1235 integer,
intent(in) :: n
1236 real(kind=
rp),
dimension(n),
intent(inout) :: a
1237 real(kind=
rp),
dimension(n),
intent(in) :: b
1238 real(kind=
rp),
dimension(n),
intent(in) :: c
1239 real(kind=
rp),
intent(in) :: c1, c2
1244 a(i) = b(i) + c1*(a(i)-c2*c(i))
1252 integer,
intent(in) :: n
1253 real(kind=
rp),
dimension(n),
intent(inout) :: a
1254 real(kind=
rp),
dimension(n),
intent(in) :: b
1255 real(kind=
rp),
dimension(n),
intent(in) :: c
1256 real(kind=
rp),
intent(in) :: c1, c2
1261 a(i) = a(i) + c1*b(i)+c2*c(i)
1269 integer,
intent(in) :: n
1270 real(kind=
rp),
dimension(n),
intent(in) :: a
1271 real(kind=
rp),
dimension(n),
intent(in) :: b
1273 real(kind=
xp) :: tmp
1279 tmp = tmp + a(i) * b(i)
1283 call mpi_allreduce(mpi_in_place, tmp, 1, &
1290 integer,
intent(in) :: n
1291 real(kind=
rp),
dimension(n),
intent(in) :: a
1292 real(kind=
rp),
dimension(n),
intent(in) :: b
1293 real(kind=
rp),
dimension(n),
intent(in) :: c
1295 real(kind=
xp) :: tmp
1301 tmp = tmp + a(i) * b(i) * c(i)
1305 call mpi_allreduce(mpi_in_place, tmp, 1, &
1311 integer,
intent(in) :: n
1312 real(kind=
rp),
dimension(n),
intent(in) :: a
1313 real(kind=
rp),
dimension(n),
intent(in) :: b
1314 real(kind=
rp),
dimension(n),
intent(in) :: c
1315 real(kind=
rp),
dimension(n),
intent(in) :: d
1317 real(kind=
xp) :: tmp
1323 tmp = tmp + a(i) * b(i) * c(i) * d(i)
1327 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
1340 real(kind=
xp) :: tmp
1346 tmp = tmp + (a(i) - b(i))**2
1350 call mpi_allreduce(mpi_in_place, tmp, 1, &
1362 integer,
intent(in) :: n
1363 real(kind=
rp),
intent(inout) :: a(n)
1364 integer,
intent(out) :: ind(n)
1366 integer :: j, ir, i, ii, l
1372 if (n .le. 1)
return
1396 do while (j .le. ir)
1398 if ( a(j) .lt. a(j+1) ) j = j + 1
1400 if (aa .lt. a(j))
then
1420 integer,
intent(in) :: n
1421 integer(i4),
intent(inout) :: a(n)
1422 integer,
intent(out) :: ind(n)
1424 integer :: j, ir, i, ii, l
1430 if (n .le. 1)
return
1453 do while (j .le. ir)
1455 if ( a(j) .lt. a(j + 1) ) j = j + 1
1457 if (aa .lt. a(j))
then
1476 integer,
intent(in) :: n
1477 real(kind=
rp),
intent(inout) :: b(n)
1478 integer,
intent(in) :: ind(n)
1479 real(kind=
rp) :: temp(n)
1503 integer,
intent(in) :: n
1504 integer(i4),
intent(inout) :: b(n)
1505 integer,
intent(in) :: ind(n)
1506 integer(i4) :: temp(n)
1530 integer,
intent(in) :: n
1531 real(kind=
rp),
intent(inout) :: b(n)
1532 integer,
intent(in) :: ind(n)
1533 real(kind=
rp) :: temp(n)
1557 integer,
intent(in) :: n
1558 integer(i4),
intent(inout) :: b(n)
1559 integer,
intent(in) :: ind(n)
1560 integer(i4) :: temp(n)
1584 integer,
intent(in) :: n
1585 real(kind=
rp),
intent(inout) :: b(n)
1586 integer,
intent(inout) :: ind(n)
1587 real(kind=
rp) :: temp(n)
1588 integer :: tempind(n)
1596 tempind(jj) = ind(i)
1614 integer,
intent(in) :: n
1615 integer(i4),
intent(inout) :: b(n)
1616 integer,
intent(inout) :: ind(n)
1617 integer(i4) :: temp(n)
1618 integer :: tempind(n)
1626 tempind(jj) = ind(i)
1643 integer,
intent(in) :: n
1644 real(kind=
rp),
dimension(n),
intent(inout) :: a
1660 integer,
intent(in) :: n
1661 real(kind=
rp),
dimension(n),
intent(inout) :: a
1662 real(kind=
rp),
dimension(n),
intent(in) :: b
1667 a(i) =
max(a(i), b(i))
1675 integer,
intent(in) :: n
1676 real(kind=
rp),
dimension(n),
intent(inout) :: a
1677 real(kind=
rp),
dimension(n),
intent(in) :: b, c
1682 a(i) =
max(b(i), c(i))
1690 integer,
intent(in) :: n
1691 real(kind=
rp),
dimension(n),
intent(inout) :: a
1692 real(kind=
rp),
intent(in) :: b
1705 integer,
intent(in) :: n
1706 real(kind=
rp),
dimension(n),
intent(inout) :: a
1707 real(kind=
rp),
dimension(n),
intent(in) :: b
1708 real(kind=
rp),
intent(in) :: c
1721 integer,
intent(in) :: n
1722 real(kind=
rp),
dimension(n),
intent(inout) :: a
1723 real(kind=
rp),
dimension(n),
intent(in) :: b
1728 a(i) = min(a(i), b(i))
1736 integer,
intent(in) :: n
1737 real(kind=
rp),
dimension(n),
intent(inout) :: a
1738 real(kind=
rp),
dimension(n),
intent(in) :: b, c
1743 a(i) = min(b(i), c(i))
1751 integer,
intent(in) :: n
1752 real(kind=
rp),
dimension(n),
intent(inout) :: a
1753 real(kind=
rp),
intent(in) :: b
1766 integer,
intent(in) :: n
1767 real(kind=
rp),
dimension(n),
intent(inout) :: a
1768 real(kind=
rp),
dimension(n),
intent(in) :: b
1769 real(kind=
rp),
intent(in) :: c
1783 function matinv39(a11, a12, a13, a21, a22, a23, a31, a32, a33) &
1785 real(kind=
rp),
intent(in) :: a11, a12, a13, a21, a22, a23, a31, a32, a33
1806 real(kind=
xp),
intent(in) :: a(3,3)
1807 real(kind=
xp) :: b(3,3)
1808 real(kind=
xp) :: detinv
1812 detinv = 1.0_xp /
real(a(1,1)*a(2,2)*a(3,3) - a(1,1)*a(2,3)*a(3,2) &
1813 - a(1,2)*a(2,1)*a(3,3) + a(1,2)*a(2,3)*a(3,1)&
1814 + a(1,3)*a(2,1)*a(3,2) - a(1,3)*a(2,2)*a(3,1),
xp)
1817 b(1,1) = +detinv * (a(2,2)*a(3,3) - a(2,3)*a(3,2))
1818 b(2,1) = -detinv * (a(2,1)*a(3,3) - a(2,3)*a(3,1))
1819 b(3,1) = +detinv * (a(2,1)*a(3,2) - a(2,2)*a(3,1))
1820 b(1,2) = -detinv * (a(1,2)*a(3,3) - a(1,3)*a(3,2))
1821 b(2,2) = +detinv * (a(1,1)*a(3,3) - a(1,3)*a(3,1))
1822 b(3,2) = -detinv * (a(1,1)*a(3,2) - a(1,2)*a(3,1))
1823 b(1,3) = +detinv * (a(1,2)*a(2,3) - a(1,3)*a(2,2))
1824 b(2,3) = -detinv * (a(1,1)*a(2,3) - a(1,3)*a(2,1))
1825 b(3,3) = +detinv * (a(1,1)*a(2,2) - a(1,2)*a(2,1))
1831 real(kind=
rp),
intent(in) :: x
1832 real(kind=
rp) :: val
1833 real(kind=
rp),
parameter :: xdmin = 0.0001_rp
1834 real(kind=
rp),
parameter :: xdmax = 0.9999_rp
1837 if (x <= xdmin)
then
1840 else if (x >= xdmax)
then
1845 g = (1.0_rp / (x - 1.0_rp)) + (1.0_rp / x)
1848 val = 1.0_rp / (1.0_rp + exp(g))
1854 real(kind=
rp),
intent(in) :: x
1855 real(kind=
rp) :: val
1856 real(kind=
rp),
parameter :: xdmin = 0.0001_rp
1857 real(kind=
rp),
parameter :: xdmax = 0.9999_rp
1858 real(kind=
rp) :: arg, g, dg, s_val
1860 if (x <= xdmin .or. x >= xdmax)
then
1867 g = (1.0_rp / (x - 1.0_rp)) + (1.0_rp / x)
1870 dg = -(1.0_rp / ((x - 1.0_rp)**2)) - (1.0_rp / (x**2))
1873 s_val = 1.0_rp / (1.0_rp + exp(g))
1875 val = -s_val * (1.0_rp - s_val) * dg
1881 integer,
intent(in) :: n
1882 real(kind=
rp),
dimension(n),
intent(inout) :: a
1895 integer,
intent(in) :: n
1896 real(kind=
rp),
dimension(n),
intent(inout) :: ap
1897 real(kind=
rp),
dimension(n),
intent(in) :: a
1898 real(kind=
rp),
intent(in) :: p
1907 end subroutine power
1911 real(kind=
dp),
intent(in) :: a11, a22, a12
1912 real(kind=
dp),
intent(out) :: e1, e2
1913 real(kind=
dp) :: t, d, s
1916 d = a11 * a22 - a12 * a12
1917 s = sqrt(
max(0.0_dp, 0.25_dp * t * t - d))
1920 if (e1 .gt. 0.0_dp)
then
1945 pure subroutine eig_sym3(a11, a22, a33, a12, a13, a23, e1, e2, e3)
1946 real(kind=
dp),
intent(in) :: a11, a22, a33, a12, a13, a23
1947 real(kind=
dp),
intent(out) :: e1, e2, e3
1948 real(kind=
dp) :: p1, p2, q, p, r, phi
1949 real(kind=
dp) :: b11, b22, b33, b12, b13, b23
1950 real(kind=
dp),
parameter :: third = 1.0_dp / 3.0_dp
1951 real(kind=
dp),
parameter :: pi_third = 1.0471975511965976_dp
1952 real(kind=
dp),
parameter :: twopi_third = 2.0943951023931953_dp
1954 p1 = a12 * a12 + a13 * a13 + a23 * a23
1956 q = (a11 + a22 + a33) * third
1957 p2 = (a11 - q)**2 + (a22 - q)**2 + (a33 - q)**2 + 2.0_dp * p1
1958 p = sqrt(p2 / 6.0_dp)
1960 if (p .le. 0.0_dp)
then
1962 e1 =
max(a11,
max(a22, a33))
1963 e3 = min(a11, min(a22, a33))
1964 e2 = a11 + a22 + a33 - e1 - e3
1975 r = 0.5_dp * (b11 * (b22 * b33 - b23 * b23) &
1976 - b12 * (b12 * b33 - b23 * b13) &
1977 + b13 * (b12 * b23 - b22 * b13))
1980 if (r .le. -1.0_dp)
then
1982 else if (r .ge. 1.0_dp)
then
1985 phi = acos(r) * third
1988 e1 = q + 2.0_dp * p * cos(phi)
1989 e3 = q + 2.0_dp * p * cos(phi + twopi_third)
1990 e2 = 3.0_dp * q - e1 - e3
__inline__ __device__ void nonlinear_index(const int idx, const int lx, int *index)
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
pure logical function qabscmp(x, y, tol)
Return double precision absolute comparison .
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 .
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 .
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 .
pure logical function qrelcmp(x, y, eps)
Return quad precision relative 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.