Skip to content

Commit

Permalink
Merge pull request #428 from rafmudaf/feature/version_flag
Browse files Browse the repository at this point in the history
Add a version flag and other printout updates
  • Loading branch information
rafmudaf authored May 7, 2020
2 parents 80b972e + 8f46e23 commit bf89cfc
Show file tree
Hide file tree
Showing 18 changed files with 193 additions and 152 deletions.
24 changes: 19 additions & 5 deletions .github/actions/compile-and-test/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions glue-codes/openfast/src/FAST_Prog.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 10 additions & 22 deletions modules/aerodyn/src/AeroDyn_Driver_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,27 @@ 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 = ""


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 )
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 )

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
CALL WrScr( ' Running '//TRIM( version%Name )//' a part of OpenFAST - '//TRIM(git_Commit)//NewLine//' linked with '//TRIM( NWTC_Ver%Name )//NewLine )

! Read the AeroDyn driver input file
call Dvr_ReadInputFile(inputFile, DvrData, errStat2, errMsg2 )
Expand Down Expand Up @@ -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))//':' &
Expand Down
6 changes: 2 additions & 4 deletions modules/aerodyn/src/UnsteadyAero_Driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions modules/aerodyn14/src/DWM.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions modules/beamdyn/src/Driver_Beam.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions modules/hydrodyn/src/HydroDyn_DriverCode.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions modules/hydrodyn/src/WAMIT2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 )



Expand Down
5 changes: 0 additions & 5 deletions modules/hydrodyn/src/Waves2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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 )




!-----------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions modules/nwtc-library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
99 changes: 68 additions & 31 deletions modules/nwtc-library/src/NWTC_IO.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1487,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

Expand Down Expand Up @@ -1544,13 +1545,24 @@ 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 )
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

Expand All @@ -1566,7 +1578,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

Expand All @@ -1590,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

Expand Down Expand Up @@ -2016,38 +2027,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.')
Expand Down Expand Up @@ -2163,7 +2164,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.
Expand Down Expand Up @@ -2354,9 +2392,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.
Expand Down
Loading

0 comments on commit bf89cfc

Please sign in to comment.