PROGRAM Flow_Through_a_Pipe
!-------------------------------------------------------------------
! Program that reads the density, average forward velocity, and
! viscosity of a  fluid and the diameter of the pipe through which
! it is flowing.  The Reynold's number is calculated and the type
! of flow -- laminar, turbulent, unstable -- is then determined
! according to whether the Reynold's number is less than a lower
! cutoff value, is between two cutoff values, or is greater than
! the larger cutoff value. Identifiers used are:
!   Density, Viscosity    : density and viscosity of the fluid
!   Velocity              : average forward flow of the fluid
!   Diameter              : diameter of the pipe 
!   LowCutoff, HighCutoff : cutoff values that distinguish between
!                             turbulent/laminar and laminar/unstable
!                             types of flow
!   ReynoldsNumber        : the Reynold's number
!
! Input:     Density, Viscosity, Velocity and  Diameter
! Constants: LowCutoff and HighCutoff
! Output:    ReynoldsNumber and a message indicating the type of flow
!-------------------------------------------------------------------

  IMPLICIT NONE
  REAL :: Density, Viscosity, Velocity, Diameter, ReynoldsNumber
  REAL, PARAMETER :: LowCutoff = 2000.0, HighCutoff = 3000.0

  ! Get the density, velocity, viscosity, and diameter
  PRINT *, "Enter the density of the fluid:"
  READ *, Density
  PRINT *, "Enter the viscosity of the fluid:"
  READ *, Viscosity
  PRINT *, "Enter the average forward velocity of the fluid:"
  READ *, Velocity
  PRINT *, "Enter the diameter of the pipe:"
  READ *, Diameter

  ! Calculate the Reynold"s number
  ReynoldsNumber = (Density * Velocity * Diameter) / Viscosity

  ! Display the input data, the Reynold"s number, and a message
  ! indicating the type of flow
  PRINT *, "For a fluid with density ", Density
  PRINT *, "viscosity ", Viscosity
  PRINT *, "and average forward velocity ", Velocity
  PRINT *, "flowing through a pipe of diameter ", Diameter
  PRINT *, "the Reynold's number is ", ReynoldsNumber
  PRINT *

  IF (ReynoldsNumber < LowCutoff) THEN
     PRINT *, "Flow is laminar"
  ELSE IF (ReynoldsNumber < HighCutoff) THEN
     PRINT *, "Flow is unstable"
  ELSE
     PRINT *, "Flow is turbulent"
  END IF

END PROGRAM Flow_Through_a_Pipe
