! !$Author: joelevin $ !$Date: 2011-03-24 11:33:26 -0500 (Thu, 24 Mar 2011) $ !$Revision: 11724 $ !$HeadURL: https://svn.weru.ksu.edu/weru/weps1/trunk/weps.src/src/lib_mproc/rootlay.for $ ! ! This routine accepts the crop root depth, soil layer thicknesses, ! and the number of soil layers. It returns the number of layers ! that will be considered to contain crop roots. integer function rootlay (rtdepth, lthick, nlay) integer nlay real rtdepth real lthick(nlay) integer i real d if ((rtdepth*1000.0) .lt. lthick(1)) then rootlay = 1 goto 1000 endif d = lthick(1) do 100 i=2, nlay d = d + lthick(i) if ((rtdepth*1000.0) .lt. d) then if ((d-(rtdepth*1000.)).lt.((rtdepth*1000.)- & & (d-lthick(i)))) then rootlay = i goto 1000 else rootlay = i-1 goto 1000 endif endif rootlay = nlay 100 continue 1000 return end