anchor.diff:                          lon(k) = lo%lon(xy%x(k), xy%y(k))
                       enddo
                       ! and calculate the weights to apply to each gridcell
  -                    lo%geolut%w(:,i,j) = bilin_weights(hi%lat(i,j), lat, hi%lon(i,j), lon)
  -                endif
  +                    lo%geolut%w(:,i,j) = idw_weights(hi%lat(i,j), lat, hi%lon(i,j), lon)
  +                    ! lo%geolut%w(:,i,j) = bilin_weights(hi%lat(i,j), lat, hi%lon(i,j), lon)
  +                endif
  +                ! if ((j>=93).and.(j<=99)) then
  +                !     if ((i>79).and.(i<85)) then
  +                !         print*, "--------------------"
  +                !         print*, i, j
  +                !         print*, curpos%x, curpos%y
  +                !         print*, lo%geolut%x(1,i,j), lo%geolut%y(1,i,j)
  +                !         print*, hi%lat(i,j), hi%lon(i,j)
  +                !         print*, lo%lat(curpos%x, curpos%y), lo%lon(curpos%x, curpos%y)
  +                !     endif
  +                ! endif
  +
               enddo
           enddo
  -
  +        call io_write("geolut_x.nc","data",lo%geolut%x)
  +        call io_write("geolut_y.nc","data",lo%geolut%y)
  +        call io_write("geolut_w.nc","data",lo%geolut%w)
       end subroutine geo_LUT
   
       !>------------------------------------------------------------
  
positive.code:         find_surrounding%x = [pos%x, pos%x-1, pos%x-1, pos%x  ]
          find_surrounding%y = [pos%y, pos%y,   pos%y-1, pos%y-1]
  
          if (test_surrounding(lat, lon, lo, find_surrounding, nx, ny, 4)) return
  
  
          ! test the upper left quadrant
          find_surrounding%x = [pos%x, pos%x-1, pos%x-1, pos%x  ]
          find_surrounding%y = [pos%y, pos%y,   pos%y+1, pos%y+1]
  
          if (test_surrounding(lat, lon, lo, find_surrounding, nx, ny, 4)) return
  
  
          ! test the upper right quadrant
          find_surrounding%x = [pos%x, pos%x+1, pos%x+1, pos%x  ]
          find_surrounding%y = [pos%y, pos%y,   pos%y+1, pos%y+1]
  
          if (test_surrounding(lat, lon, lo, find_surrounding, nx, ny, 4)) return
  
  
          ! test the lower right quadrant
          find_surrounding%x = [pos%x, pos%x+1, pos%x+1, pos%x  ]
          find_surrounding%y = [pos%y, pos%y,   pos%y-1, pos%y-1]
  
          if (test_surrounding(lat, lon, lo, find_surrounding, nx, ny, 4)) return
  
          write(*,*) "ERROR: Failed to find point", lon, lat, " in a quadrant near:"
          write(*,*) lo%lon(pos%x, pos%y), lo%lat(pos%x, pos%y)
  
negative.code: !!------------------------------------------------------------
  module geo
      use data_structures
      use io_routines, only:io_write
      implicit none
  
      private
  