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) | :: | WindTurbineNum |
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 InitWindTurbine (WindTurbineNum)
! SUBROUTINE INFORMATION:
! AUTHOR Daeho Kang
! DATE WRITTEN Oct 2009
! MODIFIED Linda K. Lawrie, December 2009 for reading stat file
! RE-ENGINEERED na
! PURPOSE OF THIS SUBROUTINE:
! This subroutine reads monthly average wind speed from stat file and then
! determines annual average wind speed. Differences between this TMY wind speed
! and local wind speed that the user inputs are then factored.
! IF the user has no local wind data and does not enter the local wind speed to be factored,
! then the factor of 1 is assigned, so that wind speed estimated
! at the particular rotor height is used with no factorization.
! It also initializes module variables at each time step.
! METHODOLOGY EMPLOYED:
! REFERENCES:
! USE STATEMENTS:
USE DataEnvironment, ONLY : WeatherFileWindModCoeff, SiteWindBLHeight, SiteWindExp
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
INTEGER, INTENT(IN) :: WindTurbineNum
! SUBROUTINE PARAMETER DEFINITIONS:
CHARACTER(len=*), PARAMETER :: Blank = ' '
CHARACTER(len=1), PARAMETER :: TabChr=CHAR(9) ! Tab character
! INTERFACE BLOCK SPECIFICATIONS
! na
! DERIVED TYPE DEFINITIONS
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
LOGICAL, SAVE :: MyOneTimeFlag = .true.
INTEGER, EXTERNAL :: GetNewUnitNumber ! External function to "get" a unit number
INTEGER :: OpenStatus ! Open status of stat file
INTEGER :: ReadStatus ! Reading status of stat file
INTEGER :: StatFile ! Weather Stat File
INTEGER :: lnPtr ! scan pointer for Line input
INTEGER :: mon ! loop counter
LOGICAL :: wsStatFound ! logical noting that wind stats were found
LOGICAL :: fileExists ! true if in.stat file exists
LOGICAL :: warningShown ! true if the <365 warning has already been shown
CHARACTER(len=200) :: lineIn
REAL(r64), DIMENSION(12) :: MonthWS
REAL(r64),SAVE :: AnnualTMYWS=0.0d0 ! Annual average wind speed in stat file
REAL(r64) :: LocalTMYWS ! Annual average wind speed at the rotor height
! Estimate average annual wind speed once
IF (MyOneTimeFlag) THEN
wsStatFound=.false.
INQUIRE(file='in.stat',EXIST=fileExists)
IF (fileExists) THEN
StatFile = GetNewUnitNumber()
readstatus=0
OPEN (unit=statFile, file='in.stat', action='READ',iostat=readStatus)
IF (readstatus /= 0) THEN
CALL ShowFatalError('InitWindTurbine: Could not open file "in.stat" for input (read).')
ENDIF
DO WHILE (readStatus == 0) !end of file
READ(UNIT=statFile,FMT='(A)',IOSTAT=readStatus) lineIn
! reconcile line with different versions of stat file
lnPtr=INDEX(lineIn,'Wind Speed')
if (lnPtr == 0) CYCLE
! have hit correct section.
DO WHILE (readStatus == 0) ! find daily avg line
READ(UNIT=statFile,FMT='(A)',IOSTAT=readStatus) lineIn
lnPtr=INDEX(lineIn,'Daily Avg')
if (lnPtr == 0) CYCLE
! tab delimited file
lineIn=lineIn(lnptr+10:)
MonthWS=0.0d0
wsStatFound=.true.
warningShown=.false.
DO mon=1,12
lnPtr=INDEX(lineIn,TabChr)
IF (lnPtr /= 1) THEN
IF (lineIn(1:lnPtr-1) /= Blank) THEN
IF (lnPtr /= 0) THEN
READ(lineIn(1:lnPtr-1),*) MonthWS(mon)
lineIn=lineIn(lnPtr+1:)
ENDIF
ELSE ! blank field
IF (.not. warningShown) THEN
CALL ShowWarningError('InitWindTurbine: read from in.stat file shows <365 days in weather file. '// &
'Annual average wind speed used will be inaccurate.')
lineIn=lineIn(lnPtr+1:)
warningShown=.true.
ENDIF
ENDIF
ELSE ! two tabs in succession
IF (.not. warningShown) THEN
CALL ShowWarningError('InitWindTurbine: read from in.stat file shows <365 days in weather file. '// &
'Annual average wind speed used will be inaccurate.')
lineIn=lineIn(lnPtr+1:)
warningShown=.true.
ENDIF
ENDIF
ENDDO
EXIT
ENDDO
if (wsStatFound) EXIT
ENDDO
CLOSE(UNIT=statFile)
IF (wsStatFound) THEN
AnnualTMYWS = SUM(MonthWS)/12.0d0
ELSE
CALL ShowWarningError('InitWindTurbine: stat file did not include Wind Speed statistics. '// &
'TMY Wind Speed adjusted at the height is used.')
ENDIF
ELSE ! No stat file
CALL ShowWarningError('InitWindTurbine: stat file missing. '// &
'TMY Wind Speed adjusted at the height is used.')
END IF
MyOneTimeFlag = .false.
END IF
WindTurbineSys(WindTurbineNum)%AnnualTMYWS=AnnualTMYWS
! Factor differences between TMY wind data and local wind data once
IF (AnnualTMYWS > 0.0d0 .AND. WindTurbineSys(WindTurbineNum)%WSFactor == 0.0d0 .AND. &
WindTurbineSys(WindTurbineNum)%LocalAnnualAvgWS > 0) THEN
! Convert the annual wind speed to the local wind speed at the height of the local station, then factor
LocalTMYWS = AnnualTMYWS * WeatherFileWindModCoeff * &
(WindTurbineSys(WindTurbineNum)%HeightForLocalWS / SiteWindBLHeight) ** SiteWindExp
WindTurbineSys(WindTurbineNum)%WSFactor = LocalTMYWS / WindTurbineSys(WindTurbineNum)%LocalAnnualAvgWS
END IF
! Assign factor of 1.0 if no stat file or no input of local average wind speed
IF (WindTurbineSys(WindTurbineNum)%WSFactor == 0.0d0) WindTurbineSys(WindTurbineNum)%WSFactor = 1.0d0
! Do every time step initialization
WindTurbineSys(WindTurbineNum)%Power = 0.0d0
WindTurbineSys(WindTurbineNum)%TotPower = 0.0d0
WindTurbineSys(WindTurbineNum)%PowerCoeff = 0.0d0
WindTurbineSys(WindTurbineNum)%TipSpeedRatio = 0.0d0
WindTurbineSys(WindTurbineNum)%ChordalVel = 0.0d0
WindTurbineSys(WindTurbineNum)%NormalVel = 0.0d0
WindTurbineSys(WindTurbineNum)%RelFlowVel = 0.0d0
WindTurbineSys(WindTurbineNum)%AngOfAttack = 0.0d0
WindTurbineSys(WindTurbineNum)%TanForce = 0.0d0
WindTurbineSys(WindTurbineNum)%NorForce = 0.0d0
WindTurbineSys(WindTurbineNum)%TotTorque = 0.0d0
RETURN
END SUBROUTINE InitWindTurbine