      module single
        integer, parameter :: float = selected_real_kind ( 6,37 )
        real ( float ) :: pi = 3.1415927_float
        real ( float ) :: e  = 2.7182818_float
      end module single

      module double
        integer, parameter :: float = selected_real_kind ( 15,307 )
        real ( float ) :: pi = 3.141592653589793_float
        real ( float ) :: e  = 2.718281828459045_float
      end module double

      program constants
!
!     Select a precision for the constants for PI and E.
!     USE SINGLE selects single precision whereas
!     USE DOUBLE selects double precision.  Only one
!     precision can be in selected per subprogram.
!     Let the main program select single precision.
      use single
      print *, " "
      print *, "Constants: pi", pi, "and e", e
      call more_precision
      print *, " "
      end program constants

      subroutine more_precision
!
!     Let the subroutine select double precision.
      use double
      print *, " "
      print *, "Constants: pi", pi, "and e", e
      end subroutine more_precision
