Skip to content

Commit

Permalink
Include program compile, runtime info in NWTC Lib
Browse files Browse the repository at this point in the history
  • Loading branch information
rafmudaf committed Mar 27, 2020
1 parent f24ff78 commit 59a520b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 53 deletions.
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
42 changes: 40 additions & 2 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 @@ -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

This comment has been minimized.

Copy link
@ebranlard

ebranlard May 13, 2020

Contributor

Unfortunately, Intel(R) Visual Fortran Compiler 17.0.2.187, doesn't have the compiler_version function. I think that's the one we use at NREL for now. I'm guessing that's why this line was commented (see FAST_Subs in previous commit). @rafmudaf , should we comment it again?

This comment has been minimized.

Copy link
@rafmudaf

rafmudaf May 13, 2020

Author Collaborator

:( Yes, unfortunately. Thanks for catching that. Is there a way to check if the function is available?

This comment has been minimized.

Copy link
@ebranlard

ebranlard May 13, 2020

Contributor

the only thing I can think of would be a preprocessor directive:

#ifdef __INTEL_COMPILER && __INTEL_COMPILER<1800
  [do not use compiler_version]

This comment has been minimized.

Copy link
@ebranlard

ebranlard May 13, 2020

Contributor

A "working" example:

use iso_fortran_env ! removed only statement, unfortunately...
character(200) :: compiler_version_str
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER<1800)
      compiler_version_str = 'intel compiler '//num2lstr(__INTEL_COMPILER)
#else
      compiler_version_str = compiler_version()
#endif

NOTE: I don't know from which version it would work..


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
50 changes: 1 addition & 49 deletions modules/openfast-library/src/FAST_Subs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ MODULE FAST_Subs

USE FAST_Solver
USE FAST_Linear
USE VersionInfo

IMPLICIT NONE

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

0 comments on commit 59a520b

Please sign in to comment.