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.
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 InitializeRuntimeLanguage
! SUBROUTINE INFORMATION:
! AUTHOR Peter Graham Ellis
! DATE WRITTEN June 2006
! MODIFIED Rui Zhang February 2010
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
!
! METHODOLOGY EMPLOYED:
! One time run. Must be run BEFORE anything gets parsed.
! USE STATEMENTS:
USE DataGlobals, ONLY: Pi, HourOfDay, OutputFileDebug, CurrentTime,TimeStepZone
USE DataEnvironment, ONLY: Year, Month, DayOfMonth, DayOfWeek, DayOfYear, &
SunIsUp, IsRain, HolidayIndex, DSTIndicator, CurEnvirNum
USE DataHVACGlobals, ONLY: TimeStepSys, SysTimeElapsed
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: tmpCurrentTime = 0.d0
REAL(r64) :: tmpMinutes = 0.0D0
REAL(r64) :: tmpHours = 0.0D0
REAL(r64) :: tmpCurEnvirNum = 0.0D0
integer, dimension(8) :: datevalues
!value(1) Current year
!value(2) Current month
!value(3) Current day
!value(4) Time difference with respect to UTC in minutes (0-59)
!value(5) Hour of the day (0-23)
!value(6) Minutes (0-59)
!value(7) Seconds (0-59)
!value(8) Milliseconds (0-999)
character(len=15) datestring ! supposedly returns blank when no date available.
! FLOW:
IF (InitializeOnce) THEN
False = SetErlValueNumber(0.0d0)
True = SetErlValueNumber(1.0d0)
! Create constant built-in variables
NullVariableNum = NewEMSVariable('NULL', 0)
ErlVariable(NullVariableNum)%Value%Type = ValueNull
FalseVariableNum = NewEMSVariable('FALSE', 0, False)
TrueVariableNum = NewEMSVariable('TRUE', 0, True)
OffVariableNum = NewEMSVariable('OFF', 0, False)
OnVariableNum = NewEMSVariable('ON', 0, True)
PiVariableNum = NewEMSVariable('PI', 0, SetErlValueNumber(Pi))
! Create dynamic built-in variables
YearVariableNum = NewEMSVariable('YEAR', 0)
MonthVariableNum = NewEMSVariable('MONTH', 0)
DayOfMonthVariableNum = NewEMSVariable('DAYOFMONTH', 0) ! 'DAYOFMONTH'?
DayOfWeekVariableNum = NewEMSVariable('DAYOFWEEK', 0)
DayOfYearVariableNum = NewEMSVariable('DAYOFYEAR', 0)
HourVariableNum = NewEMSVariable('HOUR', 0)
MinuteVariableNum = NewEMSVariable('MINUTE', 0)
HolidayVariableNum = NewEMSVariable('HOLIDAY', 0)
DSTVariableNum = NewEMSVariable('DAYLIGHTSAVINGS',0)
CurrentTimeVariableNum = NewEMSVariable('CURRENTTIME',0)
SunIsUpVariableNum = NewEMSVariable('SUNISUP', 0)
IsRainingVariableNum = NewEMSVariable('ISRAINING', 0)
SystemTimeStepVariableNum = NewEMSVariable('SYSTEMTIMESTEP', 0)
ZoneTimeStepVariableNum = NewEMSVariable('ZONETIMESTEP', 0)
ErlVariable(ZoneTimeStepVariableNum)%Value = SetErlValueNumber(TimeStepZone)
CurrentEnvironmentPeriodNum = NewEMSVariable('CURRENTENVIRONMENT', 0)
ActualDateAndTimeNum = NewEMSVariable('ACTUALDATEANDTIME', 0)
ActualTimeNum = NewEMSVariable('ACTUALTIME', 0)
CALL GetRuntimeLanguageUserInput ! Load and parse all runtime language objects
CALL DATE_AND_TIME(date=datestring,values=datevalues)
IF (datestring /= ' ') THEN
ErlVariable(ActualDateAndTimeNum)%Value = SetErlValueNumber(REAL(SUM(datevalues),r64))
!datevalues(1)+datevalues(2)+datevalues(3)+ &
!datevalues(5)+datevalues(6)+datevalues(7)+datevalues(8)
ErlVariable(ActualTimeNum)%Value = SetErlValueNumber(REAL(SUM(datevalues(5:8)),r64))
!datevalues(5)+datevalues(6)+datevalues(7)+datevalues(8)
! ELSE
! ErlVariable(ActualDateAndTimeNum)%Value = SetErlValueNumber(real(RANDOM_NUMBER(X=509),r64))
! ErlVariable(ActualTimeNum)%Value = SetErlValueNumber(real(RANDOM_NUMBER(X=400),r64))
ENDIF
InitializeOnce = .FALSE.
END IF
! Update built-in variables
ErlVariable(YearVariableNum)%Value = SetErlValueNumber(REAL(Year,r64))
ErlVariable(MonthVariableNum)%Value = SetErlValueNumber(REAL(Month,r64))
ErlVariable(DayOfMonthVariableNum)%Value = SetErlValueNumber(REAL(DayOfMonth,r64))
ErlVariable(DayOfWeekVariableNum)%Value = SetErlValueNumber(REAL(DayOfWeek, r64))
ErlVariable(DayOfYearVariableNum)%Value = SetErlValueNumber(REAL(DayOfYear, r64))
ErlVariable(DSTVariableNum)%Value = SetErlValueNumber(REAL(DSTIndicator, r64))
!DSTadjust = REAL(DSTIndicator, r64)
tmpHours = REAL(HourOfDay-1,r64) ! no, just stay on 0..23+ DSTadjust ! offset by 1 and daylight savings time
ErlVariable(HourVariableNum)%Value = SetErlValueNumber(tmpHours)
IF (TimeStepSys < TimeStepZone) THEN
!CurrentTime is for end of zone timestep, need to account for system timestep
tmpCurrentTime = CurrentTime - TimeStepZone + SysTimeElapsed + TimeStepSys
ELSE
tmpCurrentTime = CurrentTime
ENDIF
ErlVariable(CurrentTimeVariableNum)%Value = SetErlValueNumber(tmpCurrentTime)
tmpMinutes = ((tmpCurrentTime - REAL(HourOfDay-1,r64)) * 60.0D0) !- 1.d0 ! off by 1
ErlVariable(MinuteVariableNum)%Value = SetErlValueNumber(tmpMinutes)
ErlVariable(HolidayVariableNum)%Value = SetErlValueNumber(REAL(HolidayIndex,r64))
IF (SunIsUp) THEN
ErlVariable(SunIsUpVariableNum)%Value = SetErlValueNumber(1.0D0)
ELSE
ErlVariable(SunIsUpVariableNum)%Value = SetErlValueNumber(0.0D0)
ENDIF
IF (IsRain) THEN
ErlVariable(IsRainingVariableNum)%Value = SetErlValueNumber(1.0D0)
ELSE
ErlVariable(IsRainingVariableNum)%Value = SetErlValueNumber(0.0D0)
ENDIF
ErlVariable(SystemTimeStepVariableNum)%Value = SetErlValueNumber(TimeStepSys)
tmpCurEnvirNum = REAL(CurEnvirNum, r64)
ErlVariable(CurrentEnvironmentPeriodNum)%Value = SetErlValueNumber(tmpCurEnvirNum)
RETURN
END SUBROUTINE InitializeRuntimeLanguage