From f6746fd3a44ab7186602873188adbf6f37d19495 Mon Sep 17 00:00:00 2001 From: Luke Van Roekel Date: Mon, 21 Nov 2016 10:11:44 -0700 Subject: [PATCH] Fixes a bug in evaluate cubic In current CVMix master, the returned value of fprime in evaluate cubic is not correct. For example, when linear interpolation is used, the returned value of fprime is fprime = coeffs(2) + h + h^2 it should be fprime = coeffs(2) + coeffs(3)*h + coeffs(4)*h^2 As it currently sits, the returned fprime is much too large (6 orders of magnitude in my tests relative to the corrected version) --- src/shared/cvmix_math.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/cvmix_math.F90 b/src/shared/cvmix_math.F90 index cdf6fcdca..64d6a302b 100644 --- a/src/shared/cvmix_math.F90 +++ b/src/shared/cvmix_math.F90 @@ -244,7 +244,7 @@ function cvmix_math_evaluate_cubic(coeffs, x_in, fprime) cvmix_math_evaluate_cubic = cvmix_math_evaluate_cubic + & coeffs(i)*(x_in**(i-1)) if (present(fprime).and.(i.gt.2)) & - fprime = fprime + real(i-1,cvmix_r8)*(x_in**(i-2)) + fprime = fprime + coeffs(i)*real(i-1,cvmix_r8)*(x_in**(i-2)) end do end function cvmix_math_evaluate_cubic