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.
Errors are severe and fatal because should only be encountered during development.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | VariableName | |||
real(kind=r64), | intent(in), | TARGET | :: | ActualVariable | ||
character(len=*), | intent(in) | :: | IndexTypeKey | |||
character(len=*), | intent(in) | :: | VariableTypeKey | |||
character(len=*), | intent(in) | :: | KeyedValue | |||
character(len=*), | intent(in), | optional | :: | ReportFreq | ||
character(len=*), | intent(in), | optional | :: | ResourceTypeKey | ||
character(len=*), | intent(in), | optional | :: | EndUseKey | ||
character(len=*), | intent(in), | optional | :: | EndUseSubKey | ||
character(len=*), | intent(in), | optional | :: | GroupKey | ||
character(len=*), | intent(in), | optional | :: | ZoneKey | ||
integer, | intent(in), | optional | :: | ZoneMult | ||
integer, | intent(in), | optional | :: | ZoneListMult | ||
integer, | intent(in), | optional | :: | indexGroupKey |
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 SetupRealOutputVariable(VariableName,ActualVariable,IndexTypeKey,VariableTypeKey,KeyedValue, &
ReportFreq,ResourceTypeKey,EndUseKey,EndUseSubKey,GroupKey,ZoneKey,ZoneMult,ZoneListMult,indexGroupKey)
! SUBROUTINE INFORMATION:
! AUTHOR Linda K. Lawrie
! DATE WRITTEN December 1998
! MODIFIED January 2001; Implement Meters
! August 2008; Implement SQL output
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine sets up the variable data structure that will be used
! to track values of the output variables of EnergyPlus.
! METHODOLOGY EMPLOYED:
! Pointers (as pointers), pointers (as indices), and lots of other KEWL data stuff.
! REFERENCES:
! na
! USE STATEMENTS:
USE DataPrecisionGlobals
USE OutputProcessor
USE DataOutputs, ONLY: FindItemInVariableList
USE InputProcessor, ONLY: FindItem,MakeUPPERCase,SameString
USE General, ONLY: TrimSigDigits
USE SQLiteProcedures
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
CHARACTER(len=*), INTENT(IN) :: VariableName ! String Name of variable (with units)
CHARACTER(len=*), INTENT(IN) :: IndexTypeKey ! Zone, HeatBalance=1, HVAC, System, Plant=2
CHARACTER(len=*), INTENT(IN) :: VariableTypeKey ! State, Average=1, NonState, Sum=2
REAL(r64), INTENT(IN), TARGET :: ActualVariable ! Actual Variable, used to set up pointer
CHARACTER(len=*), INTENT(IN) :: KeyedValue ! Associated Key for this variable
CHARACTER(len=*), INTENT(IN), OPTIONAL :: ReportFreq ! Internal use -- causes reporting at this freqency
CHARACTER(len=*), INTENT(IN), OPTIONAL :: ResourceTypeKey ! Meter Resource Type (Electricity, Gas, etc)
CHARACTER(len=*), INTENT(IN), OPTIONAL :: EndUseKey ! Meter End Use Key (Lights, Heating, Cooling, etc)
CHARACTER(len=*), INTENT(IN), OPTIONAL :: EndUseSubKey ! Meter End Use Sub Key (General Lights, Task Lights, etc)
CHARACTER(len=*), INTENT(IN), OPTIONAL :: GroupKey ! Meter Super Group Key (Building, System, Plant)
CHARACTER(len=*), INTENT(IN), OPTIONAL :: ZoneKey ! Meter Zone Key (zone name)
INTEGER, INTENT(IN), OPTIONAL :: ZoneMult ! Zone Multiplier, defaults to 1
INTEGER, INTENT(IN), OPTIONAL :: ZoneListMult ! Zone List Multiplier, defaults to 1
INTEGER, INTENT(IN), OPTIONAL :: indexGroupKey ! Group identifier for SQL output
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER CV
CHARACTER(len=20) IDOut
INTEGER :: IndexType ! 1=TimeStepZone, 2=TimeStepSys
INTEGER :: VariableType ! 1=Average, 2=Sum, 3=Min/Max
INTEGER :: Loop
INTEGER :: RepFreq
LOGICAL :: OnMeter ! True if this variable is on a meter
CHARACTER(len=MaxNameLength) :: VarName ! Variable name without units
! CHARACTER(len=MaxNameLength) :: VariableNamewithUnits ! Variable name with units std format
CHARACTER(len=MaxNameLength) :: ResourceType ! Will hold value of ResourceTypeKey
CHARACTER(len=MaxNameLength) :: EndUse ! Will hold value of EndUseKey
CHARACTER(len=MaxNameLength) :: EndUseSub ! Will hold value of EndUseSubKey
CHARACTER(len=MaxNameLength) :: Group ! Will hold value of GroupKey
CHARACTER(len=MaxNameLength) :: ZoneName ! Will hold value of ZoneKey
LOGICAL :: ErrorsFound=.false. ! True if Errors Found
INTEGER Item
CHARACTER(len=16) :: MtrUnits ! Units for Meter
LOGICAL :: ThisOneOnTheList
CHARACTER(len=UnitsStringLength) :: UnitsString =BlankString ! Units for Variable (no brackets)
INTEGER :: localIndexGroupKey
LOGICAL :: invalidUnits
IF (.not. OutputInitialized) CALL InitializeOutput
!! Errors are severe and fatal because should only be encountered during development.
Item=INDEX(VariableName,'[')
IF (Item /= 0) THEN
UnitsString=GetVariableUnitsString(VariableName)
UnitsString=ADJUSTL(UnitsString)
VarName=ADJUSTL(VariableName(1:Item-1))
! VariableNamewithUnits=trim(VarName)//' ['//trim(UnitsString)//']'
! Check name length for variable name
invalidUnits=.false.
IF (UnitsString(1:1) == '-') invalidUnits=.true.
IF (SameString(UnitsString,'dimensionless')) invalidUnits=.true.
IF (LEN_TRIM(ADJUSTL(VariableName)) > MaxNameLength) THEN
CALL ShowSevereError('Variable Name length (including units) ['// &
trim(TrimSigDigits(LEN_TRIM(ADJUSTL(VariableName))))//'] exceeds maximum='//TRIM(VariableName))
IF (invalidUnits) CALL ShowSevereError('Variable has invalid units in call Variable='//trim(VariableName)// &
', Units='//trim(UnitsString))
CALL ShowFatalError('Program terminates.')
ENDIF
IF (invalidUnits) THEN
CALL ShowSevereError('Variable has invalid units in call Variable='//trim(VariableName)// &
', Units='//trim(UnitsString))
CALL ShowFatalError('Program terminates.')
ENDIF
ELSE ! no units
UnitsString=BlankString
VarName=ADJUSTL(VariableName)
! VariableNamewithUnits=trim(VarName)//' ['//trim(UnitsString)//']'
IF (LEN_TRIM(ADJUSTL(VariableName)) > MaxNameLength) THEN
CALL ShowSevereError('Variable Name has no units in call='//TRIM(VariableName))
CALL ShowSevereError('Variable Name length exceeds maximum='//TRIM(VariableName))
CALL ShowFatalError('Program terminates.')
ENDIF
CALL ShowSevereError('Variable Name has no units in call='//TRIM(VariableName))
CALL ShowFatalError('Program terminates.')
ENDIF
! Determine whether to Report or not
CALL CheckReportVariable(KeyedValue,VarName)
IF (NumExtraVars == 0) THEN
NumExtraVars=1
ReportList=-1
ENDIF
! If ReportFreq present, overrides input
IF (PRESENT(ReportFreq)) THEN
CALL DetermineFrequency(ReportFreq,RepFreq)
NumExtraVars=1
ReportList=0
ENDIF
ThisOneOnTheList=FindItemInVariableList(KeyedValue,VarName)
OnMeter=.false. ! just a safety initialization
DO Loop=1,NumExtraVars
IF (Loop == 1) NumOfRVariable_Setup=NumOfRVariable_Setup+1
IF (Loop == 1) THEN
OnMeter=.false.
IF (PRESENT(ResourceTypeKey)) THEN
ResourceType=ResourceTypeKey
OnMeter=.true.
ELSE
ResourceType=' '
ENDIF
IF (PRESENT(EndUseKey)) THEN
EndUse=EndUseKey
OnMeter=.true.
ELSE
EndUse=' '
ENDIF
IF (PRESENT(EndUseSubKey)) THEN
EndUseSub=EndUseSubKey
OnMeter=.true.
ELSE
EndUseSub=' '
ENDIF
IF (PRESENT(GroupKey)) THEN
Group=GroupKey
OnMeter=.true.
ELSE
Group=' '
ENDIF
IF (PRESENT(ZoneKey)) THEN
ZoneName=ZoneKey
OnMeter=.true.
ELSE
ZoneName=' '
ENDIF
ENDIF
IndexType=ValidateIndexType(IndexTypeKey,'SetupRealOutputVariable')
VariableType=ValidateVariableType(VariableTypeKey)
CALL AddToOutputVariableList(VarName,IndexType,VariableType,VarType_Real,UnitsString)
NumTotalRVariable=NumTotalRVariable+1
IF (.not. OnMeter .and. .not. ThisOneOnTheList) CYCLE
NumOfRVariable=NumOfRVariable+1
IF (Loop == 1 .and. VariableType == SummedVar) THEN
NumOfRVariable_Sum=NumOfRVariable_Sum+1
IF (PRESENT(ResourceTypeKey)) THEN
IF (ResourceTypeKey /= BlankString) NumOfRVariable_Meter=NumOfRVariable_Meter+1
ENDIF
ENDIF
IF (NumOfRVariable > MaxRVariable) THEN
CALL ReallocateRVar
ENDIF
CV=NumOfRVariable
RVariableTypes(CV)%IndexType=IndexType
RVariableTypes(CV)%StoreType=VariableType
RVariableTypes(CV)%VarName=TRIM(KeyedValue)//':'//TRIM(VarName)
RVariableTypes(CV)%VarNameOnly=TRIM(VarName)
RVariableTypes(CV)%VarNameOnlyUC=MakeUPPERCase(VarName)
RVariableTypes(CV)%VarNameUC=MakeUPPERCase(RVariableTypes(CV)%VarName)
RVariableTypes(CV)%KeyNameOnlyUC=MakeUPPERCase(KeyedValue)
RVariableTypes(CV)%UnitsString=UnitsString
CALL AssignReportNumber(CurrentReportNumber)
WRITE(IDOut,*) CurrentReportNumber
IDOut=ADJUSTL(IDOut)
ALLOCATE(RVariable)
RVariable%Value=0.0d0
RVariable%TSValue=0.0d0
RVariable%StoreValue=0.0d0
RVariable%NumStored=0.0d0
RVariable%MaxValue=MaxSetValue
RVariable%maxValueDate=0
RVariable%MinValue=MinSetValue
RVariable%minValueDate=0
RVariableTypes(CV)%Varptr=>RVariable
RVariable%Which=>ActualVariable
RVariable%ReportID=CurrentReportNumber
RVariableTypes(CV)%ReportID=CurrentReportNumber
RVariable%ReportIDChr=IDOut(1:15)
RVariable%StoreType=VariableType
RVariable%Stored=.false.
RVariable%Report=.false.
RVariable%ReportFreq=ReportHourly
RVariable%SchedPtr=0
RVariable%MeterArrayPtr=0
RVariable%ZoneMult=1
RVariable%ZoneListMult=1
IF (PRESENT(ZoneMult) .AND. PRESENT(ZoneListMult)) THEN
RVariable%ZoneMult = ZoneMult
RVariable%ZoneListMult = ZoneListMult
ENDIF
IF (Loop == 1) THEN
IF (OnMeter) THEN
IF (VariableType == AveragedVar) THEN
CALL ShowSevereError('Meters can only be "Summed" variables')
CALL ShowContinueError('..reference variable='//TRIM(KeyedValue)//':'//TRIM(VariableName))
ErrorsFound=.true.
ELSE
MtrUnits=RVariableTypes(CV)%UnitsString
ErrorsFound=.false.
CALL AttachMeters(MtrUnits,ResourceType,EndUse,EndUseSub,Group,ZoneName,CV,RVariable%MeterArrayPtr,ErrorsFound)
IF (ErrorsFound) THEN
CALL ShowContinueError('Invalid Meter spec for variable='//TRIM(KeyedValue)//':'//TRIM(VariableName))
ErrorsLogged=.true.
ENDIF
ENDIF
ENDIF
ENDIF
IF (ReportList(Loop) == -1) CYCLE
RVariable%Report=.true.
IF (ReportList(Loop) == 0) THEN
RVariable%ReportFreq=RepFreq
RVariable%SchedPtr=0
ELSE
RVariable%ReportFreq=ReqRepVars(ReportList(Loop))%ReportFreq
RVariable%SchedPtr=ReqRepVars(ReportList(Loop))%SchedPtr
ENDIF
IF (RVariable%Report) THEN
IF (PRESENT(indexGroupKey)) THEN
localIndexGroupKey = indexGroupKey
ELSE
localIndexGroupKey = -999 ! Unknown Group
ENDIF
IF (RVariable%SchedPtr /= 0) THEN
CALL WriteReportVariableDictionaryItem (RVariable%ReportFreq, RVariable%StoreType, &
RVariable%ReportID, localIndexGroupKey, IndexTypeKey, RVariable%ReportIDChr, KeyedValue, VarName, &
RVariableTypes(CV)%IndexType, RVariableTypes(CV)%UnitsString, &
ReqRepVars(ReportList(Loop))%SchedName)
ELSE
CALL WriteReportVariableDictionaryItem (RVariable%ReportFreq, RVariable%StoreType, &
RVariable%ReportID, localIndexGroupKey, IndexTypeKey, RVariable%ReportIDChr, KeyedValue, VarName, &
RVariableTypes(CV)%IndexType, RVariableTypes(CV)%UnitsString)
END IF
ENDIF
ENDDO
RETURN
END SUBROUTINE SetupRealOutputVariable