Skip to content

Commit

Permalink
Merge pull request #571 from FESOM/production_DE
Browse files Browse the repository at this point in the history
Production de merge into refactoring
  • Loading branch information
patrickscholz authored Jun 11, 2024
2 parents 269c779 + cd83463 commit 7849ff8
Show file tree
Hide file tree
Showing 56 changed files with 2,712 additions and 1,284 deletions.
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 ${PWD}
- 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: Test downstream from install-dir
run: |
export fesom_ROOT=${PWD}
rm -rf test_downstream/build
cmake -S test_downstream -B test_downstream/build -DASSERT_HAVE_IFS_INTERFACE=OFF -DASSERT_FESOM_DIR=${fesom_ROOT}
cmake --build test_downstream/build
test_downstream/build/main
- name: Compile model (library)
- name: Test downstream from ifs_interface build-dir
run: |
bash ./test/ifs_interface/configure_lib.sh -l
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: Library exists
- 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 ${PWD}
- 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 @@ -23,3 +21,15 @@ set(ASYNC_ICEBERGS ON CACHE BOOL "compile fesom with or without support for asyn
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)
3 changes: 3 additions & 0 deletions config/namelist.forcing
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@ age_start_year=2000
chl_data_source ='None' !'Sweeney' monthly chlorophyll climatology or 'NONE' for constant chl_const (below). Make use_sw_pene=.TRUE. in namelist.config!
nm_chl_data_file ='/work/ollie/clidyn/forcing/Sweeney/Sweeney_2005.nc'
chl_const = 0.1
use_runoff_mapper = .FALSE.
runoff_basins_file = 'runoff_maps_regular.nc'
runoff_radius = 500000.
/
Loading

0 comments on commit 7849ff8

Please sign in to comment.