anchor.diff:      ! TODO: consider rewriting this as a single block estimate and iterate in Python 
       !       use Cython, Numba and parallel computing as way to speed the process 
   
  +
  +    
  +    !-----------------------------------------------------------------------
  +
  +
  +
  +
       !for safety reason we don't want undeclared variables
       IMPLICIT NONE 
   
   
       ! in 
  +    ! data 
  +    integer, intent(in)               :: nd
  +    real*8, intent(in), dimension(nd) :: x,y,z,vr, ve                   !vr->variable, ve->external drift
  +    real*8, intent(in) :: tmin, tmax
  +    integer, intent(in) :: koption
  +    !Jacknife
  +    integer, intent(in)               :: ndjak
  +    real*8, intent(in), dimension(nd) :: xlj, ylj, zlj, vrlj, extvj
  +    ! grid 
  +    integer, intent(in) :: nx,ny,nz
  +    real*8 , intent(in) :: xmn,ymn,zmn,xsiz,ysiz,zsiz
  +    real*8 , intent(in), dimension(nx*ny*nz) :: extve
  +    integer, intent(inout) :: nxdis,nydis,nzdis   
  +    ! search
  +    integer, intent(in) :: ndmax, ndmin
  +    real*8, intent(in) :: radius, radius1, radius2, sang1, sang2, sang3
  +        integer, intent(in) :: noct
  +    integer, intent(in) :: MAXSBX, MAXSBY, MAXSBZ                        ! Don't like this, remove and use kdtree
       ! variogram
       integer, intent(in)  :: nst
       integer, intent(in), dimension(1)     :: it
       real*8, intent(in), dimension(1)      :: c0
       real*8, intent(in), dimension(nst) :: cc,aa, aa1, aa2,ang1,ang2,ang3
  -    ! search
  -    real*8, intent(in) :: radius, radius1, radius2, sang1, sang2, sang3
  -    integer, intent(in) :: MAXSBX, MAXSBY, MAXSBZ
  -    integer, intent(in) :: ndmax, ndmin
  -    ! grid 
  -    integer, intent(in) :: nx,ny,nz
  -    real*8 , intent(in) :: xmn,ymn,zmn,xsiz,ysiz,zsiz
  -    real*8 , intent(in), dimension(nx*ny*nz) :: extve
  -    !Jacknife
  -    integer, intent(in)               :: ndjak
  -    real*8, intent(in), dimension(nd) :: xlj, ylj, zlj, vrlj, extvj
  -    ! data 
  -    integer, intent(in)               :: nd
  -    real*8, intent(in), dimension(nd) :: x,y,z,vr, ve                   !vr->variable, ve->external drift
  -    real*8, intent(in) :: tmin, tmax
       !kriging parameters     
  -    integer, intent(in) :: ktype, koption, noct, itrend
  -    integer, intent(inout) :: nxdis,nydis,nzdis                      
  +    integer, intent(in) :: ktype,  itrend
       real*8, intent(in) :: UNEST
       real*8, intent(inout) :: skmean
  -    
  +    logical, intent(in), dimension(9) :: idrift                           !MAXDT=9     maximum number of drift terms
   
       ! out
       ! kriging parameters
  
positive.code:                 tmin, tmax, nlag,   &                            ! lag definition
                  ndir, ixd, iyd, izd,&                              ! directions and parameters
                  isill, sills, nvarg, ivtail, ivhead,ivtype,  &   ! variograms types and parameters
                  xsiz,ysiz,zsiz, &                                !dummy variable not used here
                  np, gam, hm, tm, hv, tv)                           ! output
  
  
  
negative.code:     ! TODO: np is real here, see if we may declare this as integer
  
      !new variables
      integer, intent(in), dimension(nx*ny*nz)         :: bhid             ! not implemented (use similar to gamv)
  
                 
      ! some general declarations
      real*8 :: PI, EPSLON
      parameter(PI=3.14159265, EPSLON=1.0e-20)
      
  
      !Extra Variables not declared in the original library
      real*8  ::  htave, variance, vrh, vrhpr, vrt,  vrtpr, tempvar
      integer :: i, id, iii, il, it, iv, nsiz, rnum
      integer :: ixinc, iyinc, izinc
      integer :: ix1, iy1, iz1, ix, iy, iz, index, nxy,nxyz
  
  
  