! Program Example from "Essential Fortran 90 & 95" by Loren P. Meissner
! Copyright 1996. Copying for sale requires permission from the author.
! Otherwise, distribution is permitted if these three lines are included.

! Example 3.16. Sort three values into increasing order.
  program D16
    use Swap_Reals_M
    implicit none
    real :: A, B, C
! start program D16
    write (unit = *, fmt = *) " Please enter three numbers to be sorted. "
    read (unit = *, fmt = *) A, B, C
    if (A > B) then
      if (A > C) then
        call Swap( A, C )
      else  ! Do nothing.
      end if
    else
      if (B > C) then
        call Swap( B, C )
      else  ! Do nothing.
      end if
    end if
  ! C now contains the largest of the three values.
    if (A > B) then
      call Swap( A, B )
    else  ! Do nothing.
    end if
    write (unit = *, fmt = *) " The sorted values are: ", A, B, C
    stop
  end program D16
