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)
107 vcross,
vdot2,
vdot3,
vlsc3,
vlsc2,
add2,
add3,
add4,
sub2,
sub3, &
124 real(kind=
sp),
intent(in) :: x
125 real(kind=
sp),
intent(in) :: y
126 real(kind=
sp),
intent(in),
optional :: tol
129 if (
present(tol))
then
139 real(kind=
dp),
intent(in) :: x
140 real(kind=
dp),
intent(in) :: y
141 real(kind=
dp),
intent(in),
optional :: tol
144 if (
present(tol))
then
154 real(kind=
qp),
intent(in) :: x
155 real(kind=
qp),
intent(in) :: y
156 real(kind=
qp),
intent(in),
optional :: tol
159 if (
present(tol))
then
170 real(kind=
sp),
intent(in) :: x
171 real(kind=
sp),
intent(in) :: y
172 real(kind=
sp),
intent(in),
optional :: eps
174 if (
present(eps))
then
175 srelcmp = abs(x - y) .le. eps*abs(y)
185 real(kind=
dp),
intent(in) :: x
186 real(kind=
dp),
intent(in) :: y
187 real(kind=
dp),
intent(in),
optional :: eps
189 if (
present(eps))
then
190 drelcmp = abs(x - y) .le. eps*abs(y)
200 real(kind=
qp),
intent(in) :: x
201 real(kind=
qp),
intent(in) :: y
202 real(kind=
qp),
intent(in),
optional :: eps
204 if (
present(eps))
then
205 qrelcmp = abs(x - y)/abs(y) .lt. eps
218 real(kind=
rp),
intent(in) :: x
219 integer,
intent(in) :: niter
224 if (x == 0.0_rp)
then
229 a = 1.0_rp / (1.0_rp + 0.5_rp * log(1.0_rp + x))
230 w = log(1.0_rp + a * x)
232 do k = 1,
max(niter, 0)
233 w = w / (1.0_rp + w) * (1.0_rp + log(x / w))
239 integer,
intent(in) :: n
240 real(kind=
rp),
dimension(n),
intent(inout) :: a
253 integer,
intent(in) :: n
254 integer,
dimension(n),
intent(inout) :: a
267 integer,
intent(in) :: m, n, e
268 real(kind=
rp),
intent(inout) :: a(m,n)
281 integer,
intent(in) :: n
282 real(kind=
rp),
dimension(n),
intent(inout) :: a
295 integer,
intent(in) :: n
296 real(kind=
rp),
dimension(n),
intent(in) :: b
297 real(kind=
rp),
dimension(n),
intent(inout) :: a
316 integer,
intent(in) :: n, n_mask
317 real(kind=
rp),
dimension(n),
intent(in) :: b
318 real(kind=
rp),
dimension(n),
intent(inout) :: a
319 integer,
dimension(0:n_mask) ::
mask
339 integer,
intent(in) :: n, n_mask
340 real(kind=
rp),
dimension(n),
intent(in) :: b
341 real(kind=
rp),
dimension(n),
intent(inout) :: a
342 integer,
dimension(n_mask) ::
mask
364 integer,
intent(in) :: n, n_mask
365 real(kind=
rp),
dimension(n),
intent(in) :: b
366 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
367 integer,
dimension(0:n_mask) ::
mask
389 integer,
intent(in) :: lx, ly, lz, n_mask
390 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
391 real(kind=
rp),
dimension(:, :, :, :),
intent(in) :: b
392 integer,
dimension(0:n_mask),
intent(in) ::
mask
393 integer,
dimension(0:n_mask),
intent(in) :: facet
401 select case (facet(l))
403 a(l) = b(idx(2), idx(3), facet(l), idx(4))
405 a(l) = b(idx(1), idx(3), facet(l), idx(4))
407 a(l) = b(idx(1), idx(2), facet(l), idx(4))
424 integer,
intent(in) :: n, n_mask
425 real(kind=
rp),
dimension(n),
intent(in) :: b
426 real(kind=
rp),
dimension(n_mask),
intent(inout) :: a
427 integer,
dimension(n_mask) ::
mask
449 integer,
intent(in) :: n, n_mask
450 real(kind=
rp),
dimension(n_mask),
intent(in) :: b
451 real(kind=
rp),
dimension(n),
intent(inout) :: a
452 integer,
dimension(0:n_mask) ::
mask
474 integer,
intent(in) :: n, n_mask
475 real(kind=
rp),
dimension(n_mask),
intent(in) :: b
476 real(kind=
rp),
dimension(n),
intent(inout) :: a
477 integer,
dimension(n_mask) ::
mask
492 integer,
intent(in) :: n, n_mask
493 real(kind=
rp),
dimension(n),
intent(inout) :: a
494 real(kind=
rp),
intent(in) :: c
495 integer,
dimension(n_mask),
intent(in) ::
mask
508 integer,
intent(in) :: n
509 real(kind=
rp),
dimension(n),
intent(inout) :: a
510 real(kind=
rp),
intent(in) :: c
523 integer,
intent(in) :: n
524 real(kind=
rp),
dimension(n),
intent(inout) :: a
525 real(kind=
rp),
dimension(n),
intent(in) :: b
526 real(kind=
rp),
intent(in) :: c
539 integer,
intent(in) :: n
540 real(kind=
rp),
dimension(n),
intent(inout) :: a
541 real(kind=
rp),
intent(in) :: c
554 integer,
intent(in) :: n
555 real(kind=
rp),
dimension(n),
intent(inout) :: a
556 real(kind=
rp),
dimension(n),
intent(in) :: b
557 real(kind=
rp),
intent(in) :: c
570 integer,
intent(in) :: n
571 real(kind=
rp),
dimension(n),
intent(inout) :: a
572 real(kind=
rp),
intent(in) :: s
585 integer,
intent(in) :: n
586 real(kind=
rp),
dimension(n),
intent(inout) :: a
587 real(kind=
rp),
dimension(n),
intent(in) :: b
588 real(kind=
rp),
intent(in) :: s
601 integer,
intent(in) :: n
602 real(kind=
rp),
dimension(n),
intent(inout) :: a
603 real(kind=
rp),
intent(in) :: c
615 subroutine cwrap(a, min_val, max_val, n)
616 integer,
intent(in) :: n
617 real(kind=
rp),
dimension(n),
intent(inout) :: a
618 real(kind=
rp),
intent(in) :: min_val, max_val
621 if (n .lt. 1 .or. max_val .le. min_val)
return
625 a(i) = modulo(a(i) - min_val, max_val - min_val) + min_val
633 integer,
intent(in) :: n
634 real(kind=
rp),
dimension(n) :: a
646 call mpi_allreduce(mpi_in_place, tmp, 1, &
654 integer,
intent(in) :: n
655 real(kind=
rp),
dimension(n) :: a
666 call mpi_allreduce(tmp,
glmax, 1, &
674 integer,
intent(in) :: n
675 real(kind=
rp),
dimension(n) :: a
682 tmp =
max(tmp, abs(a(i)))
686 call mpi_allreduce(tmp,
glamax, 1, &
693 integer,
intent(in) :: n
694 integer,
dimension(n) :: a
705 call mpi_allreduce(tmp,
glimax, 1, &
712 integer,
intent(in) :: n
713 real(kind=
rp),
dimension(n) :: a
724 call mpi_allreduce(tmp,
glmin, 1, &
731 integer,
intent(in) :: n
732 integer,
dimension(n) :: a
743 call mpi_allreduce(tmp,
glimin, 1, &
750 integer,
intent(in) :: n
751 real(kind=
rp),
dimension(n),
intent(inout) :: a
765 real(kind=
rp),
intent(in) :: vec(n)
766 real(kind=
rp) :: tamax
771 tamax =
max(tamax, abs(vec(i)))
780 real(kind=
rp),
intent(in) :: vec(n)
781 real(kind=
rp) :: tmax
786 tmax =
max(tmax, vec(i))
794 integer,
intent(in) :: n
795 real(kind=
rp),
intent(in) :: vec(n)
796 real(kind=
rp) :: tmin
802 tmin = min(tmin, vec(i))
810 integer,
intent(in) :: n
811 real(kind=
rp),
dimension(n),
intent(inout) :: a
816 a(i) = 1.0_xp /
real(a(i),
xp)
824 integer,
intent(in) :: n
825 real(kind=
rp),
dimension(n),
intent(inout) :: a
826 real(kind=
rp),
dimension(n),
intent(in) :: b, c
831 a(i) =
real(b(i),
xp) / c(i)
839 integer,
intent(in) :: n
840 real(kind=
rp),
dimension(n),
intent(inout) :: a
841 real(kind=
rp),
dimension(n),
intent(in) :: b
846 a(i) = 1.0_xp /
real(b(i),
xp)
854 subroutine vcross(u1, u2, u3, v1, v2, v3, w1, w2, w3, n)
855 integer,
intent(in) :: n
856 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2, v3
857 real(kind=
rp),
dimension(n),
intent(in) :: w1, w2, w3
858 real(kind=
rp),
dimension(n),
intent(out) :: u1, u2, u3
863 u1(i) = v2(i)*w3(i) - v3(i)*w2(i)
864 u2(i) = v3(i)*w1(i) - v1(i)*w3(i)
865 u3(i) = v1(i)*w2(i) - v2(i)*w1(i)
873 subroutine vdot2(dot, u1, u2, v1, v2, n)
874 integer,
intent(in) :: n
875 real(kind=
rp),
dimension(n),
intent(in) :: u1, u2
876 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2
877 real(kind=
rp),
dimension(n),
intent(out) :: dot
882 dot(i) = u1(i)*v1(i) + u2(i)*v2(i)
890 subroutine vdot3(dot, u1, u2, u3, v1, v2, v3, n)
891 integer,
intent(in) :: n
892 real(kind=
rp),
dimension(n),
intent(in) :: u1, u2, u3
893 real(kind=
rp),
dimension(n),
intent(in) :: v1, v2, v3
894 real(kind=
rp),
dimension(n),
intent(out) :: dot
899 dot(i) = u1(i)*v1(i) + u2(i)*v2(i) + u3(i)*v3(i)
906 function vlsc3(u, v, w, n)
result(s)
907 integer,
intent(in) :: n
908 real(kind=
rp),
dimension(n),
intent(in) :: u, v, w
915 s = s + u(i)*v(i)*w(i)
923 integer,
intent(in) :: n
924 real(kind=
rp),
dimension(n),
intent(in) :: u, v
939 integer,
intent(in) :: n
940 real(kind=
rp),
dimension(n),
intent(inout) :: a
941 real(kind=
rp),
dimension(n),
intent(in) :: b
954 integer,
intent(in) :: n
955 real(kind=
rp),
dimension(n),
intent(inout) :: a
956 real(kind=
rp),
dimension(n),
intent(in) :: b
957 real(kind=
rp),
dimension(n),
intent(in) :: c
970 integer,
intent(in) :: n
971 real(kind=
rp),
dimension(n),
intent(out) :: a
972 real(kind=
rp),
dimension(n),
intent(in) :: d
973 real(kind=
rp),
dimension(n),
intent(in) :: c
974 real(kind=
rp),
dimension(n),
intent(in) :: b
979 a(i) = b(i) + c(i) + d(i)
987 integer,
intent(in) :: n
988 real(kind=
rp),
dimension(n),
intent(inout) :: a
989 real(kind=
rp),
dimension(n),
intent(in) :: b
1002 integer,
intent(in) :: n
1003 real(kind=
rp),
dimension(n),
intent(inout) :: a
1004 real(kind=
rp),
dimension(n),
intent(in) :: b
1005 real(kind=
rp),
dimension(n),
intent(in) :: c
1020 integer,
intent(in) :: n
1021 real(kind=
rp),
dimension(n),
intent(inout) :: a
1022 real(kind=
rp),
dimension(n),
intent(in) :: b
1023 real(kind=
rp),
intent(in) :: c1
1028 a(i) = c1 * a(i) + b(i)
1037 integer,
intent(in) :: n
1038 real(kind=
rp),
dimension(n),
intent(inout) :: a
1039 real(kind=
rp),
dimension(n),
intent(in) :: b
1040 real(kind=
rp),
intent(in) :: c1
1045 a(i) = a(i) + c1 * b(i)
1053 integer,
intent(in) :: n
1054 real(kind=
rp),
dimension(n),
intent(inout) :: a
1055 real(kind=
rp),
dimension(n),
intent(in) :: b
1056 real(kind=
rp),
intent(in) :: c1
1061 a(i) = a(i) + c1 * ( b(i) * b(i) )
1069 integer,
intent(in) :: n
1070 real(kind=
rp),
dimension(n),
intent(inout) :: a
1071 real(kind=
rp),
dimension(n),
intent(in) :: b
1076 a(i) =
real(a(i),
xp) / b(i)
1085 integer,
intent(in) :: n
1086 real(kind=
rp),
dimension(n),
intent(inout) :: a
1087 real(kind=
rp),
dimension(n),
intent(in) :: b
1100 integer,
intent(in) :: n
1101 real(kind=
rp),
dimension(n),
intent(inout) :: a
1102 real(kind=
rp),
dimension(n),
intent(in) :: b
1103 real(kind=
rp),
dimension(n),
intent(in) :: c
1116 integer,
intent(in) :: n
1117 real(kind=
rp),
dimension(n),
intent(inout) :: a
1118 real(kind=
rp),
dimension(n),
intent(in) :: b
1119 real(kind=
rp),
dimension(n),
intent(in) :: c
1124 a(i) = a(i) - b(i) * c(i)
1132 integer,
intent(in) :: n
1133 real(kind=
rp),
dimension(n),
intent(inout) :: a
1134 real(kind=
rp),
dimension(n),
intent(in) :: b
1135 real(kind=
rp),
dimension(n),
intent(in) :: c
1136 real(kind=
rp),
intent(in) :: c1, c2
1141 a(i) = c1 * b(i) + c2 * c(i)
1149 integer,
intent(in) :: n
1150 real(kind=
rp),
dimension(n),
intent(inout) :: a
1151 real(kind=
rp),
dimension(n),
intent(in) :: b
1152 real(kind=
rp),
dimension(n),
intent(in) :: c
1153 real(kind=
rp),
dimension(n),
intent(in) :: d
1154 real(kind=
rp),
intent(in) :: c1, c2, c3
1159 a(i) = c1 * b(i) + c2 * c(i) + c3 * d(i)
1166 subroutine add5s4(a, b, c, d, e, c1, c2, c3, c4, n)
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
1171 real(kind=
rp),
dimension(n),
intent(in) :: d
1172 real(kind=
rp),
dimension(n),
intent(in) :: e
1173 real(kind=
rp),
intent(in) :: c1, c2, c3, c4
1178 a(i) = a(i) + c1 * b(i) + c2 * c(i) + c3 * d(i) + c4 * e(i)
1186 integer,
intent(in) :: n
1187 real(kind=
rp),
dimension(n),
intent(inout) :: a
1188 real(kind=
rp),
dimension(n),
intent(in) :: b
1189 real(kind=
rp),
dimension(n),
intent(in) :: c
1190 real(kind=
rp),
dimension(n),
intent(in) :: d
1195 a(i) = a(i) - b(i) * c(i) * d(i)
1203 integer,
intent(in) :: n
1204 real(kind=
rp),
dimension(n),
intent(inout) :: a
1205 real(kind=
rp),
dimension(n),
intent(in) :: b
1206 real(kind=
rp),
dimension(n),
intent(in) :: c
1211 a(i) = a(i) + b(i) * c(i)
1219 integer,
intent(in) :: n
1220 real(kind=
rp),
dimension(n),
intent(inout) :: a
1221 real(kind=
rp),
dimension(n),
intent(in) :: b
1222 real(kind=
rp),
dimension(n),
intent(in) :: c
1223 real(kind=
rp),
dimension(n),
intent(in) :: d
1228 a(i) = a(i) + b(i) * c(i) * d(i)
1236 integer,
intent(in) :: n
1237 real(kind=
rp),
dimension(n),
intent(inout) :: a
1238 real(kind=
rp),
dimension(n),
intent(in) :: b
1239 real(kind=
rp),
dimension(n),
intent(in) :: c
1240 real(kind=
rp),
intent(in) :: s
1245 a(i) = a(i) + s * b(i) * c(i)
1253 integer,
intent(in) :: n
1254 real(kind=
rp),
dimension(n),
intent(inout) :: a
1255 real(kind=
rp),
dimension(n),
intent(in) :: b
1256 real(kind=
rp),
dimension(n),
intent(in) :: c
1257 real(kind=
rp),
dimension(n),
intent(in) :: d
1258 real(kind=
rp),
dimension(n),
intent(in) :: e
1263 a(i) = b(i)*c(i) - d(i)*e(i)
1271 integer,
intent(in) :: n
1272 real(kind=
rp),
dimension(n),
intent(inout) :: a
1273 real(kind=
rp),
dimension(n),
intent(in) :: b
1274 real(kind=
rp),
dimension(n),
intent(in) :: c
1275 real(kind=
rp),
intent(in) :: c1, c2
1280 a(i) = b(i) + c1*(a(i)-c2*c(i))
1288 integer,
intent(in) :: n
1289 real(kind=
rp),
dimension(n),
intent(inout) :: a
1290 real(kind=
rp),
dimension(n),
intent(in) :: b
1291 real(kind=
rp),
dimension(n),
intent(in) :: c
1292 real(kind=
rp),
intent(in) :: c1, c2
1297 a(i) = a(i) + c1*b(i)+c2*c(i)
1305 integer,
intent(in) :: n
1306 real(kind=
rp),
dimension(n),
intent(in) :: a
1307 real(kind=
rp),
dimension(n),
intent(in) :: b
1309 real(kind=
xp) :: tmp
1315 tmp = tmp + a(i) * b(i)
1319 call mpi_allreduce(mpi_in_place, tmp, 1, &
1326 integer,
intent(in) :: n
1327 real(kind=
rp),
dimension(n),
intent(in) :: a
1328 real(kind=
rp),
dimension(n),
intent(in) :: b
1329 real(kind=
rp),
dimension(n),
intent(in) :: c
1331 real(kind=
xp) :: tmp
1337 tmp = tmp + a(i) * b(i) * c(i)
1341 call mpi_allreduce(mpi_in_place, tmp, 1, &
1347 integer,
intent(in) :: n
1348 real(kind=
rp),
dimension(n),
intent(in) :: a
1349 real(kind=
rp),
dimension(n),
intent(in) :: b
1350 real(kind=
rp),
dimension(n),
intent(in) :: c
1351 real(kind=
rp),
dimension(n),
intent(in) :: d
1353 real(kind=
xp) :: tmp
1359 tmp = tmp + a(i) * b(i) * c(i) * d(i)
1363 call mpi_allreduce(mpi_in_place, tmp, 1, &
1372 integer,
intent(in) :: n
1373 real(kind=
rp),
dimension(n),
intent(in) :: a
1374 real(kind=
rp),
dimension(n),
intent(in) :: b
1376 real(kind=
xp) :: tmp
1382 tmp = tmp + (a(i) - b(i))**2
1386 call mpi_allreduce(mpi_in_place, tmp, 1, &
1398 integer,
intent(in) :: n
1399 real(kind=
rp),
intent(inout) :: a(n)
1400 integer,
intent(out) :: ind(n)
1402 integer :: j, ir, i, ii, l
1408 if (n .le. 1)
return
1432 do while (j .le. ir)
1434 if ( a(j) .lt. a(j+1) ) j = j + 1
1436 if (aa .lt. a(j))
then
1456 integer,
intent(in) :: n
1457 integer(i4),
intent(inout) :: a(n)
1458 integer,
intent(out) :: ind(n)
1460 integer :: j, ir, i, ii, l
1466 if (n .le. 1)
return
1489 do while (j .le. ir)
1491 if ( a(j) .lt. a(j + 1) ) j = j + 1
1493 if (aa .lt. a(j))
then
1512 integer,
intent(in) :: n
1513 real(kind=
rp),
intent(inout) :: b(n)
1514 integer,
intent(in) :: ind(n)
1515 real(kind=
rp) :: temp(n)
1539 integer,
intent(in) :: n
1540 integer(i4),
intent(inout) :: b(n)
1541 integer,
intent(in) :: ind(n)
1542 integer(i4) :: temp(n)
1566 integer,
intent(in) :: n
1567 real(kind=
rp),
intent(inout) :: b(n)
1568 integer,
intent(in) :: ind(n)
1569 real(kind=
rp) :: temp(n)
1593 integer,
intent(in) :: n
1594 integer(i4),
intent(inout) :: b(n)
1595 integer,
intent(in) :: ind(n)
1596 integer(i4) :: temp(n)
1620 integer,
intent(in) :: n
1621 real(kind=
rp),
intent(inout) :: b(n)
1622 integer,
intent(inout) :: ind(n)
1623 real(kind=
rp) :: temp(n)
1624 integer :: tempind(n)
1632 tempind(jj) = ind(i)
1650 integer,
intent(in) :: n
1651 integer(i4),
intent(inout) :: b(n)
1652 integer,
intent(inout) :: ind(n)
1653 integer(i4) :: temp(n)
1654 integer :: tempind(n)
1662 tempind(jj) = ind(i)
1679 integer,
intent(in) :: n
1680 real(kind=
rp),
dimension(n),
intent(inout) :: a
1696 integer,
intent(in) :: n
1697 real(kind=
rp),
dimension(n),
intent(inout) :: a
1698 real(kind=
rp),
dimension(n),
intent(in) :: b
1703 a(i) =
max(a(i), b(i))
1711 integer,
intent(in) :: n
1712 real(kind=
rp),
dimension(n),
intent(inout) :: a
1713 real(kind=
rp),
dimension(n),
intent(in) :: b, c
1718 a(i) =
max(b(i), c(i))
1726 integer,
intent(in) :: n
1727 real(kind=
rp),
dimension(n),
intent(inout) :: a
1728 real(kind=
rp),
intent(in) :: b
1741 integer,
intent(in) :: n
1742 real(kind=
rp),
dimension(n),
intent(inout) :: a
1743 real(kind=
rp),
dimension(n),
intent(in) :: b
1744 real(kind=
rp),
intent(in) :: c
1757 integer,
intent(in) :: n
1758 real(kind=
rp),
dimension(n),
intent(inout) :: a
1759 real(kind=
rp),
dimension(n),
intent(in) :: b
1764 a(i) = min(a(i), b(i))
1772 integer,
intent(in) :: n
1773 real(kind=
rp),
dimension(n),
intent(inout) :: a
1774 real(kind=
rp),
dimension(n),
intent(in) :: b, c
1779 a(i) = min(b(i), c(i))
1787 integer,
intent(in) :: n
1788 real(kind=
rp),
dimension(n),
intent(inout) :: a
1789 real(kind=
rp),
intent(in) :: b
1802 integer,
intent(in) :: n
1803 real(kind=
rp),
dimension(n),
intent(inout) :: a
1804 real(kind=
rp),
dimension(n),
intent(in) :: b
1805 real(kind=
rp),
intent(in) :: c
1819 function matinv39(a11, a12, a13, a21, a22, a23, a31, a32, a33) &
1821 real(kind=
rp),
intent(in) :: a11, a12, a13, a21, a22, a23, a31, a32, a33
1842 real(kind=
xp),
intent(in) :: a(3,3)
1843 real(kind=
xp) :: b(3,3)
1844 real(kind=
xp) :: detinv
1848 detinv = 1.0_xp /
real(a(1,1)*a(2,2)*a(3,3) - a(1,1)*a(2,3)*a(3,2) &
1849 - a(1,2)*a(2,1)*a(3,3) + a(1,2)*a(2,3)*a(3,1)&
1850 + a(1,3)*a(2,1)*a(3,2) - a(1,3)*a(2,2)*a(3,1),
xp)
1853 b(1,1) = +detinv * (a(2,2)*a(3,3) - a(2,3)*a(3,2))
1854 b(2,1) = -detinv * (a(2,1)*a(3,3) - a(2,3)*a(3,1))
1855 b(3,1) = +detinv * (a(2,1)*a(3,2) - a(2,2)*a(3,1))
1856 b(1,2) = -detinv * (a(1,2)*a(3,3) - a(1,3)*a(3,2))
1857 b(2,2) = +detinv * (a(1,1)*a(3,3) - a(1,3)*a(3,1))
1858 b(3,2) = -detinv * (a(1,1)*a(3,2) - a(1,2)*a(3,1))
1859 b(1,3) = +detinv * (a(1,2)*a(2,3) - a(1,3)*a(2,2))
1860 b(2,3) = -detinv * (a(1,1)*a(2,3) - a(1,3)*a(2,1))
1861 b(3,3) = +detinv * (a(1,1)*a(2,2) - a(1,2)*a(2,1))
1867 real(kind=
rp),
intent(in) :: x
1868 real(kind=
rp) :: val
1869 real(kind=
rp),
parameter :: xdmin = 0.0001_rp
1870 real(kind=
rp),
parameter :: xdmax = 0.9999_rp
1873 if (x <= xdmin)
then
1876 else if (x >= xdmax)
then
1881 g = (1.0_rp / (x - 1.0_rp)) + (1.0_rp / x)
1884 val = 1.0_rp / (1.0_rp + exp(g))
1890 real(kind=
rp),
intent(in) :: x
1891 real(kind=
rp) :: val
1892 real(kind=
rp),
parameter :: xdmin = 0.0001_rp
1893 real(kind=
rp),
parameter :: xdmax = 0.9999_rp
1894 real(kind=
rp) :: arg, g, dg, s_val
1896 if (x <= xdmin .or. x >= xdmax)
then
1903 g = (1.0_rp / (x - 1.0_rp)) + (1.0_rp / x)
1906 dg = -(1.0_rp / ((x - 1.0_rp)**2)) - (1.0_rp / (x**2))
1909 s_val = 1.0_rp / (1.0_rp + exp(g))
1911 val = -s_val * (1.0_rp - s_val) * dg
1917 integer,
intent(in) :: n
1918 real(kind=
rp),
dimension(n),
intent(inout) :: a
1931 integer,
intent(in) :: n
1932 real(kind=
rp),
dimension(n),
intent(inout) :: ap
1933 real(kind=
rp),
dimension(n),
intent(in) :: a
1934 real(kind=
rp),
intent(in) :: p
1943 end subroutine power
1952 real(kind=
dp),
intent(in) :: a11, a22, a12
1953 real(kind=
dp),
intent(out) :: e1, e2
1954 real(kind=
dp) :: t, d, s
1957 d = a11 * a22 - a12 * a12
1958 s = sqrt(
max(0.0_dp, 0.25_dp * t * t - d))
1961 if (e1 .gt. 0.0_dp)
then
2002 pure subroutine eig_sym3(a11, a22, a33, a12, a13, a23, e1, e2, e3)
2003 real(kind=
dp),
intent(in) :: a11, a22, a33, a12, a13, a23
2004 real(kind=
dp),
intent(out) :: e1, e2, e3
2005 real(kind=
dp) :: p1, p2, q, p, r, phi
2006 real(kind=
dp) :: b11, b22, b33, b12, b13, b23
2007 real(kind=
dp),
parameter :: third = 1.0_dp / 3.0_dp
2008 real(kind=
dp),
parameter :: pi_third = 1.0471975511965976_dp
2009 real(kind=
dp),
parameter :: twopi_third = 2.0943951023931953_dp
2011 p1 = a12 * a12 + a13 * a13 + a23 * a23
2013 q = (a11 + a22 + a33) * third
2014 p2 = (a11 - q)**2 + (a22 - q)**2 + (a33 - q)**2 + 2.0_dp * p1
2015 p = sqrt(p2 / 6.0_dp)
2017 if (p .le. 0.0_dp)
then
2019 e1 =
max(a11,
max(a22, a33))
2020 e3 = min(a11, min(a22, a33))
2021 e2 = a11 + a22 + a33 - e1 - e3
2032 r = 0.5_dp * (b11 * (b22 * b33 - b23 * b23) &
2033 - b12 * (b12 * b33 - b23 * b13) &
2034 + b13 * (b12 * b23 - b22 * b13))
2037 if (r .le. -1.0_dp)
then
2039 else if (r .ge. 1.0_dp)
then
2042 phi = acos(r) * third
2045 e1 = q + 2.0_dp * p * cos(phi)
2046 e3 = q + 2.0_dp * p * cos(phi + twopi_third)
2047 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 .
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 .
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.