Skip to content

Commit

Permalink
Make totalChl_local a local var in compute_PAR()
Browse files Browse the repository at this point in the history
Rather than computing totalChl_local in setup_local_tracers(), we pass
autotroph_local to compute_PAR and let that subroutine compute the sum of the
Chl tracer values.
  • Loading branch information
mnlevy1981 committed Oct 13, 2023
1 parent 70318b8 commit 117b43c
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions src/marbl_interior_tendency_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ subroutine marbl_interior_tendency_compute( &
real (r8) :: Lig_photochem(domain%km) ! loss of Fe-binding Ligand from UV radiation
real (r8) :: Lig_deg(domain%km) ! loss of Fe-binding Ligand from bacterial degradation
real (r8) :: Lig_loss(domain%km) ! loss of Fe-binding Ligand
real (r8) :: totalChl_local(domain%km) ! local value of totalChl

! NOTE(bja, 2015-07) vectorization: arrays that are (n, k, c, i)
! probably can not be vectorized reasonably over c without memory
Expand Down Expand Up @@ -235,7 +234,7 @@ subroutine marbl_interior_tendency_compute( &
!-----------------------------------------------------------------------

call setup_local_tracers(domain%kmt, marbl_tracer_indices, tracers(:,:), autotroph_local, &
tracer_local(:,:), zooplankton_local, totalChl_local)
tracer_local(:,:), zooplankton_local)

!-----------------------------------------------------------------------
! Set all interior diagnostics to zero
Expand Down Expand Up @@ -371,7 +370,7 @@ subroutine marbl_interior_tendency_compute( &
end if

call compute_PAR(domain, interior_tendency_forcings, interior_tendency_forcing_indices, &
totalChl_local, unit_system, PAR)
autotroph_local, unit_system, PAR)

call compute_autotroph_elemental_ratios(km, autotroph_local, marbl_tracer_indices, tracer_local, &
autotroph_derived_terms)
Expand Down Expand Up @@ -546,7 +545,7 @@ end subroutine marbl_interior_tendency_compute
!***********************************************************************

subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_forcing_ind, &
totalChl_local, unit_system, PAR)
autotroph_local, unit_system, PAR)

!-----------------------------------------------------------------------
! compute PAR related quantities
Expand All @@ -558,12 +557,12 @@ subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_for

! PAR is intent(inout) because it components, while entirely set here, are allocated elsewhere

type(marbl_domain_type) , intent(in) :: domain
type(marbl_forcing_fields_type) , intent(in) :: interior_tendency_forcings(:)
type(marbl_interior_tendency_forcing_indexing_type), intent(in) :: interior_tendency_forcing_ind
real(r8) , intent(in) :: totalChl_local(:)
type(unit_system_type) , intent(in) :: unit_system
type(marbl_PAR_type) , intent(inout) :: PAR
type(marbl_domain_type), intent(in) :: domain
type(marbl_forcing_fields_type), intent(in) :: interior_tendency_forcings(:)
type(marbl_interior_tendency_forcing_indexing_type), intent(in) :: interior_tendency_forcing_ind
type(autotroph_local_type), intent(in) :: autotroph_local
type(unit_system_type), intent(in) :: unit_system
type(marbl_PAR_type), intent(inout) :: PAR

!-----------------------------------------------------------------------
! local variables
Expand All @@ -574,6 +573,7 @@ subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_for
real (r8), parameter :: PAR_threshold = 1.0e-19_r8

real (r8) :: WORK1(domain%kmt)
real (r8) :: totalChl_local(domain%kmt)
integer(int_kind) :: k, subcol_ind
!-----------------------------------------------------------------------

Expand Down Expand Up @@ -624,7 +624,8 @@ subroutine compute_PAR(domain, interior_tendency_forcings, interior_tendency_for
! compute attenuation coefficient over column
!-----------------------------------------------------------------------

WORK1(:) = max(totalChl_local(1:column_kmt), 0.02_r8)
totalChl_local(:) = sum(autotroph_local%Chl(:,1:column_kmt), dim=1)
WORK1(:) = max(totalChl_local(:), 0.02_r8)
do k = 1, column_kmt
if (WORK1(k) < 0.13224_r8) then
PAR%KPARdz(k) = (0.0919_r8*unit_system%len2m)*(WORK1(k)**0.3536_r8)
Expand Down Expand Up @@ -752,7 +753,7 @@ end subroutine marbl_interior_tendency_adjust_bury_coeff
!***********************************************************************

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

!-----------------------------------------------------------------------
! create local copies of model tracers
Expand All @@ -765,7 +766,6 @@ subroutine setup_local_tracers(column_kmt, marbl_tracer_indices, tracers, &
type(autotroph_local_type) , intent(inout) :: autotroph_local
real (r8) , intent(out) :: tracer_local(:,:)
type(zooplankton_local_type) , intent(inout) :: zooplankton_local
real (r8) , intent(out) :: totalChl_local(:)

!-----------------------------------------------------------------------
! local variables
Expand Down Expand Up @@ -846,13 +846,6 @@ subroutine setup_local_tracers(column_kmt, marbl_tracer_indices, tracers, &
! autotroph consistency check
call autotroph_zero_consistency_enforce(column_kmt, marbl_tracer_indices, autotroph_local)

! set totalChl_local
if (autotroph_cnt > 0) then
totalChl_local = sum(autotroph_local%Chl(:,:), dim=1)
else
totalChl_local = c0
end if

end subroutine setup_local_tracers

!***********************************************************************
Expand Down

0 comments on commit 117b43c

Please sign in to comment.