Skip to content

Commit

Permalink
Refactoring: minor clean-up (removed unused function reset_vegn_initial)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcadella committed Jan 8, 2025
1 parent a9574ca commit 77e0e12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 50 deletions.
6 changes: 2 additions & 4 deletions src/datatypes_biomee.mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ module datatypes_biomee

integer :: n_cohorts = 0.0

!===== For reseting vegetation
integer :: n_initialCC = 0
type(cohort_type), pointer :: initialCC(:) => NULL()

!===== Cohorts nested inside tile
type(cohort_type), pointer :: cohorts(:) => NULL()

Expand Down Expand Up @@ -291,6 +287,8 @@ module datatypes_biomee
end type vegn_tile_type

!=============== PFT-specific parameters ======================================================
! This is a shared variable used to give each cohort a unique ID (a simplpe counter)
! It is fine to share accross tiles.
integer :: MaxCohortID = 0

contains
Expand Down
48 changes: 2 additions & 46 deletions src/vegetation_biomee.mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module md_vegetation_biomee
public :: vegn_nat_mortality, vegn_species_switch
public :: relayer_cohorts, vegn_mergecohorts, kill_lowdensity_cohorts
public :: kill_old_grass
public :: vegn_annual_starvation,Zero_diagnostics, reset_vegn_initial
public :: vegn_annual_starvation,Zero_diagnostics

contains

Expand Down Expand Up @@ -1959,40 +1959,6 @@ subroutine initialize_cohort_from_biomass(cc, btot)

end subroutine initialize_cohort_from_biomass

!============= Reset to Initial Vegetation States =====================
!Weng, 12/20/2022
subroutine reset_vegn_initial(vegn)
type(vegn_tile_type),intent(inout),pointer :: vegn

!--------local vars -------
type(cohort_type),dimension(:), pointer :: cc,cc1
type(cohort_type), pointer :: cp
integer :: i, istat

!Reset to initial plant cohorts
allocate(cc(1:vegn%n_initialCC), STAT = istat)
cc1 => vegn%cohorts ! Remember the current cohorts in vegn
cc = vegn%initialCC ! Copy the initial cohorts to a new cohor array
vegn%cohorts => cc ! Set the vegn%cohorts as the initial cohorts
vegn%n_cohorts = vegn%n_initialCC ! size(vegn%cohorts)

!Release memory
deallocate(cc1) ! Remove the old cohorts
cc => null()

! Relayering and summary
call relayer_cohorts(vegn)
call summarize_tile(vegn)

! ID each cohort
do i=1, vegn%n_cohorts
cp => vegn%cohorts(i)
cp%ccID = MaxCohortID + i
enddo
if (vegn%n_cohorts > 0) MaxCohortID = cp%ccID

end subroutine reset_vegn_initial

subroutine init_cohort_allometry( cc )
!////////////////////////////////////////////////////////////////
! Code from BiomeE-Allocation
Expand Down Expand Up @@ -2114,7 +2080,6 @@ subroutine initialize_vegn_tile( vegn )
real :: btotal
integer :: i, istat, init_n_cohorts

! xxx seems new from d-ben - missing if?
! Initialize plant cohorts
init_n_cohorts = size(myinterface%init_cohort)
allocate(cc(1:init_n_cohorts), STAT = istat)
Expand All @@ -2128,7 +2093,7 @@ subroutine initialize_vegn_tile( vegn )
cx%layer = 1
cx%age = 0
cx%species = INT(myinterface%init_cohort(i)%init_cohort_species)
cx%ccID = i
cx%ccID = i
cx%nindivs = myinterface%init_cohort(i)%init_cohort_nindivs ! trees/m2
cx%plabl%c%c12 = myinterface%init_cohort(i)%init_cohort_nsc
cx%psapw%c%c12 = myinterface%init_cohort(i)%init_cohort_bsw
Expand Down Expand Up @@ -2175,15 +2140,6 @@ subroutine initialize_vegn_tile( vegn )
vegn%psoil_sl%n%n14 + vegn%ninorg%n14
vegn%totN = vegn%initialN0

! For reset: Keep initial plant cohorts
allocate(cc(1:init_n_cohorts), STAT = istat)
cc = vegn%cohorts
vegn%initialCC => cc
vegn%n_initialCC = init_n_cohorts
cc => null()

! xxx up to here new from d-ben

end subroutine initialize_vegn_tile

end module md_vegetation_biomee

0 comments on commit 77e0e12

Please sign in to comment.