Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(inout), | DIMENSION(:) | :: | MonWeekDay |
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.
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.
SUBROUTINE SetSpecialDayDates(MonWeekDay)
! SUBROUTINE INFORMATION:
! AUTHOR Linda Lawrie
! DATE WRITTEN March 2012
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! With multiple year weather files (or repeating weather files that rollover day),
! need to set Special Day dates at start of environment or year.
! Special Days are only projected for one year.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
USE General, ONLY: InvJulianDay,JulianDay
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(INOUT),DIMENSION(:) :: MonWeekDay ! Weekday of each day 1 of month
! SUBROUTINE PARAMETER DEFINITIONS:
CHARACTER(len=*), PARAMETER :: RoutineName='SetSpecialDayDates: '
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: Loop
INTEGER :: ThisDay
INTEGER :: JDay
INTEGER :: JDay1
INTEGER :: Loop1
LOGICAL :: ErrorsFound
INTEGER, DIMENSION(12) :: ActEndDayOfMonth
ErrorsFound=.false.
ActEndDayOfMonth=EndDayOfMonth
ActEndDayOfMonth(2)=EndDayOfMonth(2)+LeapYearAdd
SpecialDayTypes=0
DO Loop=1,NumSpecialDays
IF (SpecialDays(Loop)%WthrFile .and. .not. UseSpecialDays) CYCLE
IF (SpecialDays(Loop)%DateType <= MonthDay) THEN
JDay=JulianDay(SpecialDays(Loop)%Month,SpecialDays(Loop)%Day,LeapYearAdd)
IF (SpecialDays(Loop)%Duration == 1 .and. Environment(Envrn)%ApplyWeekendRule) THEN
IF (WeekDayTypes(JDay) == 1) THEN
! Sunday, must go to Monday
JDay=JDay+1
IF (JDay == 366 .and. LeapYearAdd == 0) JDay=1
ELSEIF (WeekDayTypes(JDay) == 7) THEN
JDay=JDay+1
IF (JDay == 366 .and. LeapYearAdd == 0) JDay=1
JDay=JDay+1
IF (JDay == 366 .and. LeapYearAdd == 0) JDay=1
ENDIF
ENDIF
CALL InvJulianDay(JDay,SpecialDays(Loop)%ActStMon,SpecialDays(Loop)%ActStDay,LeapYearAdd)
ELSEIF (SpecialDays(Loop)%DateType == NthDayInMonth) THEN
IF (SpecialDays(Loop)%WeekDay >= MonWeekDay(SpecialDays(Loop)%Month)) THEN
ThisDay=SpecialDays(Loop)%Weekday-MonWeekDay(SpecialDays(Loop)%Month)+1
ELSE
ThisDay=SpecialDays(Loop)%Weekday-MonWeekDay(SpecialDays(Loop)%Month)+1+7
ENDIF
ThisDay=ThisDay+7*(SpecialDays(Loop)%Day-1)
IF (ThisDay > ActEndDayOfMonth(SpecialDays(Loop)%Month)) THEN
CALL ShowSevereError(RoutineName//'Special Day Date, Nth Day of Month, not enough Nths, for SpecialDay='// &
TRIM(SpecialDays(Loop)%Name))
ErrorsFound=.true.
CYCLE
ENDIF
SpecialDays(Loop)%ActStMon=SpecialDays(Loop)%Month
SpecialDays(Loop)%ActStDay=ThisDay
JDay=JulianDay(SpecialDays(Loop)%Month,ThisDay,LeapYearAdd)
ELSE ! LastWeekDayInMonth
ThisDay=SpecialDays(Loop)%Weekday-MonWeekDay(SpecialDays(Loop)%Month)+1
DO WHILE (ThisDay+7 <= ActEndDayOfMonth(SpecialDays(Loop)%Month))
ThisDay=ThisDay+7
ENDDO
SpecialDays(Loop)%ActStMon=SpecialDays(Loop)%Month
SpecialDays(Loop)%ActStDay=ThisDay
JDay=JulianDay(SpecialDays(Loop)%Month,ThisDay,LeapYearAdd)
ENDIF
IF (SpecialDayTypes(JDay) /= 0) THEN
CALL ShowWarningError(RoutineName//'Special Day definition ('//TRIM(SpecialDays(Loop)%Name)// &
') is overwriting previously entered special day period')
IF (UseSpecialDays) THEN
CALL ShowContinueError('...This could be caused by definitions on the Weather File.')
ENDIF
CALL ShowContinueError('...This could be caused by duplicate definitions in the Input File.')
ENDIF
JDay1=JDay-1
DO Loop1=0,SpecialDays(Loop)%Duration-1
JDay1=JDay1+1
IF (JDay1 == 366 .and. LeapYearAdd == 0) JDay1=1
IF (JDay1 == 367) JDay1=1
SpecialDayTypes(JDay1)=SpecialDays(Loop)%DayType
ENDDO
ENDDO
IF (ErrorsFound) THEN
CALL ShowFatalError(RoutineName//'Program terminates due to preceding condition(s).')
ENDIF
RETURN
END SUBROUTINE SetSpecialDayDates