Compare commits
169 Commits
release/20
...
release/20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b8fff8306 | ||
|
|
2f708d9b2a | ||
|
|
8bee095294 | ||
|
|
57874e28a9 | ||
|
|
fc48a12fc5 | ||
|
|
f040c2984e | ||
|
|
4947c64556 | ||
|
|
7226f67e0d | ||
|
|
cc0dc95de6 | ||
|
|
46c1dfe3b4 | ||
|
|
a4f4578dc1 | ||
|
|
0283536ac4 | ||
|
|
35514c0aa0 | ||
|
|
68311cf5b3 | ||
|
|
b9af87abc2 | ||
|
|
bd52696fc2 | ||
|
|
e3793e3577 | ||
|
|
9020c7cb36 | ||
|
|
c32693f44c | ||
|
|
f998f52d61 | ||
|
|
3b22b584f3 | ||
|
|
e329f502ba | ||
|
|
1216bc0525 | ||
|
|
924e4d6ad1 | ||
|
|
d47816eb84 | ||
|
|
8bb00bc1e2 | ||
|
|
69d0edc558 | ||
|
|
dac092dc8b | ||
|
|
e83fa6d066 | ||
|
|
899730284a | ||
|
|
dd52371189 | ||
|
|
e7a047d53d | ||
|
|
9e0a5cea6c | ||
|
|
5d158d81e2 | ||
|
|
04d7375f9c | ||
|
|
333011212a | ||
|
|
a7db2bfb2d | ||
|
|
3d380cb395 | ||
|
|
a9d105c1a0 | ||
|
|
c0056ac4c8 | ||
|
|
644914ce5d | ||
|
|
8eb2cead4d | ||
|
|
7da4e4a919 | ||
|
|
64c0651ffa | ||
|
|
a32145c272 | ||
|
|
909a00fade | ||
|
|
81a9f0521f | ||
|
|
37938bbf5e | ||
|
|
29a1dcb6dc | ||
|
|
a802a5173b | ||
|
|
688ded14c3 | ||
|
|
bf63963c0c | ||
|
|
5e9e979051 | ||
|
|
43aa36e0f7 | ||
|
|
cbda0ae4a0 | ||
|
|
425f87b2e4 | ||
|
|
ab0dbee33d | ||
|
|
b1cbd664d2 | ||
|
|
547234a29c | ||
|
|
a742ddead4 | ||
|
|
e2fe88c739 | ||
|
|
3535a43382 | ||
|
|
e8e631ad3a | ||
|
|
34c4173dc3 | ||
|
|
bd425bfff9 | ||
|
|
c5f3c1eca1 | ||
|
|
7f1716b9a6 | ||
|
|
47778333bc | ||
|
|
06b18c1490 | ||
|
|
0d261d24f3 | ||
|
|
fbc67f4ef9 | ||
|
|
7064cde08b | ||
|
|
18ed6a2703 | ||
|
|
03b5b8e785 | ||
|
|
a33f369e04 | ||
|
|
22dcb236ca | ||
|
|
6d18022e19 | ||
|
|
c753787c84 | ||
|
|
25d582c19e | ||
|
|
3e57bfd844 | ||
|
|
1ea00e5602 | ||
|
|
01c6f9fbc8 | ||
|
|
8de9921890 | ||
|
|
c089761bc9 | ||
|
|
577088d80e | ||
|
|
5ad08b3843 | ||
|
|
c1e48b969c | ||
|
|
e7db252f3e | ||
|
|
080a3ff687 | ||
|
|
eb654771d9 | ||
|
|
f9510e31a0 | ||
|
|
acad3a560e | ||
|
|
3440258a72 | ||
|
|
2ec97ba27f | ||
|
|
eee539e6f1 | ||
|
|
e598210529 | ||
|
|
86a1d87a74 | ||
|
|
340f860c52 | ||
|
|
3c4e995a75 | ||
|
|
70bfdc5061 | ||
|
|
2102160bd1 | ||
|
|
d69e33f677 | ||
|
|
405a6c31c5 | ||
|
|
bf935bac89 | ||
|
|
213d4932a6 | ||
|
|
0a0332d4e3 | ||
|
|
af9b0977f6 | ||
|
|
46b7b2a114 | ||
|
|
e89bef777a | ||
|
|
752c8f3197 | ||
|
|
1a273ff6e3 | ||
|
|
51d3ba1b66 | ||
|
|
b4c9f82585 | ||
|
|
2dce26c9f0 | ||
|
|
83db625173 | ||
|
|
aa51ea67bc | ||
|
|
422a11c6c7 | ||
|
|
3573ab0181 | ||
|
|
314a3ffec7 | ||
|
|
1278e431ae | ||
|
|
199324363b | ||
|
|
908acdcb74 | ||
|
|
099099d87c | ||
|
|
ef6dea7b8d | ||
|
|
9683fe2b95 | ||
|
|
258476a196 | ||
|
|
82b638b429 | ||
|
|
53151baf66 | ||
|
|
da4923b5bb | ||
|
|
c91cd7c8c1 | ||
|
|
1acba75552 | ||
|
|
c4eb8936a8 | ||
|
|
5f9fc9bf5b | ||
|
|
f77866bf68 | ||
|
|
2da7093a35 | ||
|
|
e73db36f82 | ||
|
|
9aba3ac6b3 | ||
|
|
a5afe90659 | ||
|
|
77a3df1a61 | ||
|
|
367a9f9a0c | ||
|
|
36d959f1f5 | ||
|
|
c4c1fe2b30 | ||
|
|
f1a1aa02fb | ||
|
|
d2564ff838 | ||
|
|
9c84967734 | ||
|
|
214e45e497 | ||
|
|
5a5d5483e1 | ||
|
|
33225a533a | ||
|
|
107e43a720 | ||
|
|
6be41d2fcf | ||
|
|
474bc50519 | ||
|
|
2c10045195 | ||
|
|
ea86d58ea5 | ||
|
|
0360423aa2 | ||
|
|
bead5d2e99 | ||
|
|
492d31f6cc | ||
|
|
a6c379db05 | ||
|
|
56b6e45fc9 | ||
|
|
a896a4f792 | ||
|
|
b40ea5dda7 | ||
|
|
9a03758e9f | ||
|
|
de87c5a5b5 | ||
|
|
c3cfe38f0c | ||
|
|
74ed9172bb | ||
|
|
5d733a600c | ||
|
|
03e833db1b | ||
|
|
fdbc30f6d2 | ||
|
|
54443e5e28 | ||
|
|
6e2388ff16 |
11
.travis.yml
11
.travis.yml
@@ -13,9 +13,18 @@ addons:
|
||||
- gcc-4.8
|
||||
- g++-4.8
|
||||
- gfortran-4.8
|
||||
- liblapack-dev
|
||||
- libgmp3-dev
|
||||
- libsuitesparse-dev
|
||||
- libeigen3-dev
|
||||
|
||||
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
|
||||
|
||||
|
||||
script: opm-common/travis/build-and-test-opm-common.sh
|
||||
|
||||
@@ -36,6 +36,7 @@ list (APPEND TEST_SOURCE_FILES
|
||||
tests/test_SimulationDataContainer.cpp
|
||||
tests/test_cmp.cpp
|
||||
tests/test_OpmLog.cpp
|
||||
tests/test_messagelimiter.cpp
|
||||
)
|
||||
|
||||
list (APPEND TEST_DATA_FILES
|
||||
@@ -59,6 +60,8 @@ list( APPEND PUBLIC_HEADER_FILES
|
||||
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
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
#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)
|
||||
@@ -8,7 +8,6 @@
|
||||
# HAVE_SHARED_PTR True if std::shared_ptr is available
|
||||
# HAVE_UNIQUE_PTR True if std::unique_ptr 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_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported
|
||||
# HAS_ATTRIBUTE_UNUSED True if attribute unused is supported
|
||||
@@ -34,39 +33,57 @@ include(CheckIncludeFileCXX)
|
||||
# macro to only add option once
|
||||
include(AddOptions)
|
||||
|
||||
# try to use compiler flag -std=c++11
|
||||
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")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.1)
|
||||
if(NOT MSVC)
|
||||
# try to use compiler flag -std=c++11
|
||||
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)
|
||||
endif(NOT MSVC)
|
||||
|
||||
# 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)
|
||||
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)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# 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)
|
||||
# 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()
|
||||
|
||||
# perform tests
|
||||
include(CheckCXXSourceCompiles)
|
||||
@@ -145,33 +162,6 @@ CHECK_CXX_SOURCE_COMPILES("
|
||||
" 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
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
template <class T>
|
||||
@@ -187,7 +177,7 @@ CHECK_CXX_SOURCE_COMPILES("
|
||||
# array and fill
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <array>
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
std::array<int,2> a;
|
||||
@@ -242,24 +232,24 @@ CHECK_CXX_SOURCE_COMPILES("
|
||||
{
|
||||
bar() DEP;
|
||||
};
|
||||
|
||||
|
||||
class peng { } DEP;
|
||||
|
||||
|
||||
template <class T>
|
||||
class t_bar
|
||||
{
|
||||
t_bar() DEP;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class t_peng {
|
||||
t_peng() {};
|
||||
} DEP;
|
||||
|
||||
|
||||
void foo() DEP;
|
||||
|
||||
|
||||
void foo() {};
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
@@ -273,25 +263,25 @@ CHECK_CXX_SOURCE_COMPILES("
|
||||
class bar {
|
||||
bar() DEP;
|
||||
};
|
||||
|
||||
|
||||
class peng { } DEP;
|
||||
|
||||
|
||||
template <class T>
|
||||
class t_bar
|
||||
{
|
||||
t_bar() DEP;
|
||||
};
|
||||
|
||||
|
||||
template <class T>
|
||||
class t_peng
|
||||
{
|
||||
t_peng() {};
|
||||
t_peng() {};
|
||||
} DEP;
|
||||
|
||||
|
||||
void foo() DEP;
|
||||
|
||||
|
||||
void foo() {};
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
@@ -459,7 +449,7 @@ endif()
|
||||
if(CXX_FEATURES_MISSING)
|
||||
set (CXX11FEATURES_FOUND FALSE)
|
||||
if (CXX11Features_FIND_REQUIRED)
|
||||
message(FATAL_ERROR
|
||||
message(FATAL_ERROR
|
||||
"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. "
|
||||
"Your compiler does not seem to implement the following features:\n"
|
||||
|
||||
49
cmake/Modules/FindCwrap.cmake
Normal file
49
cmake/Modules/FindCwrap.cmake
Normal file
@@ -0,0 +1,49 @@
|
||||
# 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)
|
||||
@@ -34,7 +34,7 @@ find_path (ERT_ECL_INCLUDE_DIR
|
||||
NAMES "ert/ecl/ecl_util.h"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_SOURCE_DIR}/../ert"
|
||||
PATH_SUFFIXES "devel/libecl/include/" "include"
|
||||
PATH_SUFFIXES "libecl/include/" "include"
|
||||
DOC "Path to ERT Eclipse library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -42,7 +42,7 @@ find_path (ERT_ECL_WELL_INCLUDE_DIR
|
||||
NAMES "ert/ecl_well/well_const.h"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_SOURCE_DIR}/../ert"
|
||||
PATH_SUFFIXES "devel/libecl_well/include/" "include"
|
||||
PATH_SUFFIXES "libecl_well/include/" "include"
|
||||
DOC "Path to ERT Eclipse library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -50,7 +50,7 @@ find_path (ERT_ECLXX_INCLUDE_DIR
|
||||
NAMES "ert/ecl/EclKW.hpp"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_SOURCE_DIR}/../ert"
|
||||
PATH_SUFFIXES "devel/libeclxx/include/" "include"
|
||||
PATH_SUFFIXES "libeclxx/include/" "include"
|
||||
DOC "Path to ERT Eclipse C++ library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -58,7 +58,7 @@ find_path (ERT_UTIL_INCLUDE_DIR
|
||||
NAMES "ert/util/stringlist.h"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_SOURCE_DIR}/../ert"
|
||||
PATH_SUFFIXES "devel/libert_util/include/" "include"
|
||||
PATH_SUFFIXES "libert_util/include/" "include"
|
||||
DOC "Path to ERT Eclipse library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -66,7 +66,7 @@ find_path (ERT_UTILXX_INCLUDE_DIR
|
||||
NAMES "ert/util/ert_unique_ptr.hpp"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_SOURCE_DIR}/../ert"
|
||||
PATH_SUFFIXES "devel/libert_utilxx/include/" "include"
|
||||
PATH_SUFFIXES "libert_utilxx/include/" "include"
|
||||
DOC "Path to ERT Eclipse C++ library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -74,8 +74,8 @@ find_path (ERT_GEN_INCLUDE_DIR
|
||||
NAMES "ert/util/int_vector.h"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_SOURCE_DIR}/../ert"
|
||||
PATH_SUFFIXES "devel/libert_util/include"
|
||||
"include" "build/libert_util/include"
|
||||
PATH_SUFFIXES "libert_util/include"
|
||||
"include" "build/libert_util/include" "build/libert_util/include"
|
||||
DOC "Path to ERT generated library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -90,10 +90,8 @@ find_library (ERT_LIBRARY_ECL
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/build"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
|
||||
"${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Eclipse library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -102,10 +100,8 @@ find_library (ERT_LIBRARY_ECLXX
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/build"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
|
||||
"${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Eclipse C++ library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -114,10 +110,8 @@ find_library (ERT_LIBRARY_ECL_WELL
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/build"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
|
||||
"${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Eclipse library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -126,10 +120,8 @@ find_library (ERT_LIBRARY_GEOMETRY
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/build"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
|
||||
"${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Geometry library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -138,10 +130,18 @@ find_library (ERT_LIBRARY_UTIL
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/build"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/devel/build"
|
||||
"${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
PATH_SUFFIXES "lib" "lib/Release" "lib/Debug" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Utilities library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_library (ERT_LIBRARY_UTILXX
|
||||
NAMES "ert_utilxx"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${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"
|
||||
${_no_default_path}
|
||||
)
|
||||
@@ -160,6 +160,7 @@ list (APPEND ERT_LIBRARY
|
||||
${ERT_LIBRARY_ECL_WELL}
|
||||
${ERT_LIBRARY_GEOMETRY}
|
||||
${ERT_LIBRARY_UTIL}
|
||||
${ERT_LIBRARY_UTILXX}
|
||||
)
|
||||
list (APPEND ERT_LIBRARIES ${ERT_LIBRARY})
|
||||
list (APPEND ERT_INCLUDE_DIRS ${ERT_INCLUDE_DIR})
|
||||
@@ -243,9 +244,8 @@ if (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND
|
||||
check_cxx_source_compiles (
|
||||
"#include <ert/ecl/EclKW.hpp>
|
||||
int main ( ) {
|
||||
ERT::EclKW<int> kw(\"SATNUM\" , 1000);
|
||||
kw[0] = 10;
|
||||
return 0;
|
||||
ERT::EclKW< int > kw( ecl_kw_alloc( \"SATNUM\", 0, ECL_INT_TYPE ) );
|
||||
return 0;
|
||||
}" HAVE_ERT)
|
||||
cmake_pop_check_state ()
|
||||
else (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
|
||||
|
||||
@@ -23,20 +23,18 @@ if(PYTHONINTERP_FOUND)
|
||||
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)
|
||||
set( start_path "${ERT_ROOT}/${PYTHON_INSTALL_PREFIX}" )
|
||||
else()
|
||||
set( start_path "DEFAULT_PATH")
|
||||
list(APPEND PATH_LIST ${ERT_ROOT})
|
||||
endif()
|
||||
list(APPEND PATH_LIST ${CMAKE_PREFIX_PATH})
|
||||
|
||||
set( PATH_LIST "${start_path}"
|
||||
"${PROJECT_SOURCE_DIR}/../ert/build/${PYTHON_INSTALL_PREFIX}"
|
||||
"${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}")
|
||||
# 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}'); import os.path; import inspect; import ert; print os.path.dirname(os.path.dirname(inspect.getfile(ert)))")
|
||||
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")
|
||||
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "${python_code}"
|
||||
RESULT_VARIABLE import_result
|
||||
OUTPUT_VARIABLE stdout_output
|
||||
|
||||
@@ -107,22 +107,35 @@ if (Petsc_ROOT)
|
||||
set (PETSC_ROOT "${Petsc_ROOT}")
|
||||
endif (Petsc_ROOT)
|
||||
|
||||
find_path (PETSC_NORMAL_INCLUDE_DIR
|
||||
NAMES "petsc.h"
|
||||
PATHS ${PETSC_ROOT}
|
||||
PATH_SUFFIXES "include" "petsc"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_package(PkgConfig)
|
||||
if(PKG_CONFIG_FOUND)
|
||||
set(OLD_PKG $ENV{PKG_CONFIG_PATH})
|
||||
set(ENV{PKG_CONFIG_PATH} $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/pkgconfig)
|
||||
pkg_check_modules(PETSC PETSc>=3.4.0)
|
||||
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()
|
||||
|
||||
list(APPEND PETSC_INCLUDE_DIR ${PETSC_NORMAL_INCLUDE_DIR})
|
||||
if(NOT PETSC_FOUND)
|
||||
find_path (PETSC_NORMAL_INCLUDE_DIR
|
||||
NAMES "petsc.h"
|
||||
PATHS ${PETSC_ROOT}
|
||||
PATH_SUFFIXES "include" "petsc"
|
||||
${_no_default_path}
|
||||
)
|
||||
|
||||
# look for actual Petsc library
|
||||
find_library(PETSC_LIBRARY
|
||||
NAMES "petsc-3.4.3" "petsc-3.4.4" "petsc"
|
||||
PATHS ${PETSC_ROOT}
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
${_no_default_path}
|
||||
)
|
||||
list(APPEND PETSC_INCLUDE_DIR ${PETSC_NORMAL_INCLUDE_DIR})
|
||||
|
||||
# look for actual Petsc library
|
||||
find_library(PETSC_LIBRARY
|
||||
NAMES "petsc-3.4.3" "petsc-3.4.4" "petsc"
|
||||
PATHS ${PETSC_ROOT}
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
${_no_default_path}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT PETSC_LIBRARY)
|
||||
message(STATUS "Could not find the PETSc library")
|
||||
@@ -136,7 +149,7 @@ mark_as_advanced(PETSC_INCLUDE_DIR PETSC_LIBRARY)
|
||||
|
||||
# if both headers and library are found, store results
|
||||
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})
|
||||
|
||||
set(PETSC_LIBRARIES ${PETSC_LIBRARY})
|
||||
|
||||
@@ -42,7 +42,7 @@ if (USE_QUADMATH AND NOT QUADMATH_FOUND)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(QuadMath
|
||||
find_package_handle_standard_args(Quadmath
|
||||
DEFAULT_MSG
|
||||
QUADMATH_LIBRARIES
|
||||
HAVE_QUAD
|
||||
|
||||
@@ -21,6 +21,8 @@ include(CheckCSourceCompiles)
|
||||
|
||||
cmake_push_check_state()
|
||||
|
||||
set(SUPERLU_FOUND "FALSE")
|
||||
|
||||
# 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)
|
||||
|
||||
@@ -57,6 +57,7 @@ int main (void) {
|
||||
HAVE_NULLPTR;
|
||||
HAVE_STATIC_ASSERT;
|
||||
HAVE_SHARED_PTR;
|
||||
MPI_2;
|
||||
SHARED_PTR_HEADER;
|
||||
SHARED_PTR_NAMESPACE;
|
||||
HAVE_TYPE_TRAITS;
|
||||
@@ -66,6 +67,17 @@ int main (void) {
|
||||
")
|
||||
#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
|
||||
include (UseDuneVer)
|
||||
find_dune_version ("dune" "common")
|
||||
|
||||
@@ -26,7 +26,6 @@ find_opm_package (
|
||||
dune-common REQUIRED;
|
||||
dune-geometry REQUIRED;
|
||||
MPI;
|
||||
ALUGrid;
|
||||
UG
|
||||
"
|
||||
# header to search for
|
||||
@@ -49,7 +48,6 @@ int main (void) {
|
||||
"HAVE_MPI;
|
||||
HAVE_UG;
|
||||
HAVE_DUNE_FEM;
|
||||
HAVE_ALUGRID;
|
||||
HAVE_GRIDTYPE;
|
||||
HAVE_GRAPE;
|
||||
HAVE_PSURFACE;
|
||||
|
||||
48
cmake/Modules/Findopm-flowdiagnostics.cmake
Normal file
48
cmake/Modules/Findopm-flowdiagnostics.cmake
Normal file
@@ -0,0 +1,48 @@
|
||||
# - 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}"
|
||||
)
|
||||
@@ -30,9 +30,9 @@ find_opm_package (
|
||||
""
|
||||
|
||||
# test program
|
||||
"#include <opm/output/OutputWriter.hpp>
|
||||
"#include <opm/output/eclipse/Summary.hpp>
|
||||
int main (void) {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
# config variables
|
||||
@@ -40,3 +40,16 @@ int main (void) {
|
||||
)
|
||||
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()
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
# compiler/linker. first parameter is the name of the variable that will
|
||||
# receive this list, the rest is considered the list of libraries
|
||||
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
|
||||
string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}")
|
||||
string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
|
||||
@@ -28,6 +28,12 @@ if (POLICY CMP0048)
|
||||
cmake_policy(SET CMP0048 OLD)
|
||||
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
|
||||
if (CMAKE_VERSION VERSION_LESS "2.8.3")
|
||||
message (STATUS "Enabling compatibility modules for CMake 2.8.3")
|
||||
@@ -37,7 +43,7 @@ endif (CMAKE_VERSION VERSION_LESS "2.8.3")
|
||||
if (CMAKE_VERSION VERSION_LESS "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")
|
||||
endif (CMAKE_VERSION VERSION_LESS "2.8.5")
|
||||
endif (CMAKE_VERSION VERSION_LESS "2.8.5")
|
||||
|
||||
if (CMAKE_VERSION VERSION_LESS "2.8.7")
|
||||
message (STATUS "Enabling compatibility modules for CMake 2.8.7")
|
||||
@@ -93,6 +99,8 @@ endif (NOT USE_MPI)
|
||||
# parallel programming
|
||||
include (UseOpenMP)
|
||||
find_openmp (${project})
|
||||
include (UseThreads)
|
||||
find_threads (${project})
|
||||
|
||||
# callback hook to setup additional dependencies
|
||||
if (COMMAND prereqs_hook)
|
||||
|
||||
@@ -243,7 +243,7 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
NAMES "${_lib}"
|
||||
PATHS ${_guess_bin}
|
||||
HINTS ${PkgConf_${module}_LIBRARY_DIRS} ${_guess_hints_bin}
|
||||
PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib"
|
||||
PATH_SUFFIXES "lib" "lib/Debug" "lib/Release" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib"
|
||||
${_no_system_lib}
|
||||
)
|
||||
# debug info if we didn't find the desired library
|
||||
|
||||
7
cmake/Modules/OpmPythonTest.cmake
Normal file
7
cmake/Modules/OpmPythonTest.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
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)
|
||||
@@ -1,4 +1,8 @@
|
||||
# - 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/,
|
||||
# compile each of them and optionally set them as a test for CTest to
|
||||
@@ -337,7 +341,7 @@ macro(opm_add_test TestName)
|
||||
# the following causes the test to appear as 'skipped' in the
|
||||
# CDash dashboard. it this is removed, the test is just silently
|
||||
# ignored.
|
||||
if (NOT CURTEST_ONLY_COMPILE)
|
||||
if (NOT CURTEST_ONLY_COMPILE AND ADD_DISABLED_CTESTS)
|
||||
add_test(${TestName} skip_test_dummy)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
53
cmake/Modules/UseThreads.cmake
Normal file
53
cmake/Modules/UseThreads.cmake
Normal file
@@ -0,0 +1,53 @@
|
||||
# - 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)
|
||||
@@ -25,14 +25,15 @@ set (ewoms_DEPS
|
||||
"CXX11Features REQUIRED"
|
||||
# DUNE prerequisites
|
||||
"dune-common REQUIRED"
|
||||
"dune-localfunctions REQUIRED"
|
||||
"dune-geometry REQUIRED"
|
||||
"dune-grid REQUIRED"
|
||||
"dune-istl REQUIRED"
|
||||
"opm-common REQUIRED"
|
||||
"opm-material REQUIRED"
|
||||
"dune-localfunctions"
|
||||
"dune-alugrid"
|
||||
"dune-fem"
|
||||
"opm-parser"
|
||||
"opm-grid"
|
||||
# librt (on some systems necessary for clock_gettime())
|
||||
"librt REQUIRED"
|
||||
|
||||
@@ -42,4 +42,5 @@ set (opm-core_DEPS
|
||||
"opm-parser REQUIRED"
|
||||
# the code which implements the material laws
|
||||
"opm-material REQUIRED"
|
||||
"opm-output REQUIRED"
|
||||
)
|
||||
|
||||
21
cmake/Modules/opm-flowdiagnostics-applications-prereqs.cmake
Normal file
21
cmake/Modules/opm-flowdiagnostics-applications-prereqs.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- 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-applications_CONFIG_VAR
|
||||
)
|
||||
|
||||
# dependencies
|
||||
set (opm-flowdiagnostics-applications_DEPS
|
||||
# compile with C99 support if available
|
||||
"C99"
|
||||
# compile with C++0x/11 support if available
|
||||
"CXX11Features REQUIRED"
|
||||
"Boost 1.44.0
|
||||
COMPONENTS filesystem system unit_test_framework REQUIRED"
|
||||
"ERT REQUIRED"
|
||||
# prerequisite OPM modules
|
||||
"opm-common REQUIRED;
|
||||
opm-flowdiagnostics REQUIRED;
|
||||
opm-core REQUIRED"
|
||||
)
|
||||
18
cmake/Modules/opm-flowdiagnostics-prereqs.cmake
Normal file
18
cmake/Modules/opm-flowdiagnostics-prereqs.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
# -*- 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"
|
||||
)
|
||||
@@ -2,7 +2,7 @@
|
||||
# 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-core_CONFIG_VAR
|
||||
set (opm-output_CONFIG_VAR
|
||||
HAVE_ERT
|
||||
)
|
||||
|
||||
@@ -14,13 +14,11 @@ set (opm-output_DEPS
|
||||
"CXX11Features REQUIRED"
|
||||
# various runtime library enhancements
|
||||
"Boost 1.44.0
|
||||
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
|
||||
COMPONENTS unit_test_framework REQUIRED"
|
||||
# Ensembles-based Reservoir Tools (ERT)
|
||||
"ERT REQUIRED"
|
||||
# Look for MPI support
|
||||
"opm-common REQUIRED"
|
||||
# Parser library for ECL-type simulation models
|
||||
"opm-parser REQUIRED"
|
||||
# TODO remove this dependancy
|
||||
"opm-core REQUIRED"
|
||||
)
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
# defines that must be present in config.h for our headers
|
||||
set (opm-simulators_CONFIG_VAR
|
||||
HAVE_OPM_GRID
|
||||
HAVE_OPM_GRID
|
||||
HAVE_PTHREAD
|
||||
)
|
||||
|
||||
# dependencies
|
||||
@@ -18,7 +19,8 @@ set (opm-simulators_DEPS
|
||||
# DUNE prerequisites
|
||||
"dune-common REQUIRED;
|
||||
dune-istl REQUIRED"
|
||||
# OPM dependency
|
||||
"ERTPython"
|
||||
# OPM dependency
|
||||
"opm-common REQUIRED;
|
||||
opm-parser REQUIRED;
|
||||
opm-core REQUIRED;
|
||||
|
||||
10
debian/changelog
vendored
10
debian/changelog
vendored
@@ -1,5 +1,11 @@
|
||||
opm-common (2016.04-rc1-1~trusty) trusty; urgency=medium
|
||||
opm-common (2016.10-rfinal-1~xenial) xenial; urgency=medium
|
||||
|
||||
* New release
|
||||
|
||||
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Fri, 22 Apr 2016 10:06:00 +0200
|
||||
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Wed, 26 Oct 2016 09:55:11 +0200
|
||||
|
||||
opm-common (2015.10-1~trusty) trusty; urgency=medium
|
||||
|
||||
* New release
|
||||
|
||||
-- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Mon, 19 Oct 2015 10:49:00 +0200
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
Module: opm-common
|
||||
Description: Open Porous Media Initiative shared infrastructure
|
||||
Version: 2016.04
|
||||
Label: 2016.04
|
||||
Version: 2016.10
|
||||
Label: 2016.10
|
||||
Maintainer: opm@opm-project.org
|
||||
MaintainerName: OPM community
|
||||
Url: http://opm-project.org
|
||||
|
||||
@@ -1,17 +1,100 @@
|
||||
#!/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 $1
|
||||
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
|
||||
cmake --build .
|
||||
test $? -eq 0 || exit 2
|
||||
ctest -T Test --no-compress-output
|
||||
|
||||
# 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
|
||||
cmake --build . --target install
|
||||
fi
|
||||
@@ -20,11 +103,18 @@ function build_module {
|
||||
# $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 .
|
||||
git remote add origin https://github.com/OPM/$1
|
||||
if [ "$1" == "ert" ]
|
||||
then
|
||||
git remote add origin https://github.com/Ensembles/$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
|
||||
@@ -38,9 +128,85 @@ function clone_module {
|
||||
function clone_and_build_module {
|
||||
clone_module $1 $3
|
||||
pushd .
|
||||
mkdir $4/build-$1
|
||||
mkdir -p $4/build-$1
|
||||
cd $4/build-$1
|
||||
build_module "$2" 0 $WORKSPACE/deps/$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
|
||||
cmake --build . --target install
|
||||
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
|
||||
}
|
||||
|
||||
@@ -6,12 +6,36 @@ source `dirname $0`/build-opm-module.sh
|
||||
mkdir deps
|
||||
ln -sf $WORKSPACE deps/opm-common
|
||||
|
||||
# Build without MPI
|
||||
pushd .
|
||||
mkdir -p serial/build-opm-common
|
||||
cd serial/build-opm-common
|
||||
build_module "-DUSE_MPI=0" 1 $WORKSPACE
|
||||
test $? -eq 0 || exit 1
|
||||
popd
|
||||
# Downstreams and revisions
|
||||
declare -a downstreams
|
||||
downstreams=(ert
|
||||
opm-parser
|
||||
opm-output
|
||||
opm-material
|
||||
opm-core
|
||||
opm-grid
|
||||
opm-simulators
|
||||
opm-upscaling
|
||||
ewoms)
|
||||
|
||||
cp serial/build-opm-common/testoutput.xml .
|
||||
declare -A downstreamRev
|
||||
downstreamRev[ert]=master
|
||||
downstreamRev[opm-parser]=master
|
||||
downstreamRev[opm-material]=master
|
||||
downstreamRev[opm-core]=master
|
||||
downstreamRev[opm-grid]=master
|
||||
downstreamRev[opm-output]=master
|
||||
downstreamRev[opm-simulators]=master
|
||||
downstreamRev[opm-upscaling]=master
|
||||
downstreamRev[ewoms]=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
|
||||
|
||||
@@ -57,6 +57,16 @@
|
||||
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()); \
|
||||
} while (false)
|
||||
|
||||
// throw an exception if a condition is true
|
||||
#define OPM_ERROR_IF(condition, message) do {if(condition){ OPM_THROW(std::logic_error, message);}} while(false)
|
||||
|
||||
|
||||
@@ -48,9 +48,8 @@ size_t CounterLog::numMessages(int64_t messageType) const {
|
||||
|
||||
|
||||
|
||||
void CounterLog::addMessage(int64_t messageType , const std::string& ) {
|
||||
if (includeMessage( messageType ))
|
||||
m_count[messageType]++;
|
||||
void CounterLog::addMessageUnconditionally(int64_t messageType, const std::string& ) {
|
||||
m_count[messageType]++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,27 +30,23 @@ 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:
|
||||
class CounterLog : public LogBackend
|
||||
{
|
||||
public:
|
||||
CounterLog(int64_t messageMask);
|
||||
CounterLog();
|
||||
|
||||
CounterLog(int64_t messageMask);
|
||||
CounterLog();
|
||||
size_t numMessages(int64_t messageType) const;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
void addMessage(int64_t messageFlag ,
|
||||
const std::string& message);
|
||||
|
||||
|
||||
void clear();
|
||||
~CounterLog() {};
|
||||
private:
|
||||
std::map<int64_t , size_t> m_count;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<CounterLog> CounterLogPtr;
|
||||
typedef std::shared_ptr<const CounterLog> CounterLogConstPtr;
|
||||
} // namespace Opm
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
namespace Opm {
|
||||
|
||||
|
||||
void EclipsePRTLog::addMessage(int64_t messageType, const std::string& message)
|
||||
void EclipsePRTLog::addMessageUnconditionally(int64_t messageType, const std::string& message)
|
||||
{
|
||||
StreamLog::addMessage(messageType, message);
|
||||
StreamLog::addMessageUnconditionally(messageType, message);
|
||||
m_count[messageType]++;
|
||||
}
|
||||
|
||||
@@ -45,15 +45,33 @@ namespace Opm {
|
||||
|
||||
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("\nProblems " + std::to_string(numMessages(Log::MessageType::Problem))) +
|
||||
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";
|
||||
addMessage(Log::MessageType::Info, summary_msg);
|
||||
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)
|
||||
{}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,35 @@ class EclipsePRTLog : public StreamLog {
|
||||
public:
|
||||
using StreamLog::StreamLog;
|
||||
|
||||
void addMessage(int64_t messageType, const std::string& message);
|
||||
|
||||
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
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <opm/common/OpmLog/LogBackend.hpp>
|
||||
#include <opm/common/OpmLog/LogUtil.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@@ -27,18 +27,72 @@ namespace Opm {
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool LogBackend::includeMessage(int64_t messageFlag) {
|
||||
if (((messageFlag & m_mask) == messageFlag) &&
|
||||
(messageFlag > 0))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
LogBackend::~LogBackend()
|
||||
{
|
||||
}
|
||||
|
||||
int64_t LogBackend::getMask() const {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
Copyright 2015 Statoil ASA.
|
||||
Copyright 2015, 2016 Statoil ASA.
|
||||
Copyright 2016 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
@@ -21,25 +22,65 @@
|
||||
#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 {
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
class LogBackend {
|
||||
/// Abstract interface class for log backends.
|
||||
class LogBackend
|
||||
{
|
||||
public:
|
||||
/// Construct with given message mask.
|
||||
explicit LogBackend(int64_t mask);
|
||||
|
||||
public:
|
||||
LogBackend( int64_t mask );
|
||||
virtual ~LogBackend() { };
|
||||
virtual void addMessage(int64_t , const std::string& ) { };
|
||||
/// Virtual destructor to enable inheritance.
|
||||
virtual ~LogBackend();
|
||||
|
||||
int64_t getMask() const;
|
||||
bool includeMessage(int64_t messageFlag);
|
||||
/// Configure how formatMessage() will modify message strings.
|
||||
void setMessageFormatter(std::shared_ptr<MessageFormatterInterface> formatter);
|
||||
|
||||
private:
|
||||
int64_t m_mask;
|
||||
};
|
||||
}
|
||||
/// 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
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Log {
|
||||
std::string fileMessage(const std::string& filename , int line , const std::string& message) {
|
||||
std::ostringstream oss;
|
||||
|
||||
oss << filename << ":" << line << ": " << message;
|
||||
oss << message << "\n" << "In file " << filename << ", line " << line << "\n";
|
||||
|
||||
return oss.str();
|
||||
}
|
||||
@@ -49,22 +49,25 @@ namespace Log {
|
||||
std::string prefix;
|
||||
switch (messageType) {
|
||||
case MessageType::Debug:
|
||||
prefix = "debug";
|
||||
prefix = "Debug";
|
||||
break;
|
||||
case MessageType::Note:
|
||||
prefix = "Note";
|
||||
break;
|
||||
case MessageType::Info:
|
||||
prefix = "info";
|
||||
prefix = "Info";
|
||||
break;
|
||||
case MessageType::Warning:
|
||||
prefix = "warning";
|
||||
prefix = "Warning";
|
||||
break;
|
||||
case MessageType::Error:
|
||||
prefix = "error";
|
||||
prefix = "Error";
|
||||
break;
|
||||
case MessageType::Problem:
|
||||
prefix = "problem";
|
||||
prefix = "Problem";
|
||||
break;
|
||||
case MessageType::Bug:
|
||||
prefix = "bug";
|
||||
prefix = "Bug";
|
||||
break;
|
||||
default:
|
||||
throw std::invalid_argument("Unhandled messagetype");
|
||||
@@ -72,5 +75,24 @@ namespace Log {
|
||||
|
||||
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::Error:
|
||||
case MessageType::Problem:
|
||||
case MessageType::Bug:
|
||||
return AnsiTerminalColors::red_strong + message + AnsiTerminalColors::none;
|
||||
default:
|
||||
throw std::invalid_argument("Unhandled messagetype");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,19 +27,37 @@ namespace Opm {
|
||||
namespace Log {
|
||||
namespace MessageType {
|
||||
const int64_t Debug = 1; /* Excessive information */
|
||||
const int64_t Info = 2; /* Normal status information */
|
||||
const int64_t Warning = 4; /* Input anomaly - possible error */
|
||||
const int64_t Error = 8; /* Error in the input data - should probably exit. */
|
||||
const int64_t Problem = 16; /* Calculation problems - e.g. convergence failure. */
|
||||
const int64_t Bug = 32; /* An inconsistent state has been encountered in the simulator - should probably exit. */
|
||||
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 default_color = "\033[39m";
|
||||
}
|
||||
|
||||
const int64_t DefaultMessageTypes = MessageType::Debug + MessageType::Info + MessageType::Warning + MessageType::Error + MessageType::Problem + MessageType::Bug;
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,20 +36,25 @@ namespace Opm {
|
||||
addMessageType( Log::MessageType::Error , "error");
|
||||
addMessageType( Log::MessageType::Problem , "problem");
|
||||
addMessageType( Log::MessageType::Bug , "bug");
|
||||
addMessageType( Log::MessageType::Note , "note");
|
||||
}
|
||||
|
||||
void Logger::addMessage(int64_t messageType , const std::string& message) const {
|
||||
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.begin(); iter != m_backends.end(); ++iter) {
|
||||
std::shared_ptr<LogBackend> backend = (*iter).second;
|
||||
backend->addMessage( messageType , message );
|
||||
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;
|
||||
@@ -63,6 +68,11 @@ namespace Opm {
|
||||
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)
|
||||
|
||||
@@ -35,6 +35,7 @@ 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;
|
||||
@@ -44,6 +45,7 @@ public:
|
||||
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 {
|
||||
|
||||
95
opm/common/OpmLog/MessageFormatter.hpp
Normal file
95
opm/common/OpmLog/MessageFormatter.hpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
187
opm/common/OpmLog/MessageLimiter.hpp
Normal file
187
opm/common/OpmLog/MessageLimiter.hpp
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
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
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <opm/common/OpmLog/Logger.hpp>
|
||||
#include <opm/common/OpmLog/StreamLog.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@@ -37,48 +39,100 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
const std::string msg = Log::prefixMessage(Log::MessageType::Info, message);
|
||||
addMessage(Log::MessageType::Info, msg);
|
||||
addMessage(Log::MessageType::Info, message);
|
||||
}
|
||||
|
||||
|
||||
void OpmLog::warning(const std::string& message)
|
||||
{
|
||||
const std::string msg = Log::prefixMessage(Log::MessageType::Warning, message);
|
||||
addMessage(Log::MessageType::Warning, msg);
|
||||
addMessage(Log::MessageType::Warning, message);
|
||||
}
|
||||
|
||||
|
||||
void OpmLog::problem(const std::string& message)
|
||||
{
|
||||
const std::string msg = Log::prefixMessage(Log::MessageType::Problem, message);
|
||||
addMessage(Log::MessageType::Problem, msg);
|
||||
addMessage(Log::MessageType::Problem, message);
|
||||
}
|
||||
|
||||
|
||||
void OpmLog::error(const std::string& message)
|
||||
{
|
||||
const std::string msg = Log::prefixMessage(Log::MessageType::Error, message);
|
||||
addMessage(Log::MessageType::Error, msg);
|
||||
addMessage(Log::MessageType::Error, message);
|
||||
}
|
||||
|
||||
|
||||
void OpmLog::bug(const std::string& message)
|
||||
{
|
||||
const std::string msg = Log::prefixMessage(Log::MessageType::Bug, message);
|
||||
addMessage(Log::MessageType::Bug, msg);
|
||||
addMessage(Log::MessageType::Bug, message);
|
||||
}
|
||||
|
||||
|
||||
void OpmLog::debug(const std::string& message)
|
||||
{
|
||||
const std::string msg = Log::prefixMessage(Log::MessageType::Debug, message);
|
||||
addMessage(Log::MessageType::Debug, msg);
|
||||
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 );
|
||||
@@ -102,6 +156,13 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
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 );
|
||||
@@ -114,6 +175,14 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OpmLog::setupSimpleDefaultLogging(const bool use_prefix)
|
||||
{
|
||||
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(std::cout, Log::DefaultMessageTypes);
|
||||
OpmLog::addBackend( "SimpleDefaultLog", streamLog);
|
||||
streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(10));
|
||||
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(use_prefix, true));
|
||||
}
|
||||
/******************************************************************/
|
||||
|
||||
std::shared_ptr<Logger> OpmLog::m_logger;
|
||||
|
||||
@@ -40,6 +40,7 @@ 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);
|
||||
@@ -47,12 +48,23 @@ public:
|
||||
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);
|
||||
|
||||
static void setupSimpleDefaultLogging(const bool use_prefix);
|
||||
|
||||
template <class BackendType>
|
||||
static std::shared_ptr<BackendType> getBackend(const std::string& name) {
|
||||
|
||||
@@ -22,9 +22,13 @@
|
||||
namespace Opm {
|
||||
|
||||
|
||||
StreamLog::StreamLog(const std::string& logFile , int64_t messageMask) : LogBackend(messageMask)
|
||||
StreamLog::StreamLog(const std::string& logFile , int64_t messageMask, bool append) : LogBackend(messageMask)
|
||||
{
|
||||
m_ofstream.open( logFile.c_str() , std::ofstream::out );
|
||||
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;
|
||||
}
|
||||
@@ -44,12 +48,11 @@ void StreamLog::close() {
|
||||
}
|
||||
}
|
||||
|
||||
void StreamLog::addMessage(int64_t messageType , const std::string& message) {
|
||||
if (includeMessage( messageType )) {
|
||||
(*m_ostream) << message << std::endl;
|
||||
|
||||
if (m_ofstream.is_open())
|
||||
m_ofstream.flush();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,4 +61,4 @@ StreamLog::~StreamLog() {
|
||||
close();
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Opm
|
||||
|
||||
@@ -31,11 +31,13 @@ namespace Opm {
|
||||
class StreamLog : public LogBackend {
|
||||
|
||||
public:
|
||||
StreamLog(const std::string& logFile , int64_t messageMask);
|
||||
StreamLog(const std::string& logFile , int64_t messageMask, bool append = false);
|
||||
StreamLog(std::ostream& os , int64_t messageMask);
|
||||
void addMessage(int64_t messageType , const std::string& message);
|
||||
~StreamLog();
|
||||
|
||||
protected:
|
||||
virtual void addMessageUnconditionally(int64_t messageType, const std::string& message) override;
|
||||
|
||||
private:
|
||||
void close();
|
||||
|
||||
|
||||
@@ -41,14 +41,14 @@ TimerLog::TimerLog(std::ostream& os) : StreamLog( os , StopTimer | StartTimer )
|
||||
|
||||
|
||||
|
||||
void TimerLog::addMessage(int64_t messageType , const std::string& msg ) {
|
||||
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::addMessage( messageType , m_work.str());
|
||||
StreamLog::addMessageUnconditionally( messageType, m_work.str());
|
||||
} else {
|
||||
if (messageType == StartTimer)
|
||||
m_start = clock();
|
||||
|
||||
@@ -42,11 +42,12 @@ public:
|
||||
TimerLog(const std::string& logFile);
|
||||
TimerLog(std::ostream& os);
|
||||
|
||||
void addMessage(int64_t messageFlag ,
|
||||
const std::string& message);
|
||||
|
||||
void clear();
|
||||
~TimerLog() {};
|
||||
|
||||
protected:
|
||||
void addMessageUnconditionally(int64_t messageFlag,
|
||||
const std::string& message) override;
|
||||
private:
|
||||
clock_t m_start;
|
||||
std::ostringstream m_work;
|
||||
|
||||
@@ -210,11 +210,11 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
const std::unordered_map<std::string, std::vector<double>>& SimulationDataContainer::cellData() const {
|
||||
const std::map<std::string, std::vector<double>>& SimulationDataContainer::cellData() const {
|
||||
return m_cell_data;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, std::vector<double>>& SimulationDataContainer::cellData() {
|
||||
std::map<std::string, std::vector<double>>& SimulationDataContainer::cellData() {
|
||||
return m_cell_data;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
@@ -118,8 +118,8 @@ namespace Opm {
|
||||
const std::vector<double>& facepressure() const;
|
||||
const std::vector<double>& faceflux () const;
|
||||
|
||||
const std::unordered_map<std::string, std::vector<double>>& cellData() const;
|
||||
std::unordered_map<std::string, std::vector<double>>& cellData();
|
||||
const std::map<std::string, std::vector<double>>& cellData() const;
|
||||
std::map<std::string, std::vector<double>>& cellData();
|
||||
|
||||
private:
|
||||
void addDefaultFields();
|
||||
@@ -129,8 +129,8 @@ namespace Opm {
|
||||
size_t m_num_faces;
|
||||
size_t m_num_phases;
|
||||
|
||||
std::unordered_map< std::string , std::vector<double> > m_cell_data;
|
||||
std::unordered_map< std::string , std::vector<double> > m_face_data;
|
||||
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_;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
# spec file for package opm-common
|
||||
#
|
||||
|
||||
%define tag rc1
|
||||
%define tag final
|
||||
|
||||
Name: opm-common
|
||||
Version: 2016.04
|
||||
Version: 2016.10
|
||||
Release: 0
|
||||
Summary: Open Porous Media - common helpers and buildsystem
|
||||
License: GPL-3.0
|
||||
@@ -13,7 +13,7 @@ Group: Development/Libraries/C and C++
|
||||
Url: http://www.opm-project.org/
|
||||
Source0: https://github.com/OPM/%{name}/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz
|
||||
BuildRequires: git doxygen bc
|
||||
%{?el6:BuildRequires: devtoolset-2 cmake28 boost148-devel}
|
||||
%{?el6:BuildRequires: devtoolset-3-toolchain cmake28 boost148-devel}
|
||||
%{!?el6:BuildRequires: gcc gcc-c++ cmake boost-devel}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
@@ -48,8 +48,8 @@ This package contains the documentation files for opm-common
|
||||
|
||||
# consider using -DUSE_VERSIONED_DIR=ON if backporting
|
||||
%build
|
||||
%{?el6:scl enable devtoolset-2 bash}
|
||||
%{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DUSE_RUNPATH=OFF %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gfortran -DBOOST_LIBRARYDIR=%{_libdir}/boost148 -DBOOST_INCLUDEDIR=%{_includedir}/boost148}
|
||||
%{?el6:scl enable devtoolset-3 bash}
|
||||
%{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DUSE_RUNPATH=OFF %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gfortran -DBOOST_LIBRARYDIR=%{_libdir}/boost148 -DBOOST_INCLUDEDIR=%{_includedir}/boost148}
|
||||
make
|
||||
|
||||
%install
|
||||
|
||||
@@ -46,28 +46,11 @@ BOOST_AUTO_TEST_CASE(DoLogging) {
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Test_Format) {
|
||||
BOOST_CHECK_EQUAL( "/path/to/file:100: There is a mild fuckup here?" , Log::fileMessage("/path/to/file" , 100 , "There is a mild fuckup here?"));
|
||||
BOOST_CHECK_EQUAL( "There is an error here?\nIn file /path/to/file, line 100\n" , Log::fileMessage("/path/to/file" , 100 , "There is an error here?"));
|
||||
|
||||
BOOST_CHECK_EQUAL( "error: This is the error" , Log::prefixMessage(Log::MessageType::Error , "This is the error"));
|
||||
BOOST_CHECK_EQUAL( "warning: This is the warning" , Log::prefixMessage(Log::MessageType::Warning , "This is the warning"));
|
||||
BOOST_CHECK_EQUAL( "info: This is the info" , Log::prefixMessage(Log::MessageType::Info , "This is the info"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Test_AbstractBackend) {
|
||||
int64_t mask = 1+4+16;
|
||||
LogBackend backend(mask);
|
||||
|
||||
BOOST_CHECK_EQUAL(false , backend.includeMessage(0 ));
|
||||
BOOST_CHECK_EQUAL(true , backend.includeMessage(1 ));
|
||||
BOOST_CHECK_EQUAL(false , backend.includeMessage(2 ));
|
||||
BOOST_CHECK_EQUAL(true , backend.includeMessage(4 ));
|
||||
BOOST_CHECK_EQUAL(false , backend.includeMessage(8 ));
|
||||
BOOST_CHECK_EQUAL(true , backend.includeMessage(16 ));
|
||||
|
||||
BOOST_CHECK_EQUAL(false, backend.includeMessage(6 ));
|
||||
BOOST_CHECK_EQUAL(true , backend.includeMessage(5 ));
|
||||
BOOST_CHECK_EQUAL( "Error: This is the error" , Log::prefixMessage(Log::MessageType::Error , "This is the error"));
|
||||
BOOST_CHECK_EQUAL( "Warning: This is the warning" , Log::prefixMessage(Log::MessageType::Warning , "This is the warning"));
|
||||
BOOST_CHECK_EQUAL( "Info: This is the info" , Log::prefixMessage(Log::MessageType::Info , "This is the info"));
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +118,8 @@ public:
|
||||
m_specialMessages = 0;
|
||||
}
|
||||
|
||||
void addMessage(int64_t messageType , const std::string& /* message */) {
|
||||
void addMessageUnconditionally(int64_t messageType , const std::string& /* message */) override
|
||||
{
|
||||
if (messageType & Log::DefaultMessageTypes)
|
||||
m_defaultMessages +=1;
|
||||
else
|
||||
@@ -186,10 +170,12 @@ BOOST_AUTO_TEST_CASE( CounterLogTesting) {
|
||||
|
||||
counter.addMessage( Log::MessageType::Error , "This is an error ...");
|
||||
counter.addMessage( Log::MessageType::Warning , "This is a warning");
|
||||
counter.addMessage( Log::MessageType::Note , "This is a note");
|
||||
|
||||
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Error ));
|
||||
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Warning ));
|
||||
BOOST_CHECK_EQUAL(0 , counter.numMessages( Log::MessageType::Info ));
|
||||
BOOST_CHECK_EQUAL(1U , counter.numMessages( Log::MessageType::Note ));
|
||||
|
||||
{
|
||||
int64_t not_enabled = 4096;
|
||||
@@ -249,3 +235,189 @@ BOOST_AUTO_TEST_CASE(TestOpmLog) {
|
||||
|
||||
BOOST_CHECK_EQUAL( log_stream.str() , "Warning\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestHelperFunctions)
|
||||
{
|
||||
using namespace Log;
|
||||
|
||||
// isPower2
|
||||
BOOST_CHECK(!isPower2(0));
|
||||
BOOST_CHECK(isPower2(1));
|
||||
BOOST_CHECK(isPower2(1 << 3));
|
||||
BOOST_CHECK(isPower2(1ul << 62));
|
||||
|
||||
// fileMessage
|
||||
BOOST_CHECK_EQUAL(fileMessage("foo/bar", 1, "message"), "message\nIn file foo/bar, line 1\n");
|
||||
BOOST_CHECK_EQUAL(fileMessage(MessageType::Error, "foo/bar", 1, "message"), "Error: message\nIn file foo/bar, line 1\n");
|
||||
|
||||
// prefixMessage
|
||||
BOOST_CHECK_EQUAL(prefixMessage(MessageType::Error, "message"), "Error: message");
|
||||
BOOST_CHECK_EQUAL(prefixMessage(MessageType::Info, "message"), "Info: message");
|
||||
BOOST_CHECK_EQUAL(prefixMessage(MessageType::Note, "message"), "Note: message");
|
||||
|
||||
// colorCode Message
|
||||
BOOST_CHECK_EQUAL(colorCodeMessage(MessageType::Info, "message"), "message");
|
||||
BOOST_CHECK_EQUAL(colorCodeMessage(MessageType::Warning, "message"), AnsiTerminalColors::blue_strong + "message" + AnsiTerminalColors::none);
|
||||
BOOST_CHECK_EQUAL(colorCodeMessage(MessageType::Error, "message"), AnsiTerminalColors::red_strong + "message" + AnsiTerminalColors::none);
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestOpmLogWithColors)
|
||||
{
|
||||
OpmLog::removeAllBackends();
|
||||
|
||||
std::ostringstream log_stream;
|
||||
|
||||
{
|
||||
std::shared_ptr<CounterLog> counter = std::make_shared<CounterLog>();
|
||||
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(log_stream, Log::DefaultMessageTypes);
|
||||
BOOST_CHECK_EQUAL( false , OpmLog::hasBackend("NO"));
|
||||
OpmLog::addBackend("COUNTER" , counter);
|
||||
OpmLog::addBackend("STREAM" , streamLog);
|
||||
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("COUNTER"));
|
||||
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("STREAM"));
|
||||
|
||||
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false, true));
|
||||
}
|
||||
|
||||
OpmLog::warning("Warning");
|
||||
OpmLog::error("Error");
|
||||
OpmLog::info("Info");
|
||||
OpmLog::bug("Bug");
|
||||
|
||||
const std::string expected = Log::colorCodeMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Error, "Error") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Info, "Info") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Bug, "Bug") + "\n";
|
||||
|
||||
BOOST_CHECK_EQUAL(log_stream.str(), expected);
|
||||
|
||||
{
|
||||
auto counter = OpmLog::getBackend<CounterLog>("COUNTER");
|
||||
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Error) );
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Warning) );
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Info) );
|
||||
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Bug) );
|
||||
}
|
||||
|
||||
|
||||
std::cout << log_stream.str() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestOpmLogWithLimits)
|
||||
{
|
||||
OpmLog::removeAllBackends();
|
||||
|
||||
std::ostringstream log_stream1;
|
||||
std::ostringstream log_stream2;
|
||||
|
||||
{
|
||||
std::shared_ptr<StreamLog> streamLog1 = std::make_shared<StreamLog>(log_stream1, Log::DefaultMessageTypes);
|
||||
std::shared_ptr<StreamLog> streamLog2 = std::make_shared<StreamLog>(log_stream2, Log::DefaultMessageTypes);
|
||||
OpmLog::addBackend("STREAM1" , streamLog1);
|
||||
OpmLog::addBackend("STREAM2" , streamLog2);
|
||||
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("STREAM1"));
|
||||
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("STREAM2"));
|
||||
|
||||
streamLog1->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false, true));
|
||||
streamLog1->setMessageLimiter(std::make_shared<MessageLimiter>(2));
|
||||
streamLog2->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false, true));
|
||||
std::shared_ptr<MessageLimiter> lim(new MessageLimiter(MessageLimiter::NoLimit, {{ Log::MessageType::Warning, 2 }}));
|
||||
streamLog2->setMessageLimiter(lim); // no tag limit, but a warning category limit
|
||||
}
|
||||
|
||||
const std::string tag = "ExampleTag";
|
||||
OpmLog::warning(tag, "Warning");
|
||||
OpmLog::error("Error");
|
||||
OpmLog::info("Info");
|
||||
OpmLog::bug("Bug");
|
||||
OpmLog::warning(tag, "Warning");
|
||||
OpmLog::warning(tag, "Warning");
|
||||
OpmLog::warning(tag, "Warning");
|
||||
|
||||
const std::string expected1 = Log::colorCodeMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Error, "Error") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Info, "Info") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Bug, "Bug") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Warning, "Message limit reached for message tag: " + tag) + "\n";
|
||||
|
||||
BOOST_CHECK_EQUAL(log_stream1.str(), expected1);
|
||||
|
||||
const std::string expected2 = Log::colorCodeMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Error, "Error") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Info, "Info") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Bug, "Bug") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Warning, "Message limit reached for message category: Warning") + "\n";
|
||||
|
||||
BOOST_CHECK_EQUAL(log_stream2.str(), expected2);
|
||||
|
||||
std::cout << log_stream1.str() << std::endl;
|
||||
std::cout << log_stream2.str() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestsetupSimpleLog)
|
||||
{
|
||||
bool use_prefix = false;
|
||||
OpmLog::setupSimpleDefaultLogging(use_prefix);
|
||||
BOOST_CHECK_EQUAL(true, OpmLog::hasBackend("SimpleDefaultLog"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestFormat)
|
||||
{
|
||||
OpmLog::removeAllBackends();
|
||||
std::ostringstream log_stream1;
|
||||
std::ostringstream log_stream2;
|
||||
std::ostringstream log_stream3;
|
||||
{
|
||||
std::shared_ptr<StreamLog> streamLog1 = std::make_shared<StreamLog>(log_stream1, Log::DefaultMessageTypes);
|
||||
std::shared_ptr<StreamLog> streamLog2 = std::make_shared<StreamLog>(log_stream2, Log::DefaultMessageTypes);
|
||||
std::shared_ptr<StreamLog> streamLog3 = std::make_shared<StreamLog>(log_stream3, Log::DefaultMessageTypes);
|
||||
OpmLog::addBackend("STREAM1" , streamLog1);
|
||||
OpmLog::addBackend("STREAM2" , streamLog2);
|
||||
OpmLog::addBackend("STREAM3" , streamLog3);
|
||||
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("STREAM1"));
|
||||
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("STREAM2"));
|
||||
BOOST_CHECK_EQUAL( true , OpmLog::hasBackend("STREAM3"));
|
||||
streamLog1->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false, true));
|
||||
streamLog2->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(Log::MessageType::Info, true));
|
||||
streamLog3->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false));
|
||||
}
|
||||
|
||||
OpmLog::warning("Warning");
|
||||
OpmLog::error("Error");
|
||||
OpmLog::info("Info");
|
||||
OpmLog::bug("Bug");
|
||||
|
||||
const std::string expected1 = Log::colorCodeMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Error, "Error") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Info, "Info") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Bug, "Bug") + "\n";
|
||||
|
||||
const std::string expected2 = Log::colorCodeMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Error, "Error") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Info, "Info: Info") + "\n"
|
||||
+ Log::colorCodeMessage(Log::MessageType::Bug, "Bug") + "\n";
|
||||
|
||||
const std::string expected3 = Log::prefixMessage(Log::MessageType::Warning, "Warning") + "\n"
|
||||
+ Log::prefixMessage(Log::MessageType::Error, "Error") + "\n"
|
||||
+ "Info" + "\n"
|
||||
+ Log::prefixMessage(Log::MessageType::Bug, "Bug") + "\n";
|
||||
|
||||
BOOST_CHECK_EQUAL(log_stream1.str(), expected1);
|
||||
BOOST_CHECK_EQUAL(log_stream2.str(), expected2);
|
||||
BOOST_CHECK_EQUAL(log_stream3.str(), expected3);
|
||||
}
|
||||
|
||||
159
tests/test_messagelimiter.cpp
Normal file
159
tests/test_messagelimiter.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#define BOOST_TEST_DYN_LINK
|
||||
#define BOOST_TEST_MODULE MESSAGELIMITER_TESTS
|
||||
|
||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
||||
|
||||
#include <opm/common/OpmLog/MessageLimiter.hpp>
|
||||
#include <opm/common/OpmLog/LogUtil.hpp>
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ConstructionAndLimits)
|
||||
{
|
||||
MessageLimiter m1;
|
||||
BOOST_CHECK_EQUAL(m1.tagMessageLimit(), MessageLimiter::NoLimit);
|
||||
MessageLimiter m2(0);
|
||||
BOOST_CHECK_EQUAL(m2.tagMessageLimit(), 0);
|
||||
MessageLimiter m3(1);
|
||||
BOOST_CHECK_EQUAL(m3.tagMessageLimit(), 1);
|
||||
MessageLimiter m4(-4);
|
||||
BOOST_CHECK_EQUAL(m4.tagMessageLimit(), MessageLimiter::NoLimit);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TagResponse)
|
||||
{
|
||||
using namespace Opm;
|
||||
{
|
||||
// No limits.
|
||||
MessageLimiter m;
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 6);
|
||||
}
|
||||
|
||||
{
|
||||
// Limit == 0.
|
||||
MessageLimiter m(0);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
// Limit == 1.
|
||||
MessageLimiter m(1);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(CategoryResponse)
|
||||
{
|
||||
using namespace Opm;
|
||||
{
|
||||
// No limits.
|
||||
MessageLimiter m;
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 3);
|
||||
}
|
||||
|
||||
{
|
||||
// Limit == 0.
|
||||
MessageLimiter m(MessageLimiter::NoLimit,
|
||||
{{ Log::MessageType::Info, 0 }});
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::JustOverCategoryLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::OverCategoryLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::OverCategoryLimit);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 3);
|
||||
}
|
||||
|
||||
{
|
||||
// Limit == 1.
|
||||
MessageLimiter m(MessageLimiter::NoLimit,
|
||||
{{ Log::MessageType::Info, 1 }});
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::JustOverCategoryLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("", Log::MessageType::Info) == MessageLimiter::Response::OverCategoryLimit);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(MixedResponse)
|
||||
{
|
||||
using namespace Opm;
|
||||
{
|
||||
// Tag Limit == 1. Category limit = 0.
|
||||
MessageLimiter m(1, {{ Log::MessageType::Info, 0 }});
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::JustOverCategoryLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverCategoryLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 2);
|
||||
}
|
||||
|
||||
{
|
||||
// Tag Limit == 0. Category limit = 1.
|
||||
MessageLimiter m(0, {{ Log::MessageType::Info, 1 }});
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 0);
|
||||
}
|
||||
|
||||
{
|
||||
// Tag Limit == 1. Category limit = 1.
|
||||
MessageLimiter m(1, {{ Log::MessageType::Info, 1 }});
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::PrintMessage);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::JustOverCategoryLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::JustOverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag1", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.handleMessageLimits("tag2", Log::MessageType::Info) == MessageLimiter::Response::OverTagLimit);
|
||||
BOOST_CHECK(m.categoryMessageCounts().at(Log::MessageType::Info) == 2);
|
||||
}
|
||||
|
||||
}
|
||||
90
travis/build-and-test.sh
Executable file
90
travis/build-and-test.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
build_order=(opm-common opm-parser opm-material opm-output opm-core opm-grid ewoms opm-simulators opm-upscaling)
|
||||
|
||||
# This shell script should be started with the name of a module as
|
||||
# only only command line argument. It will start by building all
|
||||
# upstream modules, then it will build and test the module of interest
|
||||
# and all downstream modules.
|
||||
#
|
||||
# Before invoking this script all the modules should have been cloned
|
||||
# in sibling directories, so that this script will see this directory
|
||||
# structure:
|
||||
#
|
||||
# opm-common/
|
||||
# opm-parser/
|
||||
# opm-material/
|
||||
# opm-output/
|
||||
# opm-core/
|
||||
# opm-grid/
|
||||
# opm-simulators/
|
||||
# opm-upscaling/
|
||||
#
|
||||
#
|
||||
# This can typically be achived by using the 'clone-opm.sh' script.
|
||||
|
||||
|
||||
function upstream_build {
|
||||
project=${1}
|
||||
echo "Building: ${project}"
|
||||
mkdir -p ${project}/build
|
||||
pushd ${project}/build > /dev/null
|
||||
cmake ../ -DENABLE_PYTHON=ON -DBUILD_TESTING=OFF -DSILENCE_EXTERNAL_WARNINGS=True -DUSE_QUADMATH=OFF -DADD_DISABLED_CTESTS=OFF
|
||||
make
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
|
||||
function downstream_build_and_test {
|
||||
project=${1}
|
||||
echo "Building and testing: ${project}"
|
||||
mkdir -p ${project}/build
|
||||
pushd ${project}/build > /dev/null
|
||||
# The build commands cmake, make and ctest must be given as
|
||||
# separate commands and not chained with &&. If chaining with &&
|
||||
# is used the 'set -e' does not exit on first error.
|
||||
cmake ../ -DENABLE_PYTHON=ON -DBUILD_TESTING=ON -DSILENCE_EXTERNAL_WARNINGS=True -DUSE_QUADMATH=OFF -DADD_DISABLED_CTESTS=OFF
|
||||
make
|
||||
ctest --output-on-failure
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
export CONDA_HOME="$HOME/miniconda"
|
||||
export PATH="$CONDA_HOME/bin:$PATH"
|
||||
|
||||
|
||||
for i in "${!build_order[@]}"; do
|
||||
if [[ "${build_order[$i]}" = "$1" ]]; then
|
||||
project_index=$i
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z ${project_index} ]]; then
|
||||
echo "${0}: Project: ${1} not recognized."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
build_index=0
|
||||
|
||||
|
||||
while [ $build_index -lt ${project_index} ];
|
||||
do
|
||||
project=${build_order[$build_index]}
|
||||
upstream_build ${project}
|
||||
build_index=$((build_index + 1))
|
||||
done
|
||||
|
||||
|
||||
|
||||
while [ $build_index -lt ${#build_order[@]} ]
|
||||
do
|
||||
project=${build_order[$build_index]}
|
||||
downstream_build_and_test ${project}
|
||||
build_index=$((build_index + 1))
|
||||
done
|
||||
|
||||
84
travis/build-prereqs.sh
Executable file
84
travis/build-prereqs.sh
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# This script should build all the OPM dependencies which are installed from source.
|
||||
|
||||
|
||||
# The build_dune function should take the module name as the first
|
||||
# argument. By default the script will clone the source from:
|
||||
#
|
||||
# https://github.com/dune-project/${project}.git
|
||||
#
|
||||
# But you can optionally supply a git url as second argument, i.e.
|
||||
#
|
||||
# build_dune dune-alugrid https://gitlab.dune-project.org/extensions/dune-alugrid.git
|
||||
#
|
||||
# to build the dune-alugrid module which is not found at github.
|
||||
|
||||
function build_dune {
|
||||
project=$1
|
||||
if [[ $# -eq 1 ]]; then
|
||||
url=https://github.com/dune-project/${project}.git
|
||||
else
|
||||
url=$2
|
||||
fi
|
||||
pushd . > /dev/null
|
||||
git clone ${url}
|
||||
cd ${project}
|
||||
git checkout tags/v2.3.1
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ../
|
||||
make
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
|
||||
|
||||
function build_superlu {
|
||||
pushd . > /dev/null
|
||||
git clone https://github.com/starseeker/SuperLU.git
|
||||
cd SuperLU
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -D CMAKE_INSTALL_PREFIX=.. -D SUPERLU_BUILD_EXAMPLES=OFF -D SUPERLU_ENABLE_TESTING=OFF ../
|
||||
make install
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
|
||||
function install_python_deps {
|
||||
export TRAVIS_PYTHON_VERSION="2.7"
|
||||
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
|
||||
bash miniconda.sh -b -p $HOME/miniconda
|
||||
export CONDA_HOME="$HOME/miniconda"
|
||||
export PATH="$CONDA_HOME/bin:$PATH"
|
||||
hash -r
|
||||
conda config --set always_yes yes --set changeps1 no
|
||||
conda update -q conda
|
||||
|
||||
conda install numpy
|
||||
}
|
||||
|
||||
|
||||
function build_ert {
|
||||
install_python_deps
|
||||
git clone https://github.com/Ensembles/ert.git
|
||||
mkdir -p ert/build
|
||||
pushd ert/build > /dev/null
|
||||
cmake .. && make
|
||||
popd > /dev/null
|
||||
}
|
||||
|
||||
|
||||
#################################################################
|
||||
|
||||
build_superlu
|
||||
build_ert
|
||||
|
||||
build_dune dune-common
|
||||
build_dune dune-istl
|
||||
build_dune dune-geometry
|
||||
build_dune dune-grid
|
||||
build_dune dune-localfunctions
|
||||
26
travis/clone-opm.sh
Executable file
26
travis/clone-opm.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
project_list=(opm-data opm-parser opm-material ewoms opm-core opm-output opm-grid opm-simulators opm-upscaling)
|
||||
|
||||
# Will clone all the projects *except* the one project given as
|
||||
# commandline argument; that has typically been checked out by travis
|
||||
# already. Will not clone opm-commone because that should already be
|
||||
# present, either because it is the current repository - or because
|
||||
# that must be cloned specifically from the other modules first.
|
||||
|
||||
|
||||
function clone_project {
|
||||
url=https://github.com/OPM/${1}.git
|
||||
git clone $url
|
||||
}
|
||||
|
||||
|
||||
for project in "${project_list[@]}"; do
|
||||
if [ "$project" != $1 ]; then
|
||||
clone_project $project
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user