%N median %F $MIR/src/subs/median.for
%D Find the median of an array of data.
%P rjs
%: miscellaneous
%B
        subroutine median(x,n,xmed)

        implicit none
        integer n
        real x(n),xmed

  Determine the median of an array of real numbers. This sorts the input
  array. On output, the input data array is sorted.

  Input:
    n          Number of points.
  Input/Output:
    x          Data to find the median of. On output, it is sorted in
               ascending order.
  Output:
    xmed       The median of the data.
