PROGRAM Temperature_Conversion_1 
!-----------------------------------------------------------------------
! Program to convert several Fahrenheit temperatures to the 
! corresponding Celsius temperatures.  The function Fahr_to_Celsius 
! is used to perform the conversions.  Identifiers used are: 
!   Fahr_to_Celsius : internal function subprogram that converts
!                     Fahrenheit temperatures to Celsius
!   FahrenheitTemp  : a Fahrenheit temperature to be converted
!   CelsiusTemp     : the corresponding Celsius temperature
!   Response        : user response to "More data?" query
!
! Input:   FahrenheitTemp, Response
! Output:  CelsiusTemp
!-----------------------------------------------------------------------

  IMPLICIT NONE
  REAL :: FahrenheitTemp, CelsiusTemp
  CHARACTER(1) :: Response

  DO
     ! Get a Fahrenheit temperature
     WRITE (*, '(1X, A)', ADVANCE = "NO") "Enter a Fahrenheit temperature: "
     READ *, FahrenheitTemp
 
     ! Use the function Fahr_to_Celsius to convert it to Celsius
     CelsiusTemp = Fahr_to_Celsius(FahrenheitTemp)
 
     ! Output the result
     PRINT '(1X, 2(F6.2, A))', FahrenheitTemp, &
           " in Fahrenheit is equivalent to ", CelsiusTemp, " in Celsius"
 
     ! Check if more temperatures are to be converted
     WRITE (*, '(/ 1X, A)', ADVANCE = "NO") &
           "More temperatures to convert (Y or N)? "
     READ *, Response
     IF (Response /= "Y") EXIT
  END DO

CONTAINS

  !- Fahr_To_Celsius ---------------------------------------
  ! Function to convert a Fahrenheit temperature to Celsius
  !
  !   Accepts:  A temperature Temp in Fahrenheit
  !   Returns:  The corresponding Celsius temperature
  !----------------------------------------------------------
   
  FUNCTION Fahr_to_Celsius(Temp)
  
    REAL:: Fahr_to_Celsius
    REAL, INTENT(IN) :: Temp
  
    Fahr_to_Celsius = (Temp - 32.0) / 1.8
  
  END FUNCTION Fahr_to_Celsius
  
END PROGRAM Temperature_Conversion_1
