Skip to content

Commit

Permalink
Remove extra GetNewUnit calls from TurbSim
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-platt committed Nov 28, 2024
1 parent ee446dd commit 7fd00a0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 38 deletions.
7 changes: 1 addition & 6 deletions modules/turbsim/src/CohStructures.f90
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ SUBROUTINE CohStr_ReadEventFile( p_CohStr, y_CohStr, e_CohStr, TSclFact, ErrStat

MaxEvtCTKE = 0.0 ! initialize the MAX variable

CALL GetNewUnit( Un, ErrStat2, ErrMsg2 )

CALL OpenFInpFile ( Un, p_CohStr%CTEventFile, ErrStat2, ErrMsg2)
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CohStr_ReadEventFile')
IF (ErrStat >= AbortErrLev) RETURN
Expand Down Expand Up @@ -775,13 +773,10 @@ SUBROUTINE CohStr_WriteEvents( RootName, p_CohStr, e_CohStr, y_CohStr, TScale, U
ErrMsg = ""

UnOut = -1
CALL GetNewUnit( UnOut, ErrStat2, ErrMsg2 )
UnIn = -1
CALL OpenFOutFile ( UnOut, TRIM( RootName )//'.cts', ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CohStr_WriteEvents' )

UnIn = -1
CALL GetNewUnit( UnIn, ErrStat2, ErrMsg2 )


! Write event data to the time step output file (opened at the beginnig)

Expand Down
25 changes: 0 additions & 25 deletions modules/turbsim/src/TS_FileIO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ SUBROUTINE ReadInputFile(InFile, p, OtherSt_RandNum, ErrStat, ErrMsg)
! Open input file
!===============================================================================================================================

CALL GetNewUnit( UI, ErrStat2, ErrMsg2)
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)

CALL OpenFInpFile( UI, InFile, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) THEN
Expand Down Expand Up @@ -1144,7 +1141,6 @@ SUBROUTINE OpenSummaryFile(RootName, US, DescStr, ErrStat, ErrMsg)


! Open summary file.
CALL GetNewUnit( US, ErrStat, ErrMsg )
CALL OpenFOutFile( US, TRIM( RootName )//'.sum', ErrStat, ErrMsg ) ! Formatted output file
if (ErrStat >= AbortErrLev) then
US = -1
Expand Down Expand Up @@ -1205,8 +1201,6 @@ SUBROUTINE GetUSRProfiles(FileName, p_met, UnEc, ErrStat, ErrMsg)
ErrMsg = ""

U_in = -1
CALL GetNewUnit( U_in, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
CALL OpenFInpFile( U_in, FileName, ErrStat2, ErrMsg2 )
CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)

Expand Down Expand Up @@ -1401,9 +1395,6 @@ SUBROUTINE GetUSRSpec(FileName, p, UnEc, ErrStat, ErrMsg)

! --------- Open the file ---------------

CALL GetNewUnit( USpec, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2 , ErrStat, ErrMsg, RoutineName)

CALL OpenFInpFile( USpec, FileName, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2 , ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) THEN
Expand Down Expand Up @@ -1595,9 +1586,6 @@ SUBROUTINE GetUSRTimeSeries(FileName, p, UnEc, ErrStat, ErrMsg)

! --------- Open the file ---------------

CALL GetNewUnit( UnIn, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2 , ErrStat, ErrMsg, RoutineName)

CALL OpenFInpFile( UnIn, FileName, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2 , ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) THEN
Expand Down Expand Up @@ -2119,7 +2107,6 @@ SUBROUTINE WrBinBLADED(p, V, USig, VSig, WSig, ErrStat, ErrMsg)

IF ( p%WrFile(FileExt_WND) ) THEN

CALL GetNewUnit( UBFFW )
CALL OpenBOutFile ( UBFFW, TRIM(p%RootName)//'.wnd', ErrStat, ErrMsg )
IF (ErrStat >= AbortErrLev) RETURN

Expand Down Expand Up @@ -2188,7 +2175,6 @@ SUBROUTINE WrBinBLADED(p, V, USig, VSig, WSig, ErrStat, ErrMsg)

IF ( p%WrFile(FileExt_TWR) ) THEN

CALL GetNewUnit( UATWR, ErrStat, ErrMsg )
CALL OpenBOutFile ( UATWR, TRIM( p%RootName )//'.twr', ErrStat, ErrMsg )
IF (ErrStat >= AbortErrLev) RETURN

Expand Down Expand Up @@ -2369,7 +2355,6 @@ SUBROUTINE WrBinTURBSIM(p, V, ErrStat, ErrMsg)

CALL WrScr ( ' Generating AeroDyn binary time-series file "'//TRIM( p%RootName )//'.bts"' )

CALL GetNewUnit(UAFFW, ErrStat, ErrMsg)
CALL OpenBOutFile ( UAFFW, TRIM(p%RootName)//'.bts', ErrStat, ErrMsg )
IF (ErrStat >= AbortErrLev) RETURN

Expand Down Expand Up @@ -2484,10 +2469,6 @@ SUBROUTINE WrBinHAWC( p, V, USig, VSig, WSig, ErrStat, ErrMsg)
ErrStat = ErrID_None
ErrMsg = ""

CALL GetNewUnit( UnWind, ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)
IF (ErrStat >= AbortErrLev) RETURN

! calculate factors (for workaround in HAWC2); factor = Target / actual
ScaleFactors = (/ USig, VSig, WSig /)
do ic=1,3
Expand Down Expand Up @@ -2607,8 +2588,6 @@ SUBROUTINE WrFormattedFF(RootName, p_grid, UHub, V )
! Allocate the array of wind speeds.


CALL GetNewUnit(UFFF)

DO IVec=1,3

CALL WrScr ( ' Generating full-field formatted file "'//TRIM(RootName)//'.'//Comp(IVec)//'".' )
Expand Down Expand Up @@ -3017,7 +2996,6 @@ SUBROUTINE WrHH_ADtxtfile(p, V, TurbInt, ErrStat, ErrMsg)



CALL GetNewUnit( UAHH, ErrStat, ErrMsg)
CALL OpenFOutFile ( UAHH, TRIM( p%RootName)//'.hh', ErrStat, ErrMsg )
IF (ErrStat >= AbortErrLev) RETURN

Expand Down Expand Up @@ -3083,8 +3061,6 @@ SUBROUTINE WrHH_binary(p, V, ErrStat, ErrMsg)



CALL GetNewUnit(UGTP, ErrStat, ErrMsg)

CALL OpenUOutfile ( UGTP , TRIM( p%RootName)//'.bin', ErrStat, ErrMsg )
IF (ErrStat >= AbortErrLev) RETURN

Expand Down Expand Up @@ -3139,7 +3115,6 @@ SUBROUTINE WrHH_text(p, V, ErrStat, ErrMsg)

! p%WrFile(FileExt_DAT)

CALL GetNewUnit( UFTP, ErrStat, ErrMsg )
CALL OpenFOutFile ( UFTP, TRIM( p%RootName)//'.dat', ErrStat, ErrMsg )
IF (ErrStat >= AbortErrLev) RETURN

Expand Down
7 changes: 0 additions & 7 deletions modules/turbsim/src/TSsubs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ SUBROUTINE CalcFourierCoeffs_General( p, U, PhaseAngles, S, V, TRH, ErrStat, Err
IF ( COH_OUT ) THEN !debugging info...

! Write the coherence for three frequencies, for debugging purposes
CALL GetNewUnit( UC, ErrStat2, ErrMsg2 ); CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CalcFourierCoeffs_General')

CALL OpenFOutFile( UC, TRIM(p%RootName)//'.coh', ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CalcFourierCoeffs_General')
IF (ErrStat >= AbortErrLev) THEN
Expand Down Expand Up @@ -600,8 +598,6 @@ SUBROUTINE CalcFourierCoeffs_API( p, U, PhaseAngles, S, V, TRH, ErrStat, ErrMsg
IF ( COH_OUT ) THEN !debugging info...

! Write the coherence for three frequencies, for debugging purposes
CALL GetNewUnit( UC, ErrStat2, ErrMsg2 ); CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CalcFourierCoeffs_API')

CALL OpenFOutFile( UC, TRIM(p%RootName)//'.coh', ErrStat2, ErrMsg2 )
CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CalcFourierCoeffs_API')
IF (ErrStat >= AbortErrLev) THEN
Expand Down Expand Up @@ -1195,8 +1191,6 @@ SUBROUTINE CalcTargetPSD(p, S, U, ErrStat, ErrMsg)

!IF (PSD_OUT) THEN
! UP = -1
! CALL GetNewUnit( UP, ErrStat2, ErrMsg2 )
! CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! CALL OpenFOutFile ( UP, TRIM( p%RootName )//'.psd', ErrStat2, ErrMsg2)
! CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName )
! IF (ErrStat >= AbortErrLev) THEN
Expand Down Expand Up @@ -2149,7 +2143,6 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg)
! Mention the files in the summary file.

IF ( ANY (p%WrFile) ) THEN
CALL GetNewUnit( UnOut )

WRITE (p%US,"( // 'You have requested that the following file(s) be generated:' / )")

Expand Down

0 comments on commit 7fd00a0

Please sign in to comment.