Compare commits

..

5 Commits

Author SHA1 Message Date
Atgeirr Flø Rasmussen
169003bc87 Update package release tags. 2015-10-28 15:10:43 +01:00
Atgeirr Flø Rasmussen
99ed183851 Improve the UseVersion module.
The changes are:
 - Add new macros PROJECT_VERSION_NAME and PROJECT_VERSION_HASH
   in addition to the existing PROJECT_VERSION.
 - Add header include guards.
2015-10-28 15:09:11 +01:00
Atgeirr Flø Rasmussen
3a1c355100 Merge pull request #62 from akva2/release/2015.10
Bump version and unify format of dune.module.
2015-10-26 12:31:55 +01:00
Atgeirr Flø Rasmussen
8dcfef833a Bump version and unify format of dune.module.
Backports relevant parts of 9265a695ea
2015-10-26 11:08:52 +01:00
Arne Morten Kvarving
5f471c0ec8 update versions 2015-10-23 10:46:06 +02:00
109 changed files with 765 additions and 5351 deletions

3
.gitignore vendored
View File

@@ -41,6 +41,3 @@ install_manifest.txt
CTestTestfile.cmake CTestTestfile.cmake
DartConfiguration.tcl DartConfiguration.tcl
Testing/ Testing/
# Build directory in source.
build/

View File

@@ -1,39 +0,0 @@
language: cpp
compiler:
- gcc
addons:
apt:
sources:
- boost-latest
- ubuntu-toolchain-r-test
- george-edison55-precise-backports
packages:
- libboost1.55-all-dev
- gcc-4.8
- g++-4.8
- gfortran-4.8
- liblapack-dev
- libgmp3-dev
- libsuitesparse-dev
- libeigen3-dev
- bc
- cmake
- cmake-data
env:
global:
- TRAVIS_CI=1
before_script:
- export CXX="g++-4.8" CC="gcc-4.8" FC="gfortran-4.8"
- cd ..
- opm-common/travis/build-prereqs.sh
- opm-common/travis/clone-opm.sh opm-common
script: opm-common/travis/build-and-test.sh opm-common

View File

@@ -12,7 +12,7 @@ endmacro (dir_hook)
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "set(OPM_MACROS_ROOT ${CMAKE_INSTALL_PREFIX}/share/opm) set(OPM_PROJECT_EXTRA_CODE_INSTALLED "set(OPM_MACROS_ROOT ${CMAKE_INSTALL_PREFIX}/share/opm)
list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)") list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)")
set(OPM_PROJECT_EXTRA_CODE_INTREE "set(OPM_MACROS_ROOT ${OPM_MACROS_ROOT}) set(OPM_PROJECT_EXTRA_CODE_INTREE "set(OPM_MACROS_ROOT ${OPM_COMMON_ROOT})
list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)") list(APPEND CMAKE_MODULE_PATH \${OPM_MACROS_ROOT}/cmake/Modules)")
# project information is in dune.module. Read this file and set variables. # project information is in dune.module. Read this file and set variables.

View File

