Program Growing_Degree_Days !-------------------------------------------------------------------------------------- ! Samantha Santeiu ! Meteorology 227 ! Assignment #5 ! Due Date: 09/28/09 ! ! Filename: hw5_SANTEIU.f90 !-------------------------------------------------------------------------------------- ! ! This program takes in values for daily minimum and maximum temperatures, calculates ! the average temperature and number of Growing Degree Days, and outputs those four ! values to the screen. ! ! MaxTemp, MinTemp: temperatures entered by the user (degrees Fahrenheit) ! BaseTemp: base temperature used in calculating the Growing Degree Days (degrees Fahrenheit) ! New_MaxTemp, New_MinTemp: reset due to temperature threshholds (degrees Fahrenheit) ! AvgTemp, New_AvgTemp, GDDays: calculated during execution (degrees/days) ! MaxTemp, MinTemp, AvgTemp, GDDays: outputs printed to the screen (degrees/days) ! ! Inputs: MaxTemp, MinTemp (degrees Fahrenheit) ! Constants: BaseTemp (degrees Fahrenheit) ! Calculated but not displayed: New_MaxTemp, New_MinTemp, New_AvgTemp (degrees Fahrenheit) ! Outputs: MaxTemp, MinTemp, AvgTemp, GDDays (degrees/days) ! !-------------------------------------------------------------------------------------- ! Declaration statements IMPLICIT NONE REAL :: MaxTemp, MinTemp, New_MaxTemp, New_MinTemp, AvgTemp, New_AvgTemp REAL :: GDDays, New_GDDays REAL, PARAMETER :: BaseTemp = 50. ! Get inputs for MaxTemp and MinTemp from the user. PRINT * PRINT *, "Enter the daily maximum and minimum temperatures in degrees Fahrenheit:" READ *, MaxTemp, MinTemp ! Determine whether MaxTemp and MinTemp are within the threshhold level (86 to ! 50 degrees). If the values are not within the threshhold level, set New_MaxTemp ! and/or New_MinTemp equal to the threshhold values. If the values are within the ! threshhold, simply set New_MaxTemp equal to the value of MaxTemp and New_MinTemp ! equal to the value of MinTemp. IF (MaxTemp > 86) THEN New_MaxTemp = 86 ELSE IF (MaxTemp < 50) THEN New_MaxTemp = 50 ELSE New_MaxTemp = MaxTemp END IF IF (MinTemp < 50) THEN New_MinTemp = 50 ELSE IF (MinTemp > 86) THEN New_MinTemp = 86 ELSE New_MinTemp = MinTemp END IF ! Calculate the values for the average temperature with the original values (AvgTemp) ! and the average temperature with the reset values (New_AvgTemp). Use the New_AvgTemp ! to calculate the Growing Degree Days (GDDays). AvgTemp = (MaxTemp + MinTemp) / 2.0 New_AvgTemp = (New_MaxTemp + New_MinTemp) / 2.0 ! Calculate the Growing Degree Days and determine if the value is greater than or ! less than 0. If the GDDays is greater than zero, keep the value; if it is not, ! set the value of GDDays equal to zero. GDDays = New_AvgTemp - BaseTemp IF (GDDays > 0) THEN GDDays = GDDays ELSE GDDays = 0.0 END IF ! Print the max and min temperatures, the average temperature, and the growing ! degree days. PRINT * PRINT *, "For a maximum temperature ", MaxTemp, "degrees Fahrenheit" PRINT *, "and a minimum temperature ", MinTemp, "degrees Fahrenheit" PRINT *, "Average temperature = ", AvgTemp, "degrees Fahrenheit" PRINT *, "Growing degree days = ", GDDays PRINT * ! End Program Statement End Program Growing_Degree_Days