Generated by TAPENADE

    !        Generated by TAPENADE     (INRIA, Tropics team)
    !  Tapenade 3.4 (r3375) - 10 Feb 2010 15:08
    !
    !  Differentiation of lgobfun_dv in forward (tangent) mode: (multi-directional mode)
    !   variations   of useful results: lld
    !   with respect to varying inputs: pp
    !   RW status of diff variables: lld:out pp:in
    !        Generated by TAPENADE     (INRIA, Tropics team)
    !  Tapenade 3.4 (r3375) - 10 Feb 2010 15:08
    !
    !  Differentiation of lgobfun in forward (tangent) mode: (multi-directional mode)
    !   variations   of useful results: ll
    !   with respect to varying inputs: pp
    !   RW status of diff variables: ll:out pp:in
    SUBROUTINE LGOBFUN_DV_DV(n, x, y, wts, x0, y0, pp, ppd0, ppd, hx, hy, ll&
    &  , lld, lldd, nbdirs, nbdirs0)
      USE DIFFSIZES_DV
      USE DIFFSIZES
    !  Hint: nbdirsmax should be the maximum number of differentiation directions
      IMPLICIT NONE
      INTEGER, INTENT(IN) :: n
      REAL*8, DIMENSION(n), INTENT(IN) :: x
      REAL*8, DIMENSION(n), INTENT(IN) :: y
      REAL*8, DIMENSION(n), INTENT(IN) :: wts
      REAL*8, INTENT(IN) :: x0
      REAL*8, INTENT(IN) :: y0
      REAL*8, DIMENSION(5), INTENT(IN) :: pp
      REAL*8, DIMENSION(nbdirsmax0, 5), INTENT(IN) :: ppd0
      REAL*8, DIMENSION(nbdirsmax, 5), INTENT(IN) :: ppd
      REAL*8, INTENT(IN) :: hx
      REAL*8, INTENT(IN) :: hy
      REAL*8, INTENT(OUT) :: ll
      REAL*8, DIMENSION(nbdirsmax), INTENT(OUT) :: lld
      REAL*8, DIMENSION(nbdirsmax0, nbdirsmax), INTENT(OUT) :: lldd
      REAL*8, DIMENSION(n) :: lgauss
      REAL*8, DIMENSION(nbdirsmax0, n) :: lgaussd0
      REAL*8, DIMENSION(nbdirsmax, n) :: lgaussd
      REAL*8, DIMENSION(nbdirsmax0, nbdirsmax, n) :: lgaussdd
      REAL*8, DIMENSION(5) :: pars2
      REAL*8, DIMENSION(nbdirsmax0, 5) :: pars2d0
      REAL*8, DIMENSION(nbdirsmax, 5) :: pars2d
      REAL*8, DIMENSION(nbdirsmax0, nbdirsmax, 5) :: pars2dd
      REAL*8, DIMENSION(1) :: xtmp, ytmp, restmp
      REAL*8, DIMENSION(nbdirsmax0, 1) :: xtmpd0, ytmpd0, restmpd0
      REAL*8, DIMENSION(nbdirsmax, 1) :: xtmpd, ytmpd, restmpd
      REAL*8, DIMENSION(nbdirsmax0, nbdirsmax, 1) :: restmpdd
      REAL*8, DIMENSION(5) :: pars
      REAL*8, DIMENSION(nbdirsmax0, 5) :: parsd0
      REAL*8, DIMENSION(nbdirsmax, 5) :: parsd
      REAL*8, DIMENSION(nbdirsmax0, nbdirsmax, 5) :: parsdd
      REAL*8, DIMENSION(n) :: arg1
      REAL*8, DIMENSION(nbdirsmax, n) :: arg1d
      REAL*8, DIMENSION(nbdirsmax0, nbdirsmax, n) :: arg1dd
      REAL*8 :: arg10
      REAL*8, DIMENSION(nbdirsmax0) :: arg10d0
      REAL*8, DIMENSION(nbdirsmax) :: arg10d
      REAL*8, DIMENSION(nbdirsmax0, nbdirsmax) :: arg10dd
      INTEGER :: nd
      INTEGER :: nbdirs
      INTRINSIC EXP
      INTRINSIC SUM
      INTRINSIC SQRT
      REAL*8 :: result1
      REAL*8, DIMENSION(nbdirsmax0) :: result1d
      INTEGER :: nd0
      INTEGER :: nbdirs0
      pars(1:2) = pp(1:2)
      pars(3:4) = EXP(pp(3:4))
      pars(5) = -1.0_8 + 2.0_8*EXP(pp(5))/(1.0_8+EXP(pp(5)))
      DO nd0=1,nbdirs0
        parsd0(nd0, 1:2) = ppd0(nd0, 1:2)
        parsd0(nd0, 3:4) = ppd0(nd0, 3:4)*EXP(pp(3:4))
        parsd0(nd0, 5) = (2.0_8*ppd0(nd0, 5)*EXP(pp(5))*(1.0_8+EXP(pp(5)))-&
    &      2.0_8*EXP(pp(5))**2*ppd0(nd0, 5))/(1.0_8+EXP(pp(5)))**2
        arg10d0(nd0) = 2*pars(3)*parsd0(nd0, 3)
      END DO
      arg10 = pars(3)**2 + hx**2
      DO nd0=1,nbdirs0
        pars2dd(nd0, :, :) = 0.0_8
      END DO
      DO nd0=1,nbdirs0
        arg10dd(nd0, :) = 0.0_8
      END DO
      DO nd0=1,nbdirs0
        parsdd(nd0, :, :) = 0.0_8
      END DO
      DO nd=1,nbdirs
        parsd(nd, 1:2) = ppd(nd, 1:2)
        parsd(nd, 3:4) = ppd(nd, 3:4)*EXP(pp(3:4))
        parsd(nd, 5) = (2.0_8*ppd(nd, 5)*EXP(pp(5))*(1.0_8+EXP(pp(5)))-2.0_8&
    &      *EXP(pp(5))**2*ppd(nd, 5))/(1.0_8+EXP(pp(5)))**2
        DO nd0=1,nbdirs0
          parsdd(nd0, nd, 1:2) = 0.0_8
          parsdd(nd0, nd, 3:4) = ppd(nd, 3:4)*ppd0(nd0, 3:4)*EXP(pp(3:4))
          parsdd(nd0, nd, 5) = ((2.0_8*ppd(nd, 5)*(ppd0(nd0, 5)*EXP(pp(5))*(&
    &        1.0_8+EXP(pp(5)))+EXP(pp(5))**2*ppd0(nd0, 5))-2.0_8*ppd(nd, 5)*2&
    &        *EXP(pp(5))**2*ppd0(nd0, 5))*(1.0_8+EXP(pp(5)))**2-(2.0_8*ppd(nd&
    &        , 5)*EXP(pp(5))*(1.0_8+EXP(pp(5)))-2.0_8*EXP(pp(5))**2*ppd(nd, 5&
    &        ))*2*(1.0_8+EXP(pp(5)))*ppd0(nd0, 5)*EXP(pp(5)))/((1.0_8+EXP(pp(&
    &        5)))**2)**2
          pars2dd(nd0, nd, 1:2) = parsdd(nd0, nd, 1:2)
          arg10dd(nd0, nd) = 2*(parsd0(nd0, 3)*parsd(nd, 3)+pars(3)*parsdd(&
    &        nd0, nd, 3))
        END DO
        pars2d(nd, 1:2) = parsd(nd, 1:2)
        arg10d(nd) = 2*pars(3)*parsd(nd, 3)
        IF (arg10 .EQ. 0.0) THEN
          DO nd0=1,nbdirs0
            pars2dd(nd0, nd, 3) = 0.0_8
          END DO
          pars2d(nd, 3) = 0.0_8
        ELSE
          result1 = SQRT(arg10)
          DO nd0=1,nbdirs0
            IF (arg10 .EQ. 0.0) THEN
              result1d(nd0) = 0.0_8
            ELSE
              result1d(nd0) = arg10d0(nd0)/(2.0*SQRT(arg10))
            END IF
            pars2dd(nd0, nd, 3) = (arg10dd(nd0, nd)*2.0*result1-arg10d(nd)*&
    &          2.0*result1d(nd0))/(2.0*result1)**2
          END DO
          pars2d(nd, 3) = arg10d(nd)/(2.0*result1)
        END IF
        DO nd0=1,nbdirs0
          arg10dd(nd0, nd) = 2*(parsd0(nd0, 4)*parsd(nd, 4)+pars(4)*parsdd(&
    &        nd0, nd, 4))
        END DO
        arg10d(nd) = 2*pars(4)*parsd(nd, 4)
        xtmpd(nd, 1) = 0.0_8
        ytmpd(nd, 1) = 0.0_8
      END DO
      CALL LOGGAUSSPDF_DV_DV(n, x, y, pars, parsd0, parsd, parsdd, lgauss, &
    &                   lgaussd0, lgaussd, lgaussdd, nbdirs, nbdirs0)
      DO nd0=1,nbdirs0
        pars2d0(nd0, 1:2) = parsd0(nd0, 1:2)
        IF (arg10 .EQ. 0.0) THEN
          pars2d0(nd0, 3) = 0.0_8
        ELSE
          pars2d0(nd0, 3) = arg10d0(nd0)/(2.0*SQRT(arg10))
        END IF
        arg10d0(nd0) = 2*pars(4)*parsd0(nd0, 4)
      END DO
      pars2(1:2) = pars(1:2)
      pars2(3) = SQRT(arg10)
      arg10 = pars(4)**2 + hy**2
      DO nd0=1,nbdirs0
        IF (arg10 .EQ. 0.0) THEN
          pars2d0(nd0, 4) = 0.0_8
        ELSE
          pars2d0(nd0, 4) = arg10d0(nd0)/(2.0*SQRT(arg10))
        END IF
      END DO
      pars2(4) = SQRT(arg10)
      DO nd0=1,nbdirs0
        lldd(nd0, :) = 0.0_8
      END DO
      DO nd0=1,nbdirs0
        arg1dd(nd0, :, :) = 0.0_8
      END DO
      DO nd=1,nbdirs
        DO nd0=1,nbdirs0
          arg1dd(nd0, nd, :) = wts*lgaussdd(nd0, nd, :)
          lldd(nd0, nd) = SUM(arg1dd(nd0, nd, :))/(1.0_8*n)
        END DO
        arg1d(nd, :) = wts*lgaussd(nd, :)
        lld(nd) = SUM(arg1d(nd, :))/(1.0_8*n)
        IF (arg10 .EQ. 0.0) THEN
          DO nd0=1,nbdirs0
            pars2dd(nd0, nd, 4) = 0.0_8
          END DO
          pars2d(nd, 4) = 0.0_8
        ELSE
          result1 = SQRT(arg10)
          DO nd0=1,nbdirs0
            IF (arg10 .EQ. 0.0) THEN
              result1d(nd0) = 0.0_8
            ELSE
              result1d(nd0) = arg10d0(nd0)/(2.0*SQRT(arg10))
            END IF
            pars2dd(nd0, nd, 4) = (arg10dd(nd0, nd)*2.0*result1-arg10d(nd)*&
    &          2.0*result1d(nd0))/(2.0*result1)**2
          END DO
          pars2d(nd, 4) = arg10d(nd)/(2.0*result1)
        END IF
        DO nd0=1,nbdirs0
          pars2dd(nd0, nd, 5) = ((((parsdd(nd0, nd, 5)*pars(3)+parsd(nd, 5)*&
    &        parsd0(nd0, 3)+parsd0(nd0, 5)*parsd(nd, 3)+pars(5)*parsdd(nd0, &
    &        nd, 3))*pars(4)+(parsd(nd, 5)*pars(3)+pars(5)*parsd(nd, 3))*&
    &        parsd0(nd0, 4)+(parsd0(nd0, 5)*pars(3)+pars(5)*parsd0(nd0, 3))*&
    &        parsd(nd, 4)+pars(5)*pars(3)*parsdd(nd0, nd, 4))*pars2(3)*pars2(&
    &        4)+((parsd(nd, 5)*pars(3)+pars(5)*parsd(nd, 3))*pars(4)+pars(5)*&
    &        pars(3)*parsd(nd, 4))*(pars2d0(nd0, 3)*pars2(4)+pars2(3)*pars2d0&
    &        (nd0, 4))-((parsd0(nd0, 5)*pars(3)+pars(5)*parsd0(nd0, 3))*pars(&
    &        4)+pars(5)*pars(3)*parsd0(nd0, 4))*(pars2d(nd, 3)*pars2(4)+pars2&
    &        (3)*pars2d(nd, 4))-pars(5)*pars(3)*pars(4)*(pars2dd(nd0, nd, 3)*&
    &        pars2(4)+pars2d(nd, 3)*pars2d0(nd0, 4)+pars2d0(nd0, 3)*pars2d(nd&
    &        , 4)+pars2(3)*pars2dd(nd0, nd, 4)))*pars2(3)**2*pars2(4)**2-(((&
    &        parsd(nd, 5)*pars(3)+pars(5)*parsd(nd, 3))*pars(4)+pars(5)*pars(&
    &        3)*parsd(nd, 4))*pars2(3)*pars2(4)-pars(5)*pars(3)*pars(4)*(&
    &        pars2d(nd, 3)*pars2(4)+pars2(3)*pars2d(nd, 4)))*2*pars2(3)*pars2&
    &        (4)*(pars2d0(nd0, 3)*pars2(4)+pars2(3)*pars2d0(nd0, 4)))/((pars2&
    &        (3)*pars2(4))**2)**2
        END DO
        pars2d(nd, 5) = (((parsd(nd, 5)*pars(3)+pars(5)*parsd(nd, 3))*pars(4&
    &      )+pars(5)*pars(3)*parsd(nd, 4))*pars2(3)*pars2(4)-pars(5)*pars(3)*&
    &      pars(4)*(pars2d(nd, 3)*pars2(4)+pars2(3)*pars2d(nd, 4)))/(pars2(3)&
    &      *pars2(4))**2
      END DO
      arg1(:) = wts*lgauss
      ll = SUM(arg1(:))/(1.0_8*n)
      DO nd0=1,nbdirs0
        pars2d0(nd0, 5) = (((parsd0(nd0, 5)*pars(3)+pars(5)*parsd0(nd0, 3))*&
    &      pars(4)+pars(5)*pars(3)*parsd0(nd0, 4))*pars2(3)*pars2(4)-pars(5)*&
    &      pars(3)*pars(4)*(pars2d0(nd0, 3)*pars2(4)+pars2(3)*pars2d0(nd0, 4)&
    &      ))/(pars2(3)*pars2(4))**2
        xtmpd0(nd0, 1) = 0.0_8
        ytmpd0(nd0, 1) = 0.0_8
      END DO
      pars2(5) = pars(5)*pars(3)*pars(4)/(pars2(3)*pars2(4))
      xtmp(1) = x0
      ytmp(1) = y0
      CALL LOGGAUSSPDF_DV_DV(1, xtmp, ytmp, pars2, pars2d0, pars2d, pars2dd&
    &                   , restmp, restmpd0, restmpd, restmpdd, nbdirs, &
    &                   nbdirs0)
      DO nd=1,nbdirs
        DO nd0=1,nbdirs0
          lldd(nd0, nd) = lldd(nd0, nd) - restmpdd(nd0, nd, 1)*EXP(restmp(1)&
    &        ) - restmpd(nd, 1)*restmpd0(nd0, 1)*EXP(restmp(1))
        END DO
        lld(nd) = lld(nd) - restmpd(nd, 1)*EXP(restmp(1))
      END DO
      ll = ll - EXP(restmp(1))
    END SUBROUTINE LGOBFUN_DV_DV