anchor.diff:      !-----------------------------------------------------------------------
   
   
  +    ! TODO: simplify this function as mush as possible
  +    !      - split search in to external function (use kdtree for speed)
  +    !      - remove unnecessary variables output an options  
  +    !      - store the debugging info in the last estimate (to test use a single block estimate)
  +    
  +    ! 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 
   
  
positive.code:             resce  = covmax / max(extest,0.0001)
          endif
          
          ! Find the nearest samples:
      
          call srchsupr(xloc,yloc,zloc,radsqd,isrot,MAXROT,rotmat,nsbtosr, &
  
negative.code:         ! ' enough data for OK or SK.   KT3D currently leaves ',/, &
          ! ' these locations unestimated.',/, &
          ! ' This message is only written once - the first time.',/)
      
      
          ! To AAAAAAA -> Put this in a separate function to isolate and add more options (use kdtree for speed, see example scipy)
          ! ----------------------------------------------------------------------------------------------------------------
      
      
      
          ! There are enough samples - proceed with estimation.
          
  