diff --git a/docs/source/user/inflowwind/examples/inflowwind_driver_example.inp b/docs/source/user/inflowwind/examples/inflowwind_driver_example.inp index ada6a15427..6f10820ae7 100644 --- a/docs/source/user/inflowwind/examples/inflowwind_driver_example.inp +++ b/docs/source/user/inflowwind/examples/inflowwind_driver_example.inp @@ -24,4 +24,11 @@ InflowWind driver input file. 6,0,15 GridCtrCoord -- coordinate of center of grid (m) 1,1,0 GridDx,GridDY,GridDZ -- Step size of grid (m) 1,1,0 GridNx,GridNY,GridNZ -- number of grid points in X, Y and Z directions (-) +---- Output VTK slices ------------------------------------------------------ + 0 NOutWindXY -- Number of XY planes for output .XY.t.vtk (-) [0 to 9] + 90 OutWindZ -- Z coordinates of XY planes for output (m) [1 to NOutWindXY] [unused for NOutWindXY=0] + 0 NOutWindXZ -- Number of XZ planes for output .YZ.t.vtk (-) [0 to 9] + 0 OutWindY -- Y coordinates of XZ planes for output (m) [1 to NOutWindXZ] [unused for NOutWindXZ=0] + 0 NOutWindYZ -- Number of YZ planes for output .YZ.t.vtk (-) [0 to 9] + 0 OutWindX -- X coordinates of YZ planes for output (m) [1 to NOutWindYZ] [unused for NOutWindYZ=0] END of driver input file diff --git a/modules/inflowwind/CMakeLists.txt b/modules/inflowwind/CMakeLists.txt index 8e5b3c2e34..1e9b3a3063 100644 --- a/modules/inflowwind/CMakeLists.txt +++ b/modules/inflowwind/CMakeLists.txt @@ -19,6 +19,7 @@ if (GENERATE_TYPES) generate_f90_types(src/InflowWind_IO.txt ${CMAKE_CURRENT_LIST_DIR}/src/InflowWind_IO_Types.f90 -noextrap) generate_f90_types(src/Lidar.txt ${CMAKE_CURRENT_LIST_DIR}/src/Lidar_Types.f90) generate_f90_types(src/InflowWind.txt ${CMAKE_CURRENT_LIST_DIR}/src/InflowWind_Types.f90) + generate_f90_types(src/InflowWind_Driver_Registry.txt ${CMAKE_CURRENT_LIST_DIR}/src/InflowWind_Driver_Types.f90 -noextrap) endif() # InflowWind object library diff --git a/modules/inflowwind/src/InflowWind_Driver.f90 b/modules/inflowwind/src/InflowWind_Driver.f90 index 2ca88e84f1..42b29d1d11 100644 --- a/modules/inflowwind/src/InflowWind_Driver.f90 +++ b/modules/inflowwind/src/InflowWind_Driver.f90 @@ -39,6 +39,9 @@ PROGRAM InflowWind_Driver TYPE( ProgDesc ), PARAMETER :: ProgInfo = ProgDesc("InflowWind_Driver","","") INTEGER(IntKi) :: IfWDriver_Verbose = 5 ! Verbose level. 0 = none, 5 = some, 10 = lots + ! output paths hard coded + CHARACTER(*), PARAMETER :: VTKsliceDir = "vtk" ! Directory to place the output VTK slices + ! Types needed here (from InflowWind module) TYPE(InflowWind_InitInputType) :: InflowWind_InitInp ! Data for initialization -- this is where the input info goes TYPE(InflowWind_InputType) :: InflowWind_u1 ! input -- contains xyz coords of interest -- set 1 @@ -116,8 +119,23 @@ PROGRAM InflowWind_Driver CALL CPU_TIME( Timer(1) ) ! Set some CLSettings to null/default values - CLSettings%ProgInfo = ProgInfo - Settings%ProgInfo = ProgInfo + CLSettings%ProgInfo = ProgInfo + Settings%ProgInfo = ProgInfo + ! Set the filenames to empty strings -- otherwise prints garbage with the -vv option + CLSettings%DvrIptFileName = '' + CLSettings%IfWIptFileName = '' + CLSettings%SummaryFileName = '' + CLSettings%PointsFileName = '' + CLSettings%WindGridOutput%Name = '' + CLSettings%FFTOutput%Name = '' + CLSettings%PointsVelOutput%Name = '' + Settings%DvrIptFileName = '' + Settings%IfWIptFileName = '' + Settings%SummaryFileName = '' + Settings%PointsFileName = '' + Settings%WindGridOutput%Name = '' + Settings%FFTOutput%Name = '' + Settings%PointsVelOutput%Name = '' !-------------------------------------------------------------------------------------------------------------------------------- !-=-=- Parse the command line inputs -=-=- @@ -419,92 +437,61 @@ PROGRAM InflowWind_Driver InflowWind_p%FlowField%Grid3D%BoxExceedAllowDrv = .true. end if - ! Make sure no errors occured that give us reason to terminate now. - IF ( ErrStat >= AbortErrLev ) THEN - CALL DriverCleanup() - CALL ProgAbort( ErrMsg ) - ELSEIF ( ErrStat /= ErrID_None ) THEN - IF ( IfWDriver_Verbose >= 7_IntKi ) THEN - CALL WrScr(NewLine//' InflowWind_Init returned: ErrStat: '//TRIM(Num2LStr(ErrStat))// & - NewLine//' ErrMsg: '//TRIM(ErrMsg)//NewLine) - ELSEIF ( ErrStat >= ErrID_Warn ) THEN - CALL ProgWarn( ErrMsg ) - ELSE - CALL WrScr(TRIM(ErrMsg)) - ENDIF - ENDIF - + call CheckCallErr('InflowWind_Init') - ! Let user know we returned from the InflowWind code if verbose - IF ( IfWDriver_Verbose >= 5_IntKi ) CALL WrScr(NewLine//'InflowWind_Init CALL returned without errors.'//NewLine) - ! Convert InflowWind file to HAWC format IF (SettingsFlags%WrHAWC) THEN CALL IfW_WriteHAWC( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg ) - IF (ErrStat > ErrID_None) THEN - CALL WrScr( TRIM(ErrMsg) ) - IF ( ErrStat >= AbortErrLev ) THEN - CALL DriverCleanup() - CALL ProgAbort( ErrMsg ) - ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN - CALL WrScr(NewLine//' IfW_WriteHAWC returned: ErrStat: '//TRIM(Num2LStr(ErrStat))) - END IF - ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN - CALL WrScr(NewLine//'IfW_WriteHAWC CALL returned without errors.'//NewLine) - END IF + call CheckCallErr('IfW_WriteHAWC') END IF ! Convert InflowWind file to Native Bladed format IF (SettingsFlags%WrBladed) THEN CALL IfW_WriteBladed( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg ) - IF (ErrStat > ErrID_None) THEN - CALL WrScr( TRIM(ErrMsg) ) - IF ( ErrStat >= AbortErrLev ) THEN - CALL DriverCleanup() - CALL ProgAbort( ErrMsg ) - ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN - CALL WrScr(NewLine//' InflowWind_Convert2Bladed returned: ErrStat: '//TRIM(Num2LStr(ErrStat))) - END IF - ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN - CALL WrScr(NewLine//'InflowWind_Convert2Bladed CALL returned without errors.'//NewLine) - END IF + call CheckCallErr('IfW_WriteBladed') END IF + IF (SettingsFlags%WrVTK) THEN CALL IfW_WriteVTK( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg ) - IF (ErrStat > ErrID_None) THEN - CALL WrScr( TRIM(ErrMsg) ) - IF ( ErrStat >= AbortErrLev ) THEN - CALL DriverCleanup() - CALL ProgAbort( ErrMsg ) - ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN - CALL WrScr(NewLine//' IfW_WriteVTK returned: ErrStat: '//TRIM(Num2LStr(ErrStat))) - END IF - ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN - CALL WrScr(NewLine//'IfW_WriteVTK CALL returned without errors.'//NewLine) - END IF - + call CheckCallErr('IfW_WriteVTK') END IF IF (SettingsFlags%WrUniform) THEN CALL IfW_WriteUniform( InflowWind_p%FlowField, InflowWind_InitInp%RootName, ErrStat, ErrMsg ) - IF (ErrStat > ErrID_None) THEN - CALL WrScr( TRIM(ErrMsg) ) - IF ( ErrStat >= AbortErrLev ) THEN - CALL DriverCleanup() - CALL ProgAbort( ErrMsg ) - ELSEIF ( IfWDriver_Verbose >= 7_IntKi ) THEN - CALL WrScr(NewLine//' IfW_WriteUniform returned: ErrStat: '//TRIM(Num2LStr(ErrStat))) - END IF - ELSE IF ( IfWDriver_Verbose >= 5_IntKi ) THEN - CALL WrScr(NewLine//'IfW_WriteUniform CALL returned without errors.'//NewLine) - END IF + call CheckCallErr('IfW_WriteUniform') END IF + + IF (Settings%NOutWindXY>0) THEN + do i=1,Settings%NOutWindXY + CALL IfW_WriteXYslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, VTKsliceDir, Settings%OutWindZ(i), ErrStat, ErrMsg ) + call CheckCallErr('IfW_WriteXYslice'//trim(Num2LStr(i))) + enddo + END IF + + +!FIXME: future developent +! IF (Settings%NOutWindXZ>0) THEN +! do i=1,Settings%NOutWindXZ +! CALL IfW_WriteXZslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, VTKsliceDir, Settings%OutWindY(i), ErrStat, ErrMsg ) +! call CheckCallErr('IfW_WriteXZslice'//trim(Num2LStr(i))) +! enddo +! END IF + + +! IF (Settings%NOutWindYZ>0) THEN +! do i=1,Settings%NOutWindYZ +! CALL IfW_WriteYZslice( InflowWind_p%FlowField, InflowWind_InitInp%RootName, VTKsliceDir, Settings%OutWindX(i), ErrStat, ErrMsg ) +! call CheckCallErr('IfW_WriteYZslice'//trim(Num2LStr(i))) +! enddo +! END IF + + !-------------------------------------------------------------------------------------------------------------------------------- !-=-=- Other Setup -=-=- !-------------------------------------------------------------------------------------------------------------------------------- @@ -942,6 +929,22 @@ SUBROUTINE DriverCleanup() END SUBROUTINE DriverCleanup + subroutine CheckCallErr(RoutineName) + character(*), intent(in) :: RoutineName + if (ErrStat > ErrID_None) then + call WrScr( trim(ErrMsg) ) + if ( ErrStat >= AbortErrLev ) then + call DriverCleanup() + call ProgAbort( ErrMsg ) + elseif ( IfWDriver_Verbose >= 7_IntKi ) then + call WrScr(NewLine//' '//trim(RoutineName)//' returned: ErrStat: '//TRIM(Num2LStr(ErrStat))) + endif + elseif ( IfWDriver_Verbose >= 5_IntKi ) then + CALL WrScr(NewLine//trim(RoutineName)//' CALL returned without errors.'//NewLine) + endif + end subroutine CheckCallErr + + END PROGRAM InflowWind_Driver diff --git a/modules/inflowwind/src/InflowWind_Driver_Registry.txt b/modules/inflowwind/src/InflowWind_Driver_Registry.txt new file mode 100644 index 0000000000..3863019d77 --- /dev/null +++ b/modules/inflowwind/src/InflowWind_Driver_Registry.txt @@ -0,0 +1,91 @@ +#---------------------------------------------------------------------------------------------------------------------------------- +# Registry for IfW_Interp, creates MODULE IfW_Interp_Types +# Module IfW_Interp_Types contains all of the user-defined types needed in IfW_FF. It also contains copy, destroy, pack, and +# unpack routines associated with each defined data types. +#---------------------------------------------------------------------------------------------------------------------------------- +# keyword +#---------------------------------------------------------------------------------------------------------------------------------- + +include Registry_NWTC_Library.txt + +#---------------------------------------------------------------------------------------------------------------------------------- +typedef InflowWind_Driver OutputFile character(1024) Name - "" - "Filename for output from points read in from points file" - +typedef ^ ^ integer Unit - -1 - "Unit number for the output file for the Points file output" - +typedef ^ ^ logical Initialized - .false. - "Flag indicating that file has been initialized" - + +# This contains flags to note if the settings were made. This same data structure is +# used both during the driver input file and the command line options. +# +# NOTE: The WindFileType is only set if it is given as a command line option. Otherwise +# it is handled internally by InflowWInd. +# +# NOTE: The wind direction is specified by the InflowWind input file. +#---------------------------------------------------------------------------------------------------------------------------------- +typedef InflowWind_Driver IfWDriver_Flags logical DvrIptFile - .false. - "Was an input file name given on the command line?" - +typedef ^ ^ logical IfWIptFile - .false. - "Was an InflowWind input file requested?" - +typedef ^ ^ logical Summary - .false. - "create a summary at command line? (data extents in the wind file)" - +typedef ^ ^ logical SummaryFile - .false. - "create a summary file of the output?" - +typedef ^ ^ logical TStart - .false. - "specified a start time" - +typedef ^ ^ logical NumTimeSteps - .false. - "specified a number of timesteps to process" - +typedef ^ ^ logical NumTimeStepsDefault - .false. - "specified a 'DEFAULT' for number of timesteps to process" - +typedef ^ ^ logical DT - .false. - "specified a resolution in time" - +typedef ^ ^ logical DTDefault - .false. - "specified a 'DEFAULT' for the time resolution" - + +typedef ^ ^ logical FFTcalc - .false. - "do an FFT" - + +typedef ^ ^ logical WindGrid - .false. - "Requested output of wind data on a grid -- input file option only" - +typedef ^ ^ logical XRange - .false. - "specified a range of x -- command line option only -- stored as GridCtrCoord and GridDelta" - +typedef ^ ^ logical YRange - .false. - "specified a range of y -- command line option only -- stored as GridCtrCoord and GridDelta" - +typedef ^ ^ logical ZRange - .false. - "specified a range of z -- command line option only -- stored as GridCtrCoord and GridDelta" - +typedef ^ ^ logical Dx - .false. - "specified a resolution in x -- command line option only, 0.0 otherwise" - +typedef ^ ^ logical Dy - .false. - "speficied a resolution in y" - +typedef ^ ^ logical Dz - .false. - "specified a resolution in z" - + +typedef ^ ^ logical PointsFile - .false. - "points filename to read in" - +typedef ^ ^ logical OutputAccel - .false. - "flag to calculate and output wind acceleration in addition to velocity" - + +typedef ^ ^ logical Verbose - .false. - "Verbose error reporting" - +typedef ^ ^ logical VVerbose - .false. - "Very Verbose error reporting" - +typedef ^ ^ logical BoxExceedAllowF - .false. - "set flag to allow exceeding wind box boundaries for FF files (for diagnostic purposes)" - + +typedef ^ ^ logical WrHAWC - .false. - "Requested file conversion to HAWC2 format?" - +typedef ^ ^ logical WrBladed - .false. - "Requested file conversion to Bladed format?" - +typedef ^ ^ logical WrVTK - .false. - "Requested file output as VTK?" - +typedef ^ ^ logical WrUniform - .false. - "Requested file output as Uniform wind format?" - + +typedef ^ ^ logical XYslice - .false. - "Take XY slice at one elevation" - + + + +# This contains all the settings (possible passed in arguments). +#---------------------------------------------------------------------------------------------------------------------------------- +typedef InflowWind_Driver IfWDriver_Settings character(1024) DvrIptFileName - "" - "Driver input file name" - +typedef ^ ^ character(1024) IfWIptFileName - "" - "Filename of InflowWind input file to read (if no driver input file)" - +typedef ^ ^ character(1024) SummaryFileName - "" - "Filename for the summary information output" - + +typedef ^ ^ character(1024) PointsFileName - "" - "Filename of points file to read in" - + +typedef ^ ^ IntKi NumTimeSteps - 0 - "Number of timesteps" - +typedef ^ ^ DbKi DT - 0.0_DbKi - "resolution of time" s +typedef ^ ^ DbKi TStart - 0.0_DbKi - "range of time -- end time converted from TRange (command line option only)" s + +typedef ^ ^ ReKi FFTcoord(1:3) - 0.0_ReKi - "(x,y,z) coordinate to do an FFT at" (m) + +typedef ^ ^ ReKi GridDelta(1:3) - 0.0_ReKi - "(GridDx,GridDy,GridDz) -- grid point spacing" (m) +typedef ^ ^ IntKi GridN(1:3) - 1_IntKi - "(GridNx,GridNy,GridNz) -- number of grid points" - + +typedef ^ ^ ReKi XRange(1:2) - 0.0_ReKi - "Range in the x-direction for the gridded data" (m) +typedef ^ ^ ReKi YRange(1:2) - 0.0_ReKi - "Range in the y-direction for the gridded data" (m) +typedef ^ ^ ReKi ZRange(1:2) - 0.0_ReKi - "Range in the z-direction for the gridded data" (m) + +typedef ^ ^ ProgDesc ProgInfo - - - "Program info" - +typedef ^ ^ OutputFile WindGridOutput - - - "Wind grid file handling" - +typedef ^ ^ OutputFile FFTOutput - - - "FFT file handling" - +typedef ^ ^ OutputFile PointsVelOutput - - - "Points output velocity file handling" - + +typedef ^ ^ IntKi NOutWindXY - 0 - "Number of XY planes for output .XY.t.vtk [0 to 9]" - +typedef ^ ^ ReKi OutWindZ : - - "Z coordinates of XY planes for output [1 to NOutWindXY] [unused for NOutWindXY=0]" (m) +typedef ^ ^ IntKi NOutWindXZ - 0 - "Number of YZ planes for output .YZ.t.vtk [0 to 9]" - +typedef ^ ^ ReKi OutWindY : - - "Y coordinates of YZ planes for output [1 to NOutWindYZ] [unused for NOutWindYZ=0]" (m) +typedef ^ ^ IntKi NOutWindYZ - 0 - "Number of YZ planes for output .YZ.t.vtk [0 to 9]" - +typedef ^ ^ ReKi OutWindX : - - "X coordinates of YZ planes for output [1 to NOutWindYZ] [unused for NOutWindYZ=0]" (m) diff --git a/modules/inflowwind/src/InflowWind_Driver_Subs.f90 b/modules/inflowwind/src/InflowWind_Driver_Subs.f90 index 186b3435df..98d7fdf293 100644 --- a/modules/inflowwind/src/InflowWind_Driver_Subs.f90 +++ b/modules/inflowwind/src/InflowWind_Driver_Subs.f90 @@ -734,18 +734,12 @@ 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 - FileName = TRIM(DvrFileName) + ErrStat = ErrID_None + ErrMsg = "" CALL GetNewUnit( UnIn ) - CALL OpenFInpFile( UnIn, FileName, ErrStatTmp, ErrMsgTmp ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,' Failed to open InflowWind Driver input file: '//FileName, & - ErrStat,ErrMsg,RoutineName) - CLOSE( UnIn ) - RETURN - ENDIF - + CALL OpenFInpFile( UnIn, FileName, ErrStatTmp, ErrMsgTmp ); if (Failed()) return CALL WrScr( 'Opening InflowWind Driver input file: '//FileName ) @@ -754,30 +748,9 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat !------------------------------------------------------------------------------------------------- ! File header !------------------------------------------------------------------------------------------------- - - CALL ReadCom( UnIn, FileName,' InflowWind Driver input file header line 1', ErrStatTmp, ErrMsgTmp ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CLOSE( UnIn ) - RETURN - ENDIF - - - CALL ReadCom( UnIn, FileName, 'InflowWind Driver input file header line 2', ErrStatTmp, ErrMsgTmp ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CLOSE( UnIn ) - RETURN - ENDIF - - - ! Echo Input Files. - CALL ReadVar ( UnIn, FileName, EchoFileContents, 'Echo', 'Echo Input', ErrStatTmp, ErrMsgTmp ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadCom( UnIn, FileName,' InflowWind Driver input file header line 1', ErrStatTmp, ErrMsgTmp ); if (Failed()) return + CALL ReadCom( UnIn, FileName, 'InflowWind Driver input file header line 2', ErrStatTmp, ErrMsgTmp ); if (Failed()) return + CALL ReadVar ( UnIn, FileName, EchoFileContents, 'Echo', 'Echo Input', ErrStatTmp, ErrMsgTmp ); if (Failed()) return ! If we are Echoing the input then we should re-read the first three lines so that we can echo them @@ -788,44 +761,15 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat EchoFileName = TRIM(FileName)//'.ech' CALL GetNewUnit( UnEchoLocal ) - CALL OpenEcho ( UnEchoLocal, EchoFileName, ErrStatTmp, ErrMsgTmp, ProgInfo ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CLOSE( UnIn ) - RETURN - ENDIF - + CALL OpenEcho ( UnEchoLocal, EchoFileName, ErrStatTmp, ErrMsgTmp, ProgInfo ); if (Failed()) return REWIND(UnIn) ! Reread and echo - CALL ReadCom( UnIn, FileName,' InflowWind Driver input file header line 1', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal, ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - - - CALL ReadCom( UnIn, FileName, 'InflowWind Driver input file header line 2', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - - - ! Echo Input Files. - CALL ReadVar ( UnIn, FileName, EchoFileContents, 'Echo', 'Echo Input', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadCom( UnIn, FileName,' InflowWind Driver input file header line 1', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadCom( UnIn, FileName, 'InflowWind Driver input file header line 2', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar ( UnIn, FileName, EchoFileContents, 'Echo', 'Echo Input', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return @@ -835,78 +779,30 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat !------------------------------------------------------------------------------------------------- ! Driver setup section !------------------------------------------------------------------------------------------------- - - ! Header - CALL ReadCom( UnIn, FileName,' Driver setup section, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - + CALL ReadCom( UnIn, FileName,' Driver setup section, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! Name of InflowWind input file - CALL ReadVar( UnIn, FileName,DvrSettings%IfWIptFileName,'IfWIptFileName',' InflowWind input filename', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ELSE - DvrFlags%IfWIptFile = .TRUE. - ENDIF - + CALL ReadVar( UnIn, FileName,DvrSettings%IfWIptFileName,'IfWIptFileName',' InflowWind input filename', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + DvrFlags%IfWIptFile = .TRUE. IF ( PathIsRelative( DvrSettings%IfWIptFileName ) ) DvrSettings%IfWIptFileName = TRIM(PriPath)//TRIM(DvrSettings%IfWIptFileName) !------------------------------------------------------------------------------------------------- ! File Conversion Options section !------------------------------------------------------------------------------------------------- - - ! Header - CALL ReadCom( UnIn, FileName,'File Conversion Options Section Header', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - CALL SetErrStat(ErrStatTmp, ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - - ! WrHAWC - CALL ReadVar( UnIn, FileName, DvrFlags%WrHAWC, 'WrHAWC', 'Convert wind data to HAWC2 format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - CALL SetErrStat(ErrStatTmp, ErrMsgTmp,ErrStat,ErrMsg,RoutineName) + CALL ReadCom( UnIn, FileName,'File Conversion Options Section Header', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName, DvrFlags%WrHAWC, 'WrHAWC', 'Convert wind data to HAWC2 format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName, DvrFlags%WrBladed, 'WrBladed', 'Convert wind data to Bladed format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName, DvrFlags%WrVTK, 'WrVTK', 'Convert wind data to VTK format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName, DvrFlags%WrUniform, 'WrUniform','Convert wind data to Uniform Wind format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return - ! WrBladed - CALL ReadVar( UnIn, FileName, DvrFlags%WrBladed, 'WrBladed', 'Convert wind data to Bladed format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - CALL SetErrStat(ErrStatTmp, ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - - ! WrVTK - CALL ReadVar( UnIn, FileName, DvrFlags%WrVTK, 'WrVTK', 'Convert wind data to VTK format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - CALL SetErrStat(ErrStatTmp, ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - - ! WrUniform - CALL ReadVar( UnIn, FileName, DvrFlags%WrUniform, 'WrUniform', 'Convert wind data to Uniform Wind format?', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - CALL SetErrStat(ErrStatTmp, ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - - IF ( ErrStat >= AbortErrLev ) THEN - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - !------------------------------------------------------------------------------------------------- ! Tests of Interpolation Options section !------------------------------------------------------------------------------------------------- - CALL ReadCom( UnIn, FileName,'Tests of Interpolation Options Section Header', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - CALL SetErrStat(ErrStatTmp, ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - + CALL ReadCom( UnIn, FileName,'Tests of Interpolation Options Section Header', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! Number of timesteps - CALL ReadVar( UnIn, FileName,NumTimeStepsChr,'NumTimeStepsChr',' Character string for number of timesteps to read.', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadVar( UnIn, FileName,NumTimeStepsChr,'NumTimeStepsChr',' Number of timesteps to read.', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! Check if we asked for the DEFAULT (use what is in the file) CALL Conv2UC( NumTimeStepsChr ) @@ -918,8 +814,7 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat ! make sure that it was appropriately interpretted. READ (NumTimeStepsChr,*,IOSTAT=IOS) DvrSettings%NumTimeSteps IF ( IOS /= 0 ) THEN ! problem in the read, so parse the error. - CALL CheckIOS ( IOS, '', 'NumTimeSteps',NumType, ErrStatTmp, ErrMsgTmp ) - RETURN + CALL CheckIOS ( IOS, '', 'NumTimeSteps',NumType, ErrStatTmp, ErrMsgTmp ); if (Failed()) return ELSE ! Was ok, so set the flags DvrFlags%NumTimeSteps = .TRUE. DvrFlags%NumTimeStepsDefault = .FALSE. @@ -928,27 +823,11 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat ! TStart -- start time - CALL ReadVar( UnIn, FileName,DvrSettings%TStart,'TStart',' Time in wind file to start parsing.', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ELSE - DvrFlags%TStart = .TRUE. - ENDIF - + CALL ReadVar( UnIn, FileName,DvrSettings%TStart,'TStart',' Time in wind file to start parsing.', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + DvrFlags%TStart = .TRUE. ! DT -- Timestep size for the driver to take (or DEFAULT for what the file contains) - CALL ReadVar( UnIn, FileName,DTChr,'DTChr',' Character string for Timestep size for the driver to take (or DEFAULT for what the file contains).', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadVar( UnIn, FileName,DTChr,'DTChr',' Character string for Timestep', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! Check if we asked for the DEFAULT (use what is in the file) CALL Conv2UC( DTChr ) @@ -960,8 +839,7 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat ! make sure that it was appropriately interpretted. READ (DTChr,*,IOSTAT=IOS) DvrSettings%DT IF ( IOS /= 0 ) THEN ! problem in the read, so parse the error. - CALL CheckIOS ( IOS, '', 'DT',NumType, ErrStatTmp, ErrMsgTmp ) - RETURN + CALL CheckIOS ( IOS, '', 'DT',NumType, ErrStatTmp, ErrMsgTmp ); if (Failed()) return ELSE ! Was ok, so set the flags DvrFlags%DT = .TRUE. DvrFlags%DTDefault = .FALSE. @@ -969,213 +847,75 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat ENDIF - ! Summarize the extents in the windfile - CALL ReadVar( UnIn, FileName,DvrFlags%Summary,'Summary',' Summarize data extents in the windfile', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN -! ELSE -! DvrFlags%Summary = .TRUE. - ENDIF - - - ! Summarize everything in a summary file/ - CALL ReadVar( UnIn, FileName,DvrFlags%SummaryFile,'SummaryFile',' Summarize the results in a .sum file', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN -! ELSE -! DvrFlags%SummaryFile = .TRUE. - ENDIF + ! Summary info + CALL ReadVar( UnIn, FileName,DvrFlags%Summary, 'Summary', ' Summarize data extents in the windfile', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName,DvrFlags%SummaryFile,'SummaryFile',' Summarize the results in a .sum file', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! Flag to allow sampling outside grid - CALL ReadVar( UnIn, FileName,DvrFlags%BoxExceedAllowF,'BoxExceedAllow',' Allow point sampling outside grid', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadVar( UnIn, FileName,DvrFlags%BoxExceedAllowF,'BoxExceedAllow',' Allow point sampling outside grid', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + #ifdef UNUSED_INPUTFILE_LINES !------------------------------------------------------------------------------------------------- ! FFT calculations !------------------------------------------------------------------------------------------------- - - ! Header - CALL ReadCom( UnIn, FileName,' FFT calculations, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - - - ! FFTcalc -- FFTcalc of the windfield needed. - CALL ReadVar( UnIn, FileName,DvrFlags%FFTcalc,'FFTcalc',' Perform an FFT?', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - + CALL ReadCom( UnIn, FileName,' FFT calculations, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName,DvrFlags%FFTcalc,'FFTcalc',' Perform an FFT?', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! Read the coordinate for the FFT if the flag is set, otherwise skip the line IF ( DvrFlags%FFTcalc ) THEN ! FFTcoord -- The coordinates to perform the FFT at - CALL ReadAry ( UnIn, FileName, DvrSettings%FFTcoord, 3, 'FFTcoord', & - 'FFT coordinate', ErrStatTmp, ErrMsgTmp, UnEchoLocal) - IF ( ErrStat /= ErrID_None ) THEN - CALL SetErrStat( ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadAry ( UnIn, FileName, DvrSettings%FFTcoord, 3, 'FFTcoord', 'FFT coordinate', ErrStatTmp, ErrMsgTmp, UnEchoLocal); if (Failed()) return ELSE - CALL ReadCom( UnIn, FileName,' Skipping the FFT coordinate since not doint an FFT.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadCom( UnIn, FileName,' Skipping the FFT coordinate since not doint an FFT.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return ENDIF - #endif + !------------------------------------------------------------------------------------------------- ! points file input !------------------------------------------------------------------------------------------------- - - ! Header line - CALL ReadCom( UnIn, FileName,' Points file input, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - - - ! PointsFile -- Read a points file - CALL ReadVar( UnIn, FileName,DvrFlags%PointsFile,'PointsFile',' Read a points file?', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - - - ! Points input file (unused if .not. DvrFlags%PointsFile) - CALL ReadVar( UnIn, FileName,DvrSettings%PointsFileName,'PointsFileName',' Points file input filename', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - + CALL ReadCom( UnIn, FileName,' Points file input, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName,DvrFlags%PointsFile, 'PointsFile', ' Read a points file?', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadVar( UnIn, FileName,DvrSettings%PointsFileName,'PointsFileName',' Points file input filename', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return IF ( PathIsRelative( DvrSettings%PointsFileName ) ) DvrSettings%PointsFileName = TRIM(PriPath)//TRIM(DvrSettings%PointsFileName) ! CalcAccel - calculate wind acceleration (unused if .not. DvrFlags%PointsFile) - CALL ReadVar( UnIn, FileName,DvrFlags%OutputAccel, 'CalcAccel', ' Calc and output wind acceleration', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadVar( UnIn, FileName,DvrFlags%OutputAccel, 'CalcAccel', ' Calc and output wind acceleration', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + !------------------------------------------------------------------------------------------------- ! gridded data output !------------------------------------------------------------------------------------------------- - - ! Header - CALL ReadCom( UnIn, FileName,' Gridded data output, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - + CALL ReadCom( UnIn, FileName,' Gridded data output, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! WindGrid -- Gridded data output - CALL ReadVar( UnIn, FileName,DvrFlags%WindGrid,'WindGrid',' Output a grid of data?', & - ErrStatTmp,ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadVar( UnIn, FileName,DvrFlags%WindGrid,'WindGrid',' Output a grid of data?', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return - ! Read the coordinate for the FFT if the flag is set, otherwise skip the line + ! Read the coordinate for the WindGrid if the flag is set, otherwise skip the line IF ( DvrFlags%WindGrid ) THEN ! GridCtrCoord -- The coordinates to center the gridded data at - CALL ReadAry ( UnIn, FileName, GridCtrCoord, 3, 'GridCtrCoord', & - 'Coordinate of the center of the gridded data', ErrStatTmp, ErrMsgTmp, UnEchoLocal) - IF ( ErrStat /= ErrID_None ) THEN - CALL SetErrStat( ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadAry ( UnIn, FileName, GridCtrCoord, 3, 'GridCtrCoord', 'Coordinate of the center of the gridded data', ErrStatTmp, ErrMsgTmp, UnEchoLocal); if (Failed()) return ! Read the DY and DZ stepsize - CALL ReadAry ( UnIn, FileName, TmpRealAr3, 3, 'GridDX, GridDY, GridDZ', & - 'GridDX, GridDY, GridDZ', ErrStatTmp, ErrMsgTmp, UnEchoLocal) - IF ( ErrStat /= ErrID_None ) THEN - CALL SetErrStat( ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadAry ( UnIn, FileName, TmpRealAr3, 3, 'GridDX, GridDY, GridDZ', 'GridDX, GridDY, GridDZ', ErrStatTmp, ErrMsgTmp, UnEchoLocal); if (Failed()) return ! Save the DY and DZ values - DvrSettings%GridDelta(1) = abs(TmpRealAr3(1)) ! X direction - DvrSettings%GridDelta(2) = abs(TmpRealAr3(2)) ! Y direction - DvrSettings%GridDelta(3) = abs(TmpRealAr3(3)) ! Z direction + DvrSettings%GridDelta(1:3) = abs(TmpRealAr3(1:3)) DvrFlags%Dx = .TRUE. ! read in value for the X direction gridding DvrFlags%Dy = .TRUE. ! read in value for the Y direction gridding DvrFlags%Dz = .TRUE. ! read in value for the Z direction gridding ! Read the number of points in the Y and Z directions - CALL ReadAry ( UnIn, FileName, TmpIntAr3, 3, 'GridNx, GridNY, GridNZ', & - 'GridNx, GridNY, GridNZ', ErrStatTmp, ErrMsgTmp, UnEchoLocal) - IF ( ErrStat /= ErrID_None ) THEN - CALL SetErrStat( ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadAry ( UnIn, FileName, DvrSettings%GridN, 3, 'GridNx, GridNY, GridNZ', 'GridNx, GridNY, GridNZ', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return ! Save the GridNY and GridNZ values - DvrSettings%GridN(1) = TmpIntAr3(1) ! X direction - DvrSettings%GridN(2) = TmpIntAr3(2) ! Y direction - DvrSettings%GridN(3) = TmpIntAr3(3) ! Z direction - DvrFlags%XRange = .TRUE. ! read in value for the X direction gridding - DvrFlags%YRange = .TRUE. ! read in value for the Y direction gridding - DvrFlags%ZRange = .TRUE. ! read in value for the Z direction gridding - + DvrFlags%XRange = .TRUE. ! read in value for the X direction gridding + DvrFlags%YRange = .TRUE. ! read in value for the Y direction gridding + DvrFlags%ZRange = .TRUE. ! read in value for the Z direction gridding ! Check that valid values of Dx, Dy, and Dz were read in. @@ -1269,10 +1009,8 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat DvrFlags%ZRange = .TRUE. ENDIF - ELSE ! read these lines as comments (actually, we don't need to read them) - DvrSettings%GridDelta = 0.0_ReKi DvrFlags%Dx = .FALSE. DvrFlags%Dy = .FALSE. @@ -1284,34 +1022,48 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat DvrFlags%ZRange = .FALSE. ! Skip the next three entries of the gridded data section. - CALL ReadCom( UnIn, FileName,' Skipping the gridded data section since not calculating it.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - CALL ReadCom( UnIn, FileName,' Skipping the gridded data section since not calculating it.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF - CALL ReadCom( UnIn, FileName,' Skipping the gridded data section since not calculating it.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ) - IF ( ErrStatTmp /= ErrID_None ) THEN - CALL SetErrStat(ErrID_Fatal,ErrMsgTmp,ErrStat,ErrMsg,RoutineName) - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) - RETURN - ENDIF + CALL ReadCom( UnIn, FileName,' Skipping the gridded data section since not calculating it.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadCom( UnIn, FileName,' Skipping the gridded data section since not calculating it.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + CALL ReadCom( UnIn, FileName,' Skipping the gridded data section since not calculating it.', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return ENDIF + !------------------------------------------------------------------------------------------------- + ! VTK output slices + !------------------------------------------------------------------------------------------------- + CALL ReadCom( UnIn, FileName,' VTK output slices, comment line', ErrStatTmp, ErrMsgTmp, UnEchoLocal ); if (Failed()) return + + ! NOutWindXY -- Number of XY planes for output .XY.t.vtk (-) [0 to 9] + CALL ReadVar( UnIn, FileName,DvrSettings%NOutWindXY, 'NOutWindXY','Number of VTK slices in XY?', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + if (DvrSettings%NOutWindXY > 0_IntKi) then + CALL AllocAry( DvrSettings%OutWindZ, DvrSettings%NOutWindXY, "Z coordinates of XY planes for output", ErrStatTmp,ErrMsgTmp ); if (Failed()) return + CALL ReadAry( UnIn, FileName,DvrSettings%OutWindZ,DvrSettings%NOutWindXY,'OutWindZ','Z coordinates', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return + else + CALL ReadCom( UnIn, FileName,' Skipping OutWindZ', ErrStatTmp,ErrMsgTmp,UnEchoLocal); if (Failed()) return + endif + +!FIXME: future development +! ! NOutWindXZ -- Number of XZ planes for output .XZ.t.vtk (-) [0 to 9] +! CALL ReadVar( UnIn, FileName,DvrSettings%NOutWindXZ, 'NOutWindXZ','Number of VTK slices in XZ?', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return +! if (DvrSettings%NOutWindXZ > 0_IntKi) then +! CALL AllocAry( DvrSettings%OutWindY, DvrSettings%NOutWindXZ, "Y coordinates of XZ planes for output",ErrStatTmp,ErrMsgTmp ); if (Failed()) return +! CALL ReadAry( UnIn, FileName,DvrSettings%OutWindY,DvrSettings%NOutWindXZ,'OutWindY','Y coordinates' ,ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return +! else +! CALL ReadCom( UnIn, FileName,' Skipping OutWindY', ErrStatTmp,ErrMsgTmp,UnEchoLocal); if (Failed()) return +! endif +! +! ! NOutWindYZ -- Number of YZ planes for output .YZ.t.vtk (-) [0 to 9] +! CALL ReadVar( UnIn, FileName,DvrSettings%NOutWindYZ, 'NOutWindYZ','Number of VTK slices in YZ?', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return +! if (DvrSettings%NOutWindYZ > 0_IntKi) then +! CALL AllocAry( DvrSettings%OutWindX, DvrSettings%NOutWindYZ, "X coordinates of YZ planes for output", ErrStatTmp,ErrMsgTmp ); if (Failed()) return +! CALL ReadAry( UnIn, FileName,DvrSettings%OutWindX,DvrSettings%NOutWindYZ,'OutWindX','X coordinates', ErrStatTmp,ErrMsgTmp, UnEchoLocal ); if (Failed()) return +! else +! CALL ReadCom( UnIn, FileName,' Skipping OutWindX', ErrStatTmp,ErrMsgTmp,UnEchoLocal); if (Failed()) return +! endif + ! Close the echo and input file - CALL CleanupEchoFile( EchoFileContents, UnEchoLocal ) - CLOSE( UnIn ) + CALL Cleanup() CONTAINS @@ -1319,17 +1071,19 @@ SUBROUTINE ReadDvrIptFile( DvrFileName, DvrFlags, DvrSettings, ProgInfo, ErrStat !---------------------------------------------------------------------------------------------------- !> The routine cleans up the module echo file and resets the NWTC_Library, reattaching it to !! any existing echo information - SUBROUTINE CleanupEchoFile( EchoFlag, UnEcho) - LOGICAL, INTENT(IN ) :: EchoFlag ! local version of echo flag - INTEGER(IntKi), INTENT(IN ) :: UnEcho ! echo unit number - - ! Close this module's echo file - IF ( EchoFlag ) THEN - CLOSE(UnEcho) + subroutine Cleanup() + ! Close this module's echo file + IF ( EchoFileContents ) THEN + CLOSE(UnEchoLocal) ENDIF - END SUBROUTINE CleanupEchoFile - - + if (UnIn > 1) close(UnIn) + end subroutine Cleanup + !------------------------------------------------------------------------------------------------- + logical function Failed() + CALL SetErrStat( ErrStatTmp, ErrMsgTmp, ErrStat, ErrMsg, RoutineName ) + Failed = ErrStat >= AbortErrLev + if (Failed) CALL Cleanup() + end function Failed END SUBROUTINE ReadDvrIptFile @@ -2623,6 +2377,50 @@ subroutine IfW_WriteVTK(FF, FileRootName, ErrStat, ErrMsg) end subroutine IfW_WriteVTK +subroutine IfW_WriteXYslice(FF, FileRootName, vtk_dir, XYslice_height, ErrStat, ErrMsg) + type(FlowFieldType), intent(in ) :: FF !< Parameters + character(*), intent(in ) :: FileRootName !< RootName for output files + character(*), intent(in ) :: vtk_dir !< Directory for vtk slice outputs + real(ReKi), intent(in ) :: XYslice_height + integer(IntKi), intent( out) :: ErrStat !< Error status of the operation + character(*), intent( out) :: ErrMsg !< Error message if ErrStat /= ErrID_None + + character(*), parameter :: RoutineName = "IfW_WriteXYslice" + type(Grid3DFieldType) :: G3D + integer(IntKi) :: unit + integer(IntKi) :: ErrStat2 + character(ErrMsgLen) :: ErrMsg2 + + ErrStat = ErrID_None + ErrMsg = "" + + ! Get new unit for writing file + call GetNewUnit(unit, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (ErrStat >= AbortErrLev) return + + ! Switch based on field type + select case (FF%FieldType) + + case (Uniform_FieldType) + call Uniform_to_Grid3D(FF%Uniform, FF%VelInterpCubic, G3D, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (ErrStat < AbortErrLev) then + call Grid3D_WriteVTKsliceXY(G3D, FileRootName, vtk_dir, XYslice_height, unit, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + end if + + case (Grid3D_FieldType) + call Grid3D_WriteVTKsliceXY(FF%Grid3D, FileRootName, vtk_dir, XYslice_height, unit, ErrStat, ErrMsg) + + case default + ErrStat = ErrID_Warn + ErrMsg = RoutineName//': Field type '//TRIM(Num2LStr(FF%FieldType))// & + ' cannot be converted to VTK format.' + end select +end subroutine IfW_WriteXYslice + + !> This routine exists only to support the development of the module. It will not be needed after the module is complete. SUBROUTINE printSettings( DvrFlags, DvrSettings ) ! The arguments @@ -2671,6 +2469,25 @@ SUBROUTINE printSettings( DvrFlags, DvrSettings ) CALL WrScr(' FFTOutputInit: '//FLAG(DvrSettings%FFTOutput%Initialized)// ' Unit #: '//TRIM(Num2LStr(DvrSettings%FFTOutput%Unit))) CALL WrScr(' PointsVelOutputInit: '//FLAG(DvrSettings%PointsVelOutput%Initialized)// ' Unit #: '//TRIM(Num2LStr(DvrSettings%PointsVelOutput%Unit))) CALL WrScr(' PointsAccOutputInit: '//FLAG(DvrSettings%PointsVelOutput%Initialized)// ' Unit #: '//TRIM(Num2LStr(DvrSettings%PointsVelOutput%Unit))) + call WrScr(' NOutWindXY: '//trim(Num2LStr(DvrSettings%NOutWindXY))) + if (DvrSettings%NOutWindXY>0) then + do i=1,DvrSettings%NOutWindXY + call WrScr(' z location '//trim(Num2LStr(i))//': '//trim(Num2LStr(DvrSettings%OutWindZ(i)))) + enddo + endif + call WrScr(' NOutWindXZ: '//trim(Num2LStr(DvrSettings%NOutWindXZ))) + if (DvrSettings%NOutWindXZ>0) then + do i=1,DvrSettings%NOutWindXZ + call WrScr(' y location '//trim(Num2LStr(i))//': '//trim(Num2LStr(DvrSettings%OutWindY(i)))) + enddo + endif + call WrScr(' NOutWindYZ: '//trim(Num2LStr(DvrSettings%NOutWindYZ))) + if (DvrSettings%NOutWindYZ>0) then + do i=1,DvrSettings%NOutWindYZ + call WrScr(' x location '//trim(Num2LStr(i))//': '//trim(Num2LStr(DvrSettings%OutWindX(i)))) + enddo + endif + END SUBROUTINE printSettings diff --git a/modules/inflowwind/src/InflowWind_Driver_Types.f90 b/modules/inflowwind/src/InflowWind_Driver_Types.f90 index 669303cf60..6768f63819 100644 --- a/modules/inflowwind/src/InflowWind_Driver_Types.f90 +++ b/modules/inflowwind/src/InflowWind_Driver_Types.f90 @@ -1,111 +1,433 @@ -!********************************************************************************************************************************** +!STARTOFREGISTRYGENERATEDFILE 'InflowWind_Driver_Types.f90' ! -! MODULE: IfW_Driver_Types - This module contains types used by the InflowWind Driver program to store arguments passed in +! WARNING This file is generated automatically by the FAST registry. +! Do not edit. Your changes to this file will be lost. ! -! The types listed here are used within the InflowWind Driver program to store the settings. These settings are read in as -! command line arguments, then stored within these types. +! FAST Registry +!********************************************************************************************************************************* +! InflowWind_Driver_Types +!................................................................................................................................. +! This file is part of InflowWind_Driver. ! -!********************************************************************************************************************************** +! Copyright (C) 2012-2016 National Renewable Energy Laboratory ! -!.................................................................................................................................. -! LICENSING -! Copyright (C) 2015 National Renewable Energy Laboratory +! Licensed under the Apache License, Version 2.0 (the "License"); +! you may not use this file except in compliance with the License. +! You may obtain a copy of the License at ! -! This file is part of InflowWind. +! http://www.apache.org/licenses/LICENSE-2.0 ! -! InflowWind is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as -! published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +! Unless required by applicable law or agreed to in writing, software +! distributed under the License is distributed on an "AS IS" BASIS, +! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +! See the License for the specific language governing permissions and +! limitations under the License. ! -! This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty -! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! -! You should have received a copy of the GNU General Public License along with InflowWind. -! If not, see . +! W A R N I N G : This file was automatically generated from the FAST registry. Changes made to this file may be lost. ! -!********************************************************************************************************************************** - +!********************************************************************************************************************************* +!> This module contains the user-defined types needed in InflowWind_Driver. It also contains copy, destroy, pack, and +!! unpack routines associated with each defined data type. This code is automatically generated by the FAST Registry. MODULE InflowWind_Driver_Types +!--------------------------------------------------------------------------------------------------------------------------------- +USE NWTC_Library +IMPLICIT NONE +! ========= OutputFile ======= + TYPE, PUBLIC :: OutputFile + 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 [-] + LOGICAL :: Initialized = .false. !< Flag indicating that file has been initialized [-] + END TYPE OutputFile +! ======================= +! ========= IfWDriver_Flags ======= + TYPE, PUBLIC :: IfWDriver_Flags + LOGICAL :: DvrIptFile = .false. !< Was an input file name given on the command line? [-] + LOGICAL :: IfWIptFile = .false. !< Was an InflowWind input file requested? [-] + LOGICAL :: Summary = .false. !< create a summary at command line? (data extents in the wind file) [-] + LOGICAL :: SummaryFile = .false. !< create a summary file of the output? [-] + LOGICAL :: TStart = .false. !< specified a start time [-] + LOGICAL :: NumTimeSteps = .false. !< specified a number of timesteps to process [-] + LOGICAL :: NumTimeStepsDefault = .false. !< specified a 'DEFAULT' for number of timesteps to process [-] + LOGICAL :: DT = .false. !< specified a resolution in time [-] + LOGICAL :: DTDefault = .false. !< specified a 'DEFAULT' for the time resolution [-] + LOGICAL :: FFTcalc = .false. !< do an FFT [-] + LOGICAL :: WindGrid = .false. !< Requested output of wind data on a grid -- input file option only [-] + LOGICAL :: XRange = .false. !< specified a range of x -- command line option only -- stored as GridCtrCoord and GridDelta [-] + LOGICAL :: YRange = .false. !< specified a range of y -- command line option only -- stored as GridCtrCoord and GridDelta [-] + LOGICAL :: ZRange = .false. !< specified a range of z -- command line option only -- stored as GridCtrCoord and GridDelta [-] + LOGICAL :: Dx = .false. !< specified a resolution in x -- command line option only, 0.0 otherwise [-] + LOGICAL :: Dy = .false. !< speficied a resolution in y [-] + LOGICAL :: Dz = .false. !< specified a resolution in z [-] + LOGICAL :: PointsFile = .false. !< points filename to read in [-] + LOGICAL :: OutputAccel = .false. !< flag to calculate and output wind acceleration in addition to velocity [-] + LOGICAL :: Verbose = .false. !< Verbose error reporting [-] + LOGICAL :: VVerbose = .false. !< Very Verbose error reporting [-] + LOGICAL :: BoxExceedAllowF = .false. !< set flag to allow exceeding wind box boundaries for FF files (for diagnostic purposes) [-] + LOGICAL :: WrHAWC = .false. !< Requested file conversion to HAWC2 format? [-] + LOGICAL :: WrBladed = .false. !< Requested file conversion to Bladed format? [-] + LOGICAL :: WrVTK = .false. !< Requested file output as VTK? [-] + LOGICAL :: WrUniform = .false. !< Requested file output as Uniform wind format? [-] + LOGICAL :: XYslice = .false. !< Take XY slice at one elevation [-] + END TYPE IfWDriver_Flags +! ======================= +! ========= IfWDriver_Settings ======= + TYPE, PUBLIC :: IfWDriver_Settings + character(1024) :: DvrIptFileName !< Driver input file name [-] + character(1024) :: IfWIptFileName !< Filename of InflowWind input file to read (if no driver input file) [-] + character(1024) :: SummaryFileName !< Filename for the summary information output [-] + character(1024) :: PointsFileName !< Filename of points file to read in [-] + INTEGER(IntKi) :: NumTimeSteps = 0 !< Number of timesteps [-] + REAL(DbKi) :: DT = 0.0_DbKi !< resolution of time [s] + REAL(DbKi) :: TStart = 0.0_DbKi !< range of time -- end time converted from TRange (command line option only) [s] + REAL(ReKi) :: FFTcoord(1:3) = 0.0_ReKi !< (x,y,z) coordinate to do an FFT at [(m)] + REAL(ReKi) :: GridDelta(1:3) = 0.0_ReKi !< (GridDx,GridDy,GridDz) -- grid point spacing [(m)] + INTEGER(IntKi) :: GridN(1:3) = 1_IntKi !< (GridNx,GridNy,GridNz) -- number of grid points [-] + REAL(ReKi) :: XRange(1:2) = 0.0_ReKi !< Range in the x-direction for the gridded data [(m)] + REAL(ReKi) :: YRange(1:2) = 0.0_ReKi !< Range in the y-direction for the gridded data [(m)] + REAL(ReKi) :: ZRange(1:2) = 0.0_ReKi !< Range in the z-direction for the gridded data [(m)] + TYPE(ProgDesc) :: ProgInfo !< Program info [-] + TYPE(OutputFile) :: WindGridOutput !< Wind grid file handling [-] + TYPE(OutputFile) :: FFTOutput !< FFT file handling [-] + TYPE(OutputFile) :: PointsVelOutput !< Points output velocity file handling [-] + INTEGER(IntKi) :: NOutWindXY = 0 !< Number of XY planes for output .XY.t.vtk [0 to 9] [-] + REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: OutWindZ !< Z coordinates of XY planes for output [1 to NOutWindXY] [unused for NOutWindXY=0] [(m)] + INTEGER(IntKi) :: NOutWindXZ = 0 !< Number of YZ planes for output .YZ.t.vtk [0 to 9] [-] + REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: OutWindY !< Y coordinates of YZ planes for output [1 to NOutWindYZ] [unused for NOutWindYZ=0] [(m)] + INTEGER(IntKi) :: NOutWindYZ = 0 !< Number of YZ planes for output .YZ.t.vtk [0 to 9] [-] + REAL(ReKi) , DIMENSION(:), ALLOCATABLE :: OutWindX !< X coordinates of YZ planes for output [1 to NOutWindYZ] [unused for NOutWindYZ=0] [(m)] + END TYPE IfWDriver_Settings +! ======================= +CONTAINS - USE NWTC_Library - USE InflowWind_Types - - IMPLICIT NONE - - 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 - END TYPE - - !> This contains flags to note if the settings were made. This same data structure is - !! used both during the driver input file and the command line options. - !! - !! NOTE: The WindFileType is only set if it is given as a command line option. Otherwise - !! it is handled internally by InflowWInd. - !! - !! NOTE: The wind direction is specified by the InflowWind input file. - TYPE :: IfWDriver_Flags - LOGICAL :: DvrIptFile = .FALSE. !< Was an input file name given on the command line? - LOGICAL :: IfWIptFile = .FALSE. !< Was an InflowWind input file requested? - LOGICAL :: Summary = .FALSE. !< create a summary at command line? (data extents in the wind file) - LOGICAL :: SummaryFile = .FALSE. !< create a summary file of the output? - LOGICAL :: TStart = .FALSE. !< specified a start time - LOGICAL :: NumTimeSteps = .FALSE. !< specified a number of timesteps to process - LOGICAL :: NumTimeStepsDefault = .FALSE. !< specified a 'DEFAULT' for number of timesteps to process - LOGICAL :: DT = .FALSE. !< specified a resolution in time - LOGICAL :: DTDefault = .FALSE. !< specified a 'DEFAULT' for the time resolution - - LOGICAL :: FFTcalc = .FALSE. !< do an FFT - - LOGICAL :: WindGrid = .FALSE. !< Requested output of wind data on a grid -- input file option only - LOGICAL :: XRange = .FALSE. !< specified a range of x -- command line option only -- stored as GridCtrCoord and GridDelta - LOGICAL :: YRange = .FALSE. !< specified a range of y -- command line option only -- stored as GridCtrCoord and GridDelta - LOGICAL :: ZRange = .FALSE. !< specified a range of z -- command line option only -- stored as GridCtrCoord and GridDelta - LOGICAL :: Dx = .FALSE. !< specified a resolution in x -- command line option only, 0.0 otherwise - LOGICAL :: Dy = .FALSE. !< speficied a resolution in y - LOGICAL :: Dz = .FALSE. !< specified a resolution in z - - LOGICAL :: PointsFile = .FALSE. !< points filename to read in - LOGICAL :: OutputAccel = .FALSE. !< flag to calculate and output wind acceleration in addition to velocity - - LOGICAL :: Verbose = .FALSE. !< Verbose error reporting - LOGICAL :: VVerbose = .FALSE. !< Very Verbose error reporting - LOGICAL :: BoxExceedAllowF = .FALSE. !< set flag to allow exceeding wind box boundaries for FF files (for diagnostic purposes) +subroutine InflowWind_Driver_CopyOutputFile(SrcOutputFileData, DstOutputFileData, CtrlCode, ErrStat, ErrMsg) + type(OutputFile), intent(in) :: SrcOutputFileData + type(OutputFile), intent(inout) :: DstOutputFileData + integer(IntKi), intent(in ) :: CtrlCode + integer(IntKi), intent( out) :: ErrStat + character(*), intent( out) :: ErrMsg + character(*), parameter :: RoutineName = 'InflowWind_Driver_CopyOutputFile' + ErrStat = ErrID_None + ErrMsg = '' + DstOutputFileData%Name = SrcOutputFileData%Name + DstOutputFileData%Unit = SrcOutputFileData%Unit + DstOutputFileData%Initialized = SrcOutputFileData%Initialized +end subroutine - LOGICAL :: WrHAWC = .FALSE. !< Requested file conversion to HAWC2 format? - LOGICAL :: WrBladed = .FALSE. !< Requested file conversion to Bladed format? - LOGICAL :: WrVTK = .FALSE. !< Requested file output as VTK? - LOGICAL :: WrUniform = .FALSE. !< Requested file output as Uniform wind format? - END TYPE IfWDriver_Flags +subroutine InflowWind_Driver_DestroyOutputFile(OutputFileData, ErrStat, ErrMsg) + type(OutputFile), intent(inout) :: OutputFileData + integer(IntKi), intent( out) :: ErrStat + character(*), intent( out) :: ErrMsg + character(*), parameter :: RoutineName = 'InflowWind_Driver_DestroyOutputFile' + ErrStat = ErrID_None + ErrMsg = '' +end subroutine +subroutine InflowWind_Driver_PackOutputFile(RF, Indata) + type(RegFile), intent(inout) :: RF + type(OutputFile), intent(in) :: InData + character(*), parameter :: RoutineName = 'InflowWind_Driver_PackOutputFile' + if (RF%ErrStat >= AbortErrLev) return + call RegPack(RF, InData%Name) + call RegPack(RF, InData%Unit) + call RegPack(RF, InData%Initialized) + if (RegCheckErr(RF, RoutineName)) return +end subroutine - ! This contains all the settings (possible passed in arguments). - TYPE :: IfWDriver_Settings - CHARACTER(1024) :: DvrIptFileName = "" !< Driver input file name - CHARACTER(1024) :: IfWIptFileName = "" !< Filename of InflowWind input file to read (if no driver input file) - CHARACTER(1024) :: SummaryFileName = "" !< Filename for the summary information output +subroutine InflowWind_Driver_UnPackOutputFile(RF, OutData) + type(RegFile), intent(inout) :: RF + type(OutputFile), intent(inout) :: OutData + character(*), parameter :: RoutineName = 'InflowWind_Driver_UnPackOutputFile' + if (RF%ErrStat /= ErrID_None) return + call RegUnpack(RF, OutData%Name); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%Unit); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%Initialized); if (RegCheckErr(RF, RoutineName)) return +end subroutine - CHARACTER(1024) :: PointsFileName = "" !< Filename of points file to read in - - INTEGER(IntKi) :: NumTimeSteps = 0 !< Number of timesteps - REAL(DbKi) :: DT = 0.0_DbKi !< resolution of time - REAL(DbKi) :: TStart = 0.0_DbKi !< range of time -- end time converted from TRange (command line option only) +subroutine InflowWind_Driver_CopyIfWDriver_Flags(SrcIfWDriver_FlagsData, DstIfWDriver_FlagsData, CtrlCode, ErrStat, ErrMsg) + type(IfWDriver_Flags), intent(in) :: SrcIfWDriver_FlagsData + type(IfWDriver_Flags), intent(inout) :: DstIfWDriver_FlagsData + integer(IntKi), intent(in ) :: CtrlCode + integer(IntKi), intent( out) :: ErrStat + character(*), intent( out) :: ErrMsg + character(*), parameter :: RoutineName = 'InflowWind_Driver_CopyIfWDriver_Flags' + ErrStat = ErrID_None + ErrMsg = '' + DstIfWDriver_FlagsData%DvrIptFile = SrcIfWDriver_FlagsData%DvrIptFile + DstIfWDriver_FlagsData%IfWIptFile = SrcIfWDriver_FlagsData%IfWIptFile + DstIfWDriver_FlagsData%Summary = SrcIfWDriver_FlagsData%Summary + DstIfWDriver_FlagsData%SummaryFile = SrcIfWDriver_FlagsData%SummaryFile + DstIfWDriver_FlagsData%TStart = SrcIfWDriver_FlagsData%TStart + DstIfWDriver_FlagsData%NumTimeSteps = SrcIfWDriver_FlagsData%NumTimeSteps + DstIfWDriver_FlagsData%NumTimeStepsDefault = SrcIfWDriver_FlagsData%NumTimeStepsDefault + DstIfWDriver_FlagsData%DT = SrcIfWDriver_FlagsData%DT + DstIfWDriver_FlagsData%DTDefault = SrcIfWDriver_FlagsData%DTDefault + DstIfWDriver_FlagsData%FFTcalc = SrcIfWDriver_FlagsData%FFTcalc + DstIfWDriver_FlagsData%WindGrid = SrcIfWDriver_FlagsData%WindGrid + DstIfWDriver_FlagsData%XRange = SrcIfWDriver_FlagsData%XRange + DstIfWDriver_FlagsData%YRange = SrcIfWDriver_FlagsData%YRange + DstIfWDriver_FlagsData%ZRange = SrcIfWDriver_FlagsData%ZRange + DstIfWDriver_FlagsData%Dx = SrcIfWDriver_FlagsData%Dx + DstIfWDriver_FlagsData%Dy = SrcIfWDriver_FlagsData%Dy + DstIfWDriver_FlagsData%Dz = SrcIfWDriver_FlagsData%Dz + DstIfWDriver_FlagsData%PointsFile = SrcIfWDriver_FlagsData%PointsFile + DstIfWDriver_FlagsData%OutputAccel = SrcIfWDriver_FlagsData%OutputAccel + DstIfWDriver_FlagsData%Verbose = SrcIfWDriver_FlagsData%Verbose + DstIfWDriver_FlagsData%VVerbose = SrcIfWDriver_FlagsData%VVerbose + DstIfWDriver_FlagsData%BoxExceedAllowF = SrcIfWDriver_FlagsData%BoxExceedAllowF + DstIfWDriver_FlagsData%WrHAWC = SrcIfWDriver_FlagsData%WrHAWC + DstIfWDriver_FlagsData%WrBladed = SrcIfWDriver_FlagsData%WrBladed + DstIfWDriver_FlagsData%WrVTK = SrcIfWDriver_FlagsData%WrVTK + DstIfWDriver_FlagsData%WrUniform = SrcIfWDriver_FlagsData%WrUniform + DstIfWDriver_FlagsData%XYslice = SrcIfWDriver_FlagsData%XYslice +end subroutine - REAL(ReKi) :: FFTcoord(1:3) = 0.0_ReKi !< (x,y,z) coordinate to do an FFT at +subroutine InflowWind_Driver_DestroyIfWDriver_Flags(IfWDriver_FlagsData, ErrStat, ErrMsg) + type(IfWDriver_Flags), intent(inout) :: IfWDriver_FlagsData + integer(IntKi), intent( out) :: ErrStat + character(*), intent( out) :: ErrMsg + character(*), parameter :: RoutineName = 'InflowWind_Driver_DestroyIfWDriver_Flags' + ErrStat = ErrID_None + ErrMsg = '' +end subroutine - REAL(ReKi) :: GridDelta(1:3) = 0.0_ReKi !< (GridDx,GridDy,GridDz) -- grid point spacing - INTEGER(IntKi) :: GridN(1:3) = 1_IntKi !< (GridNx,GridNy,GridNz) -- number of grid points +subroutine InflowWind_Driver_PackIfWDriver_Flags(RF, Indata) + type(RegFile), intent(inout) :: RF + type(IfWDriver_Flags), intent(in) :: InData + character(*), parameter :: RoutineName = 'InflowWind_Driver_PackIfWDriver_Flags' + if (RF%ErrStat >= AbortErrLev) return + call RegPack(RF, InData%DvrIptFile) + call RegPack(RF, InData%IfWIptFile) + call RegPack(RF, InData%Summary) + call RegPack(RF, InData%SummaryFile) + call RegPack(RF, InData%TStart) + call RegPack(RF, InData%NumTimeSteps) + call RegPack(RF, InData%NumTimeStepsDefault) + call RegPack(RF, InData%DT) + call RegPack(RF, InData%DTDefault) + call RegPack(RF, InData%FFTcalc) + call RegPack(RF, InData%WindGrid) + call RegPack(RF, InData%XRange) + call RegPack(RF, InData%YRange) + call RegPack(RF, InData%ZRange) + call RegPack(RF, InData%Dx) + call RegPack(RF, InData%Dy) + call RegPack(RF, InData%Dz) + call RegPack(RF, InData%PointsFile) + call RegPack(RF, InData%OutputAccel) + call RegPack(RF, InData%Verbose) + call RegPack(RF, InData%VVerbose) + call RegPack(RF, InData%BoxExceedAllowF) + call RegPack(RF, InData%WrHAWC) + call RegPack(RF, InData%WrBladed) + call RegPack(RF, InData%WrVTK) + call RegPack(RF, InData%WrUniform) + call RegPack(RF, InData%XYslice) + if (RegCheckErr(RF, RoutineName)) return +end subroutine - REAL(ReKi) :: XRange(1:2) = 0.0_ReKi !< Range in the x-direction for the gridded data - REAL(ReKi) :: YRange(1:2) = 0.0_ReKi !< Range in the y-direction for the gridded data - REAL(ReKi) :: ZRange(1:2) = 0.0_ReKi !< Range in the z-direction for the gridded data +subroutine InflowWind_Driver_UnPackIfWDriver_Flags(RF, OutData) + type(RegFile), intent(inout) :: RF + type(IfWDriver_Flags), intent(inout) :: OutData + character(*), parameter :: RoutineName = 'InflowWind_Driver_UnPackIfWDriver_Flags' + if (RF%ErrStat /= ErrID_None) return + call RegUnpack(RF, OutData%DvrIptFile); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%IfWIptFile); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%Summary); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%SummaryFile); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%TStart); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%NumTimeSteps); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%NumTimeStepsDefault); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%DT); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%DTDefault); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%FFTcalc); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%WindGrid); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%XRange); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%YRange); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%ZRange); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%Dx); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%Dy); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%Dz); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%PointsFile); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%OutputAccel); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%Verbose); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%VVerbose); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%BoxExceedAllowF); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%WrHAWC); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%WrBladed); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%WrVTK); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%WrUniform); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%XYslice); if (RegCheckErr(RF, RoutineName)) return +end subroutine - TYPE(ProgDesc) :: ProgInfo !< Program info - TYPE(OutputFile) :: WindGridOutput - TYPE(OutputFile) :: FFTOutput - TYPE(OutputFile) :: PointsVelOutput +subroutine InflowWind_Driver_CopyIfWDriver_Settings(SrcIfWDriver_SettingsData, DstIfWDriver_SettingsData, CtrlCode, ErrStat, ErrMsg) + type(IfWDriver_Settings), intent(in) :: SrcIfWDriver_SettingsData + type(IfWDriver_Settings), intent(inout) :: DstIfWDriver_SettingsData + integer(IntKi), intent(in ) :: CtrlCode + integer(IntKi), intent( out) :: ErrStat + character(*), intent( out) :: ErrMsg + integer(B4Ki) :: LB(1), UB(1) + integer(IntKi) :: ErrStat2 + character(ErrMsgLen) :: ErrMsg2 + character(*), parameter :: RoutineName = 'InflowWind_Driver_CopyIfWDriver_Settings' + ErrStat = ErrID_None + ErrMsg = '' + DstIfWDriver_SettingsData%DvrIptFileName = SrcIfWDriver_SettingsData%DvrIptFileName + DstIfWDriver_SettingsData%IfWIptFileName = SrcIfWDriver_SettingsData%IfWIptFileName + DstIfWDriver_SettingsData%SummaryFileName = SrcIfWDriver_SettingsData%SummaryFileName + DstIfWDriver_SettingsData%PointsFileName = SrcIfWDriver_SettingsData%PointsFileName + DstIfWDriver_SettingsData%NumTimeSteps = SrcIfWDriver_SettingsData%NumTimeSteps + DstIfWDriver_SettingsData%DT = SrcIfWDriver_SettingsData%DT + DstIfWDriver_SettingsData%TStart = SrcIfWDriver_SettingsData%TStart + DstIfWDriver_SettingsData%FFTcoord(1:3) = SrcIfWDriver_SettingsData%FFTcoord(1:3) + DstIfWDriver_SettingsData%GridDelta(1:3) = SrcIfWDriver_SettingsData%GridDelta(1:3) + DstIfWDriver_SettingsData%GridN(1:3) = SrcIfWDriver_SettingsData%GridN(1:3) + DstIfWDriver_SettingsData%XRange(1:2) = SrcIfWDriver_SettingsData%XRange(1:2) + DstIfWDriver_SettingsData%YRange(1:2) = SrcIfWDriver_SettingsData%YRange(1:2) + DstIfWDriver_SettingsData%ZRange(1:2) = SrcIfWDriver_SettingsData%ZRange(1:2) + call NWTC_Library_CopyProgDesc(SrcIfWDriver_SettingsData%ProgInfo, DstIfWDriver_SettingsData%ProgInfo, CtrlCode, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (ErrStat >= AbortErrLev) return + call InflowWind_Driver_CopyOutputFile(SrcIfWDriver_SettingsData%WindGridOutput, DstIfWDriver_SettingsData%WindGridOutput, CtrlCode, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (ErrStat >= AbortErrLev) return + call InflowWind_Driver_CopyOutputFile(SrcIfWDriver_SettingsData%FFTOutput, DstIfWDriver_SettingsData%FFTOutput, CtrlCode, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (ErrStat >= AbortErrLev) return + call InflowWind_Driver_CopyOutputFile(SrcIfWDriver_SettingsData%PointsVelOutput, DstIfWDriver_SettingsData%PointsVelOutput, CtrlCode, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (ErrStat >= AbortErrLev) return + DstIfWDriver_SettingsData%NOutWindXY = SrcIfWDriver_SettingsData%NOutWindXY + if (allocated(SrcIfWDriver_SettingsData%OutWindZ)) then + LB(1:1) = lbound(SrcIfWDriver_SettingsData%OutWindZ) + UB(1:1) = ubound(SrcIfWDriver_SettingsData%OutWindZ) + if (.not. allocated(DstIfWDriver_SettingsData%OutWindZ)) then + allocate(DstIfWDriver_SettingsData%OutWindZ(LB(1):UB(1)), stat=ErrStat2) + if (ErrStat2 /= 0) then + call SetErrStat(ErrID_Fatal, 'Error allocating DstIfWDriver_SettingsData%OutWindZ.', ErrStat, ErrMsg, RoutineName) + return + end if + end if + DstIfWDriver_SettingsData%OutWindZ = SrcIfWDriver_SettingsData%OutWindZ + end if + DstIfWDriver_SettingsData%NOutWindXZ = SrcIfWDriver_SettingsData%NOutWindXZ + if (allocated(SrcIfWDriver_SettingsData%OutWindY)) then + LB(1:1) = lbound(SrcIfWDriver_SettingsData%OutWindY) + UB(1:1) = ubound(SrcIfWDriver_SettingsData%OutWindY) + if (.not. allocated(DstIfWDriver_SettingsData%OutWindY)) then + allocate(DstIfWDriver_SettingsData%OutWindY(LB(1):UB(1)), stat=ErrStat2) + if (ErrStat2 /= 0) then + call SetErrStat(ErrID_Fatal, 'Error allocating DstIfWDriver_SettingsData%OutWindY.', ErrStat, ErrMsg, RoutineName) + return + end if + end if + DstIfWDriver_SettingsData%OutWindY = SrcIfWDriver_SettingsData%OutWindY + end if + DstIfWDriver_SettingsData%NOutWindYZ = SrcIfWDriver_SettingsData%NOutWindYZ + if (allocated(SrcIfWDriver_SettingsData%OutWindX)) then + LB(1:1) = lbound(SrcIfWDriver_SettingsData%OutWindX) + UB(1:1) = ubound(SrcIfWDriver_SettingsData%OutWindX) + if (.not. allocated(DstIfWDriver_SettingsData%OutWindX)) then + allocate(DstIfWDriver_SettingsData%OutWindX(LB(1):UB(1)), stat=ErrStat2) + if (ErrStat2 /= 0) then + call SetErrStat(ErrID_Fatal, 'Error allocating DstIfWDriver_SettingsData%OutWindX.', ErrStat, ErrMsg, RoutineName) + return + end if + end if + DstIfWDriver_SettingsData%OutWindX = SrcIfWDriver_SettingsData%OutWindX + end if +end subroutine - END TYPE IfWDriver_Settings +subroutine InflowWind_Driver_DestroyIfWDriver_Settings(IfWDriver_SettingsData, ErrStat, ErrMsg) + type(IfWDriver_Settings), intent(inout) :: IfWDriver_SettingsData + integer(IntKi), intent( out) :: ErrStat + character(*), intent( out) :: ErrMsg + integer(IntKi) :: ErrStat2 + character(ErrMsgLen) :: ErrMsg2 + character(*), parameter :: RoutineName = 'InflowWind_Driver_DestroyIfWDriver_Settings' + ErrStat = ErrID_None + ErrMsg = '' + call NWTC_Library_DestroyProgDesc(IfWDriver_SettingsData%ProgInfo, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + call InflowWind_Driver_DestroyOutputFile(IfWDriver_SettingsData%WindGridOutput, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + call InflowWind_Driver_DestroyOutputFile(IfWDriver_SettingsData%FFTOutput, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + call InflowWind_Driver_DestroyOutputFile(IfWDriver_SettingsData%PointsVelOutput, ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (allocated(IfWDriver_SettingsData%OutWindZ)) then + deallocate(IfWDriver_SettingsData%OutWindZ) + end if + if (allocated(IfWDriver_SettingsData%OutWindY)) then + deallocate(IfWDriver_SettingsData%OutWindY) + end if + if (allocated(IfWDriver_SettingsData%OutWindX)) then + deallocate(IfWDriver_SettingsData%OutWindX) + end if +end subroutine +subroutine InflowWind_Driver_PackIfWDriver_Settings(RF, Indata) + type(RegFile), intent(inout) :: RF + type(IfWDriver_Settings), intent(in) :: InData + character(*), parameter :: RoutineName = 'InflowWind_Driver_PackIfWDriver_Settings' + if (RF%ErrStat >= AbortErrLev) return + call RegPack(RF, InData%DvrIptFileName) + call RegPack(RF, InData%IfWIptFileName) + call RegPack(RF, InData%SummaryFileName) + call RegPack(RF, InData%PointsFileName) + call RegPack(RF, InData%NumTimeSteps) + call RegPack(RF, InData%DT) + call RegPack(RF, InData%TStart) + call RegPack(RF, InData%FFTcoord(1:3)) + call RegPack(RF, InData%GridDelta(1:3)) + call RegPack(RF, InData%GridN(1:3)) + call RegPack(RF, InData%XRange(1:2)) + call RegPack(RF, InData%YRange(1:2)) + call RegPack(RF, InData%ZRange(1:2)) + call NWTC_Library_PackProgDesc(RF, InData%ProgInfo) + call InflowWind_Driver_PackOutputFile(RF, InData%WindGridOutput) + call InflowWind_Driver_PackOutputFile(RF, InData%FFTOutput) + call InflowWind_Driver_PackOutputFile(RF, InData%PointsVelOutput) + call RegPack(RF, InData%NOutWindXY) + call RegPackAlloc(RF, InData%OutWindZ) + call RegPack(RF, InData%NOutWindXZ) + call RegPackAlloc(RF, InData%OutWindY) + call RegPack(RF, InData%NOutWindYZ) + call RegPackAlloc(RF, InData%OutWindX) + if (RegCheckErr(RF, RoutineName)) return +end subroutine +subroutine InflowWind_Driver_UnPackIfWDriver_Settings(RF, OutData) + type(RegFile), intent(inout) :: RF + type(IfWDriver_Settings), intent(inout) :: OutData + character(*), parameter :: RoutineName = 'InflowWind_Driver_UnPackIfWDriver_Settings' + integer(B4Ki) :: LB(1), UB(1) + integer(IntKi) :: stat + logical :: IsAllocAssoc + if (RF%ErrStat /= ErrID_None) return + call RegUnpack(RF, OutData%DvrIptFileName); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%IfWIptFileName); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%SummaryFileName); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%PointsFileName); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%NumTimeSteps); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%DT); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%TStart); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%FFTcoord(1:3)); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%GridDelta(1:3)); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%GridN(1:3)); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%XRange(1:2)); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%YRange(1:2)); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%ZRange(1:2)); if (RegCheckErr(RF, RoutineName)) return + call NWTC_Library_UnpackProgDesc(RF, OutData%ProgInfo) ! ProgInfo + call InflowWind_Driver_UnpackOutputFile(RF, OutData%WindGridOutput) ! WindGridOutput + call InflowWind_Driver_UnpackOutputFile(RF, OutData%FFTOutput) ! FFTOutput + call InflowWind_Driver_UnpackOutputFile(RF, OutData%PointsVelOutput) ! PointsVelOutput + call RegUnpack(RF, OutData%NOutWindXY); if (RegCheckErr(RF, RoutineName)) return + call RegUnpackAlloc(RF, OutData%OutWindZ); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%NOutWindXZ); if (RegCheckErr(RF, RoutineName)) return + call RegUnpackAlloc(RF, OutData%OutWindY); if (RegCheckErr(RF, RoutineName)) return + call RegUnpack(RF, OutData%NOutWindYZ); if (RegCheckErr(RF, RoutineName)) return + call RegUnpackAlloc(RF, OutData%OutWindX); if (RegCheckErr(RF, RoutineName)) return +end subroutine END MODULE InflowWind_Driver_Types +!ENDOFREGISTRYGENERATEDFILE diff --git a/modules/inflowwind/src/InflowWind_IO.f90 b/modules/inflowwind/src/InflowWind_IO.f90 index 35fbd4d6dc..4c30d9d2ed 100644 --- a/modules/inflowwind/src/InflowWind_IO.f90 +++ b/modules/inflowwind/src/InflowWind_IO.f90 @@ -39,7 +39,8 @@ module InflowWind_IO public :: Uniform_WriteHH, & Grid3D_WriteBladed, & Grid3D_WriteHAWC, & - Grid3D_WriteVTK + Grid3D_WriteVTK, & + Grid3D_WriteVTKsliceXY type(ProgDesc), parameter :: InflowWind_IO_Ver = ProgDesc('InflowWind_IO', '', '') @@ -2943,4 +2944,87 @@ subroutine Grid3D_WriteHAWC(G3D, FileRootName, unit, ErrStat, ErrMsg) end subroutine Grid3D_WriteHAWC + +!> This subroutine writes a VTK slice in the XY plane at a designated height (rounds to nearest point) +!! This feature is mostly useful for testing when a grid is needed for comparison elsewhere +subroutine Grid3D_WriteVTKsliceXY(G3D, FileRootName, vtk_dir, XYslice_height, unit, ErrStat, ErrMsg) + type(Grid3DFieldType), intent(in ) :: G3D !< Parameters + character(*), intent(in ) :: FileRootName !< RootName for output files + character(*), intent(in ) :: vtk_dir !< directory for vtk file for output files + real(ReKi), intent(in ) :: XYslice_height + integer(IntKi), intent(in ) :: unit !< Error status of the operation + integer(IntKi), intent( out) :: ErrStat !< Error status of the operation + character(*), intent( out) :: ErrMsg !< Error message if ErrStat /= ErrID_None + + character(*), parameter :: RoutineName = 'Grid3D_WriteVTKsliceXY' + character(1024) :: RootPathName + character(1024) :: FileName + character(3) :: ht_str + character(8) :: t_str, t_fmt + integer :: it, ix, iy, iz, twidth + real(ReKi) :: time !< time for this slice + real(ReKi) :: ht !< nearest grid slice elevation + integer(IntKi) :: ErrStat2 + character(ErrMsgLen) :: ErrMsg2 + + ErrStat = ErrID_None + ErrMsg = "" + + call GetPath(FileRootName, RootPathName) + RootPathName = trim(RootPathName)//PathSep//vtk_dir + call MkDir(trim(RootPathName)) ! make this directory if it doesn't already exist + + ! get indices for this slice + iz = nint((G3D%GridBase + XYslice_height)*G3D%InvDZ) + ht = real(iz,ReKi) / G3D%InvDZ + G3D%GridBase ! nearest height index + write(ht_str,'(i0.3)') nint(ht) + + ! get width of string for time + twidth=ceiling(log10(real(G3D%NSteps))) + t_fmt='(i0.'//trim(Num2LStr(twidth))//')' + + ! check for errors in slice height + if (iz <= 0_IntKi .or. iz > G3D%NZGrids) then + call SetErrStat(ErrID_Warn,"No grid points near XY slice height of "//trim(num2lstr(XYslice_height))//". Skipping writing slice file.",ErrStat,ErrMsg,RoutineName) + return + endif + + ! Loop through time steps + do it = 1, G3D%NSteps + time = real(it - 1, ReKi)*G3D%DTime + + ! time string + write(t_str,t_fmt) it + + ! Create the output vtk file with naming /vtk/DisYZ.t.vtk + FileName = trim(RootPathName)//PathSep//"DisXY.Z"//ht_str//".t"//trim(t_str)//".vtp" + + ! see WrVTK_SP_header + call OpenFOutFile(unit, TRIM(FileName), ErrStat2, ErrMsg2) + call SetErrStat(ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName) + if (ErrStat >= AbortErrLev) return + + write (unit, '(A)') '# vtk DataFile Version 3.0' + write (unit, '(A)') "InflowWind XY Slice at T= "//trim(num2lstr(time))//" s" + write (unit, '(A)') 'ASCII' + write (unit, '(A)') 'DATASET STRUCTURED_POINTS' + + ! Note: gridVals must be stored such that the left-most dimension is X + ! and the right-most dimension is Z (see WrVTK_SP_vectors3D) + write (unit, '(A,3(i5,1X))') 'DIMENSIONS ', G3D%NSteps, G3D%NYGrids, 1 + write (unit, '(A,3(f10.2,1X))') 'ORIGIN ', G3D%InitXPosition+time*G3D%MeanWS, -G3D%YHWid, ht + write (unit, '(A,3(f10.2,1X))') 'SPACING ', -G3D%Dtime*G3D%MeanWS, 1.0_ReKi/G3D%InvDY, 0.0_ReKi + write (unit, '(A,i9)') 'POINT_DATA ', G3D%NSteps*G3D%NYGrids + write (unit, '(A)') 'VECTORS DisXY float' + + do iy = 1, G3D%NYGrids + do ix = 1, G3D%NSteps ! time and X are interchangeable + write (unit, '(3(f10.2,1X))') G3D%Vel(:, iy, iz, ix) + end do + end do + + close (unit) + enddo +end subroutine Grid3D_WriteVTKsliceXY + end module InflowWind_IO diff --git a/reg_tests/r-test b/reg_tests/r-test index b3824f2d3a..5641aabb0c 160000 --- a/reg_tests/r-test +++ b/reg_tests/r-test @@ -1 +1 @@ -Subproject commit b3824f2d3a4cd4cb826aa4ac95b6e39a99e66d43 +Subproject commit 5641aabb0c8dd542d7e3d45e69e52077cc12e902 diff --git a/vs-build/RunRegistry.bat b/vs-build/RunRegistry.bat index 8a65be2a5d..db72464a1c 100644 --- a/vs-build/RunRegistry.bat +++ b/vs-build/RunRegistry.bat @@ -142,6 +142,12 @@ SET Output_Loc=%CURR_LOC% %REGISTRY% "%CURR_LOC%\%ModuleName%.txt" -I "%NWTC_Lib_Loc%" -I "%CURR_LOC%" -noextrap -O "%Output_Loc%" GOTO checkError +:InflowWind_Driver +SET CURR_LOC=%IfW_Loc% +SET Output_Loc=%CURR_LOC% +%REGISTRY% "%CURR_LOC%\%ModuleName%_Registry.txt" -I "%NWTC_Lib_Loc%" -I "%CURR_LOC%" -noextrap -O "%Output_Loc%" +GOTO checkError + :ExternalInflow SET CURR_LOC=%ExtInfw_Loc% SET Output_Loc=%CURR_LOC%