anchor.diff:  *****************************************************************
             sd    = 1.0d0/(n_thrd*n) 
             chi   = two_thrd*agr*sd 
  -          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
  +          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
  
positive.code:       parameter (DNS_CUT        =      1.0d-18)
  
        real*8 tolrho,minagr
        parameter (tolrho=2.0e-8,minagr=1.0e-10)
  
  *     ***LYP parameters****************
        real*8 a,b,c,d
  
negative.code:       parameter (ETA            =      1.0d-20)
  
        real*8 tolrho,minagr
        parameter (tolrho=2.0e-11,minagr=1.0e-12)
  ****** Becke constants *****************************
        real*8 lda_c,beta
        parameter (beta = 0.0042d0)
  