Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

great fesom cmake changes from @wdeconinck to production_DE #526

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fa5d477
Added workflow for sync to lumi and a first version of a gitlab CI wo…
Oct 19, 2023
33155cc
Added lumi_gpu_evatali branch to workflow
Oct 19, 2023
0f2d022
Merge pull request #519 from tiggi/refactoring
koldunovn Oct 19, 2023
4a3ea6f
Fixed bad YAML in Lumi CICD workflow
Oct 19, 2023
17b396e
Add a partition for the Lumi CICD job
Oct 19, 2023
62098b4
Remove the artifact from gitlab-ci, it's better to have it printed ou…
Oct 19, 2023
473de2a
Remove the artifact from gitlab-ci, it's better to have it printed ou…
Oct 19, 2023
ac082c8
Merge pull request #520 from tiggi/refactoring
koldunovn Oct 19, 2023
62d3e6a
an OMP bux fix in tracer FCT
Oct 26, 2023
849b732
Merge pull request #522 from FESOM/refactoring_FCT_OMP_BUGFIX
suvarchal Oct 26, 2023
ef9e91f
Add forward declarations in parms for standard compliance
wdeconinck Aug 22, 2023
6298b59
Fix warning: format string is not a string literal (potentially insec…
wdeconinck Oct 10, 2023
66eaaaf
Fix warning: add explicit braces to avoid dangling else
wdeconinck Oct 10, 2023
74f796e
Fix warning: incompatible function pointer types initializing... TODO…
wdeconinck Oct 10, 2023
e550953
Fix warning: '%s' directive writing up to 255 bytes into a region of …
wdeconinck Oct 10, 2023
3cdb8d0
Fix warning: extra tokens at end of #endif directive
wdeconinck Oct 10, 2023
4ae7703
Improve FindNETCDF with extra search hints and handling of COMPONENTS
wdeconinck Oct 10, 2023
d526ae4
Update lumi environment, showing that FindNETCDF works without interv…
wdeconinck Oct 10, 2023
ae6958e
Update atosecmwf environment, showing mpi compiler wrappers are no lo…
wdeconinck Oct 10, 2023
449c57a
Merge pull request #523 from FESOM/bugfixes_wdeconinck
dsidoren Oct 26, 2023
89fbf65
addes missing OMP clauses
Oct 27, 2023
efbb3ed
removed just introduced OMP statement im ice_fct (was not needed)
Oct 27, 2023
5cdb7c8
Merge branch 'refactoring' into refactoring_FCT_OMP_BUGFIX
suvarchal Oct 27, 2023
7209162
Merge pull request #525 from FESOM/refactoring_FCT_OMP_BUGFIX
suvarchal Oct 27, 2023
c52360a
CMakefiles from Razvan. This wont work for standalone runs!
Oct 6, 2023
52cde62
Fix compilation errors after multio API update
Oct 2, 2023
a506965
Find MPI on atos
Aug 29, 2023
e648a8d
use assumed shapes instead of legacy assumed sizes, Merged io_netcdf_…
suvarchal Oct 9, 2023
7335b13
Fix warning: Use of the NUMERIC_STORAGE_SIZE named constant from intr…
wdeconinck Oct 10, 2023
5344625
Deprecate cmake option BUILD_FESOM_AS_LIBRARY, use ENABLE_IFS_INTERFA…
wdeconinck Oct 10, 2023
3bb3b02
Fix cmake configuration for compilation of parms
wdeconinck Oct 10, 2023
27aea3a
CMake installation and cleanup
wdeconinck Oct 10, 2023
ceec508
Avoid recompilation of fesom_version_info-generate.F90 if git sha did…
wdeconinck Aug 24, 2023
ec82fb1
Add test_downstream
wdeconinck Oct 10, 2023
dbbd86d
Fix compilation in iom related to incompatible logical type
wdeconinck Oct 30, 2023
fb4421f
Fix usage of preprocessor definition __MULTIO
wdeconinck Oct 30, 2023
c39f0d0
Add option ENABLE_MULTIO (default ON, only when ENABLE_IFS_INTERFACE …
wdeconinck Aug 22, 2023
9ad264c
Discover LAPACK_LIBRARIES on ubuntu container
wdeconinck Oct 30, 2023
00bb869
Add env "local"
wdeconinck Oct 30, 2023
51bc1f5
Github Actions: remove sed and use CMake option
wdeconinck Oct 30, 2023
707e8d3
Github Actions: git add safe directory
wdeconinck Oct 30, 2023
dc220f9
Github Actions: test compilation of IFS interface
wdeconinck Oct 30, 2023
8f7d4ed
Github Actions: Add test downstream
wdeconinck Oct 30, 2023
f0b842f
Fix possible too long line length
wdeconinck Oct 31, 2023
9d116f5
Merge branch 'production_DE' into production_DE_rebased_with_cmake
suvarchal Oct 31, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/inactive_workflows/fesom2_icepack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ jobs:

- name: prepeare FESOM2_icepack
run: |
sed -i 's/USE_ICEPACK OFF/USE_ICEPACK ON/g' CMakeLists.txt
cd ./src/icepack_drivers/
./download_icepack.sh
cd ../../

- name: Compile model
run: |
bash -l configure.sh ubuntu
bash -l configure.sh ubuntu -DUSE_ICEPACK=ON

- name: Create global test run with ICEPACK
run: |
Expand Down
37 changes: 31 additions & 6 deletions .github/workflows/fesom2.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,43 @@ jobs:
steps:
# NK: this changes working directory to fesom2
- uses: actions/checkout@v2


- name: Git safe directory
run: |
git config --global --add safe.directory /__w/fesom2/fesom2

- name: Compile model (binary)
run: |
bash -l configure.sh ubuntu
./configure.sh ubuntu

- name: Compile model (ifs_interface)
run: |
export BUILD_DIR=$PWD/build.ifs_interface
./configure.sh ubuntu -DENABLE_IFS_INTERFACE=ON -DCMAKE_INSTALL_PREFIX=$PWD/install.ifs_interface

- name: Compile model (library)
- name: Test downstream from /usr/local install-dir
run: |
bash ./test/ifs_interface/configure_lib.sh -l
rm -rf test_downstream/build
cmake -S test_downstream -B test_downstream/build -DASSERT_HAVE_IFS_INTERFACE=OFF -DASSERT_FESOM_DIR=/usr/local
cmake --build test_downstream/build
test_downstream/build/main

- name: Library exists
- name: Test downstream from ifs_interface build-dir
run: |
cmake --version
export fesom_ROOT=$PWD/build.ifs_interface
rm -rf test_downstream/build
cmake -S test_downstream -B test_downstream/build -DASSERT_HAVE_IFS_INTERFACE=ON -DASSERT_FESOM_DIR=${fesom_ROOT}
cmake --build test_downstream/build
test_downstream/build/main

- name: Test downstream from ifs_interface install-dir
run: |
bash ./test/ifs_interface/check_exist.sh
export fesom_ROOT=$PWD/install.ifs_interface
rm -rf test_downstream/build
cmake -S test_downstream -B test_downstream/build -DASSERT_HAVE_IFS_INTERFACE=ON -DASSERT_FESOM_DIR=${fesom_ROOT}
cmake --build test_downstream/build
test_downstream/build/main

- name: Create global test run
run: |
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/fesom2_openmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ jobs:
# NK: this changes working directory to fesom2
- uses: actions/checkout@v2

- name: switch OpenMP ON
- name: Git safe directory
run: |
cd ./src/
sed -i 's/with OpenMP\" OFF/with OpenMP\" ON/g' CMakeLists.txt
cd ../
git config --global --add safe.directory /__w/fesom2/fesom2

- name: Compile model
run: |
bash -l configure.sh ubuntu
bash -l configure.sh ubuntu -DENABLE_OPENMP=ON

- name: Create global test run with 4 OpenMP threads
run: |
Expand Down
18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.16)

# set default build type cache entry (do so before project(...) is called, which would create this cache entry on its own)
if(NOT CMAKE_BUILD_TYPE)
Expand All @@ -8,9 +8,7 @@ endif()

project(FESOM2.0)

set(CMAKE_VERBOSE_MAKEFILE ON)

option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) # cmake-internal switch to toggle if library targets are being build as STATIC or SHARED, see https://cmake.org/cmake/help/latest/guide/tutorial/Selecting%20Static%20or%20Shared%20Libraries.html
set(BUILD_SHARED_LIBS ON CACHE BOOL "Default to using shared libs")
set(TOPLEVEL_DIR ${CMAKE_CURRENT_LIST_DIR})
set(FESOM_COUPLED OFF CACHE BOOL "compile fesom standalone or with oasis support (i.e. coupled)")
set(OIFS_COUPLED OFF CACHE BOOL "compile fesom coupled to OpenIFS. (Also needs FESOM_COUPLED to work)")
Expand All @@ -21,3 +19,15 @@ set(OPENMP_REPRODUCIBLE OFF CACHE BOOL "serialize OpenMP loops that are critical
#set(VERBOSE OFF CACHE BOOL "toggle debug output")
#add_subdirectory(oasis3-mct/lib/psmile)
add_subdirectory(src)

foreach( _file fesom-config.cmake fesom-config-version.cmake fesom-targets.cmake )
execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${PROJECT_BINARY_DIR}/src/${_file} ${PROJECT_BINARY_DIR}/${_file} )
endforeach()

