From ecb05f7f10b613f6bc81699521f88d609ec8d0b0 Mon Sep 17 00:00:00 2001 From: Jan Hegewald Date: Thu, 6 Aug 2020 11:44:34 +0200 Subject: [PATCH 1/2] enable compiling with gfortran 10 --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1cea8d3c8..dca6aaaaf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -52,6 +52,9 @@ if(${CMAKE_Fortran_COMPILER_ID} STREQUAL Intel ) # target_compile_options(${PROJECT_NAME} PRIVATE -r8 -i4 -fp-model precise -no-prec-div -no-prec-sqrt -fast-transcendentals -xHost -ip -g -traceback -check all,noarg_temp_created,bounds,uninit ) #-ftrapuv ) #-init=zero) elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU ) target_compile_options(${PROJECT_NAME} PRIVATE -O3 -finit-local-zero -finline-functions -march=native -fimplicit-none -fdefault-real-8 -ffree-line-length-none) + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 10 ) + target_compile_options(${PROJECT_NAME} PRIVATE -fallow-argument-mismatch) # gfortran v10 is strict about erroneous API calls: "Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)" + endif() elseif(${CMAKE_Fortran_COMPILER_ID} STREQUAL Cray ) target_compile_options(${PROJECT_NAME} PRIVATE -c -emf -hbyteswapio -hflex_mp=conservative -hfp1 -hadd_paren -Ounroll0 -hipa0 -r am -s real64) endif() From c3d0b22e058add3f5e3d4439611efdf8feda7b7f Mon Sep 17 00:00:00 2001 From: Jan Hegewald Date: Tue, 15 Sep 2020 11:36:18 +0200 Subject: [PATCH 2/2] print compile time git SHA at runtime --- src/CMakeLists.txt | 10 ++++++++++ src/GitRepositoryInfo.cmake | 12 ++++++++++++ src/fesom_version_info.F90 | 14 ++++++++++++++ src/fvom_main.F90 | 2 ++ 4 files changed, 38 insertions(+) create mode 100644 src/GitRepositoryInfo.cmake create mode 100644 src/fesom_version_info.F90 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dca6aaaaf..2397c42eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,6 +9,16 @@ file(GLOB sources_Fortran ${src_home}/*.F90) #list(REMOVE_ITEM sources_Fortran ${src_home}/fesom_partition_init.F90) file(GLOB sources_C ${src_home}/*.c) +# generate a custom file from fesom_version_info.F90 which includes the current git SHA +set(FESOM_ORIGINAL_VERSION_FILE ${src_home}/fesom_version_info.F90) +set(FESOM_GENERATED_VERSION_FILE ${CMAKE_CURRENT_BINARY_DIR}/fesom_version_info-generated.F90) +list(REMOVE_ITEM sources_Fortran ${FESOM_ORIGINAL_VERSION_FILE}) # we want to compile the generated file instead +list(APPEND sources_Fortran ${FESOM_GENERATED_VERSION_FILE}) +add_custom_command(OUTPUT ${FESOM_GENERATED_VERSION_FILE} 5303B6F4_E4F4_45B2_A6E5_8E2B9FB5CDC4 # the second arg to OUTPUT is a name for a file we never create to make sure this command will run on every re-build + COMMAND ${CMAKE_COMMAND} -DFESOM_ORIGINAL_VERSION_FILE=${FESOM_ORIGINAL_VERSION_FILE} -DFESOM_GENERATED_VERSION_FILE=${FESOM_GENERATED_VERSION_FILE} -P GitRepositoryInfo.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + COMMENT "determining ${PROJECT_NAME} git SHA ...") + #if(${FESOM_STANDALONE}) # list(REMOVE_ITEM sources_Fortran ${src_home}/cpl_driver.F90) #endif() diff --git a/src/GitRepositoryInfo.cmake b/src/GitRepositoryInfo.cmake new file mode 100644 index 000000000..e5eb37c26 --- /dev/null +++ b/src/GitRepositoryInfo.cmake @@ -0,0 +1,12 @@ +find_package(Git QUIET) +if(Git_FOUND) + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE FESOM_GIT_SHA + OUTPUT_STRIP_TRAILING_WHITESPACE) +else() + set(FESOM_GIT_SHA "unknown") + message("git not found, setting FESOM_GIT_SHA to: ${FESOM_GIT_SHA}") +endif() + +configure_file(${FESOM_ORIGINAL_VERSION_FILE} ${FESOM_GENERATED_VERSION_FILE} @ONLY) diff --git a/src/fesom_version_info.F90 b/src/fesom_version_info.F90 new file mode 100644 index 000000000..5fe688b5a --- /dev/null +++ b/src/fesom_version_info.F90 @@ -0,0 +1,14 @@ +module fesom_version_info_module + private + public fesom_git_sha + +contains + + + pure function fesom_git_sha() result(x) + character(:), allocatable :: x + ! EO args + x = "@FESOM_GIT_SHA@" + end function + +end module diff --git a/src/fvom_main.F90 b/src/fvom_main.F90 index a02a8fe68..42050c90d 100755 --- a/src/fvom_main.F90 +++ b/src/fvom_main.F90 @@ -22,6 +22,7 @@ program main use io_mesh_info use diagnostics use mo_tidal +use fesom_version_info_module #if defined (__oasis) use cpl_driver #endif @@ -53,6 +54,7 @@ program main call par_init if(mype==0) then write(*,*) + print *,"FESOM2 git SHA: "//fesom_git_sha() print *, achar(27)//'[32m' //'____________________________________________________________'//achar(27)//'[0m' print *, achar(27)//'[7;32m'//' --> FESOM BUILDS UP MODEL CONFIGURATION '//achar(27)//'[0m' end if