subroutine find_max_error(these_errors, error, which_element)
! One of the simplest ways to choose the error in F+P reblocking
! is to choose the largest error that's not the one of the last two points
! (which guarentees 8 bits of data)
! General routine, does not require global data
real(dp) :: these_errors(:), error
integer :: length, which_element, i
length = size(these_errors, 1)
error = these_errors(1)
which_element = 1
do i = 2, length - 2
if (these_errors(i) > error) then
error = these_errors(i)
which_element = i
end if
end do
end subroutine find_max_error