Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | JulianDate |
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 CalculateDayOfWeek(JulianDate) RESULT (dayOfWeek)
! FUNCTION INFORMATION:
! AUTHOR Linda Lawrie
! DATE WRITTEN March 2012
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! Using Julian date (from jgdate calc), calculate the correct day of week.
! METHODOLOGY EMPLOYED:
! Zeller's algorithm.
! REFERENCES:
! http://en.wikipedia.org/wiki/Zeller%27s_congruence
! and other references around the web.
! USE STATEMENTS:
! na
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: JulianDate ! from JGDate calculation
INTEGER :: dayOfWeek ! EnergyPlus convention (1=Sunday, 2=Monday, etc)
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
INTEGER :: JulDate ! Julian date copy
INTEGER :: Gyyyy ! Gregorian yyyy
INTEGER :: Gmm ! Gregorian mm
INTEGER :: Gdd ! Gregorian dd
JulDate = JulianDate
CALL JGDate(JulianToGregorian,JulDate,Gyyyy,Gmm,Gdd)
! Jan, Feb are 13, 14 months of previous year
IF (Gmm < 3) THEN
Gmm=Gmm+12
Gyyyy=Gyyyy-1
ENDIF
dayOfWeek = MOD(Gdd + (13*(Gmm+1)/5) + Gyyyy + (Gyyyy/4) + 6*(Gyyyy/100) + (Gyyyy/400) , 7)
IF (dayOfWeek == 0) dayOfWeek=7
RETURN
END FUNCTION CalculateDayOfWeek