From 59a520b4e8ee871e34edc997f7fc8e49423917c7 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Tue, 24 Mar 2020 16:49:02 -0500 Subject: [PATCH] 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 915587467..6e055f596 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 d1916a8c0..b54209f6f 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 338ada576..744c24fb2 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.