Skip to content

Commit

Permalink
Encapsulating all write/print statements to logging in either a debug…
Browse files Browse the repository at this point in the history
… clause, or ensuring there is an endrun following.
  • Loading branch information
rgknox committed Oct 6, 2021
1 parent 70a3e13 commit d4e35f0
Show file tree
Hide file tree
Showing 25 changed files with 257 additions and 300 deletions.
9 changes: 7 additions & 2 deletions biogeochem/EDCanopyStructureMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,10 @@ subroutine update_hlm_dynamics(nsites,sites,fcolumn,bc_out)
ifp = ifp+1

if ( currentPatch%total_canopy_area-currentPatch%area > 0.000001_r8 ) then
write(fates_log(),*) 'ED: canopy area bigger than area',currentPatch%total_canopy_area ,currentPatch%area
if(debug)then
write(fates_log(),*) 'ED: canopy area bigger than area', &
currentPatch%total_canopy_area ,currentPatch%area
end if
currentPatch%total_canopy_area = currentPatch%area
endif

Expand Down Expand Up @@ -2219,7 +2222,9 @@ function NumPotentialCanopyLayers(currentPatch,site_spread,include_substory) res
if(arealayer > currentPatch%area)then
z = z + 1
if(hlm_use_sp.eq.itrue)then
write(fates_log(),*) 'SPmode, canopy_layer full:',arealayer,currentPatch%area
if(debug)then
write(fates_log(),*) 'SPmode, canopy_layer full:',arealayer,currentPatch%area
end if
end if

endif
Expand Down
13 changes: 7 additions & 6 deletions biogeochem/EDCohortDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,6 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
!---------------------------------------------------------------------!
dynamic_size_fusion_tolerance = dynamic_size_fusion_tolerance * 1.1_r8
dynamic_age_fusion_tolerance = dynamic_age_fusion_tolerance * 1.1_r8
!write(fates_log(),*) 'maxcohorts exceeded',dynamic_fusion_tolerance

else

Expand All @@ -1552,7 +1551,6 @@ subroutine fuse_cohorts(currentSite, currentPatch, bc_in)
! Making profile tolerance larger means that more fusion will happen !
!---------------------------------------------------------------------!
dynamic_size_fusion_tolerance = dynamic_size_fusion_tolerance * 1.1_r8
!write(fates_log(),*) 'maxcohorts exceeded',dynamic_fusion_tolerance

else

Expand Down Expand Up @@ -1931,10 +1929,13 @@ subroutine count_cohorts( currentPatch )
currentCohort => currentCohort%shorter
enddo

if (backcount /= currentPatch%countcohorts) then
write(fates_log(),*) 'problem with linked list, not symmetrical'
endif

if(debug) then
if (backcount /= currentPatch%countcohorts) then
write(fates_log(),*) 'problem with linked list, not symmetrical'
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
end if

end subroutine count_cohorts

! ===================================================================================
Expand Down
3 changes: 2 additions & 1 deletion biogeochem/EDLoggingMortalityMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ module EDLoggingMortalityMod
logical, protected :: logging_time ! If true, logging should be
! performed during the current time-step


logical, parameter :: debug = .false.

! harvest litter localization specifies how much of the litter from a falling
! tree lands within the newly generated patch, and how much lands outside of
! the new patch, and thus in the original patch. By setting this to zero,
Expand Down
10 changes: 9 additions & 1 deletion biogeochem/EDMortalityFunctionsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module EDMortalityFunctionsMod

use FatesConstantsMod , only : r8 => fates_r8
use FatesGlobals , only : fates_log
use FatesGlobals , only : endrun => fates_endrun
use FatesGlobals , only : fates_log
use EDPftvarcon , only : EDPftvarcon_inst
use EDTypesMod , only : ed_cohort_type
use EDTypesMod , only : ed_site_type
Expand All @@ -22,10 +24,15 @@ module EDMortalityFunctionsMod

use PRTGenericMod, only : all_carbon_elements
use PRTGenericMod, only : store_organ

use shr_log_mod , only : errMsg => shr_log_errMsg

implicit none
private


logical, parameter :: debug = .false.
character(len=*), parameter, private :: sourcefile = &
__FILE__

