From bccfe13f5c7b002e3f88a835c2009bf2cd4700d7 Mon Sep 17 00:00:00 2001 From: andrew-platt Date: Tue, 3 Dec 2024 14:50:14 -0700 Subject: [PATCH] Set file units to -1 before calling file open* subs --- glue-codes/fast-farm/src/FAST_Farm_IO.f90 | 3 ++- glue-codes/fast-farm/src/FAST_Farm_Subs.f90 | 1 + modules/aerodyn/src/AeroAcoustics_IO.f90 | 8 +++++-- .../aerodyn/src/AeroAcoustics_Registry.txt | 8 +++---- modules/aerodyn/src/AeroAcoustics_Types.f90 | 8 +++---- modules/aerodyn/src/AeroDyn_Driver_Subs.f90 | 3 ++- modules/aerodyn/src/AeroDyn_IO.f90 | 2 ++ modules/aerodyn/src/BEMT.f90 | 5 +++-- modules/aerodyn/src/FVW_IO.f90 | 1 + modules/aerodyn/src/FVW_Subs.f90 | 1 + modules/aerodyn/src/UA_Dvr_Subs.f90 | 6 ++++- modules/aerodyn/src/UnsteadyAero.f90 | 1 + modules/aerodyn14/src/AeroSubs.f90 | 6 +++++ .../src/DWM_driver_wind_farm_sub.f90 | 4 ++-- modules/awae/src/AWAE_Driver_Subs.f90 | 2 ++ modules/awae/src/AWAE_IO.f90 | 1 + modules/beamdyn/src/BeamDyn_IO.f90 | 4 +++- modules/beamdyn/src/Driver_Beam_Subs.f90 | 2 ++ modules/elastodyn/src/ElastoDyn.f90 | 1 + modules/elastodyn/src/ElastoDyn_IO.f90 | 5 ++++- modules/extptfm/src/ExtPtfm_MCKF_IO.f90 | 3 +++ modules/feamooring/src/FEAM.f90 | 1 + modules/hydrodyn/src/HydroDyn_DriverCode.f90 | 4 ++++ modules/hydrodyn/src/HydroDyn_Output.f90 | 4 ++++ modules/hydrodyn/src/Morison_Output.f90 | 1 + modules/hydrodyn/src/SS_Excitation.f90 | 3 +-- modules/hydrodyn/src/SS_Excitation_Driver.f90 | 3 +++ modules/hydrodyn/src/SS_Radiation.f90 | 6 ++--- .../hydrodyn/src/SS_Radiation_DriverCode.f90 | 2 ++ modules/hydrodyn/src/UserWaves.f90 | 7 +++--- modules/hydrodyn/src/WAMIT.f90 | 6 ++--- modules/hydrodyn/src/WAMIT2.f90 | 2 ++ modules/icedyn/src/Driver_IceDyn.f90 | 1 + modules/icedyn/src/IceDyn.f90 | 2 +- modules/icefloe/src/icefloe/iceInput.f90 | 1 + modules/icefloe/src/icefloe/iceLog.F90 | 1 + .../inflowwind/src/InflowWind_Driver_Subs.f90 | 6 +++-- .../src/InflowWind_Driver_Types.f90 | 2 +- modules/inflowwind/src/InflowWind_IO.f90 | 16 +++++++++++--- modules/map/src/map.f90 | 2 +- modules/moordyn/src/MoorDyn_IO.f90 | 2 ++ modules/moordyn/src/MoorDyn_Misc.f90 | 6 +++-- modules/moordyn/src/MoorDyn_Registry.txt | 6 ++--- modules/moordyn/src/MoorDyn_Types.f90 | 6 ++--- modules/nwtc-library/src/ModMesh_Mapping.f90 | 1 + modules/nwtc-library/src/NWTC_IO.f90 | 13 ++++++----- modules/nwtc-library/src/VTK.f90 | 4 +++- modules/openfast-library/src/FAST_Lin.f90 | 3 ++- modules/openfast-library/src/FAST_Subs.f90 | 3 +++ modules/orcaflex-interface/src/OrcaDriver.f90 | 2 +- .../src/OrcaDriver_Subs.f90 | 2 ++ .../src/OrcaDriver_Types.f90 | 2 +- .../src/OrcaFlexInterface.f90 | 1 + modules/servodyn/src/PitchCntrl_ACH.f90 | 4 ++-- modules/servodyn/src/ServoDyn_Driver.f90 | 2 +- modules/servodyn/src/ServoDyn_IO.f90 | 1 + modules/servodyn/src/StrucCtrl_Driver.f90 | 5 +++++ modules/servodyn/src/UserVSCont_KP.f90 | 2 +- modules/subdyn/src/SubDyn.f90 | 4 +--- modules/subdyn/src/SubDyn_Driver.f90 | 1 + modules/subdyn/src/SubDyn_Output.f90 | 5 +++-- modules/turbsim/src/CohStructures.f90 | 1 + modules/turbsim/src/TS_FileIO.f90 | 22 ++++++++++--------- modules/turbsim/src/TSsubs.f90 | 9 ++++++++ 64 files changed, 177 insertions(+), 75 deletions(-) diff --git a/glue-codes/fast-farm/src/FAST_Farm_IO.f90 b/glue-codes/fast-farm/src/FAST_Farm_IO.f90 index 0b232b05a1..88096646cc 100644 --- a/glue-codes/fast-farm/src/FAST_Farm_IO.f90 +++ b/glue-codes/fast-farm/src/FAST_Farm_IO.f90 @@ -73,6 +73,7 @@ SUBROUTINE Farm_PrintSum( farm, WD_InputFileData, ErrStat, ErrMsg ) CHARACTER(100) :: strModDescr ! Open the summary file and give it a heading. + UnSum = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( UnSum, TRIM( farm%p%OutFileRoot )//'.sum', ErrStat, ErrMsg ) IF ( ErrStat /= ErrID_None ) RETURN @@ -263,7 +264,7 @@ SUBROUTINE Farm_InitOutput( farm, ErrStat, ErrMsg ) !...................................................... ! IF (farm%p%WrTxtOutFile) THEN - + farm%p%UnOu = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( farm%p%UnOu, TRIM(farm%p%OutFileRoot)//'.out', ErrStat, ErrMsg ) IF ( ErrStat >= AbortErrLev ) RETURN diff --git a/glue-codes/fast-farm/src/FAST_Farm_Subs.f90 b/glue-codes/fast-farm/src/FAST_Farm_Subs.f90 index a39340d9cb..627967dc91 100644 --- a/glue-codes/fast-farm/src/FAST_Farm_Subs.f90 +++ b/glue-codes/fast-farm/src/FAST_Farm_Subs.f90 @@ -415,6 +415,7 @@ SUBROUTINE Farm_ReadPrimaryFile( InputFile, p, WD_InitInp, AWAE_InitInp, SC_Init ! Initialize some variables: UnEc = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls Echo = .FALSE. ! Don't echo until we've read the "Echo" flag CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. diff --git a/modules/aerodyn/src/AeroAcoustics_IO.f90 b/modules/aerodyn/src/AeroAcoustics_IO.f90 index 7aa5b4ecc1..c35832ffdb 100644 --- a/modules/aerodyn/src/AeroAcoustics_IO.f90 +++ b/modules/aerodyn/src/AeroAcoustics_IO.f90 @@ -118,7 +118,7 @@ SUBROUTINE ReadPrimaryFile( InputFile, InputFileData, Default_DT, OutFileRoot, U type(AA_InputFile), intent(inout) :: InputFileData ! All the data in the Noise input file ! Local variables: integer(IntKi) :: I ! loop counter - integer(IntKi) :: UnIn,UnIn2 ! Unit number for reading file + integer(IntKi) :: UnIn,UnIn2 ! Unit number for reading file (set to -1 so that Open* calls will find a valid unit number) character(1024) :: ObserverFile ! name of the files containing obesever location integer(IntKi) :: ErrStat2, IOS,cou ! Temporary Error status logical :: Echo ! Determines if an echo file should be written @@ -130,7 +130,9 @@ SUBROUTINE ReadPrimaryFile( InputFile, InputFileData, Default_DT, OutFileRoot, U ErrStat = ErrID_None ErrMsg = "" - UnEc = -1 + UnEc = -1 + UnIn = -1 + UnIn2 = -1 Echo = .FALSE. CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. @@ -333,6 +335,7 @@ SUBROUTINE ReadBLTables( InputFile, AFI, InputFileData, ErrStat, ErrMsg ) ! Initialize some variables: ErrStat = ErrID_None ErrMsg = "" + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. nAirfoils = size(AFI) @@ -438,6 +441,7 @@ SUBROUTINE ReadTICalcTables(InputFile, InputFileData, ErrStat, ErrMsg) ! Initialize some variables: ErrStat = ErrID_None ErrMsg = "" + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. diff --git a/modules/aerodyn/src/AeroAcoustics_Registry.txt b/modules/aerodyn/src/AeroAcoustics_Registry.txt index ec84c4c062..af51f6fa65 100644 --- a/modules/aerodyn/src/AeroAcoustics_Registry.txt +++ b/modules/aerodyn/src/AeroAcoustics_Registry.txt @@ -198,10 +198,10 @@ typedef ^ ParameterType IntKi NumOuts typedef ^ ParameterType IntKi NumOutsForPE - - - "Number of parameters in the output list (number of outputs requested)" - typedef ^ ParameterType IntKi NumOutsForSep - - - "Number of parameters in the output list (number of outputs requested)" - typedef ^ ParameterType IntKi NumOutsForNodes - - - "Number of parameters in the output list (number of outputs requested)" - -typedef ^ ParameterType IntKi unOutFile - - - "unit number for writing output file" "-" -typedef ^ ParameterType IntKi unOutFile2 - - - "unit number for writing output file" "-" -typedef ^ ParameterType IntKi unOutFile3 - - - "unit number for writing output file" "-" -typedef ^ ParameterType IntKi unOutFile4 - - - "unit number for writing output file" "-" +typedef ^ ParameterType IntKi unOutFile - -1 - "unit number for writing output file (set to -1 so that Open* calls will find a valid unit number)" "-" +typedef ^ ParameterType IntKi unOutFile2 - -1 - "unit number for writing output file (set to -1 so that Open* calls will find a valid unit number)" "-" +typedef ^ ParameterType IntKi unOutFile3 - -1 - "unit number for writing output file (set to -1 so that Open* calls will find a valid unit number)" "-" +typedef ^ ParameterType IntKi unOutFile4 - -1 - "unit number for writing output file (set to -1 so that Open* calls will find a valid unit number)" "-" typedef ^ ParameterType CHARACTER(1024) RootName - - - "RootName for writing output files" - typedef ^ ParameterType OutParmType OutParam {:} - - "Names and units (and other characteristics) of all requested output parameters" - typedef ^ ParameterType ReKi StallStart {:}{:} - - "ation" - diff --git a/modules/aerodyn/src/AeroAcoustics_Types.f90 b/modules/aerodyn/src/AeroAcoustics_Types.f90 index 8a702ba2fb..ac777e7adf 100644 --- a/modules/aerodyn/src/AeroAcoustics_Types.f90 +++ b/modules/aerodyn/src/AeroAcoustics_Types.f90 @@ -224,10 +224,10 @@ MODULE AeroAcoustics_Types INTEGER(IntKi) :: NumOutsForPE !< Number of parameters in the output list (number of outputs requested) [-] INTEGER(IntKi) :: NumOutsForSep !< Number of parameters in the output list (number of outputs requested) [-] INTEGER(IntKi) :: NumOutsForNodes !< Number of parameters in the output list (number of outputs requested) [-] - INTEGER(IntKi) :: unOutFile !< unit number for writing output file [-] - INTEGER(IntKi) :: unOutFile2 !< unit number for writing output file [-] - INTEGER(IntKi) :: unOutFile3 !< unit number for writing output file [-] - INTEGER(IntKi) :: unOutFile4 !< unit number for writing output file [-] + INTEGER(IntKi) :: unOutFile = -1 !< unit number for writing output file (set to -1 so that Open* calls will find a valid unit number) [-] + INTEGER(IntKi) :: unOutFile2 = -1 !< unit number for writing output file (set to -1 so that Open* calls will find a valid unit number) [-] + INTEGER(IntKi) :: unOutFile3 = -1 !< unit number for writing output file (set to -1 so that Open* calls will find a valid unit number) [-] + INTEGER(IntKi) :: unOutFile4 = -1 !< unit number for writing output file (set to -1 so that Open* calls will find a valid unit number) [-] CHARACTER(1024) :: RootName !< RootName for writing output files [-] TYPE(OutParmType) , DIMENSION(:), ALLOCATABLE :: OutParam !< Names and units (and other characteristics) of all requested output parameters [-] REAL(ReKi) , DIMENSION(:,:), ALLOCATABLE :: StallStart !< ation [-] diff --git a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 index 1f2f5a65f5..c952f0db0d 100644 --- a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 +++ b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 @@ -216,7 +216,7 @@ subroutine Dvr_InitCase(iCase, dvr, ADI, FED, errStat, errMsg ) call Dvr_InitializeDriverOutputs(dvr, ADI, errStat2, errMsg2); if(Failed()) return allocate(dvr%out%unOutFile(dvr%numTurbines)) endif - dvr%out%unOutFile = -1 + dvr%out%unOutFile = -1 ! set to -1 so that Open* calls will find a valid unit number ! --- Initialize ADI call Init_ADI_ForDriver(iCase, ADI, dvr, FED, dvr%dt, errStat2, errMsg2); if(Failed()) return @@ -1702,6 +1702,7 @@ subroutine ReadDelimFile(Filename, nCol, Array, errStat, errMsg, nHeaderLines, p character(len=2048) :: Filename_Loc ! filename local to this function errStat = ErrID_None errMsg = "" + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number Filename_Loc = Filename if (present(priPath)) then diff --git a/modules/aerodyn/src/AeroDyn_IO.f90 b/modules/aerodyn/src/AeroDyn_IO.f90 index 1307ba3469..5ddc2f56b7 100644 --- a/modules/aerodyn/src/AeroDyn_IO.f90 +++ b/modules/aerodyn/src/AeroDyn_IO.f90 @@ -1317,6 +1317,8 @@ SUBROUTINE AD_PrintSum( InputFileData, p, p_AD, u, y, ErrStat, ErrMsg ) CHARACTER(ChanLen),PARAMETER :: TitleStr(2) = (/ 'Parameter', 'Units ' /) CHARACTER(ChanLen),PARAMETER :: TitleStrLines(2) = (/ '---------------', '---------------' /) + UnSu = -1 ! set to -1 so that Open* calls will find a valid unit number + ! Open the summary file and give it a heading. CALL OpenFOutFile ( UnSu, TRIM( p%RootName )//'.sum', ErrStat, ErrMsg ) IF ( ErrStat >= AbortErrLev ) RETURN diff --git a/modules/aerodyn/src/BEMT.f90 b/modules/aerodyn/src/BEMT.f90 index 7b1df18f43..e77cc7f7fc 100644 --- a/modules/aerodyn/src/BEMT.f90 +++ b/modules/aerodyn/src/BEMT.f90 @@ -2392,11 +2392,12 @@ subroutine WriteDEBUGValuesToFile(t, u, p, x, xd, z, OtherState, m, AFInfo) integer, save :: DEBUG_BLADE integer, save :: DEBUG_BLADENODE integer, save :: DEBUG_nStep = 1 - integer, save :: DEBUG_FILE_UNIT + integer, save :: DEBUG_FILE_UNIT = -1 ! set to -1 so that Open* calls will find a valid unit number ! character(*), parameter :: RoutineName = 'BEMT_UnCoupledSolve' - DEBUG_BLADE = 1 !size(u%Vx,2) + UnOut = -1 ! set to -1 so that Open* calls will find a valid unit number + DEBUG_BLADE = 1 !size(u%Vx,2) DEBUG_BLADENODE = 23 !max(1, size(u%Vx,1) / 2 ) if (DEBUG_nStep == 1) then diff --git a/modules/aerodyn/src/FVW_IO.f90 b/modules/aerodyn/src/FVW_IO.f90 index fab11b1198..7d7859e144 100644 --- a/modules/aerodyn/src/FVW_IO.f90 +++ b/modules/aerodyn/src/FVW_IO.f90 @@ -24,6 +24,7 @@ SUBROUTINE FVW_ReadInputFile( FileName, p, m, Inp, ErrStat, ErrMsg ) character(ErrMsgLen) :: ErrMsg2 ErrStat = ErrID_None ErrMsg = "" + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number ! Open file CALL OpenFInpfile(UnIn, TRIM(FileName), ErrStat2, ErrMsg2) if (Check( ErrStat2 /= ErrID_None , 'Could not open input file')) return diff --git a/modules/aerodyn/src/FVW_Subs.f90 b/modules/aerodyn/src/FVW_Subs.f90 index 308e64e2df..914327b862 100644 --- a/modules/aerodyn/src/FVW_Subs.f90 +++ b/modules/aerodyn/src/FVW_Subs.f90 @@ -130,6 +130,7 @@ subroutine ReadAndInterpGamma(CirculationFileName, s_CP_LL, L, Gamma_CP_LL, ErrS real(ReKi), parameter :: ReNaN = huge(1.0_ReKi) ErrStat = ErrID_None ErrMsg = '' + iUnit = -1 ! set to -1 so that Open* calls will find a valid unit number ! --- call OpenFInpFile(iUnit, CirculationFileName, errStat2, errMsg2); if(Failed()) return nLines=line_count(iUnit)-1 diff --git a/modules/aerodyn/src/UA_Dvr_Subs.f90 b/modules/aerodyn/src/UA_Dvr_Subs.f90 index c308fd9548..d34ab5d25d 100644 --- a/modules/aerodyn/src/UA_Dvr_Subs.f90 +++ b/modules/aerodyn/src/UA_Dvr_Subs.f90 @@ -37,7 +37,7 @@ module UA_Dvr_Subs subroutine ReadDriverInputFile( inputFile, InitInp, ErrStat, ErrMsg ) character(1024), intent( in ) :: inputFile - type(UA_Dvr_InitInput), intent( out ) :: InitInp + type(UA_Dvr_InitInput), intent( out ) :: InitInp integer, intent( out ) :: ErrStat ! returns a non-zero value when an error occurs character(*), intent( out ) :: ErrMsg ! Error message if ErrStat /= ErrID_None @@ -57,6 +57,7 @@ subroutine ReadDriverInputFile( inputFile, InitInp, ErrStat, ErrMsg ) ! Initialize the echo file unit to -1 which is the default to prevent echoing, we will alter this based on user input UnEchoLocal = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls ErrStat = ErrID_None ErrMsg = '' FileName = trim(inputFile) @@ -426,6 +427,7 @@ subroutine ReadTimeSeriesData( inputsFile, nSimSteps, timeArr, AOAarr, Uarr, Ome ErrStat = ErrID_None ErrMsg = '' nSimSteps = 0 ! allocate here in case errors occur + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls FileName = trim(inputsFile) @@ -632,6 +634,8 @@ subroutine WriteAFITables(AFI_Params, OutRootName, UseCm, UA_f_cn) integer :: iTab, iRow, iStartUA type(AFI_Table_Type), pointer :: tab !< Alias + unOutFile = -1 ! set to -1 so that Open* calls will find a valid unit number + if (UA_f_cn) then Prefix='Cn_' sFullyAtt='Cn_FullyAtt' diff --git a/modules/aerodyn/src/UnsteadyAero.f90 b/modules/aerodyn/src/UnsteadyAero.f90 index 17d9c401c1..bbedfaf917 100644 --- a/modules/aerodyn/src/UnsteadyAero.f90 +++ b/modules/aerodyn/src/UnsteadyAero.f90 @@ -1084,6 +1084,7 @@ subroutine UA_Init( InitInp, u, p, x, xd, OtherState, y, m, Interval, & ! Initialize variables for this routine ErrStat = ErrID_None ErrMsg = "" + p%unOutFile = -1 ! set to -1 so that Open* calls will find a valid unit number ! Initialize the NWTC Subroutine Library diff --git a/modules/aerodyn14/src/AeroSubs.f90 b/modules/aerodyn14/src/AeroSubs.f90 index 2826a22868..c8a5472201 100644 --- a/modules/aerodyn14/src/AeroSubs.f90 +++ b/modules/aerodyn14/src/AeroSubs.f90 @@ -58,6 +58,7 @@ SUBROUTINE AD14_GetInput(InitInp, P, x, xd, z, m, y, ErrStat, ErrMess ) ErrStat = ErrID_None ErrMess = '' + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number !------------------------------------------------------------------------------------------------- ! Open the AeroDyn input file @@ -742,6 +743,7 @@ SUBROUTINE ADOut(InitInp, P, m, AD14_Ver, FileName, ErrStat, ErrMess ) ErrStat = ErrID_None ErrMess = "" + UnOut = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile( UnOut, FileName, ErrStatLcl, ErrMessLcl) CALL SetErrStat(ErrStatLcl,ErrMessLcl,ErrStat,ErrMess,'ADOut' ) @@ -1025,6 +1027,7 @@ SUBROUTINE READFL(InitInp, P, x, xd, z, m, y, ErrStat, ErrMess ) DO NFOILID = 1, p%AirFoil%NUMFOIL ! Open the file for reading # of lines + NUNIT = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile (NUNIT, TRIM(p%AirFoil%FOILNM(NFOILID)), ErrStatLcL, ErrMessLcl) CALL SetErrStat( ErrStatLcL, ErrMessLcl, ErrStat, ErrMess, 'READFL') IF (ErrStat >= AbortErrLev) THEN @@ -1057,6 +1060,7 @@ SUBROUTINE READFL(InitInp, P, x, xd, z, m, y, ErrStat, ErrMess ) DO NFOILID = 1, p%AirFoil%NUMFOIL ! Open the file for reading inputs + NUNIT = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile (NUNIT, TRIM(Adjustl(p%AirFoil%FOILNM(NFOILID))), ErrStatLcL, ErrMessLcl ) CALL SetErrStat( ErrStatLcL, ErrMessLcl, ErrStat, ErrMess, 'READFL') IF (ErrStat >= AbortErrLev) THEN @@ -1387,6 +1391,7 @@ SUBROUTINE READTwr(UnIn, InitInp, P, x, xd, z, m, y, ErrStat, ErrMess ) ! Open the file for reading !------------------------------------------------------------------------------------------------- FilName = p%TwrProps%TwrFile + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile (UnIn, TRIM(FilName), ErrStat, ErrMess ) IF ( ErrStat /= ErrID_None ) RETURN @@ -4463,6 +4468,7 @@ SUBROUTINE DynDebug (Time, P, x, xd, z, m, y, ErrStat, ErrMess, RHScos, RHSsin) ErrStat = ErrID_None ErrMess = "" + UnDyn = -1 ! set to -1 so that Open* calls will find a valid unit number !SAVE ! Save *all* local variables. Is this necessary, or is OnePass enough. diff --git a/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 b/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 index b2492b0462..361976cf8f 100644 --- a/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 +++ b/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 @@ -27,7 +27,7 @@ SUBROUTINE read_wind_farm_parameter(PriFile) IMPLICIT NONE CHARACTER(*), INTENT(IN) :: PriFile - INTEGER :: UnIn = 0 + INTEGER :: UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number INTEGER :: UnEc = -1 INTEGER :: I CHARACTER(1024) :: DWM_Title,comment @@ -877,4 +877,4 @@ SUBROUTINE rename_FAST_output(SimulationOrder_index) END SUBROUTINE rename_FAST_output -END MODULE DWM_driver_wind_farm_sub \ No newline at end of file +END MODULE DWM_driver_wind_farm_sub diff --git a/modules/awae/src/AWAE_Driver_Subs.f90 b/modules/awae/src/AWAE_Driver_Subs.f90 index 024fdae6b6..de8a23de96 100644 --- a/modules/awae/src/AWAE_Driver_Subs.f90 +++ b/modules/awae/src/AWAE_Driver_Subs.f90 @@ -53,6 +53,7 @@ module AWAE_Driver_Subs ! ErrMsg = "" ! ! UnEc = -1 +! UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number ! Echo = .FALSE. ! call GetPath( filename, PriPath ) ! Input files will be relative to the path where the driver input file is located. ! @@ -271,6 +272,7 @@ module AWAE_Driver_Subs ! ErrStat = ErrID_None ! ErrMsg = '' ! UnEcho = -1 +! UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number ! InputFileData%DT = Default_DT ! the glue code's suggested DT for the module (may be overwritten in ReadPrimaryFile()) ! ! ! get the primary/platform input-file data diff --git a/modules/awae/src/AWAE_IO.f90 b/modules/awae/src/AWAE_IO.f90 index 1fd51ec950..e59c94079e 100644 --- a/modules/awae/src/AWAE_IO.f90 +++ b/modules/awae/src/AWAE_IO.f90 @@ -539,6 +539,7 @@ SUBROUTINE AWAE_PrintSum( p, u, y, ErrStat, ErrMsg ) errStat = ErrID_None errMsg = "" + UnSu = -1 ! set to -1 so that Open* calls will find a valid unit number ! Open the summary file and give it a heading. CALL OpenFOutFile ( UnSu, TRIM( p%OutFileRoot )//'.sum', ErrStat, ErrMsg ) diff --git a/modules/beamdyn/src/BeamDyn_IO.f90 b/modules/beamdyn/src/BeamDyn_IO.f90 index 0d89e992dc..76da735873 100644 --- a/modules/beamdyn/src/BeamDyn_IO.f90 +++ b/modules/beamdyn/src/BeamDyn_IO.f90 @@ -577,6 +577,7 @@ SUBROUTINE BD_ReadPrimaryFile(InputFile,InputFileData,OutFileRoot,UnEc,ErrStat,E ErrMsg = "" Echo = .FALSE. UnEc = -1 + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. CALL AllocAry( InputFileData%OutList, MaxOutPts, "Outlist", ErrStat2, ErrMsg2 ) @@ -1045,6 +1046,7 @@ SUBROUTINE BD_ReadBladeFile(BldFile,BladeInputFileData,UnEc,ErrStat,ErrMsg) ErrStat = ErrID_None ErrMsg = "" + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile (UnIn,BldFile,ErrStat2,ErrMsg2) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) @@ -1935,7 +1937,7 @@ SUBROUTINE BD_PrintSum( p, x, OtherState, m, InitInp, ErrStat, ErrMsg ) CHARACTER(80) :: OutPFmt ! Format to print list of selected output channels to summary file ! Open the summary file and give it a heading. - + UnSu = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( UnSu, TRIM( InitInp%RootName )//'.sum.yaml', ErrStat, ErrMsg ) IF ( ErrStat >= AbortErrLev ) RETURN diff --git a/modules/beamdyn/src/Driver_Beam_Subs.f90 b/modules/beamdyn/src/Driver_Beam_Subs.f90 index 2d58710911..c953a6ddcb 100644 --- a/modules/beamdyn/src/Driver_Beam_Subs.f90 +++ b/modules/beamdyn/src/Driver_Beam_Subs.f90 @@ -100,6 +100,7 @@ SUBROUTINE BD_ReadDvrFile(DvrInputFile,dt,InitInputData,DvrData,& ErrStat = ErrID_None ErrMsg = "" UnEc = -1 + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile(UnIn,DvrInputFile,ErrStat2,ErrMsg2); if (Failed()) return; @@ -259,6 +260,7 @@ SUBROUTINE Dvr_InitializeOutputFile(OutUnit,IntOutput,RootName,ErrStat,ErrMsg) ErrStat = ErrID_none ErrMsg = "" + OutUnit = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( OutUnit, trim(RootName)//'.out', ErrStat2, ErrMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) diff --git a/modules/elastodyn/src/ElastoDyn.f90 b/modules/elastodyn/src/ElastoDyn.f90 index 2459c57fce..86bd20c0ed 100644 --- a/modules/elastodyn/src/ElastoDyn.f90 +++ b/modules/elastodyn/src/ElastoDyn.f90 @@ -9633,6 +9633,7 @@ SUBROUTINE ED_PrintSum( p, OtherState, ErrStat, ErrMsg ) CHARACTER(ChanLen),PARAMETER :: TitleStrLines(2) = (/ '---------------', '---------------' /) ! Open the summary file and give it a heading. + UnSu = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( UnSu, TRIM( p%RootName )//'.sum', ErrStat, ErrMsg ) IF ( ErrStat /= ErrID_None ) RETURN diff --git a/modules/elastodyn/src/ElastoDyn_IO.f90 b/modules/elastodyn/src/ElastoDyn_IO.f90 index 85d7769f60..b5fd60effc 100644 --- a/modules/elastodyn/src/ElastoDyn_IO.f90 +++ b/modules/elastodyn/src/ElastoDyn_IO.f90 @@ -1581,7 +1581,7 @@ SUBROUTINE ReadBladeFile ( BldFile, BladeKInputFileData, UnEc, ErrStat, ErrMsg ) ErrStat = ErrID_None ErrMsg = "" - UnIn = -1 + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number ! Open the input file for blade K. CALL OpenFInpFile ( UnIn, BldFile, ErrStat2, ErrMsg2 ) @@ -1883,6 +1883,7 @@ SUBROUTINE ReadBladeMeshFileAD( BladeKInputFileMesh, MeshFile, UnEc, ErrStat, Er ! Open the AeroDyn input file. + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnIn, MeshFile, ErrStat2, ErrMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF ( ErrStat >= AbortErrLev ) THEN @@ -2170,6 +2171,7 @@ SUBROUTINE ReadTowerFile( TwrFile, InputFileData, UnEc, ErrStat, ErrMsg ) ! Open the tower input file. + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnIn, TwrFile, ErrStat2, ErrMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF ( ErrStat >= AbortErrLev ) THEN @@ -2503,6 +2505,7 @@ SUBROUTINE ReadPrimaryFile( InputFile, InputFileData, BldFile, FurlFile, TwrFile ErrMsg = "" Echo = .FALSE. UnEc = -1 ! Echo file not opened, yet + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. diff --git a/modules/extptfm/src/ExtPtfm_MCKF_IO.f90 b/modules/extptfm/src/ExtPtfm_MCKF_IO.f90 index 21023f1498..8d568bdab9 100644 --- a/modules/extptfm/src/ExtPtfm_MCKF_IO.f90 +++ b/modules/extptfm/src/ExtPtfm_MCKF_IO.f90 @@ -348,6 +348,7 @@ SUBROUTINE ReadPrimaryFile(InputFile, p, OutFileRoot, InputFileData, ErrStat, Er ErrMsg = "" Echo = .FALSE. UnEc = -1 ! Echo file not opened, yet + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL GetPath(InputFile, PriPath) ! Input files will be relative to the path where the primary input file is located. CALL AllocAry(InputFileData%OutList, MaxOutChs, "ExtPtfm Input File's Outlist", ErrStat, ErrMsg); if(Failed()) return @@ -579,6 +580,7 @@ SUBROUTINE ReadReducedFile( InputFile, p, FileFormat, ErrStat, ErrMsg ) CHARACTER(4096) :: Line ! Temporary storage of a line from the input file (to compare with "default") ErrStat = ErrID_None ErrMsg = "" + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number if (FileFormat==FILEFORMAT_GUYANASCII) then call ReadGuyanASCII() elseif (FileFormat==FILEFORMAT_FLEXASCII) then @@ -820,6 +822,7 @@ SUBROUTINE ExtPtfm_PrintSum(x, p, m, RootName, ErrStat, ErrMsg) CHARACTER(ChanLen),PARAMETER :: TitleStrLines(2) = (/ '---------------', '---------------' /) ErrStat = ErrID_None ErrMsg = "" + UnSu = -1 ! set to -1 so that Open* calls will find a valid unit number ! TODO TODO TODO YAML FORMAT ! TODO TODO TODO ONLY Open Summary if no optional unit given diff --git a/modules/feamooring/src/FEAM.f90 b/modules/feamooring/src/FEAM.f90 index 70cafaa127..b490e3b60e 100644 --- a/modules/feamooring/src/FEAM.f90 +++ b/modules/feamooring/src/FEAM.f90 @@ -1666,6 +1666,7 @@ SUBROUTINE ReadPrimaryFile( InputFile, InputFileData, OutFileRoot, UnEc, ErrStat UnEc = -1 Echo = .FALSE. + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. CALL AllocAry( InputFileData%OutList, MaxOutPts, "FEAMooring Input File's Outlist", ErrStat2, ErrMsg2 ) diff --git a/modules/hydrodyn/src/HydroDyn_DriverCode.f90 b/modules/hydrodyn/src/HydroDyn_DriverCode.f90 index 08f6e156da..26e4ad6675 100644 --- a/modules/hydrodyn/src/HydroDyn_DriverCode.f90 +++ b/modules/hydrodyn/src/HydroDyn_DriverCode.f90 @@ -205,6 +205,7 @@ PROGRAM HydroDynDriver IF ( drvrInitInp%PRPInputsMod == 2 ) THEN ! Open the PRP inputs data file + UnPRPInp = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnPRPInp, drvrInitInp%PRPInputsFile, ErrStat, ErrMsg ) IF (ErrStat >=AbortErrLev) THEN call WrScr( ErrMsg ) @@ -239,6 +240,7 @@ PROGRAM HydroDynDriver NBODY = -drvrInitInp%PRPInputsMod ! Open the WAMIT inputs data file + UnPRPInp = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnPRPInp, drvrInitInp%PRPInputsFile, ErrStat, ErrMsg ) IF (ErrStat >=AbortErrLev) THEN call WrScr( ErrMsg ) @@ -650,6 +652,7 @@ SUBROUTINE ReadDriverInputFile( inputFile, InitInp, ErrStat, ErrMsg ) ! Initialize the echo file unit to -1 which is the default to prevent echoing, we will alter this based on user input UnEchoLocal = -1 + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number FileName = TRIM(inputFile) @@ -1118,6 +1121,7 @@ SUBROUTINE WaveElevGrid_Output (drvrInitInp, HDynInitInp, HDynInitOut, HDyn_p, E ErrStat = ErrID_None ErrMsgTmp = "" ErrStatTmp = ErrID_None + WaveElevFileUn = -1 ! set to -1 so that Open* calls will find a valid unit number ! If we calculated the wave elevation at a set of coordinates for use with making movies, put it into an output file diff --git a/modules/hydrodyn/src/HydroDyn_Output.f90 b/modules/hydrodyn/src/HydroDyn_Output.f90 index d1ae6aadc2..742b644b8f 100644 --- a/modules/hydrodyn/src/HydroDyn_Output.f90 +++ b/modules/hydrodyn/src/HydroDyn_Output.f90 @@ -977,6 +977,7 @@ SUBROUTINE HDOut_OpenSum( UnSum, SummaryName, HD_Prog, ErrStat, ErrMsg ) ErrStat = ErrID_None ErrMsg = "" + UnSum = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( UnSum, SummaryName, ErrStat, ErrMsg ) @@ -1032,6 +1033,7 @@ SUBROUTINE HDOut_WriteWvKinFiles( Rootname, HD_Prog, NStepWave, NNodes, NWaveEle DO iFile = 1,7 WvName = Rootname // TRIM(extension(iFile)) + UnWv = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( UnWv, WvName, ErrStat, ErrMsg ) IF (ErrStat >=AbortErrLev) RETURN @@ -1081,6 +1083,7 @@ SUBROUTINE HDOut_WriteWvKinFiles( Rootname, HD_Prog, NStepWave, NNodes, NWaveEle IF ( NWaveElev > 0 ) THEN WvName = Rootname // '.Elev' + UnWv = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( UnWv, WvName, ErrStat, ErrMsg ) IF (ErrStat >=AbortErrLev) RETURN @@ -1458,6 +1461,7 @@ SUBROUTINE HDOut_OpenOutput( HydroDyn_ProgDesc, OutRootName, p, InitOut, ErrSta ! Open the file for output OutFileName = TRIM(OutRootName)//'.HD.out' + p%UnOutFile = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( p%UnOutFile, OutFileName, ErrStat, ErrMsg ) IF (ErrStat >=AbortErrLev) RETURN diff --git a/modules/hydrodyn/src/Morison_Output.f90 b/modules/hydrodyn/src/Morison_Output.f90 index de88de6c57..58e1007e0f 100644 --- a/modules/hydrodyn/src/Morison_Output.f90 +++ b/modules/hydrodyn/src/Morison_Output.f90 @@ -6611,6 +6611,7 @@ SUBROUTINE MrsnOut_OpenOutput( ProgName, OutRootName, p, InitOut, ErrStat, ErrM ! Open the file for output OutFileName = TRIM(OutRootName)//'.MRSN.out' + p%UnOutFile = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( p%UnOutFile, OutFileName, ErrStat, ErrMsg ) IF (ErrStat >=AbortErrLev) RETURN diff --git a/modules/hydrodyn/src/SS_Excitation.f90 b/modules/hydrodyn/src/SS_Excitation.f90 index 5af0dd457c..e5a7d97a70 100644 --- a/modules/hydrodyn/src/SS_Excitation.f90 +++ b/modules/hydrodyn/src/SS_Excitation.f90 @@ -122,12 +122,11 @@ SUBROUTINE SS_Exc_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Ini u%DummyInput = 0.0_ReKi - UnSS = -1 + UnSS = -1 ! set to -1 so that Open* calls will find a valid unit number p%numStates = 0 p%NBody = InitInp%NBody ! Number of WAMIT bodies: =1 if WAMIT is using NBodyMod > 1, >=1 if NBodyMod=1 ! Open the .ss input file! - CALL GetNewUnit( UnSS ) CALL OpenFInpFile ( UnSS, TRIM(InitInp%InputFile)//'.ssexctn', ErrStat2, ErrMsg2 ) ! Open file. CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,'SS_Exc_Init') IF (ErrStat >= AbortErrLev) THEN diff --git a/modules/hydrodyn/src/SS_Excitation_Driver.f90 b/modules/hydrodyn/src/SS_Excitation_Driver.f90 index e07e00e55c..887b324570 100644 --- a/modules/hydrodyn/src/SS_Excitation_Driver.f90 +++ b/modules/hydrodyn/src/SS_Excitation_Driver.f90 @@ -111,7 +111,9 @@ PROGRAM SS_Excitation_Driver end do ! Need to read in the wave elevation data to pass in as initialization data +!FIXME: hard coded path!!!!!! waveFile = 'C:\Dev\Envision\all-changes\Test_Models\5MW_ITIBarge_DLL_WTurb_WavesIrr\barge.Elev' + UnWvEl = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenFInpFile ( UnWvEl, trim(waveFile), ErrStat, ErrMsg ) ! Open wave elevation file. if ( ErrStat /= 0 ) then ErrStat = ErrID_Fatal @@ -145,6 +147,7 @@ PROGRAM SS_Excitation_Driver ! Initialize output file + Outputy = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( Outputy, (TRIM(InitInData%InputFile)//'.out'), ErrStat, ErrMsg) IF ( ErrStat /= 0 ) THEN ErrStat = ErrID_Fatal diff --git a/modules/hydrodyn/src/SS_Radiation.f90 b/modules/hydrodyn/src/SS_Radiation.f90 index 0b45704828..8c8bdae86d 100644 --- a/modules/hydrodyn/src/SS_Radiation.f90 +++ b/modules/hydrodyn/src/SS_Radiation.f90 @@ -130,10 +130,10 @@ SUBROUTINE SS_Rad_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Ini character(ErrMsgLen) :: ErrMsg2 ! Initialize ErrStat - ErrStat = ErrID_None - ErrMsg = "" + ErrStat = ErrID_None + ErrMsg = "" - UnSS = -1 + UnSS = -1 ! set to -1 so that Open* calls will find a valid unit number N = 0 numStates = 0 p%NBody = InitInp%NBody ! Number of WAMIT bodies: =1 if WAMIT is using NBodyMod > 1, >=1 if NBodyMod=1 diff --git a/modules/hydrodyn/src/SS_Radiation_DriverCode.f90 b/modules/hydrodyn/src/SS_Radiation_DriverCode.f90 index 49f8e464c8..a1d56db4a0 100644 --- a/modules/hydrodyn/src/SS_Radiation_DriverCode.f90 +++ b/modules/hydrodyn/src/SS_Radiation_DriverCode.f90 @@ -106,6 +106,7 @@ PROGRAM SS_Radiation_Driver CALL Get_Arg_Num (len ) ! Read the time dependent input vector dq + Inputdq = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( Inputdq, (TRIM(InitInData%InputFile)//'.txt'), ErrStat ) ! Open motion file. IF ( ErrStat /= 0 ) THEN ErrStat = ErrID_Fatal @@ -126,6 +127,7 @@ PROGRAM SS_Radiation_Driver !!!GREG: here the output file is opened, you should not need this !Initialize output file + Outputy = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( Outputy, (TRIM(InitInData%InputFile)//'.out'), ErrStat) IF ( ErrStat /= 0 ) THEN ErrStat = ErrID_Fatal diff --git a/modules/hydrodyn/src/UserWaves.f90 b/modules/hydrodyn/src/UserWaves.f90 index 742d59cfe9..6a5d2cb582 100644 --- a/modules/hydrodyn/src/UserWaves.f90 +++ b/modules/hydrodyn/src/UserWaves.f90 @@ -79,6 +79,7 @@ SUBROUTINE WaveElev_ReadFile ( InitInp, WaveElevData, ErrStat, ErrMsg ) WaveElevData%FileName = TRIM(InitInp%WvKinFile)//'.Elev' ! Open the file containing the wave elevation timeseries + WaveElevUnit = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile( WaveElevUnit, WaveElevData%FileName, ErrStatTmp, ErrMsgTmp ) CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat,ErrMsg, RoutineName) IF (ErrStat >= AbortErrLev) THEN @@ -759,7 +760,7 @@ SUBROUTINE UserWaves_Init ( InitInp, InitOut, ErrStat, ErrMsg ) ! Read the first file and set the initial values of the FileName = TRIM(InitInp%WvKinFile) // TRIM(extension(1)) - + UnWv = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnWv, FileName, ErrStat, ErrMsg ) IF ( ErrStat /= 0 ) THEN ErrStat = ErrID_Fatal @@ -803,7 +804,7 @@ SUBROUTINE UserWaves_Init ( InitInp, InitOut, ErrStat, ErrMsg ) DO iFile = 2,7 FileName = TRIM(InitInp%WvKinFile) // TRIM(extension(iFile)) - + UnWv = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnWv, FileName, ErrStat, ErrMsg ) IF ( ErrStat /= 0 ) THEN ErrStat = ErrID_Fatal @@ -874,7 +875,7 @@ SUBROUTINE UserWaves_Init ( InitInp, InitOut, ErrStat, ErrMsg ) IF ( InitInp%NWaveElev > 0 ) THEN FileName = TRIM(InitInp%WvKinFile) // '.Elev' - + UnWv = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnWv, FileName, ErrStat, ErrMsg ) IF ( ErrStat /= 0 ) THEN ErrStat = ErrID_Fatal diff --git a/modules/hydrodyn/src/WAMIT.f90 b/modules/hydrodyn/src/WAMIT.f90 index bce90bec42..9ac5bdb8b9 100644 --- a/modules/hydrodyn/src/WAMIT.f90 +++ b/modules/hydrodyn/src/WAMIT.f90 @@ -325,7 +325,7 @@ SUBROUTINE WAMIT_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Init ! Linear restoring from the hydrostatics problem: - + UnWh = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnWh, TRIM(InitInp%WAMITFile)//'.hst', ErrStat2, ErrMsg2 ) ! Open file. CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'WAMIT_Init') IF ( ErrStat >= AbortErrLev ) THEN @@ -365,7 +365,7 @@ SUBROUTINE WAMIT_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Init ! Linear, frequency-dependent hydrodynamic added mass and damping from the ! radiation problem: - + UnW1 = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnW1, TRIM(InitInp%WAMITFile)//'.1', ErrStat2, ErrMsg2 ) ! Open file. CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'WAMIT_Init') IF ( ErrStat >= AbortErrLev ) THEN @@ -589,7 +589,7 @@ SUBROUTINE WAMIT_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Init ! Linear, frequency- and direction-dependent complex hydrodynamic wave ! excitation force per unit wave amplitude vector from the diffraction ! problem: - + UnW3 = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnW3, TRIM(InitInp%WAMITFile)//'.3', ErrStat2, ErrMsg2 ) ! Open file. CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'WAMIT_Init') IF ( ErrStat >= AbortErrLev ) THEN diff --git a/modules/hydrodyn/src/WAMIT2.f90 b/modules/hydrodyn/src/WAMIT2.f90 index 0c7a458601..74de75dd3a 100644 --- a/modules/hydrodyn/src/WAMIT2.f90 +++ b/modules/hydrodyn/src/WAMIT2.f90 @@ -3649,6 +3649,7 @@ SUBROUTINE Read_DataFile3D( InitInp, Filename3D, Data3D, ErrStat, Errmsg ) !------------------------------------------------------------------------------ ! Open the file + UnitDataFile = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile( UnitDataFile, TRIM(Filename3D), ErrStat, ErrMsg ) ! Open file containing mean drift information CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat, ErrMsg, RoutineName) IF ( ErrStat >= AbortErrLev ) THEN @@ -4410,6 +4411,7 @@ SUBROUTINE Read_DataFile4D( InitInp, Filename4D, Data4D, ErrStat, Errmsg ) !------------------------------------------------------------------------------ ! Open the file + UnitDataFile = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile( UnitDataFile, TRIM(Filename4D), ErrStat, ErrMsg ) ! Open file containing mean drift information CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat, ErrMsg, RoutineName) IF ( ErrStat >= AbortErrLev ) THEN diff --git a/modules/icedyn/src/Driver_IceDyn.f90 b/modules/icedyn/src/Driver_IceDyn.f90 index a2f1d3b3ad..1aa02b1c41 100644 --- a/modules/icedyn/src/Driver_IceDyn.f90 +++ b/modules/icedyn/src/Driver_IceDyn.f90 @@ -196,6 +196,7 @@ PROGRAM MAIN ! Open output file OutFileName = Trim(IceD_parameter%RootName)//'.txt' + Un = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile (Un, OutFileName, ErrStat, ErrMsg) CALL CheckError() diff --git a/modules/icedyn/src/IceDyn.f90 b/modules/icedyn/src/IceDyn.f90 index c0517d0ab6..a78693b1de 100644 --- a/modules/icedyn/src/IceDyn.f90 +++ b/modules/icedyn/src/IceDyn.f90 @@ -1141,7 +1141,7 @@ SUBROUTINE IceD_ReadInput( InitInp, InputFileData, ErrStat, ErrMsg ) ErrStat = ErrID_None ErrMsg = "" UnEc = -1 - UnIn = -1 + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number !------------------------------------------------------------------------------------------------- ! Open the file diff --git a/modules/icefloe/src/icefloe/iceInput.f90 b/modules/icefloe/src/icefloe/iceInput.f90 index 9d874607c5..5ba3d14082 100644 --- a/modules/icefloe/src/icefloe/iceInput.f90 +++ b/modules/icefloe/src/icefloe/iceInput.f90 @@ -147,6 +147,7 @@ subroutine countIceInputs (fname, iceLog, input) CHARACTER(msgLen) :: ErrMsg ! Error message if ErrStat /= ErrID_None integer(IntKi) :: ioStatus + input%UnitNum = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenFInpFile ( input%UnitNum, trim(fname), ErrStat, ErrMsg ) if (ErrStat >= AbortErrLev) then call iceErrorHndlr (iceLog, ErrStat, 'CountIceInputs => OpenFInpFile: '//newLine//ErrMsg, 1) diff --git a/modules/icefloe/src/icefloe/iceLog.F90 b/modules/icefloe/src/icefloe/iceLog.F90 index fec1db33d6..9efdcb2821 100644 --- a/modules/icefloe/src/icefloe/iceLog.F90 +++ b/modules/icefloe/src/icefloe/iceLog.F90 @@ -89,6 +89,7 @@ subroutine openIceLog (iceLog, logFile) INTEGER(IntKi) :: Err CHARACTER(msgLen) :: Msg + iceLog%unitNum = -1 ! set to -1 so that Open* calls will find a valid unit number if (present(logFile)) then call OpenFOutFile ( iceLog%unitNum, logFile, Err, Msg ) else diff --git a/modules/inflowwind/src/InflowWind_Driver_Subs.f90 b/modules/inflowwind/src/InflowWind_Driver_Subs.f90 index 608fd8fd69..190507047f 100644 --- a/modules/inflowwind/src/InflowWind_Driver_Subs.f90 +++ b/modules/inflowwind/src/InflowWind_Driver_Subs.f90 @@ -734,6 +734,7 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat ! Initialize the echo file unit to -1 which is the default to prevent echoing, we will alter this based on user input UnEchoLocal = -1 + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number FileName = TRIM(DvrFileName) @@ -1818,6 +1819,7 @@ SUBROUTINE ReadPointsFile( PointsFileName, CoordList, ErrStat, ErrMsg ) ErrMsgTmp = '' ErrStat = ErrID_None ErrStatTmp = ErrID_None + FiUnitPoints = -1 ! set to -1 so that Open* calls will find a valid unit number ! Now open file @@ -2315,7 +2317,7 @@ SUBROUTINE WindGridVel_OutputWrite (OutFile, Settings, GridXYZ, GridVel, TIME, E ! If it hasn't been initially written to, do this then exit. Otherwise set a few things and continue. IF ( .NOT. OutFile%Initialized ) THEN - + OutFile%Unit = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile( OutFile%Unit, TRIM(OutFile%Name), ErrStatTmp, ErrMsgTmp ) CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat, ErrMsg, 'WindGridVel_OutputWrite' ) IF ( ErrStat >= AbortErrLev ) RETURN @@ -2384,7 +2386,7 @@ SUBROUTINE PointData_OutputWrite (OutFile, Settings, GridXYZ, GridVel, GridAcc, ! If it hasn't been initially written to, do this then exit. Otherwise set a few things and continue. IF ( .NOT. OutFile%Initialized ) THEN - + OutFile%Unit = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile( OutFile%Unit, TRIM(OutFile%Name), ErrStatTmp, ErrMsgTmp ) CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat, ErrMsg, 'PointData_OutputWrite' ) IF ( ErrStat >= AbortErrLev ) RETURN diff --git a/modules/inflowwind/src/InflowWind_Driver_Types.f90 b/modules/inflowwind/src/InflowWind_Driver_Types.f90 index 669303cf60..c52f61d95b 100644 --- a/modules/inflowwind/src/InflowWind_Driver_Types.f90 +++ b/modules/inflowwind/src/InflowWind_Driver_Types.f90 @@ -34,7 +34,7 @@ MODULE InflowWind_Driver_Types TYPE OutputFile LOGICAL :: Initialized = .FALSE. !< Flag indicating that file has been initialized CHARACTER(1024) :: Name = "" !< Filename for output from points read in from points file - INTEGER(IntKi) :: Unit = -1 !< Unit number for the output file for the Points file output + INTEGER(IntKi) :: Unit = -1 !< Unit number for the output file for the Points file output, set to -1 so that Open* calls will find a valid unit number END TYPE !> This contains flags to note if the settings were made. This same data structure is diff --git a/modules/inflowwind/src/InflowWind_IO.f90 b/modules/inflowwind/src/InflowWind_IO.f90 index 0a2e11d75a..8d82c3cb7e 100644 --- a/modules/inflowwind/src/InflowWind_IO.f90 +++ b/modules/inflowwind/src/InflowWind_IO.f90 @@ -445,7 +445,8 @@ subroutine Uniform_WriteHH(UF, FileRootName, ErrStat, ErrMsg) character(ErrMsgLen) :: ErrMsg2 ErrStat = ErrID_None - ErrMsg = "" + ErrMsg = "" + Unit = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenFOutFile(unit, trim(FileRootName)//'.UniformWind.dat', ErrStat2, ErrMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -512,6 +513,7 @@ subroutine IfW_TurbSim_Init(InitInp, SumFileUnit, G3D, FileDat, ErrStat, ErrMsg) ErrStat = ErrID_None ErrMsg = "" + WindFileUnit = -1 ! set to -1 so that Open* calls will find a valid unit number !---------------------------------------------------------------------------- ! Open the binary wind file and read header @@ -790,6 +792,7 @@ subroutine IfW_HAWC_Init(InitInp, SumFileUnit, G3D, FileDat, ErrStat, ErrMsg) ErrStat = ErrID_None ErrMsg = "" + WindFileUnit = -1 ! set to -1 so that Open* calls will find a valid unit number G3D%WindFileFormat = 0 G3D%Periodic = .true. @@ -1126,6 +1129,7 @@ subroutine IfW_Bladed_Init(InitInp, SumFileUnit, InitOut, G3D, FileDat, ErrStat, ! determine what format binary file it is, and close it. !---------------------------------------------------------------------------- + UnitWind = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenBInpFile(UnitWind, TRIM(BinFileName), TmpErrStat, TmpErrMsg) call SetErrStat(TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return @@ -1183,6 +1187,7 @@ subroutine IfW_Bladed_Init(InitInp, SumFileUnit, InitOut, G3D, FileDat, ErrStat, ! Open the binary file and read its header !------------------------------------------------------------------------- + UnitWind = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenBInpFile(UnitWind, TRIM(BinFileName), TmpErrStat, TmpErrMsg) call SetErrStat(TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) then @@ -1452,6 +1457,7 @@ subroutine Bladed_ReadTurbSimSummary(UnitWind, FileName, CWise, ZCenter, TI, UBa ! Open summary file. !---------------------------------------------------------------------------------------------- + UnitWind = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenFInpFile(UnitWind, TRIM(FileName), TmpErrStat, TmpErrMsg) call SetErrStat(TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return @@ -2235,6 +2241,7 @@ subroutine Bladed_ReadTower(G3D, TwrFileName, ErrStat, ErrMsg) ! Open the file !---------------------------------------------------------------------------- + UnitWind = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenBInpFile(UnitWind, TRIM(TwrFileName), TmpErrStat, TmpErrMsg) call SetErrStat(TmpErrStat, TmpErrMsg, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return @@ -2671,6 +2678,7 @@ subroutine Grid3D_WriteBladed(G3D, FileRootName, ErrStat, ErrMsg) ! The summary file !---------------------------------------------------------------------------- + unit = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenFOutFile(unit, trim(FileRootName)//'-Bladed.sum', ErrStat2, ErrMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return @@ -2703,6 +2711,7 @@ subroutine Grid3D_WriteBladed(G3D, FileRootName, ErrStat, ErrMsg) ! The BINARY file !---------------------------------------------------------------------------- + unit = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenBOutFile(unit, TRIM(FileRootName)//'-Bladed.wnd', ErrStat, ErrMsg) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return @@ -2798,6 +2807,7 @@ subroutine Grid3D_WriteVTK(G3D, FileRootName, ErrStat, ErrMsg) FileName = trim(RootPathName)//PathSep//"DisYZ.t"//trim(num2lstr(i))//".vtp" ! see WrVTK_SP_header + unit = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenFOutFile(unit, TRIM(FileName), ErrStat2, ErrMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return @@ -2861,7 +2871,7 @@ subroutine Grid3D_WriteHAWC(G3D, FileRootName, ErrStat, ErrMsg) !---------------------------------------------------------------------------- ! Write summary file !---------------------------------------------------------------------------- - + unit = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenFOutFile(unit, trim(FileRootName)//'-HAWC.sum', ErrStat2, ErrMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return @@ -2899,7 +2909,7 @@ subroutine Grid3D_WriteHAWC(G3D, FileRootName, ErrStat, ErrMsg) !---------------------------------------------------------------------------- do IC = 1, G3D%NComp - + unit = -1 ! set to -1 so that Open* calls will find a valid unit number call OpenBOutFile(unit, trim(FileRootName)//'-HAWC-'//Comp(ic)//'.bin', ErrStat2, ErrMsg2) call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) if (ErrStat >= AbortErrLev) return diff --git a/modules/map/src/map.f90 b/modules/map/src/map.f90 index d6953ff481..c2831d104d 100644 --- a/modules/map/src/map.f90 +++ b/modules/map/src/map.f90 @@ -937,7 +937,7 @@ SUBROUTINE map_read_input_file_contents(file, InitInp, p, ErrStat) ! p%InputLines = "" ! Open the MAP input file - Un = -1 + Un = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( Un, file, ErrStat, ErrMsg ) IF ( ErrStat >= AbortErrLev )RETURN diff --git a/modules/moordyn/src/MoorDyn_IO.f90 b/modules/moordyn/src/MoorDyn_IO.f90 index 881e1f3651..ad2f187342 100644 --- a/modules/moordyn/src/MoorDyn_IO.f90 +++ b/modules/moordyn/src/MoorDyn_IO.f90 @@ -146,6 +146,7 @@ SUBROUTINE setupBathymetry(inputString, defaultDepth, BathGrid, BathGrid_Xs, Bat INTEGER(IntKi) :: nGridX ! integer of the size of BathGrid_Xs INTEGER(IntKi) :: nGridY ! integer of the size of BathGrid_Ys + UnCoef = -1 ! set to -1 so that Open* calls will find a valid unit number IF (LEN_TRIM(inputString) == 0) THEN ! If the input is empty (not provided), make the 1x1 bathymetry grid using the default depth @@ -233,6 +234,7 @@ SUBROUTINE getCoefficientOrCurve(inputString, LineProp_c, LineProp_npoints, Line CHARACTER(120) :: ErrMsg4 CHARACTER(120) :: Line2 + UnCoef = -1 ! set to -1 so that Open* calls will find a valid unit number if (SCAN(inputString, "abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ") == 0) then ! "eE" are exluded as they're used for scientific notation! diff --git a/modules/moordyn/src/MoorDyn_Misc.f90 b/modules/moordyn/src/MoorDyn_Misc.f90 index 801ed3f6fb..df59a3c7b7 100644 --- a/modules/moordyn/src/MoorDyn_Misc.f90 +++ b/modules/moordyn/src/MoorDyn_Misc.f90 @@ -1105,7 +1105,7 @@ SUBROUTINE WriteWaveGrid(p, ErrStat, ErrMsg) INTEGER(IntKi) :: UnOut ! for outputing wave kinematics data INTEGER(IntKi) :: I - + UnOut = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( UnOut, "waves.txt", ErrStat, ErrMsg ) IF ( ErrStat > ErrID_None ) THEN ErrMsg = ' Error opening wave grid file: '//TRIM(ErrMsg) @@ -1151,6 +1151,7 @@ SUBROUTINE WriteWaveData(p, ErrStat, ErrMsg) INTEGER(IntKi) :: UnOut ! for outputing wave kinematics data INTEGER(IntKi) :: I,J,K, l, Itemp + UnOut = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( UnOut, "wave data.txt", ErrStat, ErrMsg ) IF ( ErrStat > ErrID_None ) THEN ErrMsg = ' Error opening wave grid file: '//TRIM(ErrMsg) @@ -1365,6 +1366,7 @@ SUBROUTINE setupWaterKin(WaterKinString, p, Tmax, ErrStat, ErrMsg) UnEcho=-1 + UnIn =-1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile( UnIn, FileName, ErrStat2, ErrMsg2); if(Failed()) return @@ -1450,7 +1452,7 @@ SUBROUTINE setupWaterKin(WaterKinString, p, Tmax, ErrStat, ErrMsg) END IF ! note: following is adapted from MoorDyn_Driver - + UnElev = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnElev, WaveKinFile, ErrStat2, ErrMsg2 ); if(Failed()) return print *, 'Reading wave elevation data from ', trim(WaveKinFile) diff --git a/modules/moordyn/src/MoorDyn_Registry.txt b/modules/moordyn/src/MoorDyn_Registry.txt index 7965106d56..02e23c08ad 100644 --- a/modules/moordyn/src/MoorDyn_Registry.txt +++ b/modules/moordyn/src/MoorDyn_Registry.txt @@ -201,7 +201,7 @@ typedef ^ ^ DbKi a6 {6} typedef ^ ^ DbKi F6net {6} - - "total force and moment about end A (excluding inertial loads) that Rod may exert on whatever it's attached to" typedef ^ ^ DbKi M6net {6}{6} - - "total mass matrix about end A of Rod and any attached Points" typedef ^ ^ DbKi OrMat {3}{3} - - "DCM for body orientation" -typedef ^ ^ IntKi RodUnOut - - - "unit number of rod output file" +typedef ^ ^ IntKi RodUnOut - -1 - "unit number of rod output file" typedef ^ ^ DbKi RodWrOutput {:} - - "one row of output data for this rod" @@ -268,7 +268,7 @@ typedef ^ ^ DbKi S {:}{:}{:} typedef ^ ^ DbKi M {:}{:}{:} - - "node mass matrix" "[kg]" typedef ^ ^ DbKi EndMomentA {3} - - "vector of end moments due to bending at line end A" "[N-m]" typedef ^ ^ DbKi EndMomentB {3} - - "vector of end moments due to bending at line end B" "[N-m]" -typedef ^ ^ IntKi LineUnOut - - - "unit number of line output file" +typedef ^ ^ IntKi LineUnOut - -1 - "unit number of line output file" typedef ^ ^ DbKi LineWrOutput {:} - - "one row of output data for this line" # this is the Fail type, which holds data for possible line failure descriptors TO BE FILLED IN LATER @@ -383,7 +383,7 @@ typedef ^ ^ DbKi dtOut - typedef ^ ^ CHARACTER(1024) RootName - - - "RootName for writing output files" - typedef ^ ^ MD_OutParmType OutParam {:} - - "Names and units (and other characteristics) of all requested output parameters" - typedef ^ ^ CHARACTER(1) Delim - - - "Column delimiter for output text files" - -typedef ^ ^ IntKi MDUnOut - - - "Unit number of main output file" +typedef ^ ^ IntKi MDUnOut - -1 - "Unit number of main output file (set to -1 so that Open* calls will find a valid unit number)" typedef ^ ^ CHARACTER(1024) PriPath - - - "The path to the primary MoorDyn input file, used if looking for additional input files" typedef ^ ^ IntKi writeLog - -1 - "Switch for level of log file output" #NOTE: there may be an issue with start/restart with the UnLog stored in parameters. We'll ignore this for now -- ADP diff --git a/modules/moordyn/src/MoorDyn_Types.f90 b/modules/moordyn/src/MoorDyn_Types.f90 index debf2292ca..fe47f7450c 100644 --- a/modules/moordyn/src/MoorDyn_Types.f90 +++ b/modules/moordyn/src/MoorDyn_Types.f90 @@ -221,7 +221,7 @@ MODULE MoorDyn_Types REAL(DbKi) , DIMENSION(1:6) :: F6net !< total force and moment about end A (excluding inertial loads) that Rod may exert on whatever it's attached to [-] REAL(DbKi) , DIMENSION(1:6,1:6) :: M6net !< total mass matrix about end A of Rod and any attached Points [-] REAL(DbKi) , DIMENSION(1:3,1:3) :: OrMat !< DCM for body orientation [-] - INTEGER(IntKi) :: RodUnOut !< unit number of rod output file [-] + INTEGER(IntKi) :: RodUnOut = -1 !< unit number of rod output file [-] REAL(DbKi) , DIMENSION(:), ALLOCATABLE :: RodWrOutput !< one row of output data for this rod [-] END TYPE MD_Rod ! ======================= @@ -288,7 +288,7 @@ MODULE MoorDyn_Types REAL(DbKi) , DIMENSION(:,:,:), ALLOCATABLE :: M !< node mass matrix [[kg]] REAL(DbKi) , DIMENSION(1:3) :: EndMomentA !< vector of end moments due to bending at line end A [[N-m]] REAL(DbKi) , DIMENSION(1:3) :: EndMomentB !< vector of end moments due to bending at line end B [[N-m]] - INTEGER(IntKi) :: LineUnOut !< unit number of line output file [-] + INTEGER(IntKi) :: LineUnOut = -1 !< unit number of line output file [-] REAL(DbKi) , DIMENSION(:), ALLOCATABLE :: LineWrOutput !< one row of output data for this line [-] END TYPE MD_Line ! ======================= @@ -418,7 +418,7 @@ MODULE MoorDyn_Types CHARACTER(1024) :: RootName !< RootName for writing output files [-] TYPE(MD_OutParmType) , DIMENSION(:), ALLOCATABLE :: OutParam !< Names and units (and other characteristics) of all requested output parameters [-] CHARACTER(1) :: Delim !< Column delimiter for output text files [-] - INTEGER(IntKi) :: MDUnOut !< Unit number of main output file [-] + INTEGER(IntKi) :: MDUnOut = -1 !< Unit number of main output file (set to -1 so that Open* calls will find a valid unit number) [-] CHARACTER(1024) :: PriPath !< The path to the primary MoorDyn input file, used if looking for additional input files [-] INTEGER(IntKi) :: writeLog = -1 !< Switch for level of log file output [-] INTEGER(IntKi) :: UnLog = -1 !< Unit number of log file [-] diff --git a/modules/nwtc-library/src/ModMesh_Mapping.f90 b/modules/nwtc-library/src/ModMesh_Mapping.f90 index 11397a5a7f..56fb2d65f8 100644 --- a/modules/nwtc-library/src/ModMesh_Mapping.f90 +++ b/modules/nwtc-library/src/ModMesh_Mapping.f90 @@ -1961,6 +1961,7 @@ SUBROUTINE CreateMapping_ProjectToLine2(Mesh1, Mesh2, NodeMap, Mesh1_TYPE, ErrSt #ifdef DEBUG_MESHMAPPING ! output some mesh information for debugging DebugFileName='FAST_Meshes.'//trim(num2Lstr(Un))//'.dbg' + Un = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile(Un,DebugFileName,ErrStat2,ErrMsg2) IF (ErrStat2 >= AbortErrLev) RETURN diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index 63155a09f0..c2a3486ab5 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -2397,7 +2397,7 @@ SUBROUTINE OpenEcho ( Un, OutFile, ErrStat, ErrMsg, ProgVer ) ! Open the file for writing: !$OMP critical - call GetNewUnit(Un,ErrStat,ErrMsg) + if (Un<=0) call GetNewUnit(Un,ErrStat,ErrMsg) if (ErrStat==ErrID_None) then CALL OpenFOutFile( Un, OutFile, ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2, ErrMsg2,ErrStat, ErrMsg, RoutineName ) @@ -2440,7 +2440,7 @@ SUBROUTINE OpenFInpFile ( Un, InFile, ErrStat, ErrMsg ) ! Open input file. Make sure it worked. !$OMP critical - call GetNewUnit(Un,ErrStat,ErrMsg) + if (Un<=0) call GetNewUnit(Un,ErrStat,ErrMsg) if (ErrStat==ErrID_None) then OPEN( Un, FILE=TRIM( InFile ), STATUS='OLD', FORM='FORMATTED', IOSTAT=IOS, ACTION='READ' ) @@ -2468,7 +2468,7 @@ SUBROUTINE OpenFOutFile ( Un, OutFile, ErrStat, ErrMsg ) ! Open output file. Make sure it worked. !$OMP critical - call GetNewUnit(Un,ErrStat,ErrMsg) + if (Un<=0) call GetNewUnit(Un,ErrStat,ErrMsg) if (ErrStat==ErrID_None) then OPEN( Un, FILE=TRIM( OutFile ), STATUS='UNKNOWN', FORM='FORMATTED', IOSTAT=IOS, ACTION="WRITE" ) @@ -2504,7 +2504,7 @@ SUBROUTINE OpenFUnkFile ( Un, OutFile, FailAbt, Failed, Exists, ErrStat, ErrMsg ! Open output file. Make sure it worked. !$OMP critical - call GetNewUnit(Un,ErrStat,ErrMsg) + if (Un<=0) call GetNewUnit(Un,ErrStat,ErrMsg) if (ErrStat==ErrID_None) then OPEN( Un, FILE=TRIM( OutFile ), STATUS='UNKNOWN', FORM='FORMATTED', IOSTAT=IOS ) @@ -2540,7 +2540,7 @@ SUBROUTINE OpenFUnkFileAppend ( Un, OutFile, ErrStat, ErrMsg ) ! Open output file. Make sure it worked. !$OMP critical - call GetNewUnit(Un,ErrStat,ErrMsg) + if (Un<=0) call GetNewUnit(Un,ErrStat,ErrMsg) if (ErrStat==ErrID_None) then if (FileExists) then OPEN( Un, FILE=TRIM( OutFile ), STATUS='OLD', POSITION='APPEND', FORM='FORMATTED', IOSTAT=IOS, ACTION="WRITE" ) @@ -2593,7 +2593,7 @@ SUBROUTINE OpenUInBEFile( Un, InFile, RecLen, ErrStat, ErrMsg ) ! Open the file. !$OMP critical - call GetNewUnit(Un,ErrStat,ErrMsg) + if (Un<=0) call GetNewUnit(Un,ErrStat,ErrMsg) if (ErrStat==ErrID_None) then CALL OpenUnfInpBEFile ( Un, InFile, RecLen, Error ) @@ -4545,6 +4545,7 @@ RECURSIVE SUBROUTINE ReadComFile ( FileInfo, FileIndx, AryInd, StartLine, LastLi RETURN END IF + UnIn = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFInpFile ( UnIn, FileInfo%FileList(FileIndx), ErrStatLcl, ErrMsg2 ) CALL SetErrStat( ErrStatLcl, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF ( ErrStat >= AbortErrLev ) RETURN diff --git a/modules/nwtc-library/src/VTK.f90 b/modules/nwtc-library/src/VTK.f90 index 3577a1bf8c..a0e2504c30 100644 --- a/modules/nwtc-library/src/VTK.f90 +++ b/modules/nwtc-library/src/VTK.f90 @@ -93,7 +93,8 @@ SUBROUTINE WrVTK_header( FileName, NumberOfPoints, NumberOfLines, NumberOfPolys, INTEGER(IntKi) , INTENT( OUT) :: Un !< unit number of opened file INTEGER(IntKi) , INTENT( OUT) :: ErrStat !< error level/status of OpenFOutFile operation CHARACTER(*) , INTENT( OUT) :: ErrMsg !< message when error occurs - + + Un = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( Un, TRIM(FileName), ErrStat, ErrMsg ) if (ErrStat >= AbortErrLev) return @@ -356,6 +357,7 @@ SUBROUTINE WrVTK_SP_header( FileName, descr, Un, ErrStat, ErrMsg ) INTEGER(IntKi) , INTENT( OUT) :: ErrStat !< error level/status of OpenFOutFile operation CHARACTER(*) , INTENT( OUT) :: ErrMsg !< message when error occurs + Un = -1 ! set to -1 so that Open* calls will find a valid unit number CALL OpenFOutFile ( Un, TRIM(FileName), ErrStat, ErrMsg ) if (ErrStat >= AbortErrLev) return diff --git a/modules/openfast-library/src/FAST_Lin.f90 b/modules/openfast-library/src/FAST_Lin.f90 index be6241e29c..9e4535ad7a 100644 --- a/modules/openfast-library/src/FAST_Lin.f90 +++ b/modules/openfast-library/src/FAST_Lin.f90 @@ -1273,7 +1273,8 @@ SUBROUTINE WrLinFile_txt_Head(t_global, p_FAST, y_FAST, LinData, FileName, Un, E ErrStat = ErrID_None - ErrMsg = "" + ErrMsg = "" + Un = -1 ! set to -1 at start to find valid unit numbers in Open* calls n = 0; if (allocated(LinData%names_x )) n(Indx_x) = size(LinData%names_x ) diff --git a/modules/openfast-library/src/FAST_Subs.f90 b/modules/openfast-library/src/FAST_Subs.f90 index f526416da3..f35981d436 100644 --- a/modules/openfast-library/src/FAST_Subs.f90 +++ b/modules/openfast-library/src/FAST_Subs.f90 @@ -2407,6 +2407,7 @@ SUBROUTINE FAST_ReadPrimaryFile( InputFile, p, m_FAST, OverrideAbortErrLev, ErrS ! Initialize some variables: UnEc = -1 Echo = .FALSE. ! Don't echo until we've read the "Echo" flag + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. @@ -7595,6 +7596,7 @@ SUBROUTINE ReadModeShapeMatlabFile(p_FAST, ErrStat, ErrMsg) ErrStat = ErrID_None ErrMsg = "" + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls ! Open data file. CALL OpenBInpFile ( UnIn, trim(p_FAST%VTK_modes%MatlabFileName), ErrStat2, ErrMsg2 ) @@ -7717,6 +7719,7 @@ SUBROUTINE ReadModeShapeFile(p_FAST, InputFile, ErrStat, ErrMsg, checkpointOnly) ErrStat = ErrID_None ErrMsg = "" UnEc = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. diff --git a/modules/orcaflex-interface/src/OrcaDriver.f90 b/modules/orcaflex-interface/src/OrcaDriver.f90 index 667e588cd4..be199ca02d 100644 --- a/modules/orcaflex-interface/src/OrcaDriver.f90 +++ b/modules/orcaflex-interface/src/OrcaDriver.f90 @@ -526,7 +526,7 @@ PROGRAM OrcaDriver ! write the output file. This is a bit of a hack here to use the same routine as used for the points file output TmpFlag = .FALSE. ! Tell the subroutine that it has not initialized the file before - TmpUnit = -1 ! Temporary unit number to pass + TmpUnit = -1 ! Temporary unit number to pass (set to -1 at start to find valid unit numbers in Open* calls) CALL GetRoot( Settings%DvrIptFileName, TmpChar ) ! Get the root name TmpChar=TRIM(TmpChar)//'.out' diff --git a/modules/orcaflex-interface/src/OrcaDriver_Subs.f90 b/modules/orcaflex-interface/src/OrcaDriver_Subs.f90 index 1aa91b05c1..ecb94ab0b4 100644 --- a/modules/orcaflex-interface/src/OrcaDriver_Subs.f90 +++ b/modules/orcaflex-interface/src/OrcaDriver_Subs.f90 @@ -779,6 +779,7 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat ! Initialize the echo file unit to -1 which is the default to prevent echoing, we will alter this based on user input UnEchoLocal = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls FileName = TRIM(DvrFileName) @@ -1369,6 +1370,7 @@ SUBROUTINE ReadPointsFile( PointsFileName, AnglesInDegrees, TimeList, CoordList, ErrMsgTmp = '' ErrStat = ErrID_None ErrStatTmp = ErrID_None + FUnitPoints = -1 ! set to -1 at start to find valid unit numbers in Open* calls ! Set the ConvToRadians multiplier IF ( AnglesInDegrees) THEN diff --git a/modules/orcaflex-interface/src/OrcaDriver_Types.f90 b/modules/orcaflex-interface/src/OrcaDriver_Types.f90 index 78bbd7bf9b..0c2dbf165a 100644 --- a/modules/orcaflex-interface/src/OrcaDriver_Types.f90 +++ b/modules/orcaflex-interface/src/OrcaDriver_Types.f90 @@ -76,7 +76,7 @@ MODULE OrcaDriver_Types CHARACTER(1024) :: PointsFileName !< Filename of points file to read in CHARACTER(1024) :: PointsOutputName !< Filename for output from points read in from points file - INTEGER(IntKi) :: AddedMassOutputUnit !< Unit number for the output file for the AddedMass matrix + INTEGER(IntKi) :: AddedMassOutputUnit = 01 !< Unit number for the output file for the AddedMass matrix (set to -1 at start to find valid unit numbers in Open* calls) INTEGER(IntKi) :: PointsOutputUnit !< Unit number for the output file for the Points file output REAL(DbKi) :: DT !< resolution of time REAL(ReKi) :: TMax !< Maximum time (we calculate this based on the number of points and timestep) diff --git a/modules/orcaflex-interface/src/OrcaFlexInterface.f90 b/modules/orcaflex-interface/src/OrcaFlexInterface.f90 index 98aca12818..9919c26caa 100644 --- a/modules/orcaflex-interface/src/OrcaFlexInterface.f90 +++ b/modules/orcaflex-interface/src/OrcaFlexInterface.f90 @@ -425,6 +425,7 @@ SUBROUTINE ReadPrimaryFile( InputFile, InputFileData, OutFileRoot, ErrStat, ErrM ! Initialize some variables: Echo = .FALSE. UnEc = -1 ! Echo file not opened, yet + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. ! OrcaFlex doesn't like relative path names, so we're going to make it absolute diff --git a/modules/servodyn/src/PitchCntrl_ACH.f90 b/modules/servodyn/src/PitchCntrl_ACH.f90 index 702e813c47..787ff5ab90 100644 --- a/modules/servodyn/src/PitchCntrl_ACH.f90 +++ b/modules/servodyn/src/PitchCntrl_ACH.f90 @@ -91,7 +91,7 @@ SUBROUTINE PitchCntrl ( BlPitch, ElecPwr, LSS_Spd, TwrAccel, NB, ZTime, DT, DirR PitchFileName = 'pitch.ipt' END IF - + unit = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFInpFile ( unit, TRIM(PitchFileName), ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) CALL ProgAbort(TRIM(ErrMsg)) @@ -321,7 +321,7 @@ SUBROUTINE CTRL4 ( CNST, AC, BC, NORDER, MSZ, NSZ, & ! Open file to receive control variable output for debug (if desired) IF( DEBUGFLAG == 1 ) THEN - + unit = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile (unit, 'pitcntrl.plt', ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) CALL ProgAbort(TRIM(ErrMsg)) WRITE (unit,"( / 'This file was generated by ' , A , A , ' on ' , A , ' at ' , A , '.' / )") & diff --git a/modules/servodyn/src/ServoDyn_Driver.f90 b/modules/servodyn/src/ServoDyn_Driver.f90 index 29cd09fcc3..f25f3212af 100644 --- a/modules/servodyn/src/ServoDyn_Driver.f90 +++ b/modules/servodyn/src/ServoDyn_Driver.f90 @@ -79,7 +79,7 @@ PROGRAM SrvD_Driver CALL GetRoot( InitInData%InputFile, OutFile ) OutFile = trim(OutFile)//'.out' - + Un = -1 ! set to -1 at start to find valid unit numbers in Open* calls call OpenFOutFile ( Un, OutFile, ErrStat, ErrMsg ) ! Set the driver's request for time interval here: diff --git a/modules/servodyn/src/ServoDyn_IO.f90 b/modules/servodyn/src/ServoDyn_IO.f90 index 5ca7be3e15..6a66fa59eb 100644 --- a/modules/servodyn/src/ServoDyn_IO.f90 +++ b/modules/servodyn/src/ServoDyn_IO.f90 @@ -2399,6 +2399,7 @@ subroutine InitializeSummaryFile(InputFileData,OutfileRoot,UnSum,ErrStat,ErrMsg) ! init vars ErrStat = ErrID_None ErrMsg = '' + UnSum = -1 ! set to -1 at start to find valid unit numbers in Open* calls if ( InputFileData%SumPrint ) then CALL OpenEcho ( UnSum, TRIM(OutFileRoot)//'.sum', ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2,ErrMsg2,ErrStat,ErrMsg,RoutineName) diff --git a/modules/servodyn/src/StrucCtrl_Driver.f90 b/modules/servodyn/src/StrucCtrl_Driver.f90 index f95a143634..f86ff83e53 100644 --- a/modules/servodyn/src/StrucCtrl_Driver.f90 +++ b/modules/servodyn/src/StrucCtrl_Driver.f90 @@ -151,6 +151,7 @@ SUBROUTINE ReadAngPosFile( InputFile, APvec, NumSteps, UnEc, ErrStat, ErrMsg ) ErrMsg = "" UnEc = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls Echo = .FALSE. CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. @@ -254,6 +255,7 @@ SUBROUTINE ReadAngVelFile( InputFile, AVvec, NumSteps, UnEc, ErrStat, ErrMsg ) ErrMsg = "" UnEc = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls Echo = .FALSE. CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. @@ -356,6 +358,7 @@ SUBROUTINE ReadAngAccelFile( InputFile, AAvec, NumSteps, UnEc, ErrStat, ErrMsg ) ErrMsg = "" UnEc = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls Echo = .FALSE. CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. @@ -457,6 +460,7 @@ SUBROUTINE ReadAccelFile( InputFile, LAvec, NumSteps, UnEc, ErrStat, ErrMsg ) ErrMsg = "" UnEc = -1 + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls Echo = .FALSE. CALL GetPath( InputFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. @@ -539,6 +543,7 @@ SUBROUTINE StC_OpenOutputFile(OutputFile,UnIn,ErrStat,ErrMsg) ErrStat = ErrID_None ErrMsg = '' + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls !OutputFile = 'StC_Output_Data.txt' !Fmt = "F10.2))/" diff --git a/modules/servodyn/src/UserVSCont_KP.f90 b/modules/servodyn/src/UserVSCont_KP.f90 index b1cf8af67d..b0535e9908 100644 --- a/modules/servodyn/src/UserVSCont_KP.f90 +++ b/modules/servodyn/src/UserVSCont_KP.f90 @@ -140,7 +140,7 @@ SUBROUTINE UserVSCont ( HSS_Spd, LSS_Spd, NumBl, ZTime, DT, GenEff, DelGenTrq, D inFileName = 'spd_trq.dat' END IF - + UnCont = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFInpFile ( UnCont, TRIM(inFileName), ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) CALL ProgAbort(TRIM(ErrMsg)) diff --git a/modules/subdyn/src/SubDyn.f90 b/modules/subdyn/src/SubDyn.f90 index 1258379d05..32d81ec67b 100644 --- a/modules/subdyn/src/SubDyn.f90 +++ b/modules/subdyn/src/SubDyn.f90 @@ -864,10 +864,9 @@ SUBROUTINE SD_Input(SDInputFile, Init, p, ErrStat,ErrMsg) ErrMsg = "" UnEc = -1 +UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls Echo = .FALSE. -CALL GetNewUnit( UnIn ) - CALL OpenFInpfile(UnIn, TRIM(SDInputFile), ErrStat2, ErrMsg2) IF ( ErrStat2 /= ErrID_None ) THEN @@ -3491,7 +3490,6 @@ SUBROUTINE WriteJSONCommon(FileName, Init, p, m, InitInput, FileKind, UnSum, Err ! --- Create file and get unit UnSum = -1 ! we haven't opened the summary file, yet. - call GetNewUnit( UnSum ) call OpenFOutFile ( UnSum, FileName, ErrStat2, ErrMsg2 ) write(UnSum, '(A)')'{' diff --git a/modules/subdyn/src/SubDyn_Driver.f90 b/modules/subdyn/src/SubDyn_Driver.f90 index 6c8b9422ee..fff5d612ed 100644 --- a/modules/subdyn/src/SubDyn_Driver.f90 +++ b/modules/subdyn/src/SubDyn_Driver.f90 @@ -531,6 +531,7 @@ subroutine ReadDelimFile(Filename, nCol, Array, errStat, errMsg, nHeaderLines, p character(len=2048) :: Filename_Loc ! filename local to this function ErrStat = ErrID_None ErrMsg = "" + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls Filename_Loc = Filename if (present(priPath)) then diff --git a/modules/subdyn/src/SubDyn_Output.f90 b/modules/subdyn/src/SubDyn_Output.f90 index 769caf5ec0..b5f7e88a8c 100644 --- a/modules/subdyn/src/SubDyn_Output.f90 +++ b/modules/subdyn/src/SubDyn_Output.f90 @@ -512,7 +512,7 @@ SUBROUTINE SDOut_OpenSum( UnSum, SummaryName, SD_Prog, ErrStat, ErrMsg ) ErrStat = ErrID_None ErrMsg = "" - CALL GetNewUnit( UnSum ) + UnSum = -1 ! OpenFOutFile will find a unit number CALL OpenFOutFile ( UnSum, SummaryName, ErrStat, ErrMsg ) IF ( ErrStat >= AbortErrLev ) THEN ErrMsg = 'Failed to open SubDyn summary file: '//TRIM(ErrMsg) @@ -543,11 +543,12 @@ SUBROUTINE SDOut_OpenOutput( ProgVer, OutRootName, p, InitOut, ErrStat, ErrMsg INTEGER :: ErrStat2 ErrStat = ErrID_None ErrMsg = "" + p%UnJckF = -1 ! unit for summary file set to -1 so OpenFOutFile will find a valid unit number + ! Open the output file, if necessary, and write the header IF ( ALLOCATED( p%OutParam ) .AND. p%NumOuts > 0 ) THEN ! Output has been requested so let's open an output file ! Open the file for output OutFileName = TRIM(OutRootName)//'.out' - CALL GetNewUnit( p%UnJckF ) CALL OpenFOutFile ( p%UnJckF, OutFileName, ErrStat, ErrMsg ) IF ( ErrStat >= AbortErrLev ) THEN diff --git a/modules/turbsim/src/CohStructures.f90 b/modules/turbsim/src/CohStructures.f90 index 029332ab74..27161b91f5 100644 --- a/modules/turbsim/src/CohStructures.f90 +++ b/modules/turbsim/src/CohStructures.f90 @@ -116,6 +116,7 @@ SUBROUTINE CohStr_ReadEventFile( p_CohStr, y_CohStr, e_CohStr, TSclFact, ErrStat ErrStat = ErrID_None ErrMsg = "" + Un = -1 ! set to -1 at start to find valid unit numbers in Open* calls MaxEvtCTKE = 0.0 ! initialize the MAX variable diff --git a/modules/turbsim/src/TS_FileIO.f90 b/modules/turbsim/src/TS_FileIO.f90 index 95e45fd925..cebfeedadb 100644 --- a/modules/turbsim/src/TS_FileIO.f90 +++ b/modules/turbsim/src/TS_FileIO.f90 @@ -94,6 +94,7 @@ SUBROUTINE ReadInputFile(InFile, p, OtherSt_RandNum, ErrStat, ErrMsg) UnEc = -1 + UI = -1 ! set to -1 at start to find valid unit numbers in Open* calls Echo = .FALSE. CALL GetPath( InFile, PriPath ) ! Input files will be relative to the path where the primary input file is located. @@ -1394,7 +1395,7 @@ SUBROUTINE GetUSRSpec(FileName, p, UnEc, ErrStat, ErrMsg) ErrMSg = "" ! --------- Open the file --------------- - + USpec = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFInpFile( USpec, FileName, ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2, ErrMsg2 , ErrStat, ErrMsg, RoutineName) IF (ErrStat >= AbortErrLev) THEN @@ -1585,7 +1586,7 @@ SUBROUTINE GetUSRTimeSeries(FileName, p, UnEc, ErrStat, ErrMsg) ErrMsg = "" ! --------- Open the file --------------- - + UnIn = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFInpFile( UnIn, FileName, ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2, ErrMsg2 , ErrStat, ErrMsg, RoutineName) IF (ErrStat >= AbortErrLev) THEN @@ -2106,7 +2107,7 @@ SUBROUTINE WrBinBLADED(p, V, USig, VSig, WSig, ErrStat, ErrMsg) IF ( p%WrFile(FileExt_WND) ) THEN - + UBFW = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UBFFW, TRIM(p%RootName)//'.wnd', ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) RETURN @@ -2174,7 +2175,7 @@ SUBROUTINE WrBinBLADED(p, V, USig, VSig, WSig, ErrStat, ErrMsg) !....................................................... IF ( p%WrFile(FileExt_TWR) ) THEN - + UATWR = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UATWR, TRIM( p%RootName )//'.twr', ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) RETURN @@ -2354,7 +2355,7 @@ SUBROUTINE WrBinTURBSIM(p, V, ErrStat, ErrMsg) LenDesc = LEN_TRIM( p%DescStr ) ! Length of the string that contains program name, version, date, and time CALL WrScr ( ' Generating AeroDyn binary time-series file "'//TRIM( p%RootName )//'.bts"' ) - + UAFFW = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UAFFW, TRIM(p%RootName)//'.bts', ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) RETURN @@ -2485,7 +2486,7 @@ SUBROUTINE WrBinHAWC( p, V, USig, VSig, WSig, ErrStat, ErrMsg) ic = INDEX( p%RootName, '\', BACK=.TRUE. ) ic = MAX( ic, INDEX( p%RootName, '/', BACK=.TRUE. ) ) RootWithoutPathName = p%RootName((ic+1):) - + UnWind = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( UnWind, trim(p%RootName)//'.hawc', ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) IF (ErrStat >= AbortErrLev) RETURN @@ -2540,7 +2541,7 @@ SUBROUTINE WrBinHAWC( p, V, USig, VSig, WSig, ErrStat, ErrMsg) DO IC = 1,3 CALL WrScr ( ' Generating HAWC2 binary time-series file "'//trim(p%RootName)//'-'//Comp(ic)//'.bin"' ) - + UnWind = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UnWind, trim(p%RootName)//'-'//Comp(ic)//'.bin', ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) IF (ErrStat >= AbortErrLev) EXIT ! exit this do loop to deallocate array @@ -2591,6 +2592,7 @@ SUBROUTINE WrFormattedFF(RootName, p_grid, UHub, V ) DO IVec=1,3 CALL WrScr ( ' Generating full-field formatted file "'//TRIM(RootName)//'.'//Comp(IVec)//'".' ) + UFFF = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( UFFF, TRIM( RootName )//'.'//Comp(IVec), ErrStat, ErrMsg ) IF (ErrStat /= ErrID_None) then call WrScr(Trim(ErrMsg)) @@ -2995,7 +2997,7 @@ SUBROUTINE WrHH_ADtxtfile(p, V, TurbInt, ErrStat, ErrMsg) - + UAHH = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( UAHH, TRIM( p%RootName)//'.hh', ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) RETURN @@ -3060,7 +3062,7 @@ SUBROUTINE WrHH_binary(p, V, ErrStat, ErrMsg) INTEGER :: UGTP ! I/O unit for GenPro HH turbulence properties. - + UGTP = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenUOutfile ( UGTP , TRIM( p%RootName)//'.bin', ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) RETURN @@ -3114,7 +3116,7 @@ SUBROUTINE WrHH_text(p, V, ErrStat, ErrMsg) ! p%WrFile(FileExt_DAT) - + UFTP = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( UFTP, TRIM( p%RootName)//'.dat', ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) RETURN diff --git a/modules/turbsim/src/TSsubs.f90 b/modules/turbsim/src/TSsubs.f90 index 4e9a73a2fc..810e1bb7dc 100644 --- a/modules/turbsim/src/TSsubs.f90 +++ b/modules/turbsim/src/TSsubs.f90 @@ -296,6 +296,7 @@ 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 + UC = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile( UC, TRIM(p%RootName)//'.coh', ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CalcFourierCoeffs_General') IF (ErrStat >= AbortErrLev) THEN @@ -598,6 +599,7 @@ 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 + UC = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile( UC, TRIM(p%RootName)//'.coh', ErrStat2, ErrMsg2 ) CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, 'CalcFourierCoeffs_API') IF (ErrStat >= AbortErrLev) THEN @@ -2149,6 +2151,7 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg) IF ( p%WrFile(FileExt_BIN) ) THEN ! CALL OpenBOutFile ( UnOut, TRIM( p%RootName)//'.bin', ErrStat, ErrMsg ) + UnOut = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenUOutfile ( UnOut , TRIM( p%RootName)//'.bin', ErrStat2, ErrMsg2 ) ! just making sure it can be opened (not locked elsewhere) CLOSE(UnOut) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -2159,6 +2162,7 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg) IF ( p%WrFile(FileExt_DAT) ) THEN + UnOut = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( UnOut, TRIM( p%RootName)//'.dat', ErrStat2, ErrMsg2 ) ! just making sure it can be opened (not locked elsewhere) CLOSE( UnOut ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -2169,6 +2173,7 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg) IF ( p%WrFile(FileExt_HH) ) THEN + UnOut = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenFOutFile ( UnOut, TRIM( p%RootName)//'.hh', ErrStat2, ErrMsg2 ) ! just making sure it can be opened (not locked elsewhere) CLOSE( UnOut ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -2179,6 +2184,7 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg) IF ( p%WrFile(FileExt_BTS) ) THEN + UnOut = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UnOut, TRIM(p%RootName)//'.bts', ErrStat2, ErrMsg2 ) ! just making sure it can be opened (not locked elsewhere) CLOSE( UnOut ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -2189,6 +2195,7 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg) IF ( p%WrFile(FileExt_WND) ) THEN + UnOut = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UnOut, TRIM(p%RootName)//'.wnd', ErrStat2, ErrMsg2 ) ! just making sure it can be opened (not locked elsewhere) CLOSE(UnOut) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -2199,6 +2206,7 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg) IF ( p%WrFile(FileExt_TWR) .AND. p%WrFile(FileExt_WND) ) THEN + UnOut = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UnOut, TRIM( p%RootName )//'.twr', ErrStat2, ErrMsg2 ) ! just making sure it can be opened (not locked elsewhere) CLOSE(UnOut) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) @@ -2208,6 +2216,7 @@ SUBROUTINE TS_ValidateInput(P, ErrStat, ErrMsg) ENDIF IF ( p%WrFile(FileExt_CTS) ) THEN + UnOut = -1 ! set to -1 at start to find valid unit numbers in Open* calls CALL OpenBOutFile ( UnOut, TRIM( p%RootName )//'.cts', ErrStat2, ErrMsg2 ) ! just making sure it can be opened (not locked elsewhere) CLOSE(UnOut) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName)