diff --git a/.github/actions/tests-module-version/action.yml b/.github/actions/tests-module-version/action.yml new file mode 100644 index 0000000000..d0ed3a723f --- /dev/null +++ b/.github/actions/tests-module-version/action.yml @@ -0,0 +1,9 @@ +name: 'VersionInfo module tests' +description: 'Run tests specific to the NWTC Library module' +author: 'Rafael Mudafort https://github.com/rafmudaf' +runs: + using: "composite" + steps: + - run: ctest -VV -R versioninfo_utest + working-directory: ${{runner.workspace}}/openfast/build + shell: bash diff --git a/.github/workflows/automated-dev-tests.yml b/.github/workflows/automated-dev-tests.yml index 2962213bb6..204b95fa45 100644 --- a/.github/workflows/automated-dev-tests.yml +++ b/.github/workflows/automated-dev-tests.yml @@ -109,12 +109,14 @@ jobs: working-directory: ${{runner.workspace}}/openfast/build run: cmake --build . --target install -- -j ${{env.NUM_PROCS}} + # SubDyn has only regression tests - name: Run SubDyn tests uses: ./.github/actions/tests-module-subdyn # - name: Run AeroDyn tests # uses: ./.github/actions/tests-module-aerodyn # with: # test-target: regression + # HydroDyn has only regression tests - name: Run HydroDyn tests uses: ./.github/actions/tests-module-hydrodyn - name: Run InflowWind tests @@ -333,8 +335,12 @@ jobs: working-directory: ${{runner.workspace}}/openfast/build run: cmake --build . --target unit_tests -- -j ${{env.NUM_PROCS}} + # NWTC Library has only unit tests - name: Run NWTC Library tests uses: ./.github/actions/tests-module-nwtclibrary + # VersionInfo has only unit tests + - name: Run VersionInfo tests + uses: ./.github/actions/tests-module-version - name: Run AeroDyn tests uses: ./.github/actions/tests-module-aerodyn with: diff --git a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 index ce50e3f811..1993dbcd60 100644 --- a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 +++ b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 @@ -86,16 +86,15 @@ subroutine Dvr_Init(dvr, AD, IW, errStat,errMsg ) ! --- Driver initialization CALL NWTC_Init( ProgNameIN=version%Name ) + InputFile = "" ! initialize to empty string to make sure it's input from the command line CALL CheckArgs( InputFile, Flag=FlagArg ) IF ( LEN( TRIM(FlagArg) ) > 0 ) CALL NormStop() - ! Display the copyright notice - call DispCopyrightLicense( version%Name ) - ! Obtain OpenFAST git commit hash - git_commit = QueryGitVersion() - ! Tell our users what they're running - call WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) - + + ! Display the copyright notice and compile info: + CALL DispCopyrightLicense( version%Name ) + CALL DispCompileRuntimeInfo( version%Name ) + ! Read the AeroDyn driver input file call Dvr_ReadInputFile(inputFile, dvr, errStat2, errMsg2 ); if(Failed()) return diff --git a/modules/aerodyn14/CMakeLists.txt b/modules/aerodyn14/CMakeLists.txt index be1846cc91..58741a9281 100644 --- a/modules/aerodyn14/CMakeLists.txt +++ b/modules/aerodyn14/CMakeLists.txt @@ -45,7 +45,7 @@ set(DWM_SOURCES ) add_executable(dwm_driver_wind_farm ${DWM_SOURCES}) -target_link_libraries(dwm_driver_wind_farm aerodyn14lib) +target_link_libraries(dwm_driver_wind_farm aerodyn14lib versioninfolib) install(TARGETS dwm_driver_wind_farm RUNTIME DESTINATION bin diff --git a/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 b/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 index dae5c1a2da..b2492b0462 100644 --- a/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 +++ b/modules/aerodyn14/src/DWM_driver_wind_farm_sub.f90 @@ -1,5 +1,6 @@ MODULE DWM_driver_wind_farm_sub USE NWTC_Library + USE VersionInfo IMPLICIT NONE !PUBLIC SUBROUTINES diff --git a/modules/feamooring/CMakeLists.txt b/modules/feamooring/CMakeLists.txt index c9009c443d..42411802d3 100644 --- a/modules/feamooring/CMakeLists.txt +++ b/modules/feamooring/CMakeLists.txt @@ -33,7 +33,7 @@ install(TARGETS feamlib LIBRARY DESTINATION lib) add_executable(feam_driver src/FEAM_Driver.f90) -target_link_libraries(feam_driver feamlib) +target_link_libraries(feam_driver feamlib versioninfolib) install(TARGETS feam_driver EXPORT "${CMAKE_PROJECT_NAME}Libraries" diff --git a/modules/hydrodyn/src/HydroDyn_DriverCode.f90 b/modules/hydrodyn/src/HydroDyn_DriverCode.f90 index 2e186d5bca..6312fb010c 100644 --- a/modules/hydrodyn/src/HydroDyn_DriverCode.f90 +++ b/modules/hydrodyn/src/HydroDyn_DriverCode.f90 @@ -165,12 +165,9 @@ PROGRAM HydroDynDriver CALL CheckArgs( drvrFilename, Flag=FlagArg ) IF ( LEN( TRIM(FlagArg) ) > 0 ) CALL NormStop() - ! Display the copyright notice + ! Display the copyright notice and compile info: CALL DispCopyrightLicense( version%Name ) - ! Obtain OpenFAST git commit hash - git_commit = QueryGitVersion() - ! Tell our users what they're running - CALL WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) + CALL DispCompileRuntimeInfo( version%Name ) ! Parse the driver input file and run the simulation based on that file CALL ReadDriverInputFile( drvrFilename, drvrInitInp, ErrStat, ErrMsg ) diff --git a/modules/icefloe/CMakeLists.txt b/modules/icefloe/CMakeLists.txt index 67306c750f..12fc293ac0 100644 --- a/modules/icefloe/CMakeLists.txt +++ b/modules/icefloe/CMakeLists.txt @@ -38,7 +38,7 @@ set(ICEFLOE_LIBS_SOURCES ) add_library(icefloelib ${ICEFLOE_LIBS_SOURCES}) -target_link_libraries(icefloelib nwtclibs) +target_link_libraries(icefloelib nwtclibs versioninfolib) install(TARGETS icefloelib EXPORT "${CMAKE_PROJECT_NAME}Libraries" diff --git a/modules/inflowwind/CMakeLists.txt b/modules/inflowwind/CMakeLists.txt index abc3f26313..1dea2c8dbe 100644 --- a/modules/inflowwind/CMakeLists.txt +++ b/modules/inflowwind/CMakeLists.txt @@ -53,7 +53,7 @@ target_link_libraries(ifwlib nwtclibs) # C-bound interface library add_library(ifw_c_binding SHARED src/IfW_C_Binding.f90) -target_link_libraries(ifw_c_binding ifwlib) +target_link_libraries(ifw_c_binding ifwlib versioninfolib) if(APPLE OR UNIX) target_compile_definitions(ifw_c_binding PUBLIC -DIMPLICIT_DLLEXPORT) endif() @@ -65,7 +65,7 @@ set(IFW_DRIVER_SOURCES ) add_executable(inflowwind_driver ${IFW_DRIVER_SOURCES}) -target_link_libraries(inflowwind_driver ifwlib ${CMAKE_DL_LIBS}) +target_link_libraries(inflowwind_driver ifwlib versioninfolib ${CMAKE_DL_LIBS}) install(TARGETS inflowwind_driver ifwlib ifw_c_binding EXPORT "${CMAKE_PROJECT_NAME}Libraries" diff --git a/modules/moordyn/CMakeLists.txt b/modules/moordyn/CMakeLists.txt index 4bd406ba23..18f66807b8 100644 --- a/modules/moordyn/CMakeLists.txt +++ b/modules/moordyn/CMakeLists.txt @@ -25,7 +25,7 @@ set(MOORDYN_LIBS_SOURCES ) add_library(moordynlib ${MOORDYN_LIBS_SOURCES}) -target_link_libraries(moordynlib nwtclibs) +target_link_libraries(moordynlib nwtclibs versioninfolib) install(TARGETS moordynlib EXPORT "${CMAKE_PROJECT_NAME}Libraries" @@ -35,7 +35,7 @@ install(TARGETS moordynlib set(MD_DRIVER_SOURCES src/MoorDyn_Driver.f90) add_executable(moordyn_driver ${MD_DRIVER_SOURCES}) -target_link_libraries(moordyn_driver moordynlib nwtclibs versioninfolib ${CMAKE_DL_LIBS}) +target_link_libraries(moordyn_driver moordynlib nwtclibs ${CMAKE_DL_LIBS}) install(TARGETS moordyn_driver RUNTIME DESTINATION bin diff --git a/modules/moordyn/src/MoorDyn_Driver.f90 b/modules/moordyn/src/MoorDyn_Driver.f90 index 99ad3b8019..0b501336ea 100644 --- a/modules/moordyn/src/MoorDyn_Driver.f90 +++ b/modules/moordyn/src/MoorDyn_Driver.f90 @@ -23,6 +23,7 @@ PROGRAM MoorDyn_Driver USE MoorDyn_Types USE MoorDyn USE NWTC_Library + USE VersionInfo IMPLICIT NONE diff --git a/modules/nwtc-library/CMakeLists.txt b/modules/nwtc-library/CMakeLists.txt index 7bf80a9b3c..6883581a0e 100644 --- a/modules/nwtc-library/CMakeLists.txt +++ b/modules/nwtc-library/CMakeLists.txt @@ -125,9 +125,9 @@ add_library(nwtclibs ${NWTCLIBS_SOURCES}) if(BUILD_OPENFAST_SIMULINK_API) find_package(Matlab REQUIRED) - target_link_libraries(nwtclibs versioninfolib ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS} ${Matlab_MEX_LIBRARY}) + target_link_libraries(nwtclibs ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS} ${Matlab_MEX_LIBRARY}) else() - target_link_libraries(nwtclibs versioninfolib ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS}) + target_link_libraries(nwtclibs ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS}) endif() install(TARGETS nwtclibs diff --git a/modules/nwtc-library/test/Compare_LAPACK_MUMPS/Compare_LAPACK_MUMPS.f90 b/modules/nwtc-library/Old_test/Compare_LAPACK_MUMPS/Compare_LAPACK_MUMPS.f90 similarity index 100% rename from modules/nwtc-library/test/Compare_LAPACK_MUMPS/Compare_LAPACK_MUMPS.f90 rename to modules/nwtc-library/Old_test/Compare_LAPACK_MUMPS/Compare_LAPACK_MUMPS.f90 diff --git a/modules/nwtc-library/test/ReadMe.md b/modules/nwtc-library/Old_test/ReadMe.md similarity index 100% rename from modules/nwtc-library/test/ReadMe.md rename to modules/nwtc-library/Old_test/ReadMe.md diff --git a/modules/nwtc-library/test/Test_CheckArgs.f90 b/modules/nwtc-library/Old_test/Test_CheckArgs.f90 similarity index 100% rename from modules/nwtc-library/test/Test_CheckArgs.f90 rename to modules/nwtc-library/Old_test/Test_CheckArgs.f90 diff --git a/modules/nwtc-library/test/Test_ChkRealFmtStr/Test_ChkRealFmtStr.f90 b/modules/nwtc-library/Old_test/Test_ChkRealFmtStr/Test_ChkRealFmtStr.f90 similarity index 100% rename from modules/nwtc-library/test/Test_ChkRealFmtStr/Test_ChkRealFmtStr.f90 rename to modules/nwtc-library/Old_test/Test_ChkRealFmtStr/Test_ChkRealFmtStr.f90 diff --git a/modules/nwtc-library/test/Test_ChkRealFmtStr/makefile b/modules/nwtc-library/Old_test/Test_ChkRealFmtStr/makefile similarity index 100% rename from modules/nwtc-library/test/Test_ChkRealFmtStr/makefile rename to modules/nwtc-library/Old_test/Test_ChkRealFmtStr/makefile diff --git a/modules/nwtc-library/test/Test_FileSize/Test_FileSize.f90 b/modules/nwtc-library/Old_test/Test_FileSize/Test_FileSize.f90 similarity index 100% rename from modules/nwtc-library/test/Test_FileSize/Test_FileSize.f90 rename to modules/nwtc-library/Old_test/Test_FileSize/Test_FileSize.f90 diff --git a/modules/nwtc-library/test/Test_FileSize/makefile b/modules/nwtc-library/Old_test/Test_FileSize/makefile similarity index 100% rename from modules/nwtc-library/test/Test_FileSize/makefile rename to modules/nwtc-library/Old_test/Test_FileSize/makefile diff --git a/modules/nwtc-library/test/Test_MeshMapping/Makefile b/modules/nwtc-library/Old_test/Test_MeshMapping/Makefile similarity index 100% rename from modules/nwtc-library/test/Test_MeshMapping/Makefile rename to modules/nwtc-library/Old_test/Test_MeshMapping/Makefile diff --git a/modules/nwtc-library/test/Test_MeshMapping/Test_MeshMapping.f90 b/modules/nwtc-library/Old_test/Test_MeshMapping/Test_MeshMapping.f90 similarity index 100% rename from modules/nwtc-library/test/Test_MeshMapping/Test_MeshMapping.f90 rename to modules/nwtc-library/Old_test/Test_MeshMapping/Test_MeshMapping.f90 diff --git a/modules/nwtc-library/test/Test_MeshMapping/Test_MeshMapping_Mod.f90 b/modules/nwtc-library/Old_test/Test_MeshMapping/Test_MeshMapping_Mod.f90 similarity index 100% rename from modules/nwtc-library/test/Test_MeshMapping/Test_MeshMapping_Mod.f90 rename to modules/nwtc-library/Old_test/Test_MeshMapping/Test_MeshMapping_Mod.f90 diff --git a/modules/nwtc-library/test/Test_NWTC_Library.f90 b/modules/nwtc-library/Old_test/Test_NWTC_Library.f90 similarity index 100% rename from modules/nwtc-library/test/Test_NWTC_Library.f90 rename to modules/nwtc-library/Old_test/Test_NWTC_Library.f90 diff --git a/modules/nwtc-library/test/Test_OpenCon_GnuWin/Test_OpenCon_GnuWin.f90 b/modules/nwtc-library/Old_test/Test_OpenCon_GnuWin/Test_OpenCon_GnuWin.f90 similarity index 100% rename from modules/nwtc-library/test/Test_OpenCon_GnuWin/Test_OpenCon_GnuWin.f90 rename to modules/nwtc-library/Old_test/Test_OpenCon_GnuWin/Test_OpenCon_GnuWin.f90 diff --git a/modules/nwtc-library/test/Test_OpenCon_GnuWin/makefile b/modules/nwtc-library/Old_test/Test_OpenCon_GnuWin/makefile similarity index 100% rename from modules/nwtc-library/test/Test_OpenCon_GnuWin/makefile rename to modules/nwtc-library/Old_test/Test_OpenCon_GnuWin/makefile diff --git a/modules/nwtc-library/test/Test_ReadComFile/Test_ReadComFile.f90 b/modules/nwtc-library/Old_test/Test_ReadComFile/Test_ReadComFile.f90 similarity index 100% rename from modules/nwtc-library/test/Test_ReadComFile/Test_ReadComFile.f90 rename to modules/nwtc-library/Old_test/Test_ReadComFile/Test_ReadComFile.f90 diff --git a/modules/nwtc-library/test/Test_ReadComFile/makefile b/modules/nwtc-library/Old_test/Test_ReadComFile/makefile similarity index 100% rename from modules/nwtc-library/test/Test_ReadComFile/makefile rename to modules/nwtc-library/Old_test/Test_ReadComFile/makefile diff --git a/modules/nwtc-library/test/Test_ReadFASTbin.f90 b/modules/nwtc-library/Old_test/Test_ReadFASTbin.f90 similarity index 100% rename from modules/nwtc-library/test/Test_ReadFASTbin.f90 rename to modules/nwtc-library/Old_test/Test_ReadFASTbin.f90 diff --git a/modules/nwtc-library/test/Test_RegCubicSpline/Test_RegCubicSpline.f90 b/modules/nwtc-library/Old_test/Test_RegCubicSpline/Test_RegCubicSpline.f90 similarity index 100% rename from modules/nwtc-library/test/Test_RegCubicSpline/Test_RegCubicSpline.f90 rename to modules/nwtc-library/Old_test/Test_RegCubicSpline/Test_RegCubicSpline.f90 diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index 47da20580c..c42b4d8b33 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -23,7 +23,6 @@ MODULE NWTC_IO USE SysSubs USE NWTC_Library_Types ! ProgDesc and other types with copy and other routines for those types USE IEEE_ARITHMETIC - USE VersionInfo IMPLICIT NONE @@ -1496,181 +1495,7 @@ SUBROUTINE AllR16Ary5 ( Ary, AryDim1, AryDim2, AryDim3, AryDim4, AryDim5, Descr RETURN END SUBROUTINE AllR16Ary5 -!======================================================================= -!> This subroutine checks for command-line arguments. - SUBROUTINE CheckArgs ( Arg1, ErrStat, Arg2, Flag, InputArgArray ) - - ! Argument declarations: - CHARACTER(*), INTENT(INOUT) :: Arg1 !< The first non-flag argument; generally, the name of the input file. - INTEGER, INTENT( OUT), OPTIONAL :: ErrStat !< An optional argument for catching errors; if present, program does not abort on error. - CHARACTER(*), INTENT( OUT), OPTIONAL :: Arg2 !< An optional 2nd non-flag argument. - CHARACTER(*), INTENT( OUT), OPTIONAL :: Flag !< An optional flag argument; the first argument starting with a switch character. - CHARACTER(*), INTENT(IN ), DIMENSION(:), OPTIONAL :: InputArgArray !< An optional argument containing the arguments to parse; primarily used for unit testing. - - ! Local declarations: - INTEGER :: I, J ! Iterator variables - CHARACTER(1024) :: Arg, FlagIter - CHARACTER(1024), DIMENSION(:), ALLOCATABLE :: ArgArray, TempArray, Flags - LOGICAL :: FirstArgumentSet, SecondArgumentSet - - FirstArgumentSet = .FALSE. - SecondArgumentSet = .FALSE. - - IF ( PRESENT(Arg2) ) Arg2 = "" - IF ( PRESENT(Flag) ) Flag = "" - - ! Save all arguments in a single argument array; this is primarily used to enable unit testing - IF ( PRESENT(InputArgArray) ) THEN - ALLOCATE( ArgArray( SIZE(InputArgArray) ) ) - ArgArray = InputArgArray - ELSE - ALLOCATE( ArgArray( COMMAND_ARGUMENT_COUNT() ) ) - DO I = 1, SIZE(ArgArray) - CALL GET_COMMAND_LINE_ARG( I, ArgArray(I) ) - END DO - END IF - - ! Early return if no arguments and no default input file given - IF ( SIZE(ArgArray) == 0 .AND. LEN( TRIM(Arg1) ) == 0 ) THEN - CALL INVALID_SYNTAX( 'no command-line arguments given.' ) - CALL CLEANUP() - RETURN - END IF - - ! Split arguments into flags and non-flags - ALLOCATE( Flags(0) ) - DO I = 1, SIZE(ArgArray) - Arg = TRIM(ArgArray(I)) - IF ( IsFlag(Arg) ) THEN - ! This is how we can dynamically resize an array in Fortran... - ! Dont do this where performance matters. - ALLOCATE( TempArray( SIZE(Flags) + 1 ) ) - DO J = 1, SIZE(Flags) - TempArray(J) = Flags(J) - END DO - TempArray(SIZE(Flags) + 1) = TRIM(Arg) - DEALLOCATE(Flags) - CALL MOVE_ALLOC(TempArray, Flags) - ELSE IF ( .NOT. FirstArgumentSet ) THEN - Arg1 = TRIM(Arg) - FirstArgumentSet = .TRUE. - ELSE IF ( .NOT. SecondArgumentSet ) THEN - Arg2 = TRIM(Arg) - SecondArgumentSet = .True. - ELSE - CALL INVALID_SYNTAX( 'too many command-line arguments given.' ) - CALL CLEANUP() - RETURN - END IF - END DO - - DO I = 1, SIZE(Flags) - - FlagIter = Flags(I)(2:) ! This results in the flag without the switch character - CALL Conv2UC( FlagIter ) - IF ( PRESENT(Flag) ) Flag = FlagIter - - SELECT CASE ( TRIM(FlagIter) ) - - CASE ('H') - CALL DispCopyrightLicense( ProgName ) - CALL DispCompileRuntimeInfo - CALL NWTC_DisplaySyntax( Arg1, ProgName ) - IF ( PRESENT( ErrStat ) ) ErrStat = ErrID_None - CALL CLEANUP() - RETURN - - CASE ('V', 'VERSION') - CALL DispCopyrightLicense( ProgName ) - CALL DispCompileRuntimeInfo - IF ( PRESENT( ErrStat ) ) ErrStat = ErrID_None - CALL CLEANUP() - RETURN - - CASE ('RESTART') - IF ( FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN - Arg2 = Arg1 - Arg1 = "" - END IF - IF ( .NOT. FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN - CALL INVALID_SYNTAX( 'the restart capability requires at least one argument: -restart ' ) - CALL CLEANUP() - RETURN - END IF - - CASE ('VTKLIN') - IF ( FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN - Arg2 = Arg1 - Arg1 = "" - END IF - IF ( .NOT. FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN - CALL INVALID_SYNTAX( 'the restart capability for vtk mode shapes requires at least one argument: -vtklin ' ) - CALL CLEANUP() - RETURN - END IF - CASE DEFAULT - CALL INVALID_SYNTAX( 'unknown command-line argument given: '//TRIM(FlagIter) ) - CALL CLEANUP() - RETURN - - END SELECT - - END DO - - IF ( PRESENT( ErrStat ) ) ErrStat = ErrID_None - CALL CLEANUP() - - RETURN - - CONTAINS - SUBROUTINE CLEANUP() - IF ( ALLOCATED(ArgArray) ) DEALLOCATE(ArgArray) - IF ( ALLOCATED(Flags) ) DEALLOCATE(Flags) - IF ( ALLOCATED(TempArray) ) DEALLOCATE(TempArray) - END SUBROUTINE - - SUBROUTINE INVALID_SYNTAX(ErrorMessage) - - CHARACTER(*), INTENT(IN) :: ErrorMessage - - CALL DispCopyrightLicense( ProgName ) - CALL DispCompileRuntimeInfo - CALL NWTC_DisplaySyntax( Arg1, ProgName ) - CALL ProgAbort( ' Invalid syntax: '//TRIM(ErrorMessage), PRESENT(ErrStat) ) - IF ( PRESENT(ErrStat) ) ErrStat = ErrID_Fatal - - END SUBROUTINE - - SUBROUTINE GET_COMMAND_LINE_ARG(ArgIndex, ArgGiven) - - INTEGER, INTENT(IN) :: ArgIndex !< Index location of the argument to get. - CHARACTER(1024), INTENT(OUT) :: ArgGiven !< The gotten command-line argument. - INTEGER :: Error !< Indicates if there was an error getting an argument. - - CALL GET_COMMAND_ARGUMENT( ArgIndex, ArgGiven, STATUS=Error ) - ArgGiven = TRIM(ArgGiven) - IF ( Error /= 0 ) THEN - CALL ProgAbort ( ' Error getting command-line argument #'//TRIM( Int2LStr( ArgIndex ) )//'.', PRESENT(ErrStat) ) - IF ( PRESENT(ErrStat) ) ErrStat = ErrID_Fatal - END IF - - END SUBROUTINE - - FUNCTION IsFlag(ArgString) - - CHARACTER(*), INTENT(IN) :: ArgString - LOGICAL :: IsFlag - - IF ( ArgString(1:1) == SwChar .OR. ArgString(1:1) == '-' ) THEN - IsFlag = .TRUE. - ELSE - IsFlag = .FALSE. - END IF - - END FUNCTION - - END SUBROUTINE CheckArgs !======================================================================= !> This subroutine checks the data to be parsed to make sure it finds !! the expected variable name and an associated value. @@ -2259,65 +2084,6 @@ SUBROUTINE DLLTypeUnPack( OutData, ReKiBuf, DbKiBuf, IntKiBuf, ErrStat, ErrMsg ) END SUBROUTINE DLLTypeUnPack !======================================================================= -!> - SUBROUTINE DispCompileRuntimeInfo() -#ifdef _OPENMP - USE OMP_LIB -#endif -#ifdef HAS_FORTRAN2008_FEATURES - USE iso_fortran_env, ONLY: compiler_version -#endif - CHARACTER(200) :: compiler_version_str - CHARACTER(200) :: name - CHARACTER(200) :: git_commit, architecture, compiled_precision - CHARACTER(200) :: execution_date, execution_time, execution_zone - - name = ProgName - git_commit = QueryGitVersion() - architecture = TRIM(Num2LStr(BITS_IN_ADDR))//' bit' - IF (ReKi == SiKi) THEN - compiled_precision = 'single' - ELSE IF (ReKi == R8Ki) THEN - compiled_precision = 'double' - ELSE - compiled_precision = 'unknown' - END IF - -#if defined(HAS_FORTRAN2008_FEATURES) - compiler_version_str = compiler_version() -#elif defined(__INTEL_COMPILER) - compiler_version_str = 'Intel(R) Fortran Compiler '//num2lstr(__INTEL_COMPILER) -#else - compiler_version_str = OS_Desc -#endif - - CALL WrScr(trim(name)//'-'//trim(git_commit)) - CALL WrScr('Compile Info:') - call wrscr(' - Compiler: '//trim(compiler_version_str)) - CALL WrScr(' - Architecture: '//trim(architecture)) - CALL WrScr(' - Precision: '//trim(compiled_precision)) -#ifdef _OPENMP - !$OMP PARALLEL default(shared) - if (omp_get_thread_num()==0) then - call WrScr(' - OpenMP: Yes, number of threads: '//trim(Num2LStr(omp_get_num_threads()))//'/'//trim(Num2LStr(omp_get_max_threads()))) - endif - !$OMP END PARALLEL -#else - call WrScr(' - OpenMP: No') -#endif - CALL WrScr(' - Date: '//__DATE__) - CALL WrScr(' - Time: '//__TIME__) - ! call wrscr(' - Options: '//trim(compiler_options())) - - CALL DATE_AND_TIME(execution_date, execution_time, execution_zone) - - CALL WrScr('Execution Info:') - CALL WrScr(' - Date: '//TRIM(execution_date(5:6)//'/'//execution_date(7:8)//'/'//execution_date(1:4))) - CALL WrScr(' - Time: '//TRIM(execution_time(1:2)//':'//execution_time(3:4)//':'//execution_time(5:6))//TRIM(execution_zone)) - CALL WrScr('') - - END SUBROUTINE -!======================================================================= !> This routine displays the name of the program, its version, and its release date. !! Use DispNVD (nwtc_io::dispnvd) instead of directly calling a specific routine in the generic interface. SUBROUTINE DispNVD0() diff --git a/modules/openfast-library/src/FAST_Subs.f90 b/modules/openfast-library/src/FAST_Subs.f90 index a8608b2b3f..3a6fb654d4 100644 --- a/modules/openfast-library/src/FAST_Subs.f90 +++ b/modules/openfast-library/src/FAST_Subs.f90 @@ -24,6 +24,7 @@ MODULE FAST_Subs USE FAST_Solver USE FAST_Linear USE SC_DataEx + USE VersionInfo IMPLICIT NONE @@ -1512,48 +1513,6 @@ END SUBROUTINE SetSrvDCableControls END SUBROUTINE FAST_InitializeAll -!---------------------------------------------------------------------------------------------------------------------------------- -!> This function returns a string describing the glue code and some of the compilation options we're using. -FUNCTION GetVersion(ThisProgVer) - - ! Passed Variables: - - TYPE(ProgDesc), INTENT( IN ) :: ThisProgVer !< program name/date/version description - CHARACTER(1024) :: GetVersion !< String containing a description of the compiled precision. - - CHARACTER(200) :: git_commit - - GetVersion = TRIM(GetNVD(ThisProgVer))//', compiled' - - IF ( Cmpl4SFun ) THEN ! FAST has been compiled as an S-Function for Simulink - GetVersion = TRIM(GetVersion)//' as a DLL S-Function for Simulink' - ELSEIF ( Cmpl4LV ) THEN ! FAST has been compiled as a DLL for Labview - GetVersion = TRIM(GetVersion)//' as a DLL for LabVIEW' - ENDIF - - GetVersion = TRIM(GetVersion)//' as a '//TRIM(Num2LStr(BITS_IN_ADDR))//'-bit application using' - - ! determine precision - - IF ( ReKi == SiKi ) THEN ! Single precision - GetVersion = TRIM(GetVersion)//' single' - ELSEIF ( ReKi == R8Ki ) THEN ! Double precision - GetVersion = TRIM(GetVersion)// ' double' - ELSE ! Unknown precision - GetVersion = TRIM(GetVersion)//' unknown' - ENDIF - - -! GetVersion = TRIM(GetVersion)//' precision with '//OS_Desc - GetVersion = TRIM(GetVersion)//' precision' - - ! add git info - git_commit = QueryGitVersion() - GetVersion = TRIM(GetVersion)//' at commit '//git_commit - - RETURN -END FUNCTION GetVersion - !---------------------------------------------------------------------------------------------------------------------------------- !> This subroutine is called at the start (or restart) of a FAST program (or FAST.Farm). It initializes the NWTC subroutine library, !! displays the copyright notice, and displays some version information (including addressing scheme and precision). @@ -1564,10 +1523,9 @@ SUBROUTINE FAST_ProgStart(ThisProgVer) ! sets the pi constants, open console for output, etc... CALL NWTC_Init( ProgNameIN=ThisProgVer%Name, EchoLibVer=.FALSE. ) - ! Display the copyright notice + ! Display the copyright notice and compile info: CALL DispCopyrightLicense( ThisProgVer%Name ) - - CALL DispCompileRuntimeInfo + CALL DispCompileRuntimeInfo( ThisProgVer%Name ) END SUBROUTINE FAST_ProgStart !---------------------------------------------------------------------------------------------------------------------------------- @@ -2006,7 +1964,7 @@ SUBROUTINE FAST_InitOutput( p_FAST, y_FAST, Init, ErrStat, ErrMsg ) !...................................................... ! Set the description lines to be printed in the output file !...................................................... - y_FAST%FileDescLines(1) = 'Predictions were generated on '//CurDate()//' at '//CurTime()//' using '//TRIM(GetVersion(FAST_Ver)) + y_FAST%FileDescLines(1) = 'Predictions were generated on '//CurDate()//' at '//CurTime()//' using '//TRIM(GetVersion(FAST_Ver, Cmpl4SFun, Cmpl4LV)) y_FAST%FileDescLines(2) = 'linked with ' //' '//TRIM(GetNVD(NWTC_Ver )) ! we'll get the rest of the linked modules in the section below y_FAST%FileDescLines(3) = 'Description from the FAST input file: '//TRIM(p_FAST%FTitle) diff --git a/modules/servodyn/CMakeLists.txt b/modules/servodyn/CMakeLists.txt index 342392810e..0f74f81919 100644 --- a/modules/servodyn/CMakeLists.txt +++ b/modules/servodyn/CMakeLists.txt @@ -36,7 +36,7 @@ add_library(servodynlib ${SrvD_SOURCES}) target_link_libraries(servodynlib nwtclibs) add_executable(servodyn_driver src/ServoDyn_Driver.f90) -target_link_libraries(servodyn_driver servodynlib nwtclibs ${CMAKE_DL_LIBS}) +target_link_libraries(servodyn_driver servodynlib nwtclibs versioninfolib ${CMAKE_DL_LIBS}) # The Structural Control driver is currently not functional, so commenting this temporarily # add_executable(strucctrl_driver src/StrucCtrl_Driver.f90) diff --git a/modules/servodyn/src/ServoDyn_Driver.f90 b/modules/servodyn/src/ServoDyn_Driver.f90 index 6bc6d0ef47..4de06f0ee0 100644 --- a/modules/servodyn/src/ServoDyn_Driver.f90 +++ b/modules/servodyn/src/ServoDyn_Driver.f90 @@ -23,6 +23,7 @@ PROGRAM SrvD_Driver USE NWTC_Library USE ServoDyn USE ServoDyn_Types + USE VersionInfo IMPLICIT NONE diff --git a/modules/version/CMakeLists.txt b/modules/version/CMakeLists.txt index 1a1b0af02d..34a7891b3e 100644 --- a/modules/version/CMakeLists.txt +++ b/modules/version/CMakeLists.txt @@ -28,6 +28,8 @@ endif() add_definitions(-DGIT_VERSION_INFO="${GIT_DESCRIBE}") add_library(versioninfolib src/VersionInfo.f90) +target_link_libraries(versioninfolib nwtclibs) + install(TARGETS versioninfolib EXPORT "${CMAKE_PROJECT_NAME}Libraries" diff --git a/modules/version/README.md b/modules/version/README.md index f2efaabd76..0d79b7d4f8 100644 --- a/modules/version/README.md +++ b/modules/version/README.md @@ -18,3 +18,9 @@ For example, ``OpenFAST-v1.0.0-123-gabcd1234-dirty`` describes OpenFAST as: build [the ``-g`` is for ``git``] - abcd1234 is the first 8 characters of the current commit hash - dirty denotes that local changes have been made but not committed + +To make use of version information when checking command-line arguments, +the `CheckArgs` routine that was previously in NWTC_Library has been moved +to this module. This ensures that the version information does not have to +be one of the first modules to be compiled. (The goal is that NWTC Library +does not depend on the VersionInfo module.) diff --git a/modules/version/src/VersionInfo.f90 b/modules/version/src/VersionInfo.f90 index 27dbc73e7b..1f03e97a90 100644 --- a/modules/version/src/VersionInfo.f90 +++ b/modules/version/src/VersionInfo.f90 @@ -20,6 +20,7 @@ !********************************************************************************************************************************** MODULE VersionInfo + use NWTC_Library implicit none contains @@ -42,4 +43,291 @@ FUNCTION QueryGitVersion() RETURN END FUNCTION QueryGitVersion + +!---------------------------------------------------------------------------------------------------------------------------------- +!> This function returns a string describing the glue code and some of the compilation options we're using. +FUNCTION GetVersion(ThisProgVer, Cmpl4SFun, Cmpl4LV) + + ! Passed Variables: + + TYPE(ProgDesc), INTENT( IN ) :: ThisProgVer !< program name/date/version description + LOGICAL, INTENT(IN), OPTIONAL :: Cmpl4SFun + LOGICAL, INTENT(IN), OPTIONAL :: Cmpl4LV + CHARACTER(1024) :: GetVersion !< String containing a description of the compiled precision. + + CHARACTER(200) :: git_commit + + GetVersion = TRIM(GetNVD(ThisProgVer))//', compiled' + + if (present(Cmpl4SFun)) then + IF ( Cmpl4SFun ) THEN ! FAST has been compiled as an S-Function for Simulink + GetVersion = TRIM(GetVersion)//' as a DLL S-Function for Simulink' + ENDIF + endif + + if (present(Cmpl4LV)) then + IF ( Cmpl4LV ) THEN ! FAST has been compiled as a DLL for Labview + GetVersion = TRIM(GetVersion)//' as a DLL for LabVIEW' + ENDIF + endif + + GetVersion = TRIM(GetVersion)//' as a '//TRIM(Num2LStr(BITS_IN_ADDR))//'-bit application using' + + ! determine precision + + IF ( ReKi == SiKi ) THEN ! Single precision + GetVersion = TRIM(GetVersion)//' single' + ELSEIF ( ReKi == R8Ki ) THEN ! Double precision + GetVersion = TRIM(GetVersion)// ' double' + ELSE ! Unknown precision + GetVersion = TRIM(GetVersion)//' unknown' + ENDIF + + +! GetVersion = TRIM(GetVersion)//' precision with '//OS_Desc + GetVersion = TRIM(GetVersion)//' precision' + + ! add git info + git_commit = QueryGitVersion() + GetVersion = TRIM(GetVersion)//' at commit '//git_commit + + RETURN +END FUNCTION GetVersion + +!======================================================================= +!> + SUBROUTINE DispCompileRuntimeInfo(name) +#ifdef _OPENMP + USE OMP_LIB +#endif +#ifdef HAS_FORTRAN2008_FEATURES + USE iso_fortran_env, ONLY: compiler_version +#endif + CHARACTER(*), intent(in) :: name + CHARACTER(200) :: compiler_version_str + CHARACTER(200) :: git_commit, architecture, compiled_precision + CHARACTER(200) :: execution_date, execution_time, execution_zone + +! name = ProgName + git_commit = QueryGitVersion() + architecture = TRIM(Num2LStr(BITS_IN_ADDR))//' bit' + IF (ReKi == SiKi) THEN + compiled_precision = 'single' + ELSE IF (ReKi == R8Ki) THEN + compiled_precision = 'double' + ELSE + compiled_precision = 'unknown' + END IF + +#if defined(HAS_FORTRAN2008_FEATURES) + compiler_version_str = compiler_version() +#elif defined(__INTEL_COMPILER) + compiler_version_str = 'Intel(R) Fortran Compiler '//num2lstr(__INTEL_COMPILER) +#else + compiler_version_str = OS_Desc +#endif + + CALL WrScr(trim(name)//'-'//trim(git_commit)) + CALL WrScr('Compile Info:') + call wrscr(' - Compiler: '//trim(compiler_version_str)) + CALL WrScr(' - Architecture: '//trim(architecture)) + CALL WrScr(' - Precision: '//trim(compiled_precision)) +#ifdef _OPENMP + !$OMP PARALLEL default(shared) + if (omp_get_thread_num()==0) then + call WrScr(' - OpenMP: Yes, number of threads: '//trim(Num2LStr(omp_get_num_threads()))//'/'//trim(Num2LStr(omp_get_max_threads()))) + endif + !$OMP END PARALLEL +#else + call WrScr(' - OpenMP: No') +#endif + CALL WrScr(' - Date: '//__DATE__) + CALL WrScr(' - Time: '//__TIME__) + ! call wrscr(' - Options: '//trim(compiler_options())) + + CALL DATE_AND_TIME(execution_date, execution_time, execution_zone) + + CALL WrScr('Execution Info:') + CALL WrScr(' - Date: '//TRIM(execution_date(5:6)//'/'//execution_date(7:8)//'/'//execution_date(1:4))) + CALL WrScr(' - Time: '//TRIM(execution_time(1:2)//':'//execution_time(3:4)//':'//execution_time(5:6))//TRIM(execution_zone)) + CALL WrScr('') + + END SUBROUTINE DispCompileRuntimeInfo + +!======================================================================= +!> This subroutine checks for command-line arguments. + SUBROUTINE CheckArgs ( Arg1, ErrStat, Arg2, Flag, InputArgArray ) + + ! Argument declarations: + CHARACTER(*), INTENT(INOUT) :: Arg1 !< The first non-flag argument; generally, the name of the input file. + INTEGER, INTENT( OUT), OPTIONAL :: ErrStat !< An optional argument for catching errors; if present, program does not abort on error. + CHARACTER(*), INTENT( OUT), OPTIONAL :: Arg2 !< An optional 2nd non-flag argument. + CHARACTER(*), INTENT( OUT), OPTIONAL :: Flag !< An optional flag argument; the first argument starting with a switch character. + CHARACTER(*), INTENT(IN ), DIMENSION(:), OPTIONAL :: InputArgArray !< An optional argument containing the arguments to parse; primarily used for unit testing. + + ! Local declarations: + INTEGER :: I, J ! Iterator variables + CHARACTER(1024) :: Arg, FlagIter + CHARACTER(1024), DIMENSION(:), ALLOCATABLE :: ArgArray, TempArray, Flags + LOGICAL :: FirstArgumentSet, SecondArgumentSet + + FirstArgumentSet = .FALSE. + SecondArgumentSet = .FALSE. + + IF ( PRESENT(Arg2) ) Arg2 = "" + IF ( PRESENT(Flag) ) Flag = "" + + ! Save all arguments in a single argument array; this is primarily used to enable unit testing + IF ( PRESENT(InputArgArray) ) THEN + ALLOCATE( ArgArray( SIZE(InputArgArray) ) ) + ArgArray = InputArgArray + ELSE + ALLOCATE( ArgArray( COMMAND_ARGUMENT_COUNT() ) ) + DO I = 1, SIZE(ArgArray) + CALL GET_COMMAND_LINE_ARG( I, ArgArray(I) ) + END DO + END IF + + ! Early return if no arguments and no default input file given + IF ( SIZE(ArgArray) == 0 .AND. LEN( TRIM(Arg1) ) == 0 ) THEN + CALL INVALID_SYNTAX( 'no command-line arguments given.' ) + CALL CLEANUP() + RETURN + END IF + + ! Split arguments into flags and non-flags + ALLOCATE( Flags(0) ) + DO I = 1, SIZE(ArgArray) + Arg = TRIM(ArgArray(I)) + IF ( IsFlag(Arg) ) THEN + ! This is how we can dynamically resize an array in Fortran... + ! Dont do this where performance matters. + ALLOCATE( TempArray( SIZE(Flags) + 1 ) ) + DO J = 1, SIZE(Flags) + TempArray(J) = Flags(J) + END DO + TempArray(SIZE(Flags) + 1) = TRIM(Arg) + DEALLOCATE(Flags) + CALL MOVE_ALLOC(TempArray, Flags) + ELSE IF ( .NOT. FirstArgumentSet ) THEN + Arg1 = TRIM(Arg) + FirstArgumentSet = .TRUE. + ELSE IF ( .NOT. SecondArgumentSet ) THEN + Arg2 = TRIM(Arg) + SecondArgumentSet = .True. + ELSE + CALL INVALID_SYNTAX( 'too many command-line arguments given.' ) + CALL CLEANUP() + RETURN + END IF + END DO + + DO I = 1, SIZE(Flags) + + FlagIter = Flags(I)(2:) ! This results in the flag without the switch character + CALL Conv2UC( FlagIter ) + IF ( PRESENT(Flag) ) Flag = FlagIter + + SELECT CASE ( TRIM(FlagIter) ) + + CASE ('H') + CALL DispCopyrightLicense( ProgName ) + CALL DispCompileRuntimeInfo( ProgName ) + CALL NWTC_DisplaySyntax( Arg1, ProgName ) + IF ( PRESENT( ErrStat ) ) ErrStat = ErrID_None + CALL CLEANUP() + RETURN + + CASE ('V', 'VERSION') + CALL DispCopyrightLicense( ProgName ) + CALL DispCompileRuntimeInfo( ProgName ) + IF ( PRESENT( ErrStat ) ) ErrStat = ErrID_None + CALL CLEANUP() + RETURN + + CASE ('RESTART') + IF ( FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN + Arg2 = Arg1 + Arg1 = "" + END IF + IF ( .NOT. FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN + CALL INVALID_SYNTAX( 'the restart capability requires at least one argument: -restart ' ) + CALL CLEANUP() + RETURN + END IF + + CASE ('VTKLIN') + IF ( FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN + Arg2 = Arg1 + Arg1 = "" + END IF + IF ( .NOT. FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN + CALL INVALID_SYNTAX( 'the restart capability for vtk mode shapes requires at least one argument: -vtklin ' ) + CALL CLEANUP() + RETURN + END IF + + CASE DEFAULT + CALL INVALID_SYNTAX( 'unknown command-line argument given: '//TRIM(FlagIter) ) + CALL CLEANUP() + RETURN + + END SELECT + + END DO + + IF ( PRESENT( ErrStat ) ) ErrStat = ErrID_None + CALL CLEANUP() + + RETURN + + CONTAINS + SUBROUTINE CLEANUP() + IF ( ALLOCATED(ArgArray) ) DEALLOCATE(ArgArray) + IF ( ALLOCATED(Flags) ) DEALLOCATE(Flags) + IF ( ALLOCATED(TempArray) ) DEALLOCATE(TempArray) + END SUBROUTINE + + SUBROUTINE INVALID_SYNTAX(ErrorMessage) + + CHARACTER(*), INTENT(IN) :: ErrorMessage + + CALL DispCopyrightLicense( ProgName ) + CALL DispCompileRuntimeInfo( ProgName ) + CALL NWTC_DisplaySyntax( Arg1, ProgName ) + CALL ProgAbort( ' Invalid syntax: '//TRIM(ErrorMessage), PRESENT(ErrStat) ) + IF ( PRESENT(ErrStat) ) ErrStat = ErrID_Fatal + + END SUBROUTINE + + SUBROUTINE GET_COMMAND_LINE_ARG(ArgIndex, ArgGiven) + + INTEGER, INTENT(IN) :: ArgIndex !< Index location of the argument to get. + CHARACTER(1024), INTENT(OUT) :: ArgGiven !< The gotten command-line argument. + INTEGER :: Error !< Indicates if there was an error getting an argument. + + CALL GET_COMMAND_ARGUMENT( ArgIndex, ArgGiven, STATUS=Error ) + ArgGiven = TRIM(ArgGiven) + IF ( Error /= 0 ) THEN + CALL ProgAbort ( ' Error getting command-line argument #'//TRIM( Int2LStr( ArgIndex ) )//'.', PRESENT(ErrStat) ) + IF ( PRESENT(ErrStat) ) ErrStat = ErrID_Fatal + END IF + + END SUBROUTINE + + FUNCTION IsFlag(ArgString) + + CHARACTER(*), INTENT(IN) :: ArgString + LOGICAL :: IsFlag + + IF ( ArgString(1:1) == SwChar .OR. ArgString(1:1) == '-' ) THEN + IsFlag = .TRUE. + ELSE + IsFlag = .FALSE. + END IF + + END FUNCTION + + END SUBROUTINE CheckArgs + END MODULE diff --git a/modules/version/tests/VersionInfo_test_tools.F90 b/modules/version/tests/VersionInfo_test_tools.F90 new file mode 100644 index 0000000000..30e67ae0f7 --- /dev/null +++ b/modules/version/tests/VersionInfo_test_tools.F90 @@ -0,0 +1,27 @@ +module versioninfo_test_tools + +use NWTC_IO + +implicit none + +#ifdef _WIN32 + character(9), parameter :: nullfile="NUL" + character(11), parameter :: terminal="CON" +#else + character(9), parameter :: nullfile="/dev/null" + character(11), parameter :: terminal="/dev/stdout" +#endif + +integer, parameter :: stdout=CU + +contains + +subroutine hide_terminal_output() + open(unit=stdout, file=trim(nullfile)) +end subroutine + +subroutine show_terminal_output() + open(unit=stdout, file=terminal, status="old") +end subroutine + +end module diff --git a/modules/nwtc-library/tests/test_NWTC_IO_CheckArgs.F90 b/modules/version/tests/test_VersionInfo_CheckArgs.F90 similarity index 99% rename from modules/nwtc-library/tests/test_NWTC_IO_CheckArgs.F90 rename to modules/version/tests/test_VersionInfo_CheckArgs.F90 index 49b4d207e1..78e0b7722b 100644 --- a/modules/nwtc-library/tests/test_NWTC_IO_CheckArgs.F90 +++ b/modules/version/tests/test_VersionInfo_CheckArgs.F90 @@ -1,13 +1,13 @@ -module test_NWTC_IO_CheckArgs +module test_VersionInfo_CheckArgs use pFUnit_mod - use NWTC_IO - use nwtc_library_test_tools + use VersionInfo + use versioninfo_test_tools implicit none -contains - + contains + ! PASSING CASES ! ************************************************************************ diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index 4339b0c437..3278ec162e 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -73,8 +73,9 @@ add_subdirectory("beamdyn") add_subdirectory("nwtc-library") add_subdirectory("aerodyn") add_subdirectory("inflowwind") +add_subdirectory("version") add_custom_target( unit_tests - DEPENDS beamdyn_utest nwtc_library_utest fvw_utest inflowwind_utest + DEPENDS beamdyn_utest nwtc_library_utest fvw_utest inflowwind_utest versioninfo_utest ) diff --git a/unit_tests/nwtc-library/CMakeLists.txt b/unit_tests/nwtc-library/CMakeLists.txt index a78dda84b2..cb338b649f 100644 --- a/unit_tests/nwtc-library/CMakeLists.txt +++ b/unit_tests/nwtc-library/CMakeLists.txt @@ -32,7 +32,6 @@ include_directories( set(testlist NWTC_Library_test_tools - test_NWTC_IO_CheckArgs test_NWTC_IO_FileInfo test_NWTC_RandomNumber ) diff --git a/unit_tests/version/CMakeLists.txt b/unit_tests/version/CMakeLists.txt new file mode 100644 index 0000000000..7c7ced8c0a --- /dev/null +++ b/unit_tests/version/CMakeLists.txt @@ -0,0 +1,64 @@ +# +# Copyright 2017 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# 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. +# + +# Tell CMake not to look for this file to exist since its generated by pFUnit during compile +set_source_files_properties(${pfunit_directory}/include/driver.F90 PROPERTIES GENERATED 1) + +set(module_name "versioninfo") +set(module_directory "version") +set(module_library "versioninfolib") + +file(MAKE_DIRECTORY ${build_testdirectory}/${module_directory}) +file(WRITE ${build_testdirectory}/${module_directory}/testSuites.inc "") + +include_directories( + ${PROJECT_SOURCE_DIR} + ${pfunit_directory}/mod + ${build_testdirectory}/${module_directory} +) + +set(testlist + VersionInfo_test_tools + test_VersionInfo_CheckArgs +) +foreach(test ${testlist}) + set(test_dependency pfunit ${source_modulesdirectory}/${module_directory}/tests/${test}.F90) + add_custom_command( + OUTPUT ${build_testdirectory}/${module_directory}/${test}.F90 + COMMAND ${PYTHON_EXECUTABLE} ${pfunit_directory}/bin/pFUnitParser.py ${source_modulesdirectory}/${module_directory}/tests/${test}.F90 ${build_testdirectory}/${module_directory}/${test}.F90 + DEPENDS ${test_dependency} + ) + set(test_sources ${test_sources} ${build_testdirectory}/${module_directory}/${test}.F90) + file(APPEND ${build_testdirectory}/${module_directory}/testSuites.inc "ADD_TEST_SUITE(${test}_suite)\n") +endforeach() + +add_executable( + ${module_name}_utest + ${pfunit_directory}/include/driver.F90 + ${test_sources} +) + +target_link_libraries( + ${module_name}_utest + ${pfunit_directory}${pfunit_lib} + ${module_library} +) + +add_test( + ${module_name}_utest + ${PROJECT_BINARY_DIR}/${module_directory}/${module_name}_utest +) +