Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • foresee/4C
  • gutsch/4C
2 results
Show changes
Showing
with 11224 additions and 0 deletions
source_code/version_2.3_windows/pik400x.bmp

75.1 KiB

!*****************************************************************!
!* *!
!* 4C (FORESEE) *!
!* *!
!* *!
!* Subroutines for planting *!
!* *!
!* contains: *!
!* SR planting *!
!* function sapwood *!
!* SR gener_coh *!
!* *!
!* comment: planting is controlled by the flag flag_reg, *!
!* soe standardized planting ensembles are definded *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE planting
USE data_stand
USE data_simul
USE data_species
USE data_soil
USE data_help
USE data_plant
USE data_manag
use data_wpm
IMPLICIT NONE
integer :: nplant, &
taxid, &
i,j,nr, &
taxnum, &
outunit, ctrlunit
real :: age, &
pl_height, &
sdev, &
plhmin, &
rsap, &
hbc, &
bhd, &
cform, &
hlp_lai, &
rednpl_sh
real :: rtflsp, sapwood, height, plots
integer, dimension(nspec_tree) :: infhelp
character(80) :: infile
character :: text
CHARACTER :: source
integer :: inunit,ios
integer :: parunit
integer :: nkoh, nplanth, numb
REAL p0(nspec_tree),p1(nspec_tree),p2(nspec_tree),p3(nspec_tree),p4(nspec_tree), &
c1(nspec_tree),c2(nspec_tree),ku_a0(nspec_tree),ku_a1(nspec_tree),ku_a2(nspec_tree),&
ku_b0(nspec_tree),ku_b1(nspec_tree),ku_b2(nspec_tree),ku_c0(nspec_tree),&
ku_c1(nspec_tree),ku_c2(nspec_tree),wei_k1(nspec_tree),wei_k2(nspec_tree)
real :: crown_base, crown_base_eg
TYPE(cohort) ::tree_ini
real corr_la
real :: troot2
real, dimension(20) :: hhei
external sapwood
external rtflsp
do i =1,nspec_tree
infhelp(i) = infspec(i)
end do
parunit=GETUNIT()
OPEN (parunit, FILE='input/generreg.par', STATUS='old')
DO i=1,nspec_tree
READ (parunit,*) p0(i),p1(i),p2(i),p3(i),p4(i),c1(i),c2(i),ku_a0(i),ku_a1(i),ku_a2(i), &
ku_b0(i),ku_b1(i),ku_b2(i),ku_c0(i),ku_c1(i),ku_c2(i),wei_k1(i),wei_k2(i)
ENDDO
CLOSE(parunit)
!*********************** sea **************************************
plant_year = time
flag_plant = flag_reg
!******************************************************************
rednpl_sh = 1.
! modification uf number of planted trees in the case of shelterwood management
if(flag_shelter.eq.1) rednpl_sh = 0.7
taxid = 0
if( flag_reg .ge.10) quspec = 1
if(flag_reg.ge.10.and.flag_reg.lt. 30) then
! planting of mono-species stands
select case(flag_reg)
case(10)
! planting pine
taxnum = 3
case(11)
! planting beech
taxnum = 1
case(12)
! planting oak
taxnum =4
case(13)
! planting spruce
taxnum = 2
case(14)
! planting birch
taxnum = 5
case(15)
! planting aspen
taxnum = 8
case(16)
! planting aleppo pine
taxnum = 9
case(17)
! planting douglas fir
taxnum =10
case(18)
! planting black locust
taxnum =11
case(20)
! reading planting data from file and generating tree cohorts
inunit=getunit()
write(*,'(a)') ' *** Planting of small trees ***'
write(*,'(A)',advance='no')' Input directory and file for planting: '
read (*,'(A)') infile
open (inunit,FILE=trim(infile),STATUS='old')
! read head of data-file
outunit=getunit()
open(outunit, FILE=TRIM(treefile(ip)),STATUS='replace')
ctrlunit = getunit() +1
OPEN (ctrlunit,FILE=TRIM(site_name(ip))//'.initctrl',STATUS='replace')
plots=10000.
do
read(inunit,*) text
if(text .ne. '!')then
backspace(inunit);exit
endif
enddo
! modification AB 19.9.11
CALL header(outunit,infile,source,cform,rsap,flag_volfunc,kpatchsize)
do
READ(inunit,*,IOSTAT=ios)numb, nplant ,taxid,pl_height, age, bhd, hbc
if(ios<0) exit
height = pl_height
! Modification (Alexander Borys), generating of nkoh cohorts from given data, 19.9.11
nkoh =10
do i = 1, nkoh
hhei(i) = height*(0.8 + (i-1)*0.025)
end do
write(outunit,*) numb, plots
do i = 1, nkoh
pl_height = hhei(i)*100.
height = hhei(i)
if(taxid.eq.12.or. taxid.eq.13) then
! Eucalyptus
hbc = crown_base_eg(height, bhd)
else
hbc=crown_base(height,c1(taxid),c2(taxid),bhd)
end if
nplanth = int(nplant/nkoh)
rsap = 0.5
source = 'd'
cform=1;hlp_lai=0
corr_la = 1.
call treeini(outunit,ctrlunit,taxid,source,bhd,height,hbc,nplanth,cform,rsap,int(age),hlp_lai,corr_la)
max_coh = max_coh + 1
! initialise tree_ini with zero
call coh_initial (tree_ini)
tree_ini%ident = max_coh
tree_ini%species = taxid
tree_ini%ntreea = nplant
tree_ini%ntreed = 0.
tree_ini%nta = tree_ini%ntreea
tree_ini%x_age = age
tree_ini%x_hbole = hbc
tree_ini%resp = 0.
tree_ini%height = pl_height
tree_ini%x_sap = x_sap
tree_ini%x_fol = x_fol
tree_ini%x_frt = x_frt
tree_ini%x_hrt = x_hrt
tree_ini%x_ahb = x_ahb
tree_ini%x_crt = (tree_ini%x_sap + tree_ini%x_hrt) * spar(taxid)%alphac*spar(taxid)%cr_frac
tree_ini%x_tb = (tree_ini%x_sap + tree_ini%x_hrt) * spar(taxid)%alphac*(1.-spar(taxid)%cr_frac)
! Borys
tree_ini%diam = bhd
tree_ini%med_sla = spar(taxid)%psla_min + spar(taxid)%psla_a*0.5
tree_ini%t_leaf = tree_ini%med_sla* tree_ini%x_fol ! [m-2]
tree_ini%ca_ini = tree_ini%t_leaf
tree_ini%crown_area = tree_ini%ca_ini
! initialize pheno state variables
IF(spar(tree_ini%species)%Phmodel==1) THEN
tree_ini%P=0
tree_ini%I=1
ELSE
tree_ini%P=0
tree_ini%I=0
tree_ini%Tcrit=0
END IF
IF(nplant.ne.0.) then
IF (.not. associated(pt%first)) THEN
ALLOCATE (pt%first)
pt%first%coh = tree_ini
NULLIFY(pt%first%next)
! root distribution
call root_depth (1, pt%first%coh%species, pt%first%coh%x_age, pt%first%coh%height, pt%first%coh%x_frt, pt%first%coh%x_crt, nr, troot2, pt%first%coh%x_rdpt, pt%first%coh%nroot)
pt%first%coh%nroot = nr
do j=1,nr
pt%first%coh%rooteff = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
pt%first%coh%rooteff = 0. ! layers with no roots
enddo
ELSE
ALLOCATE(zeig)
zeig%coh = tree_ini
zeig%next => pt%first
pt%first => zeig
! root distribution
call root_depth (1, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig%coh%nroot = nr
do j=1,nr
zeig%coh%rooteff = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
zeig%coh%rooteff = 0. ! layers with no roots
enddo
END IF ! associated
anz_coh=anz_coh+1
END IF ! nplant
end do ! nkoh
end do
close(inunit)
close (outunit)
close (ctrlunit)
return
end select
! liocourt management with regeneration if flag_mg = 44
if(flag_mg.eq.44) then
do i= 1, M_numclass
taxid = m_specpl(spec_lic,i)
age = m_pl_age(spec_lic,i)
pl_height = m_plant_height(spec_lic,i)
plhmin = m_plant_hmin(spec_lic,i)
nplant = m_numplant(spec_lic,i) * kpatchsize/10000
sdev = m_hsdev(spec_lic,i)
call gener_coh(taxid, age, pl_height, plhmin, nplant,sdev)
end do
else
taxid = taxnum
age = pl_age(taxnum)
pl_height = plant_height(taxnum)
plhmin = plant_hmin(taxnum)
! number of seedling from data_plant
nplant = rednpl_sh*nint(numplant(taxnum)*kpatchsize/10000)
! number of seedlings from seedrate
if(flag_reg.eq.15.or.flag_reg.eq.16.or.flag_reg.eq.18) nplant = spar(taxnum)%seedrate*kpatchsize
sdev = hsdev(taxnum)
call gener_coh(taxid, age, pl_height, plhmin, nplant,sdev)
end if
else
! planting of mixed stands
! mixture given by ara<meters in data_plant
if(flag_reg.eq.9) then
do i = 1,nspec_tree
if (infspec(i).eq.1 .and. infhelp(i).eq.1) then
taxid = i
age = pl_age(taxid)
pl_height = plant_height(taxid)
plhmin = plant_hmin(taxid)
nplant = rednpl_sh*nint(npl_mix(taxid)*kpatchsize/10000)
sdev = hsdev(taxid)
call gener_coh(taxid, age, pl_height, plhmin, nplant,sdev)
infhelp(i) = 0
end if
end do ! i
else if(flag_reg.lt.9.or.flag_reg.gt.30) then
infspec = 0
npl_mix = 0
select case (flag_reg)
! planting of well definded mixtures of pine and oak
case(8)
infspec(3)=1
infspec(4)=1
npl_mix(3) = 9000.
npl_mix(4) = 1000.
case(7)
infspec(3)=1
infspec(4)=1
npl_mix(3) = 7000.
npl_mix(4) = 3000.
case(6)
infspec(3)=1
infspec(4)=1
npl_mix(3) = 5000.
npl_mix(4) = 5000.
case(5)
infspec(3)=1
infspec(4)=1
npl_mix(3) = 3000.
npl_mix(4) = 7000.
case(4)
infspec(3)=1
infspec(4)=1
npl_mix(3) = 2000.
npl_mix(4) = 8000.
case(33)
infspec(2) = 1
infspec(3) = 1
npl_mix(2) = 5000.
npl_mix(3) = 5000.
end select
do i =1,nspec_tree
infhelp(i) = infspec(i)
end do
do i = 1,nspec_tree
if (infspec(i).eq.1 .and. infhelp(i).eq.1) then
taxid = i
age = pl_age(taxid)
pl_height = plant_height(taxid)
plhmin = plant_hmin(taxid)
nplant = rednpl_sh*nint(npl_mix(taxid)*kpatchsize/10000)
sdev = hsdev(taxid)
call gener_coh(taxid, age, pl_height, plhmin, nplant,sdev)
infhelp(i) = 0
end if
end do ! i
end if
end if
END SUBROUTINE planting
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! gener_coh
! SR for planting seedling cohorts
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SUBROUTINE gener_coh(taxid,age,pl_height,plhmin, nplant,sdev)
USE data_simul
USE data_stand
USE data_par
USE data_species
USE data_soil
USE data_help
USE data_plant
USE data_manag
IMPLICIT NONE
integer :: nplant, &
taxid, &
nclass, &
i,j,nr
real :: age, &
pl_height, &
sdev, &
plhmin, &
plhmax, &
plhinc, &
help, &
nstot, &
hhelp,x1,x2,xacc,shelp
real :: rtflsp, sapwood
real :: troot2
real, dimension(:), save, allocatable :: hei, &
nschelp
integer,dimension(:),allocatable :: nsc
TYPE(cohort) ::tree_ini
external sapwood
external rtflsp
flag_standup = 2 ! call stand_balance and root_distribution later
! number of classes
nclass = nint(plhmin + (pl_height-plhmin))
! Liocourt management
if(flag_reg.eq.17) nclass = 20
if(flag_reg.eq.11 .and. flag_mg.eq.44) nclass = 1
if(flag_reg.eq.18) nclass =20
if (flag_reg.eq.15) nclass = 20
allocate(hei(nclass))
allocate(nschelp(nclass))
allocate(nsc(nclass))
plhmax = pl_height + (pl_height-plhmin)
plhinc = (plhmax-plhmin)/nclass
nstot = 0
help = (1/(sqrt(2*pi)*sdev))
do i = 1, nclass
if ( nclass.eq.1) then
hei(i) = pl_height
else
! height per class
hei(i) = plhmin + (i-1)
nschelp(i) = help*exp(-((hei(i)-pl_height)**2)/(2*(sdev)**2))
nstot = nstot + nschelp (i)
end if
end do
do i = 1,nclass
if(nclass.eq.1) then
nsc(i) = nplant *kpatchsize/10000
else
nsc(i) = nint((nschelp(i)*nplant/nstot) + 0.5)
end if
end do
do i = 1,nclass
max_coh = max_coh + 1
! initialise tree_ini with zero
call coh_initial (tree_ini)
tree_ini%ident = max_coh
tree_ini%species = taxid
tree_ini%ntreea = nsc(i)
tree_ini%nta = tree_ini%ntreea
tree_ini%x_age = age
tree_ini%height = hei(i)
hhelp = tree_ini%height
IF (taxid.ne.2) tree_ini%x_sap = exp(( LOG(hhelp)-LOG(spar(taxid)%pheight1))/spar(taxid)%pheight2)/1000000.
IF (taxid.eq.2) THEN
x1 = 1.
x2 = 2.
xacc=(1.0e-10)*(x1+x2)/2
heihelp = tree_ini%height
hnspec = taxid
shelp=rtflsp(sapwood,x1,x2,xacc)
tree_ini%x_sap = (10**shelp)/1000000 ! transformation mg ---> kg
ENDIF
! Leaf mass
tree_ini%x_fol = (spar(taxid)%seeda*(tree_ini%x_sap** spar(taxid)%seedb)) ![kg]
tree_ini%Fmax = tree_ini%x_fol
! Fine root mass rough estimate
tree_ini%x_frt = tree_ini%x_fol
! cross sectional area of heartwood
tree_ini%x_crt = (tree_ini%x_sap + tree_ini%x_hrt) * spar(taxid)%alphac*spar(taxid)%cr_frac
tree_ini%x_tb = (tree_ini%x_sap + tree_ini%x_hrt) * spar(taxid)%alphac*(1.-spar(taxid)%cr_frac)
tree_ini%med_sla = spar(taxid)%psla_min + spar(taxid)%psla_a*0.5
tree_ini%t_leaf = tree_ini%med_sla* tree_ini%x_fol ! [m-2]
tree_ini%ca_ini = tree_ini%t_leaf
tree_ini%crown_area = tree_ini%ca_ini
! 1 fr Vincent kint, 2 oakchain
tree_ini%underst = 2
! initialize pheno state variables
IF(spar(tree_ini%species)%Phmodel==1) THEN
tree_ini%P=0
tree_ini%I=1
ELSE
tree_ini%P=0
tree_ini%I=0
tree_ini%Tcrit=0
END IF
IF(nsc(i).ne.0.) then
IF (.not. associated(pt%first)) THEN
ALLOCATE (pt%first)
pt%first%coh = tree_ini
NULLIFY(pt%first%next)
call root_depth (1, pt%first%coh%species, pt%first%coh%x_age, pt%first%coh%height, pt%first%coh%x_frt, pt%first%coh%x_crt, nr, troot2, pt%first%coh%x_rdpt, pt%first%coh%nroot)
pt%first%coh%nroot = nr
do j=1,nr
pt%first%coh%rooteff(j) = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
pt%first%coh%rooteff(j) = 0. ! layers with no roots
enddo
ELSE
ALLOCATE(zeig)
zeig%coh = tree_ini
zeig%next => pt%first
pt%first => zeig
call root_depth (1, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig%coh%nroot = nr
do j=1,nr
zeig%coh%rooteff(j) = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
zeig%coh%rooteff(j) = 0. ! layers with no roots
enddo
END IF
anz_coh=anz_coh+1
END IF
end do
deallocate(hei)
deallocate(nschelp)
deallocate(nsc)
END SUBROUTINE gener_coh
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! weight
! seed mass function
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
function sapwood (x)
use data_help
use data_species
real :: x
real :: p1,p2,p3
p1 = spar(hnspec)%pheight1
p2 = spar(hnspec)%pheight2
p3 = spar(hnspec)%pheight3
sapwood = p3*(x**2) + p2*x +p1-alog10(heihelp)
end function sapwood
!*****************************************************************!
!* *!
!* 4C (FORESEE) *!
!* *!
!* *!
!* returns a random number N drawn from a Poisson distribution *!
!* with expected value U. I is a seed for *!
!* the random number generator *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE PRAND(U,N)
REAL UTOP
PARAMETER(UTOP=188.)
INTEGER N
REAL P,R,Q,U
! function declarations
REAL RAND
IF(U.GT.UTOP)STOP 'Failure in PRAND: expected value too high'
P=EXP(-U)
Q=P
R=RAND()
N=0
100 IF(Q.GE.R)RETURN
N=N+1
P=P*U/N
Q=Q+P
GOTO 100
END subroutine prand
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* *!
!* Contains the following subroutines: *!
!* *!
!* PREPARE_GLOBAL: general preparation of simulation *!
!* contains internal subroutines: *!
!* TOPMENU: main menu *!
!* EDITSIM: edit simulation file names *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE prepare_global
use data_simul
use data_out
use data_species
use data_stand
use data_site
use data_tsort
use data_climate
implicit none
character anf
logical ex
! main menu
DO
call topmenu
if (anf == '2') then
call editsim
call testfile(simfile,ex)
if(ex .eqv. .false.) cycle
call readsim
if (flag_mult910) print *,' Check the data from file:'
ELSE if (anf == '1' .or. anf == ' ') then
call testfile(simfile,ex)
if(ex .eqv. .false.) cycle
call readsim
if (flag_mult910) print *,' Check the data from file:'
end if
if (ex .eqv. .true.) exit
end DO
call outtest
contains
!---------------------------------------------------------------
SUBROUTINE topmenu
print *,' ****************************************************'
print *,' **************** Welcome to 4C *******************'
print *,' ****************************************************'
print *,' '
print *,' 1 <Enter>.. Start with default simulation control: ',trim(simfile)
print *,' '
print *,' 2...........Edit simulation control file name'
print *,' '
print *,' ****************************************************'
write(*,'(A)',advance='no') ' Make your choice: '
read(*,'(A)') anf
END subroutine topmenu
!-----------------------------------------------------------------------------
SUBROUTINE editsim
open(1000,file='user')
write(1000,'(A,A,A)',advance='no') ' Simulation control file (default= ',trim(simfile),'): '
read (*,'(A)') simfile
if (simfile == ' ') then
simfile = 'test0.sim'
end if
end subroutine editsim
!-----------------------------------------------------------------------------
END subroutine prepare_global
!**************************************************************
!*****************************************************************!
!* *!
!* 4C (FORESEE) *!
!* *!
!* *!
!* Subroutines: *!
!* PREPARE_SITE and PREPARE_CLIMATE *!
!* *!
!* Contains subroutines: *!
!* *!
!* PREPARE_SITE: *!
!* preparation of site specific simulation parameters *!
!* *!
!* contains internal subroutines: *!
!* SITEMENU: choice of inputs *!
!* EDITFILE: edit filenames *!
!* READSOIL: input of soil parameter *!
!* READCN: input of C-N-parameter *!
!* READVALUE: input of start values for *!
!* soil water and C-N-modeling *!
!* ALLOC_SOIL: allocate soil variables *!
!* STAND_BAL_INI: allocate and init stand variables *!
!* CONTROL_FILE: saving all parameters *!
!* and start conditions for each site *!
!* *!
!* READDEPO: reading deposition data *!
!* READREDN: reading values of redN *!
!* READLIT: reading initialisation data of litter fractions *!
!* *!
!* PREPARE_CLIMATE: reading of site specific climate input data *!
!* from file *!
!* contains internal subroutines: *!
!* READ_DWD *!
!* READ_CLI *!
!* CLIMFILL *!
!* *!
!* STORE_PARA: multi run - restore of changed parameter *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
subroutine prepare_site
! input of site specific data
use data_climate
use data_inter
use data_manag
use data_mess
use data_out
use data_par
use data_simul
use data_site
use data_soil
use data_soil_cn
use data_species
use data_stand
use data_tsort
use data_frost
implicit none
integer i,ios,help, help_ip
character a
character :: text
character(10) :: helpsim, text2
logical:: ex=.TRUE.
real parerr
real, external :: avg_sun_incl
character(100) :: helpx
if (flag_trace) write (unit_trace, '(I4,I10,A)') iday, time_cur, ' prepare_site'
WRITE(helpsim,'(I4)') anz_sim
read(helpsim,*) anh
IF(site_nr==1) THEN
help_ip=site_nr
ELSE
help_ip=ip
END IF
! Initialization of climate data
IF (flag_clim==1 .or. ip==1 .or. flag_multi .eq.5) THEN
call prepare_climate
END IF
if (flag_end .gt. 0) return
ios=0; help=0
do
if (ip==1 .and. flag_mult9) then
if (flag_trace) write (unit_trace, '(I4,I10,A,I3,A5,L5)') iday, time_cur, ' prepare_site ip=',ip,' ex=',ex
call readspec
call readsoil ! reading soil parameter
IF (flag_end .gt.0) return
if (flag_soilin .eq. 0) call readvalue ! Initialization of simulation start values for soil layers
! biochar
if (flag_bc .gt. 0) call bc_appl
! Deposition data
call readdepo
! Input redN
if (flag_multi .ne. 4 .or. flag_multi .ne. 8 ) call readredN
flag_mult9 = .FALSE.
else
if (flag_trace) write (unit_trace, '(I4,I10,A,I3,A5,L5)') iday, time_cur, ' prepare_site ip=',ip,' ex=',ex
! Deposition data
call readdepo
select case (flag_multi)
case (1,6)
call readspec
if (flag_soilin .eq. 0) call readvalue ! Initialization of simulation start values for soil layers
call readredN ! Input redN
call readsoil ! reading soil parameter
do
jpar = jpar + 1
if (vpar(jpar) .gt. -90.0) then
helpx = simpar(jpar)
call store_para(vpar(jpar), helpx, parerr)
IF (parerr .ne. 1.) then
CALL error_mess(time,'parameter variation: '//trim(simpar(jpar))//' not found',vpar(jpar))
write (*,*) '*** parameter variation: ', trim(simpar(jpar)), ' not found, see error log'
endif
else
exit
endif
enddo
! biochar
if (flag_bc .gt. 0 .or. flag_decomp .gt. 100) call bc_appl
case (2,4)
call readsoil ! reading soil parameter
if (flag_soilin .eq. 0) call readvalue ! Initialization of simulation start values for soil layers
case (5)
call readspec
call readsoil
if (flag_soilin .eq. 0) call readvalue ! Initialization of simulation start values for soil layers
call readredN ! Input redN
case (7)
call assign_co2par
call readsoil ! reading soil parameter
if (flag_soilin .eq. 0) call readvalue ! Initialization of simulation start values for soil layers
call readredN ! Input redN
case (8, 9, 10)
call readsoil ! reading soil parameter
IF (flag_end .gt.0) return
call readredN ! Input redN or test resp.
end select
endif
exit
enddo
! Setting flag_inth and prec_stad_red from flag_int
if (flag_int .lt. 1000) then
flag_inth = flag_int
else
! Conversion character ==> number and vice versa
write (helpsim,'(I4)') flag_int
text2 = helpsim(2:2)
read (text2,*) flag_inth
text2 = helpsim(3:4)
read (text2,*) prec_stand_red
endif
if (.not.flag_mult8910) then
unit_soil = getunit()
open (unit_soil,file=trim(dirout)//trim(site_name(help_ip))//'_soil.ini'//anh,status='replace')
WRITE (unit_soil,'(2A)') '! Soil initialisation, site name: ',site_name(help_ip)
endif
call stand_bal_ini !allocation of stand summation variables
! Initialization of CO2
call assign_co2par
! Initialisation litter compartments
call readlit
! Initialization of soil model with profile data
call soil_ini ! Aufruf ohne s_cn_ini
! Initialization disturbances
IF (flag_dis .eq. 1 .or. flag_dis .eq. 2) CALL dist_ini
! Initialization of stand
call prepare_stand
IF (flag_end .gt.0) return
! calculation of latitude in radians
xlat = lat/90.*pi*0.5
! calculation of average sun inclination
avg_incl = AVG_SUN_INCL(lat) ! degrees
beta=avg_incl*PI/180 ! radians
! read externally prescribed bud burst days
CALL readbudb
! Initialization management
IF(flag_mg.ne.0.and. flag_mg.ne.5) call manag_ini
IF(flag_mg.eq. 5) then
thin_dead = 1
allocate(thin_flag1(nspec_tree))
thin_flag1 = 0
end if
! Initialization of output file per site
call prep_out
call stand_balance
call CROWN_PROJ
call standup
call root_ini ! initialisation of root distribution
call s_cn_ini
! Initialization of soil temperature model with stand data
call s_t_ini
! control file for saving simulation environment
! output of first Litter-Input at start
if(flag_mult8910 .and. (anz_sim .gt. 1)) then
continue
else
IF ((ip .eq. 1 .or. flag_multi .eq. 1 .or. flag_multi .eq. 6) .and. (time_out .ne. -2) ) call control_file
endif
! hand over of the litter-initialising
call litter
if ((flag_decomp .eq. 20) .or. (flag_decomp .eq. 21)) then
call testfile(valfile(ip),ex)
if (ex .eqv. .true.) then
ios = 0
unit_litter = getunit()
open(unit_litter,file=valfile(ip),status='old',action='read')
if (flag_multi .ne. 9) print *,' *** Open file of litter input data ',valfile(ip),'...'
do
read(unit_litter,*) text
IF(text .ne. '!')then
backspace(unit_litter);exit
endif
enddo
endif
endif
call cn_inp
! read flux data
if (flag_eva .gt.10) call evapo_ini
! yearly output
IF (time_out .gt. 0) THEN
IF (mod(time,time_out) .eq. 0) CALL outyear (1)
IF (mod(time,time_out) .eq. 0) CALL outyear (2)
ENDIF
contains
!-------------------------------------------------------------------------------
subroutine readsoil ! Input of soil parameter
use data_par
use data_soil_t
use data_site
implicit none
integer :: inunit, helpnl, helpnr, ihelp
real helpgrw, hlong, hlat
character :: text
character(30) :: hor, boart, helpid
if (flag_trace) write (unit_trace, '(I4,I10,A)') iday, time_cur, ' readsoil'
! Setting of flag_surf from flag_cond
select case (flag_cond)
case (0,1,2,3)
flag_surf = 0
case (10,11,12,13)
flag_surf = 1
case (30,31,32,33)
flag_surf = 3
end select
! Setting of flag_bc from flag_decomp
if (flag_decomp .ge. 100) then
flag_decomp = flag_decomp - 100
flag_bc = 1
else
flag_bc = 0
endif
call testfile(sitefile(ip),ex)
IF (ex .eqv. .true.) then
inunit = getunit()
ios=0
open(inunit,file=sitefile(ip),iostat=ios,status='old',action='read')
if (.not.flag_mult8910) then
print *,'***** Reading soil parameter from file ',sitefile(ip),'...'
write (unit_err, *) 'Soil parameter from file ',trim(sitefile(ip))
endif
do
read(inunit,*) text
IF(text .ne. '!')then
backspace(inunit)
exit
endif
enddo
if (flag_multi .eq. 8.or. flag_multi.eq.5.or. flag_mult910) then
read(inunit,*) text
IF((text .eq. 'N') .or. (text .eq. 'n'))then
flag_soilin = 3
else
flag_soilin = 2
backspace(inunit)
endif
else
read(inunit,*) text
IF((text .eq. 'N') .or. (text .eq. 'n'))then
flag_soilin = 1
else
flag_soilin = 0
backspace(inunit)
endif
soilid(ip) = valfile(ip)
endif
if ((text .eq. 'S') .or. (text .eq. 's'))then
flag_soilin = 4
read(inunit,*) text
endif
if (.not.flag_mult8910) then
write (unit_err, *) 'Soil identity number ', trim(soilid(ip))
write (unit_err, *) 'Climate ID ', trim(clim_id(ip))
endif
if (flag_soilin .eq. 1 .or. flag_soilin .ge. 3) then
flag_hum = 1
endif
if (flag_cond .ge. 40) then
flag_hum = 0
endif
select case (flag_soilin)
case (0,1) ! single files f. j. site
read (inunit,*,iostat=ios) long
read (inunit,*,iostat=ios) lat
read (inunit,*,iostat=ios) nlay
read (inunit,*,iostat=ios) nroot_max
read (inunit,*,iostat=ios) helpgrw
if (helpgrw .gt. 1) then
grwlev = helpgrw
else
fakt = helpgrw
grwlev = 1000.
endif
read (inunit,*,iostat=ios) w_ev_d
read(inunit,*,iostat=ios) k_hum ! mineralization constants of humus
read(inunit,*,iostat=ios) k_hum_r
read(inunit,*,iostat=ios) k_nit ! nitrification constant
IF(help==0) call alloc_soil
read (inunit,*,iostat=ios) text
select case (flag_soilin)
case (0) ! old input structure
do i = 1, nlay
read (inunit,*,iostat=ios) text
read (inunit,*,iostat=ios) thick(i),pv_v(i),dens(i),f_cap_v(i), &
wilt_p_v(i),spheat(i),phv(i),wlam(i)
end do
skelv = 0.
case(1) ! new input structure
do i = 1, nlay
read (inunit,*,iostat=ios) helpnr, thick(i),pv_v(i),f_cap_v(i),wilt_p_v(i), &
dens(i),spheat(i),phv(i),wlam(i),skelv(i), sandv(i),clayv(i),humusv(i),&
C_hum(i), N_hum(i),NH4(i),NO3(i)
if (flag_wurz .eq. 4 .or. flag_wurz .eq. 6) then
if (phv(i) .le. 0.01) phv(i)=6.0 ! if flag_wurz 4 or 6 is used for calculation a pH-value is assumed
endif
end do
end select ! flag_soilin (0,1)
if (.not.flag_mult8910) print *, ' '
IF (ios .ne.0) then
print *,' >>>FORESEE message: Error during reading soil data!'
WRITE(*,'(A)',advance='no') ' Stop program (y/n)? '
read *, a
IF ( a .eq. 'y' .or. a .eq. 'Y') then
print *, ' STOP program!'
stop
endif
IF (help==1) call dealloc_soil
print *,' Check your input choice!!!'
endif ! ios
case (2) ! all sites are read from one file; old structure
ios = 0
do while (ios .eq. 0)
read (inunit,*,iostat=ios) helpid, helpnl, helpnr
if (trim(soilid(ip)) .ne. trim(helpid)) then
do i = 1, helpnl
read (inunit,*,iostat=ios) helpid
enddo
else
nlay = helpnl
nroot_max = helpnr
if (help==0) call alloc_soil
do i = 1, nlay
read (inunit,*,iostat=ios) helpnl, hor, boart, depth(i), thick(i),pv_v(i),dens(i), &
f_cap_v(i), wilt_p_v(i), spheat(i),phv(i),wlam(i), &
C_hum(i), N_hum(i), NH4(i), NO3(i), temps(i)
enddo
lat = latitude(ip)
grwlev = gwtable(ip)
exit
endif
enddo
IF (ios .lt. 0) then
if (.not.flag_mult8910) print *,' >>>FORESEE message: soil_id ', soilid(ip), ' not found'
if (.not.flag_mult8910) print *,' Check your input choice!!!'
if (help==1) call dealloc_soil
CALL error_mess(time,"soil identificator not found "//adjustl(soilid(ip))//" ip No. ",real(help_ip))
flag_end = 5
return
ENDIF ! ios
skelv = 0.
case (3) ! all sites are read from one file; new structure
ios = 0
do while (ios .eq. 0)
read (inunit,*,iostat=ios) helpid, helpnl, helpnr
if (trim(soilid(ip)) .ne. trim(helpid)) then
do i = 1, helpnl
read (inunit,*,iostat=ios) helpid
enddo
else
nlay = helpnl
nroot_max = helpnr
if (help==0) call alloc_soil
do i = 1, nlay
read (inunit,*,iostat=ios) helpnr, hor, boart, depth(i), thick(i),pv_v(i),f_cap_v(i), &
wilt_p_v(i),dens(i),spheat(i),phv(i),wlam(i),skelv(i), sandv(i), &
clayv(i),humusv(i),C_hum(i), N_hum(i),NH4(i),NO3(i)
if (flag_wurz .eq. 4 .or. flag_wurz .eq. 6) then
if (phv(i) .le. 0.01) phv(i)=6.0 ! if flag_wurz 4 or 6 is used for calculation a pH-value is assumed
endif
end do
lat = latitude(ip)
grwlev = gwtable(ip)
exit
endif
enddo
IF (ios .lt. 0) then
if (.not.flag_mult8910) print *,' >>>FORESEE message: soil_id ', soilid(ip), ' not found'
if (.not.flag_mult8910) print *,' Check your input choice!!!'
if (help==1) call dealloc_soil
CALL error_mess(time,"soil identificator not found "//adjustl(soilid(ip))//"ip No.",real(help_ip))
flag_end = 5
return
ENDIF ! ios
case (4) ! one file several sites
if (.not.flag_mult8910) print *,' Reading soil model parameter from soil type file... ', soilid(ip)
ios = 0
do while (ios .eq. 0)
read (inunit,*,iostat=ios) helpid
if (trim(soilid(ip)) .ne. trim(helpid)) then
read (inunit,*,iostat=ios) text
read (inunit,*,iostat=ios) text
read (inunit,*,iostat=ios) helpnl
do i = 1, helpnl+6
read (inunit,*,iostat=ios) boart
enddo
read (inunit,*,iostat=ios) boart
else
read (inunit,*,iostat=ios) hlong
read (inunit,*,iostat=ios) hlat
read (inunit,*,iostat=ios) nlay
read (inunit,*,iostat=ios) nroot_max
read (inunit,*,iostat=ios) helpgrw
if (flag_multi .eq. 8.or. flag_multi.eq.5.or. flag_mult910) then
if (abs(latitude(ip)) .gt. 90.) lat = latitude(ip)
grwlev = gwtable(ip)
else
if (helpgrw .gt. 1) then
grwlev = helpgrw
else
fakt = helpgrw
grwlev = 1000.
endif
long = hlong
lat = hlat
endif
read (inunit,*,iostat=ios) w_ev_d
read(inunit,*,iostat=ios) k_hum ! mineralization constants of humus
read(inunit,*,iostat=ios) k_hum_r
read(inunit,*,iostat=ios) k_nit ! nitrification constant
IF(help==0) call alloc_soil
read (inunit,*,iostat=ios) text
do i = 1, nlay
read (inunit,*,iostat=ios) helpnr, thick(i),pv_v(i),f_cap_v(i),wilt_p_v(i), &
dens(i),spheat(i),phv(i),wlam(i),skelv(i), sandv(i),clayv(i),humusv(i),&
C_hum(i), N_hum(i),NH4(i),NO3(i)
if (flag_wurz .eq. 4 .or. flag_wurz .eq. 6) then
if (phv(i) .le. 0.01) phv(i)=6.0 ! if flag_wurz 4 or 6 is used for calculation a pH-value is assumed
endif
end do
IF (ios .ne.0) then
print *,' >>>FORESEE message: Error during reading soil data!'
print *, ' Program stopped!'
IF (help==1) call dealloc_soil
flag_end = 7
return
endif ! ios
exit
endif
enddo
if (.not.flag_mult8910) print *, ' '
IF (ios .lt. 0) then
if (.not.flag_mult8910) then
print *,' >>>FORESEE message: soil_id ', soilid(ip), ' not found'
print *,' Check your input choice!!!'
endif
if (help==1) call dealloc_soil
CALL error_mess(time,"soil identificator not found "//adjustl(soilid(ip))//"ip No.",real(help_ip))
flag_end = 5
return
ENDIF ! ios
end select ! flag_soilin
close(inunit)
endif ! ex
if (nroot_max .lt. 0) then
do i=1, nlay
if (C_hum(i) .gt. zero) nroot_max = i
enddo
endif
if (.not.flag_mult8910) then
write (unit_err, *) 'Latitude ',lat
write (unit_err,*)
endif
end subroutine readsoil
!-------------------------------------------------------------------------
subroutine readvalue ! Input of cn-parameters and start values for soil model
integer :: inunit
character :: text
if (flag_trace) write (unit_trace, '(I4,I10,A)') iday, time_cur, ' readvalue'
call testfile(valfile(ip),ex)
IF (ex .eqv. .true.) then
ios = 0
inunit = getunit()
open(inunit,file=valfile(ip),status='old',action='read')
if (.not.flag_mult8910) print *,' *** Reading initial soil values from file ',valfile(ip),'...'
do
read(inunit,*) text
IF(text .ne. '!')then
backspace(inunit);exit
endif
enddo
! Soil temperature
read(inunit,*,iostat=ios) text
read(inunit,*,iostat=ios) (temps(i),i=1,nlay)
! C-content of humus
read(inunit,*,iostat=ios) text
read(inunit,*,iostat=ios) (C_hum(i),i=1,nlay)
! N-content of humus
read(inunit,*,iostat=ios) text
read(inunit,*,iostat=ios) (N_hum(i),i=1,nlay)
! NH4-content
read(inunit,*,iostat=ios) text
read(inunit,*,iostat=ios) (NH4(i),i=1,nlay)
! NO3-content
read(inunit,*,iostat=ios) text
read(inunit,*,iostat=ios) (NO3(i),i=1,nlay)
endif
IF (ios .ne. 0) then
print *,' >>>FORESEE message: Error during reading start values!'
WRITE(*,'(A)',advance='no') ' Stop program (y/n)? '
read *, a
IF ( a .eq. 'y' .or. a .eq. 'Y') then
print *, ' STOP program!'
stop
ELSE
call dealloc_soil
print *,' Check your input choice!!!'
end if
endif
close(inunit)
end subroutine readvalue
!--------------------------------------------------------------------------
subroutine alloc_soil
use data_soil_t
use data_soil
if (flag_trace) write (unit_trace, '(I4,I10,A)') iday, time_cur, ' alloc_soil'
help=0
allocate(thick(nlay))
allocate(mid(nlay))
allocate(depth(nlay))
allocate(pv(nlay))
allocate(pv_v(nlay))
allocate(dens(nlay))
allocate(f_cap_v(nlay))
allocate(field_cap(nlay))
allocate(wilt_p(nlay))
allocate(wilt_p_v(nlay))
allocate(vol(nlay))
allocate(quarzv(nlay))
allocate(sandv(nlay))
allocate(BDopt(nlay))
allocate(clayv(nlay))
allocate(siltv(nlay))
allocate(humusv(nlay))
allocate(fcaph(nlay))
allocate(wiltph(nlay))
allocate(pvh(nlay))
allocate(dmass(nlay))
allocate(skelv(nlay))
allocate(skelfact(nlay))
allocate(spheat(nlay))
allocate(phv(nlay))
allocate(wlam(nlay))
allocate(wats(nlay))
allocate(watvol(nlay))
allocate(wat_res(nlay))
wat_res = 0.
allocate(perc(nlay))
allocate(wupt_r(nlay))
allocate(wupt_ev(nlay))
allocate(s_drought(nlay))
allocate(root_fr(nlay))
!allocate(dp_rfr(nlay))
allocate(temps(nlay))
allocate (C_opm(nlay))
allocate (C_hum(nlay))
allocate (C_opmfrt(nlay))
allocate (C_opmcrt(nlay))
allocate (N_opm(nlay))
allocate (N_hum(nlay))
allocate (N_opmfrt(nlay))
allocate (N_opmcrt(nlay))
allocate (NH4(nlay))
allocate (NO3(nlay))
allocate (Nupt(nlay))
allocate (Nmin(nlay))
allocate (rmin_phv(nlay))
allocate (rnit_phv(nlay))
allocate (cnv_opm(nlay))
allocate (cnv_hum(nlay))
allocate(slit(nspecies))
allocate(slit_1(nspecies))
if (flag_bc .gt. 0) then
allocate (C_bc(nlay))
allocate (N_bc(nlay))
C_bc = 0.
N_bc = 0.
endif
do i=1,nspecies
slit(i)%C_opm_frt = 0.
slit(i)%N_opm_frt = 0.
slit(i)%C_opm_crt = 0.
slit(i)%N_opm_crt = 0.
slit(i)%C_opm_tb = 0.
slit(i)%N_opm_tb = 0.
slit(i)%C_opm_stem = 0.
slit(i)%N_opm_stem = 0.
enddo
nlay2 = nlay+2
mfirst = 1
allocate (sh(mfirst:nlay2))
allocate (sv(mfirst:nlay2))
allocate (sb(mfirst:nlay2))
allocate (sbt(mfirst:nlay2))
allocate (t_cb(mfirst:nlay2))
allocate (t_cond(mfirst:nlay2))
allocate (h_cap(mfirst:nlay2))
allocate (sxx(mfirst:nlay2))
allocate (svv(mfirst:nlay2))
allocate (svva(mfirst:nlay2))
allocate (soh(mfirst:nlay2))
allocate (son(mfirst:nlay2+1))
help=1
C_opm = 0
allocate(fr_loss(nlay))
allocate(redis(nlay))
end subroutine alloc_soil
!------------------------------------------------------------------
subroutine stand_bal_ini
use data_stand
implicit none
integer i
allocate(diam_class(num_class, nspecies)); diam_class=0
allocate(diam_class_t(num_class, nspecies)); diam_class_t=0
allocate(diam_class_h(num_class,nspecies)); diam_class_h=0
allocate(diam_class_age(num_class,nspecies)); diam_class_age=0
allocate(diam_class_mvol(num_class,nspecies)); diam_class_mvol=0
allocate(diam_classm(num_class,nspecies)); diam_classm=0
allocate(diam_classm_h(num_class,nspecies)); diam_classm_h=0
allocate(height_class(num_class)); height_class =0
! array of potential litter (dead stems and twigs/branches for the next years
allocate(dead_wood(nspec_tree))
do i = 1,nspec_tree
allocate(dead_wood(i)%C_tb(lit_year))
allocate(dead_wood(i)%N_tb(lit_year))
allocate(dead_wood(i)%C_stem(lit_year))
allocate(dead_wood(i)%N_stem(lit_year))
dead_wood(i)%C_tb = 0.
dead_wood(i)%N_tb = 0.
dead_wood(i)%C_stem = 0.
dead_wood(i)%N_stem = 0.
enddo
end subroutine stand_bal_ini
!--------------------------------------------------------------
subroutine control_file ! saving simulation parameter and start conditions for each site
real buckdepth
character(8) actdate
character(10) acttime
character(150) site_help
integer help_ip, j
TYPE(Coh_Obj), Pointer :: help_coh ! pointer to cohort list
IF(site_nr==1) THEN
help_ip=site_nr
ELSE
help_ip=ip
END IF
! Write soil initialisation file
if (flag_mult8910) then
site_help = site_name1
else
site_help = site_name(help_ip)
endif
if (.not.flag_mult8910 .or. (flag_mult8910 .and. anh .eq. "1") .or. (flag_mult8910 .and. time_out .gt. 0.)) then
if (.not.flag_mult8910) then
WRITE (unit_soil,'(26A)') 'Layer',' Depth(cm)',' F-cap(mm)',' F-cap(Vol%)',' Wiltp(mm)', &
' Wiltp(Vol%)',' Pore vol.',' Skel.(Vol%)',' Density',' Spheat',' pH',' Wlam', &
' Water(mm)',' Water(Vol%)',' Soil-temp.',' C_opm g/m2', &
' C_hum g/m2',' N_opm g/m2',' N_hum g/m2',' NH4 g/m2',' NO3 g/m2',' humus part',' d_mass g/m2', ' Clay',' Silt',' Sand'
do i = 1,nlay
WRITE (unit_soil,'(I5,2F10.2,3F12.2,F10.2,F12.2,4F8.2,F10.2,F12.2, 5F11.2,2F9.4,2E12.4, 3F6.1)') i,depth(i),field_cap(i),f_cap_v(i),wilt_p(i), &
wilt_p_v(i),pv_v(i), skelv(i)*100., dens(i),spheat(i),phv(i),wlam(i), &
wats(i),watvol(i),temps(i),c_opm(i),c_hum(i),n_opm(i), n_hum(i),nh4(i),no3(i),humusv(i),dmass(i), clayv(i)*100., siltv(i)*100., sandv(i)*100.
end do
endif
! Write control file
call date_and_time(actdate, acttime)
unit_ctr = getunit()
open(unit_ctr,file=trim(dirout)//trim(site_help)//'.ctr'//anh,status='replace')
WRITE(unit_ctr,'(2A)') '*** Site name: ',site_name(help_ip)
WRITE(unit_ctr,'(2A)') ' Appendix ' ,anh
WRITE(unit_ctr,'(A,F7.2)') ' Longitude: ', long
WRITE(unit_ctr,'(A,F7.2)') ' Latitude: ', lat
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(10A)') ' ---- Version: v2.2 ---- '
WRITE(unit_ctr,'(10A)') ' Date: ',actdate(7:8),'.',actdate(5:6),'.',actdate(1:4), &
' Time: ',acttime(1:2),':',acttime(3:4)
WRITE(unit_ctr,'(A,A)') ' Simulation control file: ',trim(simfile)
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '*** Data files:'
IF(flag_clim==1)then
WRITE(unit_ctr,'(A,A)') ' Climfile: ',trim(climfile(ip))
ELSE
WRITE(unit_ctr,'(A,A)') ' Climfile: ',trim(climfile(1))
endif
WRITE(unit_ctr,'(A,A)') ' Sitefile: ',trim(sitefile(help_ip))
WRITE(unit_ctr,'(A,A)') ' Start value file: ',trim(valfile(help_ip))
! Initialization of stand
IF( flag_multi==3 .OR. (site_nr>1 .AND. flag_stand>0) ) THEN
WRITE(unit_ctr,'(A,A)') ' Stand initialization: ',trim(treefile(ip))
ELSE IF( ip==1 .AND. flag_stand>0) THEN
WRITE(unit_ctr,'(A,A)') ' Stand initialization: ',trim(treefile(ip))
ELSE IF (flag_stand==0) THEN
WRITE(unit_ctr,'(A,A)') ' Stand initialization: none'
endif
IF (lmulti) WRITE(unit_ctr,'(A,A)') ' Stand identificator: ', adjustl(standid(ip))
WRITE(unit_ctr,*) ' '
IF(flag_mg.ne.0 .and. flag_mg.ne.5) then
WRITE(unit_ctr,'(A,A)') ' Management control file: ',trim(manfile(ip))
ELSE
WRITE(unit_ctr,'(A)') ' Management: none'
endif
WRITE(unit_ctr,'(A,A)') ' Deposition file: ',trim(depofile(ip))
WRITE(unit_ctr,'(A,A)') ' N reduction file: ',trim(redfile(ip))
WRITE(unit_ctr,'(A,A)') ' Litter initialisation file: ',trim(litfile(ip))
if (flag_stat .gt. 0) WRITE(unit_ctr,'(A,A)') ' File with measurements: ',trim(mesfile(1))
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '*** Soil description '
WRITE(unit_ctr,'(A,I3)') ' Number of soil layers: ',nlay
WRITE(unit_ctr,'(A,I3)') ' Number of rooting layers: ',nroot_max
WRITE(unit_ctr,'(A,I3)') ' Ground water from layer: ',nlgrw
WRITE(unit_ctr,'(A,F5.1)') ' Evaporation depth (cm): ',w_ev_d
call bucket(bucks_100, bucks_root, buckdepth)
buckdepth = buckdepth/100
WRITE(unit_ctr,'(A,F5.2,A,F7.2)') ' Bucket size (mm), ', buckdepth,' m depth: ',bucks_100
WRITE(unit_ctr,'(A,F7.2)') ' Bucket size (mm) of rooting zone: ',bucks_root
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '*** Soil water conditions'
WRITE(unit_ctr,'(12A)') 'Layer ','Depth(cm) ','F-cap(mm) ','F-cap(Vol%) ','Wiltp(mm) ', &
'Wiltp(Vol%) ','Pore vol. ','Density ','Spheat ','pH-value ',' Wlam',' skel. '
do i = 1,nlay
WRITE(unit_ctr,'(I5,12F10.2)') i,depth(i),field_cap(i),f_cap_v(i),wilt_p(i), &
wilt_p_v(i),pv_v(i),dens(i),spheat(i),phv(i),wlam(i),skelv(i)
end do
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '*** Soil initial values'
WRITE(unit_ctr,'(9A)') 'Layer ','Water-cont. ','Soil-temp. ','C_opm ', &
'C_hum ','N_opm ','N_hum ','NH4-cont. ','NO3-cont '
do i=1,nlay
WRITE(unit_ctr,'(I5, 2F10.2, 6F10.4)') i,wats(i),temps(i),c_opm(i),c_hum(i),n_opm(i), &
n_hum(i),nh4(i),no3(i)
end do
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') ' N_tot C_tot N_antot N_humtot C_humtot C_opm_fol C_opm_tb C_opm_frt C_opm_crt C_opm_stem '
WRITE(unit_ctr,'(10F12.4)') N_tot, C_tot, N_an_tot, N_hum_tot, C_hum_tot, C_opm_fol, C_opm_tb, C_opm_frt, C_opm_crt, C_opm_stem
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)',advance='no') 'Mineralization constant of humus - humus layer (k_hum): '
WRITE(unit_ctr,'(F10.5)') k_hum
WRITE(unit_ctr,'(A)',advance='no') 'Mineralization constant of humus - mineral soil (k_hum_r): '
WRITE(unit_ctr,'(F10.5)') k_hum_r
WRITE(unit_ctr,'(A)',advance='no') 'Nitrification constant (k_nit): '
WRITE(unit_ctr,'(F10.5)') k_nit
WRITE(unit_ctr,*) ' '
if (flag_bc .gt.0) then
WRITE(unit_ctr,'(A)') '*** Biochar application '
WRITE(unit_ctr,'(A)') ' year C-content(%) C/N-ratio depth mass(kg/ha dry mass)'
do j = 1, n_appl_bc
WRITE(unit_ctr,'(I7,F14.1, F11.1, I7, F18.1)') &
y_bc(j), cpart_bc(j), cnv_bc(j), bc_appl_lay(j), C_bc_appl(j)
enddo
WRITE(unit_ctr,'(F10.5)')
endif
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '*** Stand initialisation'
WRITE(unit_ctr,'(A)')' Coh x_fol x_frt x_sap x_hrt x_Ahb height x_hbole x_age n sp DC DBH'
help_coh => pt%first
DO WHILE (ASSOCIATED(help_coh))
WRITE(unit_ctr,'(I5,5f12.5,2f10.0,i7,f7.0,i7, 2f12.5)') help_coh%coh%ident, help_coh%coh%x_fol, help_coh%coh%x_frt, help_coh%coh%x_sap, help_coh%coh%x_hrt, &
help_coh%coh%x_Ahb, help_coh%coh%height, help_coh%coh%x_hbole, help_coh%coh%x_age, &
help_coh%coh%nTreeA,help_coh%coh%species, help_coh%coh%dcrb, help_coh%coh%diam
help_coh => help_coh%next
END DO
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '*** Simulation control'
WRITE(unit_ctr,'(A66,I4)') 'Run option: ',flag_multi
WRITE(unit_ctr,'(A66,I4)') 'Start year: ',time_b
WRITE(unit_ctr,'(A66,I4)') 'Number of simulation years - year: ', year
WRITE(unit_ctr,'(A60,F12.1)') 'Patch size [m²] - kpatchsize: ',kpatchsize
WRITE(unit_ctr,'(A60,F12.1)') 'Thickness of leaf layers - dz: ',dz
WRITE(unit_ctr,'(A66,I4)') 'Time step for photosynthesis calculations (days) - ns_pro: ',ns_pro
WRITE(unit_ctr,'(A66,I4)') 'Mortality (0-OFF,1-ON stress, 2- ON stress+intr) - flag_mort: ',flag_mort
WRITE(unit_ctr,'(A66,I4)') 'Regeneration (0-OFF,1-ON, 2-weekly growth of seedl.) - flag_reg: ',flag_reg
WRITE(unit_ctr,'(A66,I4)') 'use FORSKA for regeneration (0-OFF,1-ON) - flag_forska: ',flag_lambda
WRITE(unit_ctr,'(A66,I4)') 'Stand initialization (0-no,1-from *.ini,2-generate) - flag_stand: ',flag_stand
WRITE(unit_ctr,'(A66,I4)') 'Ground vegetation initialization (0-no,1-generate) - flag_sveg: ',flag_sveg
WRITE(unit_ctr,'(A66,I4)') 'Stand management (0-no,1-yes, 2 - seed once) - flag_mg: ',flag_mg
WRITE(unit_ctr,'(A66,I4)') 'Disturbance (0-OFF, 1-ON ) - flag_dis: ',flag_dis
WRITE(unit_ctr,'(A66,I4)') 'Light absoption algorithm (1,2,3,4) - : ',flag_light
WRITE(unit_ctr,'(A66,I4)') 'Foliage-height relationship (0,1) - flag_folhei: ',flag_folhei
WRITE(unit_ctr,'(A66,I4)') 'Volume function trunc (0,1) - flag_volfunc: ',flag_volfunc
WRITE(unit_ctr,'(A66,I4)') 'Respiration model (0-0.5*NPP,1-organ specific) - flag_resp: ',flag_resp
WRITE(unit_ctr,'(A66,I4)') 'Limitation (0-NO,1-water, 2-N, 3-water+N) - flag_limi: ',flag_limi
WRITE(unit_ctr,'(A66,I4)') 'Flag for decomposition model - flag_decomp: ',flag_decomp
WRITE(unit_ctr,'(A66,I4)') 'Root spec. activity (0-const,1-varying) - flag_sign: ',flag_sign
WRITE(unit_ctr,'(A66,I4)') 'Water uptake function soil (1,2,3,4) - flag_wred: ',flag_wred
WRITE(unit_ctr,'(A66,I4)') 'Root distribution - flag_wurz: ',flag_wurz
WRITE(unit_ctr,'(A66,I4)') 'Heat conductance - flag_cond: ',flag_cond
WRITE(unit_ctr,'(A66,I4)') 'Interception - flag_int: ',flag_int
WRITE(unit_ctr,'(A66,I4)') 'Evapotranspiration - flag_eva: ',flag_eva
WRITE(unit_ctr,'(A66,I4)') 'CO2 (0-constant,1-historic increase,2-step change)- flag_co2: ',flag_co2
WRITE(unit_ctr,'(A66,I4)') 'Sort flag - flag_sort: ',flag_sort
WRITE(unit_ctr,'(A66,I4)') 'wpm flag - flag_wpm: ',flag_wpm
WRITE(unit_ctr,'(A66,I4)') 'Analysis of measurements - flag_stat: ',flag_stat
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A66,A)') 'Species parameter file: ',trim(specfile(help_ip))
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '*** Species parameter description'
WRITE(unit_ctr,'(A51,I4)') ' Species number: ', nspecies
WRITE(unit_ctr,'(A51,I4)') ' Number of tree species: ', nspec_tree
WRITE(unit_ctr,*) ' ********** '
WRITE(unit_ctr,'(A25,A9,2X,A30)') 'Short Name', ' Spec-Nr', 'Latin Name '
WRITE(unit_ctr,*) ' '
do i=1,nspecies
WRITE(unit_ctr,'(A25,I9,2X,A30)') trim(spar(i)%species_short_name), i, spar(i)%species_name
enddo
WRITE(unit_ctr,*) ' ********** '
WRITE(unit_ctr,'(A51,15A16)') ' Species name: ', (trim(spar(i)%species_short_name),i=1,nspecies)
WRITE(unit_ctr,1010) ' Maximal age - max_age: ', (spar(i)%max_age,i=1,nspecies)
WRITE(unit_ctr,1010) ' Stress rec. time - yrec: ', (spar(i)%yrec,i=1,nspecies)
WRITE(unit_ctr,1010) ' Shade tolerance - stol: ', (spar(i)%stol,i=1,nspecies)
WRITE(unit_ctr,1000) ' Extinction coeff - pfext: ', (spar(i)%pfext,i=1,nspecies)
WRITE(unit_ctr,1000) ' Root activity rate - sigman: ', (spar(i)%sigman,i=1,nspecies)
WRITE(unit_ctr,1000) ' Respiration coeff - respcoeff: ', (spar(i)%respcoeff,i=1,nspecies)
WRITE(unit_ctr,1000) ' Growth resp. par. - prg: ', (spar(i)%prg,i=1,nspecies)
WRITE(unit_ctr,1000) ' Maint.resp.par./sapwood - prms: ', (spar(i)%prms,i=1,nspecies)
WRITE(unit_ctr,1000) ' Maint.resp.par./fineroot - prmr: ', (spar(i)%prmr,i=1,nspecies)
WRITE(unit_ctr,1000) ' Senesc.par. foliage - psf: ', (spar(i)%psf,i=1,nspecies)
WRITE(unit_ctr,1000) ' Senesc.par. sapwood - pss: ', (spar(i)%pss,i=1,nspecies)
WRITE(unit_ctr,1000) ' Senesc.par. fineroot - psr: ', (spar(i)%psr,i=1,nspecies)
WRITE(unit_ctr,1000) ' N/C ratio of biomass - pcnr: ', (spar(i)%pcnr,i=1,nspecies)
WRITE(unit_ctr,1000) ' N concentration of foliage - ncon_fol: ', (spar(i)%ncon_fol,i=1,nspecies)
WRITE(unit_ctr,1000) ' N concentration of fine roots - ncon_frt: ', (spar(i)%ncon_frt,i=1,nspecies)
WRITE(unit_ctr,1000) ' N concentration of coarse roots - ncon_crt: ', (spar(i)%ncon_crt,i=1,nspecies)
WRITE(unit_ctr,1000) ' N concentration of twigs and branches - ncon_tbc: ', (spar(i)%ncon_tbc,i=1,nspecies)
WRITE(unit_ctr,1000) ' N concentration of stemwood - ncon_stem: ', (spar(i)%ncon_stem,i=1,nspecies)
WRITE(unit_ctr,1000) ' Reallocation parameter of foliage - reallo_fol: ', (spar(i)%reallo_fol,i=1,nspecies)
WRITE(unit_ctr,1000) ' Reallocation parameter of fine root - reallo_frt: ', (spar(i)%reallo_frt,i=1,nspecies)
WRITE(unit_ctr,1000) ' Ratio of coarse wood - alphac: ', (spar(i)%alphac,i=1,nspecies)
WRITE(unit_ctr,1000) ' Coarse root fraction of coarse wood - cr_frac: ', (spar(i)%cr_frac,i=1,nspecies)
WRITE(unit_ctr,1000) ' Sapwood density - prhos: ', (spar(i)%prhos,i=1,nspecies)
WRITE(unit_ctr,1000) ' Proport.const.(pipe mod.) - pnus: ', (spar(i)%pnus,i=1,nspecies)
IF(flag_folhei==0) THEN
WRITE(unit_ctr,1000) ' Height growth parameter - pha: ', (spar(i)%pha,i=1,nspecies)
ELSEIF(flag_folhei==1) THEN
WRITE(unit_ctr,1000) ' Height growth par. 1 - pha_v1: ', (spar(i)%pha_v1,i=1,nspecies)
WRITE(unit_ctr,1000) ' Height growth par. 2 - pha_v2: ', (spar(i)%pha_v2,i=1,nspecies)
WRITE(unit_ctr,1000) ' Height growth par. 3 - pha_v3: ', (spar(i)%pha_v3,i=1,nspecies)
ELSE
WRITE(unit_ctr,'(A51,I3)') ' non valid flag value - flag_folhei : ',flag_folhei
ENDIF
WRITE(unit_ctr,1000) ' Height growth parameter coeff 1 - pha_coeff1: ', (spar(i)%pha_coeff1,i=1,nspecies)
WRITE(unit_ctr,1000) ' Height growth parameter coeff 2 - pha_coeff2: ', (spar(i)%pha_coeff2,i=1,nspecies)
WRITE(unit_ctr,1000) ' Crown radius - DBH ratio parameter a - crown_a: ', (spar(i)%crown_a,i=1,nspecies)
WRITE(unit_ctr,1000) ' Crown radius - DBH ratio parameter b - crown_b: ', (spar(i)%crown_b,i=1,nspecies)
WRITE(unit_ctr,1000) ' Crown radius - DBH ratio parameter c - crown_c: ', (spar(i)%crown_c,i=1,nspecies)
WRITE(unit_ctr,1000) ' Minimum specific leaf area - psla_min: ', (spar(i)%psla_min,i=1,nspecies)
WRITE(unit_ctr,1000) ' Light dep. specific leaf area - psla_a: ', (spar(i)%psla_a,i=1,nspecies)
WRITE(unit_ctr,1000) ' Efficiency parameter - phic: ', (spar(i)%phic,i=1,nspecies)
WRITE(unit_ctr,1000) ' N content - pnc: ', (spar(i)%pnc,i=1,nspecies)
WRITE(unit_ctr,1000) ' kco2_25: ', (spar(i)%kCO2_25,i=1,nspecies)
WRITE(unit_ctr,1000) ' ko2_25: ', (spar(i)%kO2_25,i=1,nspecies)
WRITE(unit_ctr,1000) ' CO2/O2 specif. value - pc_25: ', (spar(i)%pc_25,i=1,nspecies)
WRITE(unit_ctr,1000) ' Q10_kco2: ', (spar(i)%q10_kCO2,i=1,nspecies)
WRITE(unit_ctr,1000) ' Q10_ko2: ', (spar(i)%q10_kO2,i=1,nspecies)
WRITE(unit_ctr,1000) ' Q10_pc: ', (spar(i)%q10_pc,i=1,nspecies)
WRITE(unit_ctr,1000) ' Rd to Vm ratio - pb: ', (spar(i)%pb,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Inhibitor min temp. - PItmin: ', (spar(i)%PItmin,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Inhibitor opt temp. - PItopt: ', (spar(i)%PItopt,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Inhibitor max temp. - PItmax: ', (spar(i)%PItmax,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Inhibitor scaling factor - PIa: ', (spar(i)%PIa,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Promotor min temp. - PPtmin: ', (spar(i)%PPtmin,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Promotor opt temp. - PPtopt: ', (spar(i)%PPtopt,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Promotor max temp. - PPtmax: ', (spar(i)%PPtmax,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Promotor scaling factor - PPa: ', (spar(i)%PPa,i=1,nspecies)
WRITE(unit_ctr,1000) ' PIM: Promotor scaling factor - PPb: ', (spar(i)%PPb,i=1,nspecies)
WRITE(unit_ctr,1000) ' CSM: chilling base temp. - CSTbC: ', (spar(i)%CSTbC,i=1,nspecies)
WRITE(unit_ctr,1000) ' CSM: base temp. - CSTbT: ', (spar(i)%CSTbT,i=1,nspecies)
WRITE(unit_ctr,1000) ' CSM: scaling factor - CSa: ', (spar(i)%CSa,i=1,nspecies)
WRITE(unit_ctr,1000) ' CSM: scaling factor - CSb: ', (spar(i)%CSb,i=1,nspecies)
WRITE(unit_ctr,1000) ' TSM: base temp. - LTbT: ', (spar(i)%LTbT,i=1,nspecies)
WRITE(unit_ctr,1000) ' TSM: critical temperature sum - LTcrit: ', (spar(i)%LTcrit,i=1,nspecies)
WRITE(unit_ctr,1010) ' TSM: start day after 1.11. - Lstart: ', (spar(i)%Lstart,i=1,nspecies)
WRITE(unit_ctr,1000) ' usefd pheno model - Phmodel: ', (spar(i)%Phmodel,i=1,nspecies)
WRITE(unit_ctr,1000) ' End day for phenology - end_bb: ', (spar(i)%end_bb,i=1,nspecies)
WRITE(unit_ctr,1000) ' Fpar_mod - fpar_mod: ', (spar(i)%fpar_mod,i=1,nspecies)
WRITE(unit_ctr,1000) ' Intercep.cap. - ceppot_spec: ', (spar(i)%ceppot_spec,i=1,nspecies)
WRITE(unit_ctr,1000) ' photosynthesis response to N-limitation - Nresp: ', (spar(i)%Nresp,i=1,nspecies)
WRITE(unit_ctr,1000) ' Regeneration flag - regflag: ', (spar(i)%regflag,i=1,nspecies)
WRITE(unit_ctr,1000) ' Seedrate: ', (spar(i)%seedrate,i=1,nspecies)
WRITE(unit_ctr,1000) ' Seedmass: ', (spar(i)%seedmass,i=1,nspecies)
WRITE(unit_ctr,1000) ' Standard dev. of seedrate - seedsd: ', (spar(i)%seedsd,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - seeda: ', (spar(i)%seeda,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - seedb: ', (spar(i)%seedb,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - pheight1: ', (spar(i)%pheight1,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - pheight2: ', (spar(i)%pheight2,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - pheight3: ', (spar(i)%pheight3,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - pdiam1: ', (spar(i)%pdiam1,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - pdiam2: ', (spar(i)%pdiam2,i=1,nspecies)
WRITE(unit_ctr,1000) ' all. parameter - pdiam3: ', (spar(i)%pdiam3,i=1,nspecies)
WRITE(unit_ctr,1000) ' decomp. parameter foliage - k_opm_fol: ', (spar(i)%k_opm_fol,i=1,nspecies)
WRITE(unit_ctr,1000) ' synth. parameter foliage - k_syn_fol: ', (spar(i)%k_syn_fol,i=1,nspecies)
WRITE(unit_ctr,1000) ' decomp. parameter fine roots - k_opm_frt: ', (spar(i)%k_opm_frt,i=1,nspecies)
WRITE(unit_ctr,1000) ' synth. parameter fine roots - k_syn_frt: ', (spar(i)%k_syn_frt,i=1,nspecies)
WRITE(unit_ctr,1000) ' decomp. parameter coarse roots - k_opm_crt: ', (spar(i)%k_opm_crt,i=1,nspecies)
WRITE(unit_ctr,1000) ' synth. parameter coarse roots - k_syn_crt: ', (spar(i)%k_syn_crt,i=1,nspecies)
WRITE(unit_ctr,1000) ' decomp. parameter twigs/branches - k_opm_tb: ', (spar(i)%k_opm_tb,i=1,nspecies)
WRITE(unit_ctr,1000) ' synth. parameter twigs/branches - k_syn_tb: ', (spar(i)%k_syn_tb,i=1,nspecies)
WRITE(unit_ctr,1000) ' decomp. parameter stem - k_opm_stem: ', (spar(i)%k_opm_stem,i=1,nspecies)
WRITE(unit_ctr,1000) ' synth. parameter dtem - k_syn_stem: ', (spar(i)%k_syn_stem,i=1,nspecies)
WRITE(unit_ctr,1000)
WRITE(unit_ctr,1000) ' spec_rl: ', (spar(i)%spec_rl,i=1,nspecies)
WRITE(unit_ctr,1000) ' tbase: ', (spar(i)%tbase,i=1,nspecies)
WRITE(unit_ctr,1000) ' topt: ', (spar(i)%topt,i=1,nspecies)
WRITE(unit_ctr,1000) ' bdmax_coef: ', (spar(i)%bdmax_coef,i=1,nspecies)
WRITE(unit_ctr,1000) ' porcrit_coef: ', (spar(i)%porcrit_coef,i=1,nspecies)
WRITE(unit_ctr,1000) ' ph_opt_max: ', (spar(i)%ph_opt_max,i=1,nspecies)
WRITE(unit_ctr,1000) ' ph_opt_min: ', (spar(i)%ph_opt_min,i=1,nspecies)
WRITE(unit_ctr,1000) ' ph_max: ', (spar(i)%ph_max,i=1,nspecies)
WRITE(unit_ctr,1000) ' ph_min : ', (spar(i)%ph_min ,i=1,nspecies)
WRITE(unit_ctr,1000) ' v_growth: ', (spar(i)%v_growth,i=1,nspecies)
WRITE(unit_ctr,1000)
WRITE(unit_ctr,1000) ' C/N ratio of foliage - cnr_fol: ', (spar(i)%cnr_fol,i=1,nspecies)
WRITE(unit_ctr,1000) ' C/N ratio of fine roots - cnr_frt: ', (spar(i)%cnr_frt,i=1,nspecies)
WRITE(unit_ctr,1000) ' C/N ratio of coarse roots - cnr_crt: ', (spar(i)%cnr_crt,i=1,nspecies)
WRITE(unit_ctr,1000) ' C/N ratio of twigs and branches - cnr_tbc: ', (spar(i)%cnr_tbc,i=1,nspecies)
WRITE(unit_ctr,1000) ' C/N ratio of stemwood - cnr_stem: ', (spar(i)%cnr_stem,i=1,nspecies)
WRITE(unit_ctr,1000)
WRITE(unit_ctr,1000) ' Reduction factor - RedN: ', (svar(i)%RedN, i=1,nspecies)
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,'(A)') '****** Model parameter ******'
WRITE(unit_ctr,1020) 'Optimum ratio of ci to ca [-] - Lambda: ',lambda
WRITE(unit_ctr,1020) 'Molar mass of carbon [g/mol] - Cmass: ',Cmass
WRITE(unit_ctr,1020) 'Minimum conductance [mol/(m2*d)] - gmin: ',gmin
WRITE(unit_ctr,1020) 'Shape of PS response curve - ps: ',ps
WRITE(unit_ctr,1020) 'Slope of N function at 20 °C [g(N) (mymol s-1)-1] - pn: ',pn
WRITE(unit_ctr,1020) 'Minimum N content [g/g] - nc0: ',nc0
WRITE(unit_ctr,1020) 'C3 quantum efficiency - qco2: ',qco2
WRITE(unit_ctr,1020) 'Scaling parameter - qco2a: ',qco2a
WRITE(unit_ctr,1020) 'Partial pressure of oxygen (kPa) - o2: ',o2
WRITE(unit_ctr,1020) 'Atmospheric CO2 content (mol/mol) - co2: ',co2_st
WRITE(unit_ctr,1020) 'Albedo of the canopy - pfref: ',pfref
WRITE(unit_ctr,1020) 'Part of C in biomass [-] - cpart: ',cpart
WRITE(unit_ctr,1020) 'Ratio of molecular weights of water and air - rmolw: ',rmolw
WRITE(unit_ctr,1020) 'Universal gas constant [J/mol/K] = [Pa/m3/K] - R_gas: ',R_gas
WRITE(unit_ctr,1020) 'von Karman''s constant [-] - c_karman: ',c_karman
WRITE(unit_ctr,1020) 'Specific heat of air at const. pressure [J/g/K] - c_air: ',c_air
WRITE(unit_ctr,1020) 'Psychrometer constant [hPa/K] - psycro: ',psycro
WRITE(unit_ctr,1020) 'Breast height for inventory measurements [cm] - h_breast: ',h_breast
WRITE(unit_ctr,1020) 'Height for sapling allometry - h_sapini: ',h_sapini
WRITE(unit_ctr,1020) 'Min. diff. b. height of crown base and breast height- h_bo_br_diff: ',h_bo_br_diff
WRITE(unit_ctr,1020) 'Parameter variable for calculation of CO2 scenario - p1_co2: ',p1_co2
WRITE(unit_ctr,1020) 'Parameter variable for calculation of CO2 scenario - p2_co2: ',p2_co2
WRITE(unit_ctr,1020) 'Parameter variable for calculation of CO2 scenario - p3_co2: ',p3_co2
WRITE(unit_ctr,1020) 'Parameter variable for calculation of CO2 scenario - p4_co2: ',p4_co2
WRITE(unit_ctr,1020) 'Parameter variable for calculation of CO2 scenario - p5_co2: ',p5_co2
WRITE(unit_ctr,1020) 'Parameter variable for calculation of historical CO2 scenario - p1_co2h: ',p1_co2h
WRITE(unit_ctr,1020) 'Parameter variable for calculation of historical CO2 scenario - p2_co2h: ',p2_co2h
WRITE(unit_ctr,1020) 'Parameter variable for calculation of historical CO2 scenario - p3_co2h: ',p3_co2h
WRITE(unit_ctr,1020) 'Parameter variable for calculation of historical CO2 scenario - p4_co2h: ',p4_co2h
WRITE(unit_ctr,1020) 'Threshold of air temperature for snow accumulation [°C] - temp_snow: ',temp_snow
WRITE(unit_ctr,1020) 'Parameter for calculation of transpiration demand - alfm: ',alfm
WRITE(unit_ctr,1020) 'Parameter for calculation of transpiration demand [mol/(m2*d)] - gpmax: ',gpmax
WRITE(unit_ctr,1020) 'Parameter for growing degree day calculation - thr_gdd: ',thr_gdd
IF (flag_multi==2) THEN
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,*) 'runs with climate scenarios produced by adding summands to every daily temperature'
WRITE(unit_ctr,*) 'and modifying every single precipitation value by a multiplicand'
WRITE(unit_ctr,*) 'run ident deltaT delta P factor'
ENDIF
! mangament parameter adaptation management
IF (flag_mg.eq.2. .and. flag_reg .eq. 0) then
WRITE(unit_ctr,*) ' '
WRITE(unit_ctr,*) '***Managment parameter case flag_mg = 2 (user specified) ***'
WRITE(unit_ctr,'(A35,4F15.5)') 'height for management control(cm)', ho1,ho2,ho3,ho4
WRITE(unit_ctr,'(A35,5I15)') 'management flags thr1-thr5' , thr1,thr2, thr3,thr4,thr5
WRITE(unit_ctr,'(A35,F15.5)') 'height for directional felling', thr6
WRITE(unit_ctr,'(A35,I15)') 'measure at rotation', thr7
WRITE(unit_ctr,'(A35,I15)') 'regeneration measure', mgreg
WRITE(unit_ctr,'(A35,F15.5)') 'lower/upper limit of height(cm)', limit
WRITE(unit_ctr,'(A35,I15)') 'number of years between thinning',thinstep
WRITE(unit_ctr,'(A35,F15.5)') 'rel. value for directional felling', direcfel
WRITE(unit_ctr,'(A35,5F15.5)')'number of Zielbaeume(spec.)', (zbnr(i),i=1,nspec_tree)
WRITE(unit_ctr,'(A35,5F15.5)')'rel. value for tending of pl.',(tend(i), i =1,nspec_tree)
WRITE(unit_ctr,'(A35,5I15)')'rotation ',(rot(i), i =1,nspec_tree)
WRITE(unit_ctr,'(A35,5I15)')'age of nat./pl. regeneration',(regage(i), i =1,nspec_tree)
end IF
IF (flag_multi .ne. 2.and. flag_mg.ne.2 .and. flag_reg .eq.0) close(unit_ctr)
endif ! flag_mult8910
1000 FORMAT (A51,15 F16.5)
1010 FORMAT (A51,15 I16)
1020 FORMAT(A70,F15.5)
end subroutine control_file
end subroutine prepare_site
!******************************************************************************
SUBROUTINE readbudb
use data_simul
use data_species
use data_stand
implicit none
DO ns=1,nspecies
IF(spar(ns)%phmodel==4) THEN
WRITE(*,*) 'Please type the day of budburst for 4C species number ',ns,':'
READ(*,*) svar(ns)%ext_daybb
ENDIF
ENDDO
END subroutine readbudb
!******************************************************************************
SUBROUTINE readdepo
use data_climate
use data_depo
use data_out
use data_simul
use data_site
implicit none
character text
integer hx, unit_dep, i,j,ios, ii
!integer realrec
integer id,im,iy,itz1, itz2, hyear1, hyear2, hyear3, hy
logical ex
real hNO, hNH
if (flag_trace) write (unit_trace, '(I4,I10,A)') iday, time_cur, ' readdepo'
if (.not.allocated(NOd)) allocate (NOd (1:366,1:year))
if (.not.allocated(NHd)) allocate (NHd (1:366, 1:year))
! for areal usage standard/constant deposition is set as concentration:
if (flag_multi .eq. 8 .or. flag_mult910) then
flag_depo = 2
NOd = NOdep(ip) ! concentration mg/l
NHd = NHdep(ip) ! concentration mg/l
return
endif
NOd = 0.
NHd = 0.
if (.not.flag_mult8910) print *
inquire (File = depofile(ip), exist = ex) ! test whether file exists
IF(ex .eqv. .false.) then
if (.not.flag_mult8910) then
hx = 0
print *,' >>>FORESEE message: Cannot find deposition data - all data set to zero!'
CALL error_mess(hx,'Cannot find deposition data - all data set to ',REAL(hx))
endif
else
if (.not.flag_mult8910) print *, ' >>>FORESEE message: Now reading DEPOSITION data from file, please wait...'
! now read data from file
unit_dep = getunit()
OPEN (unit_dep,FILE=depofile(ip),IOSTAT=ios,STATUS='OLD',ACTION='READ')
flag_depo = 1
read(unit_dep,*) text
select case (text)
case ('C', 'c') ! concentrations mg/l
flag_depo = 2
read(unit_dep,*) text
case ('Y', 'y') ! Yearly constant deposition mg/m2
flag_depo = 3
read(unit_dep,*) text
case ('A', 'a') ! Annual sum of deposition g/m2
flag_depo = 4
read(unit_dep,*) text
end select
do
IF (text .ne. '!') then
backspace(unit_dep)
exit
endif
read(unit_dep,*) text
enddo
! assignment of dates
! fill in missing values with current values until current date
! fill in missing values at the end
hyear1 = 0
hyear2 = 0
hyear3 = 1
itz1 = 1
itz2 = 1
select case (flag_depo)
case(4)
do while ((ios .eq. 0) .and. (hyear1 .lt. year))
read(unit_dep,*,iostat=ios) iy, hNO, hNH
if (ios .eq.0) then
if (iy .gt. time_b+year) then
hyear1 = year
else
hyear1 = iy - time_b + 1
endif
if ((hyear1 .le. year) .and. (hyear1 .gt. 0)) then ! save from simulation start year onwards
do i = 1,366
NOd(i,hyear1) = hNO * 1000./366. ! report of year [g/m2] in daily values [mg/m2]
NHd(i,hyear1) = hNH * 1000./366.
enddo
hy = hyear1-1
do while ((hy .gt. hyear2) .and. (hy .gt. 0))
do i = 366, 1, -1
NOd(i,hy) = hNO * 1000./366.
NHd(i,hy) = hNH * 1000./366.
enddo
hy = hy - 1
enddo
hyear2 = hyear1
endif ! 0 < hyear1 < year
else ! ios .ne. 0
if (hyear1 .le. 0) then
hyear1 = 1
hyear2 = 1
endif
continue
endif ! ios = 0
enddo
case default
do while ((ios .eq. 0) .and. (hyear1 .lt. year))
read(unit_dep,*,iostat=ios) id,im,iy, hNO, hNH
if (ios .eq.0) then
call daintz(id,im,iy,itz1)
if (iy .gt. time_b+year) then
hyear1 = year
else
hyear1 = iy - time_b + 1
endif
if ((hyear1 .le. year) .and. (hyear1 .gt. 0)) then ! save from simulation start year onwards
NOd(itz1,hyear1) = hNO
NHd(itz1,hyear1) = hNH
select case (flag_depo)
case(1,2)
if (hyear1 .eq. hyear3) then
if (itz1 .gt. 1) then
do i = itz1-1, itz2, -1
NOd(i,hyear1) = hNO
NHd(i,hyear1) = hNH
enddo
endif
else
if (itz2 .lt. recs(hyear3)) then
do i = itz2+1, recs(hyear3)
NOd(i,hyear3) = hNO
NHd(i,hyear3) = hNH
enddo
endif
itz2 = 1
if (itz1 .gt. 1) then
do i = itz1-1, itz2, -1
NOd(i,hyear1) = hNO
NHd(i,hyear1) = hNH
enddo
endif
hy = hyear1-1
do while ((hy .gt. hyear3) .and. (hy .gt. 0))
do i = 366, 1, -1
NOd(i,hy) = hNO
NHd(i,hy) = hNH
enddo
hy = hy - 1
enddo
endif ! hyear1 .eq. hyear3
hyear3 = hyear1
itz2 = itz1
hyear2 = hyear3
case(3) ! fill in of constant year values
do i = 1,366
NOd(i,hyear1) = hNO
NHd(i,hyear1) = hNH
enddo
hy = hyear1-1
do while ((hy .gt. hyear2) .and. (hy .gt. 0))
do i = 366, 1, -1
NOd(i,hy) = hNO
NHd(i,hy) = hNH
enddo
hy = hy - 1
enddo
hyear2 = hyear1
itz2 = 366
end select ! flag_depo 1-3
endif ! 0 < hyear1 < year
else ! ios .ne. 0
if (hyear1 .le. 0) then
hyear1 = 1
hyear2 = 1
endif
continue
endif ! ios = 0
enddo
end select ! flag_depo
! fill in of the missing data at the end
select case (flag_depo)
case (3)
if (hyear1 .lt. year) then
hy = hyear1+1
do while (hy .le. year)
do i = 366, 1, -1
NOd(i,hy) = hNO
NHd(i,hy) = hNH
enddo
hy = hy + 1
enddo
else ! if date is outside the simulation period, it will be completly filled in
do j = 1, year
do i = 1, 366
NOd(i,j) = hNO
NHd(i,j) = hNH
enddo
enddo
endif
case default
if (hyear2 .le. year) then
if (itz2 .lt. recs(hyear2)) then
if (.not.flag_mult8910) then
hx = iy
CALL error_mess(hx,' Not enough data records in deposition file, iostat = ',REAL(ios))
WRITE (unit_err,*) ' >>>FORESEE message: Fill next values with same data '
WRITE (unit_err,'(A,2I4,A,2I4)')' from internal simulation time', itz2, hyear2, ' to', recs(hyear2), year
endif
do j = hyear2, year
ii = 1
if (j .eq. hyear2) ii = itz2
do i = ii, 366
NOd(i,j) = hNO
NHd(i,j) = hNH
enddo
enddo
else
hy = hyear2+1
do while (hy .le. year)
do i = 366, 1, -1
NOd(i,hy) = hNO
NHd(i,hy) = hNH
enddo
hy = hy + 1
enddo
endif
else ! if date is outside the simulation period, it will be completly filled in
do j = 1, year
do i = 1, 366
NOd(i,j) = hNO
NHd(i,j) = hNH
enddo
enddo
endif
end select
close (unit_dep)
endif
write (*,*)
END subroutine readdepo
!******************************************************************************
SUBROUTINE readredN
use data_out
use data_site
use data_species
use data_stand
use data_simul
implicit none
character text
integer hx, unit_red, i,ios
logical ex
if (.not.flag_mult8910) print *
if (flag_multi .lt. 8) then
inquire (File = "./input/.", exist = ex) ! test whether file exists
inquire (File = redfile(ip), exist = ex) ! test whether file exists
IF(ex .eqv. .false.) then
print *,' >>>FORESEE message: Cannot find data of RedN - internal calculation'
hx = 0
CALL error_mess(hx,'Cannot find data of RedN - internal calculation ',REAL(hx))
else
print *, ' >>>FORESEE message: Now reading RedN data from file, please wait...'
unit_red = getunit()
OPEN (unit_red,FILE=redfile(ip),IOSTAT=ios,STATUS='OLD',ACTION='READ')
DO
READ(unit_red,*) text
IF (text .ne. '!') THEN
backspace(unit_red)
EXIT
ENDIF
ENDDO
read (unit_red,*,iostat=ios) (svar(i)%RedN, i=1,nspecies)
close (unit_red)
endif ! ex
else
do i = 1, nspecies
svar(i)%RedN = RedN_list(i, ip)
enddo
endif ! flag_multi
IF(flag_limi==0 .OR. flag_limi==1) THEN
DO i=1,nspecies
svar(i)%RedN = 1.
ENDDO
ENDIF
do i = 1,nspecies
if (svar(i)%RedN .lt. 0) then ! no values; internal calculation
if (flag_multi .lt. 8) then
print *,' >>>FORESEE message: Cannot find data of RedN - internal calculation for', spar(i)%species_short_name
write (unit_err, '(A,I3,1X,A)') 'Cannot find data of RedN - internal calculation for species ',i, spar(i)%species_short_name
endif
flag_redn = .TRUE.
endif
enddo
if (.not.flag_mult8910) write (*,*)
END subroutine readredN
!******************************************************************************
SUBROUTINE readlit
!use data_climate
use data_out
use data_soil_cn
use data_species
use data_stand
use data_simul
implicit none
character text
integer unit_lit, i,ios
integer nspec_lit
logical ex
real help, hx
real, dimension(22) :: helpin
flag_lit = 0
if (flag_mult8910) then
inquire (File = litfile(1), exist = ex) ! test whether file exists
else
print *
inquire (File = litfile(ip), exist = ex) ! test whether file exists
endif
IF(ex .eqv. .false.) then
if (.not.flag_mult8910) then
print *,' >>>FORESEE message: Cannot find data of litter initialisation - internal calculation'
hx = 0.
write (unit_err,*)
write (unit_err,*) 'Cannot find data of litter initialisation - internal calculation '
endif
else
if (.not.flag_mult8910) print *, ' >>>FORESEE message: Now reading litter initialisation data from file, please wait...'
! now read data from file
unit_lit = getunit()
OPEN (unit_lit,FILE=litfile(ip),IOSTAT=ios,STATUS='OLD',ACTION='READ')
do
read(unit_lit,*) text
IF (text .ne. '!') then
backspace(unit_lit)
exit
endif
enddo
helpin = 0.
slit%C_opm_fol = 0.
read (unit_lit,*) nspec_lit
read (unit_lit,*,iostat=ios) text, (slit(i)%C_opm_fol, i=1,nspec_lit)
read (unit_lit,*,iostat=ios) text, (slit(i)%C_opm_tb , i=1,nspec_lit)
read (unit_lit,*,iostat=ios) text, (slit(i)%C_opm_frt(1), i=1,nspec_lit)
read (unit_lit,*,iostat=ios) text, (slit(i)%C_opm_crt(1), i=1,nspec_lit)
read (unit_lit,*,iostat=ios) text, (slit(i)%C_opm_stem,i=1,nspec_lit)
flag_lit = 1
help = 0.
hx = 1.
do i=1,nspecies
if (slit(i)%C_opm_fol .gt. 0) then
totfol_lit = totfol_lit + slit(i)%C_opm_fol
totfrt_lit = totfrt_lit + slit(i)%C_opm_frt(1)
tottb_lit = tottb_lit + slit(i)%C_opm_tb
totcrt_lit = totcrt_lit + slit(i)%C_opm_crt(1)
totstem_lit = totstem_lit + slit(i)%C_opm_stem
else
hx = -1.
endif
enddo
help = totfol_lit
if ((help .gt. 0.) .or. (hx .gt. 0) .and. .not.flag_mult8910) then
CALL error_mess(0,'Using data of litter initialisation from file '//trim(litfile(ip)), hx)
else
! no values; internal calculation of litter initialisation
if (.not.flag_mult8910) then
print *,' >>>FORESEE message: No data of litter initialisation - internal calculation'
hx = 0.
CALL error_mess(0,'No data of litter initialisation - internal calculation ', hx)
endif
flag_lit = 0
endif
close (unit_lit)
endif ! ex
if (.not.flag_mult8910) write (*,*)
END subroutine readlit
!******************************************************************************
subroutine prepare_climate
! read climate file
use data_climate
use data_out
use data_simul
use data_stand
implicit none
type clifile ! new data type for all climate parameters
integer :: day,mon,ye
real :: m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11
end type clifile
type (clifile), allocatable,dimension(:,:) :: climall !variable for data type climfile
character(1) c
character :: text
integer :: i,j,ios, unit_cli
integer :: realrec = 0
integer :: repflag = 0
logical :: ex
if (.not.flag_mult8910) then
print *, ' '
print *, ' Input of climate data: '
endif
call testfile(climfile(ip),ex) !input filename, test whether file exists
IF(ex .eqv. .false.) then
print *,' >>>FORESEE message: Cannot find climate data - program STOP!'
stop
endif
if (.not.flag_mult8910) print *, ' >>>FORESEE message: Now reading CLIMATE data from file, please wait...'
!now read data from file
unit_cli = getunit()
OPEN (unit_cli,FILE=climfile(ip),IOSTAT=ios,STATUS='OLD',ACTION='READ')
allocate (recs (1:year))
allocate (dd (1:366,1:year));allocate (mm (1:366, 1:year))
allocate (yy (1:year));allocate (tp (-2:366,1:year))
allocate (hm (0:366,1:year));allocate (prc (0:366,1:year))
allocate (prs (0:366,1:year));allocate (rd (0:366,1:year))
allocate (tn (0:366,1:year))
allocate (tx (0:366,1:year))
allocate (vp (0:366,1:year))
allocate (sdu (0:366,1:year))
allocate (wd (0:366,1:year))
allocate (sde (0:366,1:year))
allocate (bw (0:366,1:year))
dd = -99.9
mm = -99.9
yy = -99.9
tn = -99.9
tx = -99.9
wd = -99.9 ! wind initialisation
IF (index(climfile(ip),'.cli') .ne. 0) then
flag_climtyp = 1
do
read(unit_cli,*) text
IF (text .ne. '!') then
IF (text .eq. 'N') then
flag_climtyp = 2
else IF(text.eq.'T') then
flag_climtyp = 3
else
backspace(unit_cli)
exit
endif
endif
enddo
else if (index(climfile(ip),'.txt') .ne. 0) then
flag_climtyp = 4
else
flag_climtyp = 5
end IF
call read_cli
close(unit_cli)
if (flag_end .gt. 0) return
IF (realrec < year .and. repflag == 0) then
year = realrec
else
IF (repflag == 1) then
call climfill
end IF
end IF
med_rad1 = 0.
do j = 1, year-1
tp(0,j+1) = tp(recs(j),j)
tp(-1,j+1)= tp(recs(j)-1,j)
tp(-2,j+1)= tp(recs(j)-2,j)
hm(0,j+1) = hm(recs(j),j);prc(0,j+1) = prc(recs(j),j);prs(0,j+1) = prs(recs(j),j)
rd(0,j+1) = rd(recs(j),j)
wd(0,j+1) = wd(recs(j),j)
bw(0,j+1) = bw(recs(j),j)
vp(0,j+1) = vp(recs(j),j)
sdu(0,j+1) = sdu(recs(j),j)
sde(0,j+1) = sde(recs(j),j)
tx(0,j+1) = tx(recs(j),j)
tn(0,j+1) = tn(recs(j),j)
if( yy(j) .eq.time_b) then
do i=1, recs(j)
med_rad1 = med_rad1 + rd(i, j)
end do
med_rad1 = med_rad1/recs(1)
end if
end do
tp(-2,1) = tp(1,1); tp(-1,1) = tp(1,1); tp(0,1) = tp(1,1)
hm(0,1) = hm(1,1);prc(0,1) = prc(1,1);prs(0,1) = prs(1,1)
rd(0,1) = rd(1,1)
wd(0,1)=wd(1,1)
vp(0,1) = vp(1,1)
bw(0,1) = bw(1,1)
tn(0,1) = tn(1,1)
tx(0,1) = tx(1,1)
sdu(0,1) =sdu(1,1)
sde(0,1) = sde(1,1)
contains
!--------------------------------------------------------------
subroutine read_dwd
character(3) text
integer help, help1, help2, help3
allocate (climall (0:366,1:year))
j=1
c = 'n'
do
IF (j > year) then
realrec = year
exit
end IF
if (.not.flag_mult8910) print *, 'Year ',j
read(unit_cli,*) text
if(text.ne.'ta ') then
backspace(unit_cli)
end if
do i = 1, 366
read (unit_cli,*,IOSTAT=ios) climall(i,j)
help2 = climall(i,j)%day
help3 = climall(i,j)%mon
help = climall(i,j)%ye
help1 = climall(i-1,j)%ye
if (help.eq.2099 .and.help1.eq.2100.and. i.eq.366) then
end if
end do
IF (climall(365,j)%ye == climall(366,j)%ye) then
recs(j) = 366
else
backspace unit_cli
climall(366,j)%day = 0
climall(366,j)%mon = 0
climall(366,j)%ye = 0
recs(j) = 365
help = help-1
end IF
IF (j < year .and. ios < 0 .and. c .eq. 'n') then
realrec = j
if (.not.flag_mult8910) then
print *, ' >>>FORESEE message: Not enough climate data records in file!'
call error_mess(0,'read_cli: Not enough data records in climate file; number of complete years: ',real(realrec))
write(unit_err,'(A,I5)')' read_cli: Fill next values with same from first year, day: ',i_exit
write(unit_err,'(A,I5)')' read_cli: Fill next values with same data up to years: ',year
repflag = 1
exit
endif
else if(j.eq.year.and.ios < 0) then
realrec = year
exit
end IF
j=j+1
if(help.lt.time_b) j = j-1
end do
do j = 1, realrec
yy(j) = climall(1,j)%ye
do i = 1, recs(j)
dd(i,j) = climall(i,j)%day
mm(i,j) = climall(i,j)%mon
tx(i,j) = climall(i,j)%m1
tp(i,j) = climall(i,j)%m2
tn(i,j) = climall(i,j)%m3
prc(i,j) = climall(i,j)%m4
hm(i,j) = climall(i,j)%m5
prs(i,j) = climall(i,j)%m6
vp(i,j) = climall(i,j)%m7
sdu(i,j) = climall(i,j)%m8
bw(i,j) = climall(i,j)%m9
rd(i,j) = climall(i,j)%m10
wd(i,j) = climall(i,j)%m11
end do
end do
close(9)
deallocate (climall)
end subroutine read_dwd
!--------------------------------------------------------------
subroutine read_cli
implicit none
integer :: testtext, hp
character(11) :: text2
character(4) :: text
testtext=0
c = 'n'
j = 1
hp = 0
read(unit_cli,'(A)') text2
hp = index(text2,'.')
backspace(unit_cli)
do
IF(j > year) exit
select case(flag_climtyp)
case (1)
do i=1,366
if (hp .gt. 0) then
read(unit_cli,*,iostat=ios) text2,tp(i,j),hm(i,j),prc(i,j),prs(i,j),rd(i,j)
text = text2(1:2)
write (text,'(A)') text2(1:2)
read (text,*) dd(i,j)
write (text,'(A)') text2(4:5)
read (text,*) mm(i,j)
write (text,'(A)') text2(7:10)
read (text,*) yy(j)
else
read(unit_cli,*,iostat=ios) dd(i,j),mm(i,j),yy(j),tp(i,j),hm(i,j),prc(i,j),prs(i,j),rd(i,j)
endif ! hp
i_exit = i
if ((dd(i,j) .eq. 31) .and. (mm(i,j) .eq. 12)) then
recs(j) = i
write (*,*) 'Year ',j, yy(j)
realrec = j
if (j .eq. year) ios = -10
exit
endif
if (ios .ne. 0) exit
end do
case (2)
do i=1,366
read(unit_cli,*) dd(i,j),mm(i,j),yy(j),&
tp(i,j),hm(i,j),prc(i,j),prs(i,j),rd(i,j),wd(i,j)
i_exit = i
if ((dd(i,j) .eq. 31) .and. (mm(i,j) .eq. 12)) then
recs(j) = i
write (*,*) 'Year ',j, yy(j)
realrec = j
if (j .eq. year) ios = -10
exit
endif
if (ios .ne. 0) exit
end do
case (3)
do i=1,366
if (hp .gt. 0) then
read(unit_cli,*,iostat=ios) text2, &
tp(i,j),hm(i,j),prc(i,j),prs(i,j),rd(i,j),wd(i,j), tx(i,j),tn(i,j)
text = text2(1:2)
write (text,'(A)') text2(1:2)
read (text,*) dd(i,j)
write (text,'(A)') text2(4:5)
read (text,*) mm(i,j)
write (text,'(A)') text2(7:10)
read (text,*) yy(j)
else
read(unit_cli,*,iostat=ios) dd(i,j),mm(i,j),yy(j),&
tp(i,j),hm(i,j),prc(i,j),prs(i,j),rd(i,j),wd(i,j), tx(i,j),tn(i,j)
endif
i_exit = i
if ((dd(i,j) .eq. 31) .and. (mm(i,j) .eq. 12)) then
recs(j) = i
write (*,*) 'Year ',j, yy(j)
realrec = j
if (j .eq. year) ios = -10
exit
endif
if (ios .ne. 0) exit
end do
case (4) ! suffix 'txt'
if (j .eq. 1 .and. testtext.eq.0) then
read(unit_cli,*) text
testtext = 1
end if
do i=1,366
read(unit_cli,*,iostat=ios) dd(i,j),mm(i,j),yy(j),&
tx(i,j),tp(i,j),tn(i,j),prc(i,j),hm(i,j),prs(i,j),rd(i,j),wd(i,j)
i_exit = i
if ((dd(i,j) .eq. 31) .and. (mm(i,j) .eq. 12)) then
recs(j) = i
write (*,*) 'Year ',j, yy(j)
realrec = j
if (j .eq. year) ios = -10
exit
endif
if (ios .ne. 0) exit
end do
case (5 )
call read_dwd
exit
end select
IF (realrec .lt. year .and. ios .ne. 0 .and. c .eq. 'n') then
if (dd(i_exit,j) .gt. 0) i_exit = i_exit+1
if (i_exit .ge. 365) i_exit = 1
repflag = 1
if (.not.flag_mult8910) then
print *, ' >>>FORESEE message: Not enough data records in file'
print *, ' IOSTAT = ', ios
WRITE (*,'(A,I5)') ' >>>FORESEE message: Fill next values with same data from day number', i_exit
CALL error_mess(0,'read_cli: Not enough data records in meteorology file; number of complete years: ',real(realrec))
write(unit_err,'(A,I5)')' read_cli: Fill next values with same from first year, day: ',i_exit
write(unit_err,'(A,I5)')' read_cli: Fill next values with same data up to years: ',year
exit
endif
end if
if (ios .ne. 0) exit
if (yy(j) .ge. time_b) then
if ((j .eq. 1) .and. (yy(j) .gt. time_b)) then
CALL error_mess(0,'read_cli: No climate data in meteorology file for year ',real(time_b))
flag_end = 6
return
endif
j = j+1
endif
end do
end subroutine read_cli
!--------------------------------------------------------------
subroutine climfill
integer istart
istart = i_exit
if(istart.eq.0) istart =istart +1
do j=realrec+1,year
print *,'Year ',j
yy(j)=yy(j-realrec)
recs(j)=recs(j-realrec)
do i=istart,366
dd(i,j) = dd(i,j-realrec)
mm(i,j) = mm(i,j-realrec)
tp(i,j) = tp(i,j-realrec)
hm(i,j) = hm(i,j-realrec)
prc(i,j) = prc(i,j-realrec)
prs(i,j) = prs(i,j-realrec)
rd(i,j) = rd(i,j-realrec)
wd(i,j) = wd(i,j-realrec)
tx(i,j) = tx(i,j-realrec)
tn(i,j) = tn(i,j-realrec)
end do
end do
end subroutine climfill
END subroutine prepare_climate
!**************************************************************
SUBROUTINE store_para(hpara, simpara, parerr)
use data_simul
use data_out
use data_par
use data_species
use data_soil_cn
use data_stand
use data_tsort
implicit none
integer inum
real hpara, parerr
character(100):: simpara, hchar1
integer, external :: array_num
if (flag_trace) write (unit_trace, '(I4,I10,A)') iday, time_cur, ' store_para'
parerr = 0.
if (trim(simpara) .eq. 'year') then
year=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'time_b') then
time_b=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'kpatchsize') then
kpatchsize=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'dz') then
dz=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'ns_pro') then
ns_pro=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_mort') then
flag_mort=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_reg') then
flag_reg=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_stand') then
flag_stand=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_sveg') then
flag_sveg=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_mg') then
flag_mg=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_dis') then
flag_dis=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_light') then
flag_light=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_folhei') then
flag_folhei=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_volfunc') then
flag_volfunc=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_resp') then
flag_resp=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_limi') then
flag_limi=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_sign') then
flag_sign=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_decomp') then
flag_decomp=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_wred') then
flag_wred=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_wurz') then
flag_wurz=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_cond') then
flag_cond=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_int') then
flag_int=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_eva') then
flag_eva=hpara
parerr = 1.
return
endif
if ((trim(simpara) .eq. 'flag_co2') .or.(trim(simpara) .eq. 'flag_CO2')) then
flag_co2=hpara
parerr = 1.
return
endif
if (adjustl(trim(simpara)) .eq. 'flag_sort') then
flag_sort = hpara
parerr = 1.
return
endif
if (adjustl(trim(simpara)) .eq. 'flag_wpm') then
flag_wpm = hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'time_out') then
time_out=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_dayout') then
flag_dayout=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_cohout') then
flag_cohout=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'flag_sum') then
flag_sum=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'k_hum') then
k_hum=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'k_hum_r') then
k_hum_r=hpara
parerr = 1.
return
endif
if (trim(simpara) .eq. 'k_nit') then
k_nit=hpara
parerr = 1.
return
endif
if (adjustl(trim(simpara)) .eq. 'alfm') then
alfm = hpara
parerr = 1.
return
endif
if (adjustl(trim(simpara)) .eq. 'gpmax') then
gpmax = hpara
parerr = 1.
return
endif
if (adjustl(trim(simpara)) .eq. 'alfm') then
alfm = hpara
parerr = 1.
return
endif
! Species parameter
hchar1 = adjustl(simpara)
inum = array_num(hchar1)
if (hchar1(1:9) .eq. 'k_opm_fol') then
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%k_opm_fol = hpara
parerr = 1.
return
endif
endif
if (hchar1(1:9) .eq. 'k_opm_frt') then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%k_opm_frt = hpara
parerr = 1.
return
endif
endif
if (hchar1(1:9) .eq. 'k_syn_fol') then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%k_syn_fol = hpara
parerr = 1.
return
endif
endif
if (hchar1(1:9) .eq. 'k_syn_frt') then
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%k_syn_frt = hpara
parerr = 1.
return
endif
endif
if (hchar1(1:3) .eq. 'psf') then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%psf = hpara
parerr = 1.
return
endif
endif
if (hchar1(1:7) .eq. 'Phmodel') then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%Phmodel = hpara
parerr = 1.
return
endif
endif
if ((hchar1(1:4) .eq. 'pnus') .or. (hchar1(1:4) .eq. 'Pnus')) then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%pnus = hpara
parerr = 1.
return
endif
endif
if ((hchar1(1:4) .eq. 'RedN') .or. (hchar1(1:4) .eq. 'redn')) then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
svar(inum)%RedN = hpara
parerr = 1.
return
endif
endif
if (hchar1(1:4) .eq. 'prms') then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%prms = hpara
parerr = 1.
return
endif
endif
if (hchar1(1:4) .eq. 'prmr') then
inum = array_num(hchar1)
if (inum .gt. 0 .and. inum .le. nspecies) then
spar(inum)%prmr = hpara
parerr = 1.
return
endif
endif
END subroutine store_para
!**************************************************************
integer FUNCTION array_num(string)
! reads the field numbre out of an array and hands it back as integer
implicit none
integer ipos1, ipos2, inum
character (100) string
character (10) help, hchar
ipos1 = scan(string, '(' )
ipos2 = scan(string, ')' )
ipos1 = ipos1+1
ipos2 = ipos2-1
hchar = string(ipos1:ipos2)
write(help,'(A3)') hchar
read(help,*) inum
array_num = inum
end function array_num
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Stand initialisation *!
!* *!
!* CONTAINS SUBROUTINES : *!
!* PREPARE_STAND *!
!* internal subroutines: *!
!* SLA_INI *!
!* *!
!* CALC_INT *!
!* CALC_WEIBLA *!
!* READ_STAND (treeunit) *!
!* COH_INITIAL (coh) *!
!* CREATE_MISTLETOE *!
!* CREATE_SOILVEG *!
!* *!
!* CONTAiNS FUNCTIONS : *!
!* SURVAGE *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE prepare_stand
USE data_simul
USE data_site
USE data_stand
USE data_species
use data_climate
use data_par
USE data_manag
IMPLICIT NONE
CHARACTER :: a, with_storage
CHARACTER(30) :: text
CHARACTER(50) :: test_stand_id
INTEGER :: ios,treeunit
LOGICAL :: exs, lstin
INTEGER :: help_ip, test_vf
REAL :: test_patchsize, xx
REAL help_height_top ! auxiliary var. for setting mistletoe height at uppermost crown layer
INTEGER which_cohort
INTEGER nr_infect_trees
INTEGER nr_mist_per_tree
INTEGER i
TYPE(Coh_Obj), Pointer :: p ! pointer to cohort list
IF(site_nr==1) THEN
help_ip=site_nr
ELSE
help_ip=ip
END IF
pt = neu()
anz_coh=0
max_coh=0
ios = -1
nr_mist_per_tree=0
IF(flag_stand>0) then
exs = .false.
stand_id = standid(help_ip)
! reading stand information from treefile
inquire (File = treefile(help_ip), exist = exs)
IF((exs .eqv. .false.) .or. (flag_stand==2)) then
IF(exs .eqv. .false.) write(*,*) ' Stand initialization file not exists!'
IF(flag_stand==2) write(*,*)' Stand initialization with new file'
write(*,'(A)',advance='no') ' Creating new file (y/n): '
READ *, a
IF(a.eq.'y'.or. a.eq.'Y') CALL initia
! planting of small trees
if(flag_reg.eq.20) then
call planting
flag_reg=100
end if
flag_stand=1
exs=.true.
ENDIF
! read values from treefile
IF (exs.eqv. .true.) then
treeunit=getunit()
OPEN(treeunit,file=treefile(help_ip),action='read', pad='YES') !!!! NSC implementation for ini-file
READ(treeunit,'(A1,2X,I1,1F12.0)',iostat=ios)with_storage
backspace treeunit
if(with_storage .eq. 'C') then !flag_dis .eq. 2 .and.
READ(treeunit,'(A1,2X,I1,1F12.0)',iostat=ios)with_storage,test_vf, test_patchsize
call read_stand_with_nsc (treeunit)
CLOSE(treeunit)
kpatchsize = test_patchsize
anz_coh = max_coh
coh_ident_max = anz_coh
else
READ(treeunit,'(I1,F12.0)',iostat=ios) test_vf, test_patchsize
! write(8888,*) ip, test_vf, flag_volfunc
if(flag_multi.ne.4 .or. (flag_multi.eq.4.and.ip.eq.1) .or. (flag_multi.eq.8.and.ip.eq.1)) then
IF(test_vf.NE.flag_volfunc) THEN
if (.not.flag_mult8910) then
CALL error_mess(time,"volume function in sim-file and the one used for initialisation do not match",REAL(flag_volfunc))
CALL error_mess(time,"volume function (flag_volfunc) is set to",REAL(test_vf))
endif
flag_volfunc = test_vf
ENDIF
endif
IF(test_patchsize .GT. 0.) THEN
lmulti = .FALSE.
IF(test_patchsize.NE.kpatchsize) THEN
if (.not.flag_mult8910) then
CALL error_mess(time,"patch size in sim-file and the one used for initialisation do not match",kpatchsize)
CALL error_mess(time,"value in ini-file",test_patchsize)
CALL error_mess(time,"value in sim-file",kpatchsize)
endif
kpatchsize = test_patchsize
ENDIF
ELSE
lmulti = .TRUE.
ENDIF
do
READ(treeunit,'(A)',iostat=ios) a
IF (a .ne. '!') exit
end do
backspace treeunit
! generation of mistletoe cohort; mistletoe cohort need to be generated BEFORE tree cohorts as otherwise the light model becomes messy
if (flag_dis.eq.1) then
do i= 1, dis_row_nr
if (dis_type(i) .eq. 'M') then
if (flag_mistle.eq.0) then !set #of mist. only once
print *,"!! Note, implementation of mistletoe is restricted to trees of Pinus sylvestris"
nr_mist_per_tree = dis_rel(i)
flag_mistle=1 ! flag indicating mistletoes
call create_mistletoe ! initialisation of Mistletoe
endif
anz_coh = max_coh
endif
enddo
endif
lstin = .TRUE.
if(flag_multi.eq.4 .or. flag_multi.eq.8) stand_id = standid(help_ip)
do while (lstin)
IF (lmulti) THEN
read(treeunit,*,iostat=ios) test_stand_id, test_patchsize,text
IF (ios .lt. 0) then
if (.not.flag_mult8910) then
CALL error_mess(time,"stand identificator not found"//adjustl(stand_id)//"ip No.",real(help_ip))
write (*,*) '*** PREPSTAND: program aborted'
write (*,*) ' stand identificator',stand_id,' not found'
write (*,'(A, 2x,A)') ' in initialisation file',treefile(help_ip)
endif
flag_end = 2
return
ENDIF
IF (test_stand_id .ne. stand_id) THEN
read (treeunit,*) xx
do while (xx .gt. -90.0)
read (treeunit,*) xx
enddo ! xx
ELSE
lstin = .FALSE.
kpatchsize = test_patchsize
call read_stand (treeunit)
END IF ! stand_id
ELSE
lstin = .FALSE.
call read_stand (treeunit)
END IF ! lmulti
end do ! lstin
CLOSE(treeunit)
anz_coh = max_coh
coh_ident_max = anz_coh
endif !w/o storage
ENDIF !exs.eqv. .true.
END IF !if stand >0
!if treefile not exists and not created:
IF(ios .ne. 0 .or. exs .eqv. .false.)THEN
if (.not.flag_mult8910) PRINT *,' >>> No Stand Initialization possible '
flag_stand=0
END IF
! Setting of height and number of mistletoe
if (flag_mistle.ne.0) then
help_height_top=1.
p=>pt%first
DO WHILE (ASSOCIATED(p))
if (p%coh%species.eq.3 .AND. p%coh%height.gt.help_height_top) then !only on Pinus
help_height_top=p%coh%height
which_cohort=p%coh%ident
nr_infect_trees=p%coh%nTreeA
end if
p=>p%next
end do
p=>pt%first
DO WHILE (ASSOCIATED(p))
if (p%coh%species.eq.nspec_tree+2) then
p%coh%height = help_height_top !upper crown
p%coh%x_hbole = p%coh%height-50. !lower crown
p%coh%nTreeA = nr_infect_trees*nr_mist_per_tree !number of mistletoes
end if
if (p%coh%ident.eq.which_cohort) then !mark uppermost tree cohort with flag mistletoe
p%coh%mistletoe=1
end if
p=>p%next
end do
end if ! end set height/number of mistletoe
! Soil Vegetation
if (flag_sveg .gt. 0) then
call create_soilveg ! initialisation of ground vegetation
anz_coh = max_coh
endif
IF(flag_stand>0) CALL sla_ini
IF(flag_stand>0) CALL stand_bal_spec
CALL calc_int
CALL calc_weibla
if(flag_mg.ne.33) call overstorey
contains
SUBROUTINE sla_ini
USE data_stand
USE data_species
IMPLICIT NONE
TYPE(Coh_Obj), Pointer :: p ! pointer to cohort list
p => pt%first
DO WHILE (ASSOCIATED(p))
ns=p%coh%species
p%coh%med_sla=spar(ns)%psla_min+spar(ns)%psla_a*0.5
p%coh%t_leaf = p%coh%med_sla * p%coh%x_fol
p =>p%next
END DO
end subroutine sla_ini
end subroutine prepare_stand
!*************************************************************************
subroutine calc_int ! calculation of intrinsic mortality rate
use data_species
implicit none
INTEGER j
do j=1,nspecies
spar(j)%intr = -log(0.01)/spar(j)%max_age
end do
end subroutine calc_int
!*************************************************************************
subroutine calc_weibla
! calculation of parameter lamda for Weibull-distribution of sress mortality
use data_species
implicit none
INTEGER j
REAL survage
do j=1,nspecies
spar(j)%weibla = -log(0.01)/(survage(j)**weibal)
end do
end subroutine calc_weibla
!*************************************************************************
REAL function survage(ispec)
! calculation of survival time per species depending on shade tolerance class stol
use data_species
implicit none
INTEGER :: ispec
IF(spar(ispec)%stol.eq.1) survage=20.
IF (spar(ispec)%stol.eq.2) survage=40.
IF (spar(ispec)%stol.eq.3) survage=60.
IF (spar(ispec)%stol.eq.4) survage=80.
IF (spar(ispec)%stol.eq.5) survage=100.
end function
!*************************************************************************
SUBROUTINE read_stand (treeunit)
! Read of stand initialisation
USE data_par
USE data_simul
USE data_species
USE data_stand
IMPLICIT NONE
TYPE(cohort) :: coh_ini
REAL :: hdquo ! help variable for stress initilization
INTEGER :: ios,treeunit, loc, i
logical :: treegroup_decid
integer, dimension(5) :: decidous = (/1, 4, 5, 8, 11/)
do
call coh_initial (coh_ini)
READ(treeunit,'(5f12.5,2f10.0,i7, f10.0,i7, f9.5, f12.5)',iostat=ios) coh_ini%x_fol, coh_ini%x_frt, coh_ini%x_sap, coh_ini%x_hrt, &
coh_ini%x_Ahb, coh_ini%height, coh_ini%x_hbole, coh_ini%x_age, &
coh_ini%nTreeA,coh_ini%species, coh_ini%dcrb, coh_ini%diam
IF(ios<0 .or. coh_ini%x_fol .lt. -90.0) exit
coh_ini%nTreeD = 0.
coh_ini%x_crt = (coh_ini%x_sap + coh_ini%x_hrt) * spar(coh_ini%species)%alphac*spar(coh_ini%species)%cr_frac
coh_ini%x_tb = (coh_ini%x_sap + coh_ini%x_hrt) * spar(coh_ini%species)%alphac*(1.-spar(coh_ini%species)%cr_frac)
!NSC Speicher initialisieren
!hier neue version auslesen
treegroup_decid = .False.
do i = 1, 5
if (decidous(i) .eq. coh_ini%species) then
treegroup_decid = .True.
exit
endif
end do
If (treegroup_decid .eq. .True.) then
coh_ini%x_nsc_sap = coh_ini%x_sap * decid_sap_allo * cpart !*0.5 umrechnung von kg DW zu kg C
coh_ini%x_nsc_sap_max = coh_ini%x_nsc_sap
coh_ini%x_nsc_tb = coh_ini%x_tb * decid_tb_allo * cpart
coh_ini%x_nsc_tb_max = coh_ini%x_nsc_tb
coh_ini%x_nsc_crt = coh_ini%x_crt * decid_crt_allo * cpart
coh_ini%x_nsc_crt_max = coh_ini%x_nsc_crt
endif
If (treegroup_decid .eq. .False.) then
coh_ini%x_nsc_sap = coh_ini%x_sap * conif_sap_allo * cpart
coh_ini%x_nsc_sap_max = coh_ini%x_nsc_sap
coh_ini%x_nsc_tb = coh_ini%x_tb * conif_tb_allo * cpart
coh_ini%x_nsc_tb_max = coh_ini%x_nsc_tb
coh_ini%x_nsc_crt = coh_ini%x_crt * conif_crt_allo * cpart
coh_ini%x_nsc_crt_max = coh_ini%x_nsc_crt
endif
coh_ini%ident = max_coh + 1
coh_ini%Fmax = coh_ini%x_fol
coh_ini%x_health = 0
coh_ini%x_hsap = 0.
ns = coh_ini%species
coh_ini%N_fol=coh_ini%x_fol*spar(coh_ini%species)%ncon_fol ! kg * mg/g --> g
if (coh_ini%dcrb.eq.0..and.coh_ini%diam.eq.0..and.coh_ini%height.gt.h_sapini) then
CALL CALC_DBH(coh_ini%x_hbole,coh_ini%height,coh_ini%x_sap,coh_ini%x_hrt,coh_ini%x_Ahb,coh_ini%Ahc,coh_ini%ident,coh_ini%diam,coh_ini%dcrb,coh_ini%x_hsap,coh_ini%asapw)
else
coh_ini%x_hsap = (2*coh_ini%x_hbole + coh_ini%height)/3.
coh_ini%Asapw = coh_ini%x_sap/(spar(coh_ini%species)%prhos*coh_ini%x_hsap)
end if
! Stress calculation
IF (coh_ini%diam.ne. 0.) THEN
hdquo = coh_ini%height/ (coh_ini%diam*100)
IF (hdquo.gt. 1. .and. (coh_ini%x_age .gt. 10..and. coh_ini%x_age .lt.50) ) THEN
coh_ini%x_stress = coh_ini%x_age/2
ELSE IF ( hdquo.gt. 1. .and. coh_ini%x_age .gt.50) THEN
coh_ini%x_stress = coh_ini%x_age*3./7.
ELSE
coh_ini%x_stress = 0.
END IF
ELSE
coh_ini%x_stress = 0.
END IF ! coh_ini
coh_ini%x_stress = 0.
coh_ini%nta = coh_ini%nTreeA
IF (.not. associated(pt%first)) THEN
max_coh = 0
allocate(pt%first)
pt%first%coh = coh_ini
nullify(pt%first%next)
ELSE
allocate(zeig)
zeig%coh = coh_ini
zeig%next => pt%first
pt%first => zeig
END IF
max_coh = max_coh + 1
enddo
END SUBROUTINE read_stand
!*************************************************************************
SUBROUTINE read_stand_with_nsc (treeunit)
! Read of stand initialisation
USE data_par
USE data_simul
USE data_species
USE data_stand
IMPLICIT NONE
TYPE(cohort) :: coh_ini
REAL :: hdquo ! help variable for stress initilization
INTEGER :: ios,treeunit, loc, i
logical :: treegroup_decid
integer, dimension(5) :: decidous = (/1, 4, 5, 8, 11/)
character :: a
do
READ(treeunit,'(A)',iostat=ios) a
IF (a .ne. '!') exit
end do
backspace treeunit
do
call coh_initial (coh_ini)
! READ(treeunit,'(5f12.5,2f10.0,i7, f7.0,i7, 2f12.5)',iostat=ios) coh_ini%x_fol, coh_ini%x_frt, coh_ini%x_sap, coh_ini%x_hrt, &
READ(treeunit,'(5f12.5,2f10.0,i7,f7.0,i7, 5f12.5)',iostat=ios) coh_ini%x_fol, coh_ini%x_frt, coh_ini%x_sap, coh_ini%x_hrt, &
coh_ini%x_Ahb, coh_ini%height, coh_ini%x_hbole, coh_ini%x_age, &
coh_ini%nTreeA,coh_ini%species, coh_ini%dcrb, coh_ini%diam, coh_ini%x_nsc_tb, coh_ini%x_nsc_crt, coh_ini%x_nsc_sap
IF(ios<0 .or. coh_ini%x_fol .lt. -90.0) exit
coh_ini%nTreeD = 0.
coh_ini%x_crt = (coh_ini%x_sap + coh_ini%x_hrt) * spar(coh_ini%species)%alphac*spar(coh_ini%species)%cr_frac
coh_ini%x_tb = (coh_ini%x_sap + coh_ini%x_hrt) * spar(coh_ini%species)%alphac*(1.-spar(coh_ini%species)%cr_frac)
!hier nur den NSC Max-Speicher initialisieren
!hier neue version auslesen
treegroup_decid = .False.
do i = 1, 5
if (decidous(i) .eq. coh_ini%species) then
treegroup_decid = .True.
exit
endif
end do
If (treegroup_decid .eq. .True.) then
coh_ini%x_nsc_sap_max = coh_ini%x_sap * decid_sap_allo * cpart !*0.5 umrechnung von kg DW zu kg C
coh_ini%x_nsc_tb_max = coh_ini%x_tb * decid_tb_allo * cpart
coh_ini%x_nsc_crt_max = coh_ini%x_crt * decid_crt_allo * cpart
endif
If (treegroup_decid .eq. .False.) then
coh_ini%x_nsc_sap_max = coh_ini%x_sap * conif_sap_allo * cpart
coh_ini%x_nsc_tb_max = coh_ini%x_tb * conif_tb_allo * cpart
coh_ini%x_nsc_crt_max = coh_ini%x_crt * conif_crt_allo * cpart
endif
! IF(coh_ini%species==3.and.coh_ini%height.le.900) then
! coh_ini%x_stress =6
! ELSE IF(coh_ini%species==1.and.coh_ini%height.le.2500) then
! coh_ini%x_stress =25
! ELSE
! coh_ini%x_stress = 0
! ENDIF
coh_ini%ident = max_coh + 1
coh_ini%Fmax = coh_ini%x_fol
coh_ini%x_health = 0
coh_ini%x_hsap = 0.
ns = coh_ini%species
coh_ini%N_fol=coh_ini%x_fol*spar(coh_ini%species)%ncon_fol ! kg * mg/g --> g
! calculate diameter at breast height and pipe length by call of subroutine in partitio
if (coh_ini%dcrb.eq.0..and.coh_ini%diam.eq.0..and.coh_ini%height.gt.h_sapini) then
! if (coh_ini%dcrb.eq.0..and.coh_ini%diam.eq.0..and.coh_ini%height.gt.137.) then
CALL CALC_DBH(coh_ini%x_hbole,coh_ini%height,coh_ini%x_sap,coh_ini%x_hrt,coh_ini%x_Ahb,coh_ini%Ahc,coh_ini%ident,coh_ini%diam,coh_ini%dcrb,coh_ini%x_hsap,coh_ini%asapw)
else
coh_ini%x_hsap = (2*coh_ini%x_hbole + coh_ini%height)/3.
coh_ini%Asapw = coh_ini%x_sap/(spar(coh_ini%species)%prhos*coh_ini%x_hsap)
end if
! Stress calculation
IF (coh_ini%diam.ne. 0.) THEN
hdquo = coh_ini%height/ (coh_ini%diam*100)
IF (hdquo.gt. 1. .and. (coh_ini%x_age .gt. 10..and. coh_ini%x_age .lt.50) ) THEN
coh_ini%x_stress = coh_ini%x_age/2
ELSE IF ( hdquo.gt. 1. .and. coh_ini%x_age .gt.50) THEN
coh_ini%x_stress = coh_ini%x_age*3./7.
ELSE
coh_ini%x_stress = 0.
END IF
ELSE
coh_ini%x_stress = 0.
END IF ! coh_ini
! provisorisch stress auf Null setzen
coh_ini%x_stress = 0.
coh_ini%nta = coh_ini%nTreeA
IF (.not. associated(pt%first)) THEN
max_coh = 0
allocate(pt%first)
pt%first%coh = coh_ini
nullify(pt%first%next)
ELSE
allocate(zeig)
zeig%coh = coh_ini
zeig%next => pt%first
pt%first => zeig
END IF
max_coh = max_coh + 1
enddo
END SUBROUTINE read_stand_with_nsc
!*************************************************************************
SUBROUTINE coh_initial (coh_ini)
USE data_simul
USE data_soil
USE data_stand
USE data_species
IMPLICIT NONE
TYPE(cohort) :: coh_ini
coh_ini%nTreeA = 0.
coh_ini%nTreeD = 0.
coh_ini%nTreeM = 0.
coh_ini%nTreet = 0.
coh_ini%nta = 0.
coh_ini%mistletoe = 0
coh_ini%x_age = 0.
coh_ini%x_fol = 0.
coh_ini%x_sap = 0.
coh_ini%x_frt = 0.
coh_ini%x_hrt = 0.
coh_ini%x_crt = 0.
coh_ini%x_tb = 0.
coh_ini%x_hsap = 0.
coh_ini%x_hbole= 0.
coh_ini%x_Ahb = 0.
coh_ini%x_stress = 0
coh_ini%x_health = 0
coh_ini%bes = 0.
coh_ini%med_sla = 0.
coh_ini%Fmax = 0
coh_ini%totBio = 0.
coh_ini%Dbio = 0.
coh_ini%height = 0.
coh_ini%deltaB = 0.
coh_ini%dcrb = 0.
coh_ini%diam = 0.
coh_ini%assi = 0.
coh_ini%LUE = 0.
coh_ini%resp = 0.
coh_ini%netAss = 0.
coh_ini%NPP = 0.
coh_ini%weekNPP = 0.
coh_ini%NPPpool = 0.
coh_ini%t_Leaf = 0.
coh_ini%geff = 0.
coh_ini%Asapw = 0.
coh_ini%crown_area = 0.
coh_ini%BG = 0.
coh_ini%leafArea = 0.
coh_ini%sleafArea = 0.
coh_ini%FPAR = 0.
coh_ini%antFPAR = 0.
coh_ini%Irel = 0.
coh_ini%totFPAR = 0
coh_ini%IrelCan = 0
coh_ini%botLayer = 0
coh_ini%topLayer = 0
coh_ini%survp = 0.
coh_ini%rel_fol = 0.
coh_ini%gfol = 0.
coh_ini%gfrt = 0.
coh_ini%gsap = 0.
coh_ini%sfol = 0.
coh_ini%sfrt = 0.
coh_ini%ssap = 0.
coh_ini%grossass = 0.
coh_ini%maintres = 0.
coh_ini%respsap = 0.
coh_ini%respfrt = 0.
coh_ini%respbr = 0.
coh_ini%height_ini = 0.
coh_ini%ca_ini = 0.
coh_ini%rel_dbh_cl = 0
coh_ini%underst = 0
coh_ini%fol_inc = 0.
coh_ini%fol_inc_old = 0.
coh_ini%bio_inc = 0.
coh_ini%stem_inc = 0.
coh_ini%frt_inc = 0.
coh_ini%notViable = .FALSE.
coh_ini%intcap = 0.
coh_ini%prel = 0.
coh_ini%interc = 0.
coh_ini%prelCan = 0.
coh_ini%interc_st= 0.
coh_ini%aev_i = 0.
coh_ini%demand = 0.
coh_ini%supply = 0.
coh_ini%watuptc = 0.
coh_ini%gp = 0.
coh_ini%drIndd = 0.
coh_ini%drIndPS = 0.
coh_ini%drIndAl = 0.
coh_ini%nDaysGr = 0
coh_ini%isGrSDay = .false.
coh_ini%litC_fol = 0.
coh_ini%litC_fold = 0.
coh_ini%litN_fol = 0.
coh_ini%litN_fold = 0.
coh_ini%litC_frt = 0.
coh_ini%litC_frtd = 0.
coh_ini%litN_frt = 0.
coh_ini%litN_frtd = 0.
coh_ini%litC_stem = 0.
coh_ini%litN_stem = 0.
coh_ini%litC_tb = 0.
coh_ini%litC_crt = 0.
coh_ini%litC_tbcd = 0.
coh_ini%litN_tb = 0.
coh_ini%litN_crt = 0.
coh_ini%litN_tbcd = 0.
coh_ini%Nuptc_c = 0.
coh_ini%Nuptc_d = 0.
coh_ini%Ndemc_d = 0.
coh_ini%RedNc = 1.
coh_ini%N_pool = 0.
coh_ini%N_fol = 0.
coh_ini%wat_mg = 0. ! soley forflag_wred=9
coh_ini%nroot = 0
coh_ini%shelter = 0
coh_ini%day_bb = 0
coh_ini%x_nsc_sap = 0.
coh_ini%x_nsc_tb = 0.
coh_ini%x_nsc_crt = 0.
coh_ini%x_nsc_sap_max = 0.
coh_ini%x_nsc_tb_max = 0.
coh_ini%x_nsc_crt_max = 0.
if (coh_ini%species .ne. nspec_tree+2) then ! no root allocation for mistletoe
allocate (coh_ini%frtrel(nlay))
allocate (coh_ini%frtrelc(nlay))
if (flag_wred .eq. 9) then
allocate (coh_ini%rld(nlay))
coh_ini%rld = 0.
endif
allocate (coh_ini%rooteff(nlay))
coh_ini%frtrel = 0.
coh_ini%rooteff = 0.
end if ! end exclude mistletoe
END SUBROUTINE coh_initial
!*************************************************************************
SUBROUTINE create_mistletoe
USE data_plant
USE data_simul
USE data_species
USE data_stand
USE data_climate
USE data_soil
USE data_species
USE data_par
IMPLICIT NONE
TYPE(cohort) :: coh_ini
real :: help_height_top, help_height_bot
REAL, EXTERNAL :: fi_lf, dfi_lf, ddfi_lf
! initialising of cohort of mistletoe
call coh_initial (coh_ini)
! set mistletoe here to 20 m height, will be changed after, when cohorts of trees will be initialised
help_height_top=2000
help_height_bot=help_height_top-50
! following values are from sample calcul. of 10 year old V.austr. from Pfiz 2010
coh_ini%ident = max_coh + 1
coh_ini%species = nspec_tree+2 ! Species = species after all tree species and ground veg.
coh_ini%nTreeA = 1 ! #of mistletoes, to be read-in in management file
coh_ini%nTreeD = 0 ! dead trees
coh_ini%nta = coh_ini%nTreeA ! alive trees internal calc.
coh_ini%x_age = 10
coh_ini%x_fol = mistletoe_x_fol ! fol biomass per tree [kg DW/tree], 1 Viscum (10years) see Pfiz 2010
coh_ini%x_sap = 0. ! set near-zero for partitioning
coh_ini%x_frt = 0. ! set near-zero for partitioning
coh_ini%height = help_height_top ! highest_layer ! highest_layer of all cohorts
coh_ini%x_hbole = help_height_bot !
coh_ini%med_sla = 0. ! average cohort specific leaf area [m2/kg] is being calculated internal
coh_ini%Fmax = 0 ! anual change of leaf biomass, for now: now change
coh_ini%crown_area = 0.0189 ! max. projected crown area (m2) per individuum, calculated from Pfiz 2010
coh_ini%t_leaf = coh_ini%med_sla* coh_ini%x_fol !leaf area per tree [m2] !
coh_ini%day_bb = 1 ! evergreen
! no partitioning of NPP into stem/leaf etc.
! no root allocation
allocate(zeig)
zeig%coh = coh_ini
zeig%next => pt%first
pt%first => zeig
max_coh = max_coh + 1
END SUBROUTINE create_mistletoe
!*************************************************************************
SUBROUTINE create_soilveg
! Read of stand initialisation
USE data_plant
USE data_simul
USE data_species
USE data_stand
USE data_climate
USE data_soil
IMPLICIT NONE
TYPE(cohort) :: coh_ini
real :: lai_help, irel_help, FRsum
integer :: age_stand, nr, j
integer :: flag_SV_allo, rnum
real :: troot2
REAL, EXTERNAL :: fi_lf, dfi_lf, ddfi_lf
age_stand = 0
lai_help = 0.
irel_help = 0.
call wclas(waldtyp)
zeig=>pt%first
DO WHILE (ASSOCIATED(zeig))
ns = zeig%coh%species
lai_help = lai_help + zeig%coh%ntreea*zeig%coh%x_fol* spar(ns)%psla_min
age_stand = MAX(zeig%coh%x_age,age_stand)
zeig=>zeig%next
end do
IF((flag_stand==0 .or. age_stand .le. 5) .AND. flag_sveg ==2) THEN
NPP_est = 10.
ELSE if(age_stand.le.5) then
if(ns.eq.4) then
NPP_est = 5
else
NPP_est = 10.
end if
ELSE if(flag_reg.ne.0) then
NPP_est = 10
ELSE
lai_help = lai_help/kpatchsize
irel_help = exp(-0.5*lai_help)
if( svar(nspec_tree+1)%RedN .lt.0.) then
NPP_est = irel_help * med_rad1 * 365./100. *0.5
else
NPP_est = irel_help * med_rad1 * 365./100. *0.5 * svar(nspec_tree+1)%RedN
end if
ENDIF
call coh_initial (coh_ini)
coh_ini%species = nspec_tree+1 ! numbre of species determined automatically
ns = coh_ini%species
flag_SV_allo=1
IF(flag_SV_allo==0) THEN
! the parameters pdiam in the species.par file are used for allocation fractions
coh_ini%x_sap = spar(ns)%pdiam3 * NPP_est/1000.*kpatchsize
coh_ini%x_fol = spar(ns)%pdiam1 * NPP_est/1000.*kpatchsize
coh_ini%x_frt = spar(ns)%pdiam2 * NPP_est/1000.*kpatchsize
ELSE
FRsum=0.8*NPP_est/1000. ! start value as fraction of NPP in kg DM m-2
CALL newt (FRsum, fi_lf, dfi_lf, ddfi_lf, 0.001, 100, rnum)
IF(rnum==-1) THEN
if (.not.flag_mult8910) CALL error_mess(time,'no solution found for allocation for groundvegetation cohort: ',real(ns))
coh_ini%x_sap = spar(ns)%pdiam3 * NPP_est/1000.*kpatchsize
coh_ini%x_fol = spar(ns)%pdiam1 * NPP_est/1000.*kpatchsize
coh_ini%x_frt = spar(ns)%pdiam2 * NPP_est/1000.*kpatchsize
ELSE
coh_ini%x_sap = (ksi*FRsum**kappa)*kpatchsize
coh_ini%x_fol = (FRsum/2.)*kpatchsize
coh_ini%x_frt = (FRsum/2.)*kpatchsize
ENDIF
ENDIF
coh_ini%height = 60.
coh_ini%x_age = 1
coh_ini%nTreeA = 1
coh_ini%ident = max_coh + 1
coh_ini%Fmax = coh_ini%x_fol
coh_ini%med_sla = spar(coh_ini%species)%psla_min + spar(coh_ini%species)%psla_a*irel_help
coh_ini%t_leaf = coh_ini%med_sla* coh_ini%x_fol ! [m2]
coh_ini%nta = coh_ini%nTreeA
coh_ini%ca_ini = kpatchsize
coh_ini%day_bb = 100 ! assumption budding on 8.April
! root allocation
IF (.not. associated(pt%first)) THEN
max_coh = 0
allocate(pt%first)
pt%first%coh = coh_ini
nullify(pt%first%next)
call root_depth (1, pt%first%coh%species, pt%first%coh%x_age, pt%first%coh%height, pt%first%coh%x_frt, pt%first%coh%x_crt, nr, troot2, pt%first%coh%x_rdpt, pt%first%coh%nroot)
pt%first%coh%nroot = nr
do j=1,nr
pt%first%coh%rooteff = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
pt%first%coh%rooteff = 0. ! layers with no roots
enddo
ELSE
allocate(zeig)
zeig%coh = coh_ini
zeig%next => pt%first
pt%first => zeig
call root_depth (1, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig%coh%nroot = nr
do j=1,nr
zeig%coh%rooteff = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
zeig%coh%rooteff = 0. ! layers with no roots
enddo
END IF
max_coh = max_coh + 1
END SUBROUTINE create_soilveg
!*************************************************************************
!***************************!
! FUNCTION fi_lf *!
!***************************!
REAL FUNCTION fi_lf(x)
USE data_stand
USE data_plant
USE data_species
REAL :: x
fi_lf = spar(nspec_tree+1)%pss*ksi*x**kappa + (spar(nspec_tree+1)%psf+spar(nspec_tree+1)%psr)/2.*x - NPP_est/1000.
END ! FUNCTION fi_lf
!***************************!
! FUNCTION dfi_lf *!
!***************************!
REAL FUNCTION dfi_lf(x)
USE data_stand
USE data_plant
USE data_species
REAL :: x
dfi_lf = spar(nspec_tree+1)%pss*ksi*kappa*x**(kappa-1.) + (spar(nspec_tree+1)%psf+spar(nspec_tree+1)%psr)/2.
END ! FUNCTION dfi_lf
!***************************!
! FUNCTION ddfi_lf *!
!***************************!
REAL FUNCTION ddfi_lf(x)
USE data_stand
USE data_plant
USE data_species
REAL :: x
ddfi_lf = spar(nspec_tree+1)%pss*ksi*kappa*(kappa-1.)*x**(kappa-2.)
END ! FUNCTION ddfi_lf
!*****************************************************************!
!* *!
!* 4C (FORSEE) Simulation Model *!
!* *!
!* *!
!* Function: *!
!* Algorithm as described in APPL. STATIST. 31:2 (1982) *!
!* The function returns a pseudo-random number uniformly *!
!* distributed between 0 and 1. *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
REAL FUNCTION RAND()
INTEGER IE,IM,IG
! IE, IM and IG should be set to integer values between
! 1 and 30000 before the first entry.
COMMON /RANDOM/ IE,IM,IG
IE=171*MOD(IE,177)-2* (IE/177)
IM=172*MOD(IM,176)-35*(IM/176)
IG=170*MOD(IG,178)-63*(IG/178)
IF (IE.LT.0)IE=IE+30269
IF (IM.LT.0)IM=IM+30307
IF (IG.LT.0)IG=IG+30323
RAND = AMOD(FLOAT(IE) /30269.0+FLOAT(IM)/30307.0+ FLOAT(IG) /30323.0,1.0)
RETURN
END function rand
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* readspec: Read species parameters from file *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE readspec
! input of species data from file
use data_par
use data_simul
use data_species
use data_stand
use data_soil_cn
use data_soil
implicit none
integer i,ios,nowunit
character text
logical ex
nowunit=getunit()
if (.not.flag_mult8910) then
print *,' '
print *,' >>>foresee message: now reading species parameter file...'
endif
do
call testfile(specfile(ip),ex)
if (.not.flag_mult8910) print *,' '
if(ex .eqv. .false.) cycle
exit
end do
open(nowunit, FILE=trim(specfile(ip)), ACTION="READ")
do
read(nowunit,'(A)') text
if (text .ne. '!') then
exit
end if
end do
backspace nowunit
read(nowunit,*) text, nspecies
read(nowunit,*) text, nspec_tree
if(.not.allocated(spar)) allocate(spar(nspecies))
if(.not.allocated(svar)) allocate(svar(nspecies))
if(.not.allocated(nrspec)) allocate(nrspec(nspecies))
nrspec = 0
! read intermediate lines
do
read(nowunit,'(A)') text
if (text .ne. '!') then
exit
end if
end do
backspace nowunit
do i=1,nspecies
read(nowunit,*) text,spar(i)%species_name
if (text .ne. '!') then
svar(i)%daybb = 0
svar(i)%ext_daybb = 0
svar(i)%sum_nTreeA = 0
svar(i)%anz_coh = 0
svar(i)%RedN = -99.0
svar(i)%RedNm = 0.0
svar(i)%med_diam = 0.0
svar(i)%dom_height = 0.0
svar(i)%drIndAl = 0.0
svar(i)%sumNPP = 0.0
svar(i)%sum_bio = 0.0
svar(i)%sum_lai = 0.0
svar(i)%act_sum_lai= 0.0
svar(i)%fol = 0.0
svar(i)%hrt = 0.0
svar(i)%sap = 0.0
svar(i)%frt = 0.0
svar(i)%totsteminc = 0.0
svar(i)%totstem_m3 = 0.0
svar(i)%sumvsab = 0.0
svar(i)%sumvsdead = 0.0
svar(i)%sumvsdead_m3 = 0.
svar(i)%crown_area = 0.0
svar(i)%Ndem = 0.0
svar(i)%basal_area = 0.0
svar(i)%sumvsab = 0.0
else
write (*,*) '! *** not enough species in ', specfile(ip), (i-1),' of ', nspecies
call errorfile (specfile(ip), 0, nowunit)
call error_mess(time, 'not enough species in '//specfile(ip), real(i-1))
exit
endif
enddo
! read intermediate lines
read(nowunit,'(A)') text
if (text .ne. '!') then
do
read(nowunit,'(A)') text
if (text .eq. '!') then
do
read(nowunit,'(A)') text
if (text .ne. '!') then
exit
end if
end do
exit
end if
end do
else
do
read(nowunit,'(A)') text
if (text .ne. '!') then
exit
end if
end do
endif
backspace nowunit
read(nowunit,*) text,(spar(i)%species_short_name,i=1,nspecies) ! read abbreviated names
read(nowunit,*) text,(spar(i)%max_age,i=1,nspecies)
read(nowunit,*) text,(spar(i)%yrec,i=1,nspecies)
read(nowunit,*) text,(spar(i)%stol,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pfext, i=1,nspecies)
read(nowunit,*) text,(spar(i)%sigman,i=1,nspecies)
read(nowunit,*) text,(spar(i)%respcoeff,i=1,nspecies)
read(nowunit,*) text,(spar(i)%prg,i=1,nspecies)
read(nowunit,*) text,(spar(i)%prms,i=1,nspecies)
read(nowunit,*) text,(spar(i)%prmr,i=1,nspecies)
read(nowunit,*) text,(spar(i)%psf,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pss,i=1,nspecies)
read(nowunit,*) text,(spar(i)%psr,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pcnr,i=1,nspecies)
read(nowunit,*) text,(spar(i)%ncon_fol,i=1,nspecies)
read(nowunit,*) text,(spar(i)%ncon_frt,i=1,nspecies)
read(nowunit,*) text,(spar(i)%ncon_crt,i=1,nspecies)
read(nowunit,*) text,(spar(i)%ncon_tbc,i=1,nspecies)
read(nowunit,*) text,(spar(i)%ncon_stem,i=1,nspecies)
read(nowunit,*) text,(spar(i)%reallo_fol,i=1,nspecies)
read(nowunit,*) text,(spar(i)%reallo_frt,i=1,nspecies)
read(nowunit,*) text,(spar(i)%alphac,i=1,nspecies)
read(nowunit,*) text,(spar(i)%cr_frac,i=1,nspecies)
read(nowunit,*) text,(spar(i)%prhos,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pnus,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pha,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pha_coeff1,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pha_coeff2,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pha_v1,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pha_v2,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pha_v3,i=1,nspecies)
read(nowunit,*) text,(spar(i)%crown_a,i=1,nspecies)
read(nowunit,*) text,(spar(i)%crown_b,i=1,nspecies)
read(nowunit,*) text,(spar(i)%crown_c,i=1,nspecies)
read(nowunit,*) text,(spar(i)%psla_min,i=1,nspecies)
read(nowunit,*) text,(spar(i)%psla_a,i=1,nspecies)
read(nowunit,*) text,(spar(i)%phic,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pnc,i=1,nspecies)
read(nowunit,*) text,(spar(i)%kCO2_25,i=1,nspecies)
read(nowunit,*) text,(spar(i)%kO2_25,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pc_25,i=1,nspecies)
read(nowunit,*) text,(spar(i)%q10_kCO2,i=1,nspecies)
read(nowunit,*) text,(spar(i)%q10_kO2,i=1,nspecies)
read(nowunit,*) text,(spar(i)%q10_pc,i=1,nspecies)
read(nowunit,*) text,(spar(i)%pb,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PItmin,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PItopt,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PItmax,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PIa,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PPtmin,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PPtopt,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PPtmax,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PPa,i=1,nspecies)
read(nowunit,*) text,(spar(i)%PPb,i=1,nspecies)
read(nowunit,*) text,(spar(i)%CSTbC,i=1,nspecies)
read(nowunit,*) text,(spar(i)%CSTbT,i=1,nspecies)
read(nowunit,*) text,(spar(i)%CSa,i=1,nspecies)
read(nowunit,*) text,(spar(i)%CSb,i=1,nspecies)
read(nowunit,*) text,(spar(i)%LTbT,i=1,nspecies)
read(nowunit,*) text,(spar(i)%LTcrit,i=1,nspecies)
read(nowunit,*) text,(spar(i)%Lstart,i=1,nspecies)
read(nowunit,*) text,(spar(i)%Phmodel,i=1,nspecies)
read(nowunit,*) text,(spar(i)%end_bb,i=1,nspecies)
read(nowunit,*) text,(spar(i)%fpar_mod,i=1,nspecies)
read(nowunit,*) text,(spar(i)%ceppot_spec,i=1,nspecies)
read(nowunit,*) text,(spar(i)%Nresp,i=1,nspecies)
read(nowunit,*) text,(spar(i)%regflag, i=1,nspecies)
read(nowunit,*) text,(spar(i)%seedrate, i=1,nspecies)
read(nowunit,*) text,(spar(i)%seedmass, i=1,nspecies)
read(nowunit,*) text,(spar(i)%seedsd, i=1,nspecies)
read(nowunit,*) text,(spar(i)%seeda, i=1,nspecies)
read(nowunit,*) text,(spar(i)%seedb, i=1,nspecies)
read(nowunit,*) text,(spar(i)%pheight1, i=1,nspecies)
read(nowunit,*) text,(spar(i)%pheight2, i=1,nspecies)
read(nowunit,*) text,(spar(i)%pheight3, i=1,nspecies)
read(nowunit,*) text,(spar(i)%pdiam1, i=1,nspecies)
read(nowunit,*) text,(spar(i)%pdiam2, i=1,nspecies)
read(nowunit,*) text,(spar(i)%pdiam3, i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_opm_fol , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_syn_fol , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_opm_frt , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_syn_frt , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_opm_crt , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_syn_crt , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_opm_tb , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_syn_tb , i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_opm_stem, i=1,nspecies)
read(nowunit,*) text,(spar(i)%k_syn_stem, i=1,nspecies)
read(nowunit,*) text,(spar(i)%spec_rl, i=1,nspecies)
read(nowunit,*) text,(spar(i)%tbase, i=1,nspecies)
read(nowunit,*) text,(spar(i)%topt, i=1,nspecies)
read(nowunit,*) text,(spar(i)%bdmax_coef, i=1,nspecies)
read(nowunit,*) text,(spar(i)%porcrit_coef, i=1,nspecies)
read(nowunit,*) text,(spar(i)%ph_opt_max, i=1,nspecies)
read(nowunit,*) text,(spar(i)%ph_opt_min, i=1,nspecies)
read(nowunit,*) text,(spar(i)%ph_max, i=1,nspecies)
read(nowunit,*) text,(spar(i)%ph_min, i=1,nspecies)
read(nowunit,*) text,(spar(i)%v_growth, i=1,nspecies)
ios = 0
call errorfile (specfile(ip), ios, nowunit)
do i=1,nspecies
spar(i)%cnr_fol = cpart / (spar(i)%ncon_fol / 1000.)
spar(i)%cnr_frt = cpart / (spar(i)%ncon_frt / 1000.)
spar(i)%cnr_crt = cpart / (spar(i)%ncon_crt / 1000.)
spar(i)%cnr_tbc = cpart / (spar(i)%ncon_tbc / 1000.)
spar(i)%cnr_stem = cpart / (spar(i)%ncon_stem / 1000.)
enddo
close(nowunit)
end subroutine readspec
!------------------------------------------------------------------------
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* Subroutines for: *!
!* - READSIM: Read simulation options from file *!
!* - ALLOFILE: Allocate simulation files *!
!* - READCON *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE readsim
! read simulation options from file
use data_mess
use data_out
use data_par
use data_simul
use data_species
use data_stand
use data_site
use data_tsort
use data_climate
implicit none
logical ex
integer i, ios, ios1, nowunit, nowunit1, k, anzclim, j, l, helpi, helpw, helpy, ihelp, ilen
integer ltsunit
character:: a, ttext
character (150) tspec, tname, tclim, tval, tsite, tman, ttree, tdepo, tred, tlit, tsoilid, &
pathdir1, pathdir2,pathdir3, pathdir4, pathdir5, pathdir6, pathdir7, &
climszen, siteall, climall,site_name_all
character(50), dimension(:), allocatable:: site_name_ad
character(50), dimension(:), allocatable:: climfile_ad
character(50), dimension(:), allocatable:: sitefile_ad
character(50), dimension(:), allocatable:: manfile_ad
character(50), dimension(:), allocatable:: treefile_ad
character(50), dimension(:), allocatable:: wpmfile_ad
character(50), dimension(:), allocatable:: depofile_ad
character(50), dimension(:), allocatable:: redfile_ad
character(50), dimension(:), allocatable:: litfile_ad
character(150):: text
character(50) :: istand
character(10) :: helpsim, text4
integer :: spec1, spec2, tm
real :: h1, h2
real, dimension(:), allocatable:: clim_long, clim_lat, clim_height ! coordinates and height of climate stations
character(10), dimension(:), allocatable:: climnum
character(50), dimension(:), allocatable:: clim_nam
nowunit = getunit()
ios = 0
nvar = 0
call testfile(simfile,ex)
if(ex .eqv. .false.) return
open(nowunit,file=simfile,iostat=ios,status='old',action='read')
read(nowunit,*,iostat=ios) flag_multi
if(flag_multi .ge. 1) then
read(nowunit,*,iostat=ios) site_nr
if(flag_multi .eq. 9 .or. flag_multi .eq. 10) then
flag_mult910 = .True.
else
flag_mult910 = .False.
endif
if((flag_mult910 .or. flag_multi .eq. 8) .and. (site_nr .gt.1)) then
flag_mult8910 = .True.
else
flag_mult8910 = .False.
endif
repeat_number = site_nr
allocate(sitenum(site_nr))
allocate(clim_id(site_nr))
allocate(soilid(site_nr))
allocate(gwtable(site_nr))
allocate(NOdep(site_nr))
allocate(NHdep(site_nr))
clim_id = "xxx"
NOdep = 0.
NHdep = 0.
endif
select case (flag_multi)
case (1, 4)
flag_clim = 1
case (7, 8, 9, 10)
flag_clim = 1
flag_trace = .FALSE.
case default
flag_clim = 0
end select
read(nowunit,*,iostat=ios) ! skip comment line 'simulation specifications'
read(nowunit,*,iostat=ios) year
read(nowunit,*,iostat=ios) time_b
read(nowunit,*,iostat=ios) kpatchsize
read(nowunit,*,iostat=ios) dz
read(nowunit,*,iostat=ios) ns_pro
read(nowunit,*,iostat=ios) ! skip comment line 'choice of model options'
read(nowunit,*,iostat=ios) flag_mort
read(nowunit,*,iostat=ios) flag_reg
read(nowunit,*,iostat=ios) flag_lambda
read(nowunit,*,iostat=ios) flag_stand
read(nowunit,*,iostat=ios) flag_sveg
read(nowunit,*,iostat=ios) flag_mg
read(nowunit,*,iostat=ios) flag_dis
read(nowunit,*,iostat=ios) flag_light
read(nowunit,*,iostat=ios) flag_folhei
read(nowunit,*,iostat=ios) flag_volfunc
read(nowunit,*,iostat=ios) flag_resp
read(nowunit,*,iostat=ios) flag_limi
read(nowunit,*,iostat=ios) flag_decomp
read(nowunit,*,iostat=ios) flag_sign
read(nowunit,*,iostat=ios) flag_wred
read(nowunit,*,iostat=ios) flag_wurz
read(nowunit,*,iostat=ios) flag_cond
read(nowunit,*,iostat=ios) flag_int
read(nowunit,*,iostat=ios) flag_eva
read(nowunit,*,iostat=ios) flag_co2
read(nowunit,*,iostat=ios) flag_sort
read(nowunit,*,iostat=ios) flag_wpm
read(nowunit,*,iostat=ios) flag_stat
read(nowunit,*,iostat=ios) ! skip comment line 'output specifications'
read(nowunit,*,iostat=ios) time_out
! test lamda_ts
if(flag_lambda.eq.1) then
allocate(lambda_ts(168,3))
ltsunit=getunit()
open (ltsunit,file='input/lambdats_oak_pine.par', IOSTAT=ios,status='old')
read (ltsunit,*), text, spec1, spec2
!write(4567,*)text, spec1,spec2
do j=1,168
read(ltsunit,*) tm, h1, h2
lambda_ts(j,1)= tm
lambda_ts(j,2) = h1
lambda_ts(j,3) = h2
! write(4567,*) lambda_ts(j,1), lambda_ts(j,2), lambda_ts(j,3)
end do
end if
! define name of yearly output variables
nyvar = 1
read(nowunit,*,iostat=ios) outy_file(nyvar)
do while (trim(outy_file(nyvar)) .ne. 'end')
nyvar = nyvar + 1
read(nowunit,*) outy_file(nyvar)
enddo
read(nowunit,*,iostat=ios) flag_dayout
! define name of daily output variables
ndvar = 1
read(nowunit,*) outd_file(ndvar)
do while (trim(outd_file(ndvar)) .ne. 'end')
ndvar = ndvar + 1
read(nowunit,*) outd_file(ndvar)
enddo
read(nowunit,*,iostat=ios) flag_cohout
! define name of cohort output variables
ncvar = 1
read(nowunit,*) outc_file(ncvar)
do while (trim(outc_file(ncvar)) .ne. 'end')
ncvar = ncvar + 1
read(nowunit,*) outc_file(ncvar)
enddo
read(nowunit,*,iostat=ios) flag_sum
read(nowunit,*,iostat=ios) ! skip comment line 'input'
if (.not.flag_mult910) call allofile
SELECT CASE(flag_multi)
CASE (0,1,2,3,6)
jpar = 0
DO i=1,site_nr
if(i .gt. 1)then
read(nowunit,*,iostat=ios) ! skip comment line 'run number'
do
jpar = jpar + 1
read(nowunit,*) vpar(jpar), simpar(jpar)
if (vpar(jpar) .lt. -90.0) exit
enddo
endif
read(nowunit,'(A)',iostat=ios) specfile(i)
read(nowunit,'(A)') site_name(i)
read(nowunit,'(A)') climfile(i)
read(nowunit,'(A)') sitefile(i)
read(nowunit,'(A)') valfile(i)
read(nowunit,'(A)') treefile(i)
read(nowunit,'(A)') standid(i)
read(nowunit,'(A)') manfile(i)
read(nowunit,'(A)') depofile(i)
read(nowunit,'(A)') redfile(i)
read(nowunit,'(A)',iostat=ios) litfile(i)
! fill clim_id
clim_id(i) = climfile(i)
ios1=-1
! measurements
if(flag_multi.ne.2) then
if (ios .eq. 0) read(nowunit,'(A)',iostat=ios1) text
if (ios1 .eq. 0) then
if (flag_stat .gt. 0 .and. i .eq. 1) then
allocate (mesfile(anz_mesf))
mesfile(1) = text
ttext = adjustl(text)
if (ttext .eq. '!' .or. ttext .eq. '*') then
backspace (nowunit)
else
if (.not.flag_mult8910) write (*, '(A, I3,A,A)')' >>>foresee message: site_nr ',i,'; filename of measurements: ', trim(mesfile(1))
endif
else
ttext = adjustl(text)
if (ttext .eq. '!' .or. ttext .eq. '*') backspace (nowunit)
endif
endif
end if
if (.not.flag_mult8910) print *, ' >>>foresee message: site_nr ',i,'; input of filenames completed'
end DO
CASE (4, 5, 8)
allocate(latitude(site_nr))
allocate(RedN_list(15, site_nr))
RedN_list = -99.9
read(nowunit,'(A)',iostat=ios) specfile(1)
read(nowunit,'(A)') site_name(1)
read(nowunit,'(A)') treefile(1)
read(nowunit,'(A)') manfile(1)
read(nowunit,'(A)') siteall ! control xxx.con
read(nowunit,'(A)') climall ! climate stations with coordination
read(nowunit,'(A)') pathdir1 ! path for climate scenarios
read(nowunit,'(A)') pathdir2 ! path for soil file xxx.sop or name of total soil file (flag_multi=8)
read(nowunit,'(A)') climszen ! labeling climate scenarios
if (flag_multi .eq. 8.or.flag_multi.eq.5) read(nowunit,*) text ! BRB / BAWUE / DEU
if (.not.flag_mult8910) print *, ' >>>foresee message: Input of filenames completed'
site_name1 = site_name(1)
! define name of output variables
nvar = 1
read(nowunit,*) outvar(nvar)
do while (trim(outvar(nvar)) .ne. 'end')
nvar = nvar + 1
read(nowunit,*) outvar(nvar)
enddo
if (nvar .gt. 1) allocate(output_var(nvar,site_nr,0:year))
helpw = 0
helpi = 0
do i = 1, nvar-1
select case (trim(outvar(i)))
case ('AET_mon','AETmon','aetmon','aet_mon','cwb_mon','cwbmon','PET_mon','PETmon','petmon','pet_mon', &
'GPP_mon','GPPmon','gppmon','gpp_mon','NEP_mon','NEPmon','nepmon','nep_mon','NPP_mon','NPPmon','nppmon','npp_mon', &
'perc_mon','percmon','temp_mon','tempmon','prec_mon','precmon', 'resps_mon','respsmon','TER_mon','TERmon','ter_mon','termon')
flag_cum = 1
helpi = helpi + 1
output_var(i,1,0) = 1.*helpi ! field numbre of monthly value
case ('AET_week','AETweek','aetweek','aet_week','cwb_week','cwbweek','PET_week','PETweek','petweek','pet_week', &
'GPP_week','GPPweek','gppweek','gpp_week','NEP_week','NEPweek','nepweek','nep_week','NPP_week','NPPweek','nppweek','npp_week', &
'perc_week','percweek','temp_week','tempweek','prec_week','precweek', 'resps_week','respsweek', 'TER_week','TERweek','ter_week','terweek')
flag_cum = 1
helpw = helpw + 1
output_var(i,1,0) = 1.*helpw ! field numbre of weekly values
end select ! outvar
enddo
if (helpi .gt. 0) then
allocate(output_varm(helpi,site_nr,year,12))
endif
if (helpw .gt. 0) then
allocate(output_varw(helpw,site_nr,year,52))
endif
call errorfile(simfile, ios, nowunit)
! reading file with description of climate stations used
allocate(climnum(3000))
allocate(clim_long(3000))
allocate(clim_lat(3000))
allocate(clim_height(3000))
allocate(clim_nam(3000))
call testfile(climall,ex)
if (ex .eqv. .false.) return
nowunit1 = getunit()
ios1 = 0
open(nowunit1,file=climall,iostat=ios,status='old',action='read')
k=1
do
READ(nowunit1,'(A)',iostat=ios1) a
IF (a .ne. '!') exit
end do
backspace nowunit1
do
read(nowunit1,*,iostat=ios1) climnum(k), clim_long(k),clim_lat(k), &
clim_height(k)
if(ios1 .lt. 0) exit
k = k+1
end do
anzclim = k-1
ios1 = 0
call errorfile(climall, ios1, nowunit1)
! reading control file with site-id, climate-id, soil-id, gwtabe-id
call testfile(siteall,ex)
if (ex .eqv. .false.) return
nowunit1 = getunit()
open(nowunit1,file=siteall,iostat=ios1,status='old',action='read')
do
READ(nowunit1,'(A)',iostat=ios1) a
IF (a .ne. '!') exit
end do
backspace nowunit1
! if (flag_multi .eq. 8) read(nowunit1,*) text ! BRB / BAWUE / DEU
select case (trim(text))
case ('BRB')
flag_climnam = 1
case ('BAWUE')
flag_climnam = 2
case ('DEU')
flag_climnam = 3
case ('REMO')
flag_climnam = 4
case('WETTREG')
flag_climnam =5
end select
do i=1,site_nr
select case (flag_multi)
case (4)
read(nowunit1,*,iostat=ios1) sitenum(i), clim_id(i), soilid(i), gwtable(i)
flag_climnam = 1
sitefile(i) =trim(pathdir2)//'wbuek'//trim(soilid(i))//'.sop'
valfile(i) =trim(pathdir2)//'wbuek'//trim(soilid(i))//'.soi'
standid(i) = sitenum(i)
case (5,8)
call readcon(i, nowunit1)
soilid(i) = adjustl(soilid(i))
ihelp = len(trim(soilid(i)))
sitefile(i) = trim(pathdir2)
if( flag_climnam.eq.3) then
climfile(i) = trim(pathdir1)//trim(clim_id(i))//trim(climszen)//'.dat'
end if
if(flag_climnam.eq.4) then
climfile(i) = trim(pathdir1)//'gp_'//trim(clim_id(i))//'_'//trim(climszen)//'.txt'
end if
if(flag_climnam.eq.5) then
climfile(i) = trim(pathdir1)//trim(clim_id(i))//'_'//trim(climszen)//'.dat'
end if
end select
do j = 1,anzclim
if(clim_id(i).eq.climnum(j)) then
select case (flag_climnam)
case (1) ! WK
if(flag_climtyp .eq. 5) then
climfile(i) = trim(pathdir1)//trim(clim_nam(j))//trim(climszen)//'.dat'
else
climfile(i) = trim(pathdir1)//trim(clim_nam(j))//trim(climszen)//'.cli'
end if
case (2) ! Klara
climfile(i) = trim(pathdir1)//trim(climnum(j))//trim(climszen)//'.dat'
end select
latitude(i) = clim_lat(j)
exit
end if
if (j .eq. anzclim) then
write (unit_err,*) '*** 4C-error - searching in file:', trim(climall)
write (unit_err,*) ' no climate station found for climate id: ', clim_id(i)
write (unit_err,*)
endif
end do
! fill in sitefile
site_name(i) = site_name(1)
specfile(i) = specfile(1)
treefile(i) = treefile(1)
manfile(i) = manfile(1)
depofile(i) = 'dummy.dep'
redfile = 'dummy.red'
litfile = 'dummy.lit'
enddo
if ((.not.flag_mult8910) .and. (ios1 .lt. 0)) print *, 'no information for site number ', i
call errorfile(siteall, ios1, nowunit1)
deallocate(climnum)
deallocate(clim_long)
deallocate(clim_lat)
deallocate(clim_height)
deallocate(clim_nam)
close(nowunit1)
! variation of flag_multi= 5, especially for SILVISTRAT
CASE (7)
allocate(site_name_ad(site_nr))
allocate(climfile_ad(site_nr))
allocate(sitefile_ad(site_nr))
allocate(manfile_ad(site_nr))
allocate(treefile_ad(site_nr))
allocate(depofile_ad(site_nr))
allocate(redfile_ad(site_nr))
allocate(litfile_ad(site_nr))
allocate(fl_co2(site_nr))
read(nowunit,'(A)',iostat=ios) specfile(1)
read(nowunit,'(A)') site_name_all
read(nowunit,'(A)') siteall
read(nowunit,'(A)') pathdir1 ! path climate file
read(nowunit,'(A)') pathdir2 ! path soil file
read(nowunit,'(A)') pathdir3 ! path treeini file
read(nowunit,'(A)') pathdir4 ! path management file
read(nowunit,'(A)') pathdir5 ! path deposition file
read(nowunit,'(A)') pathdir6 ! path RedN file
read(nowunit,'(A)') pathdir7 ! path litter file
call errorfile(simfile, ios, nowunit)
! reading control file with site-id,name, climate scenario, soil-id, man-file, treeini-file, dep-file
call testfile(siteall,ex)
if (ex .eqv. .false.) return
nowunit1 = getunit()
open(nowunit1,file=siteall,iostat=ios1,status='old',action='read')
do
READ(nowunit1,'(A)',iostat=ios1) a
IF (a .ne. '!') exit
end do
backspace nowunit1
do i=1,site_nr
read(nowunit1,*,iostat=ios1) sitenum(i),site_name_ad(i), climfile_ad(i),sitefile_ad(i),treefile_ad(i), &
manfile_ad(i),depofile_ad(i),redfile_ad(i),litfile_ad(i), fl_co2(i)
specfile(i) = specfile(1)
standid(i) = sitenum(i)
site_name(i)= trim(site_name_all)//trim(site_name_ad(i))
climfile(i) = trim(pathdir1)//trim(climfile_ad(i))
sitefile(i) = trim(pathdir2)//trim(sitefile_ad(i))
treefile(i) = trim(pathdir3)//trim(treefile_ad(i))
manfile(i) = trim(pathdir4)//trim(manfile_ad(i))
depofile(i) = trim(pathdir5)//trim(depofile_ad(i))
redfile(i) = trim(pathdir6)//trim(redfile_ad(i))
litfile(i) = trim(pathdir7)//trim(litfile_ad(i))
enddo
call errorfile(siteall, ios1, nowunit1)
deallocate(site_name_ad)
deallocate(climfile_ad)
deallocate(sitefile_ad)
deallocate(manfile_ad)
deallocate(treefile_ad)
deallocate(depofile_ad)
deallocate(redfile_ad)
deallocate(litfile_ad)
if (allocated(wpmfile_ad)) deallocate(wpmfile_ad)
close(nowunit1)
CASE (9, 10)
! read once only per climate station
allocate(sitefile(site_nr))
allocate(climfile(site_nr))
allocate(treefile(site_nr))
allocate(manfile(site_nr))
allocate(standid(site_nr))
allocate(latitude(site_nr))
allocate(site_name(site_nr))
allocate(RedN_list(15, site_nr))
RedN_list = -99.9
! read once only
allocate(specfile(1))
allocate(depofile(1))
allocate(redfile(1))
allocate(litfile(1))
allocate(valfile(1))
read(nowunit,'(A)',iostat=ios) specfile(1)
read(nowunit,'(A)') site_name(1)
read(nowunit,'(A)') treefile(1)
read(nowunit,'(A)') manfile(1)
read(nowunit,'(A)') siteall ! control file xxx.con
read(nowunit,'(A)') climall ! climate station with coordiantes
read(nowunit,'(A)') pathdir1 ! path of climate scenarios
read(nowunit,'(A)') pathdir2 ! path of soil file xxx.sop or name of total soil file (flag_multi=8)
read(nowunit,'(A)') climszen ! labeling climate scenarios
read(nowunit,'(A)') text ! degree of climate scenarios
read(nowunit,*) nrreal ! amount of realisations/implementations
if (.not.flag_mult8910) print *, ' >>>foresee message: Input of filenames completed'
depofile(1) = 'dummy.dep'
redfile(1) = 'dummy.red'
litfile(1) = 'dummy.lit'
site_name = site_name(1)
site_name1 = site_name(1)
ilen = len(trim(text))
text = adjustl(text)
nrclim = 0
do while (ilen .gt. 0)
nrclim = nrclim + 1
ihelp = scan(text, ' ')
typeclim(nrclim) = adjustl(text(1:ihelp-1))
text = adjustl(text(ihelp:))
ilen = len(trim(text))
enddo
! processing of nrreal realisations/implementations of climate scenarios
site_anz = nrreal * nrclim * site_nr
allocate(climszenfile(site_nr, nrclim, nrreal))
! define name of output variables
nvar = 1
read(nowunit,*) outvar(nvar)
do while (trim(outvar(nvar)) .ne. 'end')
nvar = nvar + 1
read(nowunit,*) outvar(nvar)
enddo
if (nvar .gt. 1) then
allocate(output_var(nvar-1,1,0:year))
allocate(output_unit(nvar-1))
allocate(climszenres(nvar-1,site_nr,nrclim,nrreal))
output_unit = -99
output_unit_all = -99
helpy = 0
helpi = 0
helpw = 0
do i = 1, nvar-1
select case (trim(outvar(i)))
case ('AET_year','AETyear','aetyear','aet_year','cwb_year','cwbyear','PET_year','PETyear','petyear','pet_year', &
'GPP_year','GPPyear','gppyear','gpp_year','NEP_year','NEPyear','nepyear','nep_year','NPP_year','NPPyear','nppyear','npp_year', &
'perc_year','percyear','temp_year','tempyear','prec_year','precyear', 'resps_year','respsyear','TER_year','TERyear','ter_year','teryear')
flag_cum = 1
helpy = helpy + 1
output_var(i,1,0) = 1.*helpy ! field numbre of yearly values
case ('AET_mon','AETmon','aetmon','aet_mon','cwb_mon','cwbmon','PET_mon','PETmon','petmon','pet_mon', &
'GPP_mon','GPPmon','gppmon','gpp_mon','NEP_mon','NEPmon','nepmon','nep_mon','NPP_mon','NPPmon','nppmon','npp_mon', &
'perc_mon','percmon','temp_mon','tempmon','prec_mon','precmon', 'resps_mon','respsmon','TER_mon','TERmon','ter_mon','termon')
flag_cum = 1
helpi = helpi + 1
output_var(i,1,0) = 1.*helpi ! field numbre of monthly values
case ('AET_week','AETweek','aetweek','aet_week','cwb_week','cwbweek','PET_week','PETweek','petweek','pet_week', &
'GPP_week','GPPweek','gppweek','gpp_week','NEP_week','NEPweek','nepweek','nep_week','NPP_week','NPPweek','nppweek','npp_week', &
'perc_week','percweek','temp_week','tempweek','prec_week','precweek', 'resps_week','respsweek', 'TER_week','TERweek','ter_week','terweek')
flag_cum = 1
helpw = helpw + 1
output_var(i,1,0) = 1.*helpw ! field numbre of weekly values
end select ! outvar
enddo
if (helpy .gt. 0) then
allocate(climszenyear(helpy,site_nr,nrclim,nrreal,year))
endif
if (helpi .gt. 0) then
allocate(climszenmon(helpi,site_nr,nrclim,nrreal,12))
allocate(output_varm(helpi,1,year,12))
endif
if (helpw .gt. 0) then
allocate(climszenweek(helpw,site_nr,nrclim,nrreal,52))
allocate(output_varw(helpw,1,year,52))
endif
endif ! nvar
call errorfile(simfile, ios, nowunit)
! reading file with description of climate stations used
allocate(climnum(3000))
allocate(clim_long(3000))
allocate(clim_lat(3000))
allocate(clim_height(3000))
allocate(clim_nam(3000))
call testfile(climall,ex)
if (ex .eqv. .false.) return
nowunit1 = getunit()
ios1 = 0
open(nowunit1,file=climall,iostat=ios,status='old',action='read')
k=1
do
READ(nowunit1,'(A)',iostat=ios1) a
IF (a .ne. '!') exit
end do
backspace nowunit1
do
read(nowunit1,*,iostat=ios1) climnum(k), clim_long(k),clim_lat(k), clim_height(k)
if(ios1 .lt. 0) exit
k = k+1
end do
anzclim = k-1
ios1 = 0
call errorfile(climall, ios1, nowunit1)
! reading control file with site-id, climate-id, soil-id, gwtabe-id
call testfile(siteall,ex)
if (ex .eqv. .false.) return
nowunit1 = getunit()
open(nowunit1,file=siteall,iostat=ios1,status='old',action='read')
do
READ(nowunit1,'(A)',iostat=ios1) a
IF (a .ne. '!') exit
end do
backspace nowunit1
do i=1,site_nr
call readcon(i, nowunit1)
sitefile(i) = trim(pathdir2)
if(i.gt.1) treefile(i)= treefile(1)
if(i.gt.1) manfile(i) = manfile(1)
k = 1
do while (clim_id(i).ne.climnum(k))
k = k + 1
if (k .gt. anzclim) then
write (unit_err,*)
write (unit_err,*) ' >>>foresee message: Climate ID ', trim(clim_id(i)), ' not in file ',trim(climall)
write (unit_err,*) ' Site number ',sitenum(i)
write (*,*)
write (*,*) ' >>>foresee message: Climate ID ', trim(clim_id(i)), ' not in file ',trim(climall)
write (*,*) ' Site number ',sitenum(i)
print *,' Program will stop!'
flag_end = 4
return
endif
enddo
latitude(i) = clim_lat(k)
do l = 1, nrclim
do j = 1, nrreal
write (helpsim,'(I5)') j
read (helpsim,*) text4
select case (flag_multi)
case (9)
climszenfile(i,l,j) = trim(pathdir1)//trim(typeclim(l))//'/real_'//trim(text4)//'/'//trim(clim_id(i))//trim(climszen)//'.dat'
case (10)
if (j .lt. 10) then
text4 = '00'//text4
else if (j .lt. 100) then
text4 = '0'//text4
endif
climszenfile(i,l,j) = trim(pathdir1)//'/q'//trim(text4)//'/'//trim(clim_id(i))//trim(climszen)//'.dat'
end select
enddo !j
end do !l
enddo
if ((.not.flag_mult8910) .and. (ios1 .lt. 0)) print *, 'no information for site number ', i
call errorfile(siteall, ios1, nowunit1)
deallocate(climnum)
deallocate(clim_long)
deallocate(clim_lat)
deallocate(clim_height)
deallocate(clim_nam)
close(nowunit1)
END SELECT
jpar = 0 ! reset jpar for restore
if(flag_multi .eq. 2)then
read (nowunit,*) step_sum_T,n_T_downsteps,n_T_upsteps
read (nowunit,*) step_fac_P,n_P_downsteps,n_P_upsteps
site_nr = (1+n_T_downsteps+n_T_upsteps) * (1+n_P_downsteps+n_P_upsteps)
repeat_number = site_nr
tspec = specfile(1)
tname = site_name(1)
tclim = climfile(1)
tsite = sitefile(1)
tval = valfile(1)
ttree = treefile(1)
tman = manfile(1)
tdepo = depofile(1)
tred = redfile(1)
tlit = litfile(1)
istand = standid(1)
tsoilid = soilid(1)
deallocate (specfile)
deallocate (site_name)
deallocate (climfile)
deallocate (clim_id)
deallocate (sitefile)
deallocate (valfile)
deallocate (treefile)
deallocate (manfile)
deallocate (depofile)
deallocate (redfile)
deallocate (litfile)
deallocate (wpmfile)
deallocate (standid)
deallocate (soilid)
allocate (specfile(site_nr))
allocate (site_name(site_nr))
allocate (climfile(site_nr))
allocate (clim_id(site_nr))
allocate (sitefile(site_nr))
allocate (valfile(site_nr))
allocate (treefile(site_nr))
allocate (manfile(site_nr))
allocate (depofile(site_nr))
allocate (standid(site_nr))
allocate (soilid(site_nr))
allocate (redfile(site_nr))
allocate (litfile(site_nr))
allocate (wpmfile(site_nr))
specfile = tspec
site_name = tname
climfile = tclim
sitefile = tsite
valfile = tval
treefile = ttree
manfile = tman
depofile = tdepo
redfile = tred
litfile = tlit
standid = istand
soilid = tsoilid
call errorfile(simfile, ios, nowunit)
endif ! flag_multi = 2
close(nowunit)
END subroutine readsim
!**************************************************************
SUBROUTINE allofile
use data_simul
implicit none
allocate(site_name(site_nr))
allocate(climfile(repeat_number))
allocate(sitefile(site_nr))
allocate(valfile(site_nr))
allocate(treefile(repeat_number))
allocate(standid(repeat_number))
allocate(manfile(repeat_number))
allocate(depofile(repeat_number))
allocate(redfile(repeat_number))
allocate(litfile(repeat_number))
allocate(wpmfile(repeat_number))
allocate(specfile(repeat_number))
end subroutine allofile
!**************************************************************
SUBROUTINE readcon (ii, unitnum)
use data_depo
use data_out
use data_par
use data_simul
use data_site
implicit none
integer ii, ihelp, unitnum, ios1, ilen, helpi
character(150):: text
character(10):: helpsim, text4
read(unitnum,'(A)',iostat=ios1) text
! text disassemble
! sitenum
ilen = len(trim(text))
text = adjustl(text)
ihelp = verify(text, charset)
text4 = adjustl(text(1:ihelp-1))
sitenum(ii) = text4
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
ihelp = scan(text, charset)
text = text(ihelp:)
ihelp = verify(text, charset)
clim_id(ii) = adjustl(text(1:ihelp-1))
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
ihelp = scan(text, charset)
text = text(ihelp:)
ihelp = verify(text, charset)
soilid(ii) = adjustl(text(1:ihelp-1))
! gwtable
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
ihelp = scan(text, charset)
text = text(ihelp:)
ihelp = verify(text, charset)
text4 = adjustl(text(1:ihelp-1))
write (helpsim,'(A)') text4
read (helpsim,*) gwtable(ii)
! standid
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
ihelp = scan(text, charset)
text = text(ihelp:)
ihelp = verify(text, charset)
text4 = adjustl(text(1:ihelp-1))
standid(ii) = text4
! deposition
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
if (ilen .gt. 0) then
text = adjustl(text)
ihelp = verify(text, charset)
text4 = adjustl(text(1:ihelp-1))
write (helpsim,'(A)') text4
read (helpsim,*) NOdep(ii) ! hand over in readdepo as concentration
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
ihelp = scan(text, charset)
text = text(ihelp:)
ihelp = verify(text, charset)
text4 = adjustl(text(1:ihelp-1))
write (helpsim,'(A)') text4
read (helpsim,*) NHdep(ii) ! hand over in readdepo as concentration
! RedN
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
do while (ilen .gt. 0)
ihelp = verify(text, charset)
text4 = adjustl(text(1:ihelp-1))
write (helpsim,'(A)') text4
read (helpsim,*) helpi
text = adjustl(text(ihelp+1:))
ihelp = verify(text, charset)
text4 = adjustl(text(1:ihelp-1))
write (helpsim,'(A)') text4
read (helpsim,*) RedN_list(helpi, ii)
text = adjustl(text(ihelp+1:))
ilen = len(trim(text))
enddo
else
NOdep(ii) = 0.
NHdep(ii) = 0.
endif
End SUBROUTINE readcon
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* Root distribution *!
!* *!
!* - ROOT_DISTR *!
!* - ROOT_EFF *!
!* - ROOT_DEPTH *!
!* - ROOT_INI *!
!* - DEALLOC_ROOT *!
!* - ROOTC_NEW (nicht benutzt wegen Problemen bei Verkettung) *!
!* - CR_DEPTH *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE root_distr
! Calculation of root distribution for each cohorte
use data_simul
use data_soil
use data_stand
use data_par
use data_species
implicit none
integer specn ! species type (number)
integer i, j, nj, k, jlay
integer nr ! aux. var. for nroot (rooting depth)
integer rkind ! kind of calculation of root depth
real frtrel_1, frtrel_j ! rel fine root fraction of previous layer
real frtrel_s ! Sum of fine root fractions
real radius ! radius of cylyndric space created by roots of the root length density
real beta ! base of power
real help
real alpha, b ! Parameters for Arora function
real troot2 ! theoretical root biomass of population (coarse and fine roots) only for Arora funktion spereated according to cohorts [kg/m]
real :: part_coef=0.0 ! Verteilungskoeffizient um Verhltnis zwischen fr_loss und redis zu bestimmen
real, dimension (1:nlay) :: fr_loss1, valspace, frtrelcoh !auxiliary vectors
rkind = rdepth_kind
if ((anz_tree + anz_sveg) .eq. 0) return
select case (flag_wurz)
case (0)
root_fr = 0.
zeig => pt%first
do while (associated(zeig))
call root_depth (rkind, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig%coh%nroot = nr
zeig%coh%frtrel = thick/depth(nr)
specn = zeig%coh%species
do j = 1, nr
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
do j = nr+1, nlay
zeig%coh%frtrel(j) = 0.
enddo
zeig%coh%rooteff = 0. ! zero after use
zeig => zeig%next
enddo
case (1) ! Funktion
root_fr = 0.
zeig => pt%first
do while (associated(zeig))
call root_depth (rkind, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot) !nderung MG: bergabe von Grob und Feinwurzelmasse an root_depth
zeig%coh%nroot = nr
specn = zeig%coh%species
if (specn .eq. 2 .or. specn .eq. 3) then
beta = 0.976
else
beta = 0.966
endif
frtrel_1 = 1.
zeig%coh%frtrel = 0.
do j=1,nr
frtrel_j = beta ** depth(j)
zeig%coh%frtrel(j) = frtrel_1 - frtrel_j
frtrel_1 = frtrel_j
enddo
frtrel_s = SUM(zeig%coh%frtrel)
frtrel_s = 1./frtrel_s
do j=1,nr
! scaling of root distribution
zeig%coh%frtrel(j) = zeig%coh%frtrel(j) * frtrel_s
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
zeig%coh%rooteff = 0. ! zero after use
zeig => zeig%next
enddo
case (2) ! read/use default distribution; not changed
root_fr = 0.
zeig => pt%first
do while (associated(zeig))
if (zeig%coh%frtrel(1) .gt. 0.) then
do j = 1,nroot_max
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
else
root_fr = 0.
call root_depth (1, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig%coh%nroot = nr
specn = zeig%coh%species
if (specn .eq. 2 .or. specn .eq. 3) then
beta = 0.98
else
beta = 0.967
endif
frtrel_1 = 1.
zeig%coh%frtrel = 0.
do j=1,nr
frtrel_j = beta ** depth(j)
zeig%coh%frtrel(j) = frtrel_1 - frtrel_j
frtrel_1 = frtrel_j
enddo
frtrel_s = SUM(zeig%coh%frtrel)
frtrel_s = 1./frtrel_s
do j=1,nr
zeig%coh%frtrel(j) = zeig%coh%frtrel(j) * frtrel_s
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
endif
zeig%coh%rooteff = 0. ! zero after use
zeig => zeig%next
enddo
case (3)
root_fr = 0.
rkind=5
zeig => pt%first
do while (associated(zeig))
call root_depth (rkind, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot) !nderung MG: bergabe von Grob und Feinwurzelmasse an root_depth
zeig%coh%nroot = nr
specn = zeig%coh%species
alpha=0.7
if (specn .eq. 2 .or. specn .eq. 3 .or. specn .eq. 6 .or. specn .eq. 7) then
b = 7.95
else
b = 10.91
endif
frtrel_1 = 1.
zeig%coh%frtrel = 0.
do j=1,nr
! root distribution (Arora et al., 2003)
frtrel_j = exp((-b/troot2**alpha)*(depth(j)/100))
zeig%coh%frtrel(j) = frtrel_1 - frtrel_j
frtrel_1 = frtrel_j
enddo
frtrel_s = SUM(zeig%coh%frtrel)
frtrel_s = 1./frtrel_s
do j=1,nr
! scaling of root distribution
zeig%coh%frtrel(j) = zeig%coh%frtrel(j) * frtrel_s
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
zeig%coh%rooteff = 0. ! zero after use
zeig => zeig%next
enddo
case(4) ! TRAP-model Rasse et al. (2001)
root_fr = 0.
rkind = 6
fr_loss1= 0
k = 0
zeig => pt%first
do while (associated(zeig))
k=k+1
zeig%coh%x_rdpt=gr_depth(k)
specn = zeig%coh%species
if (specn .eq. 12) then
continue
endif
call root_depth (rkind, specn, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig%coh%nroot = nr
frtrel_1 = 1.
zeig%coh%frtrel = 0.
do j=1,nr
if (j .eq. 1) then
zeig%coh%frtrel(j) = (zeig%coh%x_rdpt**3-(zeig%coh%x_rdpt-depth(j))**3)/zeig%coh%x_rdpt**3
elseif (j .eq. nr) then
zeig%coh%frtrel(j)= frtrel_1
else
zeig%coh%frtrel(j) = ((zeig%coh%x_rdpt-depth(j-1))**3-((zeig%coh%x_rdpt-depth(j))**3))/zeig%coh%x_rdpt**3
endif
frtrel_1 = frtrel_1-zeig%coh%frtrel(j)
enddo
frtrel_s = SUM(zeig%coh%frtrel)
frtrel_s = 1./frtrel_s
zeig%coh%frtrel = zeig%coh%frtrel * frtrel_s
fr_loss1 = zeig%coh%frtrel
fr_loss = zeig%coh%frtrel*svar(specn)%Smean(1:nlay)
fr_loss = part_coef*(fr_loss1-fr_loss)
redis = zeig%coh%frtrel*svar(specn)%Smean(1:nlay)
redis = part_coef*(fr_loss1-redis)
do j=1,nr
! scaling of root distribution
if (sum(svar(specn)%Smean(1:nr)) .lt. 0.0001) then
zeig%coh%frtrel(j) = 0.
else
zeig%coh%frtrel(j) = zeig%coh%frtrel(j)*svar(specn)%Smean(j)+(sum(redis)*svar(specn)%Smean(j)/sum(svar(specn)%Smean(1:nr)))
endif
enddo
frtrel_s = SUM(zeig%coh%frtrel)
if (frtrel_s .lt. 1.E-6) then
do j=1,nr
zeig%coh%frtrel(j) = 0
enddo
else
frtrel_s = 1./frtrel_s
do j=1,nr
! scaling of root distribution
zeig%coh%frtrel(j) = zeig%coh%frtrel(j) * frtrel_s
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
endif
zeig%coh%rooteff = 0.
zeig => zeig%next
enddo
case(5)
root_fr = 0.
rkind=5
zeig => pt%first
do while (associated(zeig))
call root_depth (rkind, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot) !nderung MG: bergabe von Grob und Feinwurzelmasse an root_depth
zeig%coh%nroot = nr
specn = zeig%coh%species
if (specn .eq. 2 .or. specn .eq. 3) then
beta = 0.98
else
beta = 0.967
endif
frtrel_1 = 1.
zeig%coh%frtrel = 0.
do j=1,nr
! root distribution (Jackson et al., 1996): beta ** depth
frtrel_j = beta ** depth(j)
zeig%coh%frtrel(j) = frtrel_1 - frtrel_j
frtrel_1 = frtrel_j
enddo
frtrel_s = SUM(zeig%coh%frtrel)
frtrel_s = 1./frtrel_s
do j=1,nr
! scaling of root distribution
zeig%coh%frtrel(j) = zeig%coh%frtrel(j) * frtrel_s
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
zeig%coh%rooteff = 0. ! zero after use
zeig => zeig%next
enddo
case(6)
root_fr = 0.
rkind=7
zeig => pt%first
k=1
do while (associated(zeig))
zeig%coh%x_rdpt=gr_depth(k)
call root_depth (rkind, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt,zeig%coh%nroot) !nderung MG: bergabe von Grob und Feinwurzelmasse an root_depth
if (time .le. 1) then
root_lay(k)=nr
else
root_lay(k)=root_lay(k)+nr
endif
if (root_lay(k) .gt. nroot_max) root_lay(k) = nroot_max
zeig%coh%nroot=root_lay(k)
nr=root_lay(k)
specn = zeig%coh%species
if (specn .eq. 2 .or. specn .eq. 3) then
beta = 0.98
else
beta = 0.967
endif
frtrel_1 = 1.
zeig%coh%frtrel = 0.
do j=1,nr
! root distribution (Jackson et al., 1996): beta ** depth
frtrel_j = beta ** depth(j)
zeig%coh%frtrel(j) = frtrel_1 - frtrel_j
frtrel_1 = frtrel_j
enddo
frtrel_s = SUM(zeig%coh%frtrel)
frtrel_s = 1./frtrel_s
do j=1,nr
! scaling of root distribution
zeig%coh%frtrel(j) = zeig%coh%frtrel(j) * frtrel_s
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
zeig%coh%rooteff = 0. ! zero after use
k=k+1
zeig => zeig%next
enddo
case (7) ! Funktion nach Jackson (1996) mit fester Tiefe
root_fr = 0.
nr = nroot_max
zeig => pt%first
do while (associated(zeig))
zeig%coh%nroot = nroot_max
specn = zeig%coh%species
if (specn .eq. 2 .or. specn .eq. 3) then
beta = 0.98
else
beta = 0.967
endif
frtrel_1 = 1.
zeig%coh%frtrel = 0.
do j=1,nr
! root distribution (Jackson et al., 1996): beta ** depth
frtrel_j = beta ** depth(j)
zeig%coh%frtrel(j) = frtrel_1 - frtrel_j
frtrel_1 = frtrel_j
enddo
frtrel_s = SUM(zeig%coh%frtrel)
frtrel_s = 1./frtrel_s
do j=1,nr
! scaling of root distribution
zeig%coh%frtrel(j) = zeig%coh%frtrel(j) * frtrel_s
root_fr(j) = root_fr(j) + zeig%coh%frtrel(j) * zeig%coh%ntreeA
enddo
zeig%coh%rooteff = 0. ! zero after use
zeig => zeig%next
enddo
end select
root_fr = root_fr / (anz_tree + anz_sveg) ! normieren
zeig => pt%first
do while (associated(zeig))
help = zeig%coh%x_frt * zeig%coh%ntreea
do jlay = 1, nroot_max
if (root_fr(jlay) .gt. zero) then
zeig%coh%frtrelc(jlay) = zeig%coh%frtrel(jlay) * help / (root_fr(jlay) * totfrt_p) ! mass of root part of total cohort in a layer
else
zeig%coh%frtrelc(jlay) = 0.
endif
enddo
zeig => zeig%next
enddo
if (flag_wred .eq. 9) then
!Calculation of root length density
zeig => pt%first
do while (associated(zeig))
if (specn .le. nspec_tree) then
radius = (zeig%coh%diam/6.)*100. ! formula bhd [cm]/6 yield radius in [m] so *100 (aus Wagner 2005)
valspace = pi * radius**2 * thick
else
valspace = kpatchsize * 100*100 * thick
endif !circular cylinder
frtrelcoh = zeig%coh%frtrel * zeig%coh%x_frt * zeig%coh%ntreea
if (zeig%coh%ntreea .gt. 0 .AND. minval(valspace(1:nr)) .gt. 0.) then
zeig%coh%rld = (frtrelcoh*1000*spar(specn)%spec_rl*100)/(valspace* zeig%coh%ntreea) !in cm root length /cm3 volume
else
zeig%coh%rld = -99
endif
zeig => zeig%next
enddo
endif
if (allocated(wat_root)) wat_root=0.
END subroutine root_distr
!**************************************************************
SUBROUTINE root_eff
! Calculation of root efficiency in dependence of water and N uptake
use data_soil
use data_soil_cn
use data_stand
implicit none
integer i,j
integer nr ! layer number of root depth
real hroot ! root depth
real fdc ! discounting function describing transport resistance
real gw, gN ! accounting functions of water resp. N uptake
real glimit ! limitation constant for use of rooting layer
glimit = 0. ! min. assumption
i = 1
zeig => pt%first
do while (associated(zeig))
nr = zeig%coh%nroot
do j = 1,nr
fdc = 50./depth(j)
if (zeig%coh%supply .gt. 1e-06) then
gw = xwatupt(i,j)/zeig%coh%supply
gw = gw / thick(j)
else
gw = 0.
endif
gw = xwatupt(i,j)
zeig%coh%rooteff(j) = zeig%coh%rooteff(j) + gw
enddo
zeig%coh%watuptc = zeig%coh%watuptc + zeig%coh%supply
i = i + 1
zeig => zeig%next
enddo
END subroutine root_eff
!**************************************************************
SUBROUTINE root_depth(rkind, specn, agec, heightc, froot, croot, nr, troot2, crdepth, nrooth)
use data_simul
use data_soil
use data_soil_cn
use data_stand
implicit none
! input:
integer rkind ! kind of calculation of root depth
integer specn ! species number
integer agec ! tree age
integer nrooth ! for case(7)
real heightc, froot, croot ! tree height of cohort, fine and coarse root mass[kg]/ tree
real troot, troot1,troot2, troot_stand ! total root mass 1./tree 2./ha according to cohorts 3. /m according to cohorts Kohorten 4./ha of 4C
real :: wat_demand ! query whether one cohort was unable to cover water demand with the from root penetrated soil layer
real rootingdepth, crdepth ! rooting depth nach Arora function in [m]
real alpha, b ! parameter for Arorafunction
! output:
integer nr ! last root layer
integer i,j
real hc, wtiefe
real, dimension(4,3):: rdepth ! effective rooting depth depending on tree age and soil texture
! data from Raissi et al. (2001)
data rdepth /85, 130, 175, 95, 140, 185, 135, 180, 225, 90, 110, 135/
select case (rkind)
case (1)
! nroot depending on tree height and soil profile depth
nr = 1
do j=1,nlay
if (heightc .ge. depth(j)) nr = j
enddo
if (nr .gt. nroot_max) nr = nroot_max
crdepth = depth(nr)
case (2)
! fixed nroot for all adult cohorts
if (agec .lt. 10) then
nr = 1
wtiefe=depth(nroot_max)/(1+exp(1.5-0.55*real(agec))) ! logicla function to determin root depth [cm] until age 10
do j=1,nlay
if (wtiefe .ge. depth(j)) nr = j
enddo
if (nr .gt. nroot_max) nr = nroot_max
else
nr = nroot_max
endif
crdepth = depth(nr)
case (3)
! nroot depending on root efficiency
nr = nlay
crdepth = depth(nr)
case (4)
! nroot depending on soil texture and age
if (agec .lt. 15) then
i = 1
else if (agec .gt. 45) then
i = 3
else
i = 2
endif
nr = 1
if (heightc .gt. rdepth(s_typen,i)) then
hc = rdepth(s_typen,i)
else
hc = heightc
endif
do j=1,nlay
if (hc .ge. depth(j)) nr = j
enddo
if (nr .gt. nroot_max) nr = nroot_max
case (5)
alpha=0.7
if (specn .eq. 2 .or. specn .eq. 3 .or. specn .eq. 6 .or. specn .eq. 7) then
b = 7.95
else
b = 10.91
endif
troot=froot+croot
troot1=troot*anz_tree_ha ! total root biomass per ha if population of a cohort is soley comprised of trees
troot_stand=totfrt+totcrt ! total root biomass per ha calculated by 4C
troot2=troot1/10000 ! conversion to m
rootingdepth=(3*troot2**alpha)/b !Arora function
nr = 1
do j=1,nlay
if (rootingdepth*100 .ge. depth(j)) nr = j
enddo
if (nr .gt. nroot_max) nr = nroot_max
crdepth = depth(nr)
case (6) !Calculation in soil.f in cr_depth
if (crdepth .eq.0) then
! nroot depending on soil texture and age
if (agec .lt. 15) then
i = 1
else if (agec .gt. 45) then
i = 3
else
i = 2
endif
nr = 1
if (heightc .gt. rdepth(s_typen,i)) then
crdepth = rdepth(s_typen,i)
else
crdepth = heightc
endif
endif
do j=1,nlay
if (depth(j) .le. crdepth) nr=j
enddo
if (nr .gt. nroot_max) nr = nroot_max
case (7) !further growth only if next layer bears water
wat_demand=maxval(wat_root)
if (time .le. 1) then
crdepth=30.0
do j=1,nlay
if (depth(j) .le. 30.) nr=j
enddo
else
if (wat_demand .gt. 0) then
nr=1
else
nr=0
endif
endif
if (nr .gt. nroot_max) nr = nroot_max
crdepth = depth(nr)
end select
if (crdepth < 0.) then
continue
endif
END subroutine root_depth
!**************************************************************
SUBROUTINE root_ini
! Allocation and initialisation of root distribution
use data_simul
use data_soil
use data_species
use data_stand
implicit none
integer i, j, nj, rkind, hspec, ios
integer unit_root
integer nr ! aux. var. for nroot (rooting depth)
real frtrel_j, frtrel_1 ! rel fine root fraction of previous layer
real frtrel_s ! Sum of fine root fractions
real hfrt, help, troot2
real, allocatable, dimension(:,:):: hd,hr
integer, allocatable, dimension(:):: nlspec
character text
character (150) file_root
logical :: pruefer=.false.
root_fr = 0.
if (wlam(3) .gt. 0.4) then
s_typen = 1 ! sand
else if (wlam(3) .le. 0.15) then
s_typen = 4 ! clay
else if (wlam(3) .gt. 0.25) then
s_typen = 3 ! silt
else
s_typen = 2 ! loam
endif
if (nroot_max .lt. 0) then
nroot_max = 1
rkind = 4
else
rkind = 2
endif
rdepth_kind = rkind
select case (flag_wurz)
case (0,1,5)
if (anz_tree .gt. 0 .or. (anz_tree.eq.0 .and. flag_sveg .eq.1)) call root_distr
case (3,4,6)
!intercept the case that the ground vegetatuin is already initialised but no trees have been initialised so cohorts are not finalised
if (anz_tree.eq.0 .and. flag_sveg .eq.1) then
if (.not. allocated(wat_root)) then
allocate(wat_root(anz_coh))
wat_root=0.
allocate(root_lay(anz_coh))
root_lay=0
allocate(gr_depth(anz_coh))
gr_depth=0.
Pruefer=.true.
endif
else
if (Pruefer .OR. (.not. allocated(wat_root))) then
if (Pruefer) deallocate(wat_root)
allocate(wat_root(anz_coh))
wat_root=0.
if (Pruefer) deallocate(root_lay)
allocate(root_lay(anz_coh))
root_lay=0
if (Pruefer) deallocate(gr_depth)
allocate(gr_depth(anz_coh))
gr_depth=0.
Pruefer=.false.
endif
endif
if (anz_tree .gt. 0 .or. (anz_tree.eq.0 .and. flag_sveg .eq.1)) call root_distr
case (2)
! read root distribution once in the beginning alone
write (*,*)
write (*,'(A)', advance='no') 'Define root distribution, name of input file: '
read (*,'(A)') file_root
unit_root = getunit()
open (unit_root, file=trim(file_root), status='unknown')
allocate (hd(0:40, 1:nspecies))
allocate (hr(0:40, 1:nspecies))
allocate (nlspec(nspecies))
do
read (unit_root,'(A)') text
if (text .ne. '!') then
backspace(unit_root);exit
endif
enddo
ios = 0
hd = 0.
hr = 0.
nlspec = 0
do while (ios .ge. 0)
j = 1
read (unit_root, *, iostat=ios) hspec
if (ios .lt. 0) exit
read (unit_root, *, iostat=ios) hd(1,hspec), hr(1,hspec)
do while (hd(j,hspec) .ge. 0.)
nlspec(hspec) = j
j = j+1
read (unit_root, *, iostat=ios) hd(j,hspec), hr(j,hspec)
enddo
if (hd(j,hspec) .lt. depth(nlay)) hd(j,hspec) = depth(nlay)
enddo
close (unit_root)
zeig => pt%first
do while (associated(zeig))
ns = zeig%coh%species
zeig%coh%frtrel = 0.
! rel. root distribution of cohorts to species allocated
if (nlspec(ns) .gt. 0) then
frtrel_j = 0.
hfrt = 0.
j= 1
do while (hd(j,ns) .lt. depth(1))
hfrt = hfrt + hr(j,ns)
j = j+1
enddo
frtrel_j = hr(j,ns) / (hd(j,ns)-hd(j-1,ns))
hfrt = hfrt + frtrel_j * (depth(1)-hd(j-1,ns))
zeig%coh%frtrel(1) = hfrt
nj = j
do i=2,nlay
hfrt = 0.
do j = nj,nlspec(ns)+1
if (hd(j,ns) .lt. depth(i)) then
frtrel_j = hr(j,ns) / (hd(j,ns)-hd(j-1,ns))
hfrt = hfrt + frtrel_j * (hd(j,ns)-depth(i-1))
else
if (depth(i-1) .gt. hd(j-1,ns)) then
help = depth(i)-depth(i-1)
else
help = depth(i)-hd(j-1,ns)
endif
frtrel_j = hr(j,ns) / (hd(j,ns)-hd(j-1,ns))
hfrt = hfrt + frtrel_j * help
nj = j
exit
endif
enddo
zeig%coh%frtrel(i) = hfrt
enddo
else
continue
endif
frtrel_s = SUM(zeig%coh%frtrel)
zeig%coh%rooteff = 0.
zeig => zeig%next
enddo
rdepth_kind = 2
end select
END subroutine root_ini
!**************************************************************
SUBROUTINE dealloc_root
use data_simul
use data_stand
if (flag_wurz .eq. 1) then
zeig => pt%first
do while (associated(zeig))
deallocate (zeig%coh%frtrel)
deallocate (zeig%coh%rooteff)
zeig => zeig%next
enddo
endif
END subroutine dealloc_root
!**************************************************************
SUBROUTINE rootc_new (zeig1)
! root initialisation of a new cohort
use data_stand
use data_soil
implicit none
type(coh_obj), pointer :: zeig1 ! pointer variable for cohorts
real troot2
integer j, nr
allocate (zeig1%coh%frtrel(nlay))
allocate (zeig1%coh%rooteff(nlay))
zeig1%coh%frtrel = 0. ! initialisation
call root_depth (1, zeig1%coh%species, zeig1%coh%x_age, zeig1%coh%height, zeig1%coh%x_frt, zeig1%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig1%coh%nroot = nr
do j=1,nr
zeig1%coh%rooteff = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
zeig1%coh%rooteff = 0. ! layers with no roots
enddo
END subroutine rootc_new
!**************************************************************
SUBROUTINE cr_depth
! Calculation of the rooting depth after Rasse et al. 2001
use data_soil
use data_stand
use data_simul
use data_climate
use data_species
implicit none
real :: vcr ! growth rate rootdepth [cm]
integer :: j,k
vcr=0.
select case (flag_wurz)
case(4,6)
zeig => pt%first
k=1
do while (associated(zeig))
do j=1,nlay
if (zeig%coh%x_rdpt .lt. depth(j)) then
if (zeig%coh%x_age .le. 100) then
if (j .eq. 1) then
vcr=spar(zeig%coh%species)%v_growth*((100-real(zeig%coh%x_age))/100)*svar(zeig%coh%species)%Rstress(j)
zeig%coh%x_rdpt=zeig%coh%x_rdpt+(vcr/recs(time))
gr_depth(k)=zeig%coh%x_rdpt
exit
else
vcr=spar(zeig%coh%species)%v_growth*((100-real(zeig%coh%x_age))/100)*svar(zeig%coh%species)%Rstress(j)
zeig%coh%x_rdpt=zeig%coh%x_rdpt+(vcr/recs(time))
gr_depth(k)=zeig%coh%x_rdpt
exit
endif
endif
endif
enddo
if (zeig%coh%x_rdpt .gt. depth(nroot_max)) zeig%coh%x_rdpt = depth(nroot_max)
k=k+1
zeig => zeig%next
enddo
end select
END subroutine cr_depth
!*******************************************************************************
File added
// Generated by ResEdit 1.5.9
// Copyright (C) 2006-2011
// http://www.resedit.net
#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "4C_dialogs.h"
//
// Bitmap resources
//
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDB_BITMAP1 BITMAP "4c_logo_klein.bmp"
//
// Dialog resources
//
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_coh_daily DIALOG 100, 0, 540, 213
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_DAILYCOH_BUTTON_OK, 380, 190, 50, 14
PUSHBUTTON "Cancel", ID_CANCEL_OUTF, 439, 190, 50, 14
GROUPBOX "", IDC_STATIC_year, 10, 10, 510, 170
AUTOCHECKBOX "", IDC_CHECK_y1, 26, 30, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y2, 26, 45, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y3, 26, 60, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y4, 26, 75, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y5, 25, 90, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y6, 26, 105, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y7, 26, 120, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y8, 26, 135, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y9, 26, 150, 271, 8
AUTOCHECKBOX "", IDC_CHECK_y10, 26, 165, 217, 8
AUTOCHECKBOX "", IDC_CHECK_y11, 295, 30, 217, 8
AUTOCHECKBOX "", IDC_CHECK_y12, 295, 45, 217, 8
AUTOCHECKBOX "", IDC_CHECK_y13, 295, 60, 217, 8
AUTOCHECKBOX "", IDC_CHECK_y14, 295, 75, 217, 8
AUTOCHECKBOX "", IDC_CHECK_y15, 295, 90, 217, 8
AUTOCHECKBOX "", IDC_CHECK_y16, 295, 105, 217, 8
LTEXT " Choose daily cohort output files ", IDC_STATIC_yfile, 25, 10, 107, 8, SS_LEFT
AUTOCHECKBOX "", IDC_CHECK_y17, 295, 120, 217, 8
AUTOCHECKBOX "", IDC_CHECK_y18, 295, 135, 217, 8
PUSHBUTTON "Select all", ID_DAILYCOH_BUTTON_SELECT, 321, 190, 50, 14
PUSHBUTTON "Deselect all", ID_DAILYCOH_BUTTON_DESELECT, 262, 190, 50, 14
AUTOCHECKBOX "", IDC_CHECK_y19, 295, 150, 217, 8
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_coh_yearly DIALOG 0, 0, 718, 318
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_YEARLYCOH_BUTTON_OK, 559, 290, 50, 14
PUSHBUTTON "Cancel", ID_CANCEL_OUTF, 625, 290, 50, 14
GROUPBOX "", IDC_STATIC_year, 15, 10, 683, 275
AUTOCHECKBOX "", IDC_CHECK_y1, 21, 30, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y2, 20, 45, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y3, 21, 60, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y4, 21, 75, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y5, 21, 90, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y6, 21, 105, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y7, 21, 120, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y8, 21, 135, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y9, 21, 150, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y10, 21, 165, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y11, 21, 180, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y12, 21, 195, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y13, 21, 210, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y14, 21, 225, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y15, 21, 240, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y16, 21, 255, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y17, 21, 270, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y18, 244, 30, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y19, 244, 45, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y20, 244, 60, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y21, 244, 75, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y22, 244, 90, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y23, 244, 105, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y24, 244, 120, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y25, 244, 135, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y26, 244, 150, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y27, 244, 165, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y28, 244, 180, 222, 8
LTEXT " Choose yearly cohort output files ", IDC_STATIC_yfile, 30, 10, 111, 8, SS_LEFT
AUTOCHECKBOX "", IDC_CHECK_y29, 244, 195, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y30, 244, 210, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y31, 244, 225, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y32, 244, 240, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y33, 244, 255, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y34, 244, 270, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y35, 465, 30, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y36, 465, 45, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y37, 465, 60, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y38, 465, 75, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y39, 465, 90, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y40, 465, 105, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y41, 465, 120, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y42, 465, 135, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y43, 465, 150, 222, 8
PUSHBUTTON "Select all", ID_YEARLYCOH_BUTTON_SELECT, 493, 290, 50, 14
PUSHBUTTON "Deselect all", ID_YEARLYCOH_BUTTON_DESELECT, 427, 290, 50, 14
AUTOCHECKBOX "", IDC_CHECK_y44, 465, 165, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y45, 465, 178, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y46, 465, 193, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y47, 465, 210, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y48, 465, 225, 222, 8
AUTOCHECKBOX "", IDC_CHECK_y49, 465, 240, 222, 13
AUTOCHECKBOX "", IDC_CHECK_y50, 465, 255, 222, 13
AUTOCHECKBOX "", IDC_CHECK_y51, 465, 270, 222, 13
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_ctr DIALOG 100, 0, 280, 349
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_CTR_BUTTON_OK, 147, 319, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 207, 319, 50, 14
LTEXT "Edit simulation control file", IDC_STATIC_simul, 15, 14, 91, 11, SS_LEFT
GROUPBOX "Run option control", IDC_STATIC_runo, 15, 30, 241, 173
LTEXT "Run option", IDC_STATIC_runv, 23, 47, 36, 8, SS_LEFT
LTEXT "Number of runs", IDC_STATIC_runnr, 23, 68, 49, 8, SS_LEFT
COMBOBOX IDC_COMBO_runv, 69, 47, 175, 98, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
EDITTEXT IDC_EDIT_runnr, 162, 67, 40, 12, ES_AUTOHSCROLL
LTEXT "Number of simulation years", IDC_STATIC_yearn, 23, 89, 85, 8, SS_LEFT
LTEXT "Start year", IDC_STATIC_start, 23, 111, 31, 8, SS_LEFT
EDITTEXT IDC_EDIT_yearn, 162, 89, 40, 14, ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_start, 162, 111, 40, 14, ES_AUTOHSCROLL
LTEXT "Patch size [m]", IDC_STATIC_patch, 23, 134, 47, 8, SS_LEFT
EDITTEXT IDC_EDIT_patch, 162, 134, 40, 14, ES_AUTOHSCROLL
LTEXT "Thickness of foliage layers [cm]", IDC_STATIC_thickf, 23, 158, 100, 8, SS_LEFT
LTEXT "Time step photosynthesis calculations [d]", IDC_STATIC_timeph, 23, 184, 130, 8, SS_LEFT
EDITTEXT IDC_EDIT_thickf, 162, 157, 40, 14, ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_timeph, 162, 180, 40, 14, ES_AUTOHSCROLL
GROUPBOX "Run flags control", IDC_STATIC_runo3, 15, 214, 240, 93
COMBOBOX IDC_COMBO_runv3, 65, 235, 101, 98, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
LTEXT "Run number", IDC_STATIC_runv3, 23, 238, 40, 8, SS_LEFT
DEFPUSHBUTTON "Set Flags", ID_CTR_BUTTON_FLAGS, 177, 281, 65, 14
DEFPUSHBUTTON "Set Files", ID_CTR_BUTTON_FILES, 177, 258, 65, 14
DEFPUSHBUTTON "Apply", ID_CTR_BUTTON_RUNNR, 213, 66, 30, 14
DEFPUSHBUTTON "Change Output Id", ID_CTR_BUTTON_IDS, 178, 235, 64, 14
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_daily DIALOG 0, 0, 568, 221
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_DAILY_BUTTON_OK, 408, 195, 50, 14
PUSHBUTTON "Cancel", ID_CANCEL_OUTF, 471, 195, 50, 14
GROUPBOX "", IDC_STATIC_day, 11, 14, 534, 171
AUTOCHECKBOX "", IDC_CHECK_y1, 37, 30, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y2, 37, 45, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y3, 37, 60, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y4, 37, 75, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y5, 37, 90, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y6, 37, 105, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y7, 37, 120, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y8, 37, 135, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y9, 37, 150, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y10, 37, 165, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y11, 284, 30, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y12, 284, 45, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y13, 284, 60, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y14, 284, 75, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y15, 284, 90, 240, 8
LTEXT " Choose daily output files ", IDC_STATIC_yfile, 22, 15, 85, 8, SS_LEFT
AUTOCHECKBOX "", IDC_CHECK_y16, 284, 105, 240, 8
PUSHBUTTON "Select all", ID_DAILY_BUTTON_SELECT, 345, 195, 50, 14
PUSHBUTTON "Deselect all", ID_DAILY_BUTTON_DESELECT, 282, 195, 50, 14
AUTOCHECKBOX "", IDC_CHECK_y17, 284, 120, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y18, 284, 135, 240, 8
AUTOCHECKBOX "", IDC_CHECK_y19, 284, 150, 240, 8
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_default_dir DIALOG 10, 100, 320, 99
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_DEFAULT_DIR_BUTTON_OK, 138, 79, 50, 14
LTEXT "Default input and output directories", IDC_STATIC_4C, 15, 4, 216, 9, SS_LEFT
LTEXT "Input directory", IDC_STATIC_dirin, 16, 31, 51, 8, SS_LEFT
EDITTEXT IDC_EDIT_DIR_IN, 81, 27, 210, 12, ES_AUTOHSCROLL | ES_MULTILINE
LTEXT "Output directory", IDC_STATIC_dirout, 16, 56, 51, 8, SS_LEFT
EDITTEXT IDC_EDIT_DIR_OUT, 81, 52, 210, 12, ES_AUTOHSCROLL | ES_MULTILINE
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_files DIALOG 100, 0, 310, 330
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_FILES_BUTTON_OK, 189, 307, 50, 14
PUSHBUTTON "Cancel", ID_CANCEL_FILES, 251, 307, 50, 14
GROUPBOX "Model input files", IDC_STATIC_files, 7, 10, 295, 209
LTEXT "Species parameter file", IDC_STATIC_specpar, 16, 51, 70, 8, SS_LEFT
EDITTEXT IDC_EDIT_specpar, 109, 53, 146, 12, ES_AUTOHSCROLL | ES_MULTILINE
PUSHBUTTON "Browse", IDC_BUTTON_specpar, 259, 54, 35, 12, WS_GROUP
LTEXT "Soil parameter file", IDC_STATIC_sop, 16, 69, 56, 8, SS_LEFT
LTEXT "Soil initialisation file", IDC_STATIC_soi, 16, 87, 60, 8, SS_LEFT
EDITTEXT IDC_EDIT_sop, 109, 70, 146, 12, ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_soi, 109, 87, 146, 12, ES_AUTOHSCROLL
LTEXT "Stand initialisation file", IDC_STATIC_ini, 13, 238, 68, 8, SS_LEFT
EDITTEXT IDC_EDIT_ini, 107, 235, 145, 14, ES_AUTOHSCROLL
GROUPBOX "", IDC_STATIC_ini1, 7, 222, 295, 73
LTEXT "Stand identifier", IDC_STATIC_standid, 15, 256, 48, 8, SS_LEFT
PUSHBUTTON "Browse", IDC_BUTTON_ini, 259, 235, 35, 12, WS_GROUP
LTEXT "Management file", IDC_STATIC_man, 16, 107, 53, 8, SS_LEFT
EDITTEXT IDC_EDIT_man, 109, 104, 146, 12, ES_AUTOHSCROLL
LTEXT "Deposition data file", IDC_STATIC_dep, 16, 123, 61, 8, SS_LEFT
EDITTEXT IDC_EDIT_dep, 109, 121, 146, 12, ES_AUTOHSCROLL
LTEXT " N-reduction ( RedN) file", IDC_STATIC_red, 16, 141, 77, 8, SS_LEFT
LTEXT "Litter intilisation file", IDC_STATIC_lit, 16, 158, 59, 8, SS_LEFT
EDITTEXT IDC_EDIT_red, 109, 139, 146, 12, ES_AUTOHSCROLL
EDITTEXT IDC_EDIT_lit, 109, 155, 146, 12, ES_AUTOHSCROLL
PUSHBUTTON "Browse", IDC_BUTTON_sop, 259, 71, 35, 12, WS_GROUP
PUSHBUTTON "Browse", IDC_BUTTON_soi, 259, 88, 35, 12, WS_GROUP
PUSHBUTTON "Browse", IDC_BUTTON_man, 259, 105, 35, 12, WS_GROUP
PUSHBUTTON "Browse", IDC_BUTTON_dep, 259, 123, 35, 12, WS_GROUP
PUSHBUTTON "Browse", IDC_BUTTON_red, 259, 139, 35, 12, WS_GROUP
PUSHBUTTON "Browse", IDC_BUTTON_lit, 259, 156, 35, 12, WS_GROUP
LTEXT "Climate data file", IDC_STATIC_cli, 17, 32, 70, 8, SS_LEFT
EDITTEXT IDC_EDIT_cli, 110, 34, 146, 12, ES_AUTOHSCROLL | ES_MULTILINE
PUSHBUTTON "Browse", IDC_BUTTON_cli, 260, 35, 35, 12, WS_GROUP
COMBOBOX IDC_COMBO_standid, 106, 254, 85, 77, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
LTEXT "WPM spinup intilisation file", IDC_STATIC_spinup, 15, 177, 84, 8, SS_LEFT
EDITTEXT IDC_EDIT_wpm, 109, 174, 146, 12, ES_AUTOHSCROLL
PUSHBUTTON "Browse", IDC_BUTTON_wpm, 259, 175, 35, 12, WS_GROUP
EDITTEXT IDC_EDIT_standid, 106, 273, 76, 14, ES_AUTOHSCROLL
LTEXT "Measurement file", IDC_STATIC_mes, 16, 194, 54, 8, SS_LEFT
EDITTEXT IDC_EDIT_mes, 110, 191, 146, 12, ES_AUTOHSCROLL
PUSHBUTTON "Browse", IDC_BUTTON_mes, 260, 191, 35, 12, WS_GROUP
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_flags DIALOGEX 100, 0, 580, 297
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "4C"
FONT 8, "MS Sans Serif", 0, 0, 1
{
DEFPUSHBUTTON "OK", ID_FLAGS_BUTTON_OK, 443, 263, 50, 14
PUSHBUTTON "Cancel", ID_CANCEL_FLAGS, 509, 262, 50, 14
LTEXT "Mortality flag (flag_mort) ", IDC_STATIC_mort, 18, 33, 77, 8, SS_LEFT
LTEXT "Regeneration flag (flag_reg) ", IDC_STATIC_reg, 18, 50, 90, 8, SS_LEFT
LTEXT "Use FORSKA factors (flag_forska)", IDC_STATIC_forska, 18, 67, 113, 13, WS_TABSTOP | NOT WS_GROUP | SS_LEFT
LTEXT "Stand initialization flag (flag_stand)", IDC_STATIC_stand, 18, 84, 109, 8, WS_TABSTOP | NOT WS_GROUP | SS_LEFT
LTEXT "Soil vegetation flag (flag_sveg)", IDC_STATIC_sveg, 18, 101, 98, 8, SS_LEFT
LTEXT "Management flag (flag_mg)", IDC_STATIC_mg, 18, 118, 86, 8, SS_LEFT
LTEXT "Disturbance flag (flag_dis)", IDC_STATIC_dis, 18, 135, 82, 8, SS_LEFT
LTEXT "Ligth algorithm number (flag_light)", IDC_STATIC_light, 18, 152, 106, 8, SS_LEFT
LTEXT "Foliage-height relationship (flag_folhei)", IDC_STATIC_folhei, 18, 169, 120, 8, SS_LEFT
COMBOBOX IDC_COMBO_mort, 143, 33, 133, 42, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_reg, 143, 50, 133, 116, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL
COMBOBOX IDC_COMBO_forska, 143, 67, 133, 25, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
LTEXT "Volume function (flag_volfunc)", IDC_STATIC_volfunc, 18, 186, 96, 8, SS_LEFT
LTEXT "Respiration flag (flag_resp)", IDC_STATIC_resp, 18, 203, 84, 8, SS_LEFT
LTEXT "Limitation flag (flag_limi)", IDC_STATIC_limi, 18, 220, 74, 8, SS_LEFT
COMBOBOX IDC_COMBO_stand, 143, 84, 133, 54, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_sveg, 143, 101, 133, 48, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_mg, 143, 118, 133, 78, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_dis, 143, 135, 133, 32, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_light, 143, 152, 133, 55, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_folhei, 143, 169, 133, 53, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_volfunc, 143, 186, 133, 63, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
LTEXT "Decomposition model (flag_decomp) ", IDC_STATIC_decomp, 308, 33, 117, 8, SS_LEFT
LTEXT "Root activity function flag (flag_sign)", IDC_STATIC_sign, 308, 50, 115, 8, SS_LEFT
LTEXT "Soil water uptake flag (flag_wred)", IDC_STATIC_wred, 308, 67, 106, 8, SS_LEFT
LTEXT "Root distribution flag (flag_wurz)", IDC_STATIC_wurz, 308, 84, 101, 8, SS_LEFT
LTEXT "Heat conductance flag (flag_cond)", IDC_STATIC_cond, 308, 101, 111, 8, SS_LEFT
COMBOBOX IDC_COMBO_resp, 143, 203, 133, 64, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_limi, 143, 220, 133, 65, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_decomp, 431, 33, 133, 54, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_sign, 431, 50, 133, 67, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_wred, 431, 67, 133, 61, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_wurz, 431, 84, 133, 64, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_cond, 431, 101, 133, 78, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_int, 431, 118, 133, 75, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_eva, 431, 135, 133, 78, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
LTEXT "Interception flag (flag_int)", IDC_STATIC_int, 308, 118, 80, 8, SS_LEFT
LTEXT "Evapotranspiration flag (flag_eva)", IDC_STATIC_eva, 308, 135, 106, 8, SS_LEFT
LTEXT "Assortment flag (flag_sort)", IDC_STATIC_sort, 308, 169, 82, 8, SS_LEFT
COMBOBOX IDC_COMBO_CO2, 431, 152, 133, 51, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_sort, 431, 169, 133, 48, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
GROUPBOX "Model specification", IDC_STATIC_model, 0, 15, 564, 239
LTEXT "wpm flag (flag_wpm)", IDC_STATIC_wpm, 307, 186, 65, 8, SS_LEFT
COMBOBOX IDC_COMBO_wpm, 431, 186, 133, 64, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
LTEXT "Statistical analysis flag (flag_stat)", IDC_STATIC_stat, 307, 203, 104, 8, SS_LEFT
COMBOBOX IDC_COMBO_stat, 431, 203, 133, 48, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
LTEXT "CO2 flag (flag_CO2)", IDC_STATIC_CO2, 308, 152, 64, 8, SS_LEFT
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_ids DIALOG 100, 0, 130, 78
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_IDS_BUTTON_OK, 10, 55, 50, 14
GROUPBOX "Output File Identifiers", IDC_STATIC_model, 6, 14, 111, 35
EDITTEXT IDC_EDIT_ID, 14, 29, 95, 14, ES_AUTOHSCROLL
PUSHBUTTON "Cancel", ID_CANCEL_IDS, 67, 55, 50, 14
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_main DIALOGEX 300, 50, 245, 268
STYLE DS_3DLOOK | DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
EXSTYLE WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
CAPTION "4C"
FONT 8, "MS Sans Serif", 0, 0, 1
{
GROUPBOX "", IDC_STATIC_year, 5, 6, 233, 258, 0, WS_EX_STATICEDGE
CTEXT "Forest Growth Model 4C PIK 2016", IDC_STATIC_4C, 25, 53, 82, 23, SS_CENTER
DEFPUSHBUTTON "Start 4C", ID_START_4C, 103, 233, 56, 14
PUSHBUTTON "Exit 4C", IDSTOP, 174, 233, 50, 14
GROUPBOX "Simulation Control", IDC_STATIC_Control, 20, 126, 207, 68
AUTORADIOBUTTON "Start simulation", IDC_RADIO_start, 35, 148, 121, 10
AUTORADIOBUTTON "Edit control file", IDC_RADIO_edit, 35, 166, 62, 10
CONTROL "", IDC_REBAR1, REBARCLASSNAME, WS_TABSTOP | 0x00000401, 4294967294, 4294967295, 249, 4, WS_EX_DLGMODALFRAME | WS_EX_ACCEPTFILES | WS_EX_STATICEDGE
CONTROL IDB_BITMAP1, IDC_STATIC_pic, WC_STATIC, SS_BITMAP, 123, 14, 100, 104
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_out DIALOG 100, 0, 293, 212
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "Start simulation", ID_START, 89, 182, 56, 14
PUSHBUTTON "Exit 4C", IDCANCEL, 226, 182, 50, 14
LTEXT "Choice of output files", IDC_STATIC, 15, 18, 67, 8, SS_LEFT
PUSHBUTTON "Yearly output", IDC_BUTTON_yearly, 207, 37, 50, 14
PUSHBUTTON "Daily output", IDC_BUTTON_daily, 207, 60, 50, 14
PUSHBUTTON "Cohorts yearly", IDC_BUTTON_coh_yearly, 207, 84, 50, 14
PUSHBUTTON "Cohorts daily", IDC_BUTTON_coh_daily, 207, 108, 50, 14
GROUPBOX "", IDC_STATIC_choice_out, 8, 7, 268, 164
LTEXT "Summation output", IDC_STATIC_SUM, 19, 145, 58, 8, SS_LEFT
COMBOBOX IDC_COMBO_sum, 88, 142, 165, 74, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_SORT
DEFPUSHBUTTON "Back", ID_OUT_BUTTON_BACK, 161, 182, 50, 14
DEFPUSHBUTTON "Save changes", ID_SAVE, 17, 182, 56, 14
COMBOBOX IDC_COMBO_yearly, 14, 37, 181, 77, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_daily, 13, 60, 181, 77, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_coh_yearly, 13, 85, 181, 77, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
COMBOBOX IDC_COMBO_coh_daily, 13, 109, 181, 77, WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_4C_yearly DIALOG 100, 0, 606, 352
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_SYSMENU
CAPTION "4C"
FONT 8, "MS Sans Serif"
{
DEFPUSHBUTTON "OK", ID_YEARLY_BUTTON_OK, 455, 327, 50, 14
PUSHBUTTON "Cancel", ID_CANCEL_OUTF, 519, 327, 50, 14
GROUPBOX "", IDC_STATIC_year, 7, 15, 573, 302
AUTOCHECKBOX "", IDC_CHECK_y1, 21, 30, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y2, 21, 45, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y3, 21, 60, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y4, 21, 75, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y5, 21, 90, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y6, 21, 105, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y7, 21, 120, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y8, 21, 135, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y9, 21, 150, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y10, 21, 165, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y11, 21, 180, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y12, 21, 195, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y13, 21, 210, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y14, 21, 225, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y15, 21, 240, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y16, 21, 255, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y17, 21, 270, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y18, 21, 285, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y19, 21, 300, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y20, 294, 30, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y21, 294, 45, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y22, 294, 60, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y23, 294, 75, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y24, 294, 90, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y25, 294, 105, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y26, 294, 120, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y27, 294, 135, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y28, 294, 150, 270, 8
LTEXT " Choose yearly output files ", IDC_STATIC_yfile, 21, 14, 89, 8, SS_LEFT
AUTOCHECKBOX "", IDC_CHECK_y29, 294, 165, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y30, 294, 180, 270, 8
PUSHBUTTON "Select all", ID_YEARLY_BUTTON_SELECT, 391, 327, 50, 14
PUSHBUTTON "Deselect all", ID_YEARLY_BUTTON_DESELECT, 327, 327, 50, 14
AUTOCHECKBOX "", IDC_CHECK_y31, 294, 195, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y32, 294, 210, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y33, 294, 225, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y34, 294, 240, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y35, 294, 255, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y36, 294, 270, 270, 8
AUTOCHECKBOX "", IDC_CHECK_y37, 294, 285, 270, 8
}
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
IDD_DIALOG1 DIALOG 0, 0, 186, 95
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "Microsoft Sans Serif"
{
DEFPUSHBUTTON "OK", IDOK, 129, 7, 50, 14
PUSHBUTTON "Cancel", IDCANCEL, 129, 24, 50, 14
}
//
// Version Information resources
//
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 0,0,0,0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
FILEFLAGSMASK 0x0000003F
FILEFLAGS 0x00000000
{
BLOCK "StringFileInfo"
{
BLOCK "080904B0"
{
VALUE "Comments", "\0"
VALUE "CompanyName", "Potsdam-Institut fr Klimafolgenforschung\0"
VALUE "FileDescription", "FORESEE - Forest Ecosystems in a changing Environment\0"
VALUE "FileVersion", "0.99e\0"
VALUE "InternalName", "4C\0"
VALUE "LegalCopyright", "Copyright 2004\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "4C.exe\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "4C - PIK\0"
VALUE "ProductVersion", "0.99e\0"
VALUE "SpecialBuild", "\0"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0809, 0x04B0
}
}
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* SR SEED_multi *!
!* *!
!* including SR/Function *!
!* function rtflsp (regula falsi solving equation) *!
!* function weight *!
!* function weight1 *!
!* *!
!* generation of a variety of seedling cohorts for *!
!* one seed number according to seedmass distribution *!
!* (for given mean value and standard deviation) *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE seed_multi(nseed,nsp)
USE data_species
use data_stand
use data_help
use data_par
use data_soil
use data_simul
IMPLICIT NONE
integer :: nseed, nseedha, nsclass , k, j, nr
integer,dimension(:),allocatable :: nsc
real, dimension(:), allocatable :: msc, &
shooth, &
nschelp
integer :: nsp
REAL :: shoot
REAL :: ms, msclass, x1,x2,xacc,shelp, nshelp,ntot,help
REAL :: troot2
real :: standdev
real :: rtflsp, weight
TYPE(cohort) ::tree_ini
external weight
external rtflsp
if(nseed.eq.0) return
standdev = spar(nsp)%seedsd*1000.
hnspec = nsp
ms = spar(nsp)%seedmass *1000. ! g ---> mg
nseedha = nseed
nshelp = nseedha/10000.
! calculation of seed class number
if(flag_reg.eq.3) then
nsclass = int(100.*nshelp**0.6)
else if(flag_reg.eq.30) then
nsclass = int(10.*nshelp**0.6)+1
end if
allocate(nsc(nsclass))
allocate(nschelp(nsclass))
allocate(msc(nsclass))
allocate(shooth(nsclass))
! seed weight and number of seeds per class
msclass = 6.*standdev/nsclass
ntot = 0
help = (1/(sqrt(2*pi)*standdev))
do k=1, nsclass
msc(k) = (ms - 3.*standdev) + msclass*(k-1)
nschelp(k) = help*exp(-((msc(k)-ms)**2)/(2*(standdev)**2))
ntot = ntot + nschelp(k)
end do
do k= 1,nsclass
nsc(k) = nint((nschelp(k)*nseedha/ntot) + 0.5)
end do
! calculation of shoot weight per seed class and initilization
do k = 1,nsclass
mschelp = msc(k)/1000000. ! mg ---> kg
x1 = 0.
x2 = 0.1
xacc=(1.0e-10)*(x1+x2)/2
! solve mass equation; determine root
shelp=rtflsp(weight,x1,x2,xacc)
shooth(k)= shelp
max_coh = max_coh + 1
call coh_initial (tree_ini)
tree_ini%ident = max_coh
tree_ini%species = nsp
tree_ini%ntreea = nsc(k)
tree_ini%nta = nsc(k)
shoot = shooth(k)
tree_ini%x_sap = shoot ! [kg]
shoot = shoot * 1000. ! [g]
tree_ini%x_fol= (spar(nsp)%seeda*(tree_ini%x_sap** spar(nsp)%seedb)) ![kg]
tree_ini%x_frt = tree_ini%x_fol ! [kg]
! Leder
tree_ini%x_hrt = 0.
tree_ini%med_sla = spar(nsp)%psla_min + spar(nsp)%psla_a*0.5
tree_ini%t_leaf = tree_ini%med_sla* tree_ini%x_fol ! [m-2]
tree_ini%ca_ini = tree_ini%t_leaf
tree_ini%crown_area = tree_ini%ca_ini
tree_ini%underst = 1
! tranformation of shoot biomass kg --> mg
if(nsp.ne.2)tree_ini%height = spar(nsp)%pheight1*(shoot*1000.)**spar(nsp)%pheight2 ! [cm] berechnet aus shoot biomass (mg)
! Leder
if(nsp.eq.2) tree_ini%height = 10**(spar(nsp)%pheight1+ spar(nsp)%pheight2*LOG10(shoot*1000.)+ &
spar(nsp)%pheight3*(LOG10(shoot*1000.))**2)
IF(nsc(k).ne.0.) then
IF (.not. associated(pt%first)) THEN
ALLOCATE (pt%first)
pt%first%coh = tree_ini
NULLIFY(pt%first%next)
! root distribution
call root_depth (1, pt%first%coh%species, pt%first%coh%x_age, pt%first%coh%height, pt%first%coh%x_frt, pt%first%coh%x_crt, nr, troot2, pt%first%coh%x_rdpt, pt%first%coh%nroot)
pt%first%coh%nroot = nr
do j=1,nr
pt%first%coh%rooteff = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
pt%first%coh%rooteff = 0. ! layers with no roots
enddo
ELSE
ALLOCATE(zeig)
zeig%coh = tree_ini
zeig%next => pt%first
pt%first => zeig
call root_depth (1, zeig%coh%species, zeig%coh%x_age, zeig%coh%height, zeig%coh%x_frt, zeig%coh%x_crt, nr, troot2, zeig%coh%x_rdpt, zeig%coh%nroot)
zeig%coh%nroot = nr
do j=1,nr
zeig%coh%rooteff = 1. ! assumption for the first use
enddo
do j=nr+1, nlay
zeig%coh%rooteff = 0. ! layers with no roots
enddo
END IF
anz_coh=anz_coh+1
END IF
end do
deallocate(nsc)
deallocate(nschelp)
deallocate(msc)
deallocate(shooth)
END SUBROUTINE seed_multi
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! weight: seed mass function
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
function weight (x)
use data_help
use data_species
implicit none
real :: x
real :: p1,p2, weight
p1 = spar(hnspec)%seeda
p2 = spar(hnspec)%seedb
weight = p1*2*(x**p2) + x - 0.7*mschelp
end function weight
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! weight1: coarse root mass function
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
function weight1 (x)
use data_help
use data_species
real :: x
real :: p1,p2
p1 = spar(hnspec)%seeda
p2 = spar(hnspec)%seedb
weight1 = p1*(x**p2) + x - mschelp
end function weight1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! rtflsp: regula falsi solving euation
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FUNCTION rtflsp(func,x1,x2,xacc)
INTEGER MAXIT
REAL rtflsp,x1,x2,xacc,func
EXTERNAL func
PARAMETER (MAXIT=30)
INTEGER j
REAL del,dx,f,fh,fl,swap,xh,xl
fl=func(x1)
fh=func(x2)
if(fl.lt.0.)then
xl=x1
xh=x2
else
xl=x2
xh=x1
swap=fl
fl=fh
fh=swap
endif
dx=xh-xl
do j=1,MAXIT
rtflsp=xl+dx*fl/(fl-fh)
f=func(rtflsp)
if(f.lt.0.) then
del=xl-rtflsp
xl=rtflsp
fl=f
else
del=xh-rtflsp
xh=rtflsp
fh=f
endif
dx=xh-xl
if(abs(del).lt.xacc.or.f.eq.0.)return
end do
END function rtflsp
\ No newline at end of file
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* - Simulation initialisation (SIM_INI) *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE sim_ini
use data_biodiv
use data_climate
use data_depo
use data_evapo
use data_inter
use data_manag
use data_simul
use data_site
use data_stand
use data_soil
use data_soil_cn
use data_species
use data_par
use data_frost
implicit none
type(Coh_Obj), pointer :: p ! pointer to cohort list
anz_sim = anz_sim + 1
time = 0
time_cur = time_b - 1 ! before Sim.-Start in year_ini time_cur=time_cur+1
iday = 0
act_thin_year = 1
flag_cum = 0
flag_lit = 0
flag_sens = 0
flag_redn = .FALSE.
lai=0.
gp_can = 0.
sumbio = 0.
totfrt = 0.
sumNPP = 0.
nppsum = 0.
gppsum = 0.
cum_sumNPP= 0.
NEE_mon = 0.
NPP_mon = 0.
autresp = 0.
autresp_m = 0.
anrspec = 0
anz_coh = 0
anz_spec = 0
anz_tree = 0
med_diam = 0.
hdom = 0.
mean_drIndAl = 0.
med_air = 0.
med_rad = 0.
med_air_cm = 0.
med_air_wm = 0.
med_air_ms = 0.
med_air_mj = 0.
med_wind = 0.
temp_mon = 0.
prec_mon = 0.
sum_prec = 0.
sum_prec_ms= 0.;
sum_prec_mj= 0.
gdday = 0.
days_summer = 0
days_hot = 0
days_ice = 0
days_dry = 0
days_hrain = 0
days_rain = 0
days_rain_mj= 0
days_snow = 0
days_wof = 0
gdday_all = 0.
med_air_all = 0.
sum_prec_all = 0.
med_rad_all = 0.
int_cum_can = 0.
int_cum_sveg = 0.
interc_m_can = 0.
interc_m_sveg= 0.
perc_cum = 0.
perc_mon = 0.
wupt_cum = 0.
wupt_r_c = 0.
wupt_e_c = 0.
tra_tr_cum = 0.
tra_sv_cum = 0.
dew_m = 0.
aet_cum = 0.
pet_cum = 0.
pet_m = 0.
AET_m = 0.
wupt_r_m = 0.
perc_m = 0.
wat_tot = 0.
gp_can_mean = 0.
gp_can_max = 0.
snow = 0.
snow_day = 0
totFPARcan = 0.
Rnet_cum = 0.
! fire index
fire(1)%mean_m = 0
fire(2)%mean_m = 0
fire(3)%mean_m = 0
fire_indb_m = 0
ind_arid_an = 0.
ind_lang_an = 0.
ind_cout_an = 0.
ind_wiss_an = 0.
ind_mart_an = 0.
ind_mart_vp = 0.
ind_emb = 0.
ind_weck = 0.
ind_reich = 0.
con_gor = 0.
con_cur = 0.
con_con = 0.
cwb_an = 0.
cwb_an_m = 0.
ind_bud = 0.
ind_shc = 0.
ind_arid_an_m = 0.
ind_lang_an_m = 0.
ind_cout_an_m = 0.
ind_wiss_an_m = 0.
ind_mart_an_m = 0.
ind_mart_vp_m = 0.
ind_emb_m = 0.
ind_weck_m = 0.
ind_reich_m = 0.
con_gor_m = 0.
con_cur_m = 0.
con_con_m = 0.
ind_bud_m = 0.
ind_shc_m = 0.
ntindex = 0.
tempmean_mo = 0
aet_dec = 0.
temp_dec = 0.
prec_dec = 0.
rad_dec = 0.
hum_dec = 0.
! frost index
if(flag_climtyp .ge. 3) then
! calculation for airtemp_min > -90.
tminmay=0
lfind=0
dlfabs=0.
tminmay_sp=0
dlfabs_sp=0.
flag_tveg=0
else
tminmay=-99
lfind=-99
dlfabs=-99.
tminmay_sp=-99
dlfabs_sp=-99.
flag_tveg=-99
endif
!! initialisation of root distribution
RedN_mean = 0.
anz_RedN = 0
N_min = 0.
N_min_m = 0.
resps_c = 0.
resps_c_m = 0.
resps_mon = 0.
N_tot = 0.
N_an_tot = 0.
N_hum_tot = 0.
C_tot = 0.
C_hum_tot = 0.
N_lit = 0.
C_lit = 0.
Nupt_c = 0.
Nupt_m = 0.
C_accu = 0.
Nleach_c = 0.
Nleach_m = 0.
N_lit_m = 0.
C_lit_m = 0.
totfol_lit = 0.
totfol_lit_tree = 0.
totfrt_lit = 0.
totfrt_lit_tree = 0.
tottb_lit = 0.
totcrt_lit = 0.
totstem_lit = 0.
C_opm_fol = 0.
C_opm_frt = 0.
C_opm_crt = 0.
C_opm_tb = 0.
C_opm_stem = 0.
N_opm_stem = 0.
N_opm_fol = 0.
N_opm_frt = 0.
N_opm_crt = 0.
N_opm_tb = 0.
Ndep_cum = 0.
Ndep_cum_all= 0.
if (flag_multi .ne. 8) then
if ((flag_multi .ne. 2) .or. (ip .le. 1)) then
NOdep(ip) = 0.
NHdep(ip) = 0.
endif
endif
flag_bc = 0
totsteminc = 0.
cumsteminc = 0.
cumsumvsdead = 0.
cumsumvsab = 0.
sumvsdead = 0.
sumvsab = 0.
p => pt%first
do while (associated(p))
p%coh%N_pool = 0.
p => p%next
enddo ! p (cohorts)
allocate(dayfract(ns_pro))
! fields for frost index
allocate(dnlf(year))
allocate(tminmay_ann(year))
allocate(date_lf(year))
allocate(date_lftot(year))
allocate(dnlf_sp(year))
allocate (anzdlf(year))
allocate (sumtlf(year))
dnlf_sp=0
dnlf = 0
tminmay_ann = 0.
date_lf = 0
date_lftot = 0
anzdlf = 0.
sumtlf = 0.
end subroutine sim_ini
\ No newline at end of file
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* - Simulation control: SIM_CONTROL *!
!* SIMULATION_4C *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE sim_control
use data_climate
use data_simul
use data_site
use data_out
implicit none
integer run_nr, ipp, irl, icl, i
character a
character(8) actdate
character(10) acttime, helpsim, text1, text2
real time1, time2, time3
unit_err=getunit()
if(flag_multi.eq.5) dirout = './'
open(unit_err,file=trim(dirout)//trim(site_name(1))//'_error.log',status='replace', position='append')
unit_trace=getunit()
open(unit_trace,file=trim(dirout)//trim(site_name(1))//'_trace.log',status='replace', position='append')
write (unit_trace, *) ' Trace of calls - subroutines of 4C '
write (unit_trace, *)
write (unit_trace, *) 'iday time_cur subroutine '
write (unit_trace, '(I4,I10,A)') iday, time_cur, ' sim_control'
! check daily output
if (year > 5 .and. flag_dayout .ge. 1) then
write(*,*) ' Warning: Your choice of daily output is ON with a simulation time of'
write(*,'(I6,A,I8,A)') year,' years. This option will create ',365*year,' data records per file!'
write(*,'(A)',advance='no') ' Do you really want do use daily output (y/n)? '
read *,a
IF (a .eq. 'n' .or. a .eq. 'N') then
flag_dayout = 0
ENDIF
ENDIF
! open file ycomp (yearly compressed output (multi run))
IF (time_out .ne. -2) call prep_out_comp
!call epsilon
IF(flag_multi.eq.1) THEN
run_nr = site_nr
ELSE IF (flag_multi.eq.5) THEN
run_nr = 1
ELSE
run_nr = repeat_number
ENDIF
call date_and_time(actdate, acttime)
write (unit_err, *)
time3 = 0.
if (.not.flag_mult910) then
nrreal = 1
nrclim = 1
endif
do icl = 1, nrclim ! climate scenarios
iclim = icl
DO ipp = 1, run_nr ! sites
ip = ipp
if (flag_trace) write (unit_trace, '(I4,I10,A,I3)') iday, time_cur, ' sim_control ip=',ip
do irl = 1, nrreal ! realization f climate scenarios
if (flag_mult910) then
climfile(ip) = climszenfile(ip, icl, irl)
site_name (ip) = trim(site_name1)//'_'//trim(sitenum(ip))
write (helpsim,'(I10)') icl
read (helpsim,*) text1
write (helpsim,'(I10)') irl
read (helpsim,*) text2
site_name (ip) = trim(site_name (ip))//'_'//trim(text1)//'_'//trim(text2)
write (unit_err, *)
write (unit_err, '(A,3I5,2X, A50)')'* ip, cli-scenario, real., site: ', ip, icl, irl, site_name(ip)
write (unit_err, '(A,A)') 'Climate file: ', trim(climfile(ip))
else
write (unit_err, *)
write (unit_err, '(A10,I5,2X, A50)') ' ip/site ', ip, trim(site_name(ip))
site_name1 = trim(site_name(ip))
endif
call CPU_time (time1)
if(ip.ne.0) then
CALL sim_ini
CALL prepare_site
if (flag_multi.eq.5) then
! call m4c_simenv_in
unit_comp2 = 6 ! standard output
end if
if(flag_end.gt.0) then
select case (flag_end)
case (1)
print*,ip, ' stop in prepare_stand (see error.log)'
case (2)
print*, ip, 'stop in prepare_stand, stand ', &
'identificator not found in prepare_stand'
case (3)
print*,ip, 'stop in canopy'
case (4)
print*,ip, 'stop in readsim, climate ID not found'
case (5)
print*,ip, ' stop in readsoil, soil ID not found ', adjustl(soilid(ip))
case (6)
write(*,'(A,I5)') ' >>>foresee message: stop in read_cli, no climate data for year ',time_b
call finish_simul
stop
case (7)
print*,ip, ' stop in readsoil, error during reading soil data ', adjustl(soilid(ip))
call finish_simul
stop
case default
print*,ip, 'flag_end = ', flag_end
end select
call finish_simul
flag_end = 0
else
IF(flag_multi==2) CALL fixclimscen
if (.not.flag_mult910) then
write (*,*)
write (*,*) '>>> Start FORESEE-Simulation site ', ipp
write (*,*)
endif
CALL simulation_4c
CALL finish_simul
endif
if (flag_mult910) then
call out_var_stat(1, irl)
else
if ((flag_multi .ne. 8) .and. (nvar .gt. 1)) call out_var_stat(3, 1)
endif
endif ! flag_end
call CPU_time (time2)
if (.not.flag_mult910) then
print *, ' run time for simulation ',ip, time2-time1, ' sec'
endif
write (unit_err, *) ' run time for simulation ',ip, time2-time1, ' sec'
time3 = time3 + (time2-time1)
enddo ! irl
if (flag_mult910) call out_var_stat(2, -99)
write (unit_err, *)
write (unit_err, *)
write (unit_err, *) '* * * * * New ip/site * * * * *'
ENDDO ! ip until site_nr (page number)
write (unit_err, *)
write (unit_err, *) '************ New climate scenario **********'
enddo ! icl
if (nvar .gt. 1) then
select case (flag_multi)
case (5, 9, 10)
continue
case (1)
continue
case default
call out_var_file
end select
endif
! comparison with measurements
if (flag_stat .gt. 0) CALL mess
call CPU_time (time1)
time3 = time3 + (time1-time2)
write (unit_err, *)
write (unit_err, *) ' total run time ', time3, ' sec'
CALL finish_all
PRINT *,'All simulations finished!'
END SUBROUTINE sim_control
!**************************************************************
SUBROUTINE simulation_4C
!*** Declaration part ***!
USE data_simul
USE data_species ! species specific parameters
USE data_site ! site specific data
USE data_climate ! climate data
USE data_soil
USE data_soil_cn
USE data_stand ! state variables of stand, cohort and cohort element
USE data_out
USE data_manag
USE data_plant
USE data_par
IMPLICIT NONE
if (flag_trace) write (unit_trace, '(I4,I10,A)') iday, time_cur, ' simulation_4C'
! allocation of environmental variable fields
if(flag_wpm.ne.4 .and. flag_wpm.ne.5.and.flag_wpm.ne.6) then
! time loop
DO time = 1, year
iday = 1
! Update population variable for new year if population is changed through interventions
if (flag_standup .gt. 0 .or. flag_dis==1 .or. flag_dis==1) then
call stand_balance
call standup
flag_standup = 0
endif
CALL year_ini
! Calculate RedN from soil C/N
! read or create Redn for areal application
IF (time.EQ.1 .and. flag_redn) CALL RedN_ini
IF (flag_dis .eq. 1 .or. flag_dis .eq. 2) then
CALL dis_manag
endif
! simulation of processes with subannual resolution (fluxes and soil)
CALL stand_daily
if(flag_end.ge.1) exit ! exit do loop time
! compressed output of start values
IF (lcomp1) THEN
CALL out_comp(unit_comp1)
lcomp1 = .FALSE.
ENDIF
! cohort litter production
CALL senescence
! calculation of stand variables over all patches
CALL stand_balance
! calculation of soil variables for yearly output
CALL s_year
! calculation of fire variables for yearly output
CALL fire_year
! calculation of indices for yearly output
CALL t_indices(temp_mon)
! summation output
IF(flag_sum.eq.4) THEN
write(unit_sum,'(I5,9F11.3)') time_cur,photsum,npppotsum,nppsum,resosum,lightsum,nee,abslightsum,precsum, tempmean
photsum=0.;npppotsum=0.;nppsum=0.;resosum=0.;lightsum=0.;nee=0.;abslightsum=0.;precsum=0.
ENDIF
totsteminc = 0.
totsteminc_m3 = 0.
! cohort loop for change in crown dimensions, allocation and tree dimension calculations
zeig=>pt%first
DO
IF (.not.ASSOCIATED(zeig)) exit
IF (zeig%coh%height.ge.thr_height .and. zeig%coh%species.le.nspec_tree) then
! determine crown movement
CALL CROWN( zeig )
! allocate NPP to the various tree compartments
CALL PARTITION( zeig )
if(flag_end.ge.1) exit ! do loop
ENDIF
IF (zeig%coh%species.EQ.nspec_tree+1) then ! Ground vegetation
! allocate NPP to the various ground vegetation compartments
CALL PARTITION_SV( zeig )
ENDIF
IF (zeig%coh%species.eq.nspec_tree+2) then ! Mistletoe
CALL PARTITION_MI( zeig )
if(flag_end.ge.1) exit ! do loop
ENDIF
zeig=>zeig%next
END DO
if(flag_end.ge.1) exit ! exit do loop time
! calculation of annual mortality
IF(flag_mort.ge.1) CALL stand_mort
! annual growth of trees below thr_height, which are initialized by planting (not seeded!)
! at the beginning of the simulation or during management (shelter-wood)
if(flag_reg.ne.2.and.flag_sprout.eq.0) CALL growth_seed
CALL mort_seed
if(flag_sprout.eq.1) flag_sprout=0
IF(flag_mg==1) then
if(thin_year(act_thin_year)==time_cur) then
CALL management
act_thin_year = act_thin_year+1
end if
ELSE IF((flag_mg.ge.2 .or. flag_mg.eq.3 .or. flag_mg.eq.33.or. flag_mg.eq.9 .or. flag_mg.eq.10 .or. flag_mg.eq. 333).and.anz_spec.ne.0) THEN
CALL management
if(flag_wpm.ne.0) CALL timsort
ENDIF
! no assortment if wpm is not called
if(flag_mg.eq.0.and.anz_spec.ne.0) then
if(flag_wpm.ne.0) call timsort
end if
CALL litter
! input of dead biomass into soil compartments
CALL cn_inp
! if(flag_multi.eq.5) call m4c_simenv_out
! annual establishment for all species
IF (flag_reg.eq.1.or.flag_reg.eq.2.or.flag_reg.eq.3.or.flag_reg.eq.30) CALL stand_regen
! cumsteminc = cumsteminc + totsteminc
! planting of seedlings/saplings at the beginning of simulation
if(flag_reg.ge.9..and. flag_reg.lt.100. .and. time.eq.1) call planting
if(flag_reg.ge.9..and. flag_reg.lt.100. .and. flag_mg .eq.44) call planting
! Update stand variables if stand changed
if (flag_standup.gt.0 .or. anz_spec.eq.0) then
call stand_balance
! if (flag_standup .gt. 1) call root_distr ! wird generell in year_ini berechnet
endif
cumsteminc = cumsteminc + totsteminc
! yearly output
IF (time_out .gt. 0) THEN
IF (mod(time,time_out) .eq. 0) then
CALL outyear (1)
CALL outyear (2)
endif
ENDIF
! store of output variables (multi run 4, 8, 9)
IF (nvar .gt. 1) CALL outstore
! RedN calculation
if ((flag_limi .eq. 10) .or. (flag_limi .eq. 15)) call RedN_calc
! CALL list_cohort
CALL del_cohort
if (.not.flag_mult910) PRINT *, ' * Year ', time, time_cur,' finished... '
END DO ! time
! calculation of stand variables over all patches at the end!
CALL stand_balance
!***** wpm ******
! check if management
if(flag_mg == 0) then
flag_wpm = 0
endif
if (flag_wpm == 1 .or. flag_wpm == 21 .or. flag_wpm == 11) call wpm
if (flag_wpm == 2) call sea
if (flag_wpm == 3) then
call wpm
call sea
end if
!*** * * * * * * * ****
else
call wpm
end if
if (flag_wpm .gt. 0) call out_wpm(1)
CALL out_comp(unit_comp2)
if(flag_end.eq.1) print*,ip, 'stop in partitio'
if(flag_end.eq.3) print*,ip, 'stop in calc_la in canopy: toplayer = 125 m'
flag_end = 0
if (.not.flag_mult910) PRINT *, ' * Simulation ',ip,' finished.'
END SUBROUTINE simulation_4C
!**************************************************************
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* Soil and Water - Programs *!
!* *!
!* contains: *!
!* SOIL *!
!* SOIL_INI *!
!* SOIL_WAT *!
!* UPT_WAT *!
!* FRED1 - ...11 *!
!* TAKE_WAT *!
!* BUCKET *!
!* SNOWPACK *!
!* HUM_ADD *!
!* BC_APPL: application of biochar *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE soil
! Soil processes (frame)
use data_climate
use data_depo
use data_out
use data_simul
use data_soil
use data_soil_cn
implicit none
call evapo
call intercep
call soil_wat
call soil_temp
if (flag_wurz .eq. 4 .or. flag_wurz .eq. 6) then
call soil_stress !calculate ground stress factors
call cr_depth !define root depth
endif
call soil_cn
call root_eff
END subroutine soil
!**************************************************************
SUBROUTINE soil_ini
! Initialisation of soil data and parameters
use data_inter
use data_evapo
use data_out
use data_par
use data_simul
use data_soil
use data_soil_cn
use data_species
use data_stand
implicit none
integer i,j,k
real d_0, t_0
! Table of quarz and clay content (mass%) versus wlam
real, dimension(17) :: xwlam = (/1.5, 1.15, 0.9, 0.67, 0.6, 0.5, 0.38, 0.37, 0.3, 0.29, 0.27, 0.26, 0.25, 0.24, 0.23, 0.22, 0.15/), &
yquarz = (/93.0,85.0,80.0, 82.0,76.0, 64.0, 65.0, 51.0,60.0, 30.0, 14.0, 10.0, 12.0, 20.0, 30.0, 43.0, 23.0/), &
yclay = (/3.0, 3.0, 3.0, 12.0, 6.0, 6.0, 10.0, 4.0,21.0, 12.0, 10.0, 37.0, 15.0, 40.0, 30.0, 35.0, 55.0/)
real value
real, dimension(nlay):: humush(nlay)
real, dimension(nlay):: xfcap, xwiltp, xpv ! output of addition for water capacities
! estimation of soil layer values
d_0 = 0.
do j = 1, nlay
t_0 = thick(j)
mid(j) = d_0 + 0.5*t_0
d_0 = d_0 + t_0
depth(j) = d_0
enddo
perc = 0.
wupt_r = 0.
wupt_ev = 0.
thick_1 = thick(1)
select case (flag_soilin)
case (0,2)
do i=1,nlay
if (i .gt. 1) then
call tab_int(xwlam, yquarz, 17, wlam(i), value)
sandv(i) = value / 100. ! Mass% of mineral fraction
call tab_int(xwlam, yclay, 17, wlam(i), value)
clayv(i) = value / 100.
siltv(i) = 1. - clayv(i) - sandv(i)
else
sandv(1) = 0.0
clayv(1) = 0.0
siltv(1) = 0.0
endif
enddo
case (1,3,4)
clayv = clayv / 100.
sandv = sandv / 100.
siltv = 1. - clayv - sandv
if ((sandv(1) .le. zero) .and. (clayv(1) .le. zero)) siltv(1) = 0.
skelv = skelv / 100.
humusv = humusv / 100.
end select
! Settings for subroutine take_wat
skelfact = 1.
pv = skelfact * pv_v * thick * 0.1 ! mm
wilt_p = skelfact * wilt_p_v * thick * 0.1 ! mm
field_cap = skelfact * f_cap_v * thick * 0.1 ! mm
wats = field_cap ! mm
watvol = f_cap_v ! vol%
n_ev_d = nlay
nlgrw = nlay+1
do i=1,nlay
if (w_ev_d .gt. depth(i)) n_ev_d = i
if (grwlev .gt. depth(i)) nlgrw = i+1
vol(i) = thick(i) * 10000.
enddo
! dry mass of first layer
dmass = vol * dens
rmass1 = dmass(1) - (C_hum(1) + C_opm(1)) / cpart ! corection term of first layer
humush = humusv
if (2.*C_hum(1) .lt. humusv(1)*dmass(1)) then
humusv(1) = C_hum(1) / (dmass(1) * cpart)
endif
do i=2, nlay
humusv(i) = C_hum(i) / (dmass(i) * cpart)
enddo
if (flag_bc .gt. 0) y_bc_n = 1 ! actual number of biochar application
! calculation of additions for water capacities
call hum_add(xfcap, xwiltp, xpv)
fcaph = f_cap_v - xfcap
wiltph = wilt_p_v - xwiltp
pvh = pv_v - xpv
! ground water
do i = nlgrw, nlay
wats(i) = pv(i)
enddo
interc_can = 0.
int_st_can = 0.
interc_sveg = 0.
int_st_sveg = 0.
aev_i = 0.
wat_tot = SUM(wats)
END subroutine soil_ini
!**************************************************************
SUBROUTINE soil_wat
use data_out
! soil water balance
use data_climate
use data_evapo
use data_inter
use data_out
use data_par
use data_simul
use data_soil
use data_species
use data_stand
implicit none
real :: eva_dem ! evaporation demand of soil
real :: p_inf = 0. ! infiltrated water
real :: pev ! local: soil evaporation
real :: watot, wetot ! total water content at start and end
real :: wutot ! total water uptake from the soil
real :: wutot_ev ! total water uptake by soil evaporation
real :: wutot_r ! total water uptake by roots
real, allocatable, dimension(:) :: upt ! local array for uptake
real, external :: wat_new
real enr, wa, we, percolnl, snow_sm, buckdepth
integer j
allocate (upt(nlay))
wupt_ev = 0.
aev_s = 0.
prec_stand = MAX(0., prec - interc_can - interc_sveg) ! stand precipitation
if (flag_int .gt. 1000) then
prec_stand = prec_stand * prec_stand_red / 100.
endif
call snowpack(snow_sm, p_inf, pev)
if (anz_coh .le. 0) pev = pet
eva_dem = MAX(0., p_inf) - pev ! evaporation demand of soil
! if all stand precipitation is evaporated and there is still a demand
! there is an uptake from soil layers (up to an certain depth)
if (eva_dem .lt. 0.) then
if (snow .le. 0) call take_wat(eva_dem, cover)
aev_s = aev_s + p_inf + SUM(wupt_ev)
else
aev_s = aev_s + pev
endif ! eva_dem
aet = aev_s + aev_i
p_inf = MAX(eva_dem, 0.)
upt = wupt_ev
watot = SUM(wats) ! total initial water content
do j = 1, nlgrw-1
enr = p_inf - upt(j)
wa = wats(j) - field_cap(j)
we = wat_new(wa, enr, j)
p_inf = enr + wa - we
perc(j) = MAX(p_inf, 0.)
wats(j) = MAX(we+field_cap(j), wilt_p(j))
enddo
do j = nlgrw, nlay
enr = p_inf - upt(j)
wa = wats(j) - field_cap(j)
we = pv(j) - field_cap(j) ! ground water level is constant!
p_inf = enr + wa - we
perc(j) = MAX(p_inf, 0.)
wats(j) = MAX(we+field_cap(j), wilt_p(j))
enddo
if (flag_wred .le. 10) then
call upt_wat
else
call upt_wat1
endif
! root uptake balanced imediate after calculation
upt = upt + wupt_r
wats = wats - wupt_r
watvol = 10.*wats/(thick * skelfact) ! estimation for complete layer in Vol% without skeleton (only soil substrate)
! total water quantities
wetot = SUM(wats) ! total final water content
wutot_ev = SUM(wupt_ev) ! total water uptake by soil evaporation
wutot_r = SUM(wupt_r) ! total water uptake by roots
wutot = wutot_ev + wutot_r ! total water uptake
aet = aet + wutot_r ! daily total aet
percolnl = perc(nlay)
trans_tree = 0.
trans_sveg = 0.
zeig => pt%first
do while (associated(zeig))
if (zeig%coh%species .le. nspec_tree) then
trans_tree = trans_tree + zeig%coh%supply
else
trans_sveg = trans_sveg + zeig%coh%supply
endif
zeig => zeig%next
enddo ! zeig (cohorts)
! cumulative water quantities
perc_cum = perc_cum + perc(nlay)
wupt_r_c = wupt_r_c + wutot_r
wupt_e_c = wupt_e_c + wutot_ev
wupt_cum = wupt_cum + wutot
aet_cum = aet_cum + aet
dew_cum = dew_cum + dew_rime
tra_tr_cum = tra_tr_cum + trans_tree
tra_sv_cum = tra_sv_cum + trans_sveg
call bucket(bucks_100, bucks_root, buckdepth)
! number of drought days per layer
where ((wats-0.2) .le. wilt_p) s_drought = s_drought+1
if (flag_dayout .ge. 2) then
write (unit_wat, '(2I5, 7F7.2, 24F8.2)') time_cur, iday, airtemp, prec, interc_can, int_st_can, &
interc_sveg, int_st_sveg, snow, snow_sm, pet, trans_dem, &
pev, aev_s, aev_i, perc(nlay), watot, wetot, wutot, wutot_ev, wutot_r,&
trans_tree,trans_sveg, eva_dem, gp_can, aet, ceppot_can, ceppot_sveg
endif
deallocate (upt)
END subroutine soil_wat
!**************************************************************
SUBROUTINE upt_wat
! Water uptake by roots
use data_simul
use data_evapo
use data_soil
use data_stand
use data_par
use data_species
use data_climate
implicit none
real, dimension(1:anz_coh) :: tr_dem ! auxiliary arrays for cohorts
real wat_ava, hdem, frtrel, frtrel_1, hupt, hupt_c, totfrt_2, hv, demand_mistletoe_canopy
real wat_at ! total available water per layer
real wat_ar ! total available water per layer with uptake resistance
real hred ! resistance coefficient
real, external :: fred1, fred2, fred3, fred4, fred5, fred6, fred7, fred11
integer i, ianz, j, nroot3
! Calculation of Water Demand
ianz = anz_coh
tr_dem = 0
hdem = 0
hv = pet-aev_i-pev_s
if (hv .lt. 0.) hv = 0.
select case (flag_eva)
case (0,1,3)
if((pet .gt. 0.) .and. (hv .gt. 0.)) then
trans_dem = hv * alfm * (1. - exp(-gp_tot/gpmax)) ! pet (potential evapotranspiration) is reduced by intereption evaporation and potential ground evaporation
else
trans_dem = 0.0
endif
if (gp_tot .gt. zero) then
hdem = trans_dem / gp_tot
else
hdem= 0.
endif
case (8)
! potential transpiration demand of each cohort
if ((gp_tot .gt. zero) .and. (hv .gt. 0.)) then
hdem = (pet-aev_i-aev_s) / gp_tot
else
hdem= 0.
endif
case (2,4)
trans_dem = 0.
case (6,16,36)
! Eucalyptus
hv = pet
if((pet .gt. 0.) .and. (hv .gt. 0.)) then
trans_dem = hv * alfm * (1. - exp(-gp_tot/gpmax))
else
trans_dem = 0.
endif
! preparation: potential transpiration demand of each cohort
if (gp_tot .gt. zero) then
hdem = trans_dem / gp_tot
else
hdem= 0.
endif
case (7,17,37)
trans_dem = hv
! potential transpiration demand of each cohort
if (gp_tot .gt. zero) then
hdem = trans_dem / gp_tot
else
hdem= 0.
endif
end select
hdem = max(0., hdem)
! Distribution of total Demand into Demands of Cohorts
!extraction of demand of mistletoe cohort (for case flag eva = 1,3,6,7...)
zeig => pt%first
do while (associated(zeig))
if (zeig%coh%species.eq.nspec_tree+2) then
demand_mistletoe_canopy=zeig%coh%gp * zeig%coh%ntreea * hdem
end if
zeig => zeig%next
enddo
zeig => pt%first
i = 1
do while (associated(zeig))
select case (flag_eva)
case (0, 1, 3, 6, 7, 16, 17, 36, 37)
!uppermost tree cohort (with flag mistletoe) gets additinal demand of mistletoe
if (zeig%coh%mistletoe.eq.1) then
zeig%coh%demand = zeig%coh%gp * zeig%coh%ntreea * hdem + demand_mistletoe_canopy
elseif (zeig%coh%species.eq.nspec_tree+2) then ! set demand of mistletoe to zero as it will be fullfilled by the tree
zeig%coh%demand=0. ! set to zero because demand has been added to the infested tree cohort
else
zeig%coh%demand = zeig%coh%gp * zeig%coh%ntreea * hdem ! all other cohorts get their demand
end if
case (2,4)
!uppermost tree cohort (with flag mistletoe) gets additinal demand, that of mistletoe
if (zeig%coh%mistletoe.eq.1) then
zeig%coh%demand = (max(0., zeig%coh%demand - zeig%coh%aev_i) + demand_mistletoe_cohort)
endif
if (zeig%coh%species.eq.nspec_tree+2) then ! set demand of mistletoe to zero as it will be fullfilled by the tree
zeig%coh%demand=0.
endif
if (zeig%coh%mistletoe.ne.1 .AND. zeig%coh%species.ne.nspec_tree+2) then
zeig%coh%demand = max(0., zeig%coh%demand - zeig%coh%aev_i)
end if
trans_dem = trans_dem + zeig%coh%demand
end select
tr_dem(i) = zeig%coh%demand ! demand of transpiration per cohort
i = i + 1
zeig => zeig%next
enddo ! zeig (cohorts)
! Calculation of Water Supply
frtrel_1 = 1.
select case (flag_wurz)
case (0)
if (nroot_max .gt. 5) then
nroot3 = 5
else
nroot3 = nroot_max
endif
case default
nroot3=nroot_max
end select
! layers with seedlings
do j = 1,nroot3
! determination of resisctance coefficient
select case (flag_wred)
case(1)
hred = fred1(j)
case(2)
hred = fred2(j)
case(3)
hred = fred3(j)
case(4)
hred = fred4(j)
case(5)
hred = 1.
case(6)
hred = 0.5
case(7)
hred = 0.25
case(8)
hred = fred6(j)
case(10)
hred = fred7(j)
case(11)
hred = fred11(j)
end select
wat_res(j) = hred
if (temps(j) .gt. -0.3) then
wat_at = max(wats(j) - wilt_p(j), 0.) ! total available water per layer
wat_ar = hred * wat_at ! total available water per layer with uptake resistance
hupt = 0.
else
wat_ar = 0. ! frost
wat_at = 0.
hupt = 0.
endif
! Distribution of Water Supply into the Cohorts
! Distribution of Fine Roots
zeig => pt%first
i = 1 ! cohort index
do while (associated(zeig))
if (zeig%coh%species .ne. nspec_tree+2) then ! not for mistletoe
frtrel = zeig%coh%frtrelc(j)
wat_ava = frtrel * wat_ar ! available water per tree cohort and layer
if (wat_ava .ge. tr_dem(i)) then
hupt_c = tr_dem(i)
tr_dem(i) = 0.
else
hupt_c = wat_ava
tr_dem(i) = tr_dem(i) - wat_ava
endif
select case (flag_dis) !xylem clogger disturbance
case (1,2)
hupt_c = hupt_c * xylem_dis
end select
xwatupt(i,j) = hupt_c ! water uptake per cohorte and layer
zeig%coh%supply = zeig%coh%supply + hupt_c
if (zeig%coh%supply .lt.0.) then
continue
endif
hupt = hupt + hupt_c
i = i + 1
end if ! exclusion of mistletoe
zeig => zeig%next
enddo ! zeig (cohorts)
wupt_r(j) = hupt
enddo ! j
! layers without seedlings
if (totfrt_p.gt.(seedlfrt+zero)) then
totfrt_2 = 1./(totfrt_p-seedlfrt)
do j = nroot3+1, nroot_max
! determination of resisctance coefficient
select case (flag_wred)
case(1)
hred = fred1(j)
case(2)
hred = fred2(j)
case(3)
hred = fred3(j)
case(4)
hred = fred4(j)
case(5)
hred = 1.
case(6)
hred = 0.5
case(7)
hred = 0.25
end select
wat_res(j) = hred
if (temps(j) .gt. -0.3) then
wat_at = max(wats(j) - wilt_p(j), 0.) ! total available water per layer
wat_ar = hred * wat_at ! total available water per layer with uptake resistance
hupt = 0.
else
wat_ar = 0.
endif
zeig => pt%first
i = 1 ! cohort index
do while (associated(zeig))
frtrel = zeig%coh%frtrelc(j)
wat_ava = frtrel * wat_ar ! available water per tree cohort and layer
if (wat_ava .ge. tr_dem(i)) then
hupt_c = tr_dem(i)
tr_dem(i) = 0.
else
hupt_c = wat_ava
tr_dem(i) = tr_dem(i) - wat_ava
endif
select case (flag_dis) !xylem clogger disturbance
case (1,2)
hupt_c = hupt_c * xylem_dis
end select
xwatupt(i,j) = hupt_c
zeig%coh%supply = zeig%coh%supply + hupt_c
hupt = hupt + hupt_c
i = i + 1
zeig => zeig%next
enddo ! zeig (cohorts)
wupt_r(j) = hupt
enddo ! j
endif
END subroutine upt_wat
!**************************************************************
SUBROUTINE upt_wat1
! Water uptake by roots
! 2. Version
use data_simul
use data_evapo
use data_soil
use data_stand
use data_par
implicit none
real, dimension(1:anz_coh) :: tr_dem,frt_rel ! help arrays for cohorts
real wat_ava, hdem, frtrel, frtrel_1, hupt, hupt_c, totfrt_2
real wat_at ! total available water per layer
real wat_ar ! total available water per layer with uptake resistance
real hred ! resistance coefficient
real, external :: fred1, fred2, fred3, fred4, fred5, fred6, fred7, fred11
integer i, ianz, j, nroot3
ianz = anz_coh
tr_dem=0
trans_dem = (pet-aev_i) * alfm * (1. - exp(-gp_can/gpmax)) ! pet NOT reduced by ground evaporation
if (trans_dem .lt. 0.) trans_dem = 0.
! potential transpiration demand of each cohort
if (gp_can .gt. zero) then
hdem = trans_dem / gp_can
else
hdem= 0.
endif
! Estimation of transpiration demand of tree cohorts and total fine root mass
! in layers with and without seedlings
zeig => pt%first
i = 1
do while (associated(zeig))
select case (flag_eva)
case (0, 1, 3)
zeig%coh%demand = zeig%coh%gp * zeig%coh%ntreea * hdem
case (2)
zeig%coh%demand = zeig%coh%demand - zeig%coh%aev_i
end select
tr_dem(i) = zeig%coh%demand
i = i + 1
zeig => zeig%next
enddo ! zeig (cohorts)
! uptake controlled by share of roots
frtrel_1 = 1.
! layers with seedlings
do j = 1,nroot_max
! determination of resisctance coefficient
select case (flag_wred)
case(1)
hred = fred1(j)
case(2)
hred = fred2(j)
case(3)
hred = fred3(j)
case(4)
hred = fred4(j)
case(5)
hred = 1.
case(6)
hred = 0.5
case(7)
hred = 0.25
case(8) ! BKL, ArcEGMO
hred = fred6(j)
case(10)
hred = fred7(j)
end select
wat_at = max(wats(j) - wilt_p(j), 0.) ! total available water per layer
wat_ar = hred * wat_at ! total available water per layer with uptake resistance
hupt = 0.
zeig => pt%first
i = 1 ! cohort index
do while (associated(zeig))
frtrel = zeig%coh%frtrel(j) * zeig%coh%x_frt * zeig%coh%ntreea * totfrt_1
wat_ava = frtrel * wat_ar ! available water per tree cohort and layer
if (wat_ava .ge. tr_dem(i)) then
hupt_c = tr_dem(i)
tr_dem(i) = 0.
else
hupt_c = wat_ava
tr_dem(i) = tr_dem(i) - wat_ava
endif
select case (flag_dis) !xylem clogger disturbance
case (1,2)
hupt_c = hupt_c * xylem_dis
end select
xwatupt(i,j) = hupt_c
zeig%coh%supply = zeig%coh%supply + hupt_c
hupt = hupt + hupt_c
i = i + 1
zeig => zeig%next
enddo ! zeig (cohorts)
wupt_r(j) = hupt
enddo ! j
END subroutine upt_wat1
!**************************************************************
real FUNCTION fred1(j)
! Function for calculating uptake resistance
! from CHEN (1993)
! empirical relation between soil water content and resistance
! fred1=1 if (field_cap - 10%*field_cap) <= wats <= (field_cap + 10%*field_cap)
use data_par
use data_soil
implicit none
real hf, f09, f11, wc, diff
integer j
f09 = 0.9 * field_cap(j)
f11 = 1.1 * field_cap(j)
wc = wats(j)
if (wc .lt. wilt_p(j)) then
hf = 0.
else if (wc .lt. f09) then
diff = f09-wilt_p(j)
if (diff .lt. zero) diff = 0.001
hf = 1. - (f09-wc) / diff
else if (wc .gt. f11) then
diff = pv(j)-f11
if (diff .lt. zero) diff = 0.001
hf = 0.3 + 0.7 * (pv(j)-wc) / diff
if (hf .lt. zero) hf = 0.001
else
hf = 1.
endif
fred1 = hf
END function fred1
!**************************************************************
real FUNCTION fred2(j)
! Function for calculating uptake resistance
! from Aber and Federer (f=0.04 fuer Wasser in cm)
! only 40% of total available water are plant available per day
implicit none
integer j
fred2 = 0.05
END function fred2
!**************************************************************
real FUNCTION fred3(j)
! Function for calculating uptake resistance
! from CHEN (1993)
! modified to a profile defined in fred
! fred3 may be described by a function (old version):
! fred3 = 0.0004*j*j - 0.0107*j + 0.0735
! this case: set from a root profile, defined by input of root_fr
use data_par
use data_soil
implicit none
real hf, f09, f11, wc, diff
! hf is a reduction factor in dependence on water content
real fred(15)
integer j
! uptake reduction depending on water content
f09 = 0.9 * field_cap(j)
f11 = 1.1 * field_cap(j)
wc = wats(j)
if (wc .lt. wilt_p(j)) then
hf = 0.
else if (wc .lt. f09) then
diff = f09-wilt_p(j)
if (diff .lt. zero) diff = 0.001
hf = 1. - (f09-wc) / diff
else if (wc .gt. f11) then
diff = pv(j)-f11
if (diff .lt. zero) diff = 0.001
hf = 0.3 + 0.7 * (pv(j)-wc) / diff
if (hf .lt. zero) hf = 0.001
else
hf = 1.
endif
fred3 = root_fr(j) * hf
END function fred3
!**************************************************************
real FUNCTION fred4(j)
! Function for calculating uptake resistance
! modified to a profile defined in fred
! profile at Beerenbusch
use data_soil
implicit none
real fred(15)
integer j
fred = (/ 0.0, 0.03, 0.03, 0.02, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, &
0.01, 0.01, 0.01, 0.01, 0.01 /) ! fred fuer Beerenbusch
fred4 = fred(j)
END function fred4
!**************************************************************
real FUNCTION fred6(j)
! Function for calculating uptake resistance
! from Kloecking (2006) simular to fred1
! empirical relation between soil water content and resistance
! fred6=1 if field_cap <= wats <= (field_cap + 10%*field_cap)
use data_soil
implicit none
real hf, f09, f11, wc
integer j
f09 = field_cap(j)
f11 = 1.1 * field_cap(j)
wc = wats(j)
if (wc .le. wilt_p(j)) then
hf = 0.
else if (wc .lt. f09) then
hf = 0.1 + (0.9 *(wc-wilt_p(j)) / (f09-wilt_p(j)))
else if (wc .gt. f11) then
hf = 0.3 + 0.7 * (pv(j)-wc) / (pv(j)-f11)
if (hf .lt. 0.) hf = 0.001
else
hf = 1.
endif
fred6 = hf
END function fred6
!**************************************************************
real FUNCTION fred7(j)
! Function for calculating uptake resistance
! from CHEN (1993)
! empirical relation between soil water content and resistance
! fred1=1 if (field_cap - 10%*field_cap) <= wats <= (field_cap + 10%*field_cap)
use data_par
use data_soil
implicit none
real hf, f09, f11, wc, diff
integer j
f09 = 0.9 * field_cap(j)
f11 = 1.1 * field_cap(j)
wc = wats(j)
if (wc .lt. wilt_p(j)) then
hf = 0.
else if (wc .lt. f09) then
diff = f09-wilt_p(j)
if (diff .lt. zero) diff = 0.001
hf = exp(-5.*(f09-wc) / diff)
else if (wc .gt. f11) then
diff = pv(j)-f11
if (diff .lt. zero) diff = 0.001
hf = 0.3 + 0.7 * (pv(j)-wc) / diff
if (hf .lt. zero) hf = 0.001
else
hf = 1.
endif
fred7 = hf
END function fred7
!**************************************************************
real FUNCTION fred11(j)
! Function for calculating uptake resistance, especially adapted for Mistletoe disturbance
! function after van Wijk, 2000
use data_par
use data_soil
implicit none
real hf, S, f11, wc, diff
integer j
f11 = 1.1 * field_cap(j)
wc = wats(j)
if (wc .lt. wilt_p(j)) then
hf = 0.
else if (wc .lt. field_cap(j)) then
S=(field_cap(j)-wc)/(field_cap(j)-wilt_p(j))
hf = exp(-30*S) !30 = strong reduction in water avail.
else if (wc .gt. f11) then
diff = pv(j)-f11
if (diff .lt. zero) diff = 0.001
hf = 0.3 + 0.7 * (pv(j)-wc) / diff
if (hf .lt. zero) hf = 0.001
else
hf = 1.
endif
fred11 = hf
END function fred11
!**************************************************************
SUBROUTINE take_wat(eva_dem, psi)
! Estimation of water taking out for uncovered soil
use data_soil
use data_simul
implicit none
!input:
real :: eva_dem ! evaporation demand
real :: psi ! covering
integer i, ii, j, ntag ! max. layer of taking out
real, allocatable, dimension(:) :: gj
real, external :: b_r, funcov
real diff, gj_j, depth_j, depth_n, rij, rmax, rr, rs, sr
allocate (gj(nlay))
do i=1,nlay
wupt_ev(i)=0.0
gj(i)=0.0
enddo
ntag = 0
rmax = 0.0
depth_n = depth(n_ev_d)
do i=1,n_ev_d
rij = 0.0
rr = depth_n/depth(i)
sr = 0.0
rs = 0.0
do j=1,i
! depth for uncovered take out
depth_j = depth(j)
gj(j) = FUNCOV(w_ev_d, rs*rr, rr*depth_j)
rs = depth_j
sr = sr + gj(j)
enddo ! i
if (sr.gt.1.E-7) then
sr = 1.0/sr
do j=1,i
! water take out
! (psi = 1.-psi) no soil evaporation in case of total covering
! and maximal evaporation for uncovered soil
gj_j = -B_R(wats(j), field_cap(j), wilt_p(j)) &
* eva_dem * (1.-psi) * gj(j) * sr
gj_j = max(gj_j,0.0)
gj(j)= gj_j
rij = rij + gj_j
enddo ! i
if (rij .gt. rmax) then
rmax = rij
ntag = i
do ii=1,ntag
wupt_ev(ii) = gj(ii)
enddo
endif ! rij
endif ! sr
enddo ! n_ev_d
! balance
do i=1,nlay
diff = wats(i) - wilt_p(i)
if (wupt_ev(i) .gt. diff) then
wupt_ev(i) = diff
endif
enddo ! nlay
deallocate (gj)
END subroutine take_wat
!*******************************************************************************
real FUNCTION B_R(water, f_cap, wilting)
! Reduction function for water taking out (uncovered soil)
implicit none
!input:
real :: water ! water storage
real :: f_cap ! field capacity
real :: wilting ! wilting point
b_r = 1.0
if (water .lt. f_cap) B_R = max((water-wilting)/(f_cap-wilting), 0.0)
END function B_R
!******************************************************************************
real FUNCTION funcov(wt_d, a, bb)
! take out density function for uncovered soil
implicit none
!input:
real :: wt_d ! depth of water taking out by evaporation (cm)
real :: a, bb ! relative upper and lower depth of actual layer
real fk, wt_5, b
fk = .455218234
wt_5 = 0.05 * wt_d
b = min(bb,wt_d)
funcov = (- b + a + 1.05*wt_d*log((b+wt_5)/(a+wt_5)))*fk/wt_d
END function funcov
!******************************************************************************
real FUNCTION wat_new(wat_us, wat_in, ilayer)
! FUNCTION WIEN(WIA,NIST,ALAM,DTI,TT,DICK)
! Estimation of additional water after infiltration and percolation
use data_par
use data_soil
implicit none
! input:
real :: wat_us ! water content in relation to field capacity
real :: wat_in ! water infiltration into actual layer
integer :: ilayer ! number of actual layer
real dti !time step
real awi, b1, b2, la, hsqr, exphelp
dti = 1.
fakt = 0.4
if (fakt .ge. 0.0) then ! percolation?
la = 100.0 * fakt * dti * wlam(ilayer)/thick(ilayer)**2
if (wat_us .le. zero) then ! water near zero?
if (wat_in .le. zero) then ! infiltrated water near zero?
wat_new = wat_us + wat_in
else
if (wat_us+wat_in .gt. zero) then
exphelp = sqrt(la*wat_in) * (1 + wat_us/wat_in)*1
if (exphelp .le.10.) then ! avoid underflow
b1 = -exp(-2. * exphelp)
else
b1 = 0.
endif
wat_new = sqrt(wat_in/la) * (1+b1)/(1-b1)
else
wat_new = wat_us + wat_in
endif
endif ! wat_in
else
if (wat_in .lt. 0.) then
awi = abs(wat_in)
b1 = atan(wat_us/sqrt(awi/la)) / sqrt(la * awi)
if (b1 .gt. 1) then
b2 = sqrt (awi * la)
b1 = sin(b2) / cos(b2)
b2 = sqrt(awi / la)
wat_new = b2 * (wat_us - b2*b1) / (b2 + wat_us*b1)
else
wat_new = wat_in * (1-b1)
endif ! b1
else
if (wat_in .gt. 0.) then
b1 = sqrt(wat_in / la)
hsqr = sqrt(la*wat_in)
if (hsqr .lt. 10.) then
b2 = (wat_us - b1) * exp(-2.* hsqr) / (wat_us + b1)
if (b2 .ge. 1.0) then
b2 = 0.99999
endif
else
b2 = 0.
endif
wat_new = b1 * (1.+b2) / (1.-b2)
else
wat_new = wat_us / (1. + la*wat_us)
endif
endif ! wat_in
endif ! wat_us
else
wat_new = wat_us
endif ! fakt
END function wat_new
!******************************************************************************
SUBROUTINE bucket(bucksize1, bucksize2, buckdepth)
! calculation of bucket size (1m; without humus layer)
use data_soil
implicit none
real bucksize1, & ! bucket size of 1 m depth (nFK)
bucksize2, & ! bucket size of rooting zone
buckdepth, diff
integer j
bucksize1 = 0.
bucksize2 = 0.
buckdepth = 0.
do j=2,nlay
if ((depth(j)-depth(1)) .lt. 100.) then
bucksize1 = bucksize1 + wats(j) - wilt_p(j)
buckdepth = depth(j) - depth(1)
else
diff = 100. - buckdepth
bucksize1 = bucksize1 + (wats(j) - wilt_p(j))*diff/thick(j)
buckdepth = 100.
exit
endif
enddo
do j=2,nroot_max
bucksize2 = bucksize2 + wats(j) - wilt_p(j)
enddo
END subroutine bucket
!******************************************************************************
SUBROUTINE snowpack(snow_sm, p_inf, pev)
! properties of snow
! calculation of soil surface temperature under snow pack
use data_climate
use data_evapo
use data_inter
use data_par
use data_simul
use data_soil
use data_soil_t
implicit none
real p_inf ! infiltrated water
real snow_sm
real pev
real airtemp_sm ! melting temperature
real snow_old ! old snow pack
real tc_snow ! thermal conductivity of snow J/cm/s/K
real thick_snow ! thickness of snow
real dens_snow ! density of snow
real:: dens_sn_new = 0.1 ! density of fresh snow
real fakta
snow_old = snow
!substract evaporation of snowcover from snow in both cases
if (airtemp .lt. temp_snow) then ! frost conditions
snow = snow + prec_stand ! precipitation as snow
snow_sm = 0.0 ! no snow melting
p_inf = 0.0 ! no infiltrated precipitation
pev = max((pev_s - aev_i), 0.) ! interc. evapor. reduces soil evapor.
else
airtemp_sm = max(airtemp, 0.)
snow_sm = airtemp*(0.45+0.2*airtemp) ! snow melting
snow_sm = MIN(snow_sm, snow)
snow = snow - snow_sm
p_inf = prec_stand + snow_sm ! infiltrated precipitation
pev = max((pev_s - aev_i), 0.) ! interc. evapor. reduces soil evapor.
end if ! airtemp
if (snow .ge. zero) then
snow_day = snow_day + 1
days_snow = days_snow + 1
if (pev .le. zero) then
pev = 0.
else
! snow sublimation
aev_s = max(min(snow, pev), 0.)
snow = snow - aev_s
pev = pev - aev_s
endif
! soil surface temperature under snow pack
! snow hight = 0.2598 * water equivalent + 8.6851; adjustment from measurement values (see Bodentemperatur.xls)
if (snow .ge. 0.05) then
dens_snow = dens_sn_new + snow_day*0.025
dens_snow = MIN(dens_snow, 1.)
dens_snow = 0.5*(dens_sn_new*prec_stand + dens_snow*snow_old)/snow
dens_snow = MIN(dens_snow, 1.)
tc_snow = 0.7938*EXP(3.808*dens_snow)*0.001 ! thermal conductivity of snow J/cm/s/K
thick_snow = snow / dens_snow
fakta = tc_snow * 86400. * (thick(1)/2.) / (t_cond(1) * thick_snow) ! s --> day
temps_surf = (0.5*temps(1) + fakta*airtemp) / (1. + fakta) ! CoupModel (Jansson, 2001)
endif
else
snow_day = 0
endif
END subroutine snowpack
!******************************************************************************
SUBROUTINE soil_stress
! Calculation of the stress factors
use data_soil
use data_species
use data_stand
use data_par
implicit none
integer :: i, k
real :: m_1, m_2, n_1, n_2
real :: wratio, wafpo
real, dimension (1:4) :: allstress, xvar, yvar
!temperature stress
do i=1,nlay
do k=1,nspecies
if (temps(i) .ge. spar(k)%tbase) then
svar(k)%tstress(i) = sin((pi/2)*(temps(i)-spar(k)%tbase)/(spar(k)%topt-spar(k)%tbase))
else
svar(k)%tstress(i) = 0.
endif
!soil strength
wratio=0.
if (dens(i) .le. BDopt(i)) then
svar(k)%BDstr(i) = 1
svar(k)%BDstr(i) = 1
elseif (dens(i) .ge. svar(k)%BDmax(i)) then
svar(k)%BDstr(i) = 0
else
svar(k)%BDstr(i) = (svar(k)%BDmax(i)-dens(i))/(svar(k)%BDmax(i)-BDopt(i))
endif
if (watvol(i) .lt. wilt_p_v(i)) then
wratio = 0.
elseif (watvol(i) .gt. f_cap_v(i)) then
wratio = 1.
else
wratio = (watvol(i)-wilt_p_v(i))/(f_cap_v(i)-wilt_p_v(i))
endif
svar(k)%sstr(i)=svar(k)%BDstr(i)*sin(1.57*wratio)
!aeration
wafpo=watvol(i)/pv_v(i)
if (wafpo .ge. svar(k)%porcrit(i)) then
svar(k)%airstr(i) = (1.-wafpo)/(1.-svar(k)%porcrit(i))
else
svar(k)%airstr(i) = 1.
endif
if (svar(k)%airstr(i) .lt. 0.) svar(k)%airstr(i) = 0.
!soil acidity
xvar=(/spar(k)%ph_min, spar(k)%ph_opt_min, spar(k)%ph_opt_max, spar(k)%ph_max/)
yvar=(/0,1,1,0/)
m_1=(yvar(1)-yvar(2))/(xvar(1)-xvar(2))
n_1=yvar(2)-m_1*xvar(2)
m_2=(yvar(3)-yvar(4))/(xvar(3)-xvar(4))
n_2=yvar(4)-m_2*xvar(4)
if (phv(i) .gt. spar(k)%ph_opt_max .and. phv(i) .le. spar(k)%ph_max ) then
svar(k)%phstr(i)=m_2*phv(i)+n_2
elseif (phv(i) .lt. spar(k)%ph_opt_min .and. phv(i) .ge. spar(k)%ph_min ) then
svar(k)%phstr(i)=m_1*phv(i)+n_1
elseif (phv(i) .gt. spar(k)%ph_max .or. phv(i) .lt. spar(k)%ph_min) then
svar(k)%phstr(i)=0.
else
svar(k)%phstr(i)=1.
endif
! total stress (Rstress) is taken as the largest of the four
allstress(1)=svar(k)%tstress(i)
allstress(2)=svar(k)%sstr(i)
allstress(3)=svar(k)%airstr(i)
allstress(4)=svar(k)%phstr(i)
svar(k)%Rstress(i)= minval(allstress)
svar(k)%Smean(i)=svar(k)%Rstress(i)+svar(k)%Smean(i)
enddo
enddo
END subroutine soil_stress
!*******************************************************************************
SUBROUTINE hum_add(xfcap, xwiltp, xpv)
! Soil parameter according to [Kuntze et al., Bodenkunde, 1994], S. 172
use data_simul
use data_soil
use data_soil_cn
implicit none
integer :: i, k
real :: fcapi, clayvi, siltvi, humvi, humvi2, wiltpi, pvi, nfki, hcbc
real, dimension(nlay):: xfcap, xwiltp, xpv ! output of addition mm/dm
xfcap(1) = 0.0
xwiltp(1) = 0.0
xpv(1) = 0.0
do i = 1, nlay
fcapi = 0.
wiltpi = 0.
pvi = 0.
clayvi = clayv(i)
humvi = humusv(i)*100.
humvi2 = humusv(i)*humusv(i)
if (humvi .lt. 15.) then
if (clayvi .le. 0.05) then
wiltpi = 0.0609 * humvi2 + 0.33 * humvi
pvi = 0.0436 * humvi2 + 0.631 * humvi
nfki = -0.0009 * humvi2 + 1.171 * humvi
fcapi = nfki + wiltpi
else if (clayvi .le. 0.12) then
wiltpi = 0.0357 * humvi2 + 0.0762 * humvi
pvi = 0.0441 * humvi2 + 0.5455 * humvi
nfki = 0.0252 * humvi2 + 0.7462 * humvi
fcapi = nfki + wiltpi
else if (clayvi .le. 0.17) then
wiltpi = 0.0374 * humvi2 - 0.1777 * humvi
pvi = 0.0552 * humvi2 + 0.2936 * humvi
nfki = 0.0324 * humvi2 + 0.6243 * humvi
fcapi = nfki + wiltpi
else if (clayvi .le. 0.35) then
wiltpi = 0.0179 * humvi2 - 0.0385 * humvi
pvi = 0.0681 * humvi2 + 0.0768 * humvi
nfki = 0.0373 * humvi2 + 0.3617 * humvi
fcapi = nfki + wiltpi
else if (clayvi .le. 0.65) then
wiltpi = 0.0039 * humvi2 + 0.0254 * humvi
pvi = 0.0613 * humvi2 + 0.0947 * humvi
nfki = 0.0338 * humvi2 + 0.0904 * humvi
fcapi = nfki + wiltpi
else
wiltpi = 0.0
pvi = 0.0613 * humvi2 + 0.0947 * humvi
nfki = 0.0104 * humvi2 + 0.2853 * humvi
fcapi = nfki + wiltpi
endif
else ! humvi > 15
! organic soils
continue
endif ! humvi
xfcap(i) = fcapi
xwiltp(i) = wiltpi
xpv(i) = pvi
enddo
if (flag_bc .gt. 0) then
do i = 1, nlay
if (C_bc(i) .gt. 0.) then
fcapi = f_cap_v(i)
clayvi = clayv(i)
siltvi = siltv(i)
humvi = humusv(i)*100.
hcbc = C_bc(i)*100.*100. / (cpart_bc(y_bc_n) * dmass(i))
if ((clayvi .le. 0.17) .and. (siltvi .le. 0.5)) then ! sand
fcapi = 0.0619 * hcbc
wiltpi = 0.0375 * hcbc
nfki = 7.0
elseif ((clayvi .le. 0.45) .and. (siltvi .gt. 0.17)) then ! loam
fcapi = 0.015 * hcbc
wiltpi = 0.0157 * hcbc
nfki = 10.
else ! clay
fcapi = -0.0109 * hcbc
wiltpi = -0.0318 * hcbc
nfki = 16.
endif
xfcap(i) = xfcap(i) + fcapi
xwiltp(i) = xwiltp(i) + wiltpi
endif
enddo
endif
END subroutine hum_add
!*******************************************************************************
SUBROUTINE bc_appl
! application of biochar
use data_out
use data_simul
use data_soil
use data_soil_cn
implicit none
character :: text
integer :: ios, inunit, j
logical :: ex
real :: hcbc
call testfile(valfile(ip),ex)
IF (ex .eqv. .true.) then
inunit = getunit()
ios=0
open(inunit,file=valfile(ip),iostat=ios,status='old',action='read')
if (.not.flag_mult8910) then
print *,'***** Reading application values of biochar from file ',valfile(ip),'...'
write (unit_err, *) 'Application values of biochar from file ',trim(valfile(ip))
endif
do
read(inunit,*) text
IF(text .ne. '!')then
backspace(inunit)
exit
endif
enddo
read (inunit,*,iostat=ios) n_appl_bc
allocate (C_bc_appl(n_appl_bc))
allocate (N_bc_appl(n_appl_bc))
allocate (bc_appl_lay(n_appl_bc))
allocate (cnv_bc(n_appl_bc))
allocate (dens_bc(n_appl_bc))
allocate (cpart_bc(n_appl_bc))
allocate (y_bc(0 : n_appl_bc + 1))
y_bc = 0
C_bc_appl = 0.
N_bc_appl = 0.
do j = 1, n_appl_bc
read (inunit,*,iostat=ios) y_bc(j), cpart_bc(j), cnv_bc(j), dens_bc(j)
read (inunit,*,iostat=ios) bc_appl_lay(j), C_bc_appl(j)
enddo
endif ! ex
END subroutine bc_appl
!*******************************************************************************
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* SOIL_C/N - Programs *!
!* *!
!* Author: F. Suckow *!
!* *!
!* contains: *!
!* SOIL_CN *!
!* F_CNV(Cpool, Npool) *!
!* RMIN_T(temp) *!
!* RNIT_T(temp) *!
!* RMIN_W(water, xpv) *!
!* RNIT_W(water, xpv) *!
!* RMIN_P(phv) *!
!* RNIT_P(phv) *!
!* HUMLAY *!
!* DECOMP1(Copm, Nopm, cnv, kopm, ksyn, hdiff) *!
!* DECOMP2(Copm, Nopm, cnv, kopm, ksyn, hdiff) *!
!* MINLAY(jlay) *!
!* N_LEACH(jlay, NH4l, NO3l) *!
!* S_RESP(Copm_1, Chum_1) *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE soil_cn
! Soil C-N budget
use data_climate
use data_out
use data_simul
use data_soil
use data_soil_cn
use data_stand
implicit none
integer j, hnlay, ntr
real Copm_1, Chum_1 ! previous C-content of soil profile
real Nopm_1, Nhum_1 ! previous N-content of soil profile
real Cbc_1, Nbc_1 ! previous C- and N-content of biochar
real Nmin1, N_min_h
type(Coh_Obj), pointer :: p ! pointer to cohort list
! save previous state of soil C-content
Copm_1 = SUM(C_opm) + C_opm_stem
Chum_1 = SUM(C_hum)
Nopm_1 = SUM(N_opm) + N_opm_stem
Nhum_1 = SUM(N_hum)
N_min_h= N_min
if (flag_bc .gt. 0) then
Cbc_1 = SUM(C_bc)
Nbc_1 = SUM(N_bc)
else
Cbc_1 = 0.
Nbc_1 = 0.
endif
call humlay ! humus layer
! loop over mineral layers
do j=2,nlay
call minlay(j)
enddo ! loop over j (nlay)
! soil respiration
call s_resp(Copm_1, Chum_1, Cbc_1)
! daily values
Nleach = NH4_in + NO3_in
Nupt_d = SUM(Nupt)
N_an_tot = SUM(NH4) + SUM(NO3)
Nmin1 = Nopm_1 + Nhum_1 - SUM(N_opm) - SUM(N_hum)
if (flag_bc .gt. 0) then
Nmin1 = Nmin1 + Nbc_1 - SUM(N_bc)
endif
! yearly cumul. quantities
Nleach_c = Nleach_c + Nleach
Nupt_c = Nupt_c + Nupt_d
resps_c = resps_c + respsoil
p => pt%first
do while (associated(p))
ns = p%coh%species
ns = p%coh%species
ntr = p%coh%ntreea
svar(ns)%Ndem = svar(ns)%Ndem + ntr * p%coh%Ndemc_d
svar(ns)%Nupt = svar(ns)%Nupt + ntr * p%coh%Nuptc_d
p%coh%Nuptc_c = p%coh%Nuptc_c + p%coh%Nuptc_d
p%coh%Ndemc_c = p%coh%Ndemc_c + p%coh%Ndemc_d
p%coh%N_pool = p%coh%N_pool + p%coh%Nuptc_d
p => p%next
enddo ! p (cohorts)
if (flag_dayout .ge. 2) then
if (nlay .gt. 6) then
hnlay = 6
else
hnlay = nlay
endif
N_min_h = N_min - N_min_h
write (unit_soicna, '(A)') ''
write (unit_soicnd, '(A)') ''
endif
1000 FORMAT (2I5, 6F10.3, 6F10.1)
1100 FORMAT (2I5, 12F10.3)
1200 FORMAT (2I5, 4F10.3, 4F10.1, F10.2)
END subroutine soil_cn
!**************************************************************
real FUNCTION f_cnv(Cpool, Npool)
! C/N-ratio of a pool
! implicit none
real Cpool, Npool
if (Npool .lt. 1e-6) then
f_cnv = 0.
else
f_cnv = Cpool / Npool
endif
END function f_cnv
!**************************************************************
real FUNCTION rmin_t(temp, rkind)
! reduction of mineralization depending on soil temperature
use data_simul
implicit none
integer rkind
real temp, toptm, Q10
select case (rkind)
case(1)
toptm = 35.
Q10 = 2.9
rmin_t = exp(log(Q10) * ((temp-toptm)/10.)) ! Stanford
case(2)
toptm = 35.
Q10 = 2.9
rmin_t = Q10**((temp-toptm)*0.1) ! van't Hoff
case(4)
rmin_t = 1.
case default
toptm = 35.
Q10 = 2.9
rmin_t = exp(log(Q10) * ((temp-toptm)/10.)) ! Stanford
end select
END function rmin_t
!**************************************************************
real FUNCTION rnit_t(temp, rkind)
! reduction of nitrification depending on soil temperature
implicit none
integer rkind
real temp, toptn, Q10
select case (rkind)
case(1) ! Stanford
toptn = 30.
Q10 = 2.8
rnit_t = exp(log(Q10) * ((temp-toptn)/10.))
case(2) ! van't Hoff
toptn = 30.
Q10 = 2.8
rnit_t = Q10**((temp-toptn)*0.1) ! van't Hoff
case(3) ! SWAT-approach; Nitrif. only above 5C
if (temp .gt. 5.) then
rnit_t = 0.041 *(temp-5.)
else
rnit_t = 0.
endif
case(4)
rnit_t = 1.
case default
toptn = 30.
Q10 = 2.8
rnit_t = exp(log(Q10) * ((temp-toptn)/10.)) ! Stanford
end select
END function rnit_t
!**************************************************************
real FUNCTION rmin_w(water, xpv)
! reduction of mineralization depending on soil water content
! xpv - pore volume
rmin_w = 4.0 * water * (1.0-water/xpv) / xpv
if (rmin_w .lt. 0.) rmin_w = 0.
END function rmin_w
!**************************************************************
real FUNCTION rnit_w(water, xpv, xfk, xwp, rkind)
! reduction of nitrification depending on soil water content
! xpv - pore volume
implicit none
integer rkind
real water, xpv, xfk, xwp, nfk, avwat
select case (rkind)
case(1) ! Franco
if (water .lt. 0.9*xpv) then
rnit_w = 4.0 * water * (1.0-water/xpv) / xpv
else
rnit_w = 1.
endif
if (rnit_w .lt. 0.) rnit_w = 0.
case(2) ! SWAT-Ansatz
nfk = xfk - xwp
avwat = water - xwp
if (avwat .lt. 0.25*nfk) then
rnit_w = avwat / 0.25 * nfk
else
rnit_w = 1.
endif
case default
if (water .lt. 0.9*xpv) then
rnit_w = 4.0 * water * (1.0-water/xpv) / xpv
else
rnit_w = 1.
endif
if (rnit_w .lt. 0.) rnit_w = 0.
end select
END function rnit_w
!**************************************************************
real FUNCTION rmin_p(phv)
! reduction of mineralization depending on pH-value
real, dimension(4) :: a = (/2.5, 4.0, 5.0, 8.0/), &
b = (/0.5, 0.8, 1.0, 1.0/)
call tab_int(a,b,4,phv,value)
rmin_p = value
END function rmin_p
!**************************************************************
real FUNCTION rnit_p(phv)
! reduction of nitrification depending on pH-value
real, dimension(4) :: a = (/2.5, 4.0, 6.0, 8.0/), &
b = (/0.1, 0.3, 1.0, 1.0/)
call tab_int(a,b,4,phv,value)
rnit_p = value
END function rnit_p
!**************************************************************
SUBROUTINE humlay
! C-N budget of the humus layer
! (including litter layer)
use data_climate
use data_depo
use data_inter
use data_out
use data_simul
use data_soil
use data_soil_cn
use help_soil_cn
use data_species
implicit none
integer, parameter:: double_prec = kind(0.0D0)
integer i
real (kind = double_prec):: N_hum_1, NH4_1, NO3_1 ! previous state of C- and N-pools
real (kind = double_prec):: N_hum_2, NH4_2, NO3_2 ! actual state of C- and N-pools
real (kind = double_prec):: hnh4, hno3, bilanz, hnhum, hncopm, nh4diff, nhdiff, hdiff, s_hdiff
real (kind = double_prec):: renit ! reduction function of nitrif.
real (kind = double_prec):: redtermc, redtermn ! red. terms of C-/ N-pools
real Copm, Nopm, hcnv, hcnv_bc, kopm, redopm, Nminl, Nmin1, redbc
logical ldecomp
real, external :: rmin_t, rmin_w, rnit_t, rnit_w, f_cnv
type (species_litter) :: sliti
if (flag_dayout .ge. 2) then
write (unit_soicnr, '(2I5,3E12.3)') time_cur, iday, rmin_t(temps(1), kmint), rmin_w(wats(1), pv(1)), rmin_phv(1)
endif
! reduction factors of mineralization and nitrification
remin = rmin_t(temps(1), kmint) * rmin_w(wats(1), pv(1)) * rmin_phv(1)
renit = rnit_t(temps(1), knitt) * rnit_w(wats(1), pv(1), field_cap(1), wilt_p(1), knitw) * rnit_phv(1)
! add deposition
if (flag_depo .eq. 2) then
NH_dep = NH_dep * prec_stand ! conversion g/l in g/m2
NO_dep = NO_dep * prec_stand
endif
NH4(1) = NH4(1) + NH_dep
NO3(1) = NO3(1) + NO_dep
Ndep_cum = Ndep_cum + NO_dep + NH_dep
! store state of previous step
N_hum_1 = N_hum(1)
NH4_1 = NH4(1)
NO3_1 = NO3(1)
khr = k_hum * remin
hexph = exp(-khr)
knr = k_nit * renit
if (abs(knr-khr) .le. 1E-6) knr = knr + 1E-6
hexpn = exp(-knr)
! reduction of C- and N-humus-pool by mineralization,
redtermc = C_hum(1) * hexph ! part of equation II
redtermn = N_hum_1 * hexph ! -"-
! NH4-pool
if (NH4_1 .gt. 1E-6) then
term1 = NH4_1 * hexpn ! part of equ. III
else
term1 = NH4_1
endif
term3 = N_hum_1 * khr * (hexph-hexpn) / (knr-khr)
if (cnv_hum(1) .lt. 1e-8) cnv_hum(1) = 20.
cnvh = 1./cnv_hum(1)
redopm = 1.
redbc = 1.
slit_1 = slit
ldecomp = .TRUE.
do while (ldecomp)
! Decomposition of dead biomass
Copm = 0.
Nopm = 0.
C_opm_stem = 0.
N_opm_stem = 0.
reptermc = 0.
reptermn = 0.
term2 = 0.
term4 = 0.
s_hdiff = 0.
! Decomposition of dead biomass fractions
do i=1,nspecies
sliti = slit_1(i)
hdiff = 0.
if (sliti%C_opm_fol .gt. 1e-8) then
kopm = redopm * spar(i)%k_opm_fol
if (kopm .ge. 1e-8) then
sliti%cnv_opm_fol = f_cnv(sliti%C_opm_fol, sliti%N_opm_fol)
call decomp1(sliti%C_opm_fol, sliti%N_opm_fol, sliti%cnv_opm_fol, &
kopm, spar(i)%k_syn_fol, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
if (sliti%C_opm_frt(1) .gt. 1e-8) then
kopm = redopm * spar(i)%k_opm_frt
if (kopm .ge. 1e-8) then
sliti%cnv_opm_frt = f_cnv(sliti%C_opm_frt(1), sliti%N_opm_frt(1))
call decomp1(sliti%C_opm_frt(1), sliti%N_opm_frt(1), sliti%cnv_opm_frt, &
kopm, spar(i)%k_syn_frt, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
if (sliti%C_opm_tb .gt. 1e-8) then
kopm = redopm * spar(i)%k_opm_tb
if (kopm .ge. 1e-8) then
sliti%cnv_opm_tb = f_cnv(sliti%C_opm_tb, sliti%N_opm_tb)
call decomp1(sliti%C_opm_tb, sliti%N_opm_tb, sliti%cnv_opm_tb, &
kopm, spar(i)%k_syn_tb, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
select case (flag_decomp)
case (0, 10, 20, 30, 40)
if (sliti%C_opm_crt(1) .gt. 1e-8) then
kopm = redopm * spar(i)%k_opm_crt
if (kopm .ge. 1e-8) then
sliti%cnv_opm_crt = f_cnv(sliti%C_opm_crt(1), sliti%N_opm_crt(1))
call decomp1(sliti%C_opm_crt(1), sliti%N_opm_crt(1), sliti%cnv_opm_crt, &
kopm, spar(i)%k_syn_crt, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
if (sliti%C_opm_stem .gt. 1e-8) then
kopm = redopm * spar(i)%k_opm_stem
if (kopm .ge. 1e-8) then
sliti%cnv_opm_stem = f_cnv(sliti%C_opm_stem, sliti%N_opm_stem)
call decomp1(sliti%C_opm_stem, sliti%N_opm_stem, sliti%cnv_opm_stem, &
kopm, spar(i)%k_syn_stem, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
case (1, 11, 21, 31, 41)
if (sliti%C_opm_crt(1) .gt. 1e-8) then
kopm = redopm * spar(i)%k_opm_crt
if (kopm .ge. 1e-8) then
sliti%cnv_opm_crt = f_cnv(sliti%C_opm_crt(1), sliti%N_opm_crt(1))
call decomp2(sliti%C_opm_crt(1), sliti%N_opm_crt(1), sliti%cnv_opm_crt, &
kopm, spar(i)%k_syn_crt, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
if (sliti%C_opm_stem .gt. 1e-8) then
kopm = redopm * spar(i)%k_opm_stem
if (kopm .ge. 1e-8) then
sliti%cnv_opm_stem = f_cnv(sliti%C_opm_stem, sliti%N_opm_stem)
call decomp2(sliti%C_opm_stem, sliti%N_opm_stem, sliti%cnv_opm_stem, &
kopm, spar(i)%k_syn_stem, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
end select
! pools of dead biomass without stems
Copm = Copm + sliti%C_opm_fol + sliti%C_opm_frt(1) + sliti%C_opm_crt(1) + sliti%C_opm_tb
Nopm = Nopm + sliti%N_opm_fol + sliti%N_opm_frt(1) + sliti%N_opm_crt(1) + sliti%N_opm_tb
! dead stems
C_opm_stem = C_opm_stem + sliti%C_opm_stem
N_opm_stem = N_opm_stem + sliti%N_opm_stem
slit(i) = sliti
enddo
! Decomposition of biochar
if (flag_bc .gt. 0) then
if (C_bc(1) .gt. 1e-8) then
kbc = redbc * k_bc
if (kbc .ge. 1e-8) then
hcnv_bc = f_cnv(C_bc(1), N_bc(1))
call decomp1(C_bc(1), N_bc(1), hcnv_bc, kbc, k_syn_bc, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
endif
ldecomp = .FALSE.
C_opm(1) = Copm
N_opm(1) = Nopm
! C- and N-humus-pool: reduction by mineralization, supply by turnover of organic primary matter
C_hum(1) = redtermc + reptermc
N_hum_2 = redtermn + reptermn
N_hum(1) = N_hum_2
! ammonium pool
hnh4 = term1 + term2 + term3 + khr/(knr-khr) * term4
NH4(1) = hnh4
nhdiff = N_hum_1 - N_hum_2
nh4diff = NH4_1 - NH4(1)
Nminl = hnh4 - NH4_1 - NO3(1) ! daily net min.
! nitrat pool from balance
hno3 = NO3_1 + s_hdiff + nhdiff + nh4diff
NO3(1) = hno3
if (hnh4 .lt. 0.0 .or. hno3 .lt. 0.0) then
redopm = 0.9 * redopm
if (redopm .ge. 1E-8) then
ldecomp = .TRUE.
else
if (NH4(1) .lt. 1E-10) NH4(1) = 0.
if (NO3(1) .lt. 1E-10) NO3(1) = 0.
endif
endif
Nminl = Nminl + NO3(1) ! daily net min. per layer
enddo ! ldecomp
Nmin(1) = Nminl
N_min = N_min + Nminl ! cumul. yearly net min.
call n_leach(1) ! without balance
! new balance after leaching
NH4(1) = NH4(1) - NH4_in
NO3(1) = NO3(1) - NO3_in
call n_upt(1) ! with balance
if (flag_dayout .ge. 2) then
write (unit_soicna, '(2I5,E12.3)', advance='no') time_cur, iday, remin
write (unit_soicnd, '(2I5,E12.3)', advance='no') time_cur, iday, Nminl
endif
END subroutine humlay
!**************************************************************
SUBROUTINE decomp1(Copm, Nopm, cnv, kopm, ksyn, hdiff)
! Decomposition of dead biomass fractions per species
use help_soil_cn
implicit none
integer, parameter:: double_prec = kind(0.0D0)
real Copm, Nopm ! C- and N-pool of primary organic matter fraction
real kopm, ksyn ! mineralisation and synthesis coeff. of opm-fraction
real kor ! reduced mineralisation coeff. of opm-fraction
real N_opm_1, C_opm_1 ! previous state of C- and N-pools
real hexpo ! exponential part
real cnv ! C/N-ratio of opm-fraction
real exterm
real (kind = double_prec):: hdiff
real gamma
! store state of previous step
C_opm_1 = Copm
N_opm_1 = Nopm
kor = kopm * remin ! reduction of miner. coeff.
! avoid denominators near zero
if (abs(kor-khr) .lt. 1E-6) kor = kor + 1E-6
if (abs(kor-knr) .lt. 1E-6) kor = kor + 1E-6
hexpo = exp(-kor)
Copm = C_opm_1 * hexpo ! equations II
Nopm = N_opm_1 * hexpo ! -"-
! reproduction of C- and N-humus-pool by turnover of organic primary matter
exterm = hexph - hexpo
gamma = cnv * cnvh
if (abs(kor-khr) .gt. 1E-6) then
reptermc = reptermc + C_opm_1 * ksyn * kor * exterm / (kor-khr) ! part of equ. II
reptermn = reptermn + N_opm_1 * gamma*ksyn * kor * exterm / (kor-khr) ! part of equ. II
endif
! change of ammonium pool
if (abs(kor-knr) .gt. 1E-6) then
term2 = term2 + (1.-gamma*ksyn)*kor * N_opm_1 * (hexpn - hexpo) / (kor - knr) ! part of equ. III
endif
if ((abs(kor-khr) .gt. 1E-6) .and. (abs(kor-knr) .gt. 1E-6)) then
term4 = term4 + gamma*ksyn*kor * N_opm_1 & ! part of equ. III
* ((kor-khr) * hexpn + (knr-kor) * hexph + (khr-knr) * hexpo) &
/ ((khr - kor) * (kor - knr))
endif
hdiff = N_opm_1 - Nopm ! N-change rate in organic primary matter
END subroutine decomp1
!**************************************************************
SUBROUTINE decomp2(Copm, Nopm, cnv, kopm, ksyn, hdiffn)
! Decomposition of dead stem biomass per species
use help_soil_cn
implicit none
integer, parameter:: double_prec = kind(0.0D0)
real Copm, Nopm ! C- and N-pool of primary organic matter fraction
real kopm, ksyn ! mineralisation and synthesis coeff. of opm-fraction
real kor ! reduced mineralisation coeff. of opm-fraction
real N_opm_1, C_opm_1 ! previous state of C- and N-pools
real hexpo ! exponential part
real cnv ! C/N-ratio of opm-fraction
real (kind = double_prec):: hdiffn, hdiffc
! store state of previous step
C_opm_1 = Copm
N_opm_1 = Nopm
kor = kopm * remin ! reduction of miner. coeff.
! avoid denominators near zero
if (abs(kor) .lt. 1E-6) kor = kor + 1E-6
hexpo = exp(-kor)
Copm = C_opm_1 * hexpo ! equations II
Nopm = N_opm_1 * hexpo ! -"-
! reproduction of C- and N-humus-pool by turnover of organic primary matter
hdiffn = N_opm_1 - Nopm ! N-change rate in organic primary matter
hdiffc = hdiffn / cnvh
reptermn = reptermn + hdiffn
reptermc = reptermc + hdiffc
END subroutine decomp2
!**************************************************************
SUBROUTINE minlay(jlay)
! C-N budget of a mineral layer
use data_climate
use data_out
use data_simul
use data_soil
use data_soil_cn
use help_soil_cn
use data_species
implicit none
! input:
integer jlay ! number of actual layer
!------------------------------------------------------------
integer, parameter:: double_prec = kind(0.0D0)
integer i
real (kind = double_prec):: N_hum_1, NH4_1, NO3_1 ! previous state of C- and N-pools
real (kind = double_prec):: hnh4, hno3, bilanz, hnhum, hncopm, nh4diff, nhdiff, hdiff, s_hdiff
real (kind = double_prec):: renit ! reduction function of nitrif.
real (kind = double_prec):: redtermc, redtermn ! red. terms of C-/ N-pools
real Copm, Nopm, hcnv, hcnv_bc, kopm, redopm, Nminl, Nmin1, redbc
real, dimension(nspecies):: Copm_frt_1, Nopm_frt_1, Copm_crt_1, Nopm_crt_1
logical ldecomp
real, external :: rmin_t, rmin_w, rnit_t, rnit_w, f_cnv
! reduction factors of mineralization and nitrification
remin = rmin_t(temps(jlay), kmint) * rmin_w(wats(jlay), pv(jlay)) * rmin_phv(jlay)
renit = rnit_t(temps(jlay), knitt) * rnit_phv(jlay) * &
rnit_w(wats(jlay), pv(jlay), field_cap(jlay), wilt_p(jlay), knitw)
if (flag_dayout .eq. 3) then
write (1122, *) 'minlay ', iday, jlay
endif
! add N transport from above layer
NH4(jlay) = NH4(jlay) + NH4_in
NO3(jlay) = NO3(jlay) + NO3_in
! store state of previous step
N_hum_1 = N_hum(jlay)
NH4_1 = NH4(jlay)
NO3_1 = NO3(jlay)
Nopm_frt_1 = slit%N_opm_frt(jlay)
Copm_frt_1 = slit%C_opm_frt(jlay)
Nopm_crt_1 = slit%N_opm_crt(jlay)
Copm_crt_1 = slit%C_opm_crt(jlay)
redopm = 1.
redbc = 1.
khr = k_hum_r * remin
hexph = exp(-khr)
knr = k_nit * renit
if (abs(knr-khr) .le. 1E-6) knr = knr + 1E-6
hexpn = exp(-knr)
! reduction of C- and N-humus-pool by mineralization,
redtermc = C_hum(jlay) * hexph ! part of equation II
redtermn = N_hum_1 * hexph ! -"-
! NH4-pool
term1 = NH4_1 * hexpn ! part of equ. III
term3 = N_hum_1 * khr * (hexph-hexpn) / (knr-khr)
if (cnv_hum(jlay) .lt. 1e-8) then
if (cnv_hum(jlay-1) .ge. 1e-8) then
cnv_hum(jlay) = cnv_hum(jlay-1)
else
cnv_hum(jlay) = 20.
endif
endif
cnvh = 1./cnv_hum(jlay)
ldecomp = .TRUE.
do while (ldecomp)
! Decomposition of dead biomass
reptermc = 0.
reptermn = 0.
term2 = 0.
term4 = 0.
s_hdiff = 0.
do i=1,nspecies
Nopm = Nopm_frt_1(i)
kopm = redopm * spar(i)%k_opm_frt
if (Nopm .ge. 1e-8 .and. kopm .ge. 1e-8) then
Copm = Copm_frt_1(i)
hcnv = f_cnv(Copm, Nopm)
if ((time .eq.1) .and. (jlay .gt. 155)) then
endif
call decomp1(Copm, Nopm, hcnv, kopm, spar(i)%k_syn_frt, hdiff)
slit(i)%C_opm_frt(jlay) = Copm
slit(i)%N_opm_frt(jlay) = Nopm
cnv_opm(jlay) = hcnv
else
hdiff = 0.
endif ! Nopm
s_hdiff = s_hdiff + hdiff
Nopm = Nopm_crt_1(i)
kopm = redopm * spar(i)%k_opm_crt
if (Nopm .ge. 1e-8 .and. kopm .ge. 1e-8) then
Copm = Copm_crt_1(i)
hcnv = f_cnv(Copm, Nopm)
if ((time .eq.1) .and. (jlay .gt. 155)) then
endif
select case (flag_decomp)
case (0, 10, 20, 30, 40)
call decomp1(Copm, Nopm, hcnv, kopm, spar(i)%k_syn_crt, hdiff)
case (1, 11, 21, 31, 41)
call decomp2(Copm, Nopm, hcnv, kopm, spar(i)%k_syn_crt, hdiff)
end select
slit(i)%C_opm_crt(jlay) = Copm
slit(i)%N_opm_crt(jlay) = Nopm
cnv_opm(jlay) = hcnv
else
hdiff = 0.
endif ! Nopm
s_hdiff = s_hdiff + hdiff
enddo ! nspecies
! Decomposition of biochar
if (flag_bc .gt. 0) then
if (C_bc(jlay) .gt. 1e-8) then
kbc = redbc * k_bc
if (kbc .ge. 1e-8) then
hcnv_bc = f_cnv(C_bc(jlay), N_bc(jlay))
call decomp1(C_bc(jlay), N_bc(jlay), hcnv_bc, kbc, k_syn_bc, hdiff)
s_hdiff = s_hdiff + hdiff
endif
endif
endif
ldecomp = .FALSE.
C_opm(jlay) = SUM(slit%C_opm_frt(jlay)) + SUM(slit%C_opm_crt(jlay))
N_opm(jlay) = SUM(slit%N_opm_frt(jlay)) + SUM(slit%N_opm_crt(jlay))
! C- and N-humus-pool: reduction by mineralization,
! supply by turnover of organic primary matter
C_hum(jlay) = redtermc + reptermc
hnhum = redtermn + reptermn
N_hum(jlay) = hnhum
! ammonium pool
hnh4 = term1 + term2 + term3 + khr/(knr-khr) * term4
NH4(jlay) = hnh4
nhdiff = N_hum_1 - N_hum(jlay)
nh4diff = NH4_1 - NH4(jlay)
bilanz = NO3(jlay) + s_hdiff &
+ nhdiff + nh4diff
Nminl = NH4(jlay) - NH4_1 - NO3(jlay) ! daily net min.
! nitrate pool from balance
hno3 = NO3_1 + s_hdiff + nhdiff + nh4diff
NO3(jlay) = hno3
if (hnh4 .lt. 0.0 .or. hno3 .lt. 0.0) then
redopm = 0.9 * redopm
if (redopm .ge. 1E-8) then
ldecomp = .TRUE.
else
if (NH4(jlay) .lt. 1E-10) NH4(jlay) = 0.
if (NO3(jlay) .lt. 1E-10) NO3(jlay) = 0.
endif
endif
Nminl = Nminl + NO3(jlay) ! daily net min. per layer
bilanz = bilanz - NO3(jlay)
enddo ! ldecomp
Nmin(jlay) = Nminl
N_min = N_min + Nminl ! cumul. yearly net min.
call n_leach(jlay) ! without balance
! new balance after leaching
NH4(jlay) = NH4(jlay) - NH4_in
NO3(jlay) = NO3(jlay) - NO3_in
call n_upt(jlay) ! with balance
if (flag_dayout .ge. 2) then
write (unit_soicna, '(E12.3)', advance='no') remin
write (unit_soicnd, '(E12.3)', advance='no') Nminl
endif
END subroutine minlay
!**************************************************************
SUBROUTINE n_leach(jlay)
! N leaching and new balance
! Addition of deposition to the anorganic pools
use data_climate
use data_simul
use data_soil
use data_soil_cn
use help_soil_cn
use data_species
implicit none
! input:
integer jlay ! number of actual layer
!-----------------------------------------------------------
real NH4f, NO3f ! free available NH4-, NO3-N
real perc_w ! relative part of percolated water
! NH4 and NO3 partly fixed
if (NH4(jlay) .lt. 1E-25) then
continue
endif
NH4f = NH4(jlay) * pNH4f
NO3f = NO3(jlay) * pNO3f
! relative part of percolated water
perc_w = perc(jlay) / (wats(jlay) + perc(jlay) + wupt_r(jlay) + wupt_ev(jlay))
! N transport
NH4_in = NH4f * perc_w
NO3_in = NO3f * perc_w
END subroutine n_leach
!**************************************************************
SUBROUTINE s_resp(Copm_1, Chum_1, Cbc_1)
! Estimation of soil respiration
use data_climate
use data_simul
use data_soil
use data_soil_cn
use help_soil_cn
use data_species
implicit none
! input:
real Copm_1, Chum_1, Cbc_1 ! previous C-content of soil profile
real Sum_C_opm, Sum_C_hum, Sum_C_bc
!-----------------------------------------------------------
Sum_C_opm = SUM(C_opm) + C_opm_stem
Sum_C_hum = SUM(C_hum)
respsoil = Copm_1 + Chum_1 - Sum_C_opm - Sum_C_hum
if (flag_bc .gt. 0) then
Sum_C_bc = SUM(C_bc)
respsoil = respsoil + Cbc_1 - Sum_C_bc
endif
END subroutine s_resp
!**************************************************************
SUBROUTINE s
!
use data_climate
use data_simul
use data_soil
use data_soil_cn
use help_soil_cn
use data_species
implicit none
END subroutine s
!**************************************************************
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* linking SOIL_C/N - Programs with forest module *!
!* *!
!* Author: F. Suckow *!
!* *!
!* contains: *!
!* S_CN_INI *!
!* S_CN_GENER *!
!* CN_INP *!
!* N_UPT(jlay) *!
!* READ_LITTER_INPUT *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE s_cn_ini
! Initialisation of soil data and parameters for C/N-module
use data_simul
use data_soil
use data_soil_cn
use data_species
use data_stand
implicit none
integer i, j
type (species_litter) :: sliti
real, external :: f_cnv, rmin_p, rnit_p
real :: xx, xcnv
! turnover biochar
k_bc = 0.00005
k_syn_bc =0.03
do j = 1, nlay
if (C_hum(j) .lt.0.) then
if (.not.flag_mult8910) call error_mess(time, 'missing value of C_hum set to 0.0 in layer ', real(j))
C_hum(j) = 0.0
endif
if (N_hum(j) .lt.0.) then
if (.not.flag_mult8910) call error_mess(time, 'missing value of N_hum set to 0.0 in layer ', real(j))
N_hum(j) = 0.0
endif
enddo
!!! zum Test ohne Primaersubstanz !!!
C_opm = 0.
N_opm = 0.
!!! zum Test ohne Primaersubstanz !!!
call s_cn_gener
! Convert concentration (mg/l) into contents (g/m2) per layer
NH4 = NH4 * 0.001 *wats
NO3 = NO3 * 0.001 *wats
if (flag_lit .eq. 0) then
! to even out balance for generated values ==> new values for C_ / N_hum
do j = 1, nlay
xx = C_hum(j)
if (N_hum(j) .gt. 1E-6) then
xcnv = f_cnv(C_hum(j), N_hum(j))
if (xx .gt. C_opm(j)) then
C_hum(j) = xx - C_opm(j)
N_hum(j) = C_hum(j) / xcnv
endif
endif
enddo
endif
! reduction of mineralization and nitrification depending on pH
do j=1,nlay
if (phv(j) .lt. 0) then
rmin_phv(j) = 1
rnit_phv(j) = 1
else
rmin_phv(j) = rmin_p(phv(j))
rnit_phv(j) = rnit_p(phv(j))
endif
cnv_opm(j) = f_cnv(C_opm(j), N_opm(j))
cnv_hum(j) = f_cnv(C_hum(j), N_hum(j))
enddo
call s_year ! calculate a year's values for start year as well
wats(1) = field_cap(1) ! ensuring consistency, in case novel calculation was done in s_year
! yearly cumulative quantities
N_min = 0.
N_lit = 0.
C_lit = 0.
C_accu = C_tot
Nleach_c = 0.
Nupt_c = 0.
Nupt_d = 0.
resps_c = 0.
END subroutine s_cn_ini
!**************************************************************
SUBROUTINE s_cn_gener
! Initialisation of soil data and parameters for C/N-module
use data_par
use data_simul
use data_soil
use data_soil_cn
use data_species
use data_stand
implicit none
integer i, j
real dbm_c ! C content of dead biomass
real dbm_frt ! C content of dead fine root biomass
real dbm_part ! part of dead biomass of previous years
real e_part ! part of dead biomass of one year
real t_day
real hconvd ! conversion factor kg/patchsize ==> g/m2
real hconvda ! conversion in C content and from tree to cohort
real, external :: f_cnv
type (species_litter) :: sliti
C_opm = 0.
N_opm = 0.
do i = 1, nspecies
if (i .eq. nspec_tree+2) then
continue
endif
sliti = slit(i)
sliti%species_name = spar(i)%species_name
if (flag_lit .eq. 0) then
sliti%C_opm_fol = 0.
sliti%C_opm_tb = 0.
sliti%C_opm_stem = 0.
sliti%C_opm_frt = 0.
sliti%C_opm_crt = 0.
endif
sliti%N_opm_fol = 0.
sliti%N_opm_tb = 0.
sliti%N_opm_stem = 0.
sliti%N_opm_frt = 0.
sliti%N_opm_crt = 0.
slit(i) = sliti
enddo
hconvd = 1000. / kpatchsize
if (flag_lit .eq. 0) then
zeig => pt%first
do
if (.not. associated(zeig)) exit
i = zeig%coh%species
if (i .ne. nspec_tree+2) then ! no litter initialisation for Mistletoe
sliti = slit(i)
hconvda = cpart * zeig%coh%ntreea
! consider decomposition rate, i.e. biomass of previous years
j = 1
t_day = 365.
dbm_part = 0.
do
! consider dependency on temp. and water
e_part = exp (-spar(i)%k_opm_fol * 0.2 * j * t_day)
dbm_part = dbm_part + e_part
if (e_part .gt. 0.001) then
j = j+1
else
exit
endif
enddo
select case (flag_dis)
case (1,2)
zeig%coh%litC_fol = spar(i)%psf * zeig%coh%x_fol * hconvda !(spar(i)%psf * zeig%coh%x_fol+zeig%coh%x_fol_loss) * hconvda, diese idee wieder weg ! Umrechnung in g/m2 erst in subr. litter
case (0)
zeig%coh%litC_fol = spar(i)%psf * zeig%coh%x_fol * hconvda ! conversion in g/m2 first into subr. litter
end select
zeig%coh%litN_fol = zeig%coh%litC_fol * (1.-spar(i)%reallo_fol) / spar(i)%cnr_fol
dbm_c = dbm_part * zeig%coh%litC_fol * hconvd
sliti%C_opm_fol = sliti%C_opm_fol + dbm_c
!dead fine root biomass of humus layer
! consider decomposition rate, i.e. biomass of previous years
j = 1
t_day = 365.
dbm_part = 0.
do
! consider dependency on temp. and water
e_part = exp (-spar(i)%k_opm_frt * 0.2 * j * t_day)
dbm_part = dbm_part + e_part
if (e_part .gt. 0.001) then
j = j+1
else
exit
endif
enddo
! change see foliage
select case (flag_dis)
case (1,2)
zeig%coh%litC_frt = spar(i)%psr * zeig%coh%x_frt * hconvda ! conversion in g/m2 first into subr. litter
case (0)
zeig%coh%litC_frt = spar(i)%psr * zeig%coh%x_frt * hconvda ! conversion in g/m2 first into subr. litter
end select
zeig%coh%litN_frt = zeig%coh%litC_frt * (1.-spar(i)%reallo_frt) / spar(i)%cnr_frt
dbm_c = dbm_part * zeig%coh%litC_frt * hconvd * (1.-spar(i)%reallo_frt) / spar(i)%cnr_frt
dbm_frt = dbm_c * zeig%coh%frtrel(1)
sliti%C_opm_frt(1) = sliti%C_opm_frt(1) + dbm_frt
sliti%N_opm_frt(1) = sliti%N_opm_frt(1) + dbm_frt
! Total fine root biomass must be distributed over all soil layers
do j = 2, nlay
dbm_frt = dbm_c * zeig%coh%frtrel(j)
sliti%C_opm_frt(j) = sliti%C_opm_frt(j) + dbm_frt
sliti%N_opm_frt(j) = sliti%N_opm_frt(j) + dbm_frt
enddo
slit(i) = sliti
endif ! (i .ne. nspec_tree+2)
zeig => zeig%next
enddo
endif
do i = 1, (nspec_tree+1) !exclusion of mistletoe
sliti = slit(i)
if (flag_lit .gt. 0) then
dbm_frt = sliti%C_opm_frt(1)
dbm_c = sliti%C_opm_crt(1)
do j = 1, nlay
sliti%C_opm_frt(j) = dbm_frt * root_fr(j)
sliti%N_opm_frt(j) = sliti%C_opm_frt(j) * (1.-spar(i)%reallo_frt) / spar(i)%cnr_frt
sliti%C_opm_crt(j) = dbm_c * root_fr(j)
enddo
endif
sliti%N_opm_fol = sliti%C_opm_fol * (1.-spar(i)%reallo_fol) / spar(i)%cnr_fol
! pools of dead biomass without stems
C_opm(1) = C_opm(1) + sliti%C_opm_fol + sliti%C_opm_tb + sliti%C_opm_frt(1) + sliti%C_opm_crt(1)
N_opm(1) = N_opm(1) + sliti%N_opm_fol + sliti%N_opm_tb + sliti%N_opm_frt(1) + sliti%N_opm_crt(1)
slit(i) = sliti
enddo
do j=2,nlay
C_opm(j) = SUM(slit%C_opm_frt(j)) ! + SUM(slit%C_opm_crt(j))
N_opm(j) = SUM(slit%N_opm_frt(j)) ! + SUM(slit%N_opm_crt(j))
if (C_opm(j) < 0.) then
continue
endif
enddo
! Total OPM of all species
END subroutine s_cn_gener
!**************************************************************
SUBROUTINE cn_inp
! Input of dead biomass (all fractions) into soil C- and N-pools
! call from simulation_4C
use data_simul
use data_par
use data_soil
use data_soil_cn
use data_species
use data_stand
implicit none
integer i, j
real hconvd, hf, hc, hfc, hfn, hfrtc, hfrtn, hfc1, Copm, Nopm, Clitf, Nlitf
type (species_litter) :: sliti
real, external :: f_cnv
Clitf = 0.
Nlitf = 0.
N_lit = 0.
C_lit = 0.
C_lit_fol = 0.
N_lit_fol = 0.
C_lit_frt = 0.
N_lit_frt = 0.
C_lit_crt = 0.
N_lit_crt = 0.
C_lit_tb = 0.
N_lit_tb = 0.
C_lit_stem = 0.
N_lit_stem = 0.
select case (flag_decomp)
case (20,21)
if (time .gt. 0) call read_litter_input
case(30,31)
continue
case default
! Input of litter into primary organic matter pools
! litter: x kg/tree to g/m2 (n*x*1000g/(kPatchSize m2))
! values are aggregated already as cohort
hconvd = 1000. / kpatchsize
zeig => pt%first
do while (associated(zeig))
ns = zeig%coh%species
sliti = slit(ns)
sliti%C_opm_fol = sliti%C_opm_fol + zeig%coh%litC_fol * hconvd
sliti%N_opm_fol = sliti%N_opm_fol + zeig%coh%litN_fol * hconvd
sliti%C_opm_stem = sliti%C_opm_stem + zeig%coh%litC_stem * hconvd
sliti%N_opm_stem = sliti%N_opm_stem + zeig%coh%litN_stem * hconvd
sliti%C_opm_tb = sliti%C_opm_tb + zeig%coh%litC_tb * hconvd
sliti%N_opm_tb = sliti%N_opm_tb + zeig%coh%litN_tb * hconvd
hfc = zeig%coh%litC_frt * hconvd
hfn = zeig%coh%litN_frt * hconvd
hfrtc = hconvd * zeig%coh%litC_crt
hfrtn = hconvd * zeig%coh%litN_crt
do i = 1,nroot_max
hfc1 = zeig%coh%frtrel(i)
sliti%C_opm_frt(i) = sliti%C_opm_frt(i) + hfc * hfc1
sliti%N_opm_frt(i) = sliti%N_opm_frt(i) + hfn * hfc1
sliti%C_opm_crt(i) = sliti%C_opm_crt(i) + hfrtc * hfc1
sliti%N_opm_crt(i) = sliti%N_opm_crt(i) + hfrtn * hfc1
enddo ! i (nroot_max)
C_lit_frt = C_lit_frt + zeig%coh%litC_frt
N_lit_frt = N_lit_frt + zeig%coh%litN_frt
C_lit_crt = C_lit_crt + zeig%coh%litC_crt
N_lit_crt = N_lit_crt + zeig%coh%litN_crt
C_lit_fol = C_lit_fol + zeig%coh%litC_fol
N_lit_fol = N_lit_fol + zeig%coh%litN_fol
C_lit_tb = C_lit_tb + zeig%coh%litC_tb
N_lit_tb = N_lit_tb + zeig%coh%litN_tb
C_lit_stem = C_lit_stem + zeig%coh%litC_stem
N_lit_stem = N_lit_stem + zeig%coh%litN_stem
slit(ns) = sliti
zeig => zeig%next
enddo ! show (cohorts)
do i = 1,nspec_tree
! input of delayed litter fall from dead stems
slit(i)%C_opm_tb = slit(i)%C_opm_tb + dead_wood(i)%C_tb(1)
slit(i)%N_opm_tb = slit(i)%N_opm_tb + dead_wood(i)%N_tb(1)
slit(i)%C_opm_stem = slit(i)%C_opm_stem + dead_wood(i)%C_stem(1)
slit(i)%N_opm_stem = slit(i)%N_opm_stem + dead_wood(i)%N_stem(1)
C_lit_tb = C_lit_tb + dead_wood(i)%C_tb(1)
N_lit_tb = N_lit_tb + dead_wood(i)%N_tb(1)
C_lit_stem = C_lit_stem + dead_wood(i)%C_stem(1)
N_lit_stem = N_lit_stem + dead_wood(i)%N_stem(1)
enddo ! i (nspec_tree)
! conversion g/m2/patch --> g/m2
C_lit_fol = C_lit_fol * hconvd
N_lit_fol = N_lit_fol * hconvd
C_lit_frt = C_lit_frt * hconvd
N_lit_frt = N_lit_frt * hconvd
C_lit_crt = C_lit_crt * hconvd
N_lit_crt = N_lit_crt * hconvd
C_lit_tb = C_lit_tb * hconvd
N_lit_tb = N_lit_tb * hconvd
C_lit_stem= C_lit_stem * hconvd
N_lit_stem= N_lit_stem * hconvd
end select ! flag_decomp
do j=1,nlay
cnv_opm(j) = f_cnv(C_opm(j), N_opm(j))
cnv_hum(j) = f_cnv(C_hum(j), N_hum(j))
enddo
Clitf = C_lit_frt + C_lit_crt
Nlitf = N_lit_frt + N_lit_crt
C_lit = C_lit_fol + C_lit_tb + Clitf
N_lit = N_lit_fol + N_lit_tb + Nlitf
C_lit_m = C_lit + C_lit_m
N_lit_m = N_lit + N_lit_m
C_opm = 0.
N_opm = 0.
C_opm_stem = 0.
do i = 1,nspecies
C_opm(1) = C_opm(1) + slit(i)%C_opm_frt(1) + slit(i)%C_opm_crt(1) &
+ slit(i)%C_opm_fol + slit(i)%C_opm_tb
N_opm(1) = N_opm(1) + slit(i)%N_opm_frt(1) + slit(i)%N_opm_crt(1) &
+ slit(i)%N_opm_fol + slit(i)%N_opm_tb
C_opm_stem = C_opm_stem + slit(i)%C_opm_stem
do j = 2,nlay
C_opm(j) = C_opm(j) + slit(i)%C_opm_frt(j) + slit(i)%C_opm_crt(j)
N_opm(j) = N_opm(j) + slit(i)%N_opm_frt(j) + slit(i)%N_opm_crt(j)
enddo
enddo
END subroutine cn_inp
!**************************************************************
SUBROUTINE read_litter_input
! Reading of litter input data
use data_soil_cn
use data_simul
integer lyear, lspec, ios
real helpC, helpN
logical :: lin = .TRUE.
type (species_litter) :: sliti
if (lin) read(unit_litter,*,iostat=ios) lyear, lspec, helpC, helpN
if (ios .lt. 0) lin = .FALSE.
do while (lyear .lt. time_cur)
if (lin) read(unit_litter,*,iostat=ios) lyear, lspec, helpC, helpN
if (ios .lt. 0) then
lin = .FALSE.
exit
endif
enddo
do while (lyear .eq. time_cur)
sliti = slit(lspec)
sliti%C_opm_fol = sliti%C_opm_fol + helpC
sliti%N_opm_fol = sliti%N_opm_fol + helpN
C_lit_fol = C_lit_fol + helpC
N_lit_fol = N_lit_fol + helpN
slit(lspec) = sliti
if (lin) read(unit_litter,*,iostat=ios) lyear, lspec, helpC, helpN
if (ios .lt. 0) then
lin = .FALSE.
exit
endif
enddo
if (lin) backspace (unit_litter)
END subroutine read_litter_input
!**************************************************************
SUBROUTINE n_upt(jlay)
! N uptake by roots
use data_climate
use data_par
use data_simul
use data_soil
use data_soil_cn
use help_soil_cn
use data_species
use data_stand
implicit none
! input:
integer jlay ! number of actual layer
integer i, ntr
!-----------------------------------------------------------
real NH4f, NO3f ! free available NH4-, NO3-N
real NH4u, NO3u, Nutot ! uptake of NH4-N, NO3-N, Nan_tot
real NH4jl, NO3jl ! NH4-, NO3-N
real watlay ! total water content of layer before uptake and perc.
real upt_w ! relative part of uptake water
real :: etau = 0.036 ! parameter from A. Friend (1997)
real :: fft ! temperature function of uptake from Thornley (1991)
real :: ft0 = 0. , &
ftmax = 30. , &
ftref = 20. ! parameter (°C) of temperature function from Thornley (1991)
real help, hNupt, hNupt1, Nutot1, h1, h2, N_ava, frtrel, hfrtrel, hxw
real, dimension(1:anz_coh) :: N_dem ! auxilary array for cohorts
real, external :: fred1
! no roots -> no N-uptake
if (root_fr(jlay) .lt. 1E-10) then
Nupt(jlay) = 0.
return
endif
! all NH4 and NO3 plant available
NH4jl = NH4(jlay)
NO3jl = NO3(jlay)
NH4f = NH4jl
NO3f = NO3jl
! relative part of uptake water
watlay = wats(jlay) + wupt_r(jlay)
upt_w = wupt_r(jlay) / watlay
! uptake of total available N
upt_w = 1.
fft = (temps(jlay)-ft0)*(2.*ftmax-ft0-temps(jlay))/((ftref-ft0)*(2.*ftmax-ft0-ftref))
if (fft .lt. 0.) then
fft = 0.
else
if (fft .gt. 1) fft = 1.
endif
NH4u = NH4f * fred1(jlay)
NO3u = NO3f * fft * fred1(jlay)
Nutot = (NH4u + NO3u)
Nutot1 = 0. ! actual N uptake per layer
! Uptake per cohort and m2
select case (flag_decomp)
case (0, 1, 10, 11, 20, 21, 30, 31)
if (wupt_r(jlay) .lt. 1E-10) then
Nupt(jlay) = 0.
return
else
! new balance
NH4jl = NH4(jlay) - NH4u
NO3jl = NO3(jlay) - NO3u
if (Nutot .ge. zero) then
i = 1
hxw = 0.
zeig => pt%first
do while (associated(zeig))
if (zeig%coh%species.ne.nspec_tree+2) then !exclude mistletoe
ntr = zeig%coh%ntreea
hNupt = Nutot * xwatupt(i,jlay) / wupt_r(jlay)
Nutot1 = Nutot1 + hNupt
N_ava = hNupt * kpatchsize
N_ava = N_ava /ntr ! g per tree
zeig%coh%Nuptc_d = zeig%coh%Nuptc_d + N_ava ! in g per tree
N_ava = N_ava * ntr ! Balance in g/m2
i = i+1
endif !exclusion of mistletoe
zeig => zeig%next
enddo
Nutot1 = Nutot
else
Nutot1 = 0.
do i = 1, anz_coh
xNupt(i,jlay) = 0.
enddo
endif
endif
case (40, 41)
! Ansatz A. Friend (1997, Gl. 13)
if (Nutot .ge. 1.e-6) then
i = 1
hxw = 0.
zeig => pt%first
do while (associated(zeig))
if (zeig%coh%species.ne.nspec_tree+2) then !exclude mistletoe
ntr = zeig%coh%ntreea
frtrel = zeig%coh%frtrelc(jlay) ! root percentage of the entire cohort
hNupt = frtrel * Nutot ! available nitrogen per tree cohort and layer g
hxw = hxw + frtrel
h2 = Nutot * kpatchsize
h1 = h2 * frtrel
N_ava = h1/ntr
hNupt1 = N_ava
h1 = zeig%coh%Ndemc_c - zeig%coh%Nuptc_c
h2 = zeig%coh%Ndemc_d - zeig%coh%Nuptc_d
help = h1 + h2 ! limited by actual and resudual cohort N-demand in g/m2
! limited by actual and residual cohort N-demand in g per tree
if (help .gt. N_ava) then
zeig%coh%Nuptc_d = zeig%coh%Nuptc_d + N_ava ! in g per tree
else
if (help .gt. 0.) then
zeig%coh%Nuptc_d = zeig%coh%Nuptc_d + help ! in g/m2 per Coh.
N_ava = help
else
N_ava = 0.
endif
endif
N_ava = N_ava * ntr ! balance in g/m2
h1 = N_ava
if (NH4jl .lt. h1+zero) then
h1 = h1 - NH4jl
NH4jl = zero
if (NO3jl .lt. h1+zero) then
h1 = h1 - NO3jl
NO3jl = zero
else
NO3jl = NO3jl - h1
endif
else
NH4jl = NH4jl - h1
h1 = 0.
endif
if ((NH4jl .lt. 0.) .or. (NO3jl .lt. 0.)) then
continue
endif
Nutot1 = Nutot1 + N_ava
xNupt(i,jlay) = N_ava
i = i+1
endif !exclusion of mistletoe
zeig => zeig%next
enddo
Nutot1 = Nutot1/kpatchsize
else
Nutot1 = 0.
do i = 1, anz_coh
xNupt(i,jlay) = 0.
enddo
endif
end select
NH4(jlay) = NH4jl
NO3(jlay) = NO3jl
Nupt(jlay) = Nutot1 ! N uptake per layer
END subroutine n_upt
!**************************************************************
!*****************************************************************!
!* *!
!* 4C (FORESEE) Simulation Model *!
!* *!
!* *!
!* Subroutines for: *!
!* SOIL-Temperature - Programs *!
!* *!
!* Author: F. Suckow *!
!* *!
!* contains: *!
!* SOIL_TEMP main program for soil temperature *!
!* S_T_INI initialisation of soil temperature model *!
!* S_T_STRT initialisation of geometry parameter for the *!
!* numerical solution of the heat conduction equation *!
!* SURF_T calculation of the soil surface temperature *!
!* COND calculation of conductivity parameters *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE soil_temp
! soil temperature model
use data_simul
use data_climate
use data_soil
use data_soil_t
use data_out
implicit none
integer i
! Surface temperature
call surf_t
if (flag_dayout .eq. 3) then
write (3334,*)
write (3334,*) iday
endif
! Calculation of thermal conductivity and capacity
do i=1,nlay
call cond(i,wats(i),dens(i),thick(i),pv_v(i),sandv(i),clayv(i),siltv(i),skelv(i),vol(i),spheat(i),t_cond(i),h_cap(i))
enddo ! i (nlay)
call cond(nlay, wats(nlay),dens(nlay),sh(nlay1),pv_v(nlay),sandv(nlay),clayv(nlay),siltv(nlay),skelv(nlay),vol(nlay),spheat(nlay),t_cond(nlay1),h_cap(nlay1))
call cond(nlay, wats(nlay),dens(nlay),sh(nlay2),pv_v(nlay),sandv(nlay),clayv(nlay),siltv(nlay),skelv(nlay),vol(nlay),spheat(nlay),t_cond(nlay2),h_cap(nlay2))
! Calculation of thermal diffusivity
t_cb(1) = t_cond(1)
do i=2,nlay2
t_cb(i) = (sh(i-1)*t_cond(i-1) + sh(i)*t_cond(i))/(sh(i)+sh(i-1))
enddo
if (flag_dayout .eq. 4) then
do i=1,nlay
write (3336,'(3I4, 5E11.4)') time,iday,i,watvol(i),dens(i),spheat(i),t_cond(i),h_cap(i)
enddo
write (3336, *)
endif
! Numerical solution of the heat conduction equation
call num_t
lfirst = .FALSE.
! Restore of temperature
do i=1,nlay
if (abs(sbt(i)) .lt. 1e-6) sbt(i)=0.
temps(i) = sbt(i)
enddo
! soil heat flux at soil surface
hflux_surf = 2. * t_cond(1) * (temps_surf - temps(1)) / thick(1)
1010 FORMAT (2I5, 20F8.1)
END subroutine soil_temp
!******************************************************************************
SUBROUTINE s_t_ini
! Initialisation of soil temperature model
use data_simul
use data_soil
use data_soil_t
implicit none
integer i
real, external:: kw
real tc_cont ! thermal conductivity of continuum
! Preparation of subroutine cond
! Parameter initialisation
water%tc = 0.005945 ! thermal conductivity of water at 20C J/cm/s/K
quarz%tc = 0.0879228 ! thermal conductivity of quarz at 20C
humus%tc = 0.00251 ! thermal conductivity of humus
clay%tc = 0.0251208 ! thermal conductivity of clay minerals
silt%tc = 0.02931 ! thermal conductivity of silt
air%tc = 0.00026 ! thermal conductivity of air
ice%tc = 0.021771 ! thermal conductivity of ice
stone%tc = 0.041868 ! thermal conductivity of stone
water%hc = 4.1868 ! heat capacity of water J/cm3/K
quarz%hc = 2.01 ! heat capacity of quarz
humus%hc = 2.512 ! heat capacity of humus
clay%hc = 2.01 ! heat capacity of clay minerals
silt%hc = 2.01 ! heat capacity of silt
air%hc = 0.0012 ! heat capacity of air
ice%hc = 1.884 ! heat capacity of ice
stone%hc = 1.8 ! heat capacity of stone
! shape factors
quarz%ga = 0.144 ! de Vries, S. 224
clay%ga = 0.144
silt%ga = 0.144
stone%ga = 0.144
humus%ga = 0.333
air%ga = 0.333
ice%ga = 0.125
! weighting factors for dry soil (continuous medium air)
tc_cont = air%tc
water%kwa = kw(water, tc_cont)
quarz%kwa = kw(quarz, tc_cont)
clay%kwa = kw(clay, tc_cont)
silt%kwa = kw(silt, tc_cont)
humus%kwa = kw(humus, tc_cont)
ice%kwa = kw(ice, tc_cont)
stone%kwa = kw(stone, tc_cont)
air%kwa = 1
! weighting factors for wet soil (continuous medium water)
tc_cont = water%tc
water%kww = 1
quarz%kww = kw(quarz, tc_cont)
clay%kww = kw(clay, tc_cont)
silt%kww = kw(silt, tc_cont)
humus%kww = kw(humus, tc_cont)
ice%kww = kw(ice, tc_cont)
stone%kww = kw(stone, tc_cont)
air%kww = kw(air, tc_cont)
if (flag_dayout .eq. 3) then
write (3335, '(A)') 'wet soil'
write (3335,'(6E11.4)') water%kww, air%kww, humus%kww, quarz%kww, clay%kww,ice%kww
write (3335, '(A)') 'dry soil'
write (3335,'(6E11.4)') water%kwa, air%kwa, humus%kwa, quarz%kwa, clay%kwa,ice%kwa
endif
! Calculation of thermal diffusivity
do i=1,nlay
call cond(i,wats(i),dens(i),thick(i),pv_v(i),sandv(i),clayv(i),siltv(i),skelv(i),vol(i),spheat(i),t_cond(i),h_cap(i))
enddo
call s_t_prof
call s_t_strt
! Calculation of thermal diffusivity (additional layers)
call cond(nlay, wats(nlay),dens(nlay),sh(nlay1),pv_v(nlay),sandv(nlay),clayv(nlay),siltv(nlay),skelv(nlay),vol(nlay),spheat(nlay),t_cond(nlay1),h_cap(nlay1))
call cond(nlay, wats(nlay),dens(nlay),sh(nlay2),pv_v(nlay),sandv(nlay),clayv(nlay),siltv(nlay),skelv(nlay),vol(nlay),spheat(nlay),t_cond(nlay2),h_cap(nlay2))
t_cb(1) = t_cond(1)
do i=2,nlay2
t_cb(i) = (sh(i-1)*t_cond(i-1) + sh(i)*t_cond(i))/(sh(i)+sh(i-1))
enddo
END subroutine s_t_ini
!******************************************************************************
SUBROUTINE s_t_strt
! Initialisation of geometry parameter for the
! numerical solution of the heat conduction equation
use data_soil
use data_soil_t
implicit none
integer i
real h_0, h_1
real :: ntau = 1. ! potential time step
lfirst = .TRUE.
nlay1 = nlay+1
nlay2 = nlay+2
sh(1) = thick(1)
sb(1) = 2. / sh(1)
sv(mfirst) = sh(mfirst)
sbt(mfirst) = temps_surf
do i=mfirst+1,nlay
sbt(i) = temps(i)
sh(i) = thick(i)
enddo
sbt(nlay1) = temps(nlay)
sbt(nlay2) = temps(nlay)
sh(nlay1) = 2. * thick(nlay)
sh(nlay2) = 100.
h_0 = sh(1)
do i= mfirst+1, nlay2
h_1 = sh(i)
sb(i) = 2. / (h_1 + h_0)
sv(i) = h_1 * ntau
h_0 = h_1
enddo
END subroutine s_t_strt
!******************************************************************************
SUBROUTINE surf_t
! Calculation of soil surface temperature
use data_climate
use data_simul
use data_soil
use data_soil_t
use data_stand
implicit none
real day
real cof ! daily correction cefficient
real dampcof ! stand damping coefficient
real helplai ! thermal conductivity of organic layer (global vereinbaren und vom Vortag merken!!!)
integer unit_tmp, helptyp
character(80) text
! read surface temperature; Oberflaechentemperatur einlesen
if (flag_surf .eq. 2) then
if (lfirst) then
write (*,'(A)', advance='no') 'Reading of soil surface temperature, please type file name:'
read (*,'(A)') text
unit_tmp = getunit()
open (unit_tmp, file=trim(text), status='unknown')
read (unit_tmp,'(A)') text
read (unit_tmp, *) day, temps_surf
return
else
read (unit_tmp, *) day, temps_surf
return
endif
endif
! snow
if (snow .lt. 0.05) then ! calculation of temps_surf in subroutine snowpack
dampcof = 1.0
if (waldtyp .ge. 110 .and. (waldtyp .ne. 125)) then
helptyp = 110
else
helptyp = waldtyp
endif
select case (helptyp)
case (10,20,25,30,31,35,37,38,70,71,75,76,125) ! Spruce; Fichte
if (iday .lt. 90 .or. (iday .gt. 320)) then
dampcof=0.8
else if (iday .lt. 115) then
dampcof=1.0
else if (iday .gt. 240) then
dampcof=1.0
else
dampcof=0.7
endif
case (40,50,51,52,54,55,56,60,61,62,64,65,66,90,100) ! Pine; Kiefer
if (iday .lt. 90 .or. (iday .gt. 320)) then
dampcof=1.5
else if (iday .lt. 115) then
dampcof=1.2
else if (iday .gt. 285) then
dampcof=1.3
else
dampcof=0.8
endif
case (110) ! Beech and other decidous trees; Buche und andere Laubhoelzer
if (LAI .gt. 1.) then
if (iday .gt. 50) then
if (iday .lt. 100 .or. (iday .gt. 300 .and. iday .lt. 345)) then
dampcof=1.2
else if (iday .gt. 130 .and. iday .le. 300) then ! for beech; fuer Buche
dampcof=0.8 ! for beech; fuer Buche
endif
endif
else
dampcof=1.2 ! for beech; fuer Buche
endif
end select
! Daempfung berechnen nach Paul et al. (2004)
day = iday
cof = abs(-0.00003*day*day + 0.0118*day - 0.0703)
if (flag_surf .eq. 0) then
temps_surf = (c0*airtemp + c1*airtemp_1 + c2*airtemp_2) * cof * dampcof
temps(1) = temps_surf
else
if (flag_surf .eq. 3) then
cof = 1
dampcof = 1.0
endif
temps_surf = (c0*airtemp + c1*airtemp_1 + c2*airtemp_2) * cof * dampcof
endif
endif ! snow
if (flag_dayout .eq. 3) then
write (1222,'(A,I5,F10.4,3F8.2)') 'day, cof, dampcof', iday, cof, dampcof, temps_surf, airtemp
endif
END subroutine surf_t
!******************************************************************************
SUBROUTINE cond(ilay,watsi,densi,thicki,pvi,sandi,clayi,silti,skelvi,voli,spheati,tcondi,hcapi)
! Calculation of thermal conductivity and capacity
! de Vries-approach
use data_par
use data_soil
use data_soil_cn
use data_soil_t
use data_simul
implicit none
! input
integer ilay ! number of layer
real watsi ! water content mm
real densi ! soil density
real thicki ! layer thickness
real spheati ! specific heat capacity
real dmi ! dry mass g/m2
real pvi ! pore volume
real quarzi ! quarz fraction in soild soil
real sandi ! sand fraction in soild soil
real clayi ! clay fraction in soild soil
real silti ! silt fraction in soild soil
real skelvi ! skeleton fraction in soil
real tc_cont ! thermal conductivity of continuum
real wcvol ! water content (vol%)
! output
real tcondi, tcond0, tcond1, tcond2, tcond3 ! thermal conductivity
real hcapi, hcap0, hcap1, hcap2, hcap3 ! thermal capacity
real numera, denom ! numerator, denominator of calculation of thermal conductivity
real hum_dens, densi1, pvi1, hvf, hvf1
real aa, bb, cc, dd, vfm, vfs, massfr ! Campbell-Ansatz
real wkw,akw,hkw,qkw,ckw,skw,ikw,tkw, skel, voli, restvol
! density g/cm3
hum_dens = 1.3 !Density of humus (compressed, without air)
quarzi = sandi
! dry mass
dmi = voli * densi
voli = thicki * 10000.
hvf = (C_opm(ilay) + C_hum(ilay)) / cpart ! Masse (g)
! volume fractions
skel = 1. - skelvi
pvi1 = skel * pvi/100.
water%vf = skel * watsi/(10.*thicki)
air%vf = pvi1 - water%vf
if (air%vf .lt. 0.) then
continue
endif
hvf = hvf / hum_dens ! volume; Volumen
restvol = voli - (skelvi + pvi1)*voli - hvf
humus%vf = hvf / voli
quarz%vf = quarzi*restvol / voli
clay%vf = clayi*restvol / voli
silt%vf = silti*restvol / voli
stone%vf = skelvi
ice%vf = 0.
if (flag_dayout .ge. 3) then
write (3334,'(3I4,F8.3,8F10.4)') time,iday,ilay,pvi1, water%vf, air%vf,humus%vf,quarz%vf,clay%vf,silt%vf,stone%vf,ice%vf
if (ilay .eq. nlay) write (3334, *)
endif
select CASE (flag_cond)
CASE (1, 11, 21, 31, 41) ! Neusypina
if (densi .lt. 0.6) then
densi1 = 0.6
else
densi1 = densi
endif
wcvol = watsi/(10.*thicki)
tcondi = ((3.*densi1-1.7)*0.001)/(1.+(11.5-5.*densi1) &
*EXP((-50.)*(wcvol/densi1)**1.5))*86400.
tcondi = tcondi * 4.1868 ! convertation cal/(cm s K) in J/(cm s K)
! heat capacity J/(cm3 K)
hcapi = densi1*spheati + wcvol*4.1868
hcap1 = hcapi
tcond1 = tcondi
CASE (0, 10, 20, 30, 40) ! de Vries
! Determination of continuous medium
if (watsi .gt. 0.95 * pv(ilay)) then
! wet soil
wkw = water%kww
akw = air%kww
hkw = humus%kww
qkw = quarz%kww
ckw = clay%kww
skw = silt%kww
tkw = stone%kww
ikw = ice%kww
else
! dry soil
wkw = water%kwa
akw = air%kwa
hkw = humus%kwa
qkw = quarz%kwa
ckw = clay%kwa
skw = silt%kwa
tkw = stone%kwa
ikw = ice%kwa
endif
numera = wkw * water%vf * water%tc + qkw * quarz%vf * quarz%tc + ckw * clay%vf * clay%tc + &
skw * silt%vf * silt%tc + hkw * humus%vf * humus%tc + akw * air%vf * air%tc + &
tkw * stone%vf * stone%tc + ikw * ice%vf * ice%tc
denom = wkw * water%vf + qkw * quarz%vf + ckw * clay%vf + skw * silt%vf + &
hkw * humus%vf + akw * air%vf + tkw * stone%vf + ikw * ice%vf
tcond0 = numera/denom * 86400. ! s --> day
CASE(3, 13, 23, 33, 43) ! Campbell
vfm = clay%vf + silt%vf + stone%vf
vfs = vfm + quarz%vf + humus%vf
if (watsi .gt. 0.95 * pv(ilay)) then
! wet soil
aa = 0.57 + 1.73*quarz%vf + 0.93*vfm
aa = aa / (1. - 0.74*quarz%vf - 0.49*vfm) - 2.8*vfs*(1.-vfs)
bb = 2.8 * vfs * water%vf
tcond3 = (aa + bb * water%vf) ! W/m/K
else if (watsi .le. wilt_p(ilay)) then
! dry soil
tcond3 = 0.03 + 0.7 * vfs * vfs ! W/m/K
else
massfr = 2.65 * (vfm + quarz%vf) + 1.3 * humus%vf
massfr = 2.65 * clay%vf / massfr
aa = 0.57 + 1.73*quarz%vf + 0.93*vfm
aa = aa / (1. - 0.74*quarz%vf - 0.49*vfm) - 2.8*vfs*(1.-vfs)
bb = 2.8 * vfs * water%vf
cc = 1. + 2.6 * sqrt(clay%vf)
dd = 0.03 + 0.7 * vfs * vfs
tcond3 = aa + bb*water%vf - (aa-dd) * exp(-(cc*water%vf)**4) ! W/m/K
endif
tcond3 = tcond3 / 100. ! W/m/K ==> J/(cm s K)
tcond3 = tcond3 * 86400. ! s --> day
end select
! heat capacity J/(cm3 K)
hcap0 = water%vf * water%hc + quarz%vf * quarz%hc + clay%vf * clay%hc + silt%vf * silt%hc + &
humus%vf * humus%hc + air%vf * air%hc + stone%vf * stone%hc + ice%vf * ice%hc
if (flag_dayout .eq. 4) then
write (3337,'(3I4, 6E11.4)') time,iday,ilay,tcond0,tcond1,tcond2,tcond3,hcap0,hcap1
if (ilay .eq. nlay) write (3337, *)
endif
select CASE (flag_cond)
CASE (0, 10, 20, 30, 40) ! de Vries
hcapi = hcap0
tcondi = tcond0
CASE (1, 11, 21, 31, 41) ! Neusypina
hcapi = hcap1
tcondi = tcond1
CASE (3, 13, 23, 33, 43) ! Campbell
hcapi = hcap0
tcondi = tcond3
end select
END subroutine cond
!**************************************************************
real FUNCTION kw(part, tc_cont)
! Function for calculating weighting factor k
! in calculating thermal conductivity
use data_soil_t
implicit none
type (therm_par):: part ! soil fraction (particles)
real tc_cont ! thermal conductivity of continuum
real term, ga
term = part%tc / tc_cont -1.
ga = part%ga
kw = (2./(1.+ term*ga) + 1./(1.+ term*(1.-2.*ga)))/3.
end FUNCTION
!******************************************************************************
SUBROUTINE num_t
! Numerical solution of the heat conduction equation
use data_soil
use data_soil_t
use data_simul
implicit none
integer i
logical lcase ! logical control of Cholesky procedure
real hflux ! heat flux at surface (right side)
lcase = .TRUE.
! Determination of the volume matrix
svv = sv * h_cap
if (lfirst) svva = svv
! Determination (side diagonal; Nebendiagonale) !
do i=1,nlay2
son(i) = -sb(i) * t_cb(i)
enddo
son(nlay2+1) = 0.0
! Determination (main diagonal; Hauptdiagonale) !
do i=1,nlay2
soh(i) = svv(i) - son(i) - son(i+1)
enddo
hflux = temps_surf * sb(1) * t_cb(1) ! Set heat flux at surface at right side
if (.not.lfirst) then
! Calculation of the right side
do i=1,nlay2
sxx(i) = (svva(i) + (svv(i)-svva(i))/sh(i)) * sbt(i)
enddo
sxx(1) = sxx(1) + hflux
! Iteration (Cholesky procedure)
call chl3 (nlay2, son, soh, sxx, lcase)
! Results of iteration on temperature help array
sbt = sxx
endif ! lfirst
! Restore of geometry matrix
svva = svv
END subroutine num_t
!******************************************************************************
SUBROUTINE chl3 (n, a, b, x, lcase)
! Solution of EX = Z (E - tridiagonal, symmetric matrix)
! with Cholesky procedure (E = LDL')
implicit none
! input
integer n ! rang of matrix
logical lcase ! logical control of Cholesky procedure
! .TRUE. for start of iteration
real, dimension(n) :: a, & ! Nebendiagonale
b ! main diagonal
! output
real, dimension(n) :: x ! solution vector
! local variables
integer i, j, j1
real, dimension(n) :: d, ul
! Calculation of the left upper triangle matrix L
! and of the diagonal matrix D at start of iteration
if (lcase) then
d(1) = b(1)
do i=2,n
ul(i) = a(i) / d(i-1)
d(i) = b(i) - ul(i)*a(i)
enddo
lcase = .FALSE.
endif
! Solution of LY = Z
do i=2,n
x(i) = x(i) - ul(i)*x(i-1)
enddo
! Solution of L'X = D(-1)Y
x(n) = x(n) / d(n)
do i=1,n-1
j = n-i
j1 = j+1
x(j) = x(j)/d(j) - ul(j1)*x(j1)
enddo
END subroutine chl3
!******************************************************************************
!*****************************************************************!
!* 4C (FORSEE) Simulation Model *!
!* *!
!* *!
!* contains: *!
!* s_t_prof generates initial soil temp. profile *!
!* BTFOUR TRICOF use to develope soil-surface-temp. *!
!* *!
!* Copyright (C) 1996-2018 *!
!* Potsdam Institute for Climate Impact Reserach (PIK) *!
!* Authors and contributors see AUTHOR file *!
!* This file is part of 4C and is licensed under BSD-2-Clause *!
!* See LICENSE file or under: *!
!* http://www.https://opensource.org/licenses/BSD-2-Clause *!
!* Contact: *!
!* https://gitlab.pik-potsdam.de/foresee/4C *!
!* *!
!*****************************************************************!
SUBROUTINE s_t_prof
! Generation of initial soil temperature profile
use data_par
use data_soil
use data_soil_t
use data_simul
implicit none
integer i, ia, ie, k
real ath, dth, rfr, sn, uhf, u, vk, vh, fourterm
real tcsu, hcsu
ia = 1
ie = 365
TQ = 10.
CALL BTFOUR
tcsu = 0.
hcsu = 0.
rfr = 2. * pi / 365. ! radial frequency; Radialfrequenz
UHF=2.*pi/(IE-IA+1)
u = uhf * it
! calculation of temperature profile commonly from day 1 (it=1) set in data_soil;
! Temperaturprofil berechnen, standardmaessig it=1 (1. Tag) in data_soil gesetzt
do i = 1, nlay
tcsu = tcsu + t_cond(i)*thick(i)
hcsu = hcsu + h_cap(i)*thick(i)
ath = tcsu / hcsu ! for a weighted mean both values are divided by the depth (i), thus they cancel each other; fuer gewichtetes Mittel beide Werte durch depth(i) teilen ==> weggekuerzt
DTH=SQRT(2*ATH/RFR)
VH=mid(I)/DTH
fourterm = 0.
do k = 1, nk
VK=VH*SQRT(K+0.)
SN=FTA(K)*EXP(-VK)*SIN(U*K+FTO(K)-VK)
fourterm = fourterm + SN
enddo
temps(i) = TQ + fourterm
if (flag_dayout .eq. 3) write (2244, *) i, temps(i), mid(i), ath, dth, fourterm
enddo
END subroutine s_t_prof
!******************************************************************************
SUBROUTINE BTFOUR
! using TRICOF for a Fourier series development for ground surface temperature;
! Fourierreihenentwicklung fuer Boden-Oberflaechen-Temperatur unter Nutzung von TRICOF
use data_climate
use data_par
use data_soil
use data_soil_t
use data_simul
implicit none
integer i, n, nt, nts, nf, nend, naf, no, ne, lf
real a0
real, dimension(184):: FA,FB
! set amount of auxiliary points NF for transformation;
! Anzahl der Stuetzstellen NF fuer Transformation festlegen
nend = 365
naf = 1
NT=NEND-NAF+1
NTS=1
NF=(NT+NTS-1)/NTS
N=(NF-1)/2
IF((2*N-NF+1) .LT. 0) THEN
NF=NF-1
NT=(NF*NTS)-NTS+1
NEND=NAF+NT-1
ENDIF
NE=1+(NF/2)
NO=NE-2
NK=NO
! calculation of auxiliary points; Stuetzstellen berechnen
LF=NAF
DO I=1,NF
airtemp = tp(lf,1)
airtemp_1 = tp(lf-1,1)
airtemp_2 = tp(lf-2,1)
rad = rd(lf,1)
iday = lf
call surf_t
if (lf .eq. 1) temps(1) = temps_surf
Four_sp(i) = temps_surf
LF=LF+NTS
ENDDO
! Fourier transformation; FOURIERTRANSFORMATION
CALL TRICOF(Four_sp,NF,FA,NE,FB,NO,1)
A0 = FA(1) / 2.
TQ = A0
! coefficient to transform solution; Koeffizienten fuer Loesung transformieren
DO I=1,NK
FTA(I) = SQRT(FA(I+1)*FA(I+1) + FB(I)*FB(I))
FTA(I) = FTA(I) * SIGN(1.,FB(I))
if(FB(I).eq. 0.) then
FTO(I) = pi/2.
else
FTO(I) = ATAN(FA(I+1)/FB(I))
end if
FTO(I) = FTO(I) - (NEND+NAF)*PI*I/(NEND-NAF)
ENDDO
END SUBROUTINE BTFOUR
!******************************************************************************