anchor.diff:            h_ray(i) = sqrt(sum(xr**2)) - radearth
           end do calc_hray
   
  -        Q(:) = (h_ray - hterr) / (adist * radearth * t)
  -
  -        attn(j) = minval(Q) / 0.01 + 1
  +        attn(j) = minval(h_ray - hterr) / chkray_toler_meters + 1
           if (attn(j) < 0) attn(j) = 0
           if (attn(j) > 1) attn(j) = 1
   
  
positive.code: 
    contains
  
      pure subroutine cross(x,y,z)
        real(dp), dimension(3), intent(in) :: x,y
        real(dp), dimension(3), intent(out) :: z
        z(1) =   x(2)*y(3) - x(3)*y(2)
        z(2) = - x(1)*y(3) + x(3)*y(1)
        z(3) =   x(1)*y(2) - x(2)*y(1)
      end subroutine
  
      elemental real(dp) function f(t, k)
        real(dp), intent(in) :: t, k
  
negative.code:       call geo2xyz(src % lat, src % lng, x1(1), x1(2), x1(3))
        call geo2xyz(      lat,       lng, x2(1), x2(2), x2(3))
  
        xi = cross(x1, x2)
        xi = xi / sqrt(sum(xi**2))
        xw = cross(xi, x1)
  
        interpolate_terrain: do i = 1, nn
          xi(:) = x1 * cos(t(i) * adist) + xw * sin(t(i) * adist)
  