# Define ${PROJECT_NAME}_DIR in PARENT_SCOPE so that a `find_package( <this-project> )` in a bundle
# will easily find the project without requiring a `HINT <this-project>_BINARY_DIR` argument
if( NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR )
# Guard needed because PARENT_SCOPE cannot be used in top-level CMake project

set( fesom_DIR ${fesom_DIR} PARENT_SCOPE )
endif()
61 changes: 0 additions & 61 deletions cmake/FindBLAS.cmake

This file was deleted.

59 changes: 59 additions & 0 deletions cmake/fesom_export.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

macro( fesom_export )

set( options )
set( single_value_args )
set( multi_value_args TARGETS )

cmake_parse_arguments( _PAR "${options}" "${single_value_args}" "${multi_value_args}" ${_FIRST_ARG} ${ARGN} )

set( PROJECT_TARGETS_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake" )
file( REMOVE ${PROJECT_TARGETS_FILE} )


foreach( tgt ${_PAR_TARGETS} )
install( TARGETS ${tgt}
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${INSTALL_BIN_DIR}
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${INSTALL_LIB_DIR} )
set_target_properties( ${tgt} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
export( TARGETS ${tgt} APPEND FILE "${PROJECT_TARGETS_FILE}" )
endforeach()

include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${PROJECT_NAME}-config-version.cmake"
VERSION ${${PROJECT_NAME}_VERSION}
COMPATIBILITY AnyNewerVersion)

if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake.in )
configure_package_config_file(${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${INSTALL_CMAKE_DIR})
else()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake.in "include(${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}-targets.cmake)")
configure_package_config_file(${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${INSTALL_CMAKE_DIR})
endif()

install(EXPORT ${PROJECT_NAME}-targets DESTINATION "${INSTALL_CMAKE_DIR}")
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
DESTINATION "${INSTALL_CMAKE_DIR}")

install( DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR}
DESTINATION module/${PROJECT_NAME}
COMPONENT modules )

# Define ${PROJECT_NAME}_DIR in PARENT_SCOPE so that a `find_package( <this-project> )` in a bundle
# will easily find the project without requiring a `HINT <this-project>_BINARY_DIR` argument [ECBUILD-460]
if( NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR )
# Guard needed because PARENT_SCOPE cannot be used in top-level CMake project

set( ${PROJECT_NAME}_DIR ${PROJECT_BINARY_DIR} PARENT_SCOPE )
endif()

endmacro()
145 changes: 145 additions & 0 deletions cmake/fesom_setup.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# To a large degree this follows the ecbuild setup
message("[${PROJECT_NAME}]")

### Setup project

if(CMAKE_VERSION VERSION_LESS 3.21)
get_property(not_top DIRECTORY PROPERTY PARENT_DIRECTORY)
if(NOT not_top)
set(PROJECT_IS_TOP_LEVEL true)
endif()
endif()

set(BUILD_SHARED_LIBS ON CACHE BOOL "Default to using shared libs")
set(CMAKE_LINK_DEPENDS_NO_SHARED ON) # relink of downstream libraries not required when shared library is rebuilt

# Default build type: Release
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")

# Set location to look for find_package modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake ${CMAKE_MODULE_PATH})

# Set Fortran module directory
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/module/${PROJECT_NAME} )