public :: mortality_rates
public :: Mortality_Derivative
Expand Down Expand Up @@ -164,6 +171,7 @@ subroutine mortality_rates( cohort_in,bc_in,cmort,hmort,bmort,frmort,smort,asmor
else
write(fates_log(),*) 'dbh problem in mortality_rates', &
cohort_in%dbh,cohort_in%pft,cohort_in%n,cohort_in%canopy_layer
call endrun(msg=errMsg(sourcefile, __LINE__))
endif
!--------------------------------------------------------------------------------
! Mortality due to cold and freezing stress (frmort), based on ED2 and:
Expand Down
11 changes: 5 additions & 6 deletions biogeochem/EDPatchDynamicsMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ subroutine disturbance_rates( site_in, bc_in)
! Fires can't burn the whole patch, as this causes /0 errors.
if (debug) then
if (currentPatch%disturbance_rates(dtype_ifire) > 0.98_r8)then
write(fates_log(),*) 'very high fire areas', &
currentPatch%disturbance_rates(dtype_ifire),currentPatch%frac_burnt
write(fates_log(),*) 'very high fire areas', &
currentPatch%disturbance_rates(dtype_ifire),currentPatch%frac_burnt
endif
endif

Expand Down Expand Up @@ -2295,7 +2295,8 @@ subroutine fuse_patches( csite, bc_in )
do while(associated(tpp))

if(.not.associated(currentPatch))then
write(fates_log(),*) 'ED: issue with currentPatch'
write(fates_log(),*) 'FATES fuse_patches(): currentPatch is not associated?'
call endrun(msg=errMsg(sourcefile, __LINE__))
endif

if(associated(tpp).and.associated(currentPatch))then
Expand Down Expand Up @@ -2414,9 +2415,7 @@ subroutine fuse_patches( csite, bc_in )
!------------------------------------------------------------------------!

profiletol = ED_val_patch_fusion_tol

else
! write(fates_log(),*) 'patches not fused'

endif
endif !are both patches the same anthropogenic disturbance category as the disturbance type loop iterator?
endif !are both patches associated?
Expand Down
9 changes: 0 additions & 9 deletions biogeochem/EDPhysiologyMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,6 @@ subroutine trim_canopy( currentSite )
! Make sure the cohort trim fraction is great than the pft trim limit
if (currentCohort%canopy_trim > EDPftvarcon_inst%trim_limit(ipft)) then

! if ( debug ) then
! write(fates_log(),*) 'trimming leaves', &
! currentCohort%canopy_trim,currentCohort%leaf_cost
! endif

! keep trimming until none of the canopy is in negative carbon balance.
if (currentCohort%hite > EDPftvarcon_inst%hgt_min(ipft)) then
currentCohort%canopy_trim = currentCohort%canopy_trim - &
Expand All @@ -620,10 +615,6 @@ subroutine trim_canopy( currentSite )
call dgels(trans, m, n, nrhs, nnu_clai_a, lda, nnu_clai_b, ldb, work, lwork, info)
lwork = int(work(1)) ! Pick the optimum. TBD, can work(1) come back with greater than work size?

! if (debug) then
! write(fates_log(),*) 'LLSF lwork output (info, lwork):', info, lwork
! endif

! Compute the minimum of 2-norm of of the least squares fit to solve for X
! Note that dgels returns the solution by overwriting the nnu_clai_b array.
! The result has the form: X = [b; m]
Expand Down
9 changes: 6 additions & 3 deletions biogeochem/FatesAllometryMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2448,9 +2448,12 @@ subroutine ForceDBH( ipft, canopy_trim, d, h, bdead, bl )
end if

call h_allom(d,ipft,h)
if(counter>10)then
write(fates_log(),*) 'dbh counter: ',counter,' is woody: ',&
int(prt_params%woody(ipft))==itrue

if(debug) then
if(counter>10)then
write(fates_log(),*) 'dbh counter: ',counter,' is woody: ',&
int(prt_params%woody(ipft))==itrue
end if
end if


Expand Down
4 changes: 2 additions & 2 deletions biogeophys/EDAccumulateFluxesMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module EDAccumulateFluxesMod
! Rosie Fisher. March 2014.
!
! !USES:
use FatesGlobals, only : fates_endrun
use FatesGlobals, only : endrun => fates_endrun
use FatesGlobals, only : fates_log
use shr_log_mod , only : errMsg => shr_log_errMsg
use FatesConstantsMod , only : r8 => fates_r8

use shr_log_mod , only : errMsg => shr_log_errMsg

implicit none
private
Expand Down
10 changes: 9 additions & 1 deletion biogeophys/EDBtranMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ module EDBtranMod
use FatesInterfaceTypesMod , only : hlm_use_planthydro
use FatesGlobals , only : fates_log
use FatesAllometryMod , only : set_root_fraction
use shr_log_mod , only : errMsg => shr_log_errMsg
use FatesGlobals, only : endrun => fates_endrun

!
implicit none
private


logical, parameter :: debug = .false.

public :: btran_ed
public :: get_active_suction_layers
public :: check_layer_water
Expand Down Expand Up @@ -231,10 +236,13 @@ subroutine btran_ed( nsites, sites, bc_in, bc_out)
temprootr = sum(bc_out(s)%rootr_pasl(ifp,1:bc_in(s)%nlevsoil))

if(abs(1.0_r8-temprootr) > 1.0e-10_r8 .and. temprootr > 1.0e-10_r8)then
write(fates_log(),*) 'error with rootr in canopy fluxes',temprootr,sum_pftgs

if(debug) write(fates_log(),*) 'error with rootr in canopy fluxes',temprootr,sum_pftgs

do j = 1,bc_in(s)%nlevsoil
bc_out(s)%rootr_pasl(ifp,j) = bc_out(s)%rootr_pasl(ifp,j)/temprootr
enddo

end if
endif ! not bare ground
cpatch => cpatch%younger
Expand Down
Loading

0 comments on commit d4e35f0

Please sign in to comment.