Skip to content

Commit

Permalink
Cleanup Serialbox CMake config + add arolla env (#217)
Browse files Browse the repository at this point in the history
- Removes some boost settings which are hopefully outdated (as we are not using any compiled boost libraries by default).
- Adds arolla to the testing
  • Loading branch information
havogt authored Nov 6, 2019
1 parent 83bc38e commit 26de949
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 33 deletions.
46 changes: 17 additions & 29 deletions cmake/SerialboxConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
##
## S E R I A L B O X
##
## This file is distributed under terms of BSD license.
## This file is distributed under terms of BSD license.
## See LICENSE.txt for more information.
##
##===------------------------------------------------------------------------------------------===##
Expand Down Expand Up @@ -71,7 +71,7 @@ function( serialbox_alias_targets )
# serialbox_alias_targets( alias target_shared target_static align )
#
# Creates ALIAS target for given targets. Prefer target_shared if availabe
#
#
set( _alias ${ARGV0} )
set( _target_shared ${ARGV1} )
set( _target_static ${ARGV2} )
Expand Down Expand Up @@ -107,7 +107,7 @@ endfunction()
# Find Serialbox libraries
#====--------------------------------------------------------------------------------------------===

# Import library targets
# Import library targets
if( NOT @PROJECT_NAME@_TARGETS_EXPORTED )
include("${CMAKE_CURRENT_LIST_DIR}/SerialboxTargets.cmake")
set( ${PROJECT_NAME}_TARGETS_EXPORTED TRUE )
Expand Down Expand Up @@ -151,57 +151,46 @@ if(NOT(DEFINED SERIALBOX_NO_EXTERNAL_LIBS))
#
# Pthreads
#
message( STATUS "Serialbox: find_depencency( Threads )" )
message( STATUS "Serialbox: find_dependency(Threads)" )
find_dependency(Threads)

#
# Boost (Serialbox always uses the shared Boost libraries)
#
get_property(SHARED_LIB_SUPPORT GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
if (SHARED_LIB_SUPPORT)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_USE_MULTITHREADED ON)
endif()

set(BOOST_LIBRARYDIR "${SERIALBOX_BOOST_LIBRARY_DIRS}")
set(BOOST_INCLUDEDIR "${SERIALBOX_BOOST_INCLUDE_DIRS}")
set(Boost_NO_SYSTEM_PATHS "ON") # Force boost to search locations specified above

message( STATUS "Serialbox: find_depencency( Boost ${SERIALBOX_BOOST_VERSION} EXACT COMPONENTS ${SERIALBOX_REQUIRED_BOOST_COMPONENTS}}")
find_dependency(Boost
${SERIALBOX_BOOST_VERSION} EXACT COMPONENTS ${SERIALBOX_REQUIRED_BOOST_COMPONENTS})
message( STATUS "Serialbox: find_dependency(Boost ${SERIALBOX_BOOST_VERSION} COMPONENTS ${SERIALBOX_REQUIRED_BOOST_COMPONENTS})")
find_dependency(Boost
${SERIALBOX_BOOST_VERSION} COMPONENTS ${SERIALBOX_REQUIRED_BOOST_COMPONENTS})
if(Boost_FOUND)
list(APPEND SERIALBOX_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
else()

# Give some diagnostic infos
set(WARN_STR "Serialbox: Boost (${SERIALBOX_BOOST_VERSION}) NOT found!")

if(DEFINED Boost_LIB_VERSION)
string(REPLACE "_" "." FOUND_BOOST_VERSION ${Boost_LIB_VERSION})
list(APPEND WARN_STR " (Found Boost ${FOUND_BOOST_VERSION})")
list(APPEND WARN_STR " (Found Boost ${FOUND_BOOST_VERSION})")
endif()

list(APPEND WARN_STR "\nRequired components:")

foreach(component ${SERIALBOX_REQUIRED_BOOST_COMPONENTS})
list(APPEND WARN_STR "\n - ${component}")
endforeach()

message(WARNING ${WARN_STR} "\n")
endif()

#
# OpenSSL
#
if(SERIALBOX_HAS_OPENSSL)
find_package(OpenSSL QUIET)
if(NOT OpenSSL_FOUND)
if(NOT OpenSSL_FOUND)
message(WARNING "Serialbox depends on the OpenSSL libraries")
endif()
endif()

#
# NetCDF
#
Expand All @@ -210,7 +199,7 @@ if(NOT(DEFINED SERIALBOX_NO_EXTERNAL_LIBS))
if(NETCDF_ROOT_ENV)
set(NETCDF_ROOT ${NETCDF_ROOT_ENV} CACHE PATH "NetCDF install path.")
endif()

if(NOT(DEFINED NETCDF_ROOT))
find_path(NETCDF_ROOT NAMES include/netcdf.h)
else()
Expand All @@ -222,7 +211,7 @@ if(NOT(DEFINED SERIALBOX_NO_EXTERNAL_LIBS))
if(NETCDF_LIBRARIES)
mark_as_advanced(NETCDF_LIBRARIES)
else()
message(WARNING
message(WARNING
"Serialbox depends on the NetCDF-4 libraries. (Try setting NETCDF_ROOT in the env)")
endif()
endif()
Expand All @@ -233,4 +222,3 @@ endif()
#====--------------------------------------------------------------------------------------------===
find_file(SERIALBOX_PPSER pp_ser.py @PACKAGE_PYTHON_INSTALL_DIR@/pp_ser)
include(@PACKAGE_CMAKE_INSTALL_DIR@/SerialboxTooling.cmake)

10 changes: 7 additions & 3 deletions cmake/modules/Fortran/Cray.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
##
## S E R I A L B O X
##
## This file is distributed under terms of BSD license.
## This file is distributed under terms of BSD license.
## See LICENSE.txt for more information.
##
##===------------------------------------------------------------------------------------------===##

# General Flags (add to default)
set(CMAKE_Fortran_FLAGS
"${CMAKE_Fortran_FLAGS} -ffree -N255 -ec -eC -eI -eF -hnosecond_underscore -hflex_mp=conservative -Ofp1 -hadd_paren -ra")
set(CMAKE_Fortran_FLAGS
"${CMAKE_Fortran_FLAGS} -ffree -N255 -ec -eC -eI -eF -hflex_mp=conservative -Ofp1 -hadd_paren -ra")

if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0.0)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -hnosecond_underscore ")
endif()

# OpenACC flags
set(OpenACC_FLAGS "-hnoacc")
Expand Down
4 changes: 3 additions & 1 deletion tools/cscs-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ elif [ "$(hostname | grep kesch)" != "" ] ; then
MYHOST="kesch"
elif [ "$(hostname | grep daint)" != "" ] ; then
MYHOST="daint"
elif [ "$(hostname | grep arolla)" != "" ] ; then
MYHOST="arolla"
elif [ "$(hostname | grep tave)" != "" ] ; then
MYHOST="tave"
else
Expand Down Expand Up @@ -193,7 +195,7 @@ fi

#NetCDF
SERIALBOX_USE_NETCDF=OFF
if [ "${FC_COMPILER}" = "gfortran" ]; then
if [ "${FC_COMPILER}" = "gfortran" ] && [ "$MYHOST" != "arolla" ]; then
SERIALBOX_USE_NETCDF=ON
fi

Expand Down
99 changes: 99 additions & 0 deletions tools/cscs-scripts/env_arolla.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash
##===-----------------------------------------------------------*- bash -*-===##
##
## S E R I A L B O X
##
## This file is distributed under terms of BSD license.
## See LICENSE.txt for more information.
##
##===----------------------------------------------------------------------===##

## Print help statement and exit.
print_help()
{
printf "Usage: $0 [options]\n\n"
printf "Options:\n"

# --fc-compiler
printf " %-35s %s\n" \
"-f, --fc-compiler FORTRAN_COMPILER" \
"Fortran compiler to use (set to "
printf " %-35s %s\n" "" "environment variable FC)."

# --help
printf " %-35s %s\n" "-h, --help" "Print this help statement."
printf "\n"
exit 0
}

## Convert to lower case and remove all whitespaces
to_lower_and_trim()
{
if [ $# -ne 1 ]; then
echo "$0: internal error." ; exit 1
fi

local to_lower=$(echo "$1" | tr '[:upper:]' '[:lower:]')
local trim_whitespaces=${to_lower// /}
echo "${trim_whitespaces}"
}

#------------------------------ Parse options ----------------------------------
ENV_ARGS=$(getopt -o f:h:: -l fc-compiler,help:: -n 'env_kesch' -- "$@");

if [ $? -ne 0 ]; then
exit 1
fi

eval set -- "$ENV_ARGS"

while true; do
case "$1" in
-h|--h*) print_help; exit 0;;
-f|--fc-compiler) ARG_FC_COMPILER=$(to_lower_and_trim $2); shift 2;;
--) shift; break ;;
*) echo "$0: internal error." ; exit 1 ;;
esac
done

