Skip to content

Commit

Permalink
Previous fix to restore tracers ignored CISO
Browse files Browse the repository at this point in the history
This update makes sure interior restoring is applied to ALL tracers; it
is done in a manner such that restoring is applied after the budget
computations, so those no longer need to be adjusted to subtract out the
restoring term.

Also cleaned up one change from previous code, reverting back to
convention of putting mathematical operator after the continuation
character when wrapping lines.
  • Loading branch information
mnlevy1981 committed Jan 12, 2018
1 parent 37dc086 commit 6b59dca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 56 deletions.
59 changes: 10 additions & 49 deletions src/marbl_diagnostics_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3275,7 +3275,7 @@ subroutine marbl_diagnostics_set_interior_forcing ( &
sed_denitrif, other_remin, marbl_interior_forcing_diags)

call store_diagnostics_carbon_fluxes(domain, POC, P_CaCO3, dtracers, &
interior_restore, marbl_tracer_indices, marbl_interior_forcing_diags)
marbl_tracer_indices, marbl_interior_forcing_diags)

call store_diagnostics_nitrification(&
nitrif, denitrif, marbl_interior_forcing_diags)
Expand All @@ -3297,18 +3297,18 @@ subroutine marbl_diagnostics_set_interior_forcing ( &

call store_diagnostics_nitrogen_fluxes(domain, &
PON_sed_loss, denitrif, sed_denitrif, autotroph_secondary_species, dtracers, &
interior_restore, marbl_tracer_indices, marbl_interior_forcing_diags)
marbl_tracer_indices, marbl_interior_forcing_diags)

call store_diagnostics_phosphorus_fluxes(domain, POP, &
autotroph_secondary_species, dtracers, interior_restore, &
autotroph_secondary_species, dtracers, &
marbl_tracer_indices, marbl_interior_forcing_diags)

call store_diagnostics_silicon_fluxes(domain, P_SiO2, dtracers, &
interior_restore, marbl_tracer_indices, marbl_interior_forcing_diags)
marbl_tracer_indices, marbl_interior_forcing_diags)

call store_diagnostics_iron_fluxes(domain, P_iron, dust, &
interior_forcings(interior_forcing_ind%fesedflux_id)%field_1d(1,:), &
dtracers, interior_restore, marbl_tracer_indices, marbl_interior_forcing_diags)
dtracers, marbl_tracer_indices, marbl_interior_forcing_diags)

call store_diagnostics_interior_restore(interior_restore, &
marbl_interior_forcing_diags)
Expand Down Expand Up @@ -4035,13 +4035,12 @@ end subroutine store_diagnostics_iron_cycle
!***********************************************************************

subroutine store_diagnostics_carbon_fluxes(marbl_domain, POC, P_CaCO3, dtracers, &
interior_restore, marbl_tracer_indices, marbl_diags)
marbl_tracer_indices, marbl_diags)

type(marbl_domain_type) , intent(in) :: marbl_domain
type(column_sinking_particle_type) , intent(in) :: POC
type(column_sinking_particle_type) , intent(in) :: P_CaCO3
real(r8) , intent(in) :: dtracers(:,:) ! tracer_cnt, km
real(r8) , intent(in) :: interior_restore(:,:) ! tracer_cnt, km
type(marbl_tracer_index_type) , intent(in) :: marbl_tracer_indices
type(marbl_diagnostics_type) , intent(inout) :: marbl_diags

Expand Down Expand Up @@ -4069,17 +4068,10 @@ subroutine store_diagnostics_carbon_fluxes(marbl_domain, POC, P_CaCO3, dtracers,
sum(dtracers(marbl_tracer_indices%zoo_inds(:)%C_ind,:), dim=1) + &
sum(dtracers(marbl_tracer_indices%auto_inds(:)%C_ind,:),dim=1)

! subtract tracer restoring terms
work = work - (interior_restore(dic_ind,:) + interior_restore(doc_ind,:) + &
interior_restore(docr_ind,:) + &
sum(interior_restore(marbl_tracer_indices%zoo_inds(:)%C_ind,:), dim=1) + &
sum(interior_restore(marbl_tracer_indices%auto_inds(:)%C_ind,:),dim=1))

do auto_ind = 1, autotroph_cnt
n = marbl_tracer_indices%auto_inds(auto_ind)%CaCO3_ind
if (n .gt. 0) then
work = work + dtracers(n,:)
work = work - interior_restore(n,:)
end if
end do

Expand All @@ -4096,7 +4088,7 @@ end subroutine store_diagnostics_carbon_fluxes

subroutine store_diagnostics_nitrogen_fluxes(marbl_domain, &
PON_sed_loss, denitrif, sed_denitrif, autotroph_secondary_species, dtracers, &
interior_restore, marbl_tracer_indices, marbl_diags)
marbl_tracer_indices, marbl_diags)

