Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | usingVariable |
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 evaluateChargeBlock(usingVariable)
! SUBROUTINE INFORMATION:
! AUTHOR Jason Glazer of GARD Analytics, Inc.
! DATE WRITTEN July 2004
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! METHODOLOGY EMPLOYED:
! REFERENCES:
! na
! USE STATEMENTS:
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: usingVariable
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: curTariff
INTEGER :: indexInChg
INTEGER :: iBlk
INTEGER :: jMonth
REAL(r64), DIMENSION(MaxNumMonths) :: sourceVals
REAL(r64), DIMENSION(MaxNumMonths) :: blkSzMult
REAL(r64), DIMENSION(MaxNumMonths) :: remainVals
REAL(r64), DIMENSION(MaxNumMonths) :: resultChg
REAL(r64), DIMENSION(MaxNumMonths) :: amountForBlk
REAL(r64), DIMENSION(MaxNumMonths) :: curBlkSz
REAL(r64), DIMENSION(MaxNumMonths) :: curBlkCost
REAL(r64), DIMENSION(MaxNumMonths) :: seasonMask
LOGICAL :: flagAllZero
curTariff = econVar(usingVariable)%tariffIndx
indexInChg = econVar(usingVariable)%index
!check the tariff - make sure they match
IF (chargeBlock(indexInChg)%namePt .NE. usingVariable) THEN
CALL ShowWarningError('UtilityCost:Tariff Debugging issue. chargeBlock index does not match variable pointer.')
CALL ShowContinueError(' Between: ' // TRIM(econVar(usingVariable)%name))
CALL ShowContinueError(' And: ' // TRIM(econVar(chargeBlock(indexInChg)%namePt)%name))
END IF
IF (chargeBlock(indexInChg)%tariffIndx .NE. curTariff) THEN
CALL ShowWarningError('UtilityCost:Tariff Debugging issue. chargeBlock index does not match tariff index.')
CALL ShowContinueError(' Between: ' // TRIM(tariff(curTariff)%tariffName))
CALL ShowContinueError(' And: ' // TRIM(tariff(chargeBlock(indexInChg)%tariffIndx)%tariffName))
END IF
! data from the chargeBlock
sourceVals = econVar(chargeBlock(indexInChg)%sourcePt)%values
! find proper season mask
SELECT CASE (chargeBlock(indexInChg)%season)
CASE (seasonSummer)
seasonMask = econVar(tariff(curTariff)%nativeIsSummer)%values
CASE (seasonWinter)
seasonMask = econVar(tariff(curTariff)%nativeIsWinter)%values
CASE (seasonSpring)
seasonMask = econVar(tariff(curTariff)%nativeIsSpring)%values
CASE (seasonFall)
seasonMask = econVar(tariff(curTariff)%nativeIsAutumn)%values
CASE (seasonAnnual)
seasonMask = 1.0d0 !all months are 1
END SELECT
! get block size multiplier
IF (chargeBlock(indexInChg)%blkSzMultPt .NE. 0) THEN
blkSzMult = econVar(chargeBlock(indexInChg)%blkSzMultPt)%values
ELSE
blkSzMult = chargeBlock(indexInChg)%blkSzMultVal
END IF
!initially set the remaing energy or demand to the source
remainVals = sourceVals
!initially set the result (cost) to zero
resultChg = 0.0d0
!loop through the blocks performing calculations
DO iBlk = 1, chargeBlock(indexInChg)%numBlk
IF (chargeBlock(indexInChg)%blkSzPt(iBlk) .NE. 0) THEN
curBlkSz = econVar(chargeBlock(indexInChg)%blkSzPt(iBlk))%values
ELSE
curBlkSz = chargeBlock(indexInChg)%blkSzVal(iBlk)
END IF
IF (chargeBlock(indexInChg)%blkCostPt(iBlk) .NE. 0) THEN
curBlkCost = econVar(chargeBlock(indexInChg)%blkCostPt(iBlk))%values
ELSE
curBlkCost = chargeBlock(indexInChg)%blkCostVal(iBlk)
END IF
!loop through the months
DO jMonth = 1, MaxNumMonths
IF (seasonMask(jMonth) .EQ. 1) THEN
! IF ((curBlkSz(jMonth) * blkSzMult(jMonth)) .GT. remainVals(jMonth)) THEN - CR 6547
IF (blkSzMult(jMonth) .NE. 0) THEN
IF (curBlkSz(jMonth) .GT. (remainVals(jMonth) / blkSzMult(jMonth)) ) THEN
amountForBlk(jMonth) = remainVals(jMonth)
ELSE
amountForBlk(jMonth) = curBlkSz(jMonth) * blkSzMult(jMonth)
END IF
ELSE
amountForBlk(jMonth) = 0.0d0
END IF
resultChg(jMonth) = resultChg(jMonth) + amountForBlk(jMonth) * curBlkCost(jMonth)
remainVals(jMonth) = remainVals(jMonth) - amountForBlk(jMonth)
END IF
END DO
END DO
! store the amount remaining if a variable is specified
IF (chargeBlock(indexInChg)%remainingPt .NE. 0) THEN
econVar(chargeBlock(indexInChg)%remainingPt)%values = remainVals
ELSE
flagAllZero = .TRUE.
DO jMonth = 1, MaxNumMonths
IF (seasonMask(jMonth) .EQ. 1) THEN
IF (remainVals(jMonth) .NE. 0) THEN
flagAllZero = .FALSE.
END IF
END IF
END DO
IF (.NOT. flagAllZero) THEN
CALL ShowWarningError('UtilityCost:Tariff Not all energy or demand was assigned in the block charge: ' // &
TRIM(econVar(usingVariable)%name))
END IF
END IF
!store the cost in the name of the variable
econVar(usingVariable)%values = resultChg
!set the flag that it has been evaluated so it won't be evaluated multiple times
econVar(usingVariable)%isEvaluated = .TRUE.
END SUBROUTINE evaluateChargeBlock