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.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | CurveIndex | |||
real(kind=r64), | intent(in) | :: | Var1 | |||
real(kind=r64), | intent(in), | optional | :: | Var2 | ||
real(kind=r64), | intent(in), | optional | :: | Var3 |
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.
REAL(r64) FUNCTION PerformanceTableObject(CurveIndex,Var1,Var2,Var3) RESULT(TableValue)
! FUNCTION INFORMATION:
! AUTHOR Richard Raustad, FSEC
! DATE WRITTEN May 2010
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
! Given the curve index and the values of 1 or 2 independent variables,
! returns the value of an equipment performance table lookup.
! METHODOLOGY EMPLOYED:
! na
! REFERENCES:
! na
! USE STATEMENTS:
USE DataInterfaces, ONLY:ShowFatalError, ShowSevereError, ShowContinueError
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! FUNCTION ARGUMENT DEFINITIONS:
INTEGER, INTENT (IN) :: CurveIndex ! index of curve in curve array
REAL(r64), INTENT (IN) :: Var1 ! 1st independent variable
REAL(r64), INTENT (IN), OPTIONAL :: Var2 ! 2nd independent variable
REAL(r64), INTENT (IN), OPTIONAL :: Var3 ! 3rd independent variable
! FUNCTION PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! FUNCTION LOCAL VARIABLE DECLARATIONS:
REAL(r64) :: V1 ! 1st independent variable after limits imposed
REAL(r64) :: V2 ! 2nd independent variable after limits imposed
REAL(r64) :: V3 ! 3rd independent variable after limits imposed
Real(r64) :: TempX1Low
Real(r64) :: TempX1High
Real(r64) :: TempX2Low
Real(r64) :: TempX2High
!INTEGER :: ATempX1LowPtr(1)
!INTEGER :: ATempX1HighPtr(1)
!INTEGER :: ATempX2LowPtr(1)
!INTEGER :: ATempX2HighPtr(1)
INTEGER :: TempX1LowPtr
INTEGER :: TempX1HighPtr
INTEGER :: TempX2LowPtr
INTEGER :: TempX2HighPtr
Real(r64) :: X1Frac
Real(r64) :: X2Frac
Real(r64) :: X1ValLow
Real(r64) :: X1ValHigh
!INTEGER :: MaxSizeArray
INTEGER :: X1Val
INTEGER :: X2Val
INTEGER :: TableIndex
TableIndex = PerfCurve(CurveIndex)%TableIndex
V1 = MAX(MIN(Var1,PerfCurve(CurveIndex)%Var1Max),PerfCurve(CurveIndex)%Var1Min)
IF (PRESENT(Var2)) THEN
V2 = MAX(MIN(Var2,PerfCurve(CurveIndex)%Var2Max),PerfCurve(CurveIndex)%Var2Min)
ELSE
V2 = 0.0d0
END IF
IF (PRESENT(Var3)) THEN
V3 = MAX(MIN(Var3,PerfCurve(CurveIndex)%Var3Max),PerfCurve(CurveIndex)%Var3Min)
ELSE
V3 = 0.0d0
END IF
SELECT CASE(TableLookup(TableIndex)%NumIndependentVars)
CASE(1)
TempX1Low = MINVAL(PerfCurveTableData(TableIndex)%X1)
TempX1High = MAXVAL(PerfCurveTableData(TableIndex)%X1)
IF(V1 .LE. TempX1Low)THEN
TempX1LowPtr = 1
TempX1HighPtr = 1
ELSEIF(V1 .GE. TempX1High)THEN
TempX1LowPtr = SIZE(PerfCurveTableData(TableIndex)%X1)
TempX1HighPtr = TempX1LowPtr
ELSE
DO X1VAL = 1, SIZE(PerfCurveTableData(TableIndex)%X1)
IF(V1 .GE. PerfCurveTableData(TableIndex)%X1(X1VAL))TempX1LowPtr = X1VAL
END DO
IF(V1 .EQ. PerfCurveTableData(TableIndex)%X1(TempX1LowPtr))THEN
TempX1HighPtr = TempX1LowPtr
ELSE
TempX1HighPtr = TempX1LowPtr + 1
END IF
END IF
IF(TempX1LowPtr .EQ. TempX1HighPtr)THEN
TableValue = PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,1)
ELSE
X1Frac = (V1-PerfCurveTableData(TableIndex)%X1(TempX1LowPtr)) / &
(PerfCurveTableData(TableIndex)%X1(TempX1HighPtr)- &
PerfCurveTableData(TableIndex)%X1(TempX1LowPtr))
TableValue = X1Frac * PerfCurveTableData(TableIndex)%Y(TempX1HighPtr,1) + &
(1-X1Frac) * PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,1)
END IF
CASE(2)
TempX1Low = MINVAL(PerfCurveTableData(TableIndex)%X1)
TempX1High = MAXVAL(PerfCurveTableData(TableIndex)%X1)
IF(V1 .LE. TempX1Low)THEN
TempX1LowPtr = 1
TempX1HighPtr = 1
ELSEIF(V1 .GE. TempX1High)THEN
TempX1LowPtr = SIZE(PerfCurveTableData(TableIndex)%X1)
TempX1HighPtr = TempX1LowPtr
ELSE
DO X1VAL = 1, SIZE(PerfCurveTableData(TableIndex)%X1)
IF(V1 .GE. PerfCurveTableData(TableIndex)%X1(X1VAL))TempX1LowPtr = X1VAL
END DO
IF(V1 .EQ. PerfCurveTableData(TableIndex)%X1(TempX1LowPtr))THEN
TempX1HighPtr = TempX1LowPtr
ELSE
TempX1HighPtr = TempX1LowPtr + 1
END IF
END IF
TempX2Low = MINVAL(PerfCurveTableData(TableIndex)%X2)
TempX2High = MAXVAL(PerfCurveTableData(TableIndex)%X2)
IF(V2 .LE. TempX2Low)THEN
TempX2LowPtr = 1
TempX2HighPtr = 1
ELSEIF(V2 .GE. TempX2High)THEN
TempX2LowPtr = SIZE(PerfCurveTableData(TableIndex)%X2)
TempX2HighPtr = TempX2LowPtr
ELSE
DO X2VAL = 1, SIZE(PerfCurveTableData(TableIndex)%X2)
IF(V2 .GE. PerfCurveTableData(TableIndex)%X2(X2VAL))TempX2LowPtr = X2VAL
END DO
IF(V2 .EQ. PerfCurveTableData(TableIndex)%X2(TempX2LowPtr))THEN
TempX2HighPtr = TempX2LowPtr
ELSE
TempX2HighPtr = TempX2LowPtr + 1
END IF
END IF
IF(TempX1LowPtr .EQ. TempX1HighPtr)THEN
IF(TempX2LowPtr .EQ. TempX2HighPtr)THEN
TableValue = PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,TempX2LowPtr)
ELSE
X2Frac = (V2-PerfCurveTableData(TableIndex)%X2(TempX2LowPtr)) / &
(PerfCurveTableData(TableIndex)%X2(TempX2HighPtr)- &
PerfCurveTableData(TableIndex)%X2(TempX2LowPtr))
TableValue = X2Frac * PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,TempX2HighPtr) + &
(1-X2Frac) * PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,TempX2LowPtr)
END IF
ELSE
X1Frac = (V1-PerfCurveTableData(TableIndex)%X1(TempX1LowPtr)) / &
(PerfCurveTableData(TableIndex)%X1(TempX1HighPtr)- &
PerfCurveTableData(TableIndex)%X1(TempX1LowPtr))
IF(TempX2LowPtr .EQ. TempX2HighPtr)THEN
TableValue = X1Frac * PerfCurveTableData(TableIndex)%Y(TempX1HighPtr,TempX2LowPtr) + &
(1-X1Frac) * PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,TempX2LowPtr)
ELSE
X1ValLow = X1Frac * PerfCurveTableData(TableIndex)%Y(TempX1HighPtr,TempX2LowPtr) + &
(1-X1Frac) * PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,TempX2LowPtr)
X1ValHigh = X1Frac * PerfCurveTableData(TableIndex)%Y(TempX1HighPtr,TempX2HighPtr) + &
(1-X1Frac) * PerfCurveTableData(TableIndex)%Y(TempX1LowPtr,TempX2HighPtr)
X2Frac = (V2-PerfCurveTableData(TableIndex)%X2(TempX2LowPtr)) / &
(PerfCurveTableData(TableIndex)%X2(TempX2HighPtr)- &
PerfCurveTableData(TableIndex)%X2(TempX2LowPtr))
TableValue = X2Frac * X1ValHigh + (1-X2Frac) * X1ValLow
END IF
END IF
CASE DEFAULT
TableValue = 0.0D0
CALL ShowSevereError('Errors found in table output calculation for '//TRIM(PerfCurve(CurveIndex)%Name))
CALL ShowContinueError('...Possible causes are selection of Interpolation Method or Type or Number' // &
' of Independent Variables or Points.')
CALL ShowFatalError('PerformanceTableObject: Previous error causes program termination.')
END SELECT
IF(PerfCurve(CurveIndex)%CurveMinPresent) TableValue = MAX(TableValue , PerfCurve(CurveIndex)%CurveMin)
IF(PerfCurve(CurveIndex)%CurveMaxPresent) TableValue = MIN(TableValue , PerfCurve(CurveIndex)%CurveMax)
RETURN
END FUNCTION PerformanceTableObject