# Build-dir destinations
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# Set install directories
include(GNUInstallDirs)
if( NOT INSTALL_BIN_DIR )
set( INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR} )
endif()
if( NOT INSTALL_LIB_DIR )
set( INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} )
endif()
if( NOT INSTALL_INCLUDE_DIR )
set( INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} )
endif()
set( INSTALL_CMAKE_DIR ${INSTALL_LIB_DIR}/cmake/${PROJECT_NAME} )

mark_as_advanced( INSTALL_BIN_DIR )
mark_as_advanced( INSTALL_LIB_DIR )
mark_as_advanced( INSTALL_INCLUDE_DIR )
mark_as_advanced( INSTALL_CMAKE_DIR )

# make sure nothing breaks if INSTALL_LIB_DIR is not lib
if( NOT INSTALL_LIB_DIR STREQUAL "lib" AND NOT EXISTS ${CMAKE_BINARY_DIR}/${INSTALL_LIB_DIR} )
execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink lib ${CMAKE_BINARY_DIR}/${INSTALL_LIB_DIR} )
endif()

# for macosx use @rpath in a target’s install name (CMP0042)
set( CMAKE_MACOSX_RPATH ON )

# add the automatic parts to RPATH which point to dirs outside build tree
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )

# use RPATHs for the build tree
set( CMAKE_SKIP_BUILD_RPATH FALSE )

# build with *relative* rpaths by default
option( ENABLE_RPATHS "when installing insert RPATHS into binaries" ON )
option( ENABLE_RELATIVE_RPATHS "try to use relative RPATHS, including build dir" ON )
if( ENABLE_RELATIVE_RPATHS )
set( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
else()
# in case the RPATH is absolute, the install RPATH cannot be set
# at build-time since it breaks the build tree dynamic links
set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE )
endif()


foreach( p LIB BIN INCLUDE DATA CMAKE )
set( var INSTALL_${p}_DIR )
set( ${PROJECT_NAME}_FULL_INSTALL_${p}_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_${p}_DIR}"
CACHE INTERNAL "${PROJECT_NAME} ${p} full install path" )
endforeach()


function( _path_append var path )
list( FIND ${var} ${path} _found )
if( _found EQUAL "-1" )
list( APPEND ${var} ${path})
endif()
set( ${var} "${${var}}" PARENT_SCOPE ) #
endfunction()

function( _make_relative_rpath_entry entry var )

if( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set( ${var} "@loader_path/${entry}" PARENT_SCOPE )

elseif( CMAKE_SYSTEM_NAME MATCHES "FreeBSD|Linux|SunOS" )
set( ${var} "$ORIGIN/${entry}" PARENT_SCOPE )

elseif( CMAKE_SYSTEM_NAME MATCHES "AIX" ) # always relative to executable path
set( ${var} "${entry}" PARENT_SCOPE )

else()
set( ${var} "${CMAKE_INSTALL_PREFIX}/${entry}" PARENT_SCOPE )

endif()
endfunction()

macro( append_to_rpath RPATH_DIRS )

foreach( RPATH_DIR ${RPATH_DIRS} )

if( NOT ${RPATH_DIR} STREQUAL "" )

file( TO_CMAKE_PATH ${RPATH_DIR} RPATH_DIR ) # sanitize the path

if( IS_ABSOLUTE ${RPATH_DIR} )
_path_append( CMAKE_INSTALL_RPATH "${RPATH_DIR}" )
else()
_make_relative_rpath_entry( "${RPATH_DIR}" rpath_dir_rel )
_path_append( CMAKE_INSTALL_RPATH ${rpath_dir_rel} )
endif()

endif()

endforeach()

endmacro( append_to_rpath )


if( ENABLE_RPATHS )
if( ENABLE_RELATIVE_RPATHS )
file( RELATIVE_PATH relative_rpath ${CMAKE_INSTALL_PREFIX}/${INSTALL_BIN_DIR} ${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR} )
append_to_rpath( ${relative_rpath} )
else() # make rpaths absolute
append_to_rpath( "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" )
endif()
endif()

# put the include dirs which are in the source or build tree
# before all other include dirs, so the headers in the sources
# are prefered over the already installed ones (since cmake 2.4.1)
set( CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON )

# Set -fPIC flag etc.
set( CMAKE_POSITION_INDEPENDENT_CODE ON )

include(fesom_export)
Loading
Loading