Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply restoring to all tracers #214

Merged
merged 4 commits into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions autogenerated_src/default_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -923,19 +923,22 @@
"PO4",
"NO3",
"SiO3",
"ALK"
"ALK",
"ALK_ALT_CO2"
],
"GRID = CESM_x1": [
"PO4",
"NO3",
"SiO3",
"ALK"
"ALK",
"ALK_ALT_CO2"
],
"GRID = CESM_x3": [
"PO4",
"NO3",
"SiO3",
"ALK"
"ALK",
"ALK_ALT_CO2"
],
"default": ""
},
Expand Down
1 change: 1 addition & 0 deletions src/default_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -840,5 +840,6 @@ tracer_dependent :
- 'NO3'
- 'SiO3'
- 'ALK'
- 'ALK_ALT_CO2'
GRID = CESM_x3 : *CESM_TRACER_RESTORE
GRID = CESM_x1 : *CESM_TRACER_RESTORE
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
9 changes: 6 additions & 3 deletions src/marbl_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,9 @@ subroutine marbl_set_interior_forcing( &

end associate

! ADD RESTORING
dtracers = dtracers + interior_restore

end subroutine marbl_set_interior_forcing

!***********************************************************************
Expand Down Expand Up @@ -4317,7 +4320,7 @@ subroutine marbl_compute_dtracer_local (auto_cnt, zoo_cnt, autotrophs, &
! nitrate & ammonium
!-----------------------------------------------------------------------

dtracers(no3_ind) = interior_restore(no3_ind) + nitrif - denitrif - sed_denitrif - sum(NO3_V(:))
dtracers(no3_ind) = nitrif - denitrif - sed_denitrif - sum(NO3_V(:))

dtracers(nh4_ind) = -sum(NH4_V(:)) - nitrif + DON_remin + DONr_remin &
+ Q * (sum(zoo_loss_dic(:)) + sum(zoo_graze_dic(:)) + sum(auto_loss_dic(:)) + sum(auto_graze_dic(:)) &
Expand Down Expand Up @@ -4354,7 +4357,7 @@ subroutine marbl_compute_dtracer_local (auto_cnt, zoo_cnt, autotrophs, &
! dissolved SiO3
!-----------------------------------------------------------------------

dtracers(sio3_ind) = interior_restore(sio3_ind) + P_SiO2_remin
dtracers(sio3_ind) = P_SiO2_remin

do auto_ind = 1, auto_cnt
if (marbl_tracer_indices%auto_inds(auto_ind)%Si_ind > 0) then
Expand All @@ -4368,7 +4371,7 @@ subroutine marbl_compute_dtracer_local (auto_cnt, zoo_cnt, autotrophs, &
! phosphate
!-----------------------------------------------------------------------

dtracers(po4_ind) = interior_restore(po4_ind) + DOP_remin + DOPr_remin - sum(PO4_V(:)) &
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(:)) )

Expand Down