Skip to content

Commit

Permalink
Merge pull request FESOM#13 from FESOM/version_info
Browse files Browse the repository at this point in the history
Version info
  • Loading branch information
koldunovn authored Sep 15, 2020
2 parents 0752792 + c3d0b22 commit b921482
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -52,6 +62,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()
Expand Down
12 changes: 12 additions & 0 deletions src/GitRepositoryInfo.cmake
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions src/fesom_version_info.F90
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/fvom_main.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b921482

Please sign in to comment.