diff --git a/src/atmosphere/photochem_atmosphere_utils.f90 b/src/atmosphere/photochem_atmosphere_utils.f90 index 77f5008..e4f346d 100644 --- a/src/atmosphere/photochem_atmosphere_utils.f90 +++ b/src/atmosphere/photochem_atmosphere_utils.f90 @@ -723,7 +723,7 @@ module subroutine set_press_temp_edd(self, P, T, edd, trop_p, err) z_ = var%z z_ = z_(var%nz:1:-1) - call interp(1, var%nz, [log10(trop_p)], log10P_wrk, z_, trop_alt(1), ierr) + call interp(1, var%nz, [log10(trop_p)], log10P_wrk, z_, trop_alt, ierr) if (ierr /= 0) then err = 'Subroutine interp returned an error.' return diff --git a/src/dependencies/CMakeLists.txt b/src/dependencies/CMakeLists.txt index 37e4fcb..24d931e 100644 --- a/src/dependencies/CMakeLists.txt +++ b/src/dependencies/CMakeLists.txt @@ -1,9 +1,9 @@ CPMAddPackage( NAME futils - VERSION 0.1.7 + VERSION 0.1.8 GITHUB_REPOSITORY "Nicholaswogan/futils" - GIT_TAG "v0.1.7" + GIT_TAG "v0.1.8" EXCLUDE_FROM_ALL ON ) @@ -49,7 +49,7 @@ CPMAddPackage( CPMAddPackage( NAME clima - VERSION 0.4.2 + VERSION 0.4.3 OPTIONS "BUILD_EXECUTABLE OFF" "BUILD_WITH_OPENMP ${BUILD_WITH_OPENMP}" @@ -57,16 +57,16 @@ CPMAddPackage( "BUILD_PYTHON_CLIMA ${BUILD_PYTHON_PHOTOCHEM}" "PYTHON_CLIMA_DESTINATION photochem" GITHUB_REPOSITORY "Nicholaswogan/clima" - GIT_TAG "v0.4.2" + GIT_TAG "v0.4.3" EXCLUDE_FROM_ALL OFF ) CPMAddPackage( NAME forwarddiff - VERSION 0.1.1 + VERSION 0.1.2 OPTIONS "BUILD_EXECUTABLE OFF" GITHUB_REPOSITORY "Nicholaswogan/forwarddiff" - GIT_TAG "v0.1.1" + GIT_TAG "v0.1.2" EXCLUDE_FROM_ALL ON ) \ No newline at end of file diff --git a/src/evoatmosphere/photochem_evoatmosphere_utils.f90 b/src/evoatmosphere/photochem_evoatmosphere_utils.f90 index 0ddb4aa..af6a800 100644 --- a/src/evoatmosphere/photochem_evoatmosphere_utils.f90 +++ b/src/evoatmosphere/photochem_evoatmosphere_utils.f90 @@ -455,7 +455,7 @@ module subroutine set_press_temp_edd(self, P, T, edd, trop_p, hydro_pressure, er z_ = var%z z_ = z_(var%nz:1:-1) - call interp(1, var%nz, [log10(trop_p)], log10P_wrk, z_, trop_alt(1), ierr) + call interp(1, var%nz, [log10(trop_p)], log10P_wrk, z_, trop_alt, ierr) if (ierr /= 0) then err = 'Subroutine interp returned an error.' return @@ -605,7 +605,7 @@ subroutine properties_for_new_TOA(self, usol, top_atmos_new, & particle_radius_new, pressure_new, err) use photochem_enum, only: DensityBC, PressureBC use futils, only: interp - use photochem_eqns, only: vertical_grid, molar_weight, press_and_den, gravity, interp_new + use photochem_eqns, only: vertical_grid, molar_weight, press_and_den, gravity use photochem_const, only: small_real, k_boltz class(EvoAtmosphere), target, intent(inout) :: self real(dp), intent(in) :: usol(:,:) @@ -662,7 +662,7 @@ subroutine properties_for_new_TOA(self, usol, top_atmos_new, & enddo ! Interpolate mixing ratios, with constant extrapolation do i = 1,dat%nq - call interp_new(z_new, var%z, log10(max(mix(i,:),small_real)), mix_new(i,:), ierr=ierr) + call interp(z_new, var%z, log10(max(mix(i,:),small_real)), mix_new(i,:), ierr=ierr) if (ierr /= 0) then err = 'Subroutine interp returned an error.' return @@ -671,7 +671,7 @@ subroutine properties_for_new_TOA(self, usol, top_atmos_new, & mix_new = 10.0_dp**mix_new ! Interpolate density, with linear extrapolation - call interp_new(z_new, var%z, log10(density), density_new, linear_extrap=.true., ierr=ierr) + call interp(z_new, var%z, log10(density), density_new, linear_extrap=.true., ierr=ierr) if (ierr /= 0) then err = 'Subroutine interp returned an error.' return diff --git a/src/input/photochem_input_after_read.f90 b/src/input/photochem_input_after_read.f90 index a1f7618..b4dd254 100644 --- a/src/input/photochem_input_after_read.f90 +++ b/src/input/photochem_input_after_read.f90 @@ -162,7 +162,6 @@ subroutine interp2atmosfile_mixconserving(dat, var, err) subroutine interp2atmosfile_mix(dat, var, err) use futils, only: interp - use photochem_eqns, only: interp_new use photochem_const, only: small_real type(PhotochemData), intent(in) :: dat type(PhotochemVars), intent(inout) :: var @@ -174,7 +173,7 @@ subroutine interp2atmosfile_mix(dat, var, err) allocate(density(var%nz)) ! Interpolate file density to model grid - call interp_new(var%z, dat%z_file, log10(dat%den_file), density, linear_extrap=.true., ierr=ierr) + call interp(var%z, dat%z_file, log10(dat%den_file), density, linear_extrap=.true., ierr=ierr) if (ierr /= 0) then err = 'Subroutine interp returned an error.' return diff --git a/src/photochem_eqns.f90 b/src/photochem_eqns.f90 index 92a5a7d..a8b9f7b 100644 --- a/src/photochem_eqns.f90 +++ b/src/photochem_eqns.f90 @@ -364,70 +364,4 @@ pure function zahnle_Hescape_coeff(S1) result(coeff) end function - !> Better new interp that allows for linear extrapolation. - subroutine interp_new(xg, x, y, yg, linear_extrap, ierr) - use futils, only: interp - real(dp), intent(in) :: xg(:) !! new grid - real(dp), intent(in) :: x(:), y(:) !! old data - real(dp), intent(out) :: yg(:) !! new data - logical, optional, intent(in) :: linear_extrap - integer, optional, intent(out) :: ierr - - logical :: linear_extrap_ - integer :: ng, n - real(dp), allocatable :: x_copy(:), y_copy(:) - real(dp) :: slope, intercept, tmp - - ng = size(xg) - n = size(x) - - if (present(ierr)) then - ierr = 0 - if (ng /= size(yg)) then - ierr = -3 - return - endif - if (n /= size(y)) then - ierr = -4 - return - endif - if (n < 2) then - ierr = -5 - return - endif - endif - - if (present(linear_extrap)) then - linear_extrap_ = linear_extrap - else - linear_extrap_ = .false. - endif - - if (.not.linear_extrap_) then - call interp(ng, n, xg, x, y, yg, ierr) - return - endif - - ! We do linear extrapolation - x_copy = x - y_copy = y - if (xg(ng) > x(n)) then - slope = (y(n) - y(n-1))/(x(n) - x(n-1)) - intercept = y(n) - slope*x(n) - tmp = slope*xg(ng) + intercept - x_copy = [x_copy,xg(ng)] - y_copy = [y_copy,tmp] - endif - if (xg(1) < x(1)) then - slope = (y(2) - y(1))/(x(2) - x(1)) - intercept = y(1) - slope*x(1) - tmp = slope*xg(1) + intercept - x_copy = [xg(1),x_copy] - y_copy = [tmp,y_copy] - endif - - call interp(ng, size(x_copy), xg, x_copy, y_copy, yg, ierr) - - end subroutine - end module \ No newline at end of file