! By Rex L. Baum, 1 April 2004
! revised by H.X. Chen, 2014
module model_vars
    ! variables for rainfall-induced slope failures
	integer:: nts,kper,nmax1,nmax2,nmn,nmin,maxcatchment,cellcount(100)
	integer,allocatable:: jsav(:),templevel(:),roadindx(:),roadsectioncell(:)
	double precision:: test1,dg2rad,qb,level1,level2,level3,level4,level5
	double precision,allocatable:: q(:)
	double precision:: eps,tmin,tmax,ts,tinc,qt,tns,qmax !
	double precision:: test,nodat,sumex,dusz,dcf,vf0 !(:)
	double precision:: celsiz,param(6),parami(6),ti,tis,pi,smt,lard
	double precision,allocatable:: beta(:)
	double precision,allocatable:: zfmin(:),fsmin(:),pmin(:),fdepth(:),pfmin(:)
	double precision,allocatable:: zt(:,:),zb(:,:),dzt(:,:),dzb(:,:),deltazt(:,:),deltazb(:,:),deltadzt(:,:),deltadzb(:,:)
	double precision,allocatable:: kkb(:,:),kkt(:,:),kkb0(:,:),kkt0(:,:),kkb1(:,:),kkt1(:,:),kkb2(:,:),kkt2(:,:)
	double precision,allocatable:: pt(:,:),pb(:,:),pt0(:,:),pb0(:,:),pt1(:,:),pb1(:,:),pt2(:,:),pb2(:,:)
	double precision,allocatable:: fc(:,:),fw(:,:)
	double precision,allocatable:: inithzt(:,:),inithzb(:,:),thzt(:,:),thzb(:,:),inidesatt(:,:),inidesatb(:,:),desatt(:,:),desatb(:,:)
	double precision,allocatable:: uwspt(:),uwspb(:)
	double precision,allocatable:: p(:),ptran(:),pzero(:),bline(:)
	double precision,allocatable:: r(:),kz(:),tcap(:)
	double precision,allocatable:: trz(:),gst(:),gsb(:),gs(:),qtime(:)
	double precision,allocatable:: catchmentarea(:),catchmentdeltah(:),catchmentmouth(:)
	
	! variables for debris flow simulation
	
	! other variables
	double precision:: rhow,rhos
	
	! Auxiliary parameters
	double precision:: t0,dt,ttout,tnow,tminimum,tmaximum,tmean
	double precision, allocatable:: dmax(:),tdmax(:)
	integer:: ntsdeb,avedt
	integer(8):: maxnts
	integer:: ntout,ottout,nhtout,httout
		

end module model_vars


