anchor.diff:  
   *      *************DOWN******************
          chidn = agrdn/ndn**(4.0d0/3.0d0)
  -       chidn2 = chidn*chidn
  -       chidnSQ = dsqrt(1.0d0+chidn2)
  -
  -       Kdn = 6.0d0*beta*dlog(chidn+chidnSQ)
  -       F1dn = chidn2/(1.0d0 + chidn*Kdn)
  -       xedn = -ndn**thrd*(lda_c + beta*F1dn)
  -       F2dn = (2.0d0 + chidn*Kdn
  -     &           - 6.0d0*beta*chidn2/chidnSQ)
  -     &           /(1.0d0+chidn*Kdn)**2.0d0
  -       fdnxdn = -ndn**(thrd)*(4.0d0/3.0d0)
  -     &             *(lda_c+beta*(F1dn-chidn2*F2dn))
  -       fdagrxdn = -beta*chidn*F2dn
  -       if ((fdnxdn-xedn).gt.0.0d0) then
  +       if ((ndn.gt.tolrho)  .and.
  +     >     (agrdn.gt.minagr)) then
  +          chidn2 = chidn*chidn
  +          chidnSQ = dsqrt(1.0d0+chidn2)
  +
  +          Kdn = 6.0d0*beta*dlog(chidn+chidnSQ)
  +          F1dn = chidn2/(1.0d0 + chidn*Kdn)
  +          xedn = -ndn**thrd*(lda_c + beta*F1dn)
  +          F2dn = (2.0d0 + chidn*Kdn
  +     &              - 6.0d0*beta*chidn2/chidnSQ)
  +     &              /(1.0d0+chidn*Kdn)**2.0d0
  +          fdnxdn = -ndn**(thrd)*(4.0d0/3.0d0)
  +     &                *(lda_c+beta*(F1dn-chidn2*F2dn))
  +          fdagrxdn = -beta*chidn*F2dn
  +          !if ((fdnxdn-xedn).gt.0.0d0) then
  +          !   xedn     = -ndn**thrd*(lda_c)
  +          !   fdnxdn   = -ndn**(thrd)*(4.0d0/3.0d0)*(lda_c)
  +          !   fdagrxdn = 0.0d0
  +          !end if
  +       else
             xedn     = -ndn**thrd*(lda_c)
             fdnxdn   = -ndn**(thrd)*(4.0d0/3.0d0)*(lda_c)
             fdagrxdn = 0.0d0
  
positive.code:       parameter (ETA            =      1.0d-20)
  
        real*8 tolrho,minagr
        parameter (tolrho=2.0e-8,minagr=1.0e-10)
  ****** Becke constants *****************************
        real*8 lda_c,beta
        parameter (beta = 0.0042d0)
  
negative.code: *****************************************************************
            sd    = 1.0d0/(n_thrd*n) 
            chi   = two_thrd*agr*sd 
            if ((n.gt.tolrho)  .and.
       >        (agr.gt.minagr)) then
               chi2  = chi*chi
               chiSQ = dsqrt(1.0d0+chi2)   
  
               K  = 6.0d0*beta*dlog(chi+chiSQ)
               F1 = chi2/(1.0d0+chi*K)
               xe = -n_thrd*(lda_c+beta*F1)/two_thrd
               F2 = (2.0d0 + chi*K-(chi2)*6.0d0*beta
       &                /chiSQ)
       &              /((1.0d0+chi*K)*(1.0d0+chi*K))
               fdnx = -(n_thrd/two_thrd)*dble(4.0d0/3.0d0)
       &                  *(lda_c+beta*(F1-chi2*F2))
               fdagrx = -beta*chi*F2 
               !if ((fdnx-xe).gt.0.0d0) then
               !   write(*,*) "i,xe,fdnx,fdagrx=",i,xe,fdnx,fdagrx,chi
               !   xe = -n_thrd*(lda_c)/two_thrd
               !   fdnx = -(n_thrd/two_thrd)*dble(4.0d0/3.0d0)*(lda_c)
               !   fdagrx = 0.0d0
               !end if
            else
               xe = -n_thrd*(lda_c)/two_thrd
               fdnx = -(n_thrd/two_thrd)*dble(4.0d0/3.0d0)*(lda_c)
               fdagrx = 0.0d0
  