From 078d94ca80765662cb2686b01cdfee4671e0c408 Mon Sep 17 00:00:00 2001 From: Beni Stocker Date: Mon, 29 Apr 2024 23:32:37 +0200 Subject: [PATCH] resolved some bugs after PR from DBEN changes --- src/biosphere_biomee.mod.f90 | 46 +++++------- src/sofun_r.f90 | 24 +++--- src/vegetation_biomee.mod.f90 | 8 +- src/wrappersc.c | 134 +++++++++++++++++----------------- vignettes/biomee_use.Rmd | 10 +-- 5 files changed, 102 insertions(+), 120 deletions(-) diff --git a/src/biosphere_biomee.mod.f90 b/src/biosphere_biomee.mod.f90 index 24af5739..4ee64b84 100644 --- a/src/biosphere_biomee.mod.f90 +++ b/src/biosphere_biomee.mod.f90 @@ -196,39 +196,33 @@ subroutine biosphere_annual(out_biosphere) ! update the years of model run iyears = iyears + 1 - !--------------------------------------------- - ! Reset vegetation to initial conditions - !--------------------------------------------- + ! !--------------------------------------------- + ! ! Reset vegetation to initial conditions + ! !--------------------------------------------- - !if (iyears > myinterface%params_siml%spinupyears+31 .and. rand(0)<0.40) & - ! call reset_vegn_initial(vegn) ! 0.01, 0.02, 0.04, 0.08, 0.20, 0.40 + ! !if (iyears > myinterface%params_siml%spinupyears+31 .and. rand(0)<0.40) & + ! ! call reset_vegn_initial(vegn) ! 0.01, 0.02, 0.04, 0.08, 0.20, 0.40 - !if (iyears == 700 .or. iyears == 800) & - ! call reset_vegn_initial(vegn) - - if (myinterface%steering%finalize) then - !---------------------------------------------------------------- - ! Finazlize run: deallocating memory - !---------------------------------------------------------------- - deallocate( vegn ) + ! !if (iyears == 700 .or. iyears == 800) & + ! ! call reset_vegn_initial(vegn) - if(myinterface%params_siml%do_reset_veg) then + ! if(myinterface%params_siml%do_reset_veg) then - if (iyears==myinterface%params_siml%spinupyears + 31) then - call reset_vegn_initial(vegn) - endif + ! if (iyears==myinterface%params_siml%spinupyears + 31) then + ! call reset_vegn_initial(vegn) + ! endif - ! nfrequency = 50 ! 100,75,50,25,15,10 + ! ! nfrequency = 50 ! 100,75,50,25,15,10 - if(myinterface%params_siml%dist_frequency > 0) then - do i = myinterface%params_siml%spinupyears + 31 + myinterface%params_siml%dist_frequency, & - myinterface%params_siml%spinupyears + myinterface%params_siml%nyeartrend, & - myinterface%params_siml%dist_frequency - if (iyears == i) call reset_vegn_initial(vegn) - enddo - endif + ! if(myinterface%params_siml%dist_frequency > 0) then + ! do i = myinterface%params_siml%spinupyears + 31 + myinterface%params_siml%dist_frequency, & + ! myinterface%params_siml%spinupyears + myinterface%params_siml%nyeartrend, & + ! myinterface%params_siml%dist_frequency + ! if (iyears == i) call reset_vegn_initial(vegn) + ! enddo + ! endif - endif + ! endif !---------------------------------------------------------------- ! Finalize run: deallocating memory diff --git a/src/sofun_r.f90 b/src/sofun_r.f90 index 8d5f7c5d..a59dc381 100644 --- a/src/sofun_r.f90 +++ b/src/sofun_r.f90 @@ -768,17 +768,11 @@ subroutine biomee_f( & !---------------------------------------------------------------- ! Output output_annual_cohorts (without subroutine) !---------------------------------------------------------------- - - ! To get outputs only after spinupyears make if below and - ! also in run_biomee_f_bysite.R make n_annual_cohorts = as.integer(params_siml$nyeartrend) + if (.not. myinterface%steering%spinup) then ! To get outputs only after spinupyears - !if (.not. myinterface%steering%spinup) then ! To get outputs only after spinupyears - !idx = yr - myinterface%params_siml%spinupyears - - ! To get outputs for all runyears idx=yr and also in run_biomee_f_bysite.R make n_annual_cohorts = as.integer(runyears) - idx = yr + idx = yr - myinterface%params_siml%spinupyears - output_annual_cohorts_year(idx, :) = dble(out_biosphere%annual_cohorts(:)%year) !xxx commented out for calibration! + output_annual_cohorts_year(idx, :) = dble(out_biosphere%annual_cohorts(:)%year) output_annual_cohorts_cID(idx, :) = dble(out_biosphere%annual_cohorts(:)%cID) output_annual_cohorts_PFT(idx, :) = dble(out_biosphere%annual_cohorts(:)%PFT) output_annual_cohorts_layer(idx, :) = dble(out_biosphere%annual_cohorts(:)%layer) @@ -794,11 +788,11 @@ subroutine biomee_f( & output_annual_cohorts_Aleaf(idx, :) = dble(out_biosphere%annual_cohorts(:)%Aleaf) output_annual_cohorts_nsc(idx, :) = dble(out_biosphere%annual_cohorts(:)%nsc) output_annual_cohorts_nsn(idx, :) = dble(out_biosphere%annual_cohorts(:)%nsn) - output_annual_cohorts_nsn(idx, :) = dble(out_biosphere%annual_cohorts(:)%seedC) - output_annual_cohorts_nsn(idx, :) = dble(out_biosphere%annual_cohorts(:)%leafC) - output_annual_cohorts_nsn(idx, :) = dble(out_biosphere%annual_cohorts(:)%rootC) - output_annual_cohorts_nsn(idx, :) = dble(out_biosphere%annual_cohorts(:)%sapwC) - output_annual_cohorts_nsn(idx, :) = dble(out_biosphere%annual_cohorts(:)%woodC) + output_annual_cohorts_seedC(idx, :) = dble(out_biosphere%annual_cohorts(:)%seedC) + output_annual_cohorts_leafC(idx, :) = dble(out_biosphere%annual_cohorts(:)%leafC) + output_annual_cohorts_rootC(idx, :) = dble(out_biosphere%annual_cohorts(:)%rootC) + output_annual_cohorts_sapwC(idx, :) = dble(out_biosphere%annual_cohorts(:)%sapwC) + output_annual_cohorts_woodC(idx, :) = dble(out_biosphere%annual_cohorts(:)%woodC) output_annual_cohorts_treeG(idx, :) = dble(out_biosphere%annual_cohorts(:)%treeG) output_annual_cohorts_fseed(idx, :) = dble(out_biosphere%annual_cohorts(:)%fseed) output_annual_cohorts_fleaf(idx, :) = dble(out_biosphere%annual_cohorts(:)%fleaf) @@ -811,7 +805,7 @@ subroutine biomee_f( & output_annual_cohorts_Nfix(idx, :) = dble(out_biosphere%annual_cohorts(:)%Nfix) output_annual_cohorts_deathrate(idx, :) = dble(out_biosphere%annual_cohorts(:)%deathrate) - !end if + end if end do yearloop diff --git a/src/vegetation_biomee.mod.f90 b/src/vegetation_biomee.mod.f90 index cda3dc90..9968b4ac 100755 --- a/src/vegetation_biomee.mod.f90 +++ b/src/vegetation_biomee.mod.f90 @@ -1892,10 +1892,10 @@ subroutine kill_old_grass(vegn) if (.not. OldGrass) k=k+1 end associate enddo - if (k==0)then - write(*,*)'in kill_old_grass: All cohorts are old grass, No action!' - !stop - endif + ! if (k==0)then + ! write(*,*)'in kill_old_grass: All cohorts are old grass, No action!' + ! !stop + ! endif ! exclude cohorts that are old grass if (k>0 .and. k