PROGRAM sort3a

!-- 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 sort3a

