c $Header: /weru/cvs/weps/weps.src/manage/tillay.for,v 1.2 2001-06-06 15:44:21 jt 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 100 continue tillay = nlay 1000 return end