10 implicit none ;
private
50 integer,
intent(in) :: n
51 real,
dimension(:),
intent(in) :: h
52 real,
dimension(:),
intent(in) :: u
53 real,
dimension(:,:),
intent(inout) :: edge_slopes
54 real,
optional,
intent(in) :: h_neglect
55 logical,
optional,
intent(in) :: answers_2018
59 real :: h0_2, h1_2, h0h1
64 real,
parameter :: c1_12 = 1.0 / 12.0
65 real,
dimension(5) :: x
67 real,
dimension(4,4) :: asys
68 real,
dimension(4) :: bsys, csys
69 real,
dimension(3) :: dsys
70 real,
dimension(N+1) :: tri_l, &
77 logical :: use_2018_answers
79 hneglect =
hneglect_dflt ;
if (
present(h_neglect)) hneglect = h_neglect
80 hneglect3 = hneglect**3
81 use_2018_answers = .true. ;
if (
present(answers_2018)) use_2018_answers = answers_2018
97 d = 4.0 * h0h1 * ( h0 + h1 ) + h1_3 + h0_3
100 alpha = h1 * (h0_2 + h0h1 - h1_2) / ( d + hneglect3 )
101 beta = h0 * (h1_2 + h0h1 - h0_2) / ( d + hneglect3 )
102 a = -12.0 * h0h1 / ( d + hneglect3 )
109 tri_b(i+1) = a * u(i) + b * u(i+1)
116 x(i) = x(i-1) + h(i-1)
121 if (use_2018_answers)
then
122 do j = 1,4 ; asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j ;
enddo
124 xavg = 0.5 * (x(i+1) + x(i))
126 asys(i,2) = dx * xavg
127 asys(i,3) = dx * (xavg**2 + c1_12*dx**2)
128 asys(i,4) = dx * xavg * (xavg**2 + 0.25*dx**2)
138 dsys(2) = 2.0 * csys(3)
139 dsys(3) = 3.0 * csys(4)
148 x(i) = x(i-1) + h(n-5+i)
153 if (use_2018_answers)
then
154 do j = 1,4 ; asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j ;
enddo
156 xavg = 0.5 * (x(i+1) + x(i))
158 asys(i,2) = dx * xavg
159 asys(i,3) = dx * (xavg**2 + c1_12*dx**2)
160 asys(i,4) = dx * xavg * (xavg**2 + 0.25*dx**2)
162 bsys(i) = u(n-4+i) * dx
169 dsys(2) = 2.0 * csys(3)
170 dsys(3) = 3.0 * csys(4)
180 edge_slopes(i,1) = tri_x(i)
181 edge_slopes(i-1,2) = tri_x(i)
183 edge_slopes(1,1) = tri_x(1)
184 edge_slopes(n,2) = tri_x(n+1)
192 integer,
intent(in) :: n
193 real,
dimension(:),
intent(in) :: h
194 real,
dimension(:),
intent(in) :: u
195 real,
dimension(:,:),
intent(inout) :: edge_slopes
196 real,
optional,
intent(in) :: h_neglect
197 logical,
optional,
intent(in) :: answers_2018
233 real :: h0, h1, h2, h3
235 real :: g_4, g_5, g_6
236 real :: d2, d3, d4, d5, d6
237 real :: n2, n3, n4, n5, n6
243 real :: h0ph1, h0ph1_2
244 real :: h0ph1_3, h0ph1_4
245 real :: h2ph3, h2ph3_2
246 real :: h2ph3_3, h2ph3_4
249 real,
dimension(7) :: x
250 real,
parameter :: c1_12 = 1.0 / 12.0
251 real,
parameter :: c5_6 = 5.0 / 6.0
253 real,
dimension(6,6) :: asys
254 real,
dimension(6) :: bsys, csys
255 real,
dimension(5) :: dsys
256 real,
dimension(N+1) :: tri_l, &
262 logical :: use_2018_answers
264 hneglect =
hneglect_dflt ;
if (
present(h_neglect)) hneglect = h_neglect
265 use_2018_answers = .true. ;
if (
present(answers_2018)) use_2018_answers = answers_2018
296 d2 = ( h1_2 - g_2 ) / ( h0 + hneglect )
297 d3 = ( h1_3 - g_3 ) / ( h0 + hneglect )
298 d4 = ( h1_4 - g_4 ) / ( h0 + hneglect )
299 d5 = ( h1_5 - g_5 ) / ( h0 + hneglect )
300 d6 = ( h1_6 - g_6 ) / ( h0 + hneglect )
309 n2 = ( g_2 - h2_2 ) / ( h3 + hneglect )
310 n3 = ( g_3 - h2_3 ) / ( h3 + hneglect )
311 n4 = ( g_4 - h2_4 ) / ( h3 + hneglect )
312 n5 = ( g_5 - h2_5 ) / ( h3 + hneglect )
313 n6 = ( g_6 - h2_6 ) / ( h3 + hneglect )
325 asys(2,3) = -0.5 * d2
327 asys(2,5) = -0.5 * h2
328 asys(2,6) = -0.5 * n2
332 asys(3,3) = - d3 / 6.0
333 asys(3,4) = h1_2 / 6.0
334 asys(3,5) = h2_2 / 6.0
337 asys(4,1) = - h1_2 / 2.0
338 asys(4,2) = - h2_2 / 2.0
339 asys(4,3) = d4 / 24.0
340 asys(4,4) = - h1_3 / 24.0
341 asys(4,5) = h2_3 / 24.0
342 asys(4,6) = n4 / 24.0
344 asys(5,1) = h1_3 / 6.0
345 asys(5,2) = - h2_3 / 6.0
346 asys(5,3) = - d5 / 120.0
347 asys(5,4) = h1_4 / 120.0
348 asys(5,5) = h2_4 / 120.0
349 asys(5,6) = n5 / 120.0
351 asys(6,1) = - h1_4 / 24.0
352 asys(6,2) = - h2_4 / 24.0
353 asys(6,3) = d6 / 720.0
354 asys(6,4) = - h1_5 / 720.0
355 asys(6,5) = h2_5 / 720.0
356 asys(6,6) = n6 / 720.0
358 bsys(:) = (/ 0.0, -1.0, 0.0, 0.0, 0.0, 0.0 /)
372 tri_b(k+1) = a * u(k-1) + b * u(k) + c * u(k+1) + d * u(k+2)
405 h0ph1_2 = h0ph1 * h0ph1
406 h0ph1_3 = h0ph1_2 * h0ph1
407 h0ph1_4 = h0ph1_2 * h0ph1_2
409 d2 = ( h1_2 - g_2 ) / ( h0 + hneglect )
410 d3 = ( h1_3 - g_3 ) / ( h0 + hneglect )
411 d4 = ( h1_4 - g_4 ) / ( h0 + hneglect )
412 d5 = ( h1_5 - g_5 ) / ( h0 + hneglect )
413 d6 = ( h1_6 - g_6 ) / ( h0 + hneglect )
422 n2 = ( g_2 - h2_2 ) / ( h3 + hneglect )
423 n3 = ( g_3 - h2_3 ) / ( h3 + hneglect )
424 n4 = ( g_4 - h2_4 ) / ( h3 + hneglect )
425 n5 = ( g_5 - h2_5 ) / ( h3 + hneglect )
426 n6 = ( g_6 - h2_6 ) / ( h3 + hneglect )
438 asys(2,3) = -0.5 * d2
440 asys(2,5) = -0.5 * h2
441 asys(2,6) = -0.5 * n2
445 asys(3,3) = - d3 / 6.0
446 asys(3,4) = h1_2 / 6.0
447 asys(3,5) = h2_2 / 6.0
450 asys(4,1) = - h0ph1_2 / 2.0
452 asys(4,3) = d4 / 24.0
453 asys(4,4) = - h1_3 / 24.0
454 asys(4,5) = h2_3 / 24.0
455 asys(4,6) = n4 / 24.0
457 asys(5,1) = h0ph1_3 / 6.0
459 asys(5,3) = - d5 / 120.0
460 asys(5,4) = h1_4 / 120.0
461 asys(5,5) = h2_4 / 120.0
462 asys(5,6) = n5 / 120.0
464 asys(6,1) = - h0ph1_4 / 24.0
466 asys(6,3) = d6 / 720.0
467 asys(6,4) = - h1_5 / 720.0
468 asys(6,5) = h2_5 / 720.0
469 asys(6,6) = n6 / 720.0
471 bsys(:) = (/ 0.0, -1.0, -h1, h1_2/2.0, -h1_3/6.0, h1_4/24.0 /)
485 tri_b(2) = a * u(1) + b * u(2) + c * u(3) + d * u(4)
490 x(i) = x(i-1) + h(i-1)
496 if (use_2018_answers)
then
497 do j = 1,6 ; asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j ;
enddo
499 xavg = 0.5 * (x(i+1) + x(i))
501 asys(i,2) = dx * xavg
502 asys(i,3) = dx * (xavg**2 + c1_12*dx**2)
503 asys(i,4) = dx * xavg * (xavg**2 + 0.25*dx**2)
504 asys(i,5) = dx * (xavg**4 + 0.5*xavg**2*dx**2 + 0.0125*dx**4)
505 asys(i,6) = dx * xavg * (xavg**4 + c5_6*xavg**2*dx**2 + 0.0625*dx**4)
515 dsys(2) = 2.0 * csys(3)
516 dsys(3) = 3.0 * csys(4)
517 dsys(4) = 4.0 * csys(5)
518 dsys(5) = 5.0 * csys(6)
554 h2ph3_2 = h2ph3 * h2ph3
555 h2ph3_3 = h2ph3_2 * h2ph3
556 h2ph3_4 = h2ph3_2 * h2ph3_2
558 d2 = ( h1_2 - g_2 ) / ( h0 + hneglect )
559 d3 = ( h1_3 - g_3 ) / ( h0 + hneglect )
560 d4 = ( h1_4 - g_4 ) / ( h0 + hneglect )
561 d5 = ( h1_5 - g_5 ) / ( h0 + hneglect )
562 d6 = ( h1_6 - g_6 ) / ( h0 + hneglect )
571 n2 = ( g_2 - h2_2 ) / ( h3 + hneglect )
572 n3 = ( g_3 - h2_3 ) / ( h3 + hneglect )
573 n4 = ( g_4 - h2_4 ) / ( h3 + hneglect )
574 n5 = ( g_5 - h2_5 ) / ( h3 + hneglect )
575 n6 = ( g_6 - h2_6 ) / ( h3 + hneglect )
587 asys(2,3) = -0.5 * d2
589 asys(2,5) = -0.5 * h2
590 asys(2,6) = -0.5 * n2
594 asys(3,3) = - d3 / 6.0
595 asys(3,4) = h1_2 / 6.0
596 asys(3,5) = h2_2 / 6.0
600 asys(4,2) = - h2ph3_2 / 2.0
601 asys(4,3) = d4 / 24.0
602 asys(4,4) = - h1_3 / 24.0
603 asys(4,5) = h2_3 / 24.0
604 asys(4,6) = n4 / 24.0
607 asys(5,2) = - h2ph3_3 / 6.0
608 asys(5,3) = - d5 / 120.0
609 asys(5,4) = h1_4 / 120.0
610 asys(5,5) = h2_4 / 120.0
611 asys(5,6) = n5 / 120.0
614 asys(6,2) = - h2ph3_4 / 24.0
615 asys(6,3) = d6 / 720.0
616 asys(6,4) = - h1_5 / 720.0
617 asys(6,5) = h2_5 / 720.0
618 asys(6,6) = n6 / 720.0
620 bsys(:) = (/ 0.0, -1.0, h2, h2_2/2.0, h2_3/6.0, h2_4/24.0 /)
634 tri_b(n) = a * u(n-3) + b * u(n-2) + c * u(n-1) + d * u(n)
639 x(i) = x(i-1) + h(n-7+i)
644 if (use_2018_answers)
then
645 do j = 1,6 ; asys(i,j) = ( (x(i+1)**j) - (x(i)**j) ) / j ;
enddo
647 xavg = 0.5 * (x(i+1) + x(i))
649 asys(i,2) = dx * xavg
650 asys(i,3) = dx * (xavg**2 + c1_12*dx**2)
651 asys(i,4) = dx * xavg * (xavg**2 + 0.25*dx**2)
652 asys(i,5) = dx * (xavg**4 + 0.5*xavg**2*dx**2 + 0.0125*dx**4)
653 asys(i,6) = dx * xavg * (xavg**4 + c5_6*xavg**2*dx**2 + 0.0625*dx**4)
655 bsys(i) = u(n-6+i) * dx
661 dsys(2) = 2.0 * csys(3)
662 dsys(3) = 3.0 * csys(4)
663 dsys(4) = 4.0 * csys(5)
664 dsys(5) = 5.0 * csys(6)
675 edge_slopes(i,1) = tri_x(i)
676 edge_slopes(i-1,2) = tri_x(i)
678 edge_slopes(1,1) = tri_x(1)
679 edge_slopes(n,2) = tri_x(n+1)