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 some max_patch_per_col and maxsoil_patches loops #2056

Merged
merged 9 commits into from
Aug 25, 2023
Prev Previous commit
Next Next commit
Adjust white space to reduce diffs from main
  • Loading branch information
slevis-lmwg committed Aug 22, 2023
commit f10c7fe07fa6d6123437a4049316873e3e0fb40c
78 changes: 39 additions & 39 deletions src/biogeochem/CNCIsoFluxMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ subroutine CIsoFlux3(num_soilp, filter_soilp, &
cc = patch%column(pp)
do j = 1, nlevdecomp
iso_cnveg_cf%m_c_to_litr_fire_col(cc,j,i_met_lit) = &
iso_cnveg_cf%m_c_to_litr_fire_col(cc,j,i_met_lit) + &
iso_cnveg_cf%m_c_to_litr_fire_col(cc,j,i_met_lit) + &
((iso_cnveg_cf%m_leafc_to_litter_fire_patch(pp) * lf_f(ivt(pp),i_met_lit) &
+iso_cnveg_cf%m_leafc_storage_to_litter_fire_patch(pp) + &
iso_cnveg_cf%m_leafc_xfer_to_litter_fire_patch(pp) + &
Expand All @@ -1318,7 +1318,7 @@ subroutine CIsoFlux3(num_soilp, filter_soilp, &
iso_cnveg_cf%m_livecrootc_xfer_to_litter_fire_patch(pp) &
+iso_cnveg_cf%m_deadcrootc_storage_to_litter_fire_patch(pp) + &
iso_cnveg_cf%m_deadcrootc_xfer_to_litter_fire_patch(pp))* croot_prof(pp,j)) * patch%wtcol(pp)

! Here metabolic litter is treated differently than other
! types of litter, so it remains outside this litter loop,
! in the line above
Expand Down Expand Up @@ -1350,8 +1350,8 @@ subroutine CNCIsoLitterToColumn (num_soilp, filter_soilp, &
!DML

! !ARGUMENTS:
integer , intent(in) :: num_soilp ! number of soil columns in filter
integer , intent(in) :: filter_soilp(:) ! filter for soil columns
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! filter for soil patches
type(soilbiogeochem_state_type) , intent(in) :: soilbiogeochem_state_inst
type(cnveg_carbonflux_type) , intent(inout) :: iso_cnveg_carbonflux_inst
!
Expand Down Expand Up @@ -1384,20 +1384,20 @@ subroutine CNCIsoLitterToColumn (num_soilp, filter_soilp, &

do i = i_litr_min, i_litr_max
phenology_c_to_litr_c(c,j,i) = &
phenology_c_to_litr_c(c,j,i) + &
! leaf litter carbon fluxes
leafc_to_litter(p) * lf_f(ivt(p),i) * wtcol(p) * leaf_prof(p,j) + &
! fine root litter carbon fluxes
frootc_to_litter(p) * fr_f(ivt(p),i) * wtcol(p) * froot_prof(p,j)
phenology_c_to_litr_c(c,j,i) + &
! leaf litter carbon fluxes
leafc_to_litter(p) * lf_f(ivt(p),i) * wtcol(p) * leaf_prof(p,j) + &
! fine root litter carbon fluxes
frootc_to_litter(p) * fr_f(ivt(p),i) * wtcol(p) * froot_prof(p,j)
end do

!DML
if (ivt(p) >= npcropmin) then ! add livestemc to litter
! stem litter carbon fluxes
do i = i_litr_min, i_litr_max
phenology_c_to_litr_c(c,j,i) = &
phenology_c_to_litr_c(c,j,i) + &
livestemc_to_litter(p) * lf_f(ivt(p),i) * wtcol(p) * leaf_prof(p,j)
phenology_c_to_litr_c(c,j,i) + &
livestemc_to_litter(p) * lf_f(ivt(p),i) * wtcol(p) * leaf_prof(p,j)
end do

if (.not. use_grainproduct) then
Expand All @@ -1420,7 +1420,7 @@ subroutine CNCIsoLitterToColumn (num_soilp, filter_soilp, &
end do
end do
end if
!DML
!DML
end do
end do

Expand All @@ -1437,8 +1437,8 @@ subroutine CNCIsoGapPftToColumn (num_soilp, filter_soilp, &
! to the column level and assign them to the three litter pools (+ cwd pool)
!
! !ARGUMENTS:
integer , intent(in) :: num_soilp ! number of soil columns in filter
integer , intent(in) :: filter_soilp(:) ! soil column filter
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! soil patch filter
type(soilbiogeochem_state_type) , intent(in) :: soilbiogeochem_state_inst
type(cnveg_carbonflux_type) , intent(inout) :: iso_cnveg_carbonflux_inst
!
Expand Down Expand Up @@ -1491,12 +1491,12 @@ subroutine CNCIsoGapPftToColumn (num_soilp, filter_soilp, &
do i = i_litr_min, i_litr_max
! leaf gap mortality carbon fluxes
gap_mortality_c_to_litr_c(c,j,i) = &
gap_mortality_c_to_litr_c(c,j,i) + &
m_leafc_to_litter(p) * lf_f(ivt(p),i) * wtcol(p) * leaf_prof(p,j)
gap_mortality_c_to_litr_c(c,j,i) + &
m_leafc_to_litter(p) * lf_f(ivt(p),i) * wtcol(p) * leaf_prof(p,j)
! fine root gap mortality carbon fluxes
gap_mortality_c_to_litr_c(c,j,i) = &
gap_mortality_c_to_litr_c(c,j,i) + &
m_frootc_to_litter(p) * fr_f(ivt(p),i) * wtcol(p) * froot_prof(p,j)
gap_mortality_c_to_litr_c(c,j,i) + &
m_frootc_to_litter(p) * fr_f(ivt(p),i) * wtcol(p) * froot_prof(p,j)
end do

! wood gap mortality carbon fluxes
Expand All @@ -1513,23 +1513,23 @@ subroutine CNCIsoGapPftToColumn (num_soilp, filter_soilp, &
! of litter, so it gets this additional line after the
! most recent loop over all litter types
gap_mortality_c_to_litr_c(c,j,i_met_lit) = &
gap_mortality_c_to_litr_c(c,j,i_met_lit) + &
! storage gap mortality carbon fluxes
m_leafc_storage_to_litter(p) * wtcol(p) * leaf_prof(p,j) + &
m_frootc_storage_to_litter(p) * wtcol(p) * froot_prof(p,j) + &
m_livestemc_storage_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_deadstemc_storage_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_livecrootc_storage_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_deadcrootc_storage_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_gresp_storage_to_litter(p) * wtcol(p) * leaf_prof(p,j) + &
! transfer gap mortality carbon fluxes
m_leafc_xfer_to_litter(p) * wtcol(p) * leaf_prof(p,j) + &
m_frootc_xfer_to_litter(p) * wtcol(p) * froot_prof(p,j) + &
m_livestemc_xfer_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_deadstemc_xfer_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_livecrootc_xfer_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_deadcrootc_xfer_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_gresp_xfer_to_litter(p) * wtcol(p) * leaf_prof(p,j)
gap_mortality_c_to_litr_c(c,j,i_met_lit) + &
! storage gap mortality carbon fluxes
m_leafc_storage_to_litter(p) * wtcol(p) * leaf_prof(p,j) + &
m_frootc_storage_to_litter(p) * wtcol(p) * froot_prof(p,j) + &
m_livestemc_storage_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_deadstemc_storage_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_livecrootc_storage_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_deadcrootc_storage_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_gresp_storage_to_litter(p) * wtcol(p) * leaf_prof(p,j) + &
! transfer gap mortality carbon fluxes
m_leafc_xfer_to_litter(p) * wtcol(p) * leaf_prof(p,j) + &
m_frootc_xfer_to_litter(p) * wtcol(p) * froot_prof(p,j) + &
m_livestemc_xfer_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_deadstemc_xfer_to_litter(p) * wtcol(p) * stem_prof(p,j) + &
m_livecrootc_xfer_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_deadcrootc_xfer_to_litter(p) * wtcol(p) * croot_prof(p,j) + &
m_gresp_xfer_to_litter(p) * wtcol(p) * leaf_prof(p,j)

end do
end do
Expand All @@ -1548,8 +1548,8 @@ subroutine CNCIsoHarvestPftToColumn (num_soilp, filter_soilp, &
! to the column level and assign them to the litter, cwd, and wood product pools
!
! !ARGUMENTS:
integer , intent(in) :: num_soilp ! number of soil columns in filter
integer , intent(in) :: filter_soilp(:) ! soil column filter
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! soil patch filter
type(soilbiogeochem_state_type) , intent(in) :: soilbiogeochem_state_inst
type(cnveg_carbonflux_type) , intent(inout) :: iso_cnveg_carbonflux_inst
!
Expand Down Expand Up @@ -1664,8 +1664,8 @@ subroutine CNCIsoGrossUnrepPftToColumn (num_soilp, filter_soilp, &
! to the column level and assign them to the litter, cwd, and wood product pools
!
! !ARGUMENTS:
integer , intent(in) :: num_soilp ! number of soil columns in filter
integer , intent(in) :: filter_soilp(:) ! soil column filter
integer , intent(in) :: num_soilp ! number of soil patches in filter
integer , intent(in) :: filter_soilp(:) ! soil patch filter
type(soilbiogeochem_state_type) , intent(in) :: soilbiogeochem_state_inst
type(cnveg_carbonflux_type) , intent(inout) :: iso_cnveg_carbonflux_inst
!
Expand Down
2 changes: 1 addition & 1 deletion src/biogeochem/CNPhenologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3800,7 +3800,7 @@ subroutine CNLitterToColumn (bounds, num_bgc_vegp, filter_bgc_vegp, &
end do do_vegp
end do do_nlev

end associate
end associate

end subroutine CNLitterToColumn

Expand Down