Skip to content

Commit

Permalink
Use ifmp and fmp indicies in veg%froot calculation (#462)
Browse files Browse the repository at this point in the history
Currently veg%rootbeta may be partially initialised over the range
ifmp:fmp when calculating veg%froot. This is the case for offline MPI
configurations. This change avoids accessing uninitialised memory when
calculating veg%froot.

Fixes #395

## Type of change

Please delete options that are not relevant.

- [x] Bug fix

## Checklist

- [x] I have checked my code/text and corrected any misspellings


<!-- readthedocs-preview cable start -->
----
📚 Documentation preview 📚:
https://cable--462.org.readthedocs.build/en/462/

<!-- readthedocs-preview cable end -->
  • Loading branch information
SeanBryan51 authored Nov 7, 2024
2 parents f1bc23a + e88e9b4 commit ca4c13e
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions src/offline/cable_parameters.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,6 @@ SUBROUTINE write_default_params(met, air, ssnow, veg, bgc, &
INTEGER :: e,f,h,i,klev ! do loop counter
INTEGER :: is ! YP oct07
INTEGER :: ir ! BP sep2010
REAL :: totdepth ! YP oct07
REAL :: tmp ! BP sep2010

! The following is for the alternate method to calculate froot by Zeng 2001
Expand Down Expand Up @@ -1261,18 +1260,6 @@ SUBROUTINE write_default_params(met, air, ssnow, veg, bgc, &

veg%meth = 1 ! canopy turbulence parameterisation method: 0 or 1

! I brought this in with manual merge of #199 BUT Am i bringing this back in ?
! calculate vegin%froot from using rootbeta and soil depth
! (Jackson et al. 1996, Oceologica, 108:389-411)
!totdepth = 0.0
!DO is = 1, ms
! totdepth = totdepth + soil%zse(is) * 100.0 ! unit in centimetres
! vegin%froot(is, :) = MIN(1.0, 1.0-vegin%rootbeta(:)**totdepth)
!END DO
!DO is = ms, 2, -1
! vegin%froot(is, :) = vegin%froot(is, :)-vegin%froot(is-1, :)
!END DO

ALLOCATE(defaultLAI(mp, 12))

DO e = 1, mland ! over all land grid points
Expand Down Expand Up @@ -3339,12 +3326,12 @@ SUBROUTINE init_veg_from_vegin(ifmp,fmp, veg, soil_zse )
! (Jackson et al. 1996, Oceologica, 108:389-411)
totdepth = 0.0
DO is = 1, ms-1
totdepth = totdepth + soil_zse(is) * 100.0 ! unit in centimetres
veg%froot(:, is) = MIN( 1.0, 1.0-veg%rootbeta(:)**totdepth )
totdepth = totdepth + soil_zse(is) * 100.0 ! unit in centimetres
veg%froot(ifmp:fmp, is) = MIN( 1.0, 1.0-veg%rootbeta(ifmp:fmp)**totdepth )
END DO
veg%froot(:, ms) = 1.0 - veg%froot(:, ms-1)
veg%froot(ifmp:fmp, ms) = 1.0 - veg%froot(ifmp:fmp, ms-1)
DO is = ms-1, 2, -1
veg%froot(:, is) = veg%froot(:, is)-veg%froot(:,is-1)
veg%froot(ifmp:fmp, is) = veg%froot(ifmp:fmp, is)-veg%froot(ifmp:fmp,is-1)
END DO

END SUBROUTINE init_veg_from_vegin
Expand Down

0 comments on commit ca4c13e

Please sign in to comment.