c c subroutine invproc(nlay,thick,xcomp) *$noereference include 'p1werm.inc' *$reference c + + + PURPOSE + + + c c Invert the component passed to xcomp c c + + + KEYWORDS + + + c inversion, tillage c c + + + ARGUMENT DECLARATIONS + + + real xcomp(mnsz), thick(mnsz) integer nlay c c + + + ARGUMENT DEFINITIONS + + + c nlay - number of soil layers used c thick - thickness of each layer in a subregion c xcomp - component that needs inverting c c + + + LOCAL VARIABLES + + + integer idx, odx real ithick(mnsz), ixcomp(mnsz) real othick(mnsz) real dthick c + + + LOCAL VARIABLE DEFINITIONS + + + c idx - input index for layers c odx - output index for layers c ithick - inverted thickness of layers c ixcomp - inverted property of layers c othick - temp thickness c dthick - delta thickness C C create inverted layer thickness and property arrays C and zero out output array C do 10 idx=1, nlay ithick(idx) = thick(nlay-idx+1) ixcomp(idx) = xcomp(nlay-idx+1) xcomp(nlay-idx+1) = 0.0 othick(idx) = thick(idx) 10 continue idx = 1 odx = 1 20 dthick = min(ithick(idx), othick(odx)) xcomp(odx) = xcomp(odx) + ixcomp(idx) * dthick ithick(idx) = ithick(idx) - dthick othick(odx) = othick(odx) - dthick if (ithick(idx).eq.0.0) idx = idx + 1 if (othick(odx).eq.0.0) odx = odx + 1 if (idx.le.nlay.and.odx.le.nlay) goto 20 do 30 odx = 1, nlay xcomp(odx) = xcomp(odx) / thick(odx) 30 continue return end C ***c + + + LOCAL VARIABLES + + + C *** C *** integer i C *** real dum(mnsz),dum1(mnsz),dum2(mnsz) C *** real inverse(mnsz), depth(mnsz), oldepth(0:mnsz) C *** real x, new, p(mnsz) C ***c C ***c + + + LOCAL VARIABLE DEFINITIONS + + + C ***c C ***c dum - dummy variable used in making a property array C ***c dum1 - dummy variable used in making a property array C ***c dum2 - dummy variable used in making a property array C ***c depth - depth matrix containing inverted layer depths from the surface C ***c i - loop variable for soil layers C ***c inverse - inverse layer thickness matrix C ***c new - new inverted property value based on interpolation or C ***c extrapolation C ***c oldepth - depth matrix containing original layer depths from the surface C ***c p - property matrix after inversion C ***c x - variable containing the original depths from the surface C ***c used in the call to polint C *** C ***c Do the inversion process. C ***c Initialize the dummy variables to zero. C *** C *** dum(1) = 0.0 C *** dum1(1) = 0.0 C *** dum2(1) = 0.0 C *** oldepth(0) = 0.0 C *** C *** do 100 i=1,nlay C ***c invert the layers (layer thickness) C *** inverse(i) = thick((nlay+1)-i) C ***c invert the property passed to xcomp C *** p(i) = xcomp((nlay+1)-i) C ***c form a property array for the depth (thichness) and component based C ***c on the inverted matrix C *** dum(i+1) = thick(i) C *** dum1(i+1) = inverse(i) C *** depth(i)=inverse(i)/2.0+dum1(i)/2.0+dum2(i) C *** dum2(i+1)= depth(i) C *** oldepth(i)=thick(i)/2.0+dum(i)/2.0+oldepth(i-1) C ***100 continue C ***c C ***c make a call to subroutine polint which takes the current C ***c property matrix and depth matrix and either interpolates C ***c or extrapolates the property matrix to correspond to the C ***c original layer thickness before the inversion process C ***c was performed. Make call for each layer (nlay). C ***c C *** do 200 i=1,nlay C *** x=oldepth(i) C *** call polint(depth, p, nlay, x, new) C ***c C ***c set the component for a layer equal to the interpolated C ***c or extrapolated value calculated in polint.for C ***c C *** xcomp(i) = new C ***200 continue C *** end