Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | ScheduleIndex | |||
integer, | intent(in) | :: | StartDayOfWeek | |||
logical, | intent(in) | :: | isItLeapYear |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
FUNCTION ScheduleAverageHoursPerWeek(ScheduleIndex,StartDayOfWeek,isItLeapYear) RESULT(AverageHoursPerWeek)
! FUNCTION INFORMATION:
! AUTHOR Linda K. Lawrie
! DATE WRITTEN August 2006
! MODIFIED September 2012; Glazer - CR8849
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! This function returns the "average" hours per week for a schedule over
! the entire year.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: ScheduleIndex ! Which Schedule being tested
INTEGER, INTENT(IN) :: StartDayOfWeek ! Day of week for start of year
LOGICAL, INTENT(IN) :: isItLeapYear ! true if it is a leap year containing February 29
REAL(r64) :: AverageHoursPerWeek ! Average Hours Per Week
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
INTEGER :: WkSch
INTEGER :: DayT
INTEGER :: Loop
REAL(r64) :: TotalHours
REAL(r64) :: WeeksInYear
INTEGER :: DaysInYear
IF (isItLeapYear) THEN
DaysInYear = 366
WeeksInYear = 366.d0/7.d0
ELSE
DaysInYear = 365
WeeksInYear = 365.d0/7.d0
ENDIF
IF (ScheduleIndex < -1 .or. ScheduleIndex > NumSchedules) THEN
CALL ShowFatalError('ScheduleAverageHoursPerWeek called with ScheduleIndex out of range')
ENDIF
DayT=StartDayOfWeek
AverageHoursPerWeek=0.0d0
TotalHours=0.0d0
IF (DayT == 0) RETURN
DO Loop=1,DaysInYear
WkSch=Schedule(ScheduleIndex)%WeekSchedulePointer(Loop)
TotalHours=TotalHours+SUM(DaySchedule(WeekSchedule(WkSch)%DaySchedulePointer(DayT))%TSValue)/REAL(NumOfTimeStepInHour,r64)
DayT=DayT+1
IF (DayT > 7) DayT=1
ENDDO
! Total hours for year have been set.
AverageHoursPerWeek=TotalHours/WeeksInYear
RETURN
END FUNCTION ScheduleAverageHoursPerWeek