@@ -20,28 +20,23 @@
# you should only add to this list if the *user* of # you should only add to this list if the *user* of
# the library needs it. # the library needs it.
# originally generated with the command:
# find opm -name '*.c*' -printf '\t%p\n' | sort
list (APPEND MAIN_SOURCE_FILES list (APPEND MAIN_SOURCE_FILES
opm/common/data/SimulationDataContainer.cpp
opm/common/OpmLog/CounterLog.cpp
opm/common/OpmLog/EclipsePRTLog.cpp
opm/common/OpmLog/LogBackend.cpp
opm/common/OpmLog/Logger.cpp
opm/common/OpmLog/LogUtil.cpp
opm/common/OpmLog/OpmLog.cpp
opm/common/OpmLog/StreamLog.cpp
opm/common/OpmLog/TimerLog.cpp
) )
# originally generated with the command:
# find tests -name '*.cpp' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_SOURCE_FILES list (APPEND TEST_SOURCE_FILES
tests/test_SimulationDataContainer.cpp )
tests/test_cmp.cpp
tests/test_OpmLog.cpp
tests/test_messagelimiter.cpp
)
# originally generated with the command:
# find tests -name '*.xml' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_DATA_FILES list (APPEND TEST_DATA_FILES
) )
# originally generated with the command:
# find tutorials examples -name '*.c*' -printf '\t%p\n' | sort
list (APPEND EXAMPLE_SOURCE_FILES list (APPEND EXAMPLE_SOURCE_FILES
) )
@@ -54,20 +49,5 @@ list (APPEND PROGRAM_SOURCE_FILES
list( APPEND PUBLIC_HEADER_FILES list( APPEND PUBLIC_HEADER_FILES
opm/common/ErrorMacros.hpp opm/common/ErrorMacros.hpp
opm/common/Exceptions.hpp opm/common/Exceptions.hpp
opm/common/ResetLocale.hpp
opm/common/Unused.hpp
opm/common/Valgrind.hpp
opm/common/data/SimulationDataContainer.hpp
opm/common/OpmLog/CounterLog.hpp
opm/common/OpmLog/EclipsePRTLog.hpp
opm/common/OpmLog/LogBackend.hpp
opm/common/OpmLog/Logger.hpp
opm/common/OpmLog/LogUtil.hpp
opm/common/OpmLog/MessageFormatter.hpp
opm/common/OpmLog/MessageLimiter.hpp
opm/common/OpmLog/OpmLog.hpp
opm/common/OpmLog/StreamLog.hpp
opm/common/OpmLog/TimerLog.hpp
opm/common/util/numeric/cmp.hpp
opm/common/utility/platform_dependent/disable_warnings.h opm/common/utility/platform_dependent/disable_warnings.h
opm/common/utility/platform_dependent/reenable_warnings.h) opm/common/utility/platform_dependent/reenable_warnings.h )

View File

@@ -1,3 +1,3 @@
# opm-common ![alt text](https://travis-ci.org/OPM/opm-common.svg?branch=master "TravisCI Build Status") # opm-common
Contains common components used throughout all of OPM, Contains common components used througout all of OPM,
in particular CMake modules for the build system. in particular CMake modules for the build system.

View File

@@ -27,10 +27,11 @@
function (configure_vars obj syntax filename verb) function (configure_vars obj syntax filename verb)
# this is just to make the syntax look like the build-in commands # this is just to make the syntax look like the build-in commands
if (NOT ("X Y Z ${obj}" STREQUAL "X Y Z FILE" AND if (NOT ("${obj}" STREQUAL "FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND")))) (("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
message (FATAL_ERROR "Syntax error in argument list") message (FATAL_ERROR "Syntax error in argument list")
endif () endif (NOT ("${obj}" STREQUAL "FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
if (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE"))) if (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
message (FATAL_ERROR "Invalid target syntax \"${syntax}\"") message (FATAL_ERROR "Invalid target syntax \"${syntax}\"")
endif (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE"))) endif (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
@@ -66,14 +67,14 @@ function (configure_vars obj syntax filename verb)
# if the name of a variable has the syntax of a comments, write it # if the name of a variable has the syntax of a comments, write it
# verbatim to the file; this can be used to create headings # verbatim to the file; this can be used to create headings
if ("X Y Z ${_var}" MATCHES "^X Y Z /[/*]") if ("${_var}" MATCHES "^/[/*]")
if (NOT _prev_verbatim) if (NOT _prev_verbatim)
file (APPEND "${filename}" "\n") file (APPEND "${filename}" "\n")
endif (NOT _prev_verbatim) endif (NOT _prev_verbatim)
file (APPEND "${filename}" "${_var}\n") file (APPEND "${filename}" "${_var}\n")
set (_prev_verbatim TRUE) set (_prev_verbatim TRUE)
else () else ("${_var}" MATCHES "^/[/*]")
# write a CMake statements that warns if the value has changed # write a CMake statements that warns if the value has changed
if ("${syntax}" STREQUAL "CMAKE") if ("${syntax}" STREQUAL "CMAKE")
@@ -105,6 +106,6 @@ function (configure_vars obj syntax filename verb)
endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL "")) endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
set (_prev_verbatim FALSE) set (_prev_verbatim FALSE)
endif () endif ("${_var}" MATCHES "^/[/*]")
endforeach(_var) endforeach(_var)
endfunction (configure_vars obj syntax filename verb) endfunction (configure_vars obj syntax filename verb)

View File

@@ -0,0 +1,150 @@
#find_package(PkgConfig)
include(CheckLibraryExists)
macro(_opm_set_alugrid val)
set(ALUGRID_FOUND ${val})
if(NOT ALUGRID_FOUND AND ALUGRID_FIND_REQUIRED)
message(FATAL_ERROR "Could not find required libary ALUGrid")
endif()
# print status message if requested
if(NOT ALUGRID_FIND_QUIETLY)
if(ALUGRID_FOUND)
message(STATUS "Found ALUGrid")
else()
message(STATUS "Could not find ALUGrid")
endif()
endif()
endmacro()
if(ALUGRID_ROOT)
find_path(ALUGRID_PKGCONFIG_DIR alugrid.pc PATHS ${ALUGRID_ROOT}
PATH_SUFFIXES lib/pkgconfig/ alugrid/lib/pkgconfig
NO_DEFAULT_PATH)
find_file(ALUGRID_VERSION alugridversion PATHS ${ALUGRID_ROOT}/bin
NO_DEFAULT_PATH)
else()
find_path(ALUGRID_PKGCONFIG_DIR alugrid.pc
PATH_SUFFIXES lib/pkgconfig/ alugrid/lib/pkgconfig)
get_filename_component(_GUESSED_ALUGRID_ROOT ${ALUGRID_PKGCONFIG_DIR}/../../ ABSOLUTE)
find_file(ALUGRID_VERSION alugridversion PATHS ${_GUESSED_ALUGRID_ROOT}/bin NO_DEFAULT_PATH)
if(ALUGRID_VERSION)
set(ALUGRID_ROOT ${_GUESSED_ALUGRID_ROOT})
else(ALUGRID_VERSION_PATH)
get_filename_component(_GUESSED_ALUGRID_ROOT ${ALUGRID_PKGCONFIG_DIR}/../../.. ABSOLUTE)
find_file(ALUGRID_VERSION alugridversion
PATHS ${_GUESSED_ALUGRID_ROOT}
PATH_SUFFIXES bin
NO_DEFAULT_PATH)
if(ALUGRID_VERSION)
set(ALUGRID_ROOT ${_GUESSED_ALUGRID_ROOT})
endif(ALUGRID_VERSION)
endif(ALUGRID_VERSION)
endif()
unset(ALUGRID_PKGCONFIG_DIR CACHE)
set(ALUGRID_VERSION_REQUIRED 1.50)
if(NOT ALUGRID_VERSION)
message(STATUS "Could not find ALUGrid.")
_opm_set_alugrid(0)
return()
endif(NOT ALUGRID_VERSION)
execute_process(COMMAND ${ALUGRID_VERSION} -c ${ALUGRID_VERSION_REQUIRED} OUTPUT_VARIABLE ALUGRID_VERSION)
if(ALUGRID_VERSION LESS 0)
message(STATUS "ALUGrid version is less than ${ALUGRID_VERSION_REQUIRED}")
_opm_set_alugrid(0)
unset(ALUGRID_VERSION CACHE)
return()
else()
message(STATUS "ALUGrid version is compatible")
endif()
unset(ALUGRID_VERSION CACHE)
find_path(ALUGRID_INCLUDE_DIR "alugrid_serial.h"
PATHS "${ALUGRID_ROOT}" PATH_SUFFIXES "include" "include/serial"
NO_DEFAULT_PATH DOC "Include path of serial alugrid headers.")
if (NOT ALUGRID_INCLUDE_DIR)
message(STATUS "Could not deterimine ALUGrid include directory")
_opm_set_alugrid(0)
return()
endif()
mark_as_advanced(ALUGRID_INCLUDE_DIR)
find_library(ALUGRID_LIBRARY alugrid
PATHS "${ALUGRID_ROOT}"
PATH_SUFFIXES lib lib32 lib64
DOC "ALUGrid library"
NO_DEFAULT_PATH)
if (NOT ALUGRID_LIBRARY)
message(STATUS "Could not find ALUGrid usable library")
_opm_set_alugrid(0)
return()
endif()
set(ALUGRID_LIBRARIES ${ALUGRID_LIBRARY})
mark_as_advanced(ALUGRID_LIBRARIES)
set(ALUGRID_INCLUDE_DIRS
${ALUGRID_INCLUDE_DIR}
${ALUGRID_INCLUDE_DIR}/serial
${ALUGRID_INCLUDE_DIR}/duneinterface)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ALUGRID_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ALUGRID_LIBRARIES})
check_include_file_cxx(stlheaders.h ALUGRID_SERIAL_FOUND)
if(ALUGRID_SERIAL_FOUND)
check_cxx_source_compiles("#include <alugrid_defineparallel.h>
#if ALU3DGRID_BUILD_FOR_PARALLEL == 0
#error
#endif
int main(){}"
ALUGRID_PARALLEL_FOUND)
else()
message(STATUS "alugrid_serial.h found, but could not be compiled.")
_opm_set_alugrid(0)
return()
endif()
if(ALUGRID_PARALLEL_FOUND AND MPI_FOUND)
# must link with METIS if we are going to use parallel ALUGrid
find_package(METIS)
if (METIS_FOUND)
list(APPEND ALUGRID_LIBRARIES ${METIS_LIBRARIES})
# check for parallel ALUGrid
find_path(ALUGRID_PARALLEL_INCLUDE_PATH "alumetis.hh"
PATHS ${ALUGRID_INCLUDE_DIR}
PATH_SUFFIXES "parallel"
NO_DEFAULT_PATH)
if(ALUGRID_PARALLEL_INCLUDE_PATH)
list(APPEND ALUGRID_INCLUDE_DIRS ${ALUGRID_PARALLEL_INCLUDE_PATH})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ALUGRID_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ALUGRID_LIBRARIES})
#set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
check_include_file_cxx(alugrid_parallel.h ALUGRID_PARALLEL_FOUND)
unset(ALUGRID_PARALLEL_INCLUDE_PATH CACHE)
if(NOT ALUGRID_PARALLEL_FOUND)
message(STATUS "alumetis.hh not found in ${ALUGRID_PARALLEL_INCLUDE_PATH}")
endif()
else()
message (STATUS "METIS not found, parallel ALUGrid disabled")
set (ALUGRID_PARALLEL_FOUND 0)
endif()
else()
message(STATUS "alumetis.hh not found (required by parallel alugrid).")
set(ALUGRID_PARALLEL_FOUND 0)
endif()
endif()
if(ALUGRID_SERIAL_FOUND)
_opm_set_alugrid(1)
endif(ALUGRID_SERIAL_FOUND)

View File

@@ -8,6 +8,7 @@
# HAVE_SHARED_PTR True if std::shared_ptr is available # HAVE_SHARED_PTR True if std::shared_ptr is available
# HAVE_UNIQUE_PTR True if std::unique_ptr is available # HAVE_UNIQUE_PTR True if std::unique_ptr is available
# HAVE_NULLPTR True if nullptr is available # HAVE_NULLPTR True if nullptr is available
# HAVE_REGEX True if std::regex available and sufficiently usable
# HAVE_ARRAY True if header <array> and fill() are available # HAVE_ARRAY True if header <array> and fill() are available
# HAVE_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported # HAVE_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported
# HAS_ATTRIBUTE_UNUSED True if attribute unused is supported # HAS_ATTRIBUTE_UNUSED True if attribute unused is supported
@@ -33,65 +34,39 @@ include(CheckIncludeFileCXX)
# macro to only add option once # macro to only add option once
include(AddOptions) include(AddOptions)
# Force CXX Standard cross platfrom for CMakeVersion >=3.1 # try to use compiler flag -std=c++11
set(CMAKE_CXX_EXTENSIONS OFF) CHECK_CXX_ACCEPTS_FLAG("-std=c++11" CXX_FLAG_CXX11)
if(CXX_FLAG_CXX11)
add_options (CXX ALL_BUILDS "-std=c++11")
set(CXX_STD0X_FLAGS "-std=c++11")
else()
# try to use compiler flag -std=c++0x for older compilers
CHECK_CXX_ACCEPTS_FLAG("-std=c++0x" CXX_FLAG_CXX0X)
if(CXX_FLAG_CXX0X)
add_options (CXX ALL_BUILDS "-std=c++0x")
set(CXX_STD0X_FLAGS "-std=c++0x")
endif(CXX_FLAG_CXX0X)
endif(CXX_FLAG_CXX11)
if(NOT CMAKE_CXX_STANDARD) # if we are building with an Apple toolchain in MacOS X,
set(CMAKE_CXX_STANDARD 11) # we cannot use the old GCC 4.2 fork, but must use the
# new runtime library
set (CXX_STDLIB_FLAGS)
if(NOT MSVC) string (TOUPPER "${CMAKE_CXX_COMPILER_ID}" _comp_id)
foreach(_flag "14" "11") if (APPLE AND (_comp_id MATCHES "CLANG"))
set(_FLAG "CXX_FLAG_CXX${_flag}") CHECK_CXX_ACCEPTS_FLAG ("-stdlib=libc++" CXX_FLAG_STDLIB_LIBCXX)
string(TOUPPER ${_FLAG} _FLAG) if (CXX_FLAG_STDLIB_LIBCXX)
# try to use compiler flag -std=c++${_flag} add_options (CXX ALL_BUILDS "-stdlib=libc++")
CHECK_CXX_ACCEPTS_FLAG("-std=c++${_flag}" ${_FLAG}) set (CXX_STDLIB_FLAGS "-stdlib=libc++")
endif (CXX_FLAG_STDLIB_LIBCXX)
if(${_FLAG}) endif (APPLE AND (_comp_id MATCHES "CLANG"))
if(CMAKE_VERSION VERSION_LESS 3.1)
add_options (CXX ALL_BUILDS "-std=c++${_flag}")
endif()
set(CXX_STD0X_FLAGS "-std=c++${_flag}")
#Use vriables for CMake > 3.1 set the standard with no extensions
set(CMAKE_CXX_STANDARD ${_flag})
break()
endif()
endforeach()
endif(NOT MSVC)
endif()
if(CMAKE_VERSION VERSION_LESS 3.1)
# if we are building with an Apple toolchain in MacOS X,
# we cannot use the old GCC 4.2 fork, but must use the
# new runtime library
set (CXX_STDLIB_FLAGS)
string (TOUPPER "${CMAKE_CXX_COMPILER_ID}" _comp_id)
if (APPLE AND (_comp_id MATCHES "CLANG"))
CHECK_CXX_ACCEPTS_FLAG ("-stdlib=libc++" CXX_FLAG_STDLIB_LIBCXX)
if (CXX_FLAG_STDLIB_LIBCXX)
add_options (CXX ALL_BUILDS "-stdlib=libc++")
set (CXX_STDLIB_FLAGS "-stdlib=libc++")
endif (CXX_FLAG_STDLIB_LIBCXX)
endif (APPLE AND (_comp_id MATCHES "CLANG"))
# to format the command-line options pretty, we have an optional space
if (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
set (CXX_SPACE " ")
else (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
set (CXX_SPACE)
endif (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
endif()
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
# Workaround bug in cmake:
# cxx standard flags are not applied in CheckCXXSourceCompiles
if (CMAKE_CXX_STANDARD EQUAL 14)
add_options(CXX ALL_BUILDS ${CMAKE_CXX14_STANDARD_COMPILE_OPTION})
else()
add_options(CXX ALL_BUILDS ${CMAKE_CXX11_STANDARD_COMPILE_OPTION})
endif()
endif()
# to format the command-line options pretty, we have an optional space
if (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
set (CXX_SPACE " ")
else (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
set (CXX_SPACE)
endif (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
# perform tests # perform tests
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
@@ -170,6 +145,33 @@ CHECK_CXX_SOURCE_COMPILES("
" HAVE_NULLPTR " HAVE_NULLPTR
) )
# <regex>
CHECK_CXX_SOURCE_RUNS("
#include <regex>
int main(void)
{
std::regex r(\"AB.*|BC+|DE.+\", std::regex::extended);
if (!std::regex_match(\"AB\", r))
return 1;
if (!std::regex_match(\"ABC\", r))
return 2;
if (!std::regex_match(\"ABC!#\", r))
return 3;
if (std::regex_match(\"B\", r))
return 4;
if (!std::regex_match(\"BC\", r))
return 5;
if (std::regex_match(\"BCE\", r))
return 6;
if (std::regex_match(\"DE\", r))
return 7;
if (!std::regex_match(\"DEF\", r))
return 8;
return 0;
}
" HAVE_REGEX
)
# constexpr # constexpr
CHECK_CXX_SOURCE_COMPILES(" CHECK_CXX_SOURCE_COMPILES("
template <class T> template <class T>
@@ -185,7 +187,7 @@ CHECK_CXX_SOURCE_COMPILES("
# array and fill # array and fill
CHECK_CXX_SOURCE_COMPILES(" CHECK_CXX_SOURCE_COMPILES("
#include <array> #include <array>
int main(void) int main(void)
{ {
std::array<int,2> a; std::array<int,2> a;
@@ -240,24 +242,24 @@ CHECK_CXX_SOURCE_COMPILES("
{ {
bar() DEP; bar() DEP;
}; };
class peng { } DEP; class peng { } DEP;
template <class T> template <class T>
class t_bar class t_bar
{ {
t_bar() DEP; t_bar() DEP;
}; };
template <class T> template <class T>
class t_peng { class t_peng {
t_peng() {}; t_peng() {};
} DEP; } DEP;
void foo() DEP; void foo() DEP;
void foo() {}; void foo() {};
int main(void) int main(void)
{ {
return 0; return 0;
@@ -271,25 +273,25 @@ CHECK_CXX_SOURCE_COMPILES("
class bar { class bar {
bar() DEP; bar() DEP;
}; };
class peng { } DEP; class peng { } DEP;
template <class T> template <class T>
class t_bar class t_bar
{ {
t_bar() DEP; t_bar() DEP;
}; };
template <class T> template <class T>
class t_peng class t_peng
{ {
t_peng() {}; t_peng() {};
} DEP; } DEP;
void foo() DEP; void foo() DEP;
void foo() {}; void foo() {};
int main(void) int main(void)
{ {
return 0; return 0;
@@ -457,7 +459,7 @@ endif()
if(CXX_FEATURES_MISSING) if(CXX_FEATURES_MISSING)
set (CXX11FEATURES_FOUND FALSE) set (CXX11FEATURES_FOUND FALSE)
if (CXX11Features_FIND_REQUIRED) if (CXX11Features_FIND_REQUIRED)
message(FATAL_ERROR message(FATAL_ERROR
"Your C++ compiler does not support the minimum set of C++-2011 features required. " "Your C++ compiler does not support the minimum set of C++-2011 features required. "
"Make sure to use a compiler which implements all C++-2011 features provided by GCC 4.4. " "Make sure to use a compiler which implements all C++-2011 features provided by GCC 4.4. "
"Your compiler does not seem to implement the following features:\n" "Your compiler does not seem to implement the following features:\n"

View File

@@ -1,11 +0,0 @@
# Find clang-check.
#
# This module defines:
# CLANGCHECK_PROGRAM, the clang-check executable.
# CLANGHCECK_FOUND, If false, do not try to use cppcheck.
#
find_program(CLANGCHECK_PROGRAM NAMES clang-check clang-check-3.8)
find_package_handle_standard_args(ClangCheck DEFAULT_MSG CLANGCHECK_PROGRAM)
mark_as_advanced(CLANGCHECK_PROGRAM)

View File

@@ -1,11 +0,0 @@
# Find CppCheck.
#
# This module defines:
# CPPCHECK_PROGRAM, the cppcheck executable.
# CPPCHECK_FOUND, If false, do not try to use cppcheck.
#
find_program(CPPCHECK_PROGRAM NAMES cppcheck)
find_package_handle_standard_args(CppCheck DEFAULT_MSG CPPCHECK_PROGRAM)
mark_as_advanced(CPPCHECK_PROGRAM)

View File

@@ -1,49 +0,0 @@
# Find the Python wrappers for module cwrap from ert
#
# Set the cache variable CWRAP_PYTHON_PATH to the install location of the root
# ert package.
find_package(PythonInterp)
if(PYTHONINTERP_FOUND)
# We try to find the cwrap Python distribution. This is done by running Python
# code which tries to 'import cwrap' and prints out the path to the module if
# the import succeeds.
#
# The normal Python import machinery is employed, so if you have installed cwrap
# python in a default location, or alternatively set the PYTHONPATH variable the
# cwrap Python distribution will eventually be found there, independently of the
# alternatives which are tested with the ${PATH_LIST} variable.
if (EXISTS "/etc/debian_version")
set( PYTHON_PACKAGE_PATH "dist-packages")
else()
set( PYTHON_PACKAGE_PATH "site-packages")
endif()
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
set(PATH_LIST)
if (ERT_ROOT)
list(APPEND PATH_LIST ${ERT_ROOT})
endif()
list(APPEND PATH_LIST ${CMAKE_PREFIX_PATH})
# Add various popular sibling alternatives.
list(APPEND PATH_LIST "${PROJECT_SOURCE_DIR}/../ert/build"
"${PROJECT_BINARY_DIR}/../ert-build")
foreach( PATH ${PATH_LIST})
set( python_code "import sys; sys.path.insert(0 , '${PATH}/${PYTHON_INSTALL_PREFIX}'); import os.path; import inspect; import cwrap; print os.path.dirname(os.path.dirname(inspect.getfile(cwrap)))")
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "${python_code}"
RESULT_VARIABLE import_result
OUTPUT_VARIABLE stdout_output
ERROR_VARIABLE stderr_output
OUTPUT_STRIP_TRAILING_WHITESPACE )
if (${import_result} EQUAL 0)
set( CWRAP_PYTHON_PATH ${stdout_output} CACHE PATH "Python path for cwrap" )
break()
endif()
endforeach()
endif()
find_package_handle_standard_args("Cwrap" DEFAULT_MSG CWRAP_PYTHON_PATH)

View File

@@ -33,49 +33,41 @@ endif (ERT_ROOT)
find_path (ERT_ECL_INCLUDE_DIR find_path (ERT_ECL_INCLUDE_DIR
NAMES "ert/ecl/ecl_util.h" NAMES "ert/ecl/ecl_util.h"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}/../libecl" "${PROJECT_SOURCE_DIR}/../ert" PATHS "${PROJECT_SOURCE_DIR}/../ert"
PATH_SUFFIXES "libecl/include/" "include" PATH_SUFFIXES "devel/libecl/include/" "include"
DOC "Path to ERT Eclipse library header files" DOC "Path to ERT Eclipse library header files"
${_no_default_path} ${_no_default_path}
) )
find_path (ERT_ECL_WELL_INCLUDE_DIR find_path (ERT_ECL_WELL_INCLUDE_DIR
NAMES "ert/ecl_well/well_const.h" NAMES "ert/ecl_well/well_const.h"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}/../libecl" "${PROJECT_SOURCE_DIR}/../ert" PATHS "${PROJECT_SOURCE_DIR}/../ert"
PATH_SUFFIXES "libecl_well/include/" "include" PATH_SUFFIXES "devel/libecl_well/include/" "include"
DOC "Path to ERT Eclipse library header files" DOC "Path to ERT Eclipse library header files"
${_no_default_path} ${_no_default_path}
) )
find_path (ERT_ECLXX_INCLUDE_DIR find_path (ERT_ECLXX_INCLUDE_DIR
NAMES "ert/ecl/EclKW.hpp" NAMES "ert/ecl/EclKW.hpp"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}/../libecl" "${PROJECT_SOURCE_DIR}/../ert" PATHS "${PROJECT_SOURCE_DIR}/../ert"
PATH_SUFFIXES "libeclxx/include/" "include" PATH_SUFFIXES "devel/libeclxx/include/" "include"
DOC "Path to ERT Eclipse C++ library header files" DOC "Path to ERT Eclipse C++ library header files"
${_no_default_path} ${_no_default_path}
) )
find_path (ERT_UTIL_INCLUDE_DIR find_path (ERT_UTIL_INCLUDE_DIR
NAMES "ert/util/stringlist.h" NAMES "ert/util/stringlist.h"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}/../libecl" "${PROJECT_SOURCE_DIR}/../ert" PATHS "${PROJECT_SOURCE_DIR}/../ert"
PATH_SUFFIXES "libert_util/include/" "include" PATH_SUFFIXES "devel/libert_util/include/" "include"
DOC "Path to ERT Eclipse library header files" DOC "Path to ERT Eclipse library header files"
${_no_default_path} ${_no_default_path}
) )
find_path (ERT_UTILXX_INCLUDE_DIR
NAMES "ert/util/ert_unique_ptr.hpp"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}/../libecl" "${PROJECT_SOURCE_DIR}/../ert"
PATH_SUFFIXES "libert_utilxx/include/" "include"
DOC "Path to ERT Eclipse C++ library header files"
${_no_default_path}
)
find_path (ERT_GEN_INCLUDE_DIR find_path (ERT_GEN_INCLUDE_DIR
NAMES "ert/util/int_vector.h" NAMES "ert/util/int_vector.h"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}/../libecl" "${PROJECT_SOURCE_DIR}/../ert" PATHS "${PROJECT_SOURCE_DIR}/../ert"
PATH_SUFFIXES "libert_util/include" PATH_SUFFIXES "devel/libert_util/include"
"include" "build/libert_util/include" "build/libert_util/include" "include" "build/libert_util/include"
DOC "Path to ERT generated library header files" DOC "Path to ERT generated library header files"
${_no_default_path} ${_no_default_path}
) )
@@ -88,78 +80,60 @@ endif (CMAKE_SIZEOF_VOID_P)
find_library (ERT_LIBRARY_ECL find_library (ERT_LIBRARY_ECL
NAMES "ecl" NAMES "ecl"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../libecl" PATHS "${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../libecl/build"
"${PROJECT_BINARY_DIR}/../libecl-build"
"${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../ert/build" "${PROJECT_SOURCE_DIR}/../ert/build"
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
"${PROJECT_BINARY_DIR}/../ert-build" "${PROJECT_BINARY_DIR}/../ert-build"
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Eclipse library archive/shared object files" DOC "Path to ERT Eclipse library archive/shared object files"
${_no_default_path} ${_no_default_path}
) )
find_library (ERT_LIBRARY_ECLXX find_library (ERT_LIBRARY_ECLXX
NAMES "eclxx" NAMES "eclxx"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../libecl" PATHS "${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../libecl/build"
"${PROJECT_BINARY_DIR}/../libecl-build"
"${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../ert/build" "${PROJECT_SOURCE_DIR}/../ert/build"
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
"${PROJECT_BINARY_DIR}/../ert-build" "${PROJECT_BINARY_DIR}/../ert-build"
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Eclipse C++ library archive/shared object files" DOC "Path to ERT Eclipse C++ library archive/shared object files"
${_no_default_path} ${_no_default_path}
) )
find_library (ERT_LIBRARY_ECL_WELL find_library (ERT_LIBRARY_ECL_WELL
NAMES "ecl_well" NAMES "ecl_well"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../libecl" PATHS "${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../libecl/build"
"${PROJECT_BINARY_DIR}/../libecl-build"
"${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../ert/build" "${PROJECT_SOURCE_DIR}/../ert/build"
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
"${PROJECT_BINARY_DIR}/../ert-build" "${PROJECT_BINARY_DIR}/../ert-build"
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Eclipse library archive/shared object files" DOC "Path to ERT Eclipse library archive/shared object files"
${_no_default_path} ${_no_default_path}
) )
find_library (ERT_LIBRARY_GEOMETRY find_library (ERT_LIBRARY_GEOMETRY
NAMES "ert_geometry" NAMES "ert_geometry"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../libecl" PATHS "${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../libecl/build"
"${PROJECT_BINARY_DIR}/../libecl-build"
"${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../ert/build" "${PROJECT_SOURCE_DIR}/../ert/build"
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
"${PROJECT_BINARY_DIR}/../ert-build" "${PROJECT_BINARY_DIR}/../ert-build"
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Geometry library archive/shared object files" DOC "Path to ERT Geometry library archive/shared object files"
${_no_default_path} ${_no_default_path}
) )
find_library (ERT_LIBRARY_UTIL find_library (ERT_LIBRARY_UTIL
NAMES "ert_util" NAMES "ert_util"
HINTS "${ERT_ROOT}" HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../libecl" PATHS "${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../libecl/build"
"${PROJECT_BINARY_DIR}/../libecl-build"
"${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../ert/build" "${PROJECT_SOURCE_DIR}/../ert/build"
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
"${PROJECT_BINARY_DIR}/../ert-build" "${PROJECT_BINARY_DIR}/../ert-build"
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "${PROJECT_BINARY_DIR}/../ert/devel"
DOC "Path to ERT Utilities library archive/shared object files" PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${_no_default_path}
)
find_library (ERT_LIBRARY_UTILXX
NAMES "ert_utilxx"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../libecl"
"${PROJECT_SOURCE_DIR}/../libecl/build"
"${PROJECT_BINARY_DIR}/../libecl-build"
"${PROJECT_BINARY_DIR}/../ert"
"${PROJECT_SOURCE_DIR}/../ert/build"
"${PROJECT_BINARY_DIR}/../ert-build"
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Utilities library archive/shared object files" DOC "Path to ERT Utilities library archive/shared object files"
${_no_default_path} ${_no_default_path}
) )
@@ -169,7 +143,6 @@ list (APPEND ERT_INCLUDE_DIR
${ERT_ECL_WELL_INCLUDE_DIR} ${ERT_ECL_WELL_INCLUDE_DIR}
${ERT_ECLXX_INCLUDE_DIR} ${ERT_ECLXX_INCLUDE_DIR}
${ERT_UTIL_INCLUDE_DIR} ${ERT_UTIL_INCLUDE_DIR}
${ERT_UTILXX_INCLUDE_DIR}
${ERT_GEN_INCLUDE_DIR} ${ERT_GEN_INCLUDE_DIR}
) )
list (APPEND ERT_LIBRARY list (APPEND ERT_LIBRARY
@@ -178,7 +151,6 @@ list (APPEND ERT_LIBRARY
${ERT_LIBRARY_ECL_WELL} ${ERT_LIBRARY_ECL_WELL}
${ERT_LIBRARY_GEOMETRY} ${ERT_LIBRARY_GEOMETRY}
${ERT_LIBRARY_UTIL} ${ERT_LIBRARY_UTIL}
${ERT_LIBRARY_UTILXX}
) )
list (APPEND ERT_LIBRARIES ${ERT_LIBRARY}) list (APPEND ERT_LIBRARIES ${ERT_LIBRARY})
list (APPEND ERT_INCLUDE_DIRS ${ERT_INCLUDE_DIR}) list (APPEND ERT_INCLUDE_DIRS ${ERT_INCLUDE_DIR})
@@ -198,6 +170,36 @@ if (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
return () return ()
endif (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND") endif (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
# these system variables are probed for, and used in HEADER files (sic)
list (APPEND ERT_CONFIG_VARS
HAVE_ISFINITE
HAVE_GLOB
HAVE_FORK
HAVE_GETUID
HAVE_LOCKF
HAVE_OPENDIR
HAVE_PROC
HAVE_READLINKAT
HAVE_SYMLINK
HAVE_VA_COPY
)
include (CheckSymbolExists)
include (CheckFunctionExists)
check_symbol_exists (isfinite math.h HAVE_ISFINITE)
check_function_exists (glob HAVE_GLOB)
check_function_exists (fork HAVE_FORK)
check_function_exists (getuid HAVE_GETUID)
check_function_exists (lockf HAVE_LOCKF)
check_function_exists (opendir HAVE_OPENDIR)
check_function_exists (readlinkat HAVE_READLINKAT)
check_function_exists (symlink HAVE_SYMLINK)
check_symbol_exists (va_copy stdarg.h HAVE_VA_COPY)
if (UNIX)
set (HAVE_PROC 1)
else (UNIX)
set (HAVE_PROC)
endif (UNIX)
# dependencies # dependencies
@@ -219,7 +221,6 @@ if (BLAS_FOUND)
list (APPEND ERT_LIBRARIES ${BLAS_LIBRARIES}) list (APPEND ERT_LIBRARIES ${BLAS_LIBRARIES})
list (APPEND ERT_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) list (APPEND ERT_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
endif (BLAS_FOUND) endif (BLAS_FOUND)
find_package (LAPACK ${ERT_QUIET}) find_package (LAPACK ${ERT_QUIET})
if (LAPACK_FOUND) if (LAPACK_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${LAPACK_INCLUDE_DIRS}) list (APPEND ERT_INCLUDE_DIRS ${LAPACK_INCLUDE_DIRS})
@@ -260,11 +261,11 @@ if (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND
set (CMAKE_REQUIRED_INCLUDES ${ERT_INCLUDE_DIR}) set (CMAKE_REQUIRED_INCLUDES ${ERT_INCLUDE_DIR})
set (CMAKE_REQUIRED_LIBRARIES ${ERT_LIBRARIES}) set (CMAKE_REQUIRED_LIBRARIES ${ERT_LIBRARIES})
check_cxx_source_compiles ( check_cxx_source_compiles (
"#include <ert/ecl/ecl_grid.h> "#include <ert/ecl/EclKW.hpp>
int main ( ) { int main ( ) {
ecl_grid_type * grid = ecl_grid_alloc_rectangular( 10,10,10,1,1,1, NULL); ERT::EclKW<int> kw(\"SATNUM\" , 1000);
ecl_grid_free( grid ); kw[0] = 10;
return 0; return 0;
}" HAVE_ERT) }" HAVE_ERT)
cmake_pop_check_state () cmake_pop_check_state ()
else (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")) else (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))

View File

@@ -23,18 +23,20 @@ if(PYTHONINTERP_FOUND)
endif() endif()
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in") set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
set(PATH_LIST)
if (ERT_ROOT) if (ERT_ROOT)
list(APPEND PATH_LIST ${ERT_ROOT}) set( start_path "${ERT_ROOT}/${PYTHON_INSTALL_PREFIX}" )
else()
set( start_path "DEFAULT_PATH")
endif() endif()
list(APPEND PATH_LIST ${CMAKE_PREFIX_PATH})
# Add various popular sibling alternatives. set( PATH_LIST "${start_path}"
list(APPEND PATH_LIST "${PROJECT_SOURCE_DIR}/../ert/build" "${PROJECT_SOURCE_DIR}/../ert/build/${PYTHON_INSTALL_PREFIX}"
"${PROJECT_BINARY_DIR}/../ert-build") "${PROJECT_SOURCE_DIR}/../ert/devel/build/${PYTHON_INSTALL_PREFIX}"
"${PROJECT_BINARY_DIR}/../ert-build/${PYTHON_INSTALL_PREFIX}"
"${PROJECT_BINARY_DIR}/../ert/devel/${PYTHON_INSTALL_PREFIX}")
foreach( PATH ${PATH_LIST}) foreach( PATH ${PATH_LIST})
set( python_code "import sys; sys.path.insert(0 , '${PATH}/${PYTHON_INSTALL_PREFIX}'); import os.path; import inspect; import ert; print os.path.dirname(os.path.dirname(inspect.getfile(ert))); from ert.ecl import EclSum") set( python_code "import sys; sys.path.insert(0 , '${PATH}'); import os.path; import inspect; import ert; print os.path.dirname(os.path.dirname(inspect.getfile(ert)))")
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "${python_code}" execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "${python_code}"
RESULT_VARIABLE import_result RESULT_VARIABLE import_result
OUTPUT_VARIABLE stdout_output OUTPUT_VARIABLE stdout_output

View File

@@ -16,11 +16,6 @@
# find out the size of a pointer. this is required to only search for # find out the size of a pointer. this is required to only search for
# libraries in the directories relevant for the architecture # libraries in the directories relevant for the architecture
if(NOT USE_PETSC)
return()
endif()
if (CMAKE_SIZEOF_VOID_P) if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}") math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P) endif (CMAKE_SIZEOF_VOID_P)
@@ -112,35 +107,22 @@ if (Petsc_ROOT)
set (PETSC_ROOT "${Petsc_ROOT}") set (PETSC_ROOT "${Petsc_ROOT}")
endif (Petsc_ROOT) endif (Petsc_ROOT)
find_package(PkgConfig) find_path (PETSC_NORMAL_INCLUDE_DIR
if(PKG_CONFIG_FOUND) NAMES "petsc.h"
set(OLD_PKG $ENV{PKG_CONFIG_PATH}) PATHS ${PETSC_ROOT}
set(ENV{PKG_CONFIG_PATH} $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/pkgconfig) PATH_SUFFIXES "include" "petsc"
pkg_check_modules(PETSC PETSc>=3.4.0) ${_no_default_path}
set(ENV{PKG_CONFIG_PATH} ${OLD_PKG}) )
set(PETSC_LIBRARIES ${PETSC_STATIC_LDFLAGS})
set(PETSC_LIBRARY ${PETSC_LIBRARIES})
set(PETSC_INCLUDE_DIR ${PETSC_INCLUDE_DIRS})
endif()
if(NOT PETSC_FOUND) list(APPEND PETSC_INCLUDE_DIR ${PETSC_NORMAL_INCLUDE_DIR})
find_path (PETSC_NORMAL_INCLUDE_DIR
NAMES "petsc.h"
PATHS ${PETSC_ROOT}
PATH_SUFFIXES "include" "petsc"
${_no_default_path}
)
list(APPEND PETSC_INCLUDE_DIR ${PETSC_NORMAL_INCLUDE_DIR}) # look for actual Petsc library
find_library(PETSC_LIBRARY
# look for actual Petsc library NAMES "petsc-3.4.3" "petsc-3.4.4" "petsc"
find_library(PETSC_LIBRARY PATHS ${PETSC_ROOT}
NAMES "petsc-3.4.3" "petsc-3.4.4" "petsc" PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
PATHS ${PETSC_ROOT} ${_no_default_path}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" )
${_no_default_path}
)
endif()
if(NOT PETSC_LIBRARY) if(NOT PETSC_LIBRARY)
message(STATUS "Could not find the PETSc library") message(STATUS "Could not find the PETSc library")
@@ -154,7 +136,7 @@ mark_as_advanced(PETSC_INCLUDE_DIR PETSC_LIBRARY)
# if both headers and library are found, store results # if both headers and library are found, store results
if(PETSC_FOUND) if(PETSC_FOUND)
set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDE_DIR}) set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDE_DIR})
list(APPEND PETSC_INCLUDE_DIRS ${PETSC_MPI_INCLUDE_DIRS}) list(APPEND PETSC_INCLUDE_DIRS ${PETSC_MPI_INCLUDE_DIRS})
set(PETSC_LIBRARIES ${PETSC_LIBRARY}) set(PETSC_LIBRARIES ${PETSC_LIBRARY})

View File

@@ -11,38 +11,28 @@ include(CheckCXXSourceCompiles)
include(CMakePushCheckState) include(CMakePushCheckState)
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
if(NOT DEFINED USE_QUADMATH OR USE_QUADMATH) check_cxx_compiler_flag("-Werror -fext-numeric-literals" HAVE_EXTENDED_NUMERIC_LITERALS)
if(NOT DEFINED HAVE_EXTENDED_NUMERIC_LITERALS) if (HAVE_EXTENDED_NUMERIC_LITERALS)
check_cxx_compiler_flag("-Werror -fext-numeric-literals" HAVE_EXTENDED_NUMERIC_LITERALS)
endif()
if (HAVE_EXTENDED_NUMERIC_LITERALS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals")
endif() endif()
cmake_push_check_state(RESET) cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath") list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath")
CHECK_CXX_SOURCE_COMPILES(" CHECK_CXX_SOURCE_COMPILES("
#include <quadmath.h> #include <quadmath.h>
int main(void){ int main(void){
__float128 foo = sqrtq(123.456); __float128 foo = sqrtq(123.456);
foo = FLT128_MIN; foo = FLT128_MIN;
}" QUADMATH_FOUND) }" HAVE_QUAD)
cmake_pop_check_state() cmake_pop_check_state()
if (QUADMATH_FOUND) if (HAVE_QUAD)
set(QUADMATH_LIBRARIES "quadmath") set(QUADMATH_LIBRARIES "quadmath")
set(HAVE_QUAD "${QUADMATH_FOUND}")
endif()
endif()
if (USE_QUADMATH AND NOT QUADMATH_FOUND)
message(FATAL_ERROR "Quadruple precision math support was explicitly requested but is unavailable!")
endif() endif()
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Quadmath find_package_handle_standard_args(QuadMath
DEFAULT_MSG DEFAULT_MSG
QUADMATH_LIBRARIES QUADMATH_LIBRARIES
HAVE_QUAD HAVE_QUAD

View File

@@ -15,18 +15,12 @@
# SUPERLU_LIBRARIES Name to the SuperLU library. # SUPERLU_LIBRARIES Name to the SuperLU library.
# #
if(NOT USE_SUPERLU)
return()
endif()
include(CheckIncludeFiles) include(CheckIncludeFiles)
include(CMakePushCheckState) include(CMakePushCheckState)
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
cmake_push_check_state() cmake_push_check_state()
set(SUPERLU_FOUND "FALSE")
# find out the size of a pointer. this is required to only search for # find out the size of a pointer. this is required to only search for
# libraries in the directories relevant for the architecture # libraries in the directories relevant for the architecture
if (CMAKE_SIZEOF_VOID_P) if (CMAKE_SIZEOF_VOID_P)
@@ -122,19 +116,6 @@ int main(void)
return 0; return 0;
}" }"
SUPERLU_POST_2005_VERSION) SUPERLU_POST_2005_VERSION)
# check whether version is at least 5.0
CHECK_C_SOURCE_COMPILES("
typedef int int_t;
#include <supermatrix.h>
#include <slu_util.h>
int main(void)
{
GlobalLU_t glu;
return 0;
}"
SUPERLU_MIN_VERSION_5)
cmake_pop_check_state() cmake_pop_check_state()
if(SUPERLU_MIN_VERSION_4_3) if(SUPERLU_MIN_VERSION_4_3)
@@ -145,17 +126,6 @@ else()
"Human readable string containing SuperLU version information.") "Human readable string containing SuperLU version information.")
endif() endif()
if(SUPERLU_MIN_VERSION_5)
include(UseDuneVer)
find_dune_version("dune" "istl")
set(DUNE_ISTL_VERSION ${DUNE_ISTL_VERSION_MAJOR}.${DUNE_ISTL_VERSION_MINOR}.${DUNE_ISTL_VERSION_REVISION})
if(DUNE_ISTL_VERSION VERSION_LESS 2.5)
message(STATUS "SuperLU requested, but version found not compatible with dune-istl ${DUNE_ISTL_VERSION}")
set(SUPERLU_LIBRARY "")
set(SUPERLU_INCLUDE_DIR "")
endif()
endif()
# behave like a CMake module is supposed to behave # behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( find_package_handle_standard_args(

View File

@@ -0,0 +1,37 @@
# - Find TinyXML library
#
# Defines the following variables:
# TinyXML_INCLUDE_DIRS Directory of header files
# TinyXML_LIBRARIES Directory of shared object files
# TinyXML_DEFINITIONS Defines that must be set to compile
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (OpmPackage)
find_opm_package (
# module name
"TinyXML"
# dependencies
""
# header to search for
"tinyxml.h"
# library to search for
"tinyxml"
# defines to be added to compilations
""
# test program
"#include <tinyxml.h>
int main (void) {
TiXmlDocument doc;
return 0;
}
"
# config variables
"")

View File

@@ -24,7 +24,7 @@ find_package(PTScotch)
find_path (ZOLTAN_INCLUDE_DIRS find_path (ZOLTAN_INCLUDE_DIRS
NAMES "zoltan.h" NAMES "zoltan.h"
PATHS ${ZOLTAN_SEARCH_PATH} PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES include trilinos PATH_SUFFIXES "include"
${ZOLTAN_NO_DEFAULT_PATH}) ${ZOLTAN_NO_DEFAULT_PATH})
# only search in architecture-relevant directory # only search in architecture-relevant directory
@@ -33,7 +33,7 @@ if (CMAKE_SIZEOF_VOID_P)
endif (CMAKE_SIZEOF_VOID_P) endif (CMAKE_SIZEOF_VOID_P)
find_library(ZOLTAN_LIBRARIES find_library(ZOLTAN_LIBRARIES
NAMES zoltan trilinos_zoltan NAMES "zoltan"
PATHS ${ZOLTAN_SEARCH_PATH} PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${ZOLTAN_NO_DEFAULT_PATH}) ${ZOLTAN_NO_DEFAULT_PATH})

View File

@@ -20,8 +20,8 @@ endif (CJSON_ROOT)
find_path (CJSON_INCLUDE_DIR find_path (CJSON_INCLUDE_DIR
NAMES "cjson/cJSON.h" NAMES "cjson/cJSON.h"
HINTS "${CJSON_ROOT}" HINTS "${CJSON_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}" PATHS "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/../opm-parser"
PATH_SUFFIXES "include" "external" PATH_SUFFIXES "include" "opm/json"
DOC "Path to cjson library header files" DOC "Path to cjson library header files"
${_no_default_path} ) ${_no_default_path} )

View File

@@ -11,7 +11,6 @@
# This code is licensed under The GNU General Public License v3.0 # This code is licensed under The GNU General Public License v3.0
include (OpmPackage) include (OpmPackage)
# find dune-alugrid when build with autotools (deprecated in dune 2.4 and removed after dune 3.0
find_opm_package ( find_opm_package (
# module name # module name
"dune-alugrid" "dune-alugrid"
@@ -22,7 +21,7 @@ find_opm_package (
# we just include them to forward here in case anyone else does # we just include them to forward here in case anyone else does
"CXX11Features REQUIRED; "CXX11Features REQUIRED;
dune-grid REQUIRED; dune-grid REQUIRED;
ZLIB; ZLIB REQUIRED;
ZOLTAN; ZOLTAN;
METIS METIS
" "
@@ -30,47 +29,13 @@ find_opm_package (
"dune/alugrid/grid.hh" "dune/alugrid/grid.hh"
# library to search for # library to search for
"dunealugrid;alugrid_parallel;alugrid_serial" "dunealugrid;alugrid_2d;alugrid_parallel;alugrid_serial"
# defines to be added to compilations # defines to be added to compilations
"" ""
# test program # test program
"#include <dune/alugrid/common/interfaces.hh> "#include <dune/alugrid/2d/indexsets.hh>
int main (void) {
return 0;
}
"
# config variables
"HAVE_DUNE_ALUGRID
")
# find dune-alugrid when build with cmake
find_opm_package (
# module name
"dune-alugrid"
# dependencies
# TODO: we should probe for all the HAVE_* values listed below;
# however, we don't actually use them in our implementation, so
# we just include them to forward here in case anyone else does
"CXX11Features REQUIRED;
dune-grid REQUIRED;
ZLIB;
ZOLTAN;
METIS
"
# header to search for
"dune/alugrid/grid.hh"
# library to search for
"dunealugrid"
# defines to be added to compilations
""
# test program
"#include <dune/alugrid/common/interfaces.hh>
int main (void) { int main (void) {
return 0; return 0;
} }

View File

@@ -57,7 +57,6 @@ int main (void) {
HAVE_NULLPTR; HAVE_NULLPTR;
HAVE_STATIC_ASSERT; HAVE_STATIC_ASSERT;
HAVE_SHARED_PTR; HAVE_SHARED_PTR;
MPI_2;
SHARED_PTR_HEADER; SHARED_PTR_HEADER;
SHARED_PTR_NAMESPACE; SHARED_PTR_NAMESPACE;
HAVE_TYPE_TRAITS; HAVE_TYPE_TRAITS;
@@ -67,17 +66,6 @@ int main (void) {
") ")
#debug_find_vars ("dune-common") #debug_find_vars ("dune-common")
if(MPI_C_FOUND)
# check for MPI version 2
include(CMakePushCheckState)
include(CheckFunctionExists)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};${MPI_C_LIBRARIES})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${MPI_C_INCLUDES})
check_function_exists(MPI_Finalized MPI_2)
cmake_pop_check_state()
endif(MPI_C_FOUND)
# make version number available in config.h # make version number available in config.h
include (UseDuneVer) include (UseDuneVer)
find_dune_version ("dune" "common") find_dune_version ("dune" "common")

View File

@@ -0,0 +1,42 @@
# - Find OPM corner-point grid library
#
# Defines the following variables:
# dune-cornerpoint_INCLUDE_DIRS Directory of header files
# dune-cornerpoint_LIBRARIES Directory of shared object files
# dune-cornerpoint_DEFINITIONS Defines that must be set to compile
# dune-cornerpoint_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_CORNERPOINT Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (dune-cornerpoint-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"dune-cornerpoint"
# dependencies
"${dune-cornerpoint_DEPS}"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"dunecornerpoint"
# defines to be added to compilations
"HAVE_DUNE_CORNERPOINT"
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"${dune-cornerpoint_CONFIG_VAR}"
)
#debug_find_vars ("dune-cornerpoint")

View File

@@ -26,6 +26,7 @@ find_opm_package (
dune-common REQUIRED; dune-common REQUIRED;
dune-geometry REQUIRED; dune-geometry REQUIRED;
MPI; MPI;
ALUGrid;
UG UG
" "
# header to search for # header to search for
@@ -41,13 +42,14 @@ find_opm_package (
"#include <dune/grid/onedgrid.hh> "#include <dune/grid/onedgrid.hh>
int main (void) { int main (void) {
Dune::OneDGrid grid(1, 0., 1.); Dune::OneDGrid grid(1, 0., 1.);
return grid.size(0); return grid.lbegin<0>(0) == grid.lend<0>(0);
} }
" "
# config variables # config variables
"HAVE_MPI; "HAVE_MPI;
HAVE_UG; HAVE_UG;
HAVE_DUNE_FEM; HAVE_DUNE_FEM;
HAVE_ALUGRID;
HAVE_GRIDTYPE; HAVE_GRIDTYPE;
HAVE_GRAPE; HAVE_GRAPE;
HAVE_PSURFACE; HAVE_PSURFACE;

View File

@@ -1,30 +1,30 @@
# - Find OPM automatic differentiation library # - Find OPM automatic differentiation library
# #
# Defines the following variables: # Defines the following variables:
# opm-simulators_INCLUDE_DIRS Directory of header files # opm-autodiff_INCLUDE_DIRS Directory of header files
# opm-simulators_LIBRARIES Directory of shared object files # opm-autodiff_LIBRARIES Directory of shared object files
# opm-simulators_DEFINITIONS Defines that must be set to compile # opm-autodiff_DEFINITIONS Defines that must be set to compile
# opm-simulators_CONFIG_VARS List of defines that should be in config.h # opm-autodiff_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_SIMULATORS Binary value to use in config.h # HAVE_OPM_AUTODIFF Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS # Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0 # This code is licensed under The GNU General Public License v3.0
# use the generic find routine # use the generic find routine
include (opm-simulators-prereqs) include (opm-autodiff-prereqs)
include (OpmPackage) include (OpmPackage)
find_opm_package ( find_opm_package (
# module name # module name
"opm-simulators" "opm-autodiff"
# dependencies # dependencies
"${opm-simulators_DEPS}" "${opm-autodiff_DEPS}"
# header to search for # header to search for
"opm/autodiff/AutoDiff.hpp" "opm/autodiff/AutoDiff.hpp"
# library to search for # library to search for
"opmsimulators" "opmautodiff"
# defines to be added to compilations # defines to be added to compilations
"" ""
@@ -38,7 +38,7 @@ int main (void) {
} }
" "
# config variables # config variables
"${opm-simulators_CONFIG_VAR}" "${opm-autodiff_CONFIG_VAR}"
) )
include (UseDynamicBoost) include (UseDynamicBoost)
#debug_find_vars ("opm-simulators") #debug_find_vars ("opm-autodiff")

View File

@@ -24,7 +24,7 @@ find_opm_package (
"opm/common/utility/platform_dependent/disable_warnings.h" "opm/common/utility/platform_dependent/disable_warnings.h"
# library to search for # library to search for
"opmcommon" ""
# defines to be added to compilations # defines to be added to compilations
"" ""

View File

@@ -21,7 +21,7 @@ find_opm_package (
"${opm-core_DEPS}" "${opm-core_DEPS}"
# header to search for # header to search for
"opm/core/wells.h" "opm/core/grid.h"
# library to search for # library to search for
"opmcore" "opmcore"
@@ -30,13 +30,12 @@ find_opm_package (
"" ""
# test program # test program
" "#include <opm/core/grid.h>
#include <opm/core/utility/parameters/ParameterGroup.hpp> int main (void) {
int main() struct UnstructuredGrid *g;
{ g = create_grid_empty ();
Opm::ParameterGroup parameters; destroy_grid (g);
parameters.insertParameter(\"number\", \"7\"); return 0;
return 0;
} }
" "
# config variables # config variables

View File

@@ -17,8 +17,8 @@ endif()
if (EXISTS "${_opm_data_root}/norne/NORNE_ATW2013.DATA") if (EXISTS "${_opm_data_root}/norne/NORNE_ATW2013.DATA")
set( HAVE_OPM_DATA True ) set( HAVE_OPM_DATA True )
set( OPM_DATA_ROOT ${_opm_data_root} ) set( OPM_DATA_ROOT ${_opm_data_root} )
message(STATUS "Setting OPM_DATA_ROOT: ${OPM_DATA_ROOT}") message( "-- Setting OPM_DATA_ROOT: ${OPM_DATA_ROOT}")
else() else()
set( HAVE_OPM_DATA False ) set( HAVE_OPM_DATA False )
message(WARNING "opm-data not found - integration tests using opm-data will be skipped.") message( "opm-data not found - integration tests using opm-data will be skipped.")
endif() endif()

View File

@@ -1,48 +0,0 @@
# - Find OPM Flow Diagnostics Library
#
# Defines the following variables:
# opm-flowdiagnostics_INCLUDE_DIRS Directory of header files
# opm-flowdiagnostics_LIBRARIES Directory of shared object files
# opm-flowdiagnostics_DEFINITIONS Defines that must be set to compile
# opm-flowdiagnostics_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_FLOWDIAGNOSTICS Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (opm-flowdiagnostics-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-flowdiagnostics"
# dependencies
"${opm-flowdiagnostics_DEPS}"
# header to search for
"opm/flowdiagnostics/Toolbox.hpp"
# library to search for
"opmflowdiagnostics"
# defines to be added to compilations
""
# test program
"#include <opm/flowdiagnostics/Toolbox.hpp>
#include <vector>
int main()
{
using FDT = Opm::FlowDiagnostics::Toolbox;
const auto pv = std::vector<double>(10, 0.3);
}
"
# config variables
"${opm-flowdiagnostics_CONFIG_VAR}"
)

View File

@@ -1,42 +0,0 @@
# - Find OPM corner-point grid library
#
# Defines the following variables:
# opm-grid_INCLUDE_DIRS Directory of header files
# opm-grid_LIBRARIES Directory of shared object files
# opm-grid_DEFINITIONS Defines that must be set to compile
# opm-grid_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_GRID Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (opm-grid-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-grid"
# dependencies
"${opm-grid_DEPS}"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"opmgrid"
# defines to be added to compilations
"HAVE_OPM_GRID"
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"${opm-grid_CONFIG_VAR}"
)
#debug_find_vars ("opm-grid")

View File

@@ -1,55 +0,0 @@
# - Find OPM output library
#
# Defines the following variables:
# opm-output_INCLUDE_DIRS Directory of header files
# opm-output_LIBRARIES Directory of shared object files
# opm-output_DEFINITIONS Defines that must be set to compile
# opm-output_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_OUTPUT Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (opm-output-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-output"
# dependencies
"${opm-output_DEPS}"
# header to search for
"opm/output/OutputWriter.hpp"
# library to search for
"opmoutput"
# defines to be added to compilations
""
# test program
"#include <opm/output/eclipse/Summary.hpp>
int main (void) {
return 0;
}
"
# config variables
"${opm-output_CONFIG_VAR}"
)
include (UseDynamicBoost)
#debug_find_vars ("opm-output")
if(OPM_OUTPUT_FOUND)
get_filename_component(opm-output_PREFIX_DIR ${opm-output_LIBRARY} PATH)
find_program(COMPARE_SUMMARY_COMMAND compareSummary
PATHS ${opm-output_PREFIX_DIR}/../bin
${opm-output_PREFIX_DIR}/../../bin)
find_program(COMPARE_ECL_COMMAND compareECL
PATHS ${opm-output_PREFIX_DIR}/../bin
${opm-output_PREFIX_DIR}/../../bin)
endif()

View File

@@ -18,6 +18,13 @@ else ()
set (OPM_PARSER_QUIET "") set (OPM_PARSER_QUIET "")
endif () endif ()
# use lowercase versions of the variables if those are set
if (opm-parser_ROOT)
set (OPM_PARSER_ROOT ${opm-parser_ROOT})
endif ()
if (opm_ROOT)
set (OPM_ROOT ${opm_ROOT})
endif ()
# inherit "suite" root if not specifically set for this library # inherit "suite" root if not specifically set for this library
if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT) if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT)
@@ -43,24 +50,120 @@ else ()
"${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}") "${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}")
endif () endif ()
# use this header as signature
find_path (OPM_PARSER_INCLUDE_DIR
NAMES "opm/parser/eclipse/Parser/Parser.hpp"
HINTS "${OPM_PARSER_ROOT}"
PATHS ${_opm_parser_source}
PATH_SUFFIXES "include"
DOC "Path to OPM parser header files"
${_no_default_path} )
find_package(opm-parser CONFIG HINTS ${_opm_parser_build}) find_path (OPM_PARSER_GEN_INCLUDE_DIR
if (opm-parser_FOUND) NAMES "opm/parser/eclipse/Parser/ParserKeywords.hpp"
find_package(ecl REQUIRED) HINTS "${OPM_PARSER_ROOT}"
find_package(Boost 1.44.0 PATHS ${_opm_parser_build}
COMPONENTS regex filesystem system date_time PATH_SUFFIXES "generated-source/include" "include"
REQUIRED) DOC "Path to OPM parser generated header files"
set(HAVE_OPM_PARSER 1) ${_no_default_path} )
# setting HAVE_ERT is a mega hack here, but some downstreams require it.
# Eventually projets should move on to properly handle dependencies and
# configurations, and Findopm-parser be deprecated
set(HAVE_ERT 1)
set(opm-parser_CONFIG_VARS HAVE_OPM_PARSER HAVE_REGEX HAVE_ERT)
set(opm-parser_LIBRARIES opmparser)
find_package_handle_standard_args(opm-parser
DEFAULT_MSG # backup: if we didn't find any headers there, but a CMakeCache.txt,
opm-parser_LIBRARIES HAVE_OPM_PARSER HAVE_ERT # then it is probably a build directory; read the CMake cache of
) # opm-parser to figure out where the source directory is
if ((NOT OPM_PARSER_INCLUDE_DIR) AND
(OPM_PARSER_ROOT AND (EXISTS "${OPM_PARSER_ROOT}/CMakeCache.txt")))
set (_regex "^OPMParser_SOURCE_DIR:STATIC=\(.*\)$")
file (STRINGS
"${OPM_PARSER_ROOT}/CMakeCache.txt"
_cache_entry
REGEX "${_regex}")
string(REGEX REPLACE "${_regex}" "\\1"
OPM_PARSER_INCLUDE_DIR
"${_cache_entry}")
if (OPM_PARSER_INCLUDE_DIR)
set (OPM_PARSER_INCLUDE_DIR "${OPM_PARSER_INCLUDE_DIR}"
CACHE PATH "Path to OPM parser header files" FORCE)
endif ()
endif () endif ()
# find out the size of a pointer. this is required to only search for
# libraries in the directories relevant for the architecture
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif ()
# these libraries constitute the parser core
find_library (OPM_PARSER_LIBRARY
NAMES "opmparser"
HINTS "${OPM_PARSER_ROOT}"
PATHS ${_opm_parser_build}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
"opm/parser/eclipse"
DOC "Path to OPM parser library archive/shared object files"
${_no_default_path} )
# find the OPM-parser wrapper library around cJSON
find_library (OPM_JSON_LIBRARY
NAMES "opmjson"
HINTS "${OPM_PARSER_ROOT}"
PATHS ${_opm_parser_build}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
"opm/json"
DOC "Path to OPM JSON library archive/shared object files"
${_no_default_path} )
# get the prerequisite ERT libraries
if (NOT ERT_FOUND)
find_package(ERT ${OPM_PARSER_QUIET})
endif ()
# get the prerequisite Boost libraries
find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex ${OPM_PARSER_QUIET})
if (ERT_FOUND AND Boost_FOUND AND
OPM_PARSER_LIBRARY AND OPM_JSON_LIBRARY AND OPM_PARSER_INCLUDE_DIR)
# setup list of all required libraries to link with opm-parser. notice that
# we use the plural form to get *all* the libraries needed by cjson
set (opm-parser_INCLUDE_DIRS
${OPM_PARSER_INCLUDE_DIR}
${OPM_PARSER_GEN_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${ERT_INCLUDE_DIRS})
set (opm-parser_LIBRARIES
${OPM_PARSER_LIBRARY}
${OPM_JSON_LIBRARY}
${Boost_LIBRARIES}
${ERT_LIBRARIES})
# see if we can compile a minimum example
# CMake logical test doesn't handle lists (sic)
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()
set (CMAKE_REQUIRED_INCLUDES ${opm-parser_INCLUDE_DIRS})
set (CMAKE_REQUIRED_LIBRARIES ${opm-parser_LIBRARIES})
check_cxx_source_compiles (
"#include <cstdlib>
#include <opm/parser/eclipse/Deck/Deck.hpp>
int main (void) {
return EXIT_SUCCESS;
}" HAVE_OPM_PARSER)
cmake_pop_check_state ()
endif()
# if the test program didn't compile, but was required to do so, bail
# out now and display an error; otherwise limp on
set (OPM_PARSER_FIND_REQUIRED ${opm-parser_FIND_REQUIRED})
find_package_handle_standard_args (opm-parser
DEFAULT_MSG
opm-parser_INCLUDE_DIRS opm-parser_LIBRARIES HAVE_OPM_PARSER
)
set (opm-parser_CONFIG_VARS "HAVE_OPM_PARSER;HAVE_REGEX")
set (opm-parser_FOUND ${OPM-PARSER_FOUND})
mark_as_advanced(opm-parser_LIBRARIES opm-parser_INCLUDE_DIRS OPM-PARSER_FOUND)

View File

@@ -0,0 +1,42 @@
# - Find OPM polymer library
#
# Defines the following variables:
# opm-polymer_INCLUDE_DIRS Directory of header files
# opm-polymer_LIBRARIES Directory of shared object files
# opm-polymer_DEFINITIONS Defines that must be set to compile
# opm-polymer_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_POLYMER Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (opm-polymer-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-polymer"
# dependencies
"${opm-polymer_DEPS}"
# header to search for
"opm/polymer/PolymerState.hpp"
# library to search for
"opmpolymer"
# defines to be added to compilations
""
# test program
"#include <opm/polymer/PolymerState.hpp>
int main (void) {
Opm::PolymerState s;
return 0;
}
"
# config variables
"${opm-polymer_CONFIG_VAR}"
)
#debug_find_vars ("opm-polymer")

View File

@@ -0,0 +1,41 @@
# - Find OPM porous media solver library
#
# Defines the following variables:
# opm-porsol_INCLUDE_DIRS Directory of header files
# opm-porsol_LIBRARIES Directory of shared object files
# opm-porsol_DEFINITIONS Defines that must be set to compile
# opm-porsol_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_PORSOL Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (opm-porsol-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-porsol"
# dependencies
"${opm-porsol_DEPS}"
# header to search for
"opm/porsol/mimetic/IncompFlowSolverHybrid.hpp"
# library to search for
"opmporsol"
# defines to be added to compilations
""
# test program
"#include <opm/porsol/mimetic/IncompFlowSolverHybrid.hpp>
int main (void) {
return 0;
}
"
# config variables
"${opm-porsol_CONFIG_VAR}"
)
#debug_find_vars ("opm-porsol")

View File

@@ -2,10 +2,6 @@
# compiler/linker. first parameter is the name of the variable that will # compiler/linker. first parameter is the name of the variable that will
# receive this list, the rest is considered the list of libraries # receive this list, the rest is considered the list of libraries
function (linker_cmdline what INTO outvar FROM) function (linker_cmdline what INTO outvar FROM)
if (NOT (UNIX OR MSYS OR MINGW))
return ()
endif (NOT (UNIX OR MSYS OR MINGW))
# if we are going to put these in regexps, we must escape period # if we are going to put these in regexps, we must escape period
string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}") string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}")
string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}") string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}")

View File

@@ -13,51 +13,27 @@ macro (opm_compile opm)
# all public header files are together with the source. prepend our own # all public header files are together with the source. prepend our own
# source path to the one of the dependencies so that our version of any # source path to the one of the dependencies so that our version of any
# ambigious paths are used. # ambigious paths are used.
set (${opm}_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
option(SILENCE_CROSSMODULE_WARNINGS "Disable warnings from cross-module includes" OFF) set (${opm}_INCLUDE_DIRS ${${opm}_INCLUDE_DIR} ${${opm}_INCLUDE_DIRS})
if (SILENCE_CROSSMODULE_WARNINGS)
include_directories("${PROJECT_SOURCE_DIR}")
include_directories (SYSTEM ${${opm}_INCLUDE_DIRS})
else()
set (${opm}_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
set (${opm}_INCLUDE_DIRS ${${opm}_INCLUDE_DIR} ${${opm}_INCLUDE_DIRS})
include_directories (${${opm}_INCLUDE_DIRS})
endif()
# create this library, if there are any compilation units # create this library, if there are any compilation units
include_directories (${${opm}_INCLUDE_DIRS})
link_directories (${${opm}_LIBRARY_DIRS}) link_directories (${${opm}_LIBRARY_DIRS})
add_definitions (${${opm}_DEFINITIONS}) add_definitions (${${opm}_DEFINITIONS})
set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}") set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}")
if (${opm}_SOURCES) if (${opm}_SOURCES)
add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES}) add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES})
set_target_properties (${${opm}_TARGET} PROPERTIES set_target_properties (${${opm}_TARGET} PROPERTIES
SOVERSION ${${opm}_VERSION_MAJOR} SOVERSION ${${opm}_VERSION_MAJOR}
VERSION ${${opm}_VERSION} VERSION ${${opm}_VERSION}
LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}" LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}"
POSITION_INDEPENDENT_CODE TRUE )
) target_link_libraries (${${opm}_TARGET} ${${opm}_LIBRARIES})
if (${${opm}_LIBRARY_TYPE} STREQUAL "SHARED")
# libs that will be linked with the main lib
string(REGEX REPLACE "([;^])[^;]+\\.a[;$]" "\\1" _public_libs
"${${opm}_LIBRARIES}")
# libs that will not actually linked to the library but
# transitively linked to binaries that link to the main library
string(REGEX REPLACE "([^;]+\\.[^a][a-zA-Z0-9]*|-[a-z]*)[;$]" "" _interface_libs
"${${opm}_LIBRARIES}")
else()
# Use all libs for real and transitive linking
set(_public_libs ${${opm}_LIBRARIES})
unset(_interface)
endif()
target_link_libraries (${${opm}_TARGET} PUBLIC ${_public_libs}
INTERFACE ${_interface_libs})
if (STRIP_DEBUGGING_SYMBOLS) if (STRIP_DEBUGGING_SYMBOLS)
# queue this executable to be stripped # queue this executable to be stripped
strip_debug_symbols (${${opm}_TARGET} ${opm}_DEBUG) strip_debug_symbols (${${opm}_TARGET} ${opm}_DEBUG)
endif() endif()
add_static_analysis_tests(${opm}_SOURCES ${opm}_INCLUDE_DIRS)
else (${opm}_SOURCES) else (${opm}_SOURCES)
# unset this variable to signal that no library is generated # unset this variable to signal that no library is generated
set (${opm}_TARGET) set (${opm}_TARGET)

View File

@@ -63,7 +63,7 @@ set (_opm_proj_exemptions
) )
# although a DUNE module, it is delivered in the OPM suite # although a DUNE module, it is delivered in the OPM suite
set (opm-core_SUITE "opm") set (dune-cornerpoint_SUITE "opm")
set (ewoms_SUITE "opm") set (ewoms_SUITE "opm")
# insert this boilerplate whenever we are going to find a new package # insert this boilerplate whenever we are going to find a new package
@@ -87,7 +87,7 @@ macro (find_and_append_package_to prefix name)
# module is part of a suite if it has name with the pattern xxx-yyy # module is part of a suite if it has name with the pattern xxx-yyy
if (("${name}" MATCHES "[^-]+-.+") OR ${name}_SUITE) if (("${name}" MATCHES "[^-]+-.+") OR ${name}_SUITE)
# allow to override if the module doesn't quite fit the convention # allow to override if the module doesn't quite fit the convention
# e.g. dune-cornerpoint (since renamed to opm-grid) # e.g. dune-cornerpoint
if (NOT DEFINED ${name}_SUITE) if (NOT DEFINED ${name}_SUITE)
# extract suite name from module # extract suite name from module
string (REGEX REPLACE "([^-]+)-.+" "\\1" ${name}_SUITE "${name}") string (REGEX REPLACE "([^-]+)-.+" "\\1" ${name}_SUITE "${name}")

View File

@@ -69,7 +69,7 @@ function (opm_grid_type)
endfunction (opm_grid_type) endfunction (opm_grid_type)
# write the grid type for opm-grid # write the grid type for dune-cornerpoint
function (opm_cornerpoint_grid config_h) function (opm_cornerpoint_grid config_h)
opm_grid_type ( opm_grid_type (
FILENAME ${CONFIG_H} FILENAME ${CONFIG_H}

View File

@@ -25,19 +25,19 @@ set (KNOWN_VARS
) )
set (KNOWN_opm_PKGS set (KNOWN_opm_PKGS
common autodiff
parser
material
core core
grid material
output parser
simulators polymer
porsol
upscaling upscaling
verteq verteq
) )
set (KNOWN_dune_PKGS set (KNOWN_dune_PKGS
common common
cornerpoint
geometry geometry
grid grid
istl istl

View File

@@ -28,12 +28,6 @@ if (POLICY CMP0048)
cmake_policy(SET CMP0048 OLD) cmake_policy(SET CMP0048 OLD)
endif() endif()
# set the behavior of the policy 0054 to NEW. (i.e. do not implicitly
# expand variables in if statements)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
# include special # include special
if (CMAKE_VERSION VERSION_LESS "2.8.3") if (CMAKE_VERSION VERSION_LESS "2.8.3")
message (STATUS "Enabling compatibility modules for CMake 2.8.3") message (STATUS "Enabling compatibility modules for CMake 2.8.3")
@@ -43,7 +37,7 @@ endif (CMAKE_VERSION VERSION_LESS "2.8.3")
if (CMAKE_VERSION VERSION_LESS "2.8.5") if (CMAKE_VERSION VERSION_LESS "2.8.5")
message (STATUS "Enabling compatibility modules for CMake 2.8.5") message (STATUS "Enabling compatibility modules for CMake 2.8.5")
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/cmake/Modules/compat-2.8.5") list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/cmake/Modules/compat-2.8.5")
endif (CMAKE_VERSION VERSION_LESS "2.8.5") endif (CMAKE_VERSION VERSION_LESS "2.8.5")
if (CMAKE_VERSION VERSION_LESS "2.8.7") if (CMAKE_VERSION VERSION_LESS "2.8.7")
message (STATUS "Enabling compatibility modules for CMake 2.8.7") message (STATUS "Enabling compatibility modules for CMake 2.8.7")
@@ -99,18 +93,6 @@ endif (NOT USE_MPI)
# parallel programming # parallel programming
include (UseOpenMP) include (UseOpenMP)
find_openmp (${project}) find_openmp (${project})
include (UseThreads)
find_threads (${project})
# SuperLU is optional
option (USE_SUPERLU "Use SuperLU direct solvers" OFF)
# PETSc is optional
option (USE_PETSC "Use PETSc iterative solvers" OFF)
# static code analysis
include(UseStaticAnalysis)
setup_static_analysis_tools()
# callback hook to setup additional dependencies # callback hook to setup additional dependencies
if (COMMAND prereqs_hook) if (COMMAND prereqs_hook)
@@ -295,6 +277,10 @@ opm_doc (${project} ${doxy_dir})
# provide compatibility with using this build in dunecontrol # provide compatibility with using this build in dunecontrol
include (DuneCompat) include (DuneCompat)
include (LibtoolArchives)
if (${project}_TARGET)
configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE)
endif ()
### clean in-source builds ### ### clean in-source builds ###
include (OpmDistClean) include (OpmDistClean)

View File

@@ -98,17 +98,7 @@ macro (find_opm_package module deps header lib defs prog conf)
# to put the build-directories as siblings to the source trees, # to put the build-directories as siblings to the source trees,
# but with a -build suffix, DUNE likes to have the the build tree # but with a -build suffix, DUNE likes to have the the build tree
# in a "build-cmake" sub-directory of each module # in a "build-cmake" sub-directory of each module
set(workaround_cmake_bug 0) if (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
if(${module}_DIR})
set(workaround_cmake_bug 1)
endif()
if(${module}_ROOT})
set(workaround_cmake_bug 1)
endif()
if(${MODULE}_ROOT})
set(workaround_cmake_bug 1)
endif()
if (NOT workaround_cmake_bug)
string (TOLOWER "${module}" _module_lower) string (TOLOWER "${module}" _module_lower)
set (_guess set (_guess
"../${module}" "../${module}"
@@ -133,7 +123,7 @@ macro (find_opm_package module deps header lib defs prog conf)
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}") list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
endforeach (_item) endforeach (_item)
set (_no_system "") set (_no_system "")
else () else (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
# start looking at the paths in this order # start looking at the paths in this order
set (_guess_bin set (_guess_bin
${${module}_DIR} ${${module}_DIR}
@@ -175,7 +165,7 @@ macro (find_opm_package module deps header lib defs prog conf)
# is a problem in our own specified directory, we don't necessarily # is a problem in our own specified directory, we don't necessarily
# want an old version that is left in one of the system paths! # want an old version that is left in one of the system paths!
set (_no_system "NO_DEFAULT_PATH") set (_no_system "NO_DEFAULT_PATH")
endif () endif (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
# by specifying _guess in the HINTS section, it gets searched before # by specifying _guess in the HINTS section, it gets searched before
# the system locations as well. the CMake documentation has a cloudy # the system locations as well. the CMake documentation has a cloudy
@@ -243,7 +233,7 @@ macro (find_opm_package module deps header lib defs prog conf)
NAMES "${_lib}" NAMES "${_lib}"
PATHS ${_guess_bin} PATHS ${_guess_bin}
HINTS ${PkgConf_${module}_LIBRARY_DIRS} ${_guess_hints_bin} HINTS ${PkgConf_${module}_LIBRARY_DIRS} ${_guess_hints_bin}
PATH_SUFFIXES "lib" "lib/Debug" "lib/Release" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib" PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib"
${_no_system_lib} ${_no_system_lib}
) )
# debug info if we didn't find the desired library # debug info if we didn't find the desired library

View File

@@ -1,7 +0,0 @@
function (opm_add_python_test TEST_NAME TEST_SCRIPT)
add_test(NAME ${TEST_NAME}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMAND ${TEST_SCRIPT} ${ARGN})
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "PYTHONPATH=${ERT_PYTHON_PATH}:${CWRAP_PYTHON_PATH}:${PYTHONPATH}")
endfunction(opm_add_python_test)

View File

@@ -1,8 +1,4 @@
# - Build satellites that are dependent of main library # - Build satellites that are dependent of main library
option(ADD_DISABLED_CTESTS "Add the tests which are disabled due to failed preconditions to the ctest output (this makes ctest return an error if such a test is present)" ON)
mark_as_advanced(ADD_DISABLED_CTESTS)
# #
# Enumerate all source code in a "satellite" directory such as tests/, # Enumerate all source code in a "satellite" directory such as tests/,
# compile each of them and optionally set them as a test for CTest to # compile each of them and optionally set them as a test for CTest to
@@ -72,7 +68,6 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp)
set (_test_lib "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}") set (_test_lib "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
else (NOT "${test_regexp}" STREQUAL "") else (NOT "${test_regexp}" STREQUAL "")
set (_test_lib "") set (_test_lib "")
add_static_analysis_tests(_sat_FILE ${opm}_INCLUDE_DIRS)
endif (NOT "${test_regexp}" STREQUAL "") endif (NOT "${test_regexp}" STREQUAL "")
target_link_libraries (${_sat_NAME} ${${opm}_TARGET} ${${opm}_LIBRARIES} ${_test_lib}) target_link_libraries (${_sat_NAME} ${${opm}_TARGET} ${${opm}_LIBRARIES} ${_test_lib})
if (STRIP_DEBUGGING_SYMBOLS) if (STRIP_DEBUGGING_SYMBOLS)
@@ -89,11 +84,6 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp)
endif ("${_sat_NAME}" MATCHES "${_regexp}") endif ("${_sat_NAME}" MATCHES "${_regexp}")
endforeach (_regexp) endforeach (_regexp)
get_target_property (_sat_LOC ${_sat_NAME} LOCATION) get_target_property (_sat_LOC ${_sat_NAME} LOCATION)
# Run tests through mpi-run. Ubuntu 14.04 provided mpi libs will crash
# in the MPI_Finalize() call otherwise.
if(MPI_FOUND)
set(_sat_LOC ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1 ${_sat_LOC})
endif()
if (CMAKE_VERSION VERSION_LESS "2.8.4") if (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test ( add_test (
NAME ${_sat_FANCY} NAME ${_sat_FANCY}
@@ -170,10 +160,6 @@ macro (opm_data satellite target dirname)
DEPENDS ${${satellite}_INPUT_FILES} DEPENDS ${${satellite}_INPUT_FILES}
COMMENT "Making \"${satellite}\" data available in output tree" COMMENT "Making \"${satellite}\" data available in output tree"
) )
if(NOT TARGET test-suite)
add_custom_target(test-suite)
endif()
add_dependencies(test-suite ${${satellite}_DATAFILES})
endmacro (opm_data satellite target dirname files) endmacro (opm_data satellite target dirname files)
# Add a single unit test (can be orchestrated by the 'ctest' command) # Add a single unit test (can be orchestrated by the 'ctest' command)
@@ -342,7 +328,7 @@ macro(opm_add_test TestName)
# the following causes the test to appear as 'skipped' in the # the following causes the test to appear as 'skipped' in the
# CDash dashboard. it this is removed, the test is just silently # CDash dashboard. it this is removed, the test is just silently
# ignored. # ignored.
if (NOT CURTEST_ONLY_COMPILE AND ADD_DISABLED_CTESTS) if (NOT CURTEST_ONLY_COMPILE)
add_test(${TestName} skip_test_dummy) add_test(${TestName} skip_test_dummy)
endif() endif()
endif() endif()

View File

@@ -92,12 +92,13 @@ opm_static_add_dependencies(dune-geometry dune-common)
opm_static_add_dependencies(dune-grid dune-geometry) opm_static_add_dependencies(dune-grid dune-geometry)
# OPM # OPM
foreach(opm_repo opm-common opm-parser opm-core opm-output opm-grid opm-material foreach(opm_repo opm-common opm-parser opm-core dune-cornerpoint opm-material
opm-upscaling) opm-porsol opm-upscaling)
opm_from_git(https://github.com/OPM/${opm_repo} ${opm_repo} ${OPM_BENCHMARK_VERSION}) opm_from_git(https://github.com/OPM/${opm_repo} ${opm_repo} ${OPM_BENCHMARK_VERSION})
endforeach() endforeach()
opm_static_add_dependencies(opm-parser opm-common ert) opm_static_add_dependencies(opm-parser opm-common ert)
opm_static_add_dependencies(opm-core opm-parser dune-istl) opm_static_add_dependencies(opm-core opm-parser dune-istl)
opm_static_add_dependencies(opm-grid opm-core dune-grid) opm_static_add_dependencies(dune-cornerpoint opm-core dune-grid)
opm_static_add_dependencies(opm-material opm-core) opm_static_add_dependencies(opm-material opm-core)
opm_static_add_dependencies(opm-upscaling opm-grid opm-material) opm_static_add_dependencies(opm-porsol dune-cornerpoint opm-material)
opm_static_add_dependencies(opm-upscaling opm-porsol)

View File

@@ -1,4 +1,6 @@
find_package (Boost 1.44.0 COMPONENTS unit_test_framework QUIET) if (NOT Boost_UNIT_TEST_FRAMEWORK_FOUND)
find_package (Boost 1.44.0 COMPONENTS unit_test_framework QUIET)
endif ()
if (Boost_UNIT_TEST_FRAMEWORK_FOUND) if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
# setup to do a test compile # setup to do a test compile

View File

@@ -38,7 +38,7 @@ if (CXX_COMPAT_GCC)
# default optimization flags, if not set by user # default optimization flags, if not set by user
set_default_option (CXX _opt_dbg "-O0" "(^|\ )-O") set_default_option (CXX _opt_dbg "-O0" "(^|\ )-O")
set_default_option (CXX _opt_rel "-O3" "(^|\ )-O") set_default_option (CXX _opt_rel "-O2" "(^|\ )-O")
# use these options for debug builds - no optimizations # use these options for debug builds - no optimizations
add_options (ALL_LANGUAGES "${_prof_DEBUG}" ${_opt_dbg} "-DDEBUG") add_options (ALL_LANGUAGES "${_prof_DEBUG}" ${_opt_dbg} "-DDEBUG")

View File

@@ -1,50 +0,0 @@
# Add static analysis tests for a given source file
macro(setup_static_analysis_tools)
find_package(CppCheck)
if(CMAKE_EXPORT_COMPILE_COMMANDS)
find_package(ClangCheck)
else()
message(STATUS "Disabling clang-check as CMAKE_EXPORT_COMPILE_COMMANDS is not enabled")
endif()
if(OPM_COMMON_ROOT)
set(DIR ${OPM_COMMON_ROOT})
elseif(OPM_MACROS_ROOT)
set(DIR ${OPM_MACROS_ROOT})
else()
set(DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(CPPCHECK_FOUND)
file(COPY ${DIR}/cmake/Scripts/cppcheck-test.sh
DESTINATION bin
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()
if(CLANGCHECK_FOUND AND CMAKE_EXPORT_COMPILE_COMMANDS)
configure_file(${DIR}/cmake/Scripts/clang-check-test.sh.in
${CMAKE_BINARY_DIR}/CMakeFiles/clang-check-test.sh)
file(COPY ${CMAKE_BINARY_DIR}/CMakeFiles/clang-check-test.sh
DESTINATION bin
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()
endmacro()
function(add_static_analysis_tests sources includes)
if(CPPCHECK_FOUND OR (CLANGCHECK_FOUND AND CMAKE_EXPORT_COMPILE_COMMANDS))
foreach(dep ${${includes}})
list(APPEND IPATHS -I ${dep})
endforeach()
foreach(src ${${sources}})
file(RELATIVE_PATH name ${PROJECT_SOURCE_DIR} ${src})
if(CPPCHECK_FOUND)
add_test(NAME cppcheck+${name}
COMMAND bin/cppcheck-test.sh ${CPPCHECK_PROGRAM} ${src} ${IPATHS}
CONFIGURATIONS analyze cppcheck)
endif()
if(CLANGCHECK_FOUND AND CMAKE_EXPORT_COMPILE_COMMANDS)
add_test(NAME clang-check+${name}
COMMAND bin/clang-check-test.sh ${CLANGCHECK_PROGRAM} ${src}
CONFIGURATIONS analyze clang-check)
endif()
endforeach()
endif()
endfunction()

View File

@@ -1,53 +0,0 @@
# - Use PThread features
#
# Synopsis:
#
# find_threads (module)
#
# where:
#
# module Name of the module to which Threads support
# etc. should be added, e.g. "opm-core".
#
# Note: Compiler flags are always added globally, to avoid ABI
# incompatibility problems.
#
# It is assumed that the following variables are available
#
# ${module}_QUIET Verbosity level of the parent's find module
# ${module}_LIBRARIES List of libraries to which Thread support will be added
#
# Example:
# find_threads (opm-core)
include (AddOptions)
include (UseCompVer)
is_compiler_gcc_compatible ()
macro(find_threads opm)
# default is that Threads are added
option(USE_PTHREAD "Use pthreads" ON)
# if USE_PTHREAD is enabled then check and set HAVE_PTHREAD
if( USE_PTHREAD )
# threading library
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (Threads ${${opm}_QUIET})
if (CMAKE_USE_PTHREADS_INIT)
list (APPEND ${opm}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
if (CXX_COMPAT_GCC)
check_cxx_accepts_flag ("-pthread" HAVE_PTHREAD)
if(HAVE_PTHREAD)
add_options (ALL_LANGUAGES ALL_BUILDS "-pthread")
set(HAVE_PTHREAD "1")
endif(HAVE_PTHREAD)
endif (CXX_COMPAT_GCC)
else(CMAKE_USE_PTHREADS_INIT)
set(USE_PTHREAD OFF)
endif (CMAKE_USE_PTHREADS_INIT)
else( USE_PTHREAD )
# reset HAVE_PTHREAD
set(HAVE_PTHREAD "")
endif( USE_PTHREAD )
endmacro(find_threads opm)

View File

@@ -2,32 +2,31 @@
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap: # vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers # defines that must be present in config.h for our headers
set (opm-grid_CONFIG_VAR set (dune-cornerpoint_CONFIG_VAR
DUNE_GRID_VERSION_MAJOR DUNE_GRID_VERSION_MAJOR
DUNE_GRID_VERSION_MINOR DUNE_GRID_VERSION_MINOR
DUNE_GRID_VERSION_REVISION DUNE_GRID_VERSION_REVISION
DUNE_COMMON_VERSION_MAJOR DUNE_COMMON_VERSION_MAJOR
DUNE_COMMON_VERSION_MINOR DUNE_COMMON_VERSION_MINOR
DUNE_COMMON_VERSION_REVISION DUNE_COMMON_VERSION_REVISION
HAVE_DUNE_ISTL
HAVE_MPI
HAVE_ZOLTAN HAVE_ZOLTAN
) )
# dependencies # dependencies
set (opm-grid_DEPS set (dune-cornerpoint_DEPS
# compile with C99 support if available # compile with C99 support if available
"C99" "C99"
# compile with C++0x/11 support if available # compile with C++0x/11 support if available
"CXX11Features" "CXX11Features"
# various runtime library enhancements # various runtime library enhancements
"Boost 1.44.0 "Boost 1.44.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED" COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
"MPI" # DUNE dependency
"dune-common" "dune-common REQUIRED;
"dune-grid REQUIRED" dune-grid REQUIRED;
"dune-istl" dune-geometry REQUIRED"
"opm-common REQUIRED" # OPM dependency
"opm-parser REQUIRED" "opm-common REQUIRED;
opm-core REQUIRED"
"ZOLTAN" "ZOLTAN"
) )

View File

@@ -9,13 +9,6 @@ set(DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING 1)
set (ewoms_CONFIG_VAR set (ewoms_CONFIG_VAR
HAVE_QUAD HAVE_QUAD
HAVE_VALGRIND HAVE_VALGRIND
HAVE_DUNE_COMMON
HAVE_DUNE_GEOMETRY
HAVE_DUNE_GRID
HAVE_DUNE_LOCALFUNCTIONS
HAVE_DUNE_ISTL
HAVE_DUNE_ALUGRID
HAVE_DUNE_FEM
DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING
) )
@@ -25,17 +18,14 @@ set (ewoms_DEPS
"CXX11Features REQUIRED" "CXX11Features REQUIRED"
# DUNE prerequisites # DUNE prerequisites
"dune-common REQUIRED" "dune-common REQUIRED"
"dune-localfunctions REQUIRED"
"dune-geometry REQUIRED" "dune-geometry REQUIRED"
"dune-grid REQUIRED" "dune-grid REQUIRED"
"dune-istl REQUIRED" "dune-istl REQUIRED"
"opm-common REQUIRED"
"opm-material REQUIRED" "opm-material REQUIRED"
"dune-localfunctions"
"dune-alugrid" "dune-alugrid"
"dune-fem" "dune-fem"
"opm-parser" "dune-cornerpoint"
"opm-grid"
"opm-core"
# librt (on some systems necessary for clock_gettime()) # librt (on some systems necessary for clock_gettime())
"librt REQUIRED" "librt REQUIRED"
# valgrind client requests # valgrind client requests

View File

@@ -2,35 +2,25 @@
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap: # vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers # defines that must be present in config.h for our headers
set (opm-simulators_CONFIG_VAR set (opm-autodiff_CONFIG_VAR
HAVE_OPM_GRID HAVE_DUNE_CORNERPOINT
HAVE_PTHREAD
HAVE_EWOMS
DUNE_ISTL_VERSION_MAJOR
DUNE_ISTL_VERSION_MINOR
DUNE_ISTL_VERSION_REVISION
) )
# dependencies # dependencies
set (opm-simulators_DEPS set (opm-autodiff_DEPS
# Compile with C99 support if available # Compile with C99 support if available
"C99" "C99"
# Compile with C++0x/11 support if available # Compile with C++0x/11 support if available
"CXX11Features" "CXX11Features"
# Various runtime library enhancements # Various runtime library enhancements
"Boost 1.44.0 "Boost 1.44.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED" COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# DUNE prerequisites # DUNE prerequisites
"dune-common REQUIRED; "dune-common REQUIRED;
dune-istl REQUIRED" dune-istl REQUIRED;
"ERTPython" dune-cornerpoint;
# OPM dependency opm-common REQUIRED;
"opm-common REQUIRED; opm-core REQUIRED"
opm-parser REQUIRED;
opm-grid REQUIRED;
opm-core REQUIRED;
opm-output REQUIRED;
ewoms REQUIRED"
# Eigen # Eigen
"Eigen3 3.2.0" "Eigen3 3.2.0"
) )

View File

@@ -11,7 +11,7 @@ set (opm-benchmarks_DEPS
"CXX11Features REQUIRED" "CXX11Features REQUIRED"
# various runtime library enhancements # various runtime library enhancements
"Boost 1.44.0 "Boost 1.44.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED" COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# OPM dependency # OPM dependency
"opm-common" "opm-common"
"opm-core REQUIRED" "opm-core REQUIRED"

View File

@@ -3,7 +3,7 @@
# defines that must be present in config.h for our headers # defines that must be present in config.h for our headers
set (opm-common_CONFIG_VAR set (opm-common_CONFIG_VAR
"HAS_ATTRIBUTE_UNUSED") )
# dependencies # dependencies
set (opm-common_DEPS set (opm-common_DEPS
@@ -12,6 +12,5 @@ set (opm-common_DEPS
# compile with C++0x/11 support if available # compile with C++0x/11 support if available
"CXX11Features REQUIRED" "CXX11Features REQUIRED"
# various runtime library enhancements # various runtime library enhancements
"Boost 1.44.0 ""
COMPONENTS system unit_test_framework REQUIRED"
) )

View File

@@ -8,9 +8,6 @@ set (opm-core_CONFIG_VAR
HAVE_DUNE_ISTL HAVE_DUNE_ISTL
HAVE_MPI HAVE_MPI
HAVE_PETSC HAVE_PETSC
DUNE_ISTL_VERSION_MAJOR
DUNE_ISTL_VERSION_MINOR
DUNE_ISTL_VERSION_REVISION
) )
# dependencies # dependencies
@@ -21,7 +18,7 @@ set (opm-core_DEPS
"CXX11Features REQUIRED" "CXX11Features REQUIRED"
# various runtime library enhancements # various runtime library enhancements
"Boost 1.44.0 "Boost 1.44.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED" COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# matrix library # matrix library
"BLAS REQUIRED" "BLAS REQUIRED"
"LAPACK REQUIRED" "LAPACK REQUIRED"
@@ -29,8 +26,10 @@ set (opm-core_DEPS
"SuiteSparse COMPONENTS umfpack" "SuiteSparse COMPONENTS umfpack"
# solver # solver
"SuperLU" "SuperLU"
# xml processing (for config parsing)
"TinyXML"
# Ensembles-based Reservoir Tools (ERT) # Ensembles-based Reservoir Tools (ERT)
"ecl REQUIRED" "ERT REQUIRED"
# Look for MPI support # Look for MPI support
"MPI" "MPI"
# PETSc numerical backend # PETSc numerical backend
@@ -43,8 +42,4 @@ set (opm-core_DEPS
"opm-parser REQUIRED" "opm-parser REQUIRED"
# the code which implements the material laws # the code which implements the material laws
"opm-material REQUIRED" "opm-material REQUIRED"
# the code which implements the output routines
"opm-output REQUIRED"
# the code which implements grids
"opm-grid REQUIRED"
) )

View File

@@ -1,18 +0,0 @@
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers
set (opm-flowdiagnostics_CONFIG_VAR
)
# dependencies
set (opm-flowdiagnostics_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
"Boost 1.44.0
COMPONENTS unit_test_framework REQUIRED"
# prerequisite OPM modules
"opm-common REQUIRED"
)

View File

@@ -16,10 +16,8 @@ set (opm-material_DEPS
# compile with C++0x/11 support if available # compile with C++0x/11 support if available
"CXX11Features REQUIRED" "CXX11Features REQUIRED"
# prerequisite OPM modules # prerequisite OPM modules
"opm-common"
"opm-parser" "opm-parser"
"opm-common REQUIRED"
# DUNE dependency # DUNE dependency
"dune-common REQUIRED" "dune-common REQUIRED"
# valgrind client requests
"Valgrind"
) )

View File

@@ -2,23 +2,24 @@
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap: # vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers # defines that must be present in config.h for our headers
set (opm-output_CONFIG_VAR set (opm-polymer_CONFIG_VAR
HAVE_ERT
) )
# dependencies # dependencies
set (opm-output_DEPS set (opm-polymer_DEPS
# compile with C99 support if available # compile with C99 support if available
"C99" "C99"
# compile with C++0x/11 support if available # compile with C++0x/11 support if available
"CXX11Features REQUIRED" "CXX11Features"
# various runtime library enhancements # various runtime library enhancements
"Boost 1.44.0 "Boost 1.44.0
COMPONENTS unit_test_framework REQUIRED" COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# Ensembles-based Reservoir Tools (ERT) # Ensembles-based Reservoir Tools
"ecl REQUIRED" "ERT"
# Look for MPI support # OPM dependency
"opm-common REQUIRED" "opm-autodiff REQUIRED;
# Parser library for ECL-type simulation models opm-common;
"opm-parser REQUIRED" opm-core REQUIRED"
# Eigen
"Eigen3 3.1 REQUIRED"
) )

View File

@@ -2,20 +2,24 @@
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap: # vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# defines that must be present in config.h for our headers # defines that must be present in config.h for our headers
set (opm-flowdiagnostics-applications_CONFIG_VAR set (opm-porsol_CONFIG_VAR
) )
# dependencies # dependencies
set (opm-flowdiagnostics-applications_DEPS set (opm-porsol_DEPS
# compile with C99 support if available # compile with C99 support if available
"C99" "C99"
# compile with C++0x/11 support if available # compile with C++0x/11 support if available
"CXX11Features REQUIRED" "CXX11Features"
# various runtime library enhancements
"Boost 1.44.0 "Boost 1.44.0
COMPONENTS filesystem regex system unit_test_framework REQUIRED" COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
"ERT REQUIRED" # DUNE dependency
# prerequisite OPM modules "dune-common REQUIRED;
"opm-common REQUIRED; dune-istl REQUIRED;
opm-flowdiagnostics REQUIRED; dune-grid REQUIRED;
opm-core REQUIRED" opm-common;
opm-core REQUIRED;
opm-material REQUIRED;
dune-cornerpoint REQUIRED"
) )

View File

@@ -25,8 +25,8 @@ set (opm-upscaling_DEPS
dune-istl REQUIRED; dune-istl REQUIRED;
dune-geometry REQUIRED; dune-geometry REQUIRED;
dune-grid REQUIRED; dune-grid REQUIRED;
opm-common REQUIRED; opm-common;
opm-grid REQUIRED;
opm-core REQUIRED; opm-core REQUIRED;
opm-output REQUIRED" dune-cornerpoint REQUIRED;
opm-porsol REQUIRED"
) )

View File

@@ -13,7 +13,7 @@ set (opm-verteq_DEPS
"CXX11Features" "CXX11Features"
# various runtime library enhancements # various runtime library enhancements
"Boost 1.44.0 "Boost 1.44.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED" COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# OPM dependency # OPM dependency
"opm-common; "opm-common;
opm-core REQUIRED" opm-core REQUIRED"

View File

@@ -1,23 +0,0 @@
#!/bin/bash
# This script performs a single analysis using clang-check
# It is used by the 'make test' target in the buildsystems
# Usually you should use 'ctest -C clang-check' rather than calling this script directly
#
# Parameters: $1 = Application binary
# $2 = Source file to process
clangcheck_cmd=$1
source_file=$2
tmpfil=`mktemp`
$clangcheck_cmd -p @CMAKE_BINARY_DIR@ -analyze $source_file &> $tmpfil
cat $tmpfil
if test -s $tmpfil
then
rm $tmpfil
exit 1
fi
rm $tmpfil
exit 0

View File

@@ -1,30 +0,0 @@
#!/bin/bash
# This script performs a single analysis using cppcheck
# It is used by the 'make test' target in the buildsystems
# Usually you should use 'ctest -C cppcheck' rather than calling this script directly
#
# Parameters: $1 = Application binary
# $2 = Source file to process
# $3..$N = include path parameters (-I dir1 -I dir2 ...)
cppcheck_cmd=$1
source_file=$2
shift 2
tmpfil=`mktemp`
$cppcheck_cmd $@ --enable=all --suppress=unusedFunction $source_file &> $tmpfil
nmatch=`cat $tmpfil | grep "\[.*\]" | wc -l`
nsys=`cat $tmpfil | grep "\[/usr.*\]" | wc -l`
nnone=`cat $tmpfil | grep "\[\\*]" | wc -l`
ndef=`cat $tmpfil | grep "\[.*Too many #ifdef" | wc -l`
let "nval=$nmatch-$nsys-$nnone-$ndef"
if test $nval -gt 0
then
cat $tmpfil
rm $tmpfil
exit 1
fi
rm $tmpfil
exit 0

2
debian/changelog vendored
View File

@@ -1,4 +1,4 @@
opm-common (2015.10-1~trusty) trusty; urgency=medium opm-common (2015.10-rc-2~trusty) trusty; urgency=medium
* New release * New release

13
debian/control vendored
View File

@@ -4,30 +4,19 @@ Maintainer: Arne Morten Kvarving <arne.morten.kvarving@sintef.no>
Build-Depends: build-essential, debhelper (>= 9), Build-Depends: build-essential, debhelper (>= 9),
pkg-config, cmake, git, libtool, doxygen, pkg-config, cmake, git, libtool, doxygen,
texlive-latex-extra, texlive-latex-recommended, texlive-latex-extra, texlive-latex-recommended,
ghostscript, libboost-system-dev, libboost-test-dev ghostscript
Standards-Version: 3.9.2 Standards-Version: 3.9.2
Section: libs Section: libs
Homepage: http://opm-project.org Homepage: http://opm-project.org
Vcs-Git: git://github.com/OPM/opm-common.git Vcs-Git: git://github.com/OPM/opm-common.git
Vcs-Browser: https://github.com/OPM/opm-common Vcs-Browser: https://github.com/OPM/opm-common
Package: libopm-common1
Section: libs
Pre-Depends: ${misc:Pre-Depends}, multiarch-support
Architecture: any
Multi-Arch: same
Depends: ${shlibs:Depends}, ${misc:Depends}
Provides: libopm-common
Description: OPM common library
The OPM common library contains generic code shared across all OPM modules.
Package: libopm-common1-dev Package: libopm-common1-dev
Section: libdevel Section: libdevel
Architecture: any Architecture: any
Multi-Arch: foreign Multi-Arch: foreign
Provides: libopm-common-dev Provides: libopm-common-dev
Suggests: libopm-common1-doc Suggests: libopm-common1-doc
Depends: libopm-common1 (= ${binary:Version})
Description: OPM common library -- development files Description: OPM common library -- development files
The OPM common library contains the shared buildsystem The OPM common library contains the shared buildsystem
and helpers shared across all OPM modules. and helpers shared across all OPM modules.

View File

@@ -1,6 +1,5 @@
usr/include/* usr/include/*
usr/lib/dunecontrol/* usr/lib/dunecontrol/*
usr/lib/*/pkgconfig/* usr/lib/pkgconfig/*
usr/share/cmake/* usr/share/cmake/*
usr/share/opm/* usr/share/opm/*
usr/lib/*/lib*.so

View File

@@ -1 +0,0 @@
usr/lib/*/lib*.so.*

2
debian/rules vendored
View File

@@ -20,7 +20,7 @@ override_dh_auto_build:
# consider using -DUSE_VERSIONED_DIR=ON if backporting # consider using -DUSE_VERSIONED_DIR=ON if backporting
override_dh_auto_configure: override_dh_auto_configure:
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-common1 -DWHOLE_PROG_OPTIM=ON -DUSE_RUNPATH=OFF -DWITH_NATIVE=OFF dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-common1 -DWHOLE_PROG_OPTIM=ON -DUSE_RUNPATH=OFF
override_dh_auto_install: override_dh_auto_install:
dh_auto_install -- install-html dh_auto_install -- install-html

View File

@@ -5,8 +5,8 @@
Module: opm-common Module: opm-common
Description: Open Porous Media Initiative shared infrastructure Description: Open Porous Media Initiative shared infrastructure
Version: 2017.10-pre Version: 2015.10
Label: 2017.10-pre Label: 2015.10
Maintainer: opm@opm-project.org Maintainer: opm@opm-project.org
MaintainerName: OPM community MaintainerName: OPM community
Url: http://opm-project.org Url: http://opm-project.org

View File

@@ -1,11 +0,0 @@
# opm-common jenkins build scripts:
**build-opm-module.sh**:
This is a helper script which contains functions for building,
testing and cloning modules.
**build.sh**:
This expects to run on a jenkins instance with opm-common as the 'origin' remote.
It will build and test opm-common. It can be used both for post-merge builds
of the master branch and for a github pull request builder job.

View File

@@ -1,233 +0,0 @@
#!/bin/bash
declare -A configurations
# Parse revisions from trigger comment and setup arrays
# Depends on: 'upstreams', upstreamRev',
# 'downstreams', 'downstreamRev',
# 'ghprbCommentBody',
# 'CONFIGURATIONS', 'TOOLCHAINS'
function parseRevisions {
for upstream in ${upstreams[*]}
do
if grep -qi "$upstream=" <<< $ghprbCommentBody
then
upstreamRev[$upstream]=pull/`echo $ghprbCommentBody | sed -r "s/.*${upstream,,}=([0-9]+).*/\1/g"`/merge
fi
done
if grep -q "with downstreams" <<< $ghprbCommentBody
then
for downstream in ${downstreams[*]}
do
if grep -qi "$downstream=" <<< $ghprbCommentBody
then
downstreamRev[$downstream]=pull/`echo $ghprbCommentBody | sed -r "s/.*${downstream,,}=([0-9]+).*/\1/g"`/merge
fi
done
fi
# Default to a serial build if no types are given
if test -z "$BTYPES"
then
BTYPES="serial"
fi
# Convert to arrays for easy looping
declare -a BTYPES_ARRAY
for btype in $BTYPES
do
BTYPES_ARRAY=($BTYPES_ARRAY $btype)
done
TOOLCHAIN_ARRAY=($CMAKE_TOOLCHAIN_FILES)
for index in ${!BTYPES_ARRAY[*]}
do
key=${BTYPES_ARRAY[$index]}
data=${TOOLCHAIN_ARRAY[$index]}
configurations[$key]=$data
done
}
# Print revisions and configurations
# $1 = Name of main module
# Depends on: 'upstreams', upstreamRev',
# 'downstreams', 'downstreamRev',
# 'ghprbCommentBody',
# 'configurations', 'sha1'
function printHeader {
echo -e "Repository revisions:"
for upstream in ${upstreams[*]}
do
echo -e "\t [upstream] $upstream=${upstreamRev[$upstream]}"
done
echo -e "\t[main module] $1=$sha1"
if grep -q "with downstreams" <<< $ghprbCommentBody
then
for downstream in ${downstreams[*]}
do
echo -e "\t [downstream] $downstream=${downstreamRev[$downstream]}"
done
fi
echo "Configurations to process:"
for conf in ${!configurations[@]}
do
echo -e "\t$conf=${configurations[$conf]}"
done
}
# $1 = Additional cmake parameters
# $2 = 0 to build and install module, 1 to build and test module
# $3 = Source root of module to build
function build_module {
cmake $3 -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=$2 -DCMAKE_TOOLCHAIN_FILE=${configurations[$configuration]} $1
test $? -eq 0 || exit 1
if test $2 -eq 1
then
if [ ! -z $BUILDTHREADS ]
then
cmake --build . -- -j$BUILDTHREADS
else
cmake --build .
fi
test $? -eq 0 || exit 2
if test -z "$CTEST_CONFIGURATION"
then
ctest -T Test --no-compress-output
else
ctest -C $CTEST_CONFIGURATION --timeout 5000 -T Test --no-compress-output
fi
# Convert to junit format
$WORKSPACE/deps/opm-common/jenkins/convert.py -x $WORKSPACE/deps/opm-common/jenkins/conv.xsl -t . > testoutput.xml
if ! grep -q "with downstreams" <<< $ghprbCommentBody
then
# Add configuration name
sed -e "s/classname=\"TestSuite\"/classname=\"${configuration}\"/g" testoutput.xml > $WORKSPACE/$configuration/testoutput.xml
fi
else
if [ ! -z $BUILDTHREADS ]
then
cmake --build . --target install -- -j$BUILDTHREADS
else
cmake --build . --target install
fi
fi
}
# $1 = Name of module
# $2 = git-rev to use for module
function clone_module {
# Already cloned by an earlier configuration
test -d $WORKSPACE/deps/$1 && return 0
pushd .
mkdir -p $WORKSPACE/deps/$1
cd $WORKSPACE/deps/$1
git init .
if [ "$1" == "libecl" ]
then
git remote add origin https://github.com/Statoil/$1
else
git remote add origin https://github.com/OPM/$1
fi
git fetch --depth 1 origin $2:branch_to_build
git checkout branch_to_build
test $? -eq 0 || exit 1
popd
}
# $1 = Module to clone
# $2 = Additional cmake parameters
# $3 = git-rev to use for module
# $4 = Build root
function clone_and_build_module {
clone_module $1 $3
pushd .
mkdir -p $4/build-$1
cd $4/build-$1
test_build=0
if test -n "$5"
then
test_build=$5
fi
build_module "$2" $test_build $WORKSPACE/deps/$1
test $? -eq 0 || exit 1
popd
}
# Uses pre-filled arrays upstreams, and associativ array upstreamRev
# which holds the revisions to use for upstreams.
function build_upstreams {
for upstream in ${upstreams[*]}
do
echo "Building upstream $upstream=${upstreamRev[$upstream]} configuration=$configuration"
# Build upstream and execute installation
clone_and_build_module $upstream "-DCMAKE_PREFIX_PATH=$WORKSPACE/$configuration/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/$configuration/install" ${upstreamRev[$upstream]} $WORKSPACE/$configuration
test $? -eq 0 || exit 1
done
test $? -eq 0 || exit 1
}
# $1 - name of the module we are called from
# Uses pre-filled arrays downstreams, and associativ array downstreamRev
# which holds the default revisions to use for downstreams
function build_downstreams {
pushd .
cd $WORKSPACE/$configuration/build-$1
cmake --build . --target install
popd
egrep_cmd="xml_grep --wrap testsuites --cond testsuite $WORKSPACE/$configuration/build-$1/testoutput.xml"
for downstream in ${downstreams[*]}
do
echo "Building downstream $downstream=${downstreamRev[$downstream]} configuration=$configuration"
# Build downstream and execute installation
clone_and_build_module $downstream "-DCMAKE_PREFIX_PATH=$WORKSPACE/$configuration/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/$configuration/install -DOPM_DATA_ROOT=$OPM_DATA_ROOT" ${downstreamRev[$downstream]} $WORKSPACE/$configuration 1
test $? -eq 0 || exit 1
# Installation for downstream
pushd .
cd $WORKSPACE/$configuration/build-$downstream
if [ ! -z $BUILDTHREADS ]
then
cmake --build . --target install -- -j$BUILDTHREADS
else
cmake --build . --target install
fi
popd
egrep_cmd="$egrep_cmd $WORKSPACE/$configuration/build-$downstream/testoutput.xml"
done
$egrep_cmd > $WORKSPACE/$configuration/testoutput.xml
# Add testsuite name
sed -e "s/classname=\"TestSuite\"/classname=\"${configuration}\"/g" -i $WORKSPACE/$configuration/testoutput.xml
test $? -eq 0 || exit 1
}
# $1 = Name of main module
function build_module_full {
for configuration in ${!configurations[@]}
do
# Build upstream modules
build_upstreams
# Build main module
pushd .
mkdir -p $configuration/build-$1
cd $configuration/build-$1
echo "Building main module $1=$sha1 configuration=$configuration"
build_module "-DCMAKE_INSTALL_PREFIX=$WORKSPACE/$configuration/install -DOPM_DATA_ROOT=$OPM_DATA_ROOT" 1 $WORKSPACE
test $? -eq 0 || exit 1
popd
# If no downstream builds we are done
if grep -q "with downstreams" <<< $ghprbCommentBody
then
build_downstreams $1
test $? -eq 0 || exit 1
fi
done
}

View File

@@ -1,42 +0,0 @@
#!/bin/bash
source `dirname $0`/build-opm-module.sh
# Create symlink so build_module can find the test result converter
mkdir deps
ln -sf $WORKSPACE deps/opm-common
# Downstreams and revisions
declare -a downstreams
downstreams=(libecl
opm-parser
opm-output
opm-material
opm-grid
opm-core
ewoms
opm-simulators
opm-upscaling
)
declare -A downstreamRev
downstreamRev[libecl]=master
downstreamRev[opm-parser]=master
downstreamRev[opm-material]=master
downstreamRev[opm-core]=master
downstreamRev[opm-grid]=master
downstreamRev[opm-output]=master
downstreamRev[ewoms]=master
downstreamRev[opm-simulators]=master
downstreamRev[opm-upscaling]=master
parseRevisions
printHeader opm-common
# Setup opm-data if necessary
if grep -q "with downstreams" <<< $ghprbCommentBody
then
source $WORKSPACE/deps/opm-common/jenkins/setup-opm-data.sh
fi
build_module_full opm-common

View File

@@ -1,116 +0,0 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/Site">
<testsuite>
<xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
<xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
<xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
<xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
<xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
<xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
<xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
<xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
<xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
<xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
<xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
<xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
<xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
<xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
<xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
<xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
<xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
<xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
<xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
<xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
<xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
<xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
<properties>
<property name="BuildName" value="{$BuildName}" />
<property name="BuildStamp" value="{$BuildStamp}" />
<property name="Name" value="{$Name}" />
<property name="Generator" value="{$Generator}" />
<property name="CompilerName" value="{$CompilerName}" />
<property name="OSName" value="{$OSName}" />
<property name="Hostname" value="{$Hostname}" />
<property name="OSRelease" value="{$OSRelease}" />
<property name="OSVersion" value="{$OSVersion}" />
<property name="OSPlatform" value="{$OSPlatform}" />
<property name="Is64Bits" value="{$Is64Bits}" />
<property name="VendorString" value="{$VendorString}" />
<property name="VendorID" value="{$VendorID}" />
<property name="FamilyID" value="{$FamilyID}" />
<property name="ModelID" value="{$ModelID}" />
<property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
<property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
<property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
<property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
<property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
<property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
<property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
</properties>
<xsl:apply-templates select="Testing/Test"/>
<system-out>
BuildName: <xsl:value-of select="$BuildName" />
BuildStamp: <xsl:value-of select="$BuildStamp" />
Name: <xsl:value-of select="$Name" />
Generator: <xsl:value-of select="$Generator" />
CompilerName: <xsl:value-of select="$CompilerName" />
OSName: <xsl:value-of select="$OSName" />
Hostname: <xsl:value-of select="$Hostname" />
OSRelease: <xsl:value-of select="$OSRelease" />
OSVersion: <xsl:value-of select="$OSVersion" />
OSPlatform: <xsl:value-of select="$OSPlatform" />
Is64Bits: <xsl:value-of select="$Is64Bits" />
VendorString: <xsl:value-of select="$VendorString" />
VendorID: <xsl:value-of select="$VendorID" />
FamilyID: <xsl:value-of select="$FamilyID" />
ModelID: <xsl:value-of select="$ModelID" />
ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
</system-out>
</testsuite>
</xsl:template>
<xsl:template match="Testing/Test">
<xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
<xsl:variable name="exectime">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Execution Time'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<testcase name="{$testcasename}" classname="TestSuite" time="{$exectime}">
<xsl:if test="@Status = 'passed'">
</xsl:if>
<xsl:if test="@Status = 'failed'">
<xsl:variable name="failtype">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Code'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="failcode">
<xsl:for-each select="Results/NamedMeasurement">
<xsl:if test="@name = 'Exit Value'">
<xsl:value-of select="."/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<error message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></error>
</xsl:if>
<xsl:if test="@Status = 'notrun'">
<skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
</xsl:if>
</testcase>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,74 +0,0 @@
#!/usr/bin/env python
# coding: utf-8
# originally from:
# http://www.warp1337.com/content/how-use-ctest-jenkins-xunit-or-junit-plugin
# improved by:
# Jorge Araya Navarro <elcorreo@deshackra.com>
# Veni, Sancte Spiritus.
from lxml import etree
import argparse
from os.path import expanduser
from os.path import join
import logging
# configure logging
logging.basicConfig(format="%(levelname)s: %(message)s",
level=logging.ERROR)
desc = ("Converts ctest XML file to xUnit/JUnit XML "
"compatible file to use with Jenkins-CI. "
"Did you found any bug? please report it on: "
"https://bitbucket.org/shackra/ctest-jenkins/issues")
# configure argument parser.
parser = argparse.ArgumentParser(description=desc)
parser.add_argument("-x", "--xslt", help="the XSLT file to use", required=True)
parser.add_argument("-t", "--tag", help=("the directory where 'Testing/TAG'"
"file is. Remember to call ctest with"
" '-T test' option to generate it"),
required=True)
parsed = parser.parse_args()
# expanding user symbol "~"
parsed.xsl = expanduser(parsed.xslt)
parsed.tag = expanduser(parsed.tag)
# opening the TAG file
directory = None
try:
with open(join(parsed.tag, "Testing", "TAG")) as tagfile:
directory = tagfile.readline().strip()
except NotADirectoryError:
logging.error(
"'Testing/TAG' wasn't found on directory '{}'.".format(parsed.tag))
exit(1)
except FileNotFoundError:
logging.error(
"File '{}' not found.".format(join(parsed.tag, "Testing", "TAG")))
exit(1)
xmldoc = None
transform = None
try:
with open(join(parsed.tag, "Testing", directory, "Test.xml"))\
as testxmlfile:
xmldoc = etree.parse(testxmlfile)
except FileNotFoundError:
logging.error("File {} not found. Was it deleted or moved?".format(
join(parsed.tag, "Testing", directory, "Test.xml")))
exit(1)
try:
with open(parsed.xslt) as xsltfile:
xslt_root = etree.XML(xsltfile.read())
transform = etree.XSLT(xslt_root)
except FileNotFoundError:
logging.error("File {} not found.".format(parsed.xslt))
exit(1)
result_tree = transform(xmldoc)
print(result_tree)

View File

@@ -1,29 +0,0 @@
#!/bin/bash
# Predefined by environment
if test -z "$OPM_DATA_ROOT"
then
OPM_DATA_REVISION="master"
if grep -q "opm-data=" <<< $ghprbCommentBody
then
OPM_DATA_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-data=([0-9]+).*/\1/g'`/merge
fi
# Not specified in trigger, use shared copy
if [[ "$OPM_DATA_REVISION" = "master" ]] && [[ ! "$OPM_DATA_ROOT_PREDEFINED" = "" ]]
then
if ! test -d $WORKSPACE/deps/opm-data
then
cp $OPM_DATA_ROOT_PREDEFINED $WORKSPACE/deps/opm-data -R
fi
else
# Specified in trigger, download it
source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh
clone_module opm-data $OPM_DATA_REVISION
fi
else
if ! test -d $WORKSPACE/deps/opm-data
then
cp $OPM_DATA_ROOT $WORKSPACE/deps/opm-data -R
fi
fi
OPM_DATA_ROOT=$WORKSPACE/deps/opm-data

View File

@@ -1,58 +0,0 @@
#!/bin/bash
MAIN_REPO=$1 # The repo the update was triggered from
source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh
declare -a upstreams # Everything is considered an upstream to aid code reuse
upstreams=(libecl
opm-common
opm-parser
opm-output
opm-material
opm-grid
opm-core
ewoms
opm-simulators
opm-upscaling
)
declare -A upstreamRev
upstreamRev[libecl]=master
upstreamRev[opm-common]=master
upstreamRev[opm-parser]=master
upstreamRev[opm-material]=master
upstreamRev[opm-core]=master
upstreamRev[opm-grid]=master
upstreamRev[opm-output]=master
upstreamRev[ewoms]=master
upstreamRev[opm-simulators]=master
upstreamRev[opm-upscaling]=master
# Setup revision tables
parseRevisions
upstreamRev[$MAIN_REPO]=$sha1
# Create branch name
BRANCH_NAME="update"
for repo in ${upstreams[*]}
do
if [ "${upstreamRev[$repo]}" != "master" ]
then
rev=${upstreamRev[$repo]}
prnumber=${rev//[!0-9]/}
BRANCH_NAME="${BRANCH_NAME}_${repo}_$prnumber"
test -n "$REASON" && REASON+=" "
REASON+="https://github.com/OPM/$repo/pull/$prnumber\n"
fi
done
# Do the commit
export REASON
export BRANCH_NAME
$WORKSPACE/deps/opm-simulators/tests/update_reference_data.sh $OPM_DATA_ROOT
# Finally open the pull request
cd $OPM_DATA_ROOT
git remote add jenkins4opm git@github.com:jenkins4opm/opm-data
git-open-pull -u jenkins4opm --base-account OPM --base-repo opm-data -r /tmp/cmsg $BRANCH_NAME

View File

@@ -21,12 +21,11 @@
#ifndef OPM_ERRORMACROS_HPP #ifndef OPM_ERRORMACROS_HPP
#define OPM_ERRORMACROS_HPP #define OPM_ERRORMACROS_HPP
#include <opm/common/OpmLog/OpmLog.hpp>
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <exception> #include <exception>
#include <stdexcept> #include <stdexcept>
#include <cassert> #include <cassert>
// macros for reporting to stderr // macros for reporting to stderr
@@ -53,17 +52,7 @@
do { \ do { \
std::ostringstream oss__; \ std::ostringstream oss__; \
oss__ << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \ oss__ << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \
Opm::OpmLog::error(oss__.str()); \ OPM_MESSAGE(message); \
throw Exception(oss__.str()); \
} while (false)
// Same as OPM_THROW, except for not making an OpmLog::error() call.
//
// Usage: OPM_THROW_NOLOG(ExceptionClass, "Error message " << value);
#define OPM_THROW_NOLOG(Exception, message) \
do { \
std::ostringstream oss__; \
oss__ << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \
throw Exception(oss__.str()); \ throw Exception(oss__.str()); \
} while (false) } while (false)

View File

@@ -58,13 +58,6 @@ public:
: NumericalProblem(message) : NumericalProblem(message)
{} {}
}; };
class TooManyIterations : public NumericalProblem
{
public:
explicit TooManyIterations(const std::string &message)
: NumericalProblem(message)
{}
};
} }
#endif // OPM_EXCEPTIONS_HPP #endif // OPM_EXCEPTIONS_HPP

View File

@@ -1,63 +0,0 @@
/*
Copyright 2014 Andreas Lauser
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <sstream>
#include <cassert>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/common/OpmLog/CounterLog.hpp>
namespace Opm {
CounterLog::CounterLog(int64_t messageTypes) : LogBackend(messageTypes)
{ }
CounterLog::CounterLog() : LogBackend(Log::DefaultMessageTypes)
{ }
size_t CounterLog::numMessages(int64_t messageType) const {
if (Log::isPower2( messageType )) {
auto iter = m_count.find( messageType );
if (iter == m_count.end())
return 0;
else
return (*iter).second;
} else
throw std::invalid_argument("The messageType ID must be 2^n");
}
void CounterLog::addMessageUnconditionally(int64_t messageType, const std::string& ) {
m_count[messageType]++;
}
void CounterLog::clear()
{
m_count.clear();
}
} // namespace Opm

View File

@@ -1,53 +0,0 @@
/*
Copyright 2014 Andreas Lauser
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_COUNTERLOG_HPP
#define OPM_COUNTERLOG_HPP
#include <string>
#include <memory>
#include <map>
#include <opm/common/OpmLog/LogBackend.hpp>
namespace Opm {
/*!
* \brief Provides a simple sytem for log message which are found by the
* Parser/Deck/EclipseState classes during processing the deck.
*/
class CounterLog : public LogBackend
{
public:
explicit CounterLog(int64_t messageMask);
CounterLog();
size_t numMessages(int64_t messageType) const;
void clear();
protected:
void addMessageUnconditionally(int64_t messageFlag,
const std::string& message) override;
private:
std::map<int64_t , size_t> m_count;
};
} // namespace Opm
#endif

View File

@@ -1,77 +0,0 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/OpmLog/EclipsePRTLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
void EclipsePRTLog::addMessageUnconditionally(int64_t messageType, const std::string& message)
{
StreamLog::addMessageUnconditionally(messageType, message);
m_count[messageType]++;
}
size_t EclipsePRTLog::numMessages(int64_t messageType) const
{
if (Log::isPower2( messageType )) {
auto iter = m_count.find( messageType );
if (iter == m_count.end())
return 0;
else
return (*iter).second;
} else
throw std::invalid_argument("The messageType ID must be 2^n");
}
EclipsePRTLog::~EclipsePRTLog()
{
if( ! print_summary_ )
{
return;
}
//output summary.
const std::string summary_msg = "\n\nError summary:" +
std::string("\nWarnings " + std::to_string(numMessages(Log::MessageType::Warning))) +
std::string("\nInfo " + std::to_string(numMessages(Log::MessageType::Info))) +
std::string("\nErrors " + std::to_string(numMessages(Log::MessageType::Error))) +
std::string("\nBugs " + std::to_string(numMessages(Log::MessageType::Bug))) +
std::string("\nDebug " + std::to_string(numMessages(Log::MessageType::Debug))) +
std::string("\nProblems " + std::to_string(numMessages(Log::MessageType::Problem))) +"\n";
StreamLog::addTaggedMessage(Log::MessageType::Info, "", summary_msg);
}
EclipsePRTLog::EclipsePRTLog(const std::string& logFile,
int64_t messageMask,
bool append,
bool print_summary)
: StreamLog(logFile, messageMask, append),
print_summary_(print_summary)
{}
EclipsePRTLog::EclipsePRTLog(std::ostream& os,
int64_t messageMask,
bool print_summary)
: StreamLog(os, messageMask), print_summary_(print_summary)
{}
}

View File

@@ -1,65 +0,0 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ECLIPSEPRTLOG_H
#define ECLIPSEPRTLOG_H
#include <map>
#include <string>
#include <opm/common/OpmLog/StreamLog.hpp>
namespace Opm {
class EclipsePRTLog : public StreamLog {
public:
using StreamLog::StreamLog;
size_t numMessages(int64_t messageType) const;
~EclipsePRTLog();
/// \brief Construct a logger to the <MODLE>.PRT file
/// \param logFile The name of the logfile to use.
/// \param messageMask ????
/// \param append If true then we append messages to the file.
/// Otherwise a new file is created.
/// \param print_summary If true print a summary to the PRT file.
EclipsePRTLog(const std::string& logFile , int64_t messageMask,
bool append, bool print_summary);
/// \brief Construct a logger to the <MODLE>.PRT file
/// \param logFile The name of the logfile to use.
/// \param messageMask ????
/// \param append If true then we append messages to the file.
/// Otherwise a new file is created.
/// \param print_summary If true print a summary to the PRT file.
EclipsePRTLog(std::ostream& os , int64_t messageMask,
bool print_summary);
protected:
void addMessageUnconditionally(int64_t messageType, const std::string& message) override;
private:
std::map<int64_t, size_t> m_count;
/// \brief Whether to print a summary to the log file.
bool print_summary_ = true;
};
}
#endif // ECLIPSEPRTLOG_H

View File

@@ -1,98 +0,0 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/OpmLog/LogBackend.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
LogBackend::LogBackend( int64_t mask ) :
m_mask(mask)
{
}
LogBackend::~LogBackend()
{
}
void LogBackend::setMessageFormatter(std::shared_ptr<MessageFormatterInterface> formatter)
{
m_formatter = formatter;
}
void LogBackend::setMessageLimiter(std::shared_ptr<MessageLimiter> limiter)
{
m_limiter = limiter;
}
void LogBackend::addMessage(int64_t messageFlag, const std::string& message)
{
// Forward the call to the tagged version.
addTaggedMessage(messageFlag, "", message);
}
void LogBackend::addTaggedMessage(int64_t messageType, const std::string& messageTag, const std::string& message) {
if (includeMessage( messageType, messageTag )) {
addMessageUnconditionally(messageType, message);
}
}
int64_t LogBackend::getMask() const
{
return m_mask;
}
bool LogBackend::includeMessage(int64_t messageFlag, const std::string& messageTag)
{
// Check mask.
const bool included = ((messageFlag & m_mask) == messageFlag) && (messageFlag > 0);
if (!included) {
return false;
}
// Use the message limiter (if any).
MessageLimiter::Response res = m_limiter
? m_limiter->handleMessageLimits(messageTag, messageFlag)
: MessageLimiter::Response::PrintMessage;
if (res == MessageLimiter::Response::JustOverTagLimit) {
// Special case: add a message to this backend about limit being reached.
std::string msg = "Message limit reached for message tag: " + messageTag;
addMessageUnconditionally(messageFlag, msg);
}
if (res == MessageLimiter::Response::JustOverCategoryLimit) {
// Special case: add a message to this backend about limit being reached.
std::string prefix = Log::prefixMessage(messageFlag, "");
std::string msg = "Message limit reached for message category: " + prefix.substr(0, prefix.size()-2);
addMessageUnconditionally(messageFlag, msg);
}
return res == MessageLimiter::Response::PrintMessage;
}
std::string LogBackend::formatMessage(int64_t messageFlag, const std::string& message)
{
if (m_formatter) {
return m_formatter->format(messageFlag, message);
} else {
return message;
}
}
}

View File

@@ -1,86 +0,0 @@
/*
Copyright 2015, 2016 Statoil ASA.
Copyright 2016 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_LOGBACKEND_HPP
#define OPM_LOGBACKEND_HPP
#include <opm/common/OpmLog/MessageFormatter.hpp>
#include <opm/common/OpmLog/MessageLimiter.hpp>
#include <cstdint>
#include <string>
#include <memory>
namespace Opm
{
/// Abstract interface class for log backends.
class LogBackend
{
public:
/// Construct with given message mask.
explicit LogBackend(int64_t mask);
/// Virtual destructor to enable inheritance.
virtual ~LogBackend();
/// Configure how formatMessage() will modify message strings.
void setMessageFormatter(std::shared_ptr<MessageFormatterInterface> formatter);
/// Configure how message tags will be used to limit messages.
void setMessageLimiter(std::shared_ptr<MessageLimiter> limiter);
/// Add a message to the backend if accepted by the message limiter.
void addMessage(int64_t messageFlag, const std::string& message);
/// Add a tagged message to the backend if accepted by the message limiter.
void addTaggedMessage(int64_t messageFlag,
const std::string& messageTag,
const std::string& message);
/// The message mask types are specified in the
/// Opm::Log::MessageType namespace, in file LogUtils.hpp.
int64_t getMask() const;
protected:
/// This is the method subclasses should override.
///
/// Typically a subclass may filter, change, and output
/// messages based on configuration and the messageFlag.
virtual void addMessageUnconditionally(int64_t messageFlag,
const std::string& message) = 0;
/// Return decorated version of message depending on configureDecoration() arguments.
std::string formatMessage(int64_t messageFlag, const std::string& message);
private:
/// Return true if all bits of messageFlag are also set in our mask,
/// and the message limiter returns a PrintMessage response.
bool includeMessage(int64_t messageFlag, const std::string& messageTag);
int64_t m_mask;
std::shared_ptr<MessageFormatterInterface> m_formatter;
std::shared_ptr<MessageLimiter> m_limiter;
};
} // namespace LogBackend
#endif

View File

@@ -1,99 +0,0 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sstream>
#include <stdexcept>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
namespace Log {
bool isPower2(int64_t x) {
return ((x != 0) && !(x & (x - 1)));
}
std::string fileMessage(const std::string& filename , int line , const std::string& message) {
std::ostringstream oss;
oss << message << "\n" << "In file " << filename << ", line " << line << "\n";
return oss.str();
}
std::string fileMessage(int64_t messageType , const std::string& filename , int line , const std::string& message) {
return fileMessage( filename , line , prefixMessage( messageType , message ));
}
std::string prefixMessage(int64_t messageType, const std::string& message) {
std::string prefix;
switch (messageType) {
case MessageType::Debug:
prefix = "Debug";
break;
case MessageType::Note:
prefix = "Note";
break;
case MessageType::Info:
prefix = "Info";
break;
case MessageType::Warning:
prefix = "\nWarning";
break;
case MessageType::Error:
prefix = "\nError";
break;
case MessageType::Problem:
prefix = "\nProblem";
break;
case MessageType::Bug:
prefix = "\nBug";
break;
default:
throw std::invalid_argument("Unhandled messagetype");
}
return prefix + ": " + message;
}
std::string colorCodeMessage(int64_t messageType, const std::string& message) {
switch (messageType) {
case MessageType::Debug:
case MessageType::Note:
case MessageType::Info:
return message; // No color coding, not even the code for default color.
case MessageType::Warning:
return AnsiTerminalColors::blue_strong + message + AnsiTerminalColors::none;
case MessageType::Problem:
return AnsiTerminalColors::magenta_strong + message + AnsiTerminalColors::none;
case MessageType::Error:
case MessageType::Bug:
return AnsiTerminalColors::red_strong + message + AnsiTerminalColors::none;
default:
throw std::invalid_argument("Unhandled messagetype");
}
}
}
}

View File

@@ -1,67 +0,0 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_LOG_UTIL_HPP
#define OPM_LOG_UTIL_HPP
#include <cstdint>
#include <string>
namespace Opm {
namespace Log {
namespace MessageType {
const int64_t Debug = 1; /* Excessive information */
const int64_t Note = 2; /* Information that should only go into print file.*/
const int64_t Info = 4; /* Normal status information */
const int64_t Warning = 8; /* Input anomaly - possible error */
const int64_t Error = 16; /* Error in the input data - should probably exit. */
const int64_t Problem = 32; /* Calculation problems - e.g. convergence failure. */
const int64_t Bug = 64; /* An inconsistent state has been encountered in the simulator - should probably exit. */
}
const int64_t DefaultMessageTypes = MessageType::Debug + MessageType::Note + MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
const int64_t NoDebugMessageTypes = MessageType::Info + MessageType::Note + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
const int64_t StdoutMessageTypes = MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
/// Terminal codes for ANSI/vt100 compatible terminals.
/// See for example http://ascii-table.com/ansi-escape-sequences.php
namespace AnsiTerminalColors {
const std::string none = "\033[0m";
const std::string red = "\033[31m";
const std::string red_strong = "\033[31;1m";
const std::string yellow = "\033[33m";
const std::string yellow_strong = "\033[33;1m";
const std::string blue = "\033[34m";
const std::string blue_strong = "\033[34;1m";
const std::string magenta = "\033[35m";
const std::string magenta_strong = "\033[35;1m";
const std::string default_color = "\033[39m";
}
bool isPower2(int64_t x);
std::string fileMessage(const std::string& path, int line , const std::string& msg);
std::string fileMessage(int64_t messageType , const std::string& path, int line , const std::string& msg);
std::string prefixMessage(int64_t messageType , const std::string& msg);
std::string colorCodeMessage(int64_t messageType , const std::string& msg);
}
}
#endif

View File

@@ -1,124 +0,0 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sstream>
#include <stdexcept>
#include <iostream>
#include <opm/common/OpmLog/LogBackend.hpp>
#include <opm/common/OpmLog/Logger.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
Logger::Logger()
: m_globalMask(0),
m_enabledTypes(0)
{
addMessageType( Log::MessageType::Debug , "debug");
addMessageType( Log::MessageType::Info , "info");
addMessageType( Log::MessageType::Warning , "warning");
addMessageType( Log::MessageType::Error , "error");
addMessageType( Log::MessageType::Problem , "problem");
addMessageType( Log::MessageType::Bug , "bug");
addMessageType( Log::MessageType::Note , "note");
}
void Logger::addTaggedMessage(int64_t messageType, const std::string& tag, const std::string& message) const {
if ((m_enabledTypes & messageType) == 0)
throw std::invalid_argument("Tried to issue message with unrecognized message ID");
if (m_globalMask & messageType) {
for (auto iter : m_backends) {
LogBackend& backend = *(iter.second);
backend.addTaggedMessage( messageType, tag, message );
}
}
}
void Logger::addMessage(int64_t messageType , const std::string& message) const {
addTaggedMessage(messageType, "", message);
}
void Logger::updateGlobalMask( int64_t mask ) {
m_globalMask |= mask;
}
bool Logger::hasBackend(const std::string& name) {
if (m_backends.find( name ) == m_backends.end())
return false;
else
return true;
}
void Logger::removeAllBackends() {
m_backends.clear();
m_globalMask = 0;
}
bool Logger::removeBackend(const std::string& name) {
size_t eraseCount = m_backends.erase( name );
if (eraseCount == 1)
return true;
else
return false;
}
void Logger::addBackend(const std::string& name , std::shared_ptr<LogBackend> backend) {
updateGlobalMask( backend->getMask() );
m_backends[ name ] = backend;
}
int64_t Logger::enabledMessageTypes() const {
return m_enabledTypes;
}
//static:
bool Logger::enabledMessageType( int64_t enabledTypes , int64_t messageType) {
if (Log::isPower2( messageType)) {
if ((messageType & enabledTypes) == 0)
return false;
else
return true;
} else
throw std::invalid_argument("The message type id must be ~ 2^n");
}
//static:
bool Logger::enabledDefaultMessageType( int64_t messageType) {
return enabledMessageType( Log::DefaultMessageTypes , messageType );
}
bool Logger::enabledMessageType( int64_t messageType) const {
return enabledMessageType( m_enabledTypes , messageType );
}
void Logger::addMessageType( int64_t messageType , const std::string& /* prefix */) {
if (Log::isPower2( messageType)) {
m_enabledTypes |= messageType;
} else
throw std::invalid_argument("The message type id must be ~ 2^n");
}
}

View File

@@ -1,82 +0,0 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_LOGGER_HPP
#define OPM_LOGGER_HPP
#include <stdexcept>
#include <cstdint>
#include <map>
#include <memory>
#include <string>
namespace Opm {
class LogBackend;
class Logger {
public:
Logger();
void addMessage(int64_t messageType , const std::string& message) const;
void addTaggedMessage(int64_t messageType, const std::string& tag, const std::string& message) const;
static bool enabledDefaultMessageType( int64_t messageType);
bool enabledMessageType( int64_t messageType) const;
void addMessageType( int64_t messageType , const std::string& prefix);
int64_t enabledMessageTypes() const;
void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);
bool hasBackend(const std::string& name);
bool removeBackend(const std::string& name);
void removeAllBackends();
template <class BackendType>
std::shared_ptr<BackendType> getBackend(const std::string& name) const {
auto pair = m_backends.find( name );
if (pair == m_backends.end())
throw std::invalid_argument("Invalid backend name: " + name);
else
return std::static_pointer_cast<BackendType>(m_backends.find(name)->second);
}
template <class BackendType>
std::shared_ptr<BackendType> popBackend(const std::string& name) {
auto pair = m_backends.find( name );
if (pair == m_backends.end())
throw std::invalid_argument("Invalid backend name: " + name);
else {
std::shared_ptr<LogBackend> backend = (*pair).second;
removeBackend( name );
return std::static_pointer_cast<BackendType>(backend);
}
}
private:
void updateGlobalMask( int64_t mask );
static bool enabledMessageType( int64_t enabledTypes , int64_t messageType);
int64_t m_globalMask;
int64_t m_enabledTypes;
std::map<std::string , std::shared_ptr<LogBackend> > m_backends;
};
}
#endif

View File

@@ -1,95 +0,0 @@
/*
Copyright 2016 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_MESSAGEFORMATTER_HEADER_INCLUDED
#define OPM_MESSAGEFORMATTER_HEADER_INCLUDED
#include <opm/common/OpmLog/LogUtil.hpp>
#include <string>
namespace Opm
{
/// Abstract interface for message formatting classes.
class MessageFormatterInterface
{
public:
/// Virtual destructor to enable inheritance.
virtual ~MessageFormatterInterface() = default;
/// Should return a possibly modified/decorated version of the
/// input string, the formatting applied depending on the
/// message_flag.
virtual std::string format(const int64_t message_flag, const std::string& message) = 0;
};
/// A simple formatter capable of adding message prefixes and colors.
class SimpleMessageFormatter : public MessageFormatterInterface
{
public:
/// Constructor controlling formatting to be applied.
SimpleMessageFormatter(const bool use_prefix, const bool use_color_coding)
: use_color_coding_(use_color_coding)
{
if (use_prefix) {
prefix_flag_ = Log::DefaultMessageTypes;
}
}
SimpleMessageFormatter(const int64_t prefix_flag, const bool use_color_coding)
: use_color_coding_(use_color_coding),
prefix_flag_(prefix_flag)
{
}
explicit SimpleMessageFormatter(const bool use_color_coding)
: use_color_coding_(use_color_coding)
{
prefix_flag_ = Log::MessageType::Warning + Log::MessageType::Error
+ Log::MessageType::Problem + Log::MessageType::Bug;
}
/// Returns a copy of the input string with a flag-dependant
/// prefix (if use_prefix) and the entire message in a
/// flag-dependent color (if use_color_coding).
virtual std::string format(const int64_t message_flag, const std::string& message) override
{
std::string msg = message;
if (message_flag & prefix_flag_) {
msg = Log::prefixMessage(message_flag, msg);
}
if (use_color_coding_) {
msg = Log::colorCodeMessage(message_flag, msg);
}
return msg;
}
private:
bool use_color_coding_ = false;
int64_t prefix_flag_ = 0;
};
} // namespace Opm
#endif // OPM_MESSAGEFORMATTER_HEADER_INCLUDED

View File

@@ -1,187 +0,0 @@
/*
Copyright 2016 SINTEF ICT, Applied Mathematics.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_MESSAGELIMITER_HEADER_INCLUDED
#define OPM_MESSAGELIMITER_HEADER_INCLUDED
#include <opm/common/OpmLog/LogUtil.hpp>
#include <cassert>
#include <map>
#include <string>
#include <unordered_map>
#include <vector>
namespace Opm
{
/// Handles limiting the number of messages with the same tag.
class MessageLimiter
{
public:
/// Used to indicate no message number limit.
enum { NoLimit = -1 };
/// Default constructor, no limit to the number of messages.
MessageLimiter()
: MessageLimiter(NoLimit)
{
}
/// Construct with given limit to number of messages with the
/// same tag.
///
/// Negative limits (including NoLimit) are interpreted as
/// NoLimit, but the default constructor is the preferred way
/// to obtain that behaviour.
explicit MessageLimiter(const int tag_limit)
: tag_limit_(tag_limit < 0 ? NoLimit : tag_limit),
category_limits_({{Log::MessageType::Note, NoLimit},
{Log::MessageType::Info, NoLimit},
{Log::MessageType::Warning, NoLimit},
{Log::MessageType::Error, NoLimit},
{Log::MessageType::Problem, NoLimit},
{Log::MessageType::Bug, NoLimit}})
{
}
MessageLimiter(const int tag_limit, const std::map<int64_t, int>& category_limits)
: tag_limit_(tag_limit < 0 ? NoLimit : tag_limit),
category_limits_(category_limits)
{
// Must ensure NoLimit for categories that are not
// explicitly specified in the input.
for (auto category : { Log::MessageType::Note,
Log::MessageType::Info,
Log::MessageType::Warning,
Log::MessageType::Error,
Log::MessageType::Problem,
Log::MessageType::Bug }) {
if (category_limits_.find(category) == category_limits_.end()) {
category_limits_[category] = NoLimit;
}
}
}
/// The tag message limit (same for all tags).
int tagMessageLimit() const
{
return tag_limit_;
}
/// The category message limits.
const std::map<int64_t, int>& categoryMessageLimits() const
{
return category_limits_;
}
/// The category message counts.
const std::map<int64_t, int>& categoryMessageCounts() const
{
return category_counts_;
}
/// Used for handleMessageLimits() return type (see that
/// function).
enum class Response
{
PrintMessage, JustOverTagLimit, JustOverCategoryLimit, OverTagLimit, OverCategoryLimit
};
/// If (tag count == tag limit + 1) for the passed tag, respond JustOverTagLimit.
/// If (tag count > tag limit + 1), respond OverTagLimit.
/// If a tag is empty, there is no tag message limit or for that tag
/// (tag count <= tag limit), consider the category limits:
/// If (category count == category limit + 1) for the passed messageMask, respond JustOverCategoryLimit.
/// If (category count > category limit + 1), respond OverCategoryLimit.
/// If (category count <= category limit), or there is no limit for that category, respond PrintMessage.
Response handleMessageLimits(const std::string& tag, const int64_t messageMask)
{
Response res = Response::PrintMessage;
// Deal with tag limits.
if (!tag.empty() && tag_limit_ != NoLimit) {
// See if tag already encountered.
auto it = tag_counts_.find(tag);
if (it != tag_counts_.end()) {
// Already encountered this tag. Increment its count.
const int count = ++it->second;
res = countBasedResponseTag(count);
} else {
// First encounter of this tag. Insert 1.
tag_counts_.insert({tag, 1});
res = countBasedResponseTag(1);
}
}
// If tag count reached the limit, the message is not counted
// towards the category limits.
if (res == Response::PrintMessage) {
// We are *not* above the tag limit, consider category limit.
const int count = ++category_counts_[messageMask];
if (category_limits_[messageMask] != NoLimit) {
res = countBasedResponseCategory(count, messageMask);
}
}
return res;
}
private:
Response countBasedResponseTag(const int count) const
{
if (count <= tag_limit_) {
return Response::PrintMessage;
} else if (count == tag_limit_ + 1) {
return Response::JustOverTagLimit;
} else {
return Response::OverTagLimit;
}
}
Response countBasedResponseCategory(const int count, const int64_t messageMask) const
{
const int limit = category_limits_.at(messageMask);
if (count <= limit) {
return Response::PrintMessage;
} else if (count == limit + 1) {
return Response::JustOverCategoryLimit;
} else {
return Response::OverCategoryLimit;
}
}
int tag_limit_;
std::unordered_map<std::string, int> tag_counts_;
std::map<int64_t, int> category_limits_;
std::map<int64_t, int> category_counts_ = {{Log::MessageType::Note, 0},
{Log::MessageType::Info, 0},
{Log::MessageType::Warning, 0},
{Log::MessageType::Error, 0},
{Log::MessageType::Problem, 0},
{Log::MessageType::Bug, 0}};
};
} // namespace Opm
#endif // OPM_MESSAGELIMITER_HEADER_INCLUDED

View File

@@ -1,209 +0,0 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/Logger.hpp>
#include <opm/common/OpmLog/StreamLog.hpp>
#include <iostream>
#include <errno.h> // For errno
#include <stdio.h> // For fileno() and stdout
#include <unistd.h> // For isatty()
namespace Opm {
namespace {
bool stdoutIsTerminal()
{
const int errno_save = errno; // For playing nice with C error handling.
const int file_descriptor = fileno(stdout);
if (file_descriptor == -1) {
// stdout is an invalid stream
errno = errno_save;
return false;
} else {
return isatty(file_descriptor);
}
}
}
std::shared_ptr<Logger> OpmLog::getLogger() {
if (!m_logger)
m_logger.reset( new Logger() );
return m_logger;
}
void OpmLog::addMessage(int64_t messageFlag , const std::string& message) {
if (m_logger)
m_logger->addMessage( messageFlag , message );
}
void OpmLog::addTaggedMessage(int64_t messageFlag, const std::string& tag, const std::string& message) {
if (m_logger)
m_logger->addTaggedMessage( messageFlag, tag, message );
}
void OpmLog::info(const std::string& message)
{
addMessage(Log::MessageType::Info, message);
}
void OpmLog::warning(const std::string& message)
{
addMessage(Log::MessageType::Warning, message);
}
void OpmLog::problem(const std::string& message)
{
addMessage(Log::MessageType::Problem, message);
}
void OpmLog::error(const std::string& message)
{
addMessage(Log::MessageType::Error, message);
}
void OpmLog::bug(const std::string& message)
{
addMessage(Log::MessageType::Bug, message);
}
void OpmLog::debug(const std::string& message)
{
addMessage(Log::MessageType::Debug, message);
}
void OpmLog::note(const std::string& message)
{
addMessage(Log::MessageType::Note, message);
}
void OpmLog::info(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Info, tag, message);
}
void OpmLog::warning(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Warning, tag, message);
}
void OpmLog::problem(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Problem, tag, message);
}
void OpmLog::error(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Error, tag, message);
}
void OpmLog::bug(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Bug, tag, message);
}
void OpmLog::debug(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Debug, tag, message);
}
void OpmLog::note(const std::string& tag, const std::string& message)
{
addTaggedMessage(Log::MessageType::Note, tag, message);
}
bool OpmLog::enabledMessageType( int64_t messageType ) {
if (m_logger)
return m_logger->enabledMessageType( messageType );
else
return Logger::enabledDefaultMessageType( messageType );
}
bool OpmLog::hasBackend(const std::string& name) {
if (m_logger)
return m_logger->hasBackend( name );
else
return false;
}
bool OpmLog::removeBackend(const std::string& name) {
if (m_logger)
return m_logger->removeBackend( name );
else
return false;
}
void OpmLog::removeAllBackends() {
if (m_logger) {
m_logger->removeAllBackends();
}
}
void OpmLog::addMessageType( int64_t messageType , const std::string& prefix) {
auto logger = OpmLog::getLogger();
logger->addMessageType( messageType , prefix );
}
void OpmLog::addBackend(const std::string& name , std::shared_ptr<LogBackend> backend) {
auto logger = OpmLog::getLogger();
return logger->addBackend( name , backend );
}
void OpmLog::setupSimpleDefaultLogging(const bool use_prefix,
const bool use_color_coding,
const int message_limit)
{
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(std::cout, Log::DefaultMessageTypes);
OpmLog::addBackend( "SimpleDefaultLog", streamLog);
streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(message_limit));
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(use_prefix, use_color_coding && stdoutIsTerminal()));
}
/******************************************************************/
std::shared_ptr<Logger> OpmLog::m_logger;
}

View File

@@ -1,102 +0,0 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPMLOG_HPP
#define OPMLOG_HPP
#include <memory>
#include <cstdint>
#include <opm/common/OpmLog/Logger.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
namespace Opm {
class LogBackend;
/*
The OpmLog class is a fully static class which manages a proper
Logger instance.
*/
class OpmLog {
public:
static void addMessage(int64_t messageFlag , const std::string& message);
static void addTaggedMessage(int64_t messageFlag, const std::string& tag, const std::string& message);
static void info(const std::string& message);
static void warning(const std::string& message);
static void error(const std::string& message);
static void problem(const std::string& message);
static void bug(const std::string& message);
static void debug(const std::string& message);
static void note(const std::string& message);
static void info(const std::string& tag, const std::string& message);
static void warning(const std::string& tag, const std::string& message);
static void error(const std::string& tag, const std::string& message);
static void problem(const std::string& tag, const std::string& message);
static void bug(const std::string& tag, const std::string& message);
static void debug(const std::string& tag, const std::string& message);
static void note(const std::string& tag, const std::string& message);
static bool hasBackend( const std::string& backendName );
static void addBackend(const std::string& name , std::shared_ptr<LogBackend> backend);
static bool removeBackend(const std::string& name);
static void removeAllBackends();
static bool enabledMessageType( int64_t messageType );
static void addMessageType( int64_t messageType , const std::string& prefix);
/// Create a basic logging setup that will send all log messages to standard output.
///
/// By default category prefixes will be printed (i.e. Error: or
/// Warning:), color coding will be used, and a maximum of 10
/// messages with the same tag will be printed. These settings can
/// be controlled by the function parameters.
static void setupSimpleDefaultLogging(const bool use_prefix = true,
const bool use_color_coding = true,
const int message_limit = 10);
template <class BackendType>
static std::shared_ptr<BackendType> getBackend(const std::string& name) {
auto logger = getLogger();
return logger->getBackend<BackendType>(name);
}
template <class BackendType>
static std::shared_ptr<BackendType> popBackend(const std::string& name) {
auto logger = getLogger();
return logger->popBackend<BackendType>(name);
}
private:
static std::shared_ptr<Logger> getLogger();
static std::shared_ptr<Logger> m_logger;
};
}
#endif

View File

@@ -1,64 +0,0 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <opm/common/OpmLog/StreamLog.hpp>
namespace Opm {
StreamLog::StreamLog(const std::string& logFile , int64_t messageMask, bool append) : LogBackend(messageMask)
{
if (append) {
m_ofstream.open( logFile.c_str() , std::ofstream::app );
} else {
m_ofstream.open( logFile.c_str() , std::ofstream::out );
}
m_streamOwner = true;
m_ostream = &m_ofstream;
}
StreamLog::StreamLog(std::ostream& os , int64_t messageMask) : LogBackend(messageMask)
{
m_ostream = &os;
m_streamOwner = false;
}
void StreamLog::close() {
if (m_streamOwner && m_ofstream.is_open()) {
m_ofstream.close();
m_ostream = NULL;
}
}
void StreamLog::addMessageUnconditionally(int64_t messageType, const std::string& message)
{
(*m_ostream) << formatMessage(messageType, message) << std::endl;
if (m_ofstream.is_open()) {
m_ofstream.flush();
}
}
StreamLog::~StreamLog() {
close();
}
} // namespace Opm

View File

@@ -1,50 +0,0 @@
/*
Copyright 2015 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STREAMLOG_H
#define STREAMLOG_H
#include <fstream>
#include <iostream>
#include <cstdint>
#include <opm/common/OpmLog/LogBackend.hpp>
namespace Opm {
class StreamLog : public LogBackend {
public:
StreamLog(const std::string& logFile , int64_t messageMask, bool append = false);
StreamLog(std::ostream& os , int64_t messageMask);
~StreamLog();
protected:
virtual void addMessageUnconditionally(int64_t messageType, const std::string& message) override;
private:
void close();
std::ofstream m_ofstream;
std::ostream * m_ostream;
bool m_streamOwner;
};
}
#endif

View File

@@ -1,62 +0,0 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdexcept>
#include <cassert>
#include <iomanip>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/LogUtil.hpp>
#include <opm/common/OpmLog/TimerLog.hpp>
#include <opm/common/OpmLog/StreamLog.hpp>
namespace Opm {
TimerLog::TimerLog(const std::string& logFile) : StreamLog( logFile , StopTimer | StartTimer )
{
m_work.precision(8);
m_start = 0;
}
TimerLog::TimerLog(std::ostream& os) : StreamLog( os , StopTimer | StartTimer )
{
m_work.precision(8);
m_start = 0;
}
void TimerLog::addMessageUnconditionally(int64_t messageType, const std::string& msg ) {
if (messageType == StopTimer) {
clock_t stop = clock();
double secondsElapsed = 1.0 * (m_start - stop) / CLOCKS_PER_SEC ;
m_work.str("");
m_work << std::fixed << msg << ": " << secondsElapsed << " seconds ";
StreamLog::addMessageUnconditionally( messageType, m_work.str());
} else {
if (messageType == StartTimer)
m_start = clock();
}
}
} // namespace Opm

View File

@@ -1,61 +0,0 @@
/*
Copyright 2014 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_TIMERLOG_HPP
#define OPM_TIMERLOG_HPP
#include <time.h>
#include <memory>
#include <sstream>
#include <string>
#include <opm/common/OpmLog/StreamLog.hpp>
/*
This class is a simple demonstration of how the logging framework
can be used to create a simple very special case logging facility.
*/
namespace Opm {
class TimerLog : public StreamLog {
public:
static const int64_t StartTimer = 4096;
static const int64_t StopTimer = 8192;
explicit TimerLog(const std::string& logFile);
explicit TimerLog(std::ostream& os);
void clear();
~TimerLog() {};
protected:
void addMessageUnconditionally(int64_t messageFlag,
const std::string& message) override;
private:
clock_t m_start;
std::ostringstream m_work;
};
typedef std::shared_ptr<TimerLog> TimerLogPtr;
typedef std::shared_ptr<const TimerLog> TimerLogConstPtr;
} // namespace Opm
#endif

View File

@@ -1,62 +0,0 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file
* \brief Provides a free function to reset the localization settings
*
* Under some circumstances, some environments seem to set a locale which they do not
* install. In turn this leads to std::runtime_errror being thrown by some parts of Boost
* (for some versions) which causes unsolicited program aborts.
*
* This issue asside, it looks pretty weird if the e.g. the number format is inconsistent
* with the language used by rest of the simulation.
*/
#ifndef OPM_RESET_LOCALE_HH
#define OPM_RESET_LOCALE_HH
#include <stdlib.h>
namespace Opm {
inline void resetLocale()
{
#ifndef WIN32
// this probably only works for POSIX compatible operating systems. for all others,
// unsetting a few environment variables should not hurt, though.
unsetenv("LC_ALL");
unsetenv("LANG");
unsetenv("LANGUAGE");
unsetenv("LC_ADDRESS");
unsetenv("LC_COLLATE");
unsetenv("LC_CTYPE");
unsetenv("LC_IDENTIFICATION");
unsetenv("LC_MEASUREMENT");
unsetenv("LC_MESSAGES");
unsetenv("LC_MONETARY");
unsetenv("LC_NAME");
unsetenv("LC_NUMERIC");
unsetenv("LC_PAPER");
unsetenv("LC_TELEPHONE");
unsetenv("LC_TIME");
#endif // !WIN32
}
} // namespace Opm
#endif

View File

@@ -1,43 +0,0 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file
* \brief Provides the OPM_UNUSED macro
*
* This macro can be used to mark variables as "potentially unused" which suppresses some
* bogus compiler warnings. If the compiler does not support this, the macro is a no-op.
*/
#ifndef OPM_UNUSED_HH
#define OPM_UNUSED_HH
#ifndef HAS_ATTRIBUTE_UNUSED
#define OPM_UNUSED
#else
#define OPM_UNUSED __attribute__((unused))
#endif
#ifdef NDEBUG
#define OPM_DEBUG_UNUSED
#define OPM_OPTIM_UNUSED OPM_UNUSED
#else
#define OPM_DEBUG_UNUSED OPM_UNUSED
#define OPM_OPTIM_UNUSED
#endif
#endif

View File

@@ -1,311 +0,0 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
/*!
* \file
* \brief Some templates to wrap the valgrind client request macros
*/
#ifndef OPM_VALGRIND_HPP
#define OPM_VALGRIND_HPP
#include <opm/common/Unused.hpp>
#if HAVE_VALGRIND
#include <valgrind/memcheck.h>
#endif
#if HAVE_VALGRIND
#define OPM_VALGRIND_OPTIM_UNUSED OPM_OPTIM_UNUSED
#else
#define OPM_VALGRIND_OPTIM_UNUSED OPM_UNUSED
#endif
namespace Opm {
namespace Valgrind {
/*!
* \ingroup Valgrind
* \brief Returns whether the program is running under Valgrind or not.
*/
inline bool IsRunning()
{
#if !defined NDEBUG && HAVE_VALGRIND
return RUNNING_ON_VALGRIND;
#else
return false;
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if any of the memory occupied by an object
* is undefined.
*
* Please note that this does not check whether the destinations of an
* object's pointers or references are defined. Also, for performance
* reasons the compiler might insert "padding bytes" between within
* the objects which leads to false positives.
*
* Example:
*
* \code
* int i;
* Valgrind::CheckDefined(i); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be checked
*
* \param value the object which valgrind should check
*
* \return true iff there are no undefined bytes in the memory
* occupied by the object.
*/
template <class T>
inline bool CheckDefined(const T& value OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto tmp = VALGRIND_CHECK_MEM_IS_DEFINED(&value, sizeof(T));
return tmp == 0;
#else
return true;
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if any of the memory occupied by an object
* is not addressable.
*
* Example:
*
* \code
* int* i = NULL;
* Valgrind::CheckAddressable(*i); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be checked
*
* \param value the object which valgrind should check
*
* \return true iff there are no unadressable bytes in the memory
* occupied by the object.
*/
template <class T>
inline bool CheckAddressable(const T& value OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto tmp = VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&value, sizeof(T));
return tmp == 0;
#else
return true;
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if any of the the memory occupied
* by a C-style array objects is undefined.
*
* Please note that this does not check whether the destinations of an
* object's pointers or references are defined. Also, for performance
* reasons the compiler might insert "padding bytes" between within
* the objects which leads to false positives.
*
* Example:
*
* \code
* int i[2];
* Valgrind::CheckDefined(i, 2); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be checked
*
* \param value Pointer to the first object of the array.
* \param size The size of the array in number of objects
*
* \return true iff there are no undefined bytes in the memory
* occupied by the array.
*/
template <class T>
inline bool CheckDefined(const T* value OPM_VALGRIND_OPTIM_UNUSED, int size OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto tmp = VALGRIND_CHECK_MEM_IS_DEFINED(value, size*sizeof(T));
return tmp == 0;
#else
return true;
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which an object resides undefined in
* valgrind runs.
*
* Example:
*
* \code
* int i = 0;
* Valgrind::SetUndefined(i);
* Valgrind::CheckDefined(i); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be set to undefined
*
* \param value The object which's memory valgrind should be told is undefined
*/
template <class T>
inline void SetUndefined(const T &value OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
VALGRIND_MAKE_MEM_UNDEFINED(&value, sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which an array of object resides
* undefined in valgrind runs.
*
* Example:
*
* \code
* int i[3] = {0, 1, 3};
* Valgrind::SetUndefined(&i[1], 2);
* Valgrind::CheckDefined(i, 3); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be set to undefined
*
* \param value Pointer to the first object of the array.
* \param size The size of the array in number of objects
*/
template <class T>
inline void SetUndefined(const T* value OPM_VALGRIND_OPTIM_UNUSED, int size OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
VALGRIND_MAKE_MEM_UNDEFINED(value, size*sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which an object resides defined.
*
* Example:
*
* \code
* int i;
* Valgrind::SetDefined(i);
* Valgrind::CheckDefined(i); // Valgrind does not complain!
* \endcode
*
* \tparam T The type of the object which valgrind should consider as defined
*
* \param value The object which's memory valgrind should consider as defined
*/
template <class T>
inline void SetDefined(const T& value OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
VALGRIND_MAKE_MEM_DEFINED(&value, sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which a C-style array of objects resides
* defined.
*
* Example:
*
* \code
* int i[3];
* Valgrind::SetDefined(i, 3);
* Valgrind::CheckDefined(i, 3); // Valgrind does not complain!
* \endcode
*
* \tparam T The type of the object which valgrind should consider as defined
*
* \param value Pointer to the first object of the array.
* \param n The size of the array in number of objects
*/
template <class T>
inline void SetDefined(const T *value OPM_VALGRIND_OPTIM_UNUSED, int n OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
VALGRIND_MAKE_MEM_DEFINED(value, n*sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if an object's memory is accessed.
*
* Example:
*
* \code
* int i = 1;
* Valgrind::SetNoAccess(i);
* int j = i; // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which valgrind should complain if accessed
*
* \param value The object which's memory valgrind should complain if accessed
*/
template <class T>
inline void SetNoAccess(const T &value OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
VALGRIND_MAKE_MEM_NOACCESS(&value, sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if the memory of a C-style array of
* objects is accessed.
*
* Example:
*
* \code
* int i[3] = {0, 1, 2};
* Valgrind::SetNoAccess(i, 2);
* int j = i[1]; // Valgrind complains!
* \endcode
*
* \param value Pointer to the first object of the array.
* \param size The size of the array in number of objects
*/
template <class T>
inline void SetNoAccess(const T *value OPM_VALGRIND_OPTIM_UNUSED, int size OPM_VALGRIND_OPTIM_UNUSED)
{
#if !defined NDEBUG && HAVE_VALGRIND
VALGRIND_MAKE_MEM_NOACCESS(value, size*sizeof(T));
#endif
}
}} // namespace Valgrind, Opm
#endif

View File

@@ -1,247 +0,0 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/util/numeric/cmp.hpp>
#include <opm/common/data/SimulationDataContainer.hpp>
namespace Opm {
SimulationDataContainer::SimulationDataContainer(size_t num_cells, size_t num_faces , size_t num_phases) :
m_num_cells( num_cells ),
m_num_faces( num_faces ),
m_num_phases( num_phases )
{
addDefaultFields( );
}
SimulationDataContainer::SimulationDataContainer(const SimulationDataContainer& other)
: m_num_cells(other.m_num_cells),
m_num_faces(other.m_num_faces),
m_num_phases(other.m_num_phases),
m_cell_data(other.m_cell_data),
m_face_data(other.m_face_data)
{
setReferencePointers();
}
SimulationDataContainer& SimulationDataContainer::operator=(const SimulationDataContainer& other)
{
SimulationDataContainer copy(other);
copy.swap(*this);
return *this;
}
void SimulationDataContainer::swap(SimulationDataContainer& other)
{
using std::swap;
swap(m_num_cells, other.m_num_cells);
swap(m_num_faces, other.m_num_faces);
swap(m_num_phases, other.m_num_phases);
swap(m_cell_data, other.m_cell_data);
swap(m_face_data, other.m_face_data);
setReferencePointers();
other.setReferencePointers();
}
size_t SimulationDataContainer::numPhases() const {
return m_num_phases;
}
size_t SimulationDataContainer::numFaces() const {
return m_num_faces;
}
size_t SimulationDataContainer::numCells() const {
return m_num_cells;
}
bool SimulationDataContainer::hasCellData( const std::string& name ) const {
return ( m_cell_data.find( name ) == m_cell_data.end() ? false : true );
}
std::vector<double>& SimulationDataContainer::getCellData( const std::string& name ) {
auto iter = m_cell_data.find( name );
if (iter == m_cell_data.end()) {
throw std::invalid_argument("The cell data with name: " + name + " does not exist");
} else
return iter->second;
}
const std::vector<double>& SimulationDataContainer::getCellData( const std::string& name ) const {
auto iter = m_cell_data.find( name );
if (iter == m_cell_data.end()) {
throw std::invalid_argument("The cell data with name: " + name + " does not exist");
} else
return iter->second;
}
void SimulationDataContainer::registerCellData( const std::string& name , size_t components , double initialValue) {
if (!hasCellData( name )) {
m_cell_data.insert( std::pair<std::string , std::vector<double>>( name , std::vector<double>(components * m_num_cells , initialValue )));
}
}
void SimulationDataContainer::setCellDataComponent( const std::string& key ,
size_t component ,
const std::vector<int>& cells ,
const std::vector<double>& values) {
auto& data = getCellData( key );
if (component >= m_num_phases)
OPM_THROW(std::invalid_argument, "The component number: " << component << " is invalid");
if (cells.size() != values.size())
OPM_THROW(std::invalid_argument, "size mismatch between cells and values");
// This is currently quite broken; the setCellDataComponent
// method assumes that the number of components in the field
// we are currently focusing on has num_phases components in
// total. This restriction should be lifted by allowing a per
// field number of components.
if (data.size() != m_num_phases * m_num_cells)
OPM_THROW(std::invalid_argument , "Can currently only be used on fields with num_components == num_phases (i.e. saturation...) ");
for (size_t i = 0; i < cells.size(); i++) {
if (size_t(cells[i]) < m_num_cells) {
auto field_index = cells[i] * m_num_phases + component;
data[field_index] = values[i];
} else {
OPM_THROW(std::invalid_argument , "The cell number: " << cells[i] << " is invalid.");
}
}
}
bool SimulationDataContainer::hasFaceData( const std::string& name ) const {
return ( m_face_data.find( name ) == m_face_data.end() ? false : true );
}
std::vector<double>& SimulationDataContainer::getFaceData( const std::string& name ) {
auto iter = m_face_data.find( name );
if (iter == m_face_data.end()) {
throw std::invalid_argument("The face data with name: " + name + " does not exist");
} else
return iter->second;
}
const std::vector<double>& SimulationDataContainer::getFaceData( const std::string& name ) const {
auto iter = m_face_data.find( name );
if (iter == m_face_data.end()) {
throw std::invalid_argument("The Face data with name: " + name + " does not exist");
} else
return iter->second;
}
void SimulationDataContainer::registerFaceData( const std::string& name , size_t components , double initialValue) {
if (!hasFaceData( name )) {
m_face_data.insert( std::pair<std::string , std::vector<double>>( name , std::vector<double>(components * m_num_faces , initialValue )));
}
}
bool SimulationDataContainer::equal( const SimulationDataContainer& other ) const {
if ((m_num_cells != other.m_num_cells) ||
(m_num_phases != other.m_num_phases) ||
(m_num_faces != other.m_num_faces))
return false;
if ((m_face_data.size() != other.m_face_data.size()) ||
(m_cell_data.size() != other.m_cell_data.size()))
return false;
for (const auto& cell_data : m_cell_data) {
const auto key = cell_data.first;
const auto data = cell_data.second;
if (other.hasCellData( key )) {
const auto& other_data = other.getCellData( key );
if (!cmp::vector_equal<double>( data , other_data ))
return false;
} else
return false;
}
for (const auto& face_data : m_face_data) {
const auto key = face_data.first;
const auto data = face_data.second;
if (other.hasFaceData( key )) {
const auto& other_data = other.getFaceData( key );
if (!cmp::vector_equal<double>( data , other_data ))
return false;
} else
return false;
}
return true;
}
size_t SimulationDataContainer::numCellDataComponents( const std::string& name ) const {
const auto& data = getCellData( name );
return data.size() / m_num_cells;
}
const std::map<std::string, std::vector<double>>& SimulationDataContainer::cellData() const {
return m_cell_data;
}
std::map<std::string, std::vector<double>>& SimulationDataContainer::cellData() {
return m_cell_data;
}
// This is very deprecated.
void SimulationDataContainer::addDefaultFields() {
registerCellData("PRESSURE" , 1 , 0.0);
registerCellData("SATURATION" , m_num_phases , 0.0);
registerCellData("TEMPERATURE" , 1 , 273.15 + 20);
registerFaceData("FACEPRESSURE" , 1 , 0.0 );
registerFaceData("FACEFLUX" , 1 , 0.0 );
setReferencePointers();
}
void SimulationDataContainer::setReferencePointers()
{
// This sets the reference pointers for the fast
// accessors, the fields must be created first
// by copying or a call to addDefaultFields().
pressure_ref_ = &getCellData("PRESSURE");
temperature_ref_ = &getCellData("TEMPERATURE");
saturation_ref_ = &getCellData("SATURATION");
facepressure_ref_ = &getFaceData("FACEPRESSURE");
faceflux_ref_ = &getFaceData("FACEFLUX");
}
} // namespace Opm

View File

@@ -1,191 +0,0 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SIMULATION_DATA_CONTAINER_HPP
#define SIMULATION_DATA_CONTAINER_HPP
#include <cstddef>
#include <string>
#include <map>
#include <vector>
namespace Opm {
/// The SimulationDataContainer is a simple container to manage
/// simulation data. The container is instantiated with information
/// of how many cells, faces and phases are present in the
/// reservoirmodel. You can then add data to the container by using the
///
/// registerCellData()
/// registerFaceData()
///
/// functions. The container owns and manages the data, but
/// mutable references are returned with the getCellData() and
/// getFaceData() methods, and the content will typically be
/// modified by external scope.
class SimulationDataContainer
{
public:
/// Main constructor setting the sizes for the contained data
/// types.
/// \param num_cells number of elements in cell data vectors
/// \param num_faces number of elements in face data vectors
/// \param num_phases number of phases, the number of components
/// in any data vector must equal 1 or this
/// number (this behaviour and argument is deprecated).
SimulationDataContainer(size_t num_cells, size_t num_faces, size_t num_phases);
/// Copy constructor.
/// Must be defined explicitly because class contains non-value objects
/// (the reference pointers pressure_ref_ etc.) that should not simply
/// be copied.
SimulationDataContainer(const SimulationDataContainer&);
/// Copy assignment operator.
/// Must be defined explicitly because class contains non-value objects
/// (the reference pointers pressure_ref_ etc.) that should not simply
/// be copied.
SimulationDataContainer& operator=(const SimulationDataContainer&);
/// Efficient O(1) swap.
void swap(SimulationDataContainer& other);
size_t numPhases() const;
size_t numFaces() const;
size_t numCells() const;
bool hasCellData( const std::string& name ) const;
/// Will register a data vector of size numCells() *
/// components.
void registerCellData( const std::string& name , size_t components , double initialValue = 0.0 );
std::vector<double>& getCellData( const std::string& name );
const std::vector<double>& getCellData( const std::string& name ) const;
bool hasFaceData( const std::string& name ) const;
void registerFaceData( const std::string& name , size_t components , double initialValue = 0.0 );
std::vector<double>& getFaceData( const std::string& name );
const std::vector<double>& getFaceData( const std::string& name ) const;
/// Will return the number of components of the celldata with
/// name @name:
///
/// numCellDataComponents( "PRESSURE" ) -> 1
/// numCellDataComponents( "SATURATION" ) -> 3
///
/// for a three phase model.
size_t numCellDataComponents( const std::string& name ) const;
bool equal(const SimulationDataContainer& other) const;
/// Will set the values of component nr @component in the
/// field @key. All the cells in @cells will be set to the
/// values in @values.
void setCellDataComponent( const std::string& key , size_t component , const std::vector<int>& cells , const std::vector<double>& values);
// Direct explicit field access for certain default fields.
// These methods are all deprecated, and will eventually be moved to
// concrete subclasses.
std::vector<double>& pressure ();
std::vector<double>& temperature ();
std::vector<double>& saturation ();
std::vector<double>& facepressure();
std::vector<double>& faceflux ();
const std::vector<double>& pressure () const;
const std::vector<double>& temperature () const;
const std::vector<double>& saturation () const;
const std::vector<double>& facepressure() const;
const std::vector<double>& faceflux () const;
const std::map<std::string, std::vector<double>>& cellData() const;
std::map<std::string, std::vector<double>>& cellData();
private:
void addDefaultFields();
void setReferencePointers();
size_t m_num_cells;
size_t m_num_faces;
size_t m_num_phases;
std::map< std::string , std::vector<double> > m_cell_data;
std::map< std::string , std::vector<double> > m_face_data;
std::vector<double>* pressure_ref_;
std::vector<double>* temperature_ref_;
std::vector<double>* saturation_ref_;
std::vector<double>* facepressure_ref_;
std::vector<double>* faceflux_ref_;
};
// Inline implementations of the direct accessors required to guarantee
// performance.
inline std::vector<double>& SimulationDataContainer::pressure( ) {
return *pressure_ref_;
}
inline std::vector<double>& SimulationDataContainer::temperature() {
return *temperature_ref_;
}
inline std::vector<double>& SimulationDataContainer::saturation() {
return *saturation_ref_;
}
inline std::vector<double>& SimulationDataContainer::facepressure() {
return *facepressure_ref_;
}
inline std::vector<double>& SimulationDataContainer::faceflux() {
return *faceflux_ref_;
}
inline const std::vector<double>& SimulationDataContainer::pressure( ) const {
return *pressure_ref_;
}
inline const std::vector<double>& SimulationDataContainer::temperature() const {
return *temperature_ref_;
}
inline const std::vector<double>& SimulationDataContainer::saturation() const {
return *saturation_ref_;
}
inline const std::vector<double>& SimulationDataContainer::facepressure() const {
return *facepressure_ref_;
}
inline const std::vector<double>& SimulationDataContainer::faceflux() const {
return *faceflux_ref_;
}
}
#endif

View File

@@ -1,133 +0,0 @@
/*
Copyright 2016 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef COMMON_UTIL_NUMERIC_CMP
#define COMMON_UTIL_NUMERIC_CMP
#include <cstddef>
#include <vector>
#include <type_traits>
#include <cmath>
#include <algorithm>
namespace Opm {
/// In the namespace cmp are implemented functions for
/// approximate comparison of double values based on absolute
/// and relative difference. There are three functions:
///
/// scalar_equal<T>() : Compare two <T> values.
///
/// ptr_equal<T>(): This compares all the element in the
/// two T * pointers.
///
/// vector_equal<T>(): This compares all the elements in
/// two std::vector<T> instances.
///
/// For both vector_equal<T>() and ptr_equal<T>() the
/// actual comparison is based on the scalar_equal<T>()
/// function. All functions exist as two overloads, one which
/// takes explicit input values for the absolute and relative
/// epsilon, and one which uses default values.
///
/// The comparison functions are implemented as templates, with
/// the following caveats:
///
/// 1. The static_assert() in scalar_equal<T> ensures that only
/// floating point types can be used.
///
/// 2. The default epsilon values are of type double -
/// irrespective of the type of data being compared.
///
/// For more details of floating point comparison please consult
/// this reference:
///
/// https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
namespace cmp {
const double default_abs_epsilon = 1e-8;
const double default_rel_epsilon = 1e-5;
template<typename T>
bool scalar_equal(T value1, T value2, T abs_eps , T rel_eps) {
static_assert(std::is_floating_point<T>::value, "Function scalar_equal() A can only be instantiated with floating point types");
bool equal = true;
T diff = std::fabs(value1 - value2);
if (diff > abs_eps) {
T scale = std::max(std::fabs(value1), std::fabs(value2));
if (diff > scale * rel_eps) {
equal = false;
}
}
return equal;
}
template<typename T>
bool scalar_equal(T value1, T value2) {
return scalar_equal<T>( value1 , value2 , default_abs_epsilon , default_rel_epsilon );
}
template<typename T>
bool vector_equal(const std::vector<T>& v1, const std::vector<T>& v2, T abs_eps, T rel_eps) {
if (v1.size() != v2.size()) {
return false;
}
for (size_t i = 0; i < v1.size(); i++) {
if (!scalar_equal<T>( v1[i], v2[i], abs_eps, rel_eps ))
return false;
}
return true;
}
template<typename T>
bool vector_equal(const std::vector<T>& v1, const std::vector<T>& v2) {
return vector_equal<T>(v1, v2, default_abs_epsilon, default_rel_epsilon);
}
template<typename T>
bool array_equal(const T* p1, const T* p2, size_t num_elements, T abs_eps, T rel_eps) {
if (memcmp(p1 , p2 , num_elements * sizeof * p1) == 0)
return true;
else {
size_t index;
for (index = 0; index < num_elements; index++) {
if (!scalar_equal<T>( p1[index] , p2[index] , abs_eps , rel_eps)) {
return false;
}
}
}
return true;
}
template<typename T>
bool array_equal(const T* p1, const T* p2, size_t num_elements) {
return array_equal<T>(p1, p2, num_elements , default_abs_epsilon, default_rel_epsilon);
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More