Skip to content

Commit

Permalink
renormalized mixing ratios in make_profile_dry
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholaswogan committed Aug 23, 2024
1 parent 8b4c3b0 commit 3063e68
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/adiabat/clima_adiabat_dry.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ subroutine make_profile_dry(P_in, T_in, f_i_in, &
use futils, only: linspace
real(dp), target, intent(in) :: P_in(:)
real(dp), target, intent(in) :: T_in(:)
real(dp), target, intent(in) :: f_i_in(:,:)
real(dp), intent(in) :: f_i_in(:,:)
type(Species), target, intent(inout) :: sp
integer, target, intent(in) :: nz
real(dp), target, intent(in) :: planet_mass, planet_radius
Expand All @@ -69,7 +69,7 @@ subroutine make_profile_dry(P_in, T_in, f_i_in, &
real(dp), target, intent(out) :: lapse_rate(:)
character(:), allocatable, intent(out) :: err

real(dp), allocatable :: tmp_arr(:)
real(dp), target, allocatable :: tmp_arr(:), f_i_in_copy(:,:)
real(dp), allocatable :: log10P_in_interp(:)
type(AdiabatDryProfileData) :: d
integer :: i, ierr
Expand Down Expand Up @@ -114,10 +114,16 @@ subroutine make_profile_dry(P_in, T_in, f_i_in, &
return
endif

! First, lets renormalize the mixing ratios so they sum to 1
f_i_in_copy = f_i_in
do i = 1,size(f_i_in,1)
f_i_in_copy(i,:) = f_i_in_copy(i,:)/sum(f_i_in_copy(i,:))
enddo

! Associate inputs
d%P_in => P_in
d%T_in => T_in
d%f_i_in => f_i_in
d%f_i_in => f_i_in_copy
d%sp => sp
d%nz => nz
d%planet_mass => planet_mass
Expand Down Expand Up @@ -160,7 +166,7 @@ subroutine make_profile_dry(P_in, T_in, f_i_in, &
! Mixing ratios
allocate(d%f_i_interp(sp%ng))
do i = 1,sp%ng
tmp_arr = log10(f_i_in(:,i))
tmp_arr = log10(f_i_in_copy(:,i))
tmp_arr = tmp_arr(size(tmp_arr):1:-1)
call d%f_i_interp(i)%initialize(log10P_in_interp, tmp_arr, ierr)
if (ierr /= 0) then
Expand Down

0 comments on commit 3063e68

Please sign in to comment.