program sort3b
!-- read in three real numbers and print them in ascending order
implicit none
real :: n1, n2, n3
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
call swap (n1, n2)
endif
if (n1 > n3) then
call swap (n1, n3)
endif
if (n2 > n3) then
call swap (n2, n3)
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
subroutine swap(a,b)
real :: a, b, temp
temp = a
a = b
b = temp
end subroutine swap
end program sort3b