16 implicit none ;
private 29 #undef __DO_SAFETY_CHECKS__ 56 integer,
intent(in) :: N
57 real,
dimension(:),
intent(in) :: h
58 real,
dimension(:),
intent(in) :: u
59 real,
dimension(:,:),
intent(inout) :: edge_values
67 real :: sigma_l, sigma_c, sigma_r
84 else if ( k .EQ. n )
then 103 u0_l = edge_values(k,1)
104 u0_r = edge_values(k,2)
106 sigma_l = 2.0 * ( u_c - u_l ) / ( h_c + 1.e-30 )
107 sigma_c = 2.0 * ( u_r - u_l ) / ( h_l + 2.0*h_c + h_r + 1.e-30 )
108 sigma_r = 2.0 * ( u_r - u_c ) / ( h_c + 1.e-30 )
110 if ( (sigma_l * sigma_r) .GT. 0.0 )
then 111 slope = sign( min(abs(sigma_l),abs(sigma_c),abs(sigma_r)), sigma_c )
120 slope = slope * h_c * 0.5
122 if ( (u_l-u0_l)*(u0_l-u_c) .LT. 0.0 )
then 123 u0_l = u_c - sign( min( abs(slope), abs(u0_l-u_c) ), slope )
126 if ( (u_r-u0_r)*(u0_r-u_c) .LT. 0.0 )
then 127 u0_r = u_c + sign( min( abs(slope), abs(u0_r-u_c) ), slope )
131 u0_l = max( min( u0_l, max(u_l, u_c) ), min(u_l, u_c) )
132 u0_r = max( min( u0_r, max(u_r, u_c) ), min(u_r, u_c) )
135 edge_values(k,1) = u0_l
136 edge_values(k,2) = u0_r
153 integer,
intent(in) :: N
154 real,
dimension(:,:),
intent(inout) :: edge_values
166 u0_minus = edge_values(k,2)
169 u0_plus = edge_values(k+1,1)
171 if ( u0_minus .NE. u0_plus )
then 172 u0_avg = 0.5 * ( u0_minus + u0_plus )
173 edge_values(k,2) = u0_avg
174 edge_values(k+1,1) = u0_avg
192 integer,
intent(in) :: N
193 real,
dimension(:),
intent(in) :: u
194 real,
dimension(:,:),
intent(inout) :: edge_values
208 u0_minus = edge_values(k,2)
211 u0_plus = edge_values(k+1,1)
219 if ( (u0_plus - u0_minus)*(um_plus - um_minus) .LT. 0.0 )
then 220 u0_avg = 0.5 * ( u0_minus + u0_plus )
221 u0_avg = max( min( u0_avg, max(um_minus, um_plus) ), min(um_minus, um_plus) )
222 edge_values(k,2) = u0_avg
223 edge_values(k+1,1) = u0_avg
249 integer,
intent(in) :: N
250 real,
dimension(:),
intent(in) :: h
251 real,
dimension(:),
intent(in) :: u
252 real,
dimension(:,:),
intent(inout) :: edge_values
275 edge_values(k,1) = ( u0*h1 + u1*h0 ) / ( h0 + h1 )
279 edge_values(k-1,2) = edge_values(k,1)
284 edge_values(1,1) = u(1)
285 edge_values(n,2) = u(n)
314 integer,
intent(in) :: N
315 real,
dimension(:),
intent(in) :: h
316 real,
dimension(:),
intent(in) :: u
317 real,
dimension(:,:),
intent(inout) :: edge_values
321 real :: u0, u1, u2, u3
322 real :: h0, h1, h2, h3
325 real,
dimension(5) :: x
326 real,
dimension(4,4) :: A
327 real,
dimension(4) :: B, C
338 if (h0+h1==0. .or. h1+h2==0. .or. h2+h3==0.)
then 351 f1 = (h0+h1) * (h2+h3) / (h1+h2)
352 f2 = u1 * h2 + u2 * h1
353 f3 = 1.0 / (h0+h1+h2) + 1.0 / (h1+h2+h3)
357 f1 = h2 * (h2+h3) / ( (h0+h1+h2)*(h0+h1) )
358 f2 = u1*(h0+2.0*h1) - u0*h1
362 f1 = h1 * (h0+h1) / ( (h1+h2+h3)*(h2+h3) )
363 f2 = u2*(2.0*h2+h3) - u3*h2
367 e = e / ( h0 + h1 + h2 + h3)
370 edge_values(i-1,2) = e
372 #ifdef __DO_SAFETY_CHECKS__ 374 write(0,*)
'NaN in explicit_edge_h4 at k=',i
375 write(0,*)
'u0-u3=',u0,u1,u2,u3
376 write(0,*)
'h0-h3=',h0,h1,h2,h3
377 write(0,*)
'f1-f3=',f1,f2,f3
378 stop
'Nan during edge_values_explicit_h4' 388 x(i) = x(i-1) + max(f1, h(i-1))
394 a(i,j) = ( (x(i+1)**j) - (x(i)**j) ) /
real(j)
397 b(i) = u(i) * max(f1, h(i) )
408 edge_values(2,1) = edge_values(1,2)
410 #ifdef __DO_SAFETY_CHECKS__ 411 if (edge_values(1,1) /= edge_values(1,1) .or. edge_values(1,2) /= edge_values(1,2))
then 412 write(0,*)
'NaN in explicit_edge_h4 at k=',1
416 write(0,*)
'h(1:4)=',h(1:4)
418 stop
'Nan during edge_values_explicit_h4' 426 x(i) = x(i-1) + max(f1, h(n-5+i))
432 a(i,j) = ( (x(i+1)**j) - (x(i)**j) ) /
real(j)
435 b(i) = u(n-4+i) * max(f1, h(n-4+i) )
446 edge_values(n-1,2) = edge_values(n,1)
448 #ifdef __DO_SAFETY_CHECKS__ 449 if (edge_values(n,1) /= edge_values(n,1) .or. edge_values(n,2) /= edge_values(n,2))
then 450 write(0,*)
'NaN in explicit_edge_h4 at k=',n
454 a(i,j) = ( (x(i+1)**j) - (x(i)**j) ) /
real(j)
457 b(i) = u(n-4+i) * ( h(n-4+i) )
461 write(0,*)
'h(:N)=',h(n-3:n)
463 stop
'Nan during edge_values_explicit_h4' 499 integer,
intent(in) :: N
500 real,
dimension(:),
intent(in) :: h
501 real,
dimension(:),
intent(in) :: u
502 real,
dimension(:,:),
intent(inout) :: edge_values
507 real :: h0_2, h1_2, h0h1
511 real,
dimension(5) :: x
512 real,
dimension(4,4) :: Asys
513 real,
dimension(4) :: Bsys, Csys
514 real,
dimension(N+1) :: tri_l, &
543 a = 2.0 * h1_2 * ( h1_2 + 2.0 * h0_2 + 3.0 * h0h1 ) / d4
544 b = 2.0 * h0_2 * ( h0_2 + 2.0 * h1_2 + 3.0 * h0h1 ) / d4
550 tri_b(i+1) = a * u(i) + b * u(i+1)
558 x(i) = x(i-1) + max( h0, h(i-1) )
564 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
567 bsys(i) = u(i) * max( h0, h(i) )
581 x(i) = x(i-1) + max( h0, h(n-5+i) )
587 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
590 bsys(i) = u(n-4+i) * max( h0, h(n-4+i) )
604 edge_values(i,1) = tri_x(i)
605 edge_values(i-1,2) = tri_x(i)
607 edge_values(1,1) = tri_x(1)
608 edge_values(n,2) = tri_x(n+1)
651 integer,
intent(in) :: N
652 real,
dimension(:),
intent(in) :: h
653 real,
dimension(:),
intent(in) :: u
654 real,
dimension(:,:),
intent(inout) :: edge_values
658 real :: h0, h1, h2, h3
660 real :: g_4, g_5, g_6
661 real :: d2, d3, d4, d5, d6
662 real :: n2, n3, n4, n5, n6
668 real :: h0ph1, h0ph1_2
669 real :: h0ph1_3, h0ph1_4
670 real :: h2ph3, h2ph3_2
671 real :: h2ph3_3, h2ph3_4
672 real :: h0ph1_5, h2ph3_5
675 real,
dimension(7) :: x
676 real,
dimension(6,6) :: Asys
677 real,
dimension(6) :: Bsys, Csys
678 real,
dimension(N+1) :: tri_l, &
722 d2 = ( h1_2 - g_2 ) / h0
723 d3 = ( h1_3 - g_3 ) / h0
724 d4 = ( h1_4 - g_4 ) / h0
725 d5 = ( h1_5 - g_5 ) / h0
726 d6 = ( h1_6 - g_6 ) / h0
735 n2 = ( g_2 - h2_2 ) / h3
736 n3 = ( g_3 - h2_3 ) / h3
737 n4 = ( g_4 - h2_4 ) / h3
738 n5 = ( g_5 - h2_5 ) / h3
739 n6 = ( g_6 - h2_6 ) / h3
751 asys(2,3) = -0.5 * d2
753 asys(2,5) = -0.5 * h2
754 asys(2,6) = -0.5 * n2
756 asys(3,1) = 0.5 * h1_2
757 asys(3,2) = 0.5 * h2_2
759 asys(3,4) = - h1_2 / 6.0
760 asys(3,5) = - h2_2 / 6.0
761 asys(3,6) = - n3 / 6.0
763 asys(4,1) = - h1_3 / 6.0
764 asys(4,2) = h2_3 / 6.0
765 asys(4,3) = - d4 / 24.0
766 asys(4,4) = h1_3 / 24.0
767 asys(4,5) = - h2_3 / 24.0
768 asys(4,6) = - n4 / 24.0
770 asys(5,1) = h1_4 / 24.0
771 asys(5,2) = h2_4 / 24.0
772 asys(5,3) = d5 / 120.0
773 asys(5,4) = - h1_4 / 120.0
774 asys(5,5) = - h2_4 / 120.0
775 asys(5,6) = - n5 / 120.0
777 asys(6,1) = - h1_5 / 120.0
778 asys(6,2) = h2_5 / 120.0
779 asys(6,3) = - d6 / 720.0
780 asys(6,4) = h1_5 / 720.0
781 asys(6,5) = - h2_5 / 720.0
782 asys(6,6) = - n6 / 720.0
784 bsys(:) = (/ -1.0, 0.0, 0.0, 0.0, 0.0, 0.0 /)
798 tri_b(k+1) = a * u(k-1) + b * u(k) + c * u(k+1) + d * u(k+2)
840 h0ph1_2 = h0ph1 * h0ph1
841 h0ph1_3 = h0ph1_2 * h0ph1
842 h0ph1_4 = h0ph1_2 * h0ph1_2
843 h0ph1_5 = h0ph1_3 * h0ph1_2
845 d2 = ( h1_2 - g_2 ) / h0
846 d3 = ( h1_3 - g_3 ) / h0
847 d4 = ( h1_4 - g_4 ) / h0
848 d5 = ( h1_5 - g_5 ) / h0
849 d6 = ( h1_6 - g_6 ) / h0
858 n2 = ( g_2 - h2_2 ) / h3
859 n3 = ( g_3 - h2_3 ) / h3
860 n4 = ( g_4 - h2_4 ) / h3
861 n5 = ( g_5 - h2_5 ) / h3
862 n6 = ( g_6 - h2_6 ) / h3
874 asys(2,3) = -0.5 * d2
876 asys(2,5) = -0.5 * h2
877 asys(2,6) = -0.5 * n2
879 asys(3,1) = 0.5 * h0ph1_2
882 asys(3,4) = - h1_2 / 6.0
883 asys(3,5) = - h2_2 / 6.0
884 asys(3,6) = - n3 / 6.0
886 asys(4,1) = - h0ph1_3 / 6.0
888 asys(4,3) = - d4 / 24.0
889 asys(4,4) = h1_3 / 24.0
890 asys(4,5) = - h2_3 / 24.0
891 asys(4,6) = - n4 / 24.0
893 asys(5,1) = h0ph1_4 / 24.0
895 asys(5,3) = d5 / 120.0
896 asys(5,4) = - h1_4 / 120.0
897 asys(5,5) = - h2_4 / 120.0
898 asys(5,6) = - n5 / 120.0
900 asys(6,1) = - h0ph1_5 / 120.0
902 asys(6,3) = - d6 / 720.0
903 asys(6,4) = h1_5 / 720.0
904 asys(6,5) = - h2_5 / 720.0
905 asys(6,6) = - n6 / 720.0
907 bsys(:) = (/ -1.0, h1, -0.5*h1_2, h1_3/6.0, -h1_4/24.0, h1_5/120.0 /)
921 tri_b(2) = a * u(1) + b * u(2) + c * u(3) + d * u(4)
927 x(i) = x(i-1) + max( g, h(i-1) )
933 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
936 bsys(i) = u(i) * max( g, h(i) )
985 h2ph3_2 = h2ph3 * h2ph3
986 h2ph3_3 = h2ph3_2 * h2ph3
987 h2ph3_4 = h2ph3_2 * h2ph3_2
988 h2ph3_5 = h2ph3_3 * h2ph3_2
990 d2 = ( h1_2 - g_2 ) / h0
991 d3 = ( h1_3 - g_3 ) / h0
992 d4 = ( h1_4 - g_4 ) / h0
993 d5 = ( h1_5 - g_5 ) / h0
994 d6 = ( h1_6 - g_6 ) / h0
1003 n2 = ( g_2 - h2_2 ) / h3
1004 n3 = ( g_3 - h2_3 ) / h3
1005 n4 = ( g_4 - h2_4 ) / h3
1006 n5 = ( g_5 - h2_5 ) / h3
1007 n6 = ( g_6 - h2_6 ) / h3
1019 asys(2,3) = -0.5 * d2
1020 asys(2,4) = 0.5 * h1
1021 asys(2,5) = -0.5 * h2
1022 asys(2,6) = -0.5 * n2
1025 asys(3,2) = 0.5 * h2ph3_2
1026 asys(3,3) = d3 / 6.0
1027 asys(3,4) = - h1_2 / 6.0
1028 asys(3,5) = - h2_2 / 6.0
1029 asys(3,6) = - n3 / 6.0
1032 asys(4,2) = h2ph3_3 / 6.0
1033 asys(4,3) = - d4 / 24.0
1034 asys(4,4) = h1_3 / 24.0
1035 asys(4,5) = - h2_3 / 24.0
1036 asys(4,6) = - n4 / 24.0
1039 asys(5,2) = h2ph3_4 / 24.0
1040 asys(5,3) = d5 / 120.0
1041 asys(5,4) = - h1_4 / 120.0
1042 asys(5,5) = - h2_4 / 120.0
1043 asys(5,6) = - n5 / 120.0
1046 asys(6,2) = h2ph3_5 / 120.0
1047 asys(6,3) = - d6 / 720.0
1048 asys(6,4) = h1_5 / 720.0
1049 asys(6,5) = - h2_5 / 720.0
1050 asys(6,6) = - n6 / 720.0
1052 bsys(:) = (/ -1.0, -h2, -0.5*h2_2, -h2_3/6.0, -h2_4/24.0, -h2_5/120.0 /)
1066 tri_b(n) = a * u(n-3) + b * u(n-2) + c * u(n-1) + d * u(n)
1072 x(i) = x(i-1) + max( g, h(n-7+i) )
1078 asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j
1081 bsys(i) = u(n-6+i) * max( g, h(n-6+i) )
1096 edge_values(i,1) = tri_x(i)
1097 edge_values(i-1,2) = tri_x(i)
1099 edge_values(1,1) = tri_x(1)
1100 edge_values(n,2) = tri_x(n+1)
subroutine, public edge_values_implicit_h6(N, h, u, edge_values)
subroutine, public edge_values_implicit_h4(N, h, u, edge_values)
subroutine, public check_discontinuous_edge_values(N, u, edge_values)
subroutine, public average_discontinuous_edge_values(N, edge_values)
real, parameter hnegligible
subroutine, public solve_tridiagonal_system(Al, Ad, Au, B, X, system_size)
subroutine, public bound_edge_values(N, h, u, edge_values)
subroutine, public edge_values_explicit_h2(N, h, u, edge_values)
subroutine, public solve_linear_system(A, B, X, system_size)
subroutine, public edge_values_explicit_h4(N, h, u, edge_values)
real function, public evaluation_polynomial(coefficients, nb_coefficients, x)