SUBROUTINE CreateEnergyReportStructure
! SUBROUTINE INFORMATION:
! AUTHOR Dan Fisher/Linda Lawrie
! DATE WRITTEN June 2005
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Creates the Energy Reporting Structure. This routine is only called once --
! so string compares have been left in.
! METHODOLOGY EMPLOYED:
! Once all compsets/nodes/connections have been established find all components
! subcomponents, etc.
! REFERENCES:
! na
! USE STATEMENTS:
USE BranchNodeConnections, ONLY: GetComponentData, GetChildrenData, GetNumChildren, IsParentObject
USE DataGlobalConstants
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
! na
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
INTERFACE GetNumMeteredVariables
FUNCTION GetNumMeteredVariables(ComponentType,ComponentName) RESULT(NumVariables)
CHARACTER(len=*), INTENT(IN) :: ComponentType ! Given Component Type
CHARACTER(len=*), INTENT(IN) :: ComponentName ! Given Component Name (user defined)
INTEGER :: NumVariables
END FUNCTION
END INTERFACE
INTERFACE GetMeteredVariables
SUBROUTINE GetMeteredVariables(ComponentType,ComponentName,VarIndexes,VarTypes,IndexTypes, &
UnitsStrings,ResourceTypes,EndUses,Groups,Names,NumFound,VarIDs)
CHARACTER(len=*), INTENT(IN) :: ComponentType ! Given Component Type
CHARACTER(len=*), INTENT(IN) :: ComponentName ! Given Component Name (user defined)
INTEGER, DIMENSION(:), INTENT(OUT) :: VarIndexes ! Variable Numbers
INTEGER, DIMENSION(:), INTENT(OUT) :: VarTypes ! Variable Types (1=integer, 2=real, 3=meter)
INTEGER, DIMENSION(:), INTENT(OUT) :: IndexTypes ! Variable Index Types (1=Zone,2=HVAC)
CHARACTER(len=*), DIMENSION(:), INTENT(OUT) :: UnitsStrings ! UnitsStrings for each variable
INTEGER, DIMENSION(:), INTENT(OUT) :: ResourceTypes ! ResourceTypes for each variable
CHARACTER(len=*), DIMENSION(:), &
OPTIONAL, INTENT(OUT) :: EndUses ! EndUses for each variable
CHARACTER(len=*), DIMENSION(:), &
OPTIONAL, INTENT(OUT) :: Groups ! Groups for each variable
CHARACTER(len=*), DIMENSION(:), &
OPTIONAL, INTENT(OUT) :: Names ! Variable Names for each variable
INTEGER, OPTIONAL, INTENT(OUT) :: NumFound ! Number Found
INTEGER, DIMENSION(:), OPTIONAL, INTENT(OUT) :: VarIDs ! Variable Report Numbers
END SUBROUTINE
END INTERFACE
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: AirLoopNum
INTEGER :: BranchNum
INTEGER :: CompNum
INTEGER :: SubCompNum
INTEGER :: SubSubCompNum
INTEGER :: VarNum
INTEGER :: VarNum1
INTEGER :: CtrlZoneNum
CHARACTER(len=MaxNameLength) :: TypeOfComp
CHARACTER(len=MaxNameLength) :: NameOfComp
LOGICAL :: ErrorsFound
LOGICAL :: ModeFlagOn
INTEGER :: NumInlets
INTEGER :: NumOutlets
INTEGER :: PlantLoopNum
!Dimension GetChildrenData arrays
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: SubCompTypes
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: SubCompNames
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: InletNodeNames
INTEGER, ALLOCATABLE, DIMENSION(:) :: InletNodeNumbers
INTEGER, ALLOCATABLE, DIMENSION(:) :: InletFluidStreams
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: OutletNodeNames
INTEGER, ALLOCATABLE, DIMENSION(:) :: OutletNodeNumbers
INTEGER, ALLOCATABLE, DIMENSION(:) :: OutletFluidStreams
INTEGER :: NumChildren
INTEGER :: NumGrandChildren
LOGICAL :: IsParent
!Dimension GetMeteredVariables arrays
INTEGER, ALLOCATABLE, DIMENSION(:) :: VarIndexes ! Variable Numbers
INTEGER, ALLOCATABLE, DIMENSION(:) :: VarTypes ! Variable Types (1=integer, 2=real, 3=meter)
INTEGER, ALLOCATABLE, DIMENSION(:) :: IndexTypes ! Variable Index Types (1=Zone,2=HVAC)
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: UnitsStrings ! UnitsStrings for each variable
INTEGER, ALLOCATABLE, DIMENSION(:) :: ResourceTypes ! ResourceTypes for each variable
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: EndUses ! EndUses for each variable
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: Groups ! Groups for each variable
CHARACTER(len=MaxNameLength), ALLOCATABLE, DIMENSION(:) :: Names ! Variable Names for each variable
INTEGER :: NumFound ! Number Found
INTEGER :: NumVariables
INTEGER :: NumLeft ! Counter for deeper components
! some variables for setting up the plant data structures
INTEGER :: LoopSideNum
TYPE (ReportLoopData), POINTER :: ThisReportData
VentReportStructureCreated=.true.
CALL AllocateAndSetUpVentReports
DO AirLoopNum = 1, NumPrimaryAirSys
DO BranchNum =1, PrimaryAirSystem(AirLoopNum)%NumBranches
DO CompNum =1, PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%TotalComponents
TypeOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%TypeOf
NameOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%Name
! Get complete list of components for complex branches
IF (IsParentObject(TypeOfComp,NameOfComp))THEN
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%Parent = .TRUE.
NumChildren = GetNumChildren(TypeOfComp, NameOfComp)
ALLOCATE (SubCompTypes(NumChildren))
ALLOCATE (SubCompNames(NumChildren))
ALLOCATE (InletNodeNames(NumChildren))
ALLOCATE (InletNodeNumbers(NumChildren))
ALLOCATE (OutletNodeNames(NumChildren))
ALLOCATE (OutletNodeNumbers(NumChildren))
ALLOCATE (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(NumChildren))
CALL GetChildrenData(TypeOfComp, NameOfComp, &
NumChildren, &
SubCompTypes,SubCompNames, &
InletNodeNames,InletNodeNumbers, &
OutletNodeNames,OutletNodeNumbers,ErrorsFound)
DO SubCompNum = 1, NumChildren
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%TypeOf = &
SubCompTypes(SubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Name = &
SubCompNames(SubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNameIn = &
InletNodeNames(SubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNameOut = &
OutletNodeNames(SubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNumIn = &
InletNodeNumbers(SubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNumOut = &
OutletNodeNumbers(SubCompNum)
END DO
DEALLOCATE (SubCompTypes)
DEALLOCATE (SubCompNames)
DEALLOCATE (InletNodeNames)
DEALLOCATE (InletNodeNumbers)
DEALLOCATE (OutletNodeNames)
DEALLOCATE (OutletNodeNumbers)
ELSE
NumChildren =0
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%Parent = .FALSE.
END IF
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%NumSubComps = NumChildren
!check for 'grandchildren'
DO SubCompNum = 1, NumChildren
TypeOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%TypeOf
NameOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Name
IF (IsParentObject(TypeOfComp, NameOfComp))THEN
NumGrandChildren = GetNumChildren(TypeOfComp, NameOfComp)
ALLOCATE (SubCompTypes(NumGrandChildren))
ALLOCATE (SubCompNames(NumGrandChildren))
ALLOCATE (InletNodeNames(NumGrandChildren))
ALLOCATE (InletNodeNumbers(NumGrandChildren))
ALLOCATE (OutletNodeNames(NumGrandChildren))
ALLOCATE (OutletNodeNumbers(NumGrandChildren))
ALLOCATE &
(PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%SubSubComp(NumGrandChildren))
CALL GetChildrenData(TypeOfComp, NameOfComp, &
NumGrandChildren, &
SubCompTypes,SubCompNames, &
InletNodeNames,InletNodeNumbers, &
OutletNodeNames,OutletNodeNumbers,ErrorsFound)
DO SubSubCompNum = 1, NumGrandChildren
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%TypeOf = SubCompTypes(SubSubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%Name = SubCompNames(SubSubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNameIn = InletNodeNames(SubSubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNameOut = OutletNodeNames(SubSubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNumIn = InletNodeNumbers(SubSubCompNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNumOut = OutletNodeNumbers(SubSubCompNum)
NumLeft=GetNumChildren(SubCompTypes(SubSubCompNum),SubCompNames(SubSubCompNum))
IF (NumLeft > 0) THEN
CALL ShowSevereError('Hanging Children for component='//TRIM(SubCompTypes(SubSubCompNum))//':'// &
TRIM(SubCompNames(SubSubCompNum)))
ENDIF
END DO
DEALLOCATE (SubCompTypes)
DEALLOCATE (SubCompNames)
DEALLOCATE (InletNodeNames)
DEALLOCATE (InletNodeNumbers)
DEALLOCATE (OutletNodeNames)
DEALLOCATE (OutletNodeNumbers)
ELSE
NumGrandChildren =0
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Parent = .FALSE.
END IF
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NumSubSubComps = NumGrandChildren
END DO
END DO
END DO
END DO
DO AirLoopNum = 1, NumPrimaryAirSys
DO BranchNum =1, PrimaryAirSystem(AirLoopNum)%NumBranches
DO CompNum =1, PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%TotalComponents
! Get complete list of components for complex branches
TypeOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%TypeOf
NameOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%Name
NumVariables=GetNumMeteredVariables(TypeOfComp,NameOfComp)
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(NumVariables))
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%NumMeteredVars = NumVariables
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarName = Names(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarUnits = UnitsStrings(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarIndex = VarIndexes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarIndexType = IndexTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarType = VarTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ResourceType = ResourceTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%EndUse = EndUses(VarNum)
IF (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' &
.AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum1)%EndUse_CompMode = HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' &
.AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum1)%EndUse_CompMode = CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%EndUse_CompMode = NoHeatNoCool
ENDIF
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%Group = Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
DO SubCompNum =1, PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%NumSubComps
! Get complete list of components for complex branches
TypeOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%TypeOf
NameOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Name
NumVariables=GetNumMeteredVariables(TypeOfComp,NameOfComp)
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%MeteredVar(NumVariables))
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarName = Names(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarUnits = UnitsStrings(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarIndex = VarIndexes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarIndexType = IndexTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarType = VarTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ResourceType = ResourceTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse = EndUses(VarNum)
IF (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum1)%EndUse_CompMode = HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum1)%EndUse_CompMode = CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse_CompMode = NoHeatNoCool
ENDIF
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%Group = Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NumMeteredVars = NumVariables
DO SubSubCompNum = 1,PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NumSubSubComps
! Get complete list of components for complex branches
TypeOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%TypeOf
NameOfComp = PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%Name
NumVariables=GetNumMeteredVariables(TypeOfComp,NameOfComp)
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(NumVariables))
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%ReportVarName = Names(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%ReportVarUnits = UnitsStrings(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%ReportVarIndex = VarIndexes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%ReportVarIndexType = IndexTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%ReportVarType = VarTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%ResourceType = ResourceTypes(VarNum)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%EndUse = EndUses(VarNum)
IF (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum1)%EndUse_CompMode = HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum1)%EndUse_CompMode = CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%EndUse_CompMode = NoHeatNoCool
ENDIF
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%MeteredVar(VarNum)%Group = Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
PrimaryAirSystem(AirLoopNum)%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NumMeteredVars = NumVariables
END DO
END DO
END DO
END DO
END DO
! Allocate the system serving zone equipment component arrays
DO CtrlZoneNum=1,NumOfZones
IF (.not. ZoneEquipConfig(CtrlZoneNum)%IsControlled) CYCLE
! Set index of air loop serving zone
DO CompNum = 1, ZoneEquipList(CtrlZoneNum)%NumOfEquipTypes
TypeOfComp = ZoneEquipList(CtrlZoneNum)%EquipType(CompNum)
NameOfComp = ZoneEquipList(CtrlZoneNum)%EquipName(CompNum)
CALL GetComponentData(TypeOfComp, NameOfComp, IsParent, NumInlets, &
InletNodeNames, InletNodeNumbers, InletFluidStreams, &
NumOutlets, OutletNodeNames, OutletNodeNumbers, OutletFluidStreams, &
ErrorsFound)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%TypeOf = TypeOfComp
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%Name = NameOfComp
ALLOCATE(ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%OutletNodeNums(NumOutlets))
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%NumOutlets = NumOutlets
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%OutletNodeNums = OutletNodeNumbers
ALLOCATE(ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%InletNodeNums(NumInlets))
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%NumInlets = NumInlets
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%InletNodeNums = InletNodeNumbers
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%Parent = IsParent
NumVariables = GetNumMeteredVariables(TypeOfComp,NameOfComp)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%NumMeteredVars = NumVariables
DEALLOCATE(InletNodeNames)
DEALLOCATE(InletNodeNumbers)
DEALLOCATE(InletFluidStreams)
DEALLOCATE(OutletNodeNames)
DEALLOCATE(OutletNodeNumbers)
DEALLOCATE(OutletFluidStreams)
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(NumVariables))
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%ReportVarName = Names(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%ReportVarUnits = UnitsStrings(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%ReportVarIndex = VarIndexes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%ReportVarIndexType = IndexTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%ReportVarType = VarTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%ResourceType = ResourceTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%EndUse = EndUses(VarNum)
IF (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum1)%EndUse_CompMode = HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum1)%EndUse_CompMode = CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%EndUse_CompMode = NoHeatNoCool
ENDIF
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%MeteredVar(VarNum)%Group = Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
IF (IsParentObject(TypeOfComp,NameOfComp))THEN
NumChildren = GetNumChildren(TypeOfComp, NameOfComp)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%NumSubEquip=NumChildren
ALLOCATE (SubCompTypes(NumChildren))
ALLOCATE (SubCompNames(NumChildren))
ALLOCATE (InletNodeNames(NumChildren))
ALLOCATE (InletNodeNumbers(NumChildren))
ALLOCATE (OutletNodeNames(NumChildren))
ALLOCATE (OutletNodeNumbers(NumChildren))
ALLOCATE (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(NumChildren))
CALL GetChildrenData(TypeOfComp, NameOfComp, &
NumChildren, &
SubCompTypes,SubCompNames, &
InletNodeNames,InletNodeNumbers, &
OutletNodeNames,OutletNodeNumbers,ErrorsFound)
DO SubCompNum = 1, NumChildren
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%TypeOf = SubCompTypes(SubCompNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%Name = SubCompNames(SubCompNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%OutletNodeNum = OutletNodeNumbers(SubCompNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%InletNodeNum = InletNodeNumbers(SubCompNum)
END DO
DEALLOCATE (SubCompTypes)
DEALLOCATE (SubCompNames)
DEALLOCATE (InletNodeNames)
DEALLOCATE (InletNodeNumbers)
DEALLOCATE (OutletNodeNames)
DEALLOCATE (OutletNodeNumbers)
ELSE
NumChildren =0
END IF
DO SubCompNum = 1, NumChildren
TypeOfComp = ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%TypeOf
NameOfComp = ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%Name
IF (IsParentObject(TypeOfComp,NameOfComp))THEN
NumGrandChildren = GetNumChildren(TypeOfComp, NameOfComp)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%NumSubSubEquip=NumGrandChildren
ALLOCATE (SubCompTypes(NumGrandChildren))
ALLOCATE (SubCompNames(NumGrandChildren))
ALLOCATE (InletNodeNames(NumGrandChildren))
ALLOCATE (InletNodeNumbers(NumGrandChildren))
ALLOCATE (OutletNodeNames(NumGrandChildren))
ALLOCATE (OutletNodeNumbers(NumGrandChildren))
ALLOCATE (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(NumGrandChildren))
!Sankar added the array number for EquipData
CALL GetChildrenData(TypeOfComp, NameOfComp, &
NumGrandChildren, &
SubCompTypes,SubCompNames, &
InletNodeNames,InletNodeNumbers, &
OutletNodeNames,OutletNodeNumbers,ErrorsFound)
DO SubSubCompNum = 1, NumGrandChildren
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)% &
SubSubEquipData(SubSubCompNum)%TypeOf = SubCompTypes(SubSubCompNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)% &
SubSubEquipData(SubSubCompNum)%Name = SubCompNames(SubSubCompNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)% &
SubSubEquipData(SubSubCompNum)%OutletNodeNum = OutletNodeNumbers(SubSubCompNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)% &
SubSubEquipData(SubSubCompNum)%InletNodeNum = InletNodeNumbers(SubSubCompNum)
END DO
DEALLOCATE (SubCompTypes)
DEALLOCATE (SubCompNames)
DEALLOCATE (InletNodeNames)
DEALLOCATE (InletNodeNumbers)
DEALLOCATE (OutletNodeNames)
DEALLOCATE (OutletNodeNumbers)
ELSE
NumGrandChildren =0
END IF
END DO
END DO
END DO
DO CtrlZoneNum=1,NumOfZones
IF (.not. ZoneEquipConfig(CtrlZoneNum)%IsControlled) CYCLE
DO CompNum = 1,ZoneEquipList(CtrlZoneNum)%NumOfEquipTypes
DO SubCompNum = 1, ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%NumSubEquip
TypeOfComp = ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%TypeOf
NameOfComp = ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%Name
NumVariables=GetNumMeteredVariables(TypeOfComp,NameOfComp)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%NumMeteredVars = NumVariables !Sankar added this line
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(NumVariables))
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%ReportVarName = &
Names(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%ReportVarUnits = &
UnitsStrings(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%ReportVarIndex = &
VarIndexes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%ReportVarIndexType = &
IndexTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%ReportVarType = &
VarTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%ResourceType = &
ResourceTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%EndUse = &
EndUses(VarNum)
IF (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)% &
MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum1)%EndUse_CompMode = &
HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)% &
MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum1)%EndUse_CompMode = &
CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%EndUse_CompMode = &
NoHeatNoCool
ENDIF
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%MeteredVar(VarNum)%Group = &
Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
DO SubSubCompNum = 1, ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%NumSubSubEquip
TypeOfComp = ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)%TypeOf
NameOfComp = ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)%Name
NumVariables=GetNumMeteredVariables(TypeOfComp,NameOfComp)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)%NumMeteredvars = &
NumVariables !Sankar added this line
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)% &
SubSubEquipData(SubSubCompNum)%MeteredVar(NumVariables))
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%ReportVarName = Names(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%ReportVarUnits = UnitsStrings(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%ReportVarIndex = VarIndexes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%ReportVarIndexType = IndexTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%ReportVarType = VarTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%ResourceType = ResourceTypes(VarNum)
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%EndUse = EndUses(VarNum)
IF (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum1)%EndUse_CompMode = HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum1)%EndUse_CompMode = CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%EndUse_CompMode = NoHeatNoCool
ENDIF
ZoneEquipList(CtrlZoneNum)%EquipData(CompNum)%SubEquipData(SubCompNum)%SubSubEquipData(SubSubCompNum)% &
MeteredVar(VarNum)%Group = Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
END DO
END DO
END DO
END DO
!***Plant Loops
! previously, four separate huge DO loops all looking very very similar were used here
! each individual block would operate on a single type of loop-side (plant demand, cond supply, etc.)
! now, a bigger DO loop is applied iterating over all loops
! a pointer (ThisReportData) is then directed to a particular item in the appropriate array
! by operating on the pointer directly, we are actually operating on the item in the TARGET array item
! in making this change, over 700 lines of code were dropped down to a single block
DO PlantLoopNum = 1, NumPlantLoops+NumCondLoops
DO LoopSideNum = DemandSide, SupplySide
IF (PlantLoopNum <= NumPlantLoops) THEN
SELECT CASE (LoopSideNum)
CASE (DemandSide)
ThisReportData => VentRepPlantDemandSide(PlantLoopNum)
CASE (SupplySide)
ThisReportData => VentRepPlantSupplySide(PlantLoopNum)
END SELECT
ELSE ! CondLoop
SELECT CASE (LoopSideNum)
CASE (DemandSide)
ThisReportData => VentRepCondDemandSide(PlantLoopNum-NumPlantLoops)
CASE (SupplySide)
ThisReportData => VentRepCondSupplySide(PlantLoopNum-NumPlantLoops)
END SELECT
END IF
DO BranchNum =1, ThisReportData%TotalBranches
DO CompNum =1, ThisReportData%Branch(BranchNum)%TotalComponents
TypeOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%TypeOf
NameOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%Name
! Get complete list of components for complex branches
IF (IsParentObject(TypeOfComp,NameOfComp))THEN
ThisReportData%Branch(BranchNum)%Comp(CompNum)%Parent = .TRUE.
NumChildren = GetNumChildren(TypeOfComp, NameOfComp)
ALLOCATE (SubCompTypes(NumChildren))
ALLOCATE (SubCompNames(NumChildren))
ALLOCATE (InletNodeNames(NumChildren))
ALLOCATE (InletNodeNumbers(NumChildren))
ALLOCATE (OutletNodeNames(NumChildren))
ALLOCATE (OutletNodeNumbers(NumChildren))
ALLOCATE (ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(NumChildren))
CALL GetChildrenData(TypeOfComp, NameOfComp, &
NumChildren, &
SubCompTypes,SubCompNames, &
InletNodeNames,InletNodeNumbers, &
OutletNodeNames,OutletNodeNumbers,ErrorsFound)
DO SubCompNum = 1, NumChildren
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%TypeOf = &
SubCompTypes(SubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Name = &
SubCompNames(SubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNameIn = &
InletNodeNames(SubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNameOut = &
OutletNodeNames(SubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNumIn = &
InletNodeNumbers(SubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NodeNumOut = &
OutletNodeNumbers(SubCompNum)
END DO
DEALLOCATE (SubCompTypes)
DEALLOCATE (SubCompNames)
DEALLOCATE (InletNodeNames)
DEALLOCATE (InletNodeNumbers)
DEALLOCATE (OutletNodeNames)
DEALLOCATE (OutletNodeNumbers)
ELSE
NumChildren =0
ThisReportData%Branch(BranchNum)%Comp(CompNum)%Parent = .FALSE.
END IF
ThisReportData%Branch(BranchNum)%Comp(CompNum)%NumSubComps = NumChildren
!check for 'grandchildren'
DO SubCompNum = 1, NumChildren
TypeOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%TypeOf
NameOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Name
IF (IsParentObject(TypeOfComp, NameOfComp))THEN
NumGrandChildren = GetNumChildren(TypeOfComp, NameOfComp)
ALLOCATE (SubCompTypes(NumGrandChildren))
ALLOCATE (SubCompNames(NumGrandChildren))
ALLOCATE (InletNodeNames(NumGrandChildren))
ALLOCATE (InletNodeNumbers(NumGrandChildren))
ALLOCATE (OutletNodeNames(NumGrandChildren))
ALLOCATE (OutletNodeNumbers(NumGrandChildren))
ALLOCATE (ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(NumGrandChildren))
CALL GetChildrenData(TypeOfComp, NameOfComp, &
NumGrandChildren, &
SubCompTypes,SubCompNames, &
InletNodeNames,InletNodeNumbers, &
OutletNodeNames,OutletNodeNumbers,ErrorsFound)
DO SubSubCompNum = 1, NumGrandChildren
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%TypeOf = SubCompTypes(SubSubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%Name = SubCompNames(SubSubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNameIn = InletNodeNames(SubSubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNameOut = OutletNodeNames(SubSubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNumIn = InletNodeNumbers(SubSubCompNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
SubSubComp(SubSubCompNum)%NodeNumOut = OutletNodeNumbers(SubSubCompNum)
END DO
DEALLOCATE (SubCompTypes)
DEALLOCATE (SubCompNames)
DEALLOCATE (InletNodeNames)
DEALLOCATE (InletNodeNumbers)
DEALLOCATE (OutletNodeNames)
DEALLOCATE (OutletNodeNumbers)
ELSE
NumGrandChildren =0
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Parent = .FALSE.
END IF
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NumSubSubComps = NumGrandChildren
END DO
END DO
END DO
END DO
END DO
DO PlantLoopNum = 1, NumPlantLoops + NumCondLoops
DO LoopSideNum = DemandSide, SupplySide
IF (PlantLoopNum <= NumPlantLoops) THEN
SELECT CASE (LoopSideNum)
CASE (DemandSide)
ThisReportData => VentRepPlantDemandSide(PlantLoopNum)
CASE (SupplySide)
ThisReportData => VentRepPlantSupplySide(PlantLoopNum)
END SELECT
ELSE ! CondLoop
SELECT CASE (LoopSideNum)
CASE (DemandSide)
ThisReportData => VentRepCondDemandSide(PlantLoopNum - NumPlantLoops)
CASE (SupplySide)
ThisReportData => VentRepCondSupplySide(PlantLoopNum - NumPlantLoops)
END SELECT
END IF
DO BranchNum =1, ThisReportData%TotalBranches
DO CompNum =1, ThisReportData%Branch(BranchNum)%TotalComponents
! Get complete list of components for complex branches
TypeOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%TypeOf
NameOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%Name
NumVariables=GetNumMeteredVariables(TypeOfComp,NameOfComp)
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE (ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(NumVariables))
ThisReportData%Branch(BranchNum)%Comp(CompNum)%NumMeteredVars = NumVariables
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarName = &
Names(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarUnits = &
UnitsStrings(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarIndex = &
VarIndexes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarIndexType = &
IndexTypes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ReportVarType = &
VarTypes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%ResourceType = &
ResourceTypes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%EndUse = &
EndUses(VarNum)
IF (ThisReportData%Branch(BranchNum)%Comp(CompNum)% &
MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ThisReportData%Branch(BranchNum)%Comp(CompNum)% &
MeteredVar(VarNum1)%EndUse_CompMode = HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (ThisReportData%Branch(BranchNum)%Comp(CompNum)% &
MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum1)%EndUse_CompMode = CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%EndUse_CompMode = NoHeatNoCool
ENDIF
ThisReportData%Branch(BranchNum)%Comp(CompNum)%MeteredVar(VarNum)%Group = Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
DO SubCompNum =1, ThisReportData%Branch(BranchNum)%Comp(CompNum)%NumSubComps
! Get complete list of components for complex branches
TypeOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%TypeOf
NameOfComp = ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%Name
NumVariables=GetNumMeteredVariables(TypeOfComp,NameOfComp)
ALLOCATE (VarIndexes(NumVariables))
ALLOCATE (VarTypes(NumVariables))
ALLOCATE (IndexTypes(NumVariables))
ALLOCATE (UnitsStrings(NumVariables))
ALLOCATE (ResourceTypes(NumVariables))
ALLOCATE (EndUses(NumVariables))
ALLOCATE (Groups(NumVariables))
ALLOCATE (Names(NumVariables))
ALLOCATE &
(ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%MeteredVar(NumVariables))
CALL GetMeteredVariables(TypeOfComp, NameOfComp, &
VarIndexes, VarTypes, &
IndexTypes, UnitsStrings, &
ResourceTypes, EndUses, Groups, Names, NumFound)
ModeFlagOn = .TRUE.
DO VarNum = 1, NumVariables
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarName = Names(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarUnits = UnitsStrings(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarIndex = VarIndexes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarIndexType = IndexTypes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ReportVarType = VarTypes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%ResourceType = ResourceTypes(VarNum)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse = EndUses(VarNum)
IF (ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse == 'HEATINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum1)%EndUse_CompMode = HeatingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF (ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse == 'COOLINGCOILS' .AND. ModeFlagOn) THEN
DO VarNum1 = 1, NumVariables
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum1)%EndUse_CompMode = CoolingOnly
END DO
ModeFlagOn = .FALSE.
ELSEIF(ModeFlagOn)THEN
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%EndUse_CompMode = NoHeatNoCool
ENDIF
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)% &
MeteredVar(VarNum)%Group = Groups(VarNum)
END DO
DEALLOCATE (VarIndexes)
DEALLOCATE (VarTypes)
DEALLOCATE (IndexTypes)
DEALLOCATE (UnitsStrings)
DEALLOCATE (ResourceTypes)
DEALLOCATE (EndUses)
DEALLOCATE (Groups)
DEALLOCATE (Names)
ThisReportData%Branch(BranchNum)%Comp(CompNum)%SubComp(SubCompNum)%NumMeteredVars = NumVariables
END DO
END DO
END DO
END DO
END DO
RETURN
END SUBROUTINE CreateEnergyReportStructure