program sort_3

!-- read in three real numbers and print them in ascending order

  implicit none
  real :: n1, n2, n3, temp

  call read_the_numbers
  call sort_the_numbers
  call print_the_numbers
  
  contains
  
  subroutine read_the_numbers
  
!-- read the numbers
  read*, n1, n2, n3
  print*, "Input data n1:",n1
  print*, "           n2:",n2
  print*, "           n3:",n3
  
  end subroutine read_the_numbers
  
  subroutine sort_the_numbers
  
!-- sort the numbers
  if (n1 > n2) then
    temp = n1; n1 = n2; n2 = temp
  endif
  if (n1 > n3) then
    temp = n1; n1 = n3; n3 = temp
  endif
  if (n2 > n3) then
    temp = n2; n2 = n3; n3 = temp
  endif
  
  end subroutine sort_the_numbers

  subroutine print_the_numbers

!-- print the numbers
  print *, "The numbers in ascending order are:"
  print *, n1, n2, n3

  end subroutine print_the_numbers
  
end program sort_3