Skip to content

Commit

Permalink
Code clean-up following review
Browse files Browse the repository at this point in the history
* several "zooC" -> "total zooC" or "zoototC" in comments
* R1[34]C_zooC -> R1[34]C_zoototC
* autotroph consistency check has a single "if (ciso_on) then" block
  and checks for Ca1[34]CO3_ind instead of individual checks for all
  isotopic autotroph tracers
* ciso_set_interior_forcing(): reordered arguments in interface so all
  intent(in)s are clumped together, followed by the (inout)s
  • Loading branch information
mnlevy1981 committed Apr 20, 2018
1 parent a284a46 commit d106c6d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 46 deletions.
42 changes: 21 additions & 21 deletions src/marbl_ciso_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ subroutine marbl_ciso_set_interior_forcing( &
autotroph_local, &
autotroph_secondary_species, &
temperature, &
column_dtracer, &
marbl_tracer_indices, &
column_dtracer, &
marbl_interior_diags, &
marbl_status_log)

Expand All @@ -240,8 +240,8 @@ subroutine marbl_ciso_set_interior_forcing( &
type(autotroph_local_type) , intent(in) :: autotroph_local(:,:)
type(autotroph_secondary_species_type), intent(in) :: autotroph_secondary_species(:,:)
real (r8) , intent(in) :: temperature(:)
real (r8) , intent(inout) :: column_dtracer(:,:) ! computed source/sink terms (inout because we don't touch non-ciso tracers)
type(marbl_tracer_index_type) , intent(in) :: marbl_tracer_indices
real (r8) , intent(inout) :: column_dtracer(:,:) ! computed source/sink terms (inout because we don't touch non-ciso tracers)
type(marbl_diagnostics_type) , intent(inout) :: marbl_interior_diags
type(marbl_log_type) , intent(inout) :: marbl_status_log

Expand Down Expand Up @@ -287,12 +287,12 @@ subroutine marbl_ciso_set_interior_forcing( &
R13C_CO2STAR, & ! 13C/12C in CO2* water
R13C_DIC, & ! 13C/12C in total DIC
R13C_DOCtot, & ! 13C/12C in total DOCtot
R13C_zooC, & ! 13C/12C in total zooplankton
R13C_zoototC, & ! 13C/12C in total zooplankton
R14C_CaCO3_form, & ! 14C/12C in CaCO3 production of small phyto
R14C_CO2STAR, & ! 14C/12C in CO2* water
R14C_DIC, & ! 14C/12C in total DIC
R14C_DOCtot, & ! 14C/12C in total DOCtot
R14C_zooC ! 14C/12C in total zooplankton
R14C_zoototC ! 14C/12C in total zooplankton

real (r8), dimension(autotroph_cnt, marbl_domain%km) :: &
Ca13CO3_PROD, & ! prod. of 13C CaCO3 by small phyto (mmol CaCO3/m^3/sec)
Expand Down Expand Up @@ -331,10 +331,10 @@ subroutine marbl_ciso_set_interior_forcing( &
delta_C14_CO2STAR, & ! deltaC14 of CO2*
DIC_d13C, & ! d13C of DIC
DOCtot_d13C, & ! d13C of DOCtot
zoototC_d13C, & ! d13C of zooC
zoototC_d13C, & ! d13C of zoototC
DIC_d14C, & ! d14C of DIC
DOCtot_d14C, & ! d14C of DOCtot
zoototC_d14C, & ! d14C of zooC
zoototC_d14C, & ! d14C of zoototC
decay_14Ctot ! 14C decay loss term

!-------------------------------------------------------------
Expand Down Expand Up @@ -371,7 +371,7 @@ subroutine marbl_ciso_set_interior_forcing( &
CaCO3_form => autotroph_secondary_species%CaCO3_form , & ! INPUT prod. of CaCO3 by small phyto (mmol CaCO3/m^3/sec)
PCphoto => autotroph_secondary_species%PCphoto , & ! INPUT C-specific rate of photosynth. (1/sec)

zoototC_loc => marbl_zooplankton_share%zoototC_loc_fields , & ! INPUT local copy of model zooC
zoototC_loc => marbl_zooplankton_share%zoototC_loc_fields , & ! INPUT local copy of model zoototC
zootot_loss => marbl_zooplankton_share%zootot_loss_fields , & ! INPUT mortality & higher trophic grazing on zooplankton (mmol C/m^3/sec)
zootot_loss_poc => marbl_zooplankton_share%zootot_loss_poc_fields , & ! INPUT zootot_loss routed to large detrital pool (mmol C/m^3/sec)
zootot_loss_doc => marbl_zooplankton_share%zootot_loss_doc_fields , & ! INPUT zootot_loss routed to doc (mmol C/m^3/sec)
Expand Down Expand Up @@ -459,11 +459,11 @@ subroutine marbl_ciso_set_interior_forcing( &
end if

if (zoototC_loc(k) > c0) then
R13C_zooC(k) = zootot13C_loc(k) / zoototC_loc(k)
R14C_zooC(k) = zootot14C_loc(k) / zoototC_loc(k)
R13C_zoototC(k) = zootot13C_loc(k) / zoototC_loc(k)
R14C_zoototC(k) = zootot14C_loc(k) / zoototC_loc(k)
else
R13C_zooC(k) = c0
R14C_zooC(k) = c0
R13C_zoototC(k) = c0
R14C_zoototC(k) = c0
end if

do auto_ind = 1, autotroph_cnt
Expand Down Expand Up @@ -656,11 +656,11 @@ subroutine marbl_ciso_set_interior_forcing( &
!-----------------------------------------------------------------------

DO13Ctot_prod(k) = &
(zootot_loss_doc(k) + zootot_graze_doc(k))*R13C_zooC(k) + &
(zootot_loss_doc(k) + zootot_graze_doc(k))*R13C_zoototC(k) + &
sum((auto_loss_doc(:,k) + auto_graze_doc(:,k)) * R13C_autotroph(:,k),dim=1)

DO14Ctot_prod(k) = &
(zootot_loss_doc(k) + zootot_graze_doc(k))*R14C_zooC(k) + &
(zootot_loss_doc(k) + zootot_graze_doc(k))*R14C_zoototC(k) + &
sum((auto_loss_doc(:,k) + auto_graze_doc(:,k)) * R14C_autotroph(:,k),dim=1)

DO13Ctot_remin(k) = DOCtot_remin(k) * R13C_DOCtot(k)
Expand All @@ -671,11 +671,11 @@ subroutine marbl_ciso_set_interior_forcing( &
!-----------------------------------------------------------------------

PO13C%prod(k) = &
(zootot_loss_poc(k) + zootot_graze_poc(k))*R13C_zooC(k) + &
(zootot_loss_poc(k) + zootot_graze_poc(k))*R13C_zoototC(k) + &
sum((auto_graze_poc(:,k) + auto_agg(:,k) + auto_loss_poc(:,k)) * R13C_autotroph(:,k),dim=1)

PO14C%prod(k) = &
(zootot_loss_poc(k) + zootot_graze_poc(k))*R14C_zooC(k) + &
(zootot_loss_poc(k) + zootot_graze_poc(k))*R14C_zoototC(k) + &
sum((auto_graze_poc(:,k) + auto_agg(:,k) + auto_loss_poc(:,k)) * R14C_autotroph(:,k),dim=1)

!-----------------------------------------------------------------------
Expand All @@ -699,8 +699,8 @@ subroutine marbl_ciso_set_interior_forcing( &
DOCtot_d13C(k) = ( R13C_DOCtot(k) / R13C_std - c1 ) * c1000
DOCtot_d14C(k) = ( R14C_DOCtot(k) / R14C_std - c1 ) * c1000

zoototC_d13C(k)= ( R13C_zooC(k) / R13C_std - c1 ) * c1000
zoototC_d14C(k)= ( R14C_zooC(k) / R14C_std - c1 ) * c1000
zoototC_d13C(k)= ( R13C_zoototC(k) / R13C_std - c1 ) * c1000
zoototC_d14C(k)= ( R14C_zoototC(k) / R14C_std - c1 ) * c1000

do auto_ind = 1, autotroph_cnt
if (marbl_tracer_indices%auto_inds(auto_ind)%CaCO3_ind > 0) then
Expand Down Expand Up @@ -770,12 +770,12 @@ subroutine marbl_ciso_set_interior_forcing( &
column_dtracer(zootot13C_ind,k) = &
sum(auto_graze_zoo(:,k) * R13C_autotroph(:,k),dim=1) &
+ (zootot_graze_zoo(k) - zootot_graze(k) - zootot_loss(k)) &
* R13C_zooC(k)
* R13C_zoototC(k)

column_dtracer(zootot14C_ind,k) = &
sum(auto_graze_zoo(:,k) * R14C_autotroph(:,k),dim=1) &
+ (zootot_graze_zoo(k) - zootot_graze(k) - zootot_loss(k)) &
* R14C_zooC(k) - c14_lambda_inv_sec * zootot14C_loc(k)
* R14C_zoototC(k) - c14_lambda_inv_sec * zootot14C_loc(k)

decay_14Ctot(k) = decay_14Ctot(k) + c14_lambda_inv_sec * zootot14C_loc(k)

Expand All @@ -797,14 +797,14 @@ subroutine marbl_ciso_set_interior_forcing( &
sum((auto_loss_dic(:,k) + auto_graze_dic(:,k))*R13C_autotroph(:,k),dim=1) &
- sum(photo13C(:,k),dim=1) &
+ DO13Ctot_remin(k) + PO13C%remin(k) &
+ (zootot_loss_dic(k) + zootot_graze_dic(k)) * R13C_zooC(k) &
+ (zootot_loss_dic(k) + zootot_graze_dic(k)) * R13C_zoototC(k) &
+ P_Ca13CO3%remin(k)

column_dtracer(di14c_ind,k) = &
sum((auto_loss_dic(:,k) + auto_graze_dic(:,k))*R14C_autotroph(:,k),dim=1) &
- sum(photo14C(:,k),dim=1) &
+ DO14Ctot_remin(k) + PO14C%remin(k) &
+ (zootot_loss_dic(k) + zootot_graze_dic(k)) * R14C_zooC(k) &
+ (zootot_loss_dic(k) + zootot_graze_dic(k)) * R14C_zoototC(k) &
+ P_Ca14CO3%remin(k) &
- c14_lambda_inv_sec * DI14C_loc(k)

Expand Down
24 changes: 12 additions & 12 deletions src/marbl_diagnostics_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,10 @@ module marbl_diagnostics_mod
integer (int_kind), allocatable :: CISO_photo14C(:) ! 14C fixation
integer (int_kind), allocatable :: CISO_photo13C_zint(:) ! 13C fixation vertical integral
integer (int_kind), allocatable :: CISO_photo14C_zint(:) ! 14C fixation vertical integral
integer (int_kind), allocatable :: CISO_d13C(:) ! if for d13C of autotroph carbon
integer (int_kind), allocatable :: CISO_d14C(:) ! if for d14C of autotroph carbon
integer (int_kind), allocatable :: CISO_autotrophCaCO3_d14C(:) ! if for d14C of autotrophCaCO3
integer (int_kind), allocatable :: CISO_autotrophCaCO3_d13C(:) ! if for d13C of autotrophCaCO3
integer (int_kind), allocatable :: CISO_d13C(:) ! d13C of autotroph carbon
integer (int_kind), allocatable :: CISO_d14C(:) ! d14C of autotroph carbon
integer (int_kind), allocatable :: CISO_autotrophCaCO3_d14C(:) ! d14C of autotrophCaCO3
integer (int_kind), allocatable :: CISO_autotrophCaCO3_d13C(:) ! d13C of autotrophCaCO3

integer (int_kind) :: CISO_eps_aq_g ! eps_aq_g
integer (int_kind) :: CISO_eps_dic_g ! eps_dic_g
Expand All @@ -320,12 +320,12 @@ module marbl_diagnostics_mod
integer (int_kind) :: CISO_DO14Ctot_remin ! do14ctot remineralization
integer (int_kind) :: CISO_Jint_13Ctot ! vertically integrated source sink term, 13Ctot
integer (int_kind) :: CISO_Jint_14Ctot ! vertically integrated source sink term, 14Ctot
integer (int_kind) :: CISO_zoototC_d13C ! if for d13C of zooC
integer (int_kind) :: CISO_zoototC_d14C ! if for d14C of zooC
integer (int_kind) :: CISO_DOCtot_d13C ! if for d13C of DOCtot
integer (int_kind) :: CISO_DOCtot_d14C ! if for d14C of DOCtot
integer (int_kind) :: CISO_DIC_d13C ! if for d13C of DIC
integer (int_kind) :: CISO_DIC_d14C ! if for d14C of DIC
integer (int_kind) :: CISO_zoototC_d13C ! d13C of total zooC
integer (int_kind) :: CISO_zoototC_d14C ! d14C of total zooC
integer (int_kind) :: CISO_DOCtot_d13C ! d13C of DOCtot
integer (int_kind) :: CISO_DOCtot_d14C ! d14C of DOCtot
integer (int_kind) :: CISO_DIC_d13C ! d13C of DIC
integer (int_kind) :: CISO_DIC_d14C ! d14C of DIC
integer (int_kind) :: calcToSed_13C ! calcite flux sedimentary burial
integer (int_kind) :: calcToSed_14C ! calcite flux sedimentary burial
integer (int_kind) :: pocToSed_13C ! poc burial flux to sediments
Expand Down Expand Up @@ -5404,8 +5404,8 @@ subroutine store_diagnostics_ciso_interior(&
DIC_d14C , & ! d14C of DIC
DOCtot_d13C , & ! d13C of DOCtot
DOCtot_d14C , & ! d14C of DOCtot
zoototC_d13C , & ! d13C of zooC
zoototC_d14C , & ! d14C of zooC
zoototC_d13C , & ! d13C of total zooC
zoototC_d14C , & ! d14C of total zooC
DO13Ctot_prod , & ! production of 13C DOCtot (mmol C/m^3/sec)
DO14Ctot_prod , & ! production of 14C DOCtot (mmol C/m^3/sec)
DO13Ctot_remin , & ! remineralization of 13C DOCtot (mmol C/m^3/sec)
Expand Down
4 changes: 2 additions & 2 deletions src/marbl_interface_private_types.F90
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ module marbl_interface_private_types
! For CISO, don't want individual C13 and C14 tracers for each zooplankton
! Instead we collect them into one tracer for each isotope, regardless of
! zooplankton_cnt
integer (int_kind) :: zootot13C_ind = 0 ! zooplankton carbon 13
integer (int_kind) :: zootot14C_ind = 0 ! zooplankton carbon 14
integer (int_kind) :: zootot13C_ind = 0 ! total zooplankton carbon 13
integer (int_kind) :: zootot14C_ind = 0 ! total zooplankton carbon 14

contains
procedure, public :: add_tracer_index
Expand Down
21 changes: 10 additions & 11 deletions src/marbl_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -817,14 +817,14 @@ subroutine marbl_set_interior_forcing( &
tracer_local = tracer_local, &
autotroph_local = autotroph_local, &
temperature = temperature, &
column_dtracer = dtracers, &
marbl_tracer_indices = marbl_tracer_indices, &
column_dtracer = dtracers, &
marbl_interior_diags = interior_forcing_diags, &
marbl_status_log = marbl_status_log)

if (marbl_status_log%labort_marbl) then
call marbl_status_log%log_error_trace(&
'marbl_ciso_set_interior_foricng()', subname)
'marbl_ciso_set_interior_forcing()', subname)
return
end if
end if
Expand Down Expand Up @@ -2347,17 +2347,16 @@ subroutine marbl_consistency_check_autotrophs(auto_cnt, column_kmt, &
end if

! carbon isotope components of autotroph_local_type
if (marbl_tracer_indices%auto_inds(auto_ind)%C13_ind > 0) then
if (ciso_on) then
autotroph_local(auto_ind,k)%C13 = c0
end if
if (marbl_tracer_indices%auto_inds(auto_ind)%C14_ind > 0) then
autotroph_local(auto_ind,k)%C14 = c0
end if
if (marbl_tracer_indices%auto_inds(auto_ind)%Ca13CO3_ind > 0) then
autotroph_local(auto_ind,k)%Ca13CO3 = c0
end if
if (marbl_tracer_indices%auto_inds(auto_ind)%Ca14CO3_ind > 0) then
autotroph_local(auto_ind,k)%Ca14CO3 = c0

if (marbl_tracer_indices%auto_inds(auto_ind)%Ca13CO3_ind > 0) then
autotroph_local(auto_ind,k)%Ca13CO3 = c0
end if
if (marbl_tracer_indices%auto_inds(auto_ind)%Ca14CO3_ind > 0) then
autotroph_local(auto_ind,k)%Ca14CO3 = c0
end if
end if
end if

Expand Down

0 comments on commit d106c6d

Please sign in to comment.