Skip to content

Commit

Permalink
+Eliminate unused answers_2018 optional arguments
Browse files Browse the repository at this point in the history
  Eliminated the now unused answers_2018 optional arguments in a variety of the
ALE-related subroutines that are only called from code in the ALE directory. The
functionality previously provided by answers_2018 is now provided by the more
flexible answer_date arguments.  A handful of spelling errors were also
corrected in comments in the files that were edited.  All answers are bitwise
identical.
  • Loading branch information
Hallberg-NOAA committed Jul 30, 2022
1 parent 7c72377 commit 7a9c8a8
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/ALE/MOM_remapping.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ logical function remapping_unit_tests(verbose)

call edge_values_explicit_h4( 5, (/1.,1.,1.,1.,1./), (/1.,1.,7.,19.,37./), ppoly0_E, &
h_neglect=1e-10, answer_date=answer_date )
! The next two tests are now passing when answers_2018 = .false., but otherwise only work to roundoff.
! The next two tests are now passing when answer_date >= 20190101, but otherwise only work to roundoff.
thisTest = test_answer(v, 5, ppoly0_E(:,1), (/3.,0.,3.,12.,27./), 'Parabola H4: left edges', tol=2.7e-14)
remapping_unit_tests = remapping_unit_tests .or. thisTest
thisTest = test_answer(v, 5, ppoly0_E(:,2), (/0.,3.,12.,27.,48./), 'Parabola H4: right edges', tol=4.8e-14)
Expand Down
8 changes: 3 additions & 5 deletions src/ALE/P1M_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,22 @@ module P1M_functions
!!
!! It is assumed that the size of the array 'u' is equal to the number of cells
!! defining 'grid' and 'ppoly'. No consistency check is performed here.
subroutine P1M_interpolation( N, h, u, edge_values, ppoly_coef, h_neglect, answers_2018, answer_date )
subroutine P1M_interpolation( N, h, u, edge_values, ppoly_coef, h_neglect, answer_date )
integer, intent(in) :: N !< Number of cells
real, dimension(:), intent(in) :: h !< cell widths (size N) [H]
real, dimension(:), intent(in) :: u !< cell average properties (size N) [A]
real, dimension(:,:), intent(inout) :: edge_values !< Potentially modified edge values [A]
real, dimension(:,:), intent(inout) :: ppoly_coef !< Potentially modified
!! piecewise polynomial coefficients, mainly [A]
real, optional, intent(in) :: h_neglect !< A negligibly small width [H]
logical, optional, intent(in) :: answers_2018 !< If true use older, less acccurate expressions.
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use

! Local variables
integer :: k ! loop index
real :: u0_l, u0_r ! edge values (left and right)

! Bound edge values (routine found in 'edge_values.F90')
call bound_edge_values( N, h, u, edge_values, h_neglect, &
answers_2018=answers_2018, answer_date=answer_date )
call bound_edge_values( N, h, u, edge_values, h_neglect, answer_date=answer_date )

