c $Header: /weru/cvs/weps/weps.src/manage/tillay.for,v 1.1.1.1 1999-03-12 17:05:28 wagner Exp $ c c This routine accepts the tillage depth, soil layer thicknesses, c and the number of soil layers. It returns the number of layers c that will be considered to be within the tillage zone for this c operation. integer function tillay i (tdepth, lthick, nlay) real tdepth integer nlay real lthick(nlay) integer i real d if (tdepth .lt. lthick(1)) then tillay = 1 goto 1000 endif d = lthick(1) do 100 i=2, nlay d = d + lthick(i) if (tdepth .lt. d) then if ( (d - tdepth) .lt. (tdepth - (d-lthick(i))) ) then tillay = i goto 1000 else tillay = i-1 goto 1000 endif endif tillay = nlay 100 continue 1000 return end