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.
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 WritePredefinedTables
! SUBROUTINE INFORMATION:
! AUTHOR Jason Glazer
! DATE WRITTEN August 2006
! MODIFIED January 2010, Kyle Benne; Added SQLite output
! March 2010, Linda Lawrie; Modify SizingPeriod:DesignDay to convert column/humidity types
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! Write out tables that have been predefined with data gathered
! throughout the program code.
! METHODOLOGY EMPLOYED:
! Create arrays for the call to writeTable and then call it.
! This is a generic routine to write a report with multiple
! subtables. The structure of the report are created in
! OutputReportPredefined which also includes a routine that
! builds up a tableEntry array which holds the data for the
! predefined reports.
! REFERENCES:
! na
! USE STATEMENTS:
USE SQLiteProcedures, ONLY: CreateSQLiteTabularDataRecords
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
! na
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
! all arrays are in the format: (row, column)
CHARACTER(len=MaxNameLength),ALLOCATABLE, DIMENSION(:) :: columnHead
INTEGER,ALLOCATABLE,DIMENSION(:) :: columnWidth
CHARACTER(len=MaxNameLength),ALLOCATABLE, DIMENSION(:) :: rowHead
CHARACTER(len=MaxNameLength),ALLOCATABLE, DIMENSION(:,:) :: tableBody
INTEGER,ALLOCATABLE,DIMENSION(:) :: rowToUnqObjName
INTEGER,ALLOCATABLE,DIMENSION(:) :: colHeadToColTag
INTEGER :: curNumColumns
INTEGER :: curNumRows
INTEGER :: curColumn
CHARACTER(len=MaxNameLength),ALLOCATABLE, DIMENSION(:) :: uniqueObjectName
LOGICAL, ALLOCATABLE, DIMENSION(:) :: useUniqueObjectName
INTEGER :: numUnqObjName
CHARACTER(len=MaxNameLength) :: curObjectName
INTEGER :: countRow
INTEGER :: countColumn
INTEGER :: found
INTEGER :: curColTagIndex
INTEGER :: curRowUnqObjIndex
INTEGER :: colCurrent
INTEGER :: rowCurrent
INTEGER :: iReportName
INTEGER :: jSubTable
INTEGER :: kColumnTag
INTEGER :: lTableEntry
INTEGER :: mUnqObjNames
INTEGER :: nColHead
INTEGER :: oRowHead
CHARACTER(len=MaxNameLength) :: colTagWithSI
CHARACTER(len=MaxNameLength) :: curColTag
INTEGER, ALLOCATABLE, DIMENSION(:) :: colUnitConv
INTEGER :: indexUnitConv
INTEGER :: columnUnitConv
CHARACTER(len=MaxNameLength) :: repTableTag
REAL(r64) :: IPvalue
! loop through the entries and associate them with the subtable and create
! list of unique object names
! Much of this code is to allow for integer compares instead of string
! compares that are nested three levels in a loop.
ALLOCATE(uniqueObjectName(numTableEntry))
ALLOCATE(useUniqueObjectName(numTableEntry))
numUnqObjName=0
DO lTableEntry = 1,numTableEntry
!associate the subtable with each column
curColumn = tableEntry(lTableEntry)%indexColumn
IF ((curColumn .GE. 1) .AND. (curColumn .LE. numColumnTag)) THEN
tableEntry(lTableEntry)%subTableIndex = columnTag(curColumn)%indexSubTable
END IF
!make a list of unique object names
curObjectName = tableEntry(lTableEntry)%objectName
found = 0
DO mUnqObjNames = 1,numUnqObjName
IF (SameString(curObjectName,uniqueObjectName(mUnqObjNames))) THEN
found = mUnqObjNames
END IF
END DO
! if found then point to the unique object
IF (found .GT. 0) THEN
tableEntry(lTableEntry)%uniqueObjName = found
! if not found add to the unique object list
ELSE
numUnqObjName = numUnqObjName + 1
uniqueObjectName(numUnqObjName) = curObjectName
tableEntry(lTableEntry)%uniqueObjName = numUnqObjName
END IF
END DO
! loop through all reports and include those that have been flagged as 'show'
DO iReportName = 1, numReportName
IF (reportName(iReportName)%show) THEN
CALL WriteReportHeaders(reportName(iReportname)%namewithSpaces,'Entire Facility',isAverage)
! loop through the subtables and include those that are associated with this report
DO jSubTable = 1, numSubTable
IF (subTable(jSubTable)%indexReportName .EQ. iReportName) THEN
!determine how many columns
curNumColumns = 0
DO kColumnTag = 1,numColumnTag
IF (columnTag(kColumnTag)%indexSubTable .EQ. jSubTable) THEN
curNumColumns = curNumColumns + 1
END IF
END DO
!determine how many rows by going through table entries and setting
!flag in useUniqueObjectName to true, then count number of true's.
useUniqueObjectName = .FALSE. !array assignment
DO lTableEntry = 1,numTableEntry
IF (tableEntry(lTableEntry)%subTableIndex .EQ. jSubTable) THEN
useUniqueObjectName(tableEntry(lTableEntry)%uniqueObjName) = .TRUE.
END IF
END DO
curNumRows = 0
DO mUnqObjNames = 1,numUnqObjName
IF (useUniqueObjectName(mUnqObjNames)) THEN
curNumRows = curNumRows + 1
END IF
END DO
IF (curNumRows .EQ. 0) curNumRows = 1
! now create the arrays that are filled with values
ALLOCATE(rowHead(curNumRows))
ALLOCATE(columnHead(curNumColumns))
ALLOCATE(columnWidth(curNumColumns))
columnWidth = 14 !array assignment - same for all columns
ALLOCATE(tableBody(curNumRows,curNumColumns))
rowHead = ''
columnHead = ''
tableBody = ''
! this array stores the unique object name index for each row
ALLOCATE(rowToUnqObjName(curNumRows))
! this array stores the columnHead index for each column
ALLOCATE(colHeadToColTag(curNumColumns))
ALLOCATE(colUnitConv(curNumColumns))
! set row headings
countRow = 0
rowHead(1) = 'None'
DO mUnqObjNames = 1,numUnqObjName
IF (useUniqueObjectName(mUnqObjNames)) THEN
countRow = countRow + 1
rowHead(countRow) = uniqueObjectName(mUnqObjNames)
rowToUnqObjName(countRow) = mUnqObjNames
END IF
END DO
! set column headings
countColumn = 0
DO kColumnTag = 1,numColumnTag
IF (columnTag(kColumnTag)%indexSubTable .EQ. jSubTable) THEN
countColumn = countColumn + 1
!do the unit conversions
colTagWithSI = columnTag(kColumnTag)%heading
IF (unitsStyle .EQ. unitsStyleInchPound) THEN
CALL LookupSItoIP(colTagWithSI, indexUnitConv, curColTag)
colUnitConv(countColumn) = indexUnitConv
ELSE
curColTag = colTagWithSI
colUnitConv(countColumn) = 0
END IF
columnHead(countColumn) = curColTag
colHeadToColTag(countColumn) = kColumnTag
END IF
END DO
! fill the body of the table from the entries
! find the entries associated with the current subtable
DO lTableEntry = 1,numTableEntry
IF (tableEntry(lTableEntry)%subTableIndex .EQ. jSubTable) THEN
!determine what column the current entry is in
curColTagIndex = tableEntry(lTableEntry)%indexColumn
DO nColHead = 1,curNumColumns
IF (curColTagIndex .EQ. colHeadToColTag(nColHead)) THEN
colCurrent = nColHead
EXIT
END IF
END DO
!determine what row the current entry is in
curRowUnqObjIndex = tableEntry(lTableEntry)%uniqueObjName
DO oRowHead = 1, curNumRows
IF (curRowUnqObjIndex .EQ. rowToUnqObjName(oRowHead)) THEN
rowCurrent = oRowHead
EXIT
END IF
END DO
!finally assign the entry to the place in the table body
IF (unitsStyle .EQ. unitsStyleInchPound) THEN
columnUnitConv=colUnitConv(colCurrent)
IF (SameString(subTable(jSubTable)%Name,'SizingPeriod:DesignDay')) THEN
IF (SameString(columnHead(colCurrent),'Humidity Value')) THEN
CALL LookupSItoIP(tableEntry(lTableEntry+1)%charEntry, columnUnitConv, repTableTag)
tableEntry(lTableEntry+1)%charEntry=repTableTag
ENDIF
ENDIF
IF (tableEntry(lTableEntry)%origEntryIsReal .AND. (columnUnitConv .NE.0)) THEN
IPvalue = convertIP(columnUnitConv, tableEntry(lTableEntry)%origRealEntry)
tableBody(rowCurrent, colCurrent) = TRIM(RealToStr(IPvalue,tableEntry(lTableEntry)%significantDigits))
ELSE
tableBody(rowCurrent, colCurrent) = tableEntry(lTableEntry)%charEntry
END IF
ELSE
tableBody(rowCurrent, colCurrent) = tableEntry(lTableEntry)%charEntry
END IF
END IF
END DO
!create the actual output table
CALL writeSubtitle(subTable(jSubTable)%name)
CALL writeTable(tableBody,rowHead,columnHead,columnWidth,.false.,subTable(jSubTable)%footnote)
CALL CreateSQLiteTabularDataRecords(tableBody,rowHead,columnHead,&
reportName(iReportname)%name,&
'Entire Facility',&
subTable(jSubTable)%name)
!clean up the temporary arrays used
DEALLOCATE(columnHead)
DEALLOCATE(rowHead)
DEALLOCATE(columnWidth)
DEALLOCATE(tableBody)
!clean up the pointer arrays
DEALLOCATE(rowToUnqObjName)
DEALLOCATE(colHeadToColTag)
DEALLOCATE(colUnitConv)
END IF
END DO
END IF
END DO
DEALLOCATE(uniqueObjectName)
END SUBROUTINE WritePredefinedTables