use marbl_settings_mod, only : Q

Expand All @@ -4106,7 +4098,6 @@ subroutine store_diagnostics_nitrogen_fluxes(marbl_domain, &
real(r8) , intent(in) :: sed_denitrif(:) ! km
type(autotroph_secondary_species_type) , intent(in) :: autotroph_secondary_species(:,:)
real(r8) , intent(in) :: dtracers(:,:) ! tracer_cnt, km
real(r8) , intent(in) :: interior_restore(:,:) ! tracer_cnt, km
type(marbl_tracer_index_type) , intent(in) :: marbl_tracer_indices
type(marbl_diagnostics_type) , intent(inout) :: marbl_diags

Expand Down Expand Up @@ -4136,12 +4127,6 @@ subroutine store_diagnostics_nitrogen_fluxes(marbl_domain, &
Q * sum(dtracers(marbl_tracer_indices%auto_inds(:)%C_ind,:), dim=1) + &
denitrif(:) + sed_denitrif(:)

! subtract tracer restoring terms
work = work - (interior_restore(no3_ind,:) + interior_restore(nh4_ind,:) + &
interior_restore(don_ind,:) + interior_restore(donr_ind,:) + &
Q * sum(interior_restore(marbl_tracer_indices%zoo_inds(:)%C_ind,:), dim=1) + &
Q * sum(interior_restore(marbl_tracer_indices%auto_inds(:)%C_ind,:), dim=1))

! subtract out N fixation
do n = 1, autotroph_cnt
if (autotrophs(n)%Nfixer) then
Expand All @@ -4161,7 +4146,7 @@ end subroutine store_diagnostics_nitrogen_fluxes
!***********************************************************************

subroutine store_diagnostics_phosphorus_fluxes(marbl_domain, POP, &
autotroph_secondary_species, dtracers, interior_restore, &
autotroph_secondary_species, dtracers, &
marbl_tracer_indices, marbl_diags)

use marbl_pft_mod, only : Qp_zoo
Expand All @@ -4171,7 +4156,6 @@ subroutine store_diagnostics_phosphorus_fluxes(marbl_domain, POP, &
type(column_sinking_particle_type) , intent(in) :: POP
type(autotroph_secondary_species_type) , intent(in) :: autotroph_secondary_species(:,:)
real(r8) , intent(in) :: dtracers(:,:) ! tracer_cnt, km
real(r8) , intent(in) :: interior_restore(:,:) ! tracer_cnt, km
type(marbl_tracer_index_type) , intent(in) :: marbl_tracer_indices
type(marbl_diagnostics_type) , intent(inout) :: marbl_diags

Expand Down Expand Up @@ -4204,18 +4188,6 @@ subroutine store_diagnostics_phosphorus_fluxes(marbl_domain, POP, &
end do
endif

! subtract restoring terms
work = work - (interior_restore(po4_ind,:) + interior_restore(dop_ind,:) + interior_restore(dopr_ind,:) + &
Qp_zoo * sum(interior_restore(marbl_tracer_indices%zoo_inds(:)%C_ind,:), dim=1))

if (lvariable_PtoC) then
work = work - sum(interior_restore(marbl_tracer_indices%auto_inds(:)%P_ind,:),dim=1)
else
do n = 1, autotroph_cnt
work = work - autotroph_secondary_species(n,:)%Qp * interior_restore(marbl_tracer_indices%auto_inds(n)%C_ind,:)
end do
endif

call compute_vertical_integrals(work, delta_z, kmt, &
full_depth_integral=diags(ind%Jint_Ptot)%field_2d(1), &
near_surface_integral=diags(ind%Jint_100m_Ptot)%field_2d(1), &
Expand All @@ -4228,12 +4200,11 @@ end subroutine store_diagnostics_phosphorus_fluxes
!***********************************************************************

subroutine store_diagnostics_silicon_fluxes(marbl_domain, P_SiO2, dtracers, &
interior_restore, marbl_tracer_indices, marbl_diags)
marbl_tracer_indices, marbl_diags)

type(marbl_domain_type) , intent(in) :: marbl_domain
type(column_sinking_particle_type) , intent(in) :: P_SiO2
real(r8) , intent(in) :: dtracers(:,:) ! tracer_cnt, km
real(r8) , intent(in) :: interior_restore(:,:) ! tracer_cnt, km
type(marbl_tracer_index_type) , intent(in) :: marbl_tracer_indices
type(marbl_diagnostics_type) , intent(inout) :: marbl_diags

Expand All @@ -4255,13 +4226,9 @@ subroutine store_diagnostics_silicon_fluxes(marbl_domain, P_SiO2, dtracers, &
! vertical integrals
work = dtracers(marbl_tracer_indices%sio3_ind,:)

! subtract tracer restoring terms
work = work - interior_restore(marbl_tracer_indices%sio3_ind,:)

do n = 1, autotroph_cnt
if (marbl_tracer_indices%auto_inds(n)%Si_ind > 0) then
work = work + dtracers(marbl_tracer_indices%auto_inds(n)%Si_ind,:)
work = work - interior_restore(marbl_tracer_indices%auto_inds(n)%Si_ind,:)
end if
end do

Expand All @@ -4277,7 +4244,7 @@ end subroutine store_diagnostics_silicon_fluxes
!***********************************************************************

subroutine store_diagnostics_iron_fluxes(marbl_domain, P_iron, dust, &
fesedflux, dtracers, interior_restore, marbl_tracer_indices, marbl_diags)
fesedflux, dtracers, marbl_tracer_indices, marbl_diags)

use marbl_settings_mod, only : Qfe_zoo
use marbl_settings_mod, only : dust_to_Fe
Expand All @@ -4287,7 +4254,6 @@ subroutine store_diagnostics_iron_fluxes(marbl_domain, P_iron, dust, &
type(column_sinking_particle_type) , intent(in) :: dust
real(r8) , intent(in) :: fesedflux(:) ! km
real(r8) , intent(in) :: dtracers(:,:) ! tracer_cnt, km
real(r8) , intent(in) :: interior_restore(:,:) ! tracer_cnt, km
type(marbl_tracer_index_type) , intent(in) :: marbl_tracer_indices
type(marbl_diagnostics_type) , intent(inout) :: marbl_diags

Expand All @@ -4312,11 +4278,6 @@ subroutine store_diagnostics_iron_fluxes(marbl_domain, P_iron, dust, &
Qfe_zoo * sum(dtracers(marbl_tracer_indices%zoo_inds(:)%C_ind, :),dim=1) - &
dust%remin(:) * dust_to_Fe

! subtract tracer restoring terms
work = work - (interior_restore(fe_ind, :) + &
sum(interior_restore(marbl_tracer_indices%auto_inds(:)%Fe_ind, :),dim=1) + &
Qfe_zoo * sum(interior_restore(marbl_tracer_indices%zoo_inds(:)%C_ind, :),dim=1))

call compute_vertical_integrals(work, delta_z, kmt, &
full_depth_integral=diags(ind%Jint_Fetot)%field_2d(1), &
near_surface_integral=diags(ind%Jint_100m_Fetot)%field_2d(1), &
Expand Down
15 changes: 8 additions & 7 deletions src/marbl_mod.F90
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

! -*- mode: f90; indent-tabs-mode: nil; f90-do-indent:3; f90-if-indent:3; f90-type-indent:3; f90-program-indent:2; f90-associate-indent:0; f90-continuation-indent:5 -*-
!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

Expand Down Expand Up @@ -834,6 +835,9 @@ subroutine marbl_set_interior_forcing( &

end associate

! ADD RESTORING
dtracers = dtracers + interior_restore

end subroutine marbl_set_interior_forcing

!***********************************************************************
Expand Down Expand Up @@ -4368,9 +4372,9 @@ subroutine marbl_compute_dtracer_local (auto_cnt, zoo_cnt, autotrophs, &
! phosphate
!-----------------------------------------------------------------------

dtracers(po4_ind) = DOP_remin + DOPr_remin - sum(PO4_V(:)) + &
(c1 - POPremin_refract) * POP_remin + sum(remaining_P_dip(:)) + &
Qp_zoo * ( sum(zoo_loss_dic(:)) + sum(zoo_graze_dic(:)) )
dtracers(po4_ind) = DOP_remin + DOPr_remin - sum(PO4_V(:)) &
+ (c1 - POPremin_refract) * POP_remin + sum(remaining_P_dip(:)) &
+ Qp_zoo * ( sum(zoo_loss_dic(:)) + sum(zoo_graze_dic(:)) )

!-----------------------------------------------------------------------
! zoo Carbon
Expand Down Expand Up @@ -4499,9 +4503,6 @@ subroutine marbl_compute_dtracer_local (auto_cnt, zoo_cnt, autotrophs, &

dtracers(o2_ind) = o2_production - o2_consumption

! ADD RESTORING
dtracers(:) = dtracers(:) + interior_restore(:)

end associate
end subroutine marbl_compute_dtracer_local

Expand Down Expand Up @@ -4641,4 +4642,4 @@ end subroutine log_add_forcing_field_error

end module marbl_mod

!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
!|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||

0 comments on commit 6b59dca

Please sign in to comment.