Skip to content

Commit

Permalink
Added more gfortran debug flag option and fixed FPEs.
Browse files Browse the repository at this point in the history
  • Loading branch information
drnimbusrain committed Jan 24, 2024
1 parent 4329e91 commit 29863dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ $(info DEBUG setting: '$(DEBUG)')
ifeq ($(DEBUG), 1)
ifeq ($(findstring gfortran,$(notdir $(FC))),gfortran)
FCFLAGS := -g -Wall -Wextra -Wconversion -Og -pedantic -fcheck=bounds -fmax-errors=5 -std=f2003 -fall-intrinsics
# More Debug Flags

This comment has been minimized.

Copy link
@drnimbusrain

drnimbusrain Jan 24, 2024

Author Member

Thanks to @zmoon for adding these.

This comment has been minimized.

Copy link
@zmoon

zmoon Jan 25, 2024

Member

We could make make that the DEBUG=2 option?

This comment has been minimized.

Copy link
@drnimbusrain

drnimbusrain via email Jan 25, 2024

Author Member

This comment has been minimized.

Copy link
@drnimbusrain

drnimbusrain via email Jan 25, 2024

Author Member

This comment has been minimized.

Copy link
@zmoon

zmoon Jan 25, 2024

Member

Sure, added these notes to the #85 description.

This comment has been minimized.

Copy link
@drnimbusrain

drnimbusrain via email Jan 25, 2024

Author Member
# FCFLAGS := -g -Og -Wall -Wextra -pedantic -fcheck=all -fmax-errors=5 -std=f2003 \
# -fall-intrinsics -fbacktrace -ffpe-trap=invalid,zero,overflow
else ifeq ($(FC),ifort)
FCFLAGS := -g -warn all -check bounds -implicitnone -O0 -error-limit 5
endif
Expand Down
7 changes: 5 additions & 2 deletions src/canopy_calcs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ SUBROUTINE canopy_calcs(nn)
ubzref = sqrt((uref**2.0) + (vref**2.0))

! ... get scaled canopy model profile and sub-canopy layers
zhc = zk/hcmref
if (hcmref > 0) then
zhc = zk / hcmref
else
zhc = 0
end if
cansublays = min(floor(hcmref/modres),modlays)

! ... check for valid model vegetation types
Expand Down Expand Up @@ -164,7 +168,6 @@ SUBROUTINE canopy_calcs(nn)
end if

! ... calculate zero-plane displacement height/hc and surface (soil+veg) roughness lengths/hc

call canopy_zpd(zhc(1:cansublays), fafraczInt(1:cansublays), &
ubzref, z0ghc, lambdars, cdrag, pai, hcmref, hgtref, &
z0ref, vtyperef, lu_opt, z0_opt, d_h, zo_h)
Expand Down
6 changes: 5 additions & 1 deletion src/canopy_profile_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,11 @@ SUBROUTINE CANOPY_ZPD( ZHC, FCLAI, UBZREF, Z0GHC, &
dha = 1.0 - (cosh(qstar*nrat*FCLAI(1))/cosh(qstar*nrat))
fafraczInt_tota = IntegrateTrapezoid( ZHC,(cosh(qstar*nrat*FCLAI)*ZHC) )
fafraczInt_totb = IntegrateTrapezoid( ZHC, cosh(qstar*nrat*FCLAI) )
dhb = fafraczInt_tota/fafraczInt_totb
if (fafraczInt_totb > 0) then
dhb = fafraczInt_tota/fafraczInt_totb
else
dhb = 0
end if

! Final zero-plane displacement (zpd) height
d_h = dha * dhb
Expand Down

0 comments on commit 29863dc

Please sign in to comment.