! Systematically average discontinuous edge values (routine found in
! 'edge_values.F90')
Expand Down Expand Up @@ -155,7 +153,7 @@ end subroutine P1M_boundary_extrapolation
!! linearly interpolating between them.
!
!! Once the edge values are estimated, the limiting process takes care of
!! ensuring that (1) edge values are bounded by neighoring cell averages
!! ensuring that (1) edge values are bounded by neighboring cell averages
!! and (2) discontinuous edge values are averaged in order to provide a
!! fully continuous interpolant throughout the domain. This last step is
!! essential for the regridding problem to yield a unique solution.
Expand Down
12 changes: 5 additions & 7 deletions src/ALE/P3M_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module P3M_functions
!!
!! It is assumed that the size of the array 'u' is equal to the number of cells
!! defining 'grid' and 'ppoly'. No consistency check is performed here.
subroutine P3M_interpolation( N, h, u, edge_values, ppoly_S, ppoly_coef, h_neglect, answers_2018, answer_date )
subroutine P3M_interpolation( N, h, u, edge_values, ppoly_S, ppoly_coef, h_neglect, answer_date )
integer, intent(in) :: N !< Number of cells
real, dimension(:), intent(in) :: h !< cell widths (size N) [H]
real, dimension(:), intent(in) :: u !< cell averages (size N) in arbitrary units [A]
Expand All @@ -34,7 +34,6 @@ subroutine P3M_interpolation( N, h, u, edge_values, ppoly_S, ppoly_coef, h_negle
real, dimension(:,:), intent(inout) :: ppoly_coef !< Coefficients of polynomial [A]
real, optional, intent(in) :: h_neglect !< A negligibly small width for the
!! purpose of cell reconstructions [H]
logical, optional, intent(in) :: answers_2018 !< If true use older, less acccurate expressions.
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use

! Call the limiter for p3m, which takes care of everything from
Expand All @@ -43,7 +42,7 @@ subroutine P3M_interpolation( N, h, u, edge_values, ppoly_S, ppoly_coef, h_negle
! 'P3M_interpolation' first but we do that to provide an homogeneous
! interface.
call P3M_limiter( N, h, u, edge_values, ppoly_S, ppoly_coef, h_neglect, &
answers_2018=answers_2018, answer_date=answer_date )
answer_date=answer_date )

end subroutine P3M_interpolation

Expand All @@ -60,7 +59,7 @@ end subroutine P3M_interpolation
!! c. If not, monotonize cubic curve and rebuild it
!!
!! Step 3 of the monotonization process leaves all edge values unchanged.
subroutine P3M_limiter( N, h, u, edge_values, ppoly_S, ppoly_coef, h_neglect, answers_2018, answer_date )
subroutine P3M_limiter( N, h, u, edge_values, ppoly_S, ppoly_coef, h_neglect, answer_date )
integer, intent(in) :: N !< Number of cells
real, dimension(:), intent(in) :: h !< cell widths (size N) [H]
real, dimension(:), intent(in) :: u !< cell averages (size N) in arbitrary units [A]
Expand All @@ -69,7 +68,6 @@ subroutine P3M_limiter( N, h, u, edge_values, ppoly_S, ppoly_coef, h_neglect, an
real, dimension(:,:), intent(inout) :: ppoly_coef !< Coefficients of polynomial [A]
real, optional, intent(in) :: h_neglect !< A negligibly small width for
!! the purpose of cell reconstructions [H]
logical, optional, intent(in) :: answers_2018 !< If true use older, less acccurate expressions.
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use

! Local variables
Expand All @@ -89,7 +87,7 @@ subroutine P3M_limiter( N, h, u, edge_values, ppoly_S, ppoly_coef, h_neglect, an
eps = 1e-10

! 1. Bound edge values (boundary cells are assumed to be local extrema)
call bound_edge_values( N, h, u, edge_values, hNeglect, answers_2018=answers_2018, answer_date=answer_date )
call bound_edge_values( N, h, u, edge_values, hNeglect, answer_date=answer_date )

! 2. Systematically average discontinuous edge values
call average_discontinuous_edge_values( N, edge_values )
Expand Down Expand Up @@ -386,7 +384,7 @@ end subroutine build_cubic_interpolant
!! Hence, we check whether the roots (if any) lie inside this interval. If there
!! is no root or if both roots lie outside this interval, the cubic is monotonic.
logical function is_cubic_monotonic( ppoly_coef, k )
real, dimension(:,:), intent(in) :: ppoly_coef !< Coefficients of cubic polynomial in arbitary units [A]
real, dimension(:,:), intent(in) :: ppoly_coef !< Coefficients of cubic polynomial in arbitrary units [A]
integer, intent(in) :: k !< The index of the cell to work on
! Local variables
real :: a, b, c ! Coefficients of the first derivative of the cubic [A]
Expand Down
2 changes: 1 addition & 1 deletion src/ALE/PCM_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end subroutine PCM_reconstruction
!! Date of creation: 2008.06.06
!! L. White
!!
!! This module contains routines that handle one-dimensionnal finite volume
!! This module contains routines that handle one-dimensional finite volume
!! reconstruction using the piecewise constant method (PCM).

end module PCM_functions
4 changes: 2 additions & 2 deletions src/ALE/PLM_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ real elemental pure function PLM_monotonized_slope(u_l, u_c, u_r, s_l, s_c, s_r)
end function PLM_monotonized_slope

!> Returns a PLM slope using h2 extrapolation from a cell to the left.
!! Use the negative to extrapolate from the a cell to the right.
!! Use the negative to extrapolate from the cell to the right.
real elemental pure function PLM_extrapolate_slope(h_l, h_c, h_neglect, u_l, u_c)
real, intent(in) :: h_l !< Thickness of left cell [units of grid thickness]
real, intent(in) :: h_c !< Thickness of center cell [units of grid thickness]
Expand Down Expand Up @@ -305,7 +305,7 @@ end subroutine PLM_boundary_extrapolation
!! Date of creation: 2008.06.06
!! L. White
!!
!! This module contains routines that handle one-dimensionnal finite volume
!! This module contains routines that handle one-dimensional finite volume
!! reconstruction using the piecewise linear method (PLM).

end module PLM_functions
12 changes: 5 additions & 7 deletions src/ALE/PPM_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,21 @@ module PPM_functions
contains

!> Builds quadratic polynomials coefficients from cell mean and edge values.
subroutine PPM_reconstruction( N, h, u, edge_values, ppoly_coef, h_neglect, answers_2018, answer_date)
subroutine PPM_reconstruction( N, h, u, edge_values, ppoly_coef, h_neglect, answer_date)
integer, intent(in) :: N !< Number of cells
real, dimension(N), intent(in) :: h !< Cell widths [H]
real, dimension(N), intent(in) :: u !< Cell averages [A]
real, dimension(N,2), intent(inout) :: edge_values !< Edge values [A]
real, dimension(N,3), intent(inout) :: ppoly_coef !< Polynomial coefficients, mainly [A]
real, optional, intent(in) :: h_neglect !< A negligibly small width [H]
logical, optional, intent(in) :: answers_2018 !< If true use older, less acccurate expressions.
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use

! Local variables
integer :: k ! Loop index
real :: edge_l, edge_r ! Edge values (left and right)

! PPM limiter
call PPM_limiter_standard( N, h, u, edge_values, h_neglect, answers_2018=answers_2018, answer_date=answer_date )
call PPM_limiter_standard( N, h, u, edge_values, h_neglect, answer_date=answer_date )

! Loop over all cells
do k = 1,N
Expand All @@ -60,13 +59,12 @@ end subroutine PPM_reconstruction
!> Adjusts edge values using the standard PPM limiter (Colella & Woodward, JCP 1984)
!! after first checking that the edge values are bounded by neighbors cell averages
!! and that the edge values are monotonic between cell averages.
subroutine PPM_limiter_standard( N, h, u, edge_values, h_neglect, answers_2018, answer_date )
subroutine PPM_limiter_standard( N, h, u, edge_values, h_neglect, answer_date )
integer, intent(in) :: N !< Number of cells
real, dimension(:), intent(in) :: h !< cell widths (size N) [H]
real, dimension(:), intent(in) :: u !< cell average properties (size N) [A]
real, dimension(:,:), intent(inout) :: edge_values !< Potentially modified edge values [A]
real, optional, intent(in) :: h_neglect !< A negligibly small width [H]
logical, optional, intent(in) :: answers_2018 !< If true use older, less acccurate expressions.
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use

! Local variables
Expand All @@ -76,7 +74,7 @@ subroutine PPM_limiter_standard( N, h, u, edge_values, h_neglect, answers_2018,
real :: expr1, expr2

! Bound edge values
call bound_edge_values( N, h, u, edge_values, h_neglect, answers_2018=answers_2018, answer_date=answer_date )
call bound_edge_values( N, h, u, edge_values, h_neglect, answer_date=answer_date )

! Make discontinuous edge values monotonic
call check_discontinuous_edge_values( N, u, edge_values )
Expand Down Expand Up @@ -112,7 +110,7 @@ subroutine PPM_limiter_standard( N, h, u, edge_values, h_neglect, answers_2018,
endif
! This checks that the difference in edge values is representable
! and avoids overshoot problems due to round off.
!### The 1.e-60 needs to have units of [A], so this dimensionally inconsisent.
!### The 1.e-60 needs to have units of [A], so this dimensionally inconsistent.
if ( abs( edge_r - edge_l )<max(1.e-60,epsilon(u_c)*abs(u_c)) ) then
edge_l = u_c
edge_r = u_c
Expand Down
14 changes: 6 additions & 8 deletions src/ALE/PQM_functions.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module PQM_functions
!!
!! It is assumed that the dimension of 'u' is equal to the number of cells
!! defining 'grid' and 'ppoly'. No consistency check is performed.
subroutine PQM_reconstruction( N, h, u, edge_values, edge_slopes, ppoly_coef, h_neglect, answers_2018, answer_date )
subroutine PQM_reconstruction( N, h, u, edge_values, edge_slopes, ppoly_coef, h_neglect, answer_date )
integer, intent(in) :: N !< Number of cells
real, dimension(:), intent(in) :: h !< cell widths (size N) [H]
real, dimension(:), intent(in) :: u !< cell averages (size N) [A]
Expand All @@ -26,7 +26,6 @@ subroutine PQM_reconstruction( N, h, u, edge_values, edge_slopes, ppoly_coef, h_
real, dimension(:,:), intent(inout) :: ppoly_coef !< Coefficients of polynomial, mainly [A]
real, optional, intent(in) :: h_neglect !< A negligibly small width for
!! the purpose of cell reconstructions [H]
logical, optional, intent(in) :: answers_2018 !< If true use older, less acccurate expressions.
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use

! Local variables
Expand All @@ -37,7 +36,7 @@ subroutine PQM_reconstruction( N, h, u, edge_values, edge_slopes, ppoly_coef, h_
real :: a, b, c, d, e ! parabola coefficients

! PQM limiter
call PQM_limiter( N, h, u, edge_values, edge_slopes, h_neglect, answers_2018=answers_2018, answer_date=answer_date )
call PQM_limiter( N, h, u, edge_values, edge_slopes, h_neglect, answer_date=answer_date )

! Loop on cells to construct the cubic within each cell
do k = 1,N
Expand Down Expand Up @@ -73,15 +72,14 @@ end subroutine PQM_reconstruction
!!
!! It is assumed that the dimension of 'u' is equal to the number of cells
!! defining 'grid' and 'ppoly'. No consistency check is performed.
subroutine PQM_limiter( N, h, u, edge_values, edge_slopes, h_neglect, answers_2018, answer_date )
subroutine PQM_limiter( N, h, u, edge_values, edge_slopes, h_neglect, answer_date )
integer, intent(in) :: N !< Number of cells
real, dimension(:), intent(in) :: h !< cell widths (size N) [H]
real, dimension(:), intent(in) :: u !< cell average properties (size N) [A]
real, dimension(:,:), intent(inout) :: edge_values !< Potentially modified edge values [A]
real, dimension(:,:), intent(inout) :: edge_slopes !< Potentially modified edge slopes [A H-1]
real, optional, intent(in) :: h_neglect !< A negligibly small width for
!! the purpose of cell reconstructions [H]
logical, optional, intent(in) :: answers_2018 !< If true use older, less acccurate expressions.
integer, optional, intent(in) :: answer_date !< The vintage of the expressions to use

! Local variables
Expand All @@ -104,7 +102,7 @@ subroutine PQM_limiter( N, h, u, edge_values, edge_slopes, h_neglect, answers_20
hNeglect = hNeglect_dflt ; if (present(h_neglect)) hNeglect = h_neglect

! Bound edge values
call bound_edge_values( N, h, u, edge_values, hNeglect, answers_2018=answers_2018, answer_date=answer_date )
call bound_edge_values( N, h, u, edge_values, hNeglect, answer_date=answer_date )

! Make discontinuous edge values monotonic (thru averaging)
call check_discontinuous_edge_values( N, u, edge_values )
Expand Down Expand Up @@ -160,7 +158,7 @@ subroutine PQM_limiter( N, h, u, edge_values, edge_slopes, h_neglect, answers_20

! Edge values are bounded and averaged when discontinuous and not
! monotonic, edge slopes are consistent and the cell is not an extremum.
! We now need to check and encorce the monotonicity of the quartic within
! We now need to check and enforce the monotonicity of the quartic within
! the cell
if ( (inflexion_l == 0) .AND. (inflexion_r == 0) ) then

Expand Down Expand Up @@ -835,7 +833,7 @@ end subroutine PQM_boundary_extrapolation_v1
!! Date of creation: 2008.06.06
!! L. White
!!
!! This module contains routines that handle one-dimensionnal finite volume
!! This module contains routines that handle one-dimensional finite volume
!! reconstruction using the piecewise quartic method (PQM).

end module PQM_functions
Loading

0 comments on commit 7a9c8a8

Please sign in to comment.