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

Refactor how total Chlorophyll is summed #474

Merged
merged 1 commit into from
Oct 21, 2024
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
14 changes: 14 additions & 0 deletions src/marbl_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ module marbl_interface
procedure, public :: extract_timing
procedure, private :: glo_vars_init
procedure, public :: get_tracer_index
procedure, public :: compute_totChl
procedure, public :: interior_tendency_compute
procedure, public :: surface_flux_compute
procedure, public :: set_global_scalars
Expand Down Expand Up @@ -188,6 +189,7 @@ module marbl_interface
private :: reset_timers
private :: extract_timing
private :: glo_vars_init
private :: compute_totChl
private :: interior_tendency_compute
private :: surface_flux_compute
private :: shutdown
Expand Down Expand Up @@ -972,6 +974,18 @@ end subroutine glo_vars_init

!***********************************************************************

subroutine compute_totChl(this)

use marbl_interior_tendency_mod, only : marbl_interior_tendency_compute_totChl

class(marbl_interface_class), intent(inout) :: this

call marbl_interior_tendency_compute_totChl(this%tracers, this%tracer_indices, this%interior_tendency_output)

end subroutine compute_totChl

!***********************************************************************

subroutine interior_tendency_compute(this)

use marbl_interior_tendency_mod, only : marbl_interior_tendency_compute
Expand Down
36 changes: 26 additions & 10 deletions src/marbl_interior_tendency_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module marbl_interior_tendency_mod

public :: marbl_interior_tendency_compute
public :: marbl_interior_tendency_adjust_bury_coeff
public :: marbl_interior_tendency_compute_totChl

contains

Expand Down Expand Up @@ -135,7 +136,6 @@ subroutine marbl_interior_tendency_compute( &
use marbl_interface_private_types, only : marbl_internal_timers_type
use marbl_interface_private_types, only : marbl_timer_indexing_type
use marbl_interface_private_types, only : marbl_interior_tendency_saved_state_indexing_type
use marbl_interface_public_types, only : ofg_ind
use marbl_interface_public_types, only : marbl_diagnostics_type
use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_export_variables
use marbl_interior_tendency_share_mod, only : marbl_interior_tendency_share_export_zooplankton
Expand Down Expand Up @@ -183,7 +183,7 @@ subroutine marbl_interior_tendency_compute( &
real(r8), dimension(size(tracers,1), domain%km) :: interior_restore
real(r8), dimension(size(tracers,1), domain%km) :: tracer_local

integer (int_kind) :: auto_ind, k ! indices for loops
integer (int_kind) :: k ! index for loops

real (r8) :: surf_press(domain%km) ! pressure in surface layer
real (r8) :: temperature(domain%km) ! in situ temperature
Expand Down Expand Up @@ -276,14 +276,7 @@ subroutine marbl_interior_tendency_compute( &
! Compute Chlorophyll (if requested by GCM)
!-----------------------------------------------------------------------

if (ofg_ind%total_Chl_id.ne.0) then
interior_tendency_output%outputs_for_GCM(ofg_ind%total_Chl_id)%forcing_field_1d(1,:) = c0
do auto_ind = 1,autotroph_cnt
interior_tendency_output%outputs_for_GCM(ofg_ind%total_Chl_id)%forcing_field_1d(1,:) = &
interior_tendency_output%outputs_for_GCM(ofg_ind%total_Chl_id)%forcing_field_1d(1,:) &
+ tracer_local(marbl_tracer_indices%auto_inds(auto_ind)%Chl_ind,:)
end do
end if
call marbl_interior_tendency_compute_totChl(tracer_local, marbl_tracer_indices, interior_tendency_output)

! Verify forcing is consistent
if (lcheck_forcing) &
Expand Down Expand Up @@ -769,6 +762,29 @@ end subroutine marbl_interior_tendency_adjust_bury_coeff

!***********************************************************************

subroutine marbl_interior_tendency_compute_totChl(tracer_local, marbl_tracer_indices, interior_tendency_output)

use marbl_interface_public_types, only : ofg_ind

real(r8), dimension(:,:), intent(in) :: tracer_local
type(marbl_tracer_index_type), intent(in) :: marbl_tracer_indices
type(marbl_output_for_GCM_type), intent(inout) :: interior_tendency_output

integer (int_kind) :: auto_ind

if (ofg_ind%total_Chl_id.ne.0) then
interior_tendency_output%outputs_for_GCM(ofg_ind%total_Chl_id)%forcing_field_1d(1,:) = c0
do auto_ind = 1,autotroph_cnt
interior_tendency_output%outputs_for_GCM(ofg_ind%total_Chl_id)%forcing_field_1d(1,:) = &
interior_tendency_output%outputs_for_GCM(ofg_ind%total_Chl_id)%forcing_field_1d(1,:) &
+ tracer_local(marbl_tracer_indices%auto_inds(auto_ind)%Chl_ind,:)
end do
end if

end subroutine marbl_interior_tendency_compute_totChl

!***********************************************************************

subroutine setup_local_tracers(column_kmt, marbl_tracer_indices, tracers, &
autotroph_local, tracer_local, zooplankton_local)

Expand Down
Loading