From f24ff7869302d765ac39b89b8aa3a62e4ba23f1b Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 24 Mar 2020 16:26:46 -0500 Subject: [PATCH 01/12] Add support for a version flag --- glue-codes/openfast/src/FAST_Prog.f90 | 9 +++++---- modules/nwtc-library/src/NWTC_IO.f90 | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/glue-codes/openfast/src/FAST_Prog.f90 b/glue-codes/openfast/src/FAST_Prog.f90 index ef0d4b1d70..8dbb76dedd 100644 --- a/glue-codes/openfast/src/FAST_Prog.f90 +++ b/glue-codes/openfast/src/FAST_Prog.f90 @@ -63,12 +63,13 @@ PROGRAM FAST CALL CheckArgs( InputFile, Flag=FlagArg, Arg2=CheckpointRoot ) - IF ( TRIM(FlagArg) == 'H' ) THEN ! Exit after help prompt - CALL NormStop() - - ELSE IF ( TRIM(FlagArg) == 'RESTART' ) THEN ! Restart from checkpoint file + IF ( TRIM(FlagArg) == 'RESTART' ) THEN ! Restart from checkpoint file CALL FAST_RestoreFromCheckpoint_Tary(t_initial, Restart_step, Turbine, CheckpointRoot, ErrStat, ErrMsg ) CALL CheckError( ErrStat, ErrMsg, 'during restore from checkpoint' ) + + ELSEIF ( LEN( TRIM(FlagArg) ) > 0 ) THEN ! Any other flag, end normally + CALL NormStop() + ELSE Restart_step = 0 diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index 77bdede750..d1916a8c00 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -1550,10 +1550,18 @@ SUBROUTINE CheckArgs ( Arg1, ErrStat, Arg2, Flag, InputArgArray ) SELECT CASE ( TRIM(Flag) ) CASE ('H') + CALL DispCopyrightLicense( ProgName ) + CALL DispCompileRuntimeInfo CALL NWTC_DisplaySyntax( Arg1, ProgName ) CALL CLEANUP() RETURN + CASE ('V', 'VERSION') + CALL DispCopyrightLicense( ProgName ) + CALL DispCompileRuntimeInfo + CALL CLEANUP() + RETURN + CASE ('RESTART') IF ( FirstArgumentSet .AND. .NOT. SecondArgumentSet ) THEN Arg2 = Arg1 From 59a520b4e8ee871e34edc997f7fc8e49423917c7 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 24 Mar 2020 16:49:02 -0500 Subject: [PATCH 02/12] Include program compile, runtime info in NWTC Lib --- modules/nwtc-library/CMakeLists.txt | 4 +- modules/nwtc-library/src/NWTC_IO.f90 | 42 +++++++++++++++++- modules/openfast-library/src/FAST_Subs.f90 | 50 +--------------------- 3 files changed, 43 insertions(+), 53 deletions(-) diff --git a/modules/nwtc-library/CMakeLists.txt b/modules/nwtc-library/CMakeLists.txt index 915587467a..6e055f5969 100644 --- a/modules/nwtc-library/CMakeLists.txt +++ b/modules/nwtc-library/CMakeLists.txt @@ -77,9 +77,9 @@ add_library(nwtclibs ${NWTCLIBS_SOURCES}) if(BUILD_OPENFAST_SIMULINK_API) find_package(Matlab REQUIRED) - target_link_libraries(nwtclibs ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS} ${Matlab_MEX_LIBRARY}) + target_link_libraries(nwtclibs versioninfolib ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS} ${Matlab_MEX_LIBRARY}) else() - target_link_libraries(nwtclibs ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS}) + target_link_libraries(nwtclibs versioninfolib ${LAPACK_LIBRARIES} ${CMAKE_DL_LIBS}) endif() install(TARGETS nwtclibs diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index d1916a8c00..b54209f6f6 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -20,8 +20,9 @@ !> This module contains I/O-related variables and routines with non-system-specific logic. MODULE NWTC_IO - USE SysSubs - USE NWTC_Library_Types ! ProgDesc and other types with copy and other routines for those types + USE SysSubs + USE NWTC_Library_Types ! ProgDesc and other types with copy and other routines for those types + USE VersionInfo IMPLICIT NONE @@ -2171,7 +2172,44 @@ SUBROUTINE DLLTypeUnPack( OutData, ReKiBuf, DbKiBuf, IntKiBuf, ErrStat, ErrMsg ) END IF END SUBROUTINE DLLTypeUnPack +!======================================================================= +!> + SUBROUTINE DispCompileRuntimeInfo() + + USE iso_fortran_env, ONLY: compiler_options, compiler_version + + 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 + + CALL WrScr(trim(name)//'-'//trim(git_commit)) + CALL WrScr('Compile Info:') + call wrscr(' - Compiler: '//trim(compiler_version())) + CALL WrScr(' - Architecture: '//trim(architecture)) + CALL WrScr(' - Precision: '//trim(compiled_precision)) + 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. diff --git a/modules/openfast-library/src/FAST_Subs.f90 b/modules/openfast-library/src/FAST_Subs.f90 index 338ada5769..744c24fb22 100644 --- a/modules/openfast-library/src/FAST_Subs.f90 +++ b/modules/openfast-library/src/FAST_Subs.f90 @@ -23,7 +23,6 @@ MODULE FAST_Subs USE FAST_Solver USE FAST_Linear - USE VersionInfo IMPLICIT NONE @@ -1363,31 +1362,6 @@ FUNCTION GetVersion(ThisProgVer) RETURN END FUNCTION GetVersion -!---------------------------------------------------------------------------------------------------------------------------------- -!> This subroutine parses and compiles the relevant version and compile data for a givne program -subroutine GetProgramMetadata(ThisProgVer, name, version, git_commit, architecture, precision) - - TYPE(ProgDesc), INTENT(IN ) :: ThisProgVer !< program name/date/version description - character(200), intent(out) :: name, version - character(200), intent(out) :: git_commit, architecture, precision - - name = trim(ThisProgVer%Name) - version = trim(ThisProgVer%Ver) - - git_commit = QueryGitVersion() - - architecture = TRIM(Num2LStr(BITS_IN_ADDR))//' bit' - - if (ReKi == SiKi) then - precision = 'single' - else if (ReKi == R8Ki) then - precision = 'double' - else - precision = 'unknown' - end if - -end subroutine GetProgramMetadata - !---------------------------------------------------------------------------------------------------------------------------------- !> 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). @@ -1404,31 +1378,9 @@ SUBROUTINE FAST_ProgStart(ThisProgVer) ! Display the copyright notice CALL DispCopyrightLicense( ThisProgVer ) - ! Display the program metadata - call GetProgramMetadata(ThisProgVer, name, version, git_commit, architecture, precision) - - call wrscr(trim(name)//'-'//trim(git_commit)) - call wrscr('Compile Info:') - call wrscr(' - Architecture: '//trim(architecture)) - call wrscr(' - Precision: '//trim(precision)) - call wrscr(' - Date: '//__DATE__) - call wrscr(' - Time: '//__TIME__) - ! use iso_fortran_env for compiler_version() and compiler_options() - ! call wrscr(' - Compiler: '//trim(compiler_version())) - ! call wrscr(' - Options: '//trim(compiler_options())) + CALL DispCompileRuntimeInfo - 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('') - - ! CALL WrScr( ' Running '//TRIM(GetVersion(ThisProgVer))//NewLine//' linked with '//TRIM( GetNVD( NWTC_Ver ))//NewLine ) - END SUBROUTINE FAST_ProgStart - !---------------------------------------------------------------------------------------------------------------------------------- !> This routine gets the name of the FAST input file from the command line. It also returns a logical indicating if this there !! was a "DWM" argument after the file name. From 493fdb533dd56748a8893f2891d276081f0a9952 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 24 Mar 2020 16:52:44 -0500 Subject: [PATCH 03/12] Simplify subroutine signature to display copyright --- modules/nwtc-library/src/NWTC_IO.f90 | 24 +++++++--------------- modules/openfast-library/src/FAST_Subs.f90 | 2 +- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index b54209f6f6..d7d3b639ce 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -2025,38 +2025,28 @@ FUNCTION CurTime( ) END FUNCTION CurTime !======================================================================= !> This routine displays some text about copyright and license. - SUBROUTINE DispCopyrightLicense( ProgInfo, AdditionalComment ) + SUBROUTINE DispCopyrightLicense( ProgramName, AdditionalComment ) - - TYPE( ProgDesc ), INTENT(IN) :: ProgInfo !< Contains the name and version info of the program being run + CHARACTER(*), INTENT(IN) :: ProgramName !< The name of the program being run CHARACTER(*), INTENT(IN), OPTIONAL :: AdditionalComment !< An additional comment displayed in the copyright notice. Typically used to describe alpha versions or one-off versions. ! local variable - INTEGER(IntKi) :: DateLen ! the trim length of the ProgInfo date field INTEGER(IntKi) :: I ! generic loop/index - CHARACTER(4) :: year ! the year, determined from ProgInfo's date field + CHARACTER(4) :: Year ! the year, determined from the FPP __DATE__ variable CHARACTER(MaxWrScrLen) :: Stars ! a line of '*******' characters DO I=1,MaxWrScrLen Stars(I:I)='*' END DO - - DateLen = LEN_TRIM(ProgInfo%date) - IF ( DateLen > 3 ) THEN - I = DateLen-4+1 - year = ProgInfo%date(I:) - ELSE - year = '' - END IF - + Year = __DATE__(8:11) CALL WrScr('') CALL WrScr(Stars) - CALL WrScr( TRIM(GetNVD(ProgInfo)) ) + CALL WrScr( TRIM(ProgramName) ) CALL WrScr('') - CALL WrScr( 'Copyright (C) '//TRIM(year)//' National Renewable Energy Laboratory' ) - CALL WrScr( 'Copyright (C) '//TRIM(year)//' Envision Energy USA LTD' ) + CALL WrScr( 'Copyright (C) '//TRIM(Year)//' National Renewable Energy Laboratory' ) + CALL WrScr( 'Copyright (C) '//TRIM(Year)//' Envision Energy USA LTD' ) CALL WrScr('') CALL WrScr( 'This program is licensed under Apache License Version 2.0 and comes with ABSOLUTELY NO WARRANTY. '//& 'See the "LICENSE" file distributed with this software for details.') diff --git a/modules/openfast-library/src/FAST_Subs.f90 b/modules/openfast-library/src/FAST_Subs.f90 index 744c24fb22..cd87fdae1b 100644 --- a/modules/openfast-library/src/FAST_Subs.f90 +++ b/modules/openfast-library/src/FAST_Subs.f90 @@ -1376,7 +1376,7 @@ SUBROUTINE FAST_ProgStart(ThisProgVer) CALL NWTC_Init( ProgNameIN=ThisProgVer%Name, EchoLibVer=.FALSE. ) ! Display the copyright notice - CALL DispCopyrightLicense( ThisProgVer ) + CALL DispCopyrightLicense( ThisProgVer%Name ) CALL DispCompileRuntimeInfo From 70f2d19047948095e8a6226af40b7f59014dcac6 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 24 Mar 2020 16:55:30 -0500 Subject: [PATCH 04/12] Update driver codes calling display routines --- modules/aerodyn/src/AeroDyn_Driver_Subs.f90 | 4 ++-- modules/aerodyn/src/UnsteadyAero_Driver.f90 | 6 ++---- modules/aerodyn14/src/DWM.f90 | 7 ++----- modules/beamdyn/src/Driver_Beam.f90 | 4 ++-- modules/hydrodyn/src/HydroDyn_DriverCode.f90 | 4 ++-- modules/hydrodyn/src/WAMIT2.f90 | 3 --- modules/hydrodyn/src/Waves2.f90 | 5 ----- modules/nwtc-library/src/NWTC_IO.f90 | 5 ++--- modules/subdyn/src/SubDyn_Driver.f90 | 4 ++-- modules/turbsim/src/TurbSim.f90 | 6 ++---- 10 files changed, 16 insertions(+), 32 deletions(-) diff --git a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 index 2ca6fe5fc6..c97d6ceefd 100644 --- a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 +++ b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 @@ -55,11 +55,11 @@ subroutine Dvr_Init(DvrData,errStat,errMsg ) CALL NWTC_Init() ! Display the copyright notice - CALL DispCopyrightLicense( version ) + CALL DispCopyrightLicense( version%Name ) ! Obtain OpenFAST git commit hash git_commit = QueryGitVersion() ! Tell our users what they're running - CALL WrScr( ' Running '//GetNVD( version )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( GetNVD( NWTC_Ver ))//NewLine ) + CALL WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) InputFile = "" ! initialize to empty string to make sure it's input from the command line CALL CheckArgs( InputFile, ErrStat2 ) diff --git a/modules/aerodyn/src/UnsteadyAero_Driver.f90 b/modules/aerodyn/src/UnsteadyAero_Driver.f90 index ce2a4a2e25..fda0e5e1db 100644 --- a/modules/aerodyn/src/UnsteadyAero_Driver.f90 +++ b/modules/aerodyn/src/UnsteadyAero_Driver.f90 @@ -82,13 +82,11 @@ program UnsteadyAero_Driver ! Display the copyright notice - CALL DispCopyrightLicense( version ) + CALL DispCopyrightLicense( version%Name ) ! Obtain OpenFAST git commit hash git_commit = QueryGitVersion() ! Tell our users what they're running - CALL WrScr( ' Running '//GetNVD( version )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( GetNVD( NWTC_Ver ))//NewLine ) - - + CALL WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) ! Parse the driver file if one was provided, if not, then set driver parameters using hardcoded values diff --git a/modules/aerodyn14/src/DWM.f90 b/modules/aerodyn14/src/DWM.f90 index f02732e3c7..2889057e3c 100644 --- a/modules/aerodyn14/src/DWM.f90 +++ b/modules/aerodyn14/src/DWM.f90 @@ -65,14 +65,11 @@ SUBROUTINE DWM_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, InitOu CALL NWTC_Init( ) ! Display the module information - - !CALL DispNVD( DWM__Ver ) - - ! read the wind file for DWM - CALL WrScr('') CALL DispNVD(DWM_Ver) + ! read the wind file for DWM + CALL WrScr(" Reading the wind file for DWM simulation." ) ! InitInp%IfW%InputFileName is already set in FAST diff --git a/modules/beamdyn/src/Driver_Beam.f90 b/modules/beamdyn/src/Driver_Beam.f90 index b7ea7f74a4..8c11cb9a59 100644 --- a/modules/beamdyn/src/Driver_Beam.f90 +++ b/modules/beamdyn/src/Driver_Beam.f90 @@ -81,11 +81,11 @@ PROGRAM BeamDyn_Driver_Program CALL NWTC_Init() ! Display the copyright notice - CALL DispCopyrightLicense( version ) + CALL DispCopyrightLicense( version%Name ) ! Obtain OpenFAST git commit hash git_commit = QueryGitVersion() ! Tell our users what they're running - CALL WrScr( ' Running '//GetNVD( version )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( GetNVD( NWTC_Ver ))//NewLine ) + CALL WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) ! ------------------------------------------------------------------------- ! Initialization of glue-code time-step variables diff --git a/modules/hydrodyn/src/HydroDyn_DriverCode.f90 b/modules/hydrodyn/src/HydroDyn_DriverCode.f90 index f913722706..857f85cedc 100644 --- a/modules/hydrodyn/src/HydroDyn_DriverCode.f90 +++ b/modules/hydrodyn/src/HydroDyn_DriverCode.f90 @@ -157,11 +157,11 @@ PROGRAM HydroDynDriver call nwtc_init() ! Display the copyright notice - CALL DispCopyrightLicense( version ) + CALL DispCopyrightLicense( version%Name ) ! Obtain OpenFAST git commit hash git_commit = QueryGitVersion() ! Tell our users what they're running - CALL WrScr( ' Running '//GetNVD( version )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( GetNVD( NWTC_Ver ))//NewLine ) + CALL WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) IF ( command_argument_count() /= 1 ) THEN CALL print_help() diff --git a/modules/hydrodyn/src/WAMIT2.f90 b/modules/hydrodyn/src/WAMIT2.f90 index 05c45bde52..af88651924 100644 --- a/modules/hydrodyn/src/WAMIT2.f90 +++ b/modules/hydrodyn/src/WAMIT2.f90 @@ -65,8 +65,6 @@ MODULE WAMIT2 ! INTEGER(IntKi), PARAMETER :: DataFormatID = 1 !< Update this value if the data types change (used in WAMIT_Pack) TYPE(ProgDesc), PARAMETER :: WAMIT2_ProgDesc = ProgDesc( 'WAMIT2', '', '' ) !< This holds the name of the program, version info, and date. - !! It is used by the DispNVD routine in the library and as header - !! information in output files. REAL(DbKi), PARAMETER, PRIVATE :: OnePlusEps = 1.0 + EPSILON(OnePlusEps) ! The number slighty greater than unity in the precision of DbKi. @@ -278,7 +276,6 @@ SUBROUTINE WAMIT2_Init( InitInp, u, p, x, xd, z, OtherState, y, m, Interval, Ini !> Initialize the NWTC Subroutine Library and display the information about this module. CALL NWTC_Init() ! WAMIT2_ProgDesc%Name, '('//WAMIT2_ProgDesc%Ver//','//WAMIT2_ProgDesc%Date//')', EchoLibVer = .FALSE. ) - !CALL DispNVD( WAMIT2_ProgDesc ) diff --git a/modules/hydrodyn/src/Waves2.f90 b/modules/hydrodyn/src/Waves2.f90 index 33e92f807a..97ea03a202 100644 --- a/modules/hydrodyn/src/Waves2.f90 +++ b/modules/hydrodyn/src/Waves2.f90 @@ -46,8 +46,6 @@ MODULE Waves2 ! INTEGER(IntKi), PARAMETER :: DataFormatID = 1 !< Update this value if the data types change (used in Waves2_Pack) TYPE(ProgDesc), PARAMETER :: Waves2_ProgDesc = ProgDesc( 'Waves2', '', '' ) !< This holds the name of the program, version info, and date. - !! It is used by the DispNVD routine in the library and as header - !! information in output files. REAL(DbKi), PARAMETER, PRIVATE :: OnePlusEps = 1.0 + EPSILON(OnePlusEps) ! The number slighty greater than unity in the precision of DbKi. @@ -223,9 +221,6 @@ SUBROUTINE Waves2_Init( InitInp, u, p, x, xd, z, OtherState, y, misc, Interval, ! Initialize the NWTC Subroutine Library and display the information about this module. CALL NWTC_Init( ) - !CALL DispNVD( Waves2_ProgDesc ) - - !----------------------------------------------------------------------------- diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index d7d3b639ce..29d5e219d8 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -2390,9 +2390,8 @@ FUNCTION GetErrStr ( ErrID ) END FUNCTION GetErrStr !======================================================================= -!> This function converts the three strings contained in the ProgDesc -!! data type into a single string listing the program name, -!! version, and release date. +!> This function extracts the Name field from the ProgDesc data type +! and return it. FUNCTION GetNVD ( ProgInfo ) ! Argument declarations. diff --git a/modules/subdyn/src/SubDyn_Driver.f90 b/modules/subdyn/src/SubDyn_Driver.f90 index cc6c4026ea..0047bc5ded 100644 --- a/modules/subdyn/src/SubDyn_Driver.f90 +++ b/modules/subdyn/src/SubDyn_Driver.f90 @@ -113,11 +113,11 @@ PROGRAM TestSubDyn CALL NWTC_Init( ) ! Display the copyright notice - CALL DispCopyrightLicense( version ) + CALL DispCopyrightLicense( version%Name ) ! Obtain OpenFAST git commit hash git_commit = QueryGitVersion() ! Tell our users what they're running - CALL WrScr( ' Running '//GetNVD( version )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( GetNVD( NWTC_Ver ))//NewLine ) + CALL WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) diff --git a/modules/turbsim/src/TurbSim.f90 b/modules/turbsim/src/TurbSim.f90 index 9cdbf4a573..87a287706d 100644 --- a/modules/turbsim/src/TurbSim.f90 +++ b/modules/turbsim/src/TurbSim.f90 @@ -99,13 +99,11 @@ PROGRAM TurbSim ! Print out program name, version, and date. ! Display the copyright notice - CALL DispCopyrightLicense( TurbSim_Ver ) + CALL DispCopyrightLicense( TurbSim_Ver%Name ) ! Obtain OpenFAST git commit hash git_commit = QueryGitVersion() ! Tell our users what they're running - CALL WrScr( ' Running '//GetNVD( TurbSim_Ver )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( GetNVD( NWTC_Ver ))//NewLine ) - - + CALL WrScr( ' Running '//TRIM( TurbSim_Ver%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) ! Check for command line arguments. InFile = 'TurbSim.inp' ! default name for input file From 29e4d78e1c355b025dd236737423eb158bd8e1f9 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Thu, 26 Mar 2020 13:32:39 -0500 Subject: [PATCH 05/12] Bug fix for using an intent(out) variable --- modules/nwtc-library/src/NWTC_IO.f90 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index 29d5e219d8..7ab8faeec5 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -1488,7 +1488,7 @@ SUBROUTINE CheckArgs ( Arg1, ErrStat, Arg2, Flag, InputArgArray ) ! Local declarations: INTEGER :: I, J ! Iterator variables - CHARACTER(1024) :: Arg + CHARACTER(1024) :: Arg, FlagIter CHARACTER(1024), DIMENSION(:), ALLOCATABLE :: ArgArray, TempArray, Flags LOGICAL :: FirstArgumentSet, SecondArgumentSet @@ -1545,10 +1545,11 @@ SUBROUTINE CheckArgs ( Arg1, ErrStat, Arg2, Flag, InputArgArray ) DO I = 1, SIZE(Flags) - Flag = Flags(I)(2:) ! This results in the flag without the switch character - CALL Conv2UC( Flag ) + FlagIter = Flags(I)(2:) ! This results in the flag without the switch character + CALL Conv2UC( FlagIter ) + IF ( PRESENT(Flag) ) Flag = FlagIter - SELECT CASE ( TRIM(Flag) ) + SELECT CASE ( TRIM(FlagIter) ) CASE ('H') CALL DispCopyrightLicense( ProgName ) @@ -1575,7 +1576,7 @@ SUBROUTINE CheckArgs ( Arg1, ErrStat, Arg2, Flag, InputArgArray ) END IF CASE DEFAULT - CALL INVALID_SYNTAX( 'unknown command-line argument given: '//TRIM(Flag) ) + CALL INVALID_SYNTAX( 'unknown command-line argument given: '//TRIM(FlagIter) ) CALL CLEANUP() RETURN From f8bd2d1ce06770cbd0228c6eeb7a6cc881bc8a7c Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Thu, 26 Mar 2020 13:33:14 -0500 Subject: [PATCH 06/12] Set error status for normal abort arguments --- modules/nwtc-library/src/NWTC_IO.f90 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/nwtc-library/src/NWTC_IO.f90 b/modules/nwtc-library/src/NWTC_IO.f90 index 7ab8faeec5..411fb7daee 100644 --- a/modules/nwtc-library/src/NWTC_IO.f90 +++ b/modules/nwtc-library/src/NWTC_IO.f90 @@ -1555,12 +1555,14 @@ SUBROUTINE CheckArgs ( Arg1, ErrStat, Arg2, Flag, InputArgArray ) 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 @@ -1600,12 +1602,11 @@ 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) ) THEN - ErrStat = ErrID_Fatal - RETURN - END IF + IF ( PRESENT(ErrStat) ) ErrStat = ErrID_Fatal END SUBROUTINE From 66b80e9872b29807f2538dc979a8b377d9fbe6aa Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Thu, 26 Mar 2020 14:08:09 -0500 Subject: [PATCH 07/12] Allow the version to be set through CMake This will be used when compiling in package managers since they seem to prefer downloading a tarball of source code rather than using git to get the repository. --- modules/version/CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/version/CMakeLists.txt b/modules/version/CMakeLists.txt index 63e280e001..1a1b0af02d 100644 --- a/modules/version/CMakeLists.txt +++ b/modules/version/CMakeLists.txt @@ -14,8 +14,17 @@ # limitations under the License. # -include(GetGitRevisionDescription) -git_describe(GIT_DESCRIBE) +# Allow the git-version information to be set externally for the +# package manager distributions (homebrew, conda, apt) that download +# the tarball source code rather than clone with git. +if( DEFINED GIT_DESCRIBE ) + message( WARNING + "Version information has been set as a CMake flag. This should only used when the git-version cannot be set automatically." + ) +else() + include(GetGitRevisionDescription) + git_describe(GIT_DESCRIBE) +endif() add_definitions(-DGIT_VERSION_INFO="${GIT_DESCRIBE}") add_library(versioninfolib src/VersionInfo.f90) From 80053e8219d740cb2d10cd2c4a3792bf47b43f51 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Thu, 26 Mar 2020 15:28:45 -0500 Subject: [PATCH 08/12] Update drivers to support help and version flags --- modules/aerodyn/src/AeroDyn_Driver_Subs.f90 | 28 ++++++--------------- modules/servodyn/src/ServoDyn_Driver.f90 | 10 ++++++-- modules/turbsim/src/TurbSim.f90 | 9 ++++--- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 index c97d6ceefd..b06c2267e8 100644 --- a/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 +++ b/modules/aerodyn/src/AeroDyn_Driver_Subs.f90 @@ -44,8 +44,8 @@ subroutine Dvr_Init(DvrData,errStat,errMsg ) CHARACTER(1000) :: inputFile ! String to hold the file name. CHARACTER(200) :: git_commit ! String containing the current git commit hash + CHARACTER(20) :: FlagArg ! flag argument from command line - TYPE(ProgDesc), PARAMETER :: version = ProgDesc( 'AeroDyn Driver', '', '' ) ! The version number of this program. ErrStat = ErrID_None ErrMsg = "" @@ -53,30 +53,18 @@ subroutine Dvr_Init(DvrData,errStat,errMsg ) DvrData%OutFileData%unOutFile = -1 - CALL NWTC_Init() + 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 ) - - InputFile = "" ! initialize to empty string to make sure it's input from the command line - CALL CheckArgs( InputFile, ErrStat2 ) - IF (LEN_TRIM(InputFile) == 0) THEN ! no input file was specified - call SetErrStat(ErrID_Fatal, 'The required input file was not specified on the command line.', ErrStat, ErrMsg, RoutineName) - - !bjj: if people have compiled themselves, they should be able to figure out the file name, right? - IF (BITS_IN_ADDR==32) THEN - CALL NWTC_DisplaySyntax( InputFile, 'AeroDyn_Driver_Win32.exe' ) - ELSEIF( BITS_IN_ADDR == 64) THEN - CALL NWTC_DisplaySyntax( InputFile, 'AeroDyn_Driver_x64.exe' ) - ELSE - CALL NWTC_DisplaySyntax( InputFile, 'AeroDyn_Driver.exe' ) - END IF - - return - END IF ! Read the AeroDyn driver input file call Dvr_ReadInputFile(inputFile, DvrData, errStat2, errMsg2 ) @@ -642,7 +630,7 @@ subroutine Dvr_InitializeOutputFile( iCase, CaseData, OutFileData, errStat, errM call OpenFOutFile ( OutFileData%unOutFile, trim(outFileData%Root)//'.'//trim(num2lstr(iCase))//'.out', ErrStat, ErrMsg ) if ( ErrStat >= AbortErrLev ) return - write (OutFileData%unOutFile,'(/,A)') 'Predictions were generated on '//CurDate()//' at '//CurTime()//' using '//trim(GetNVD(version)) + write (OutFileData%unOutFile,'(/,A)') 'Predictions were generated on '//CurDate()//' at '//CurTime()//' using '//trim( version%Name ) write (OutFileData%unOutFile,'(1X,A)') trim(GetNVD(OutFileData%AD_ver)) write (OutFileData%unOutFile,'()' ) !print a blank line ! write (OutFileData%unOutFile,'(A,11(1x,A,"=",ES11.4e2,1x,A))' ) 'Case '//trim(num2lstr(iCase))//':' & diff --git a/modules/servodyn/src/ServoDyn_Driver.f90 b/modules/servodyn/src/ServoDyn_Driver.f90 index d09a710eac..e19d3dd4f0 100644 --- a/modules/servodyn/src/ServoDyn_Driver.f90 +++ b/modules/servodyn/src/ServoDyn_Driver.f90 @@ -58,17 +58,23 @@ PROGRAM SrvD_Driver INTEGER(IntKi) :: Un INTEGER(IntKi), parameter :: nMax = 80 CHARACTER(1024) :: OutFile - + CHARACTER(20) :: FlagArg !< Flag argument from command line + + TYPE(ProgDesc), PARAMETER :: version = ProgDesc( 'ServoDyn_driver', '', '' ) !............................................................................................................................... ! Routines called in initialization !............................................................................................................................... + CALL NWTC_Init( ProgNameIN=version%Name ) + ! Populate the InitInData data structure here: + ! Check for command line arguments. InitInData%InputFile = '' !'ServoDyn_input.dat' + CALL CheckArgs( InitInData%InputFile, Flag=FlagArg ) + IF ( LEN( TRIM(FlagArg) ) > 0 ) CALL NormStop() - CALL CheckArgs( InitInData%InputFile, ErrStat) ! if ErrStat2 /= ErrID_None, we'll ignore and deal with the problem when we try to read the input file CALL GetRoot( InitInData%InputFile, OutFile ) OutFile = trim(OutFile)//'.out' diff --git a/modules/turbsim/src/TurbSim.f90 b/modules/turbsim/src/TurbSim.f90 index 87a287706d..e07223fa27 100644 --- a/modules/turbsim/src/TurbSim.f90 +++ b/modules/turbsim/src/TurbSim.f90 @@ -84,6 +84,7 @@ PROGRAM TurbSim CHARACTER(MaxMsgLen) :: ErrMsg ! error message CHARACTER(200) :: InFile ! Name of the TurbSim input file. CHARACTER(200) :: git_commit ! String containing the current git commit hash +CHARACTER(20) :: FlagArg ! flag argument from command line !BONNIE:***************************** @@ -95,6 +96,10 @@ PROGRAM TurbSim ! ... Initialize NWTC Library (open console, set pi constants) ... CALL NWTC_Init( ProgNameIN=TurbSim_Ver%Name, EchoLibVer=.FALSE. ) + ! Check for command line arguments. +InFile = 'TurbSim.inp' ! default name for input file +CALL CheckArgs( InFile, Flag=FlagArg ) +IF ( LEN( TRIM(FlagArg) ) > 0 ) CALL NormStop() ! Print out program name, version, and date. @@ -105,10 +110,6 @@ PROGRAM TurbSim ! Tell our users what they're running CALL WrScr( ' Running '//TRIM( TurbSim_Ver%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine ) - ! Check for command line arguments. -InFile = 'TurbSim.inp' ! default name for input file -CALL CheckArgs( InFile ) - CALL GetRoot( InFile, p%RootName ) ! Open input file and summary file. From 5aa3e37698fee105463fcaf95fa23f4caa1dc553 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Thu, 26 Mar 2020 15:53:35 -0500 Subject: [PATCH 09/12] Add a unit test for the version flag --- .../tests/test_NWTC_IO_CheckArgs.F90 | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/modules/nwtc-library/tests/test_NWTC_IO_CheckArgs.F90 b/modules/nwtc-library/tests/test_NWTC_IO_CheckArgs.F90 index 0ab007824b..838a29688b 100644 --- a/modules/nwtc-library/tests/test_NWTC_IO_CheckArgs.F90 +++ b/modules/nwtc-library/tests/test_NWTC_IO_CheckArgs.F90 @@ -227,6 +227,56 @@ subroutine test_help2() deallocate(argument_array) end subroutine + ! ************************************************************************ + ! The version flag in any position should show the version info and exit + ! normally. + + @test + subroutine test_version1() + + ! executable.exe -v FileName + + character(1024) :: filename, second_argument, flag + integer(IntKi) :: error_status + character(16), dimension(:), allocatable :: argument_array + + filename = "" + allocate(argument_array(2)) + argument_array = (/ & + "-v ", & + "first_arg.txt " & + /) + call CheckArgs( filename, error_status, second_argument, flag, argument_array ) + @assertEqual( "first_arg.txt", filename ) + @assertEqual( 0, error_status ) + @assertEqual( "", second_argument ) + @assertEqual( "V", flag ) + deallocate(argument_array) + end subroutine + + @test + subroutine test_version2() + + ! executable.exe FileName -VERSION + + character(1024) :: filename, second_argument, flag + integer(IntKi) :: error_status + character(16), dimension(:), allocatable :: argument_array + + filename = "" + allocate(argument_array(2)) + argument_array = (/ & + "first_arg.txt ", & + "-VERSION " & + /) + call CheckArgs( filename, error_status, second_argument, flag, argument_array ) + @assertEqual( "first_arg.txt", filename ) + @assertEqual( 0, error_status ) + @assertEqual( "", second_argument ) + @assertEqual( "VERSION", flag ) + deallocate(argument_array) + end subroutine + ! FAILING CASES ! ************************************************************************ From f1a9bc2b03fe9c501bfa3cd84d4726e5e5751504 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Fri, 27 Mar 2020 13:04:17 -0500 Subject: [PATCH 10/12] Print debugging info in Actions entrypoint script --- .../actions/compile-and-test/entrypoint.sh | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/actions/compile-and-test/entrypoint.sh b/.github/actions/compile-and-test/entrypoint.sh index 57ec3db74d..f5bb4369de 100755 --- a/.github/actions/compile-and-test/entrypoint.sh +++ b/.github/actions/compile-and-test/entrypoint.sh @@ -1,17 +1,31 @@ #!/bin/bash +cd /openfast + git fetch origin ${GITHUB_REF}:CI git checkout CI git submodule update -# Print the current git info -echo `git status` -echo `git log -1` +# Display the current git info +echo git-status from openfast: +git status + +echo git-log from openfast: +git log -1 + cd /openfast/reg_tests/r-test -echo `git status` -echo `git log -1` +echo git-status from r-test: +git status + +echo git-log from r-test: +git log -1 + cd /openfast +# Display the differences between this commit and `dev` +echo git-diff from ${GITHUB_REF} to dev: +git diff dev + # Move into the "build" directory, remove the old reg tests, and compile cd /openfast/build rm -rf reg_tests From 9a86ebea821dada091274a1d7ba07d0de9a3d489 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 5 May 2020 12:42:50 -0500 Subject: [PATCH 11/12] Add comment describing the use of an ifdef --- modules/version/src/VersionInfo.f90 | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/version/src/VersionInfo.f90 b/modules/version/src/VersionInfo.f90 index a462697a99..27dbc73e7b 100644 --- a/modules/version/src/VersionInfo.f90 +++ b/modules/version/src/VersionInfo.f90 @@ -28,6 +28,7 @@ FUNCTION QueryGitVersion() CHARACTER(200) :: QueryGitVersion +! The Visual Studio project sets the path for where to find the header file with version info #ifdef GIT_INCLUDE_FILE #include GIT_INCLUDE_FILE #endif From 76cb1e1acc3bebe301dbcfa2c574d2a8e5fd3243 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 5 May 2020 13:40:19 -0500 Subject: [PATCH 12/12] Remove unused variables --- modules/openfast-library/src/FAST_Subs.f90 | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/openfast-library/src/FAST_Subs.f90 b/modules/openfast-library/src/FAST_Subs.f90 index cd87fdae1b..3e71a38a32 100644 --- a/modules/openfast-library/src/FAST_Subs.f90 +++ b/modules/openfast-library/src/FAST_Subs.f90 @@ -1367,9 +1367,6 @@ END FUNCTION GetVersion !! displays the copyright notice, and displays some version information (including addressing scheme and precision). SUBROUTINE FAST_ProgStart(ThisProgVer) TYPE(ProgDesc), INTENT(IN) :: ThisProgVer !< program name/date/version description - character(200) :: name, version - character(200) :: git_commit, architecture, precision - character(200) :: execution_date, execution_time, execution_zone ! ... Initialize NWTC Library (open console, set pi constants) ... ! sets the pi constants, open console for output, etc...