anchor.diff:          xc = lastpos%x
           yc = lastpos%y
   
  -        x = lo%lon(xc,yc)
  -        y = lo%lat(xc,yc)
  +        x = lo%lon(xc, yc)
  +        y = lo%lat(xc, yc)
   
           ! steps to take = the difference the between the current point and the input point / dx
           xstep = (lon-x)/dx
           ystep = (lat-y)/dy
   
  -        ! CASE 1 assume a quasi regular dx/dy and caluate new location
  +        ! CASE 1 assume a quasi regular dx/dy and calculate new location
           !  while we need to step by more than one grid cell, iterate
           !  if the grid is highly regular, we will only iterate 1-2x, highly irregular might require more iterations
           !  in the diabolical case, this could fail?
  
positive.code:     !!
      !!------------------------------------------------------------
      integer function minyw(yw,latgrid,xpos,ypos,lat)
          integer, intent(in)::yw,xpos,ypos
          real,intent(in)::latgrid(:,:),lat
          real::curdist,dx
          integer::ny
  
          ny=size(latgrid,2)
          curdist=abs(lat-latgrid(xpos,ypos))
          if (ypos<ny) then
              dx=abs(latgrid(xpos,ypos)-latgrid(xpos,ypos+1))
          else
              dx=abs(latgrid(xpos,ypos)-latgrid(xpos,ypos-1))
          endif
          minyw=max(yw,ceiling(curdist/dx))
          if (minyw>yw) then
              if (minyw>4) then
                  minyw=ceiling(minyw*0.8)
              endif
          endif
      end function minyw
  
negative.code: 
          real, dimension(:,:), allocatable :: temporary_geo_data
          integer :: nx, ny, i
          integer :: ims,ime,jms,jme
  
          ! if the lat, lon data were given as 1D variables, we need to make them 2D for interpolability
          if (size(domain%lat,2)==1) then
              nx = size(domain%lon,1)
              ny = size(domain%lat,1)
  
              ims = lbound(domain%lon,1)
              ime = ubound(domain%lon,1)
              jms = lbound(domain%lat,1)
              jme = ubound(domain%lat,1)
  
              allocate(temporary_geo_data(ims:ime, jms:jme))
              do i = jms,jme
                  temporary_geo_data(:,i) = domain%lon(:,1)
              end do
  
              deallocate(domain%lon)
              allocate(domain%lon(ims:ime, jms:jme))
              domain%lon = temporary_geo_data
  
              do i = ims, ime
                  temporary_geo_data(i,:) = domain%lat(:,1)
              end do
              deallocate(domain%lat)
              allocate(domain%lat(ims:ime, jms:jme))
              domain%lat = temporary_geo_data
  
          endif
  