@@ -1432,17 +1432,34 @@ subroutine UP3_Koren_limiter_reconstruction(q4,u,qr)
1432
1432
real , parameter :: C1_6 = 1.0 / 6.0 ! The ratio of 1/6 [nondim]
1433
1433
1434
1434
if (u> 0 .) then
1435
- theta = (q4(2 ) - q4(1 ))/ (q4(3 ) - q4(2 ) + 1e-20 )
1436
- psi = max (0 ., min (1 ., C1_3 + C1_6* theta, theta)) ! limiter introduced by Koren (1993)
1437
- qr = q4(2 ) + psi* (q4(3 ) - q4(2 ))
1435
+ if (q4(3 ) == q4(2 )) then
1436
+ qr = q4(2 )
1437
+ else
1438
+ theta = (q4(2 ) - q4(1 ))/ (q4(3 ) - q4(2 ))
1439
+ psi = max (0 ., min (1 ., C1_3 + C1_6* theta, theta)) ! limiter introduced by Koren (1993)
1440
+ qr = q4(2 ) + psi* (q4(3 ) - q4(2 ))
1441
+ endif
1438
1442
else
1439
- theta = (q4(4 ) - q4(3 ))/ (q4(3 ) - q4(2 ) + 1e-20 )
1440
- psi = max (0 ., min (1 ., C1_3 + C1_6* theta, theta))
1441
- qr = q4(3 ) + psi* (q4(2 ) - q4(3 ))
1443
+ if (q4(3 ) == q4(2 )) then
1444
+ qr = q4(3 )
1445
+ else
1446
+ theta = (q4(4 ) - q4(3 ))/ (q4(3 ) - q4(2 ))
1447
+ psi = max (0 ., min (1 ., C1_3 + C1_6* theta, theta))
1448
+ qr = q4(3 ) + psi* (q4(2 ) - q4(3 ))
1449
+ endif
1442
1450
endif
1443
1451
1444
1452
end subroutine UP3_Koren_limiter_reconstruction
1445
1453
1454
+ ! > Compute the factor for the WENO weights
1455
+ function fac_fn (tau , b ) result(fac)
1456
+ real , intent (in ) :: tau ! < Difference of the smoothness indicator [A ~> a]
1457
+ real , intent (in ) :: b ! < The smoothness indicator [A ~> a]
1458
+ real :: fac ! < The factor for the weight [nondim]
1459
+
1460
+ fac = (1 + tau / b)** 2 ; if (b == 0 .) fac = 1.0e40
1461
+
1462
+ end function fac_fn
1446
1463
1447
1464
1448
1465
! > Reconstruct the tracer (e.g., PV, vorticity) onto the point i-1/2 using a third-order WENO scheme
@@ -1463,7 +1480,7 @@ subroutine weno_three_h_weight_reconstruction(q4, h4, u4, &
1463
1480
real :: c0, c1 ! Intermediate reconstruction of q [A ~> a]
1464
1481
real :: d0, d1 ! Intermediate reconstruction of h [L ~> m]
1465
1482
real :: b0, b1 ! Smoothness indicator [A ~> a]
1466
- real :: tau ! Temporary variables [nondim ]
1483
+ real :: tau ! Difference of smoothness indicator [A ~> a ]
1467
1484
real :: w0, w1 ! Weights [nondim]
1468
1485
real :: s ! Temporary variables [nondim]
1469
1486
real , parameter :: C2_3 = 2.0 / 3.0 ! The ratio of 2/3 [nondim]
@@ -1498,8 +1515,8 @@ subroutine weno_three_h_weight_reconstruction(q4, h4, u4, &
1498
1515
endif
1499
1516
1500
1517
tau = abs (b0- b1)
1501
- w0 = C2_3 * ( 1 + ( tau / (b0 + 1e-20 )) ** 2 )
1502
- w1 = C1_3 * ( 1 + ( tau / (b1 + 1e-20 )) ** 2 )
1518
+ w0 = C2_3 * fac_fn( tau, b0)
1519
+ w1 = C1_3 * fac_fn( tau, b1 )
1503
1520
1504
1521
s = 1 . / (w0 + w1)
1505
1522
w0 = w0 * s
@@ -1562,7 +1579,7 @@ subroutine weno_five_h_weight_reconstruction(q6, h6, u6, &
1562
1579
real :: c0, c1, c2 ! Intermediate reconstruction of hq[A ~> a]
1563
1580
real :: d0, d1, d2 ! Intermediate reconstruction of h [L ~> m]
1564
1581
real :: b0, b1, b2 ! Smoothness indicator [A ~> a]
1565
- real :: tau ! Temporary variables [nondim ]
1582
+ real :: tau ! Difference of smoothness indicators [A ~> a ]
1566
1583
real :: w0, w1, w2 ! Weights [nondim]
1567
1584
real :: s ! Temporary variables [nondim]
1568
1585
real , parameter :: C3_10 = 3.0 / 10.0 ! The ratio of 3/10 [nondim]
@@ -1606,9 +1623,9 @@ subroutine weno_five_h_weight_reconstruction(q6, h6, u6, &
1606
1623
endif
1607
1624
1608
1625
tau = abs (b0 - b2)
1609
- w0 = C3_10 * ( 1 + ( tau / (b0 + 1e-20 )) ** 2 )
1610
- w1 = C3_5 * ( 1 + ( tau / (b1 + 1e-20 )) ** 2 )
1611
- w2 = C1_10 * ( 1 + ( tau / (b2 + 1e-20 )) ** 2 )
1626
+ w0 = C3_10 * fac_fn( tau, b0 )
1627
+ w1 = C3_5 * fac_fn( tau, b1 )
1628
+ w2 = C1_10 * fac_fn( tau, b2 )
1612
1629
1613
1630
s = 1 . / (w0 + w1 + w2)
1614
1631
w0 = w0 * s
@@ -1705,7 +1722,7 @@ subroutine weno_seven_h_weight_reconstruction(q8, h8, u8, &
1705
1722
real :: c0, c1, c2, c3 ! Intermediate reconstruction of hq [A ~> a]
1706
1723
real :: d0, d1, d2, d3 ! Intermediate reconstruction of h [L ~> m]
1707
1724
real :: b0, b1, b2, b3 ! Smoothness indicator [A ~> a]
1708
- real :: tau ! Temporary variables [nondim ]
1725
+ real :: tau ! Difference of smoothness indicators [A ~> a ]
1709
1726
real :: w0, w1, w2, w3 ! Weights [nondim]
1710
1727
real :: s ! Temporary variables [nondim]
1711
1728
real , parameter :: C4_35 = 4.0 / 35.0 ! The ratio of 4/35 [nondim]
@@ -1758,10 +1775,10 @@ subroutine weno_seven_h_weight_reconstruction(q8, h8, u8, &
1758
1775
endif
1759
1776
1760
1777
tau = abs ((b0 - b3) + 3 * (b1 - b2))
1761
- w0 = C4_35 * ( 1 + ( tau / (b0 + 1e-20 )) ** 2 )
1762
- w1 = C18_35 * ( 1 + ( tau / (b1 + 1e-20 )) ** 2 )
1763
- w2 = C12_35 * ( 1 + ( tau / (b2 + 1e-20 )) ** 2 )
1764
- w3 = C1_35 * ( 1 + ( tau / (b3 + 1e-20 )) ** 2 )
1778
+ w0 = C4_35 * fac_fn( tau, b0 )
1779
+ w1 = C18_35 * fac_fn( tau, b1 )
1780
+ w2 = C12_35 * fac_fn( tau, b2 )
1781
+ w3 = C1_35 * fac_fn( tau, b3 )
1765
1782
1766
1783
s = 1 . / (w0 + w1 + w2 + w3)
1767
1784
w0 = w0 * s
0 commit comments