# Fortran Compiler
if [ -z ${ARG_FC_COMPILER+x} ]; then
echo "$0: error: fortran compiler is not set"
exit 1
else
FC_COMPILER=${ARG_FC_COMPILER}
fi

#------------------------------ Set environment --------------------------------

module load craype-x86-skylake
module load craype-network-infiniband
module load slurm
module load cmake/3.14.3

if [ "$FC_COMPILER" = "pgfortran" ]; then
module load PrgEnv-pgi/19.4
module load gcc
elif [ "$FC_COMPILER" = "ftn" ]; then
module load PrgEnv-cray
module load gcc
elif [ "$FC_COMPILER" = "ifort" ]; then
echo "not defined"
exit 1
else
module load PrgEnv-gnu
fi

#module load netcdf-c++/4.3.0-gmvolf-18.12
#module load hdf5/1.10.5-gmvolf-18.12
#export NETCDF_ROOT=${EBROOTNETCDF}

export CXX=$(which g++)
export CC=$(which gcc)
export FC=$(which $FC_COMPILER)

export Boost_NO_SYSTEM_PATHS=true
export Boost_NO_BOOST_CMAKE=true

export BOOST_ROOT=/project/c14/install/daint/boost/boost_1_67_0

0 comments on commit 26de949

Please sign in to comment.