Compare commits
26 Commits
release/20
...
release/20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1371b5706d | ||
|
|
b571dd9d66 | ||
|
|
ad746440e0 | ||
|
|
2bae3b2300 | ||
|
|
75a2a7e0ee | ||
|
|
917fc523ad | ||
|
|
28e492ecb9 | ||
|
|
ec1c315968 | ||
|
|
cf72ef0330 | ||
|
|
10a3bc4b56 | ||
|
|
8b4d8f1734 | ||
|
|
7cea357930 | ||
|
|
720fb8dcab | ||
|
|
8e56b44201 | ||
|
|
b14c5fc1a9 | ||
|
|
565d6b76dc | ||
|
|
ac840312e7 | ||
|
|
5e800ae2e7 | ||
|
|
2e0583cc74 | ||
|
|
8365eaed0b | ||
|
|
571582c881 | ||
|
|
6439ae1cea | ||
|
|
e796916057 | ||
|
|
63b663228a | ||
|
|
bf475b73b4 | ||
|
|
1e734020f1 |
184
CMakeLists.txt
184
CMakeLists.txt
@@ -1,5 +1,5 @@
|
||||
project(opm-common C CXX)
|
||||
cmake_minimum_required (VERSION 3.10)
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||
@@ -10,7 +10,7 @@ option(ENABLE_ECL_OUTPUT "Enable eclipse output support?" ON)
|
||||
option(ENABLE_MOCKSIM "Build the mock simulator for io testing" ON)
|
||||
option(OPM_ENABLE_PYTHON "Enable python bindings?" OFF)
|
||||
option(OPM_INSTALL_PYTHON "Enable python bindings?" OFF)
|
||||
option(OPM_ENABLE_EMBEDDED_PYTHON "Enable embedded python?" OFF)
|
||||
option(OPM_ENABLE_EMBEDDED_PYTHON "Enable python bindings?" OFF)
|
||||
|
||||
# Output implies input
|
||||
if(ENABLE_ECL_OUTPUT)
|
||||
@@ -42,13 +42,11 @@ set(OPM_PROJECT_EXTRA_CODE_INTREE "#ENABLE_ECL_INPUT is needed by opm-common-pre
|
||||
if(ENABLE_ECL_OUTPUT)
|
||||
set(OPM_PROJECT_EXTRA_CODE_INSTALLED "${OPM_PROJECT_EXTRA_CODE_INSTALLED}
|
||||
set(COMPARE_ECL_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/compareECL)
|
||||
set(OPM_PACK_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/opmpack)
|
||||
set(RST_DECK_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/rst_deck)")
|
||||
set(OPM_PACK_COMMAND ${CMAKE_INSTALL_PREFIX}/bin${${name}_VER_DIR}/opmpack)")
|
||||
|
||||
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
|
||||
set(COMPARE_ECL_COMMAND ${PROJECT_BINARY_DIR}/bin/compareECL)
|
||||
set(OPM_PACK_COMMAND ${PROJECT_BINARY_DIR}/bin/opmpack)
|
||||
set(RST_DECK_COMMAND ${PROJECT_BINARY_DIR}/bin/rst_deck)")
|
||||
set(OPM_PACK_COMMAND ${PROJECT_BINARY_DIR}/bin/opmpack)")
|
||||
endif()
|
||||
|
||||
# project information is in dune.module. Read this file and set variables.
|
||||
@@ -66,20 +64,6 @@ include(Findopm-tests)
|
||||
# with the find module
|
||||
include (${project}-prereqs)
|
||||
|
||||
if(ENABLE_ECL_INPUT)
|
||||
# source_hook runs before config_hook and the former needs fmt, hence this
|
||||
# needs to be here.
|
||||
if(fmt_FOUND)
|
||||
# OpmSatellites will not add the library, do it here.
|
||||
list(APPEND opm-common_LIBRARIES fmt::fmt)
|
||||
else()
|
||||
add_definitions(-DFMT_HEADER_ONLY)
|
||||
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
|
||||
# Not sure why this is needed.
|
||||
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/fmtlib/include)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# read the list of components from this file (in the project directory);
|
||||
# it should set various lists with the names of the files to include
|
||||
include (CMakeLists_files.cmake)
|
||||
@@ -89,9 +73,9 @@ macro (config_hook)
|
||||
if(NOT cjson_FOUND)
|
||||
list(APPEND EXTRA_INCLUDES ${PROJECT_SOURCE_DIR}/external/cjson)
|
||||
endif()
|
||||
|
||||
# For this project
|
||||
include_directories(${EXTRA_INCLUDES} ${PROJECT_BINARY_DIR}/include)
|
||||
|
||||
# For downstreams
|
||||
list(APPEND EXTRA_INCLUDES ${PROJECT_BINARY_DIR}/include)
|
||||
set(OPM_PROJECT_EXTRA_CODE_INTREE "${OPM_PROJECT_EXTRA_CODE_INTREE}
|
||||
@@ -109,7 +93,8 @@ macro (config_hook)
|
||||
set(HAVE_ECL_OUTPUT 1)")
|
||||
endif()
|
||||
|
||||
find_package(Boost COMPONENTS filesystem regex system unit_test_framework)
|
||||
# Configure boost targets for old cmake
|
||||
include(cmake/Modules/BoostTargets.cmake)
|
||||
|
||||
if (HAVE_DYNAMIC_BOOST_TEST)
|
||||
set_target_properties(Boost::unit_test_framework PROPERTIES INTERFACE_COMPILE_DEFINITIONS BOOST_TEST_DYN_LINK=1)
|
||||
@@ -130,9 +115,6 @@ macro (sources_hook)
|
||||
foreach (name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
|
||||
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/ParserKeywords/${name}.cpp)
|
||||
endforeach()
|
||||
if (OPM_ENABLE_PYTHON)
|
||||
list(INSERT opm-common_SOURCES 0 ${PROJECT_BINARY_DIR}/python/cxx/builtin_pybind11.cpp)
|
||||
endif()
|
||||
endif()
|
||||
set_source_files_properties(src/opm/parser/eclipse/Python/Python.cpp
|
||||
PROPERTIES COMPILE_FLAGS -Wno-shadow)
|
||||
@@ -163,58 +145,10 @@ endmacro (install_hook)
|
||||
# OpmnLibMain function. Here only the library dependency is implemented, the
|
||||
# bulk of the python configuration is further down in the file.
|
||||
if (OPM_ENABLE_PYTHON)
|
||||
# We need to be compatible with older CMake versions
|
||||
# that do not offer FindPython3
|
||||
# e.g. Ubuntu LTS 18.04 uses cmake 3.10
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
|
||||
find_package(PythonInterp REQUIRED)
|
||||
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
||||
find_package(PythonLibs REQUIRED)
|
||||
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARIES})
|
||||
endif()
|
||||
if(PYTHON_VERSION_MAJOR LESS 3)
|
||||
message(SEND_ERROR "OPM requires version 3 of Python but only version ${PYTHON_VERSION_STRING} was found")
|
||||
endif()
|
||||
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
|
||||
else()
|
||||
# Be backwards compatible.
|
||||
if(PYTHON_EXECUTABLE AND NOT Python3_EXECUTABLE)
|
||||
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
endif()
|
||||
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||||
get_target_property(_lib_path Python3::Python IMPORTED_LOCATION)
|
||||
set(PYTHON_LIBRARY ${_lib_path})
|
||||
set(PYTHON_LIBRARIES {PYTHON_LIBRARY})
|
||||
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARY})
|
||||
set(PYTHON_INCLUDE_DIRS ${Python3_INCLUDE_DIRS})
|
||||
else()
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
endif()
|
||||
# Compatibility settings for PythonInterp and PythonLibs
|
||||
# used e.g. in FindCwrap, pybind11
|
||||
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
|
||||
endif()
|
||||
# We always need the PYTHON_INCLUDE_DIR. Unfortunately
|
||||
# When we build pypi packages CMake will fail to determine
|
||||
# these via the usual find_package(PythonLibs or
|
||||
# find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||||
# Hence we overwrite them here.
|
||||
if(NOT PYTHON_INCLUDE_DIRS)
|
||||
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" "from distutils import sysconfig; print(sysconfig.get_python_inc(plat_specific=True), end=\"\");"
|
||||
RESULT_VARIABLE _PYTHON_DIR_SUCCESS
|
||||
OUTPUT_VARIABLE PYTHON_INCLUDE_DIR
|
||||
ERROR_VARIABLE _PYTHON_ERROR_VALUE)
|
||||
if(NOT _PYTHON_DIR_SUCCESS MATCHES 0)
|
||||
message(FATAL_ERROR "Could not determine Python include directory. Error: ${_PYTHON_ERROR_VALUE}.")
|
||||
endif()
|
||||
set(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
|
||||
endif()
|
||||
find_package(pybind11 2.2 CONFIG)
|
||||
if (NOT pybind11_FOUND)
|
||||
# Use full path for reuse with pypi
|
||||
set(pybind11_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/python/pybind11/include ${PYTHON_INCLUDE_DIRS})
|
||||
find_package(PythonInterp REQUIRED)
|
||||
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
||||
find_package(PythonLibs REQUIRED)
|
||||
list(APPEND opm-common_LIBRARIES ${PYTHON_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -243,10 +177,6 @@ if (ENABLE_MOCKSIM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ENABLE_SCHEDULE_DEBUG)
|
||||
add_compile_definitions( SCHEDULE_DEBUG )
|
||||
endif()
|
||||
|
||||
# Build the compare utilities
|
||||
if(ENABLE_ECL_INPUT)
|
||||
add_executable(compareECL
|
||||
@@ -263,11 +193,11 @@ if(ENABLE_ECL_INPUT)
|
||||
test_util/summary.cpp
|
||||
)
|
||||
|
||||
add_executable(rewriteEclFile
|
||||
test_util/rewriteEclFile.cpp
|
||||
add_executable(test_esmry_lod
|
||||
test_util/test_esmry_lod.cpp
|
||||
)
|
||||
|
||||
foreach(target compareECL convertECL summary rewriteEclFile)
|
||||
foreach(target compareECL convertECL summary test_esmry_lod)
|
||||
target_link_libraries(${target} opmcommon)
|
||||
install(TARGETS ${target} DESTINATION bin)
|
||||
endforeach()
|
||||
@@ -301,20 +231,15 @@ if(ENABLE_ECL_INPUT)
|
||||
${PROJECT_BINARY_DIR}/tests
|
||||
)
|
||||
|
||||
foreach(test test_EclIO test_EGrid test_ERft test_ERst test_ESmry test_EInit test_ExtESmry)
|
||||
foreach(test test_EclIO test_EGrid test_ERft test_ERst test_ESmry)
|
||||
opm_add_test(${test} CONDITION ENABLE_ECL_INPUT AND Boost_UNIT_TEST_FRAMEWORK_FOUND
|
||||
LIBRARIES ${_libs}
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/tests)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Install build system files and documentation
|
||||
install(DIRECTORY cmake
|
||||
DESTINATION share/opm USE_SOURCE_PERMISSIONS
|
||||
PATTERN "OPM-CMake.md" EXCLUDE)
|
||||
|
||||
install(FILES cmake/OPM-CMake.md
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
# Install build system files
|
||||
install(DIRECTORY cmake DESTINATION share/opm)
|
||||
|
||||
# Install tab completion skeleton
|
||||
install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc)
|
||||
@@ -327,28 +252,17 @@ if (OPM_ENABLE_PYTHON)
|
||||
else()
|
||||
set(PYTHON_PACKAGE_PATH "site-packages")
|
||||
endif()
|
||||
if(PYTHON_VERSION_MAJOR)
|
||||
set(PY_MAJOR ${PYTHON_VERSION_MAJOR})
|
||||
else()
|
||||
set(PY_MAJOR ${Python3_VERSION_MAJOR})
|
||||
endif()
|
||||
if(PYTHON_VERSION_MINOR)
|
||||
set(PY_MINOR ${PYTHON_VERSION_MINOR})
|
||||
else()
|
||||
set(PY_MINOR ${Python3_VERSION_MINOR})
|
||||
endif()
|
||||
set(PYTHON_INSTALL_PREFIX "lib/python${PY_MAJOR}.${PY_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
|
||||
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
|
||||
|
||||
make_directory(${PROJECT_BINARY_DIR}/python)
|
||||
get_target_property(_opmcommon_include_dirs opmcommon INCLUDE_DIRECTORIES)
|
||||
list(APPEND _opmcommon_include_dirs ${_ecl_include_dirs})
|
||||
string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}")
|
||||
|
||||
get_target_property(_opmcommon_lib_dirs opmcommon LINK_DIRECTORIES)
|
||||
if (CMAKE_PREFIX_PATH)
|
||||
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
|
||||
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR})
|
||||
else()
|
||||
list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
|
||||
set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib)
|
||||
endif()
|
||||
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
|
||||
|
||||
@@ -374,47 +288,26 @@ if (OPM_ENABLE_PYTHON)
|
||||
set( _rpath_arg "")
|
||||
endif()
|
||||
|
||||
set(opm-common_PYTHON_PACKAGE_VERSION ${OPM_PYTHON_PACKAGE_VERSION_TAG})
|
||||
|
||||
# Generate versioned setup.py
|
||||
if (pybind11_INCLUDE_DIRS)
|
||||
string(REGEX REPLACE ";" "', '" _tmp "${pybind11_INCLUDE_DIRS}")
|
||||
set(SETUP_PY_PYBIND_INCLUDE_DIR "'${_tmp}'")
|
||||
endif()
|
||||
|
||||
if (TARGET fmt::fmt)
|
||||
get_target_property(SETUP_PY_FMT_LIBS fmt::fmt LOCATION)
|
||||
get_target_property(FMT_FLAGS fmt::fmt INTERFACE_COMPILE_DEFINITIONS)
|
||||
foreach(flag ${FMT_FLAGS})
|
||||
set(SETUP_PY_FMT_FLAGS "${SETUP_PY_FMT_FLAGS} '-D${flag}',")
|
||||
endforeach()
|
||||
list(APPEND opm-common_PYTHON_LINKAGE "'${SETUP_PY_FMT_LIBS}'")
|
||||
else()
|
||||
set(SETUP_PY_FMT_FLAGS "'-DFMT_HEADER_ONLY'")
|
||||
endif()
|
||||
|
||||
configure_file (${PROJECT_SOURCE_DIR}/python/setup.py.in ${PROJECT_BINARY_DIR}/python/setup.py)
|
||||
file(COPY ${PROJECT_SOURCE_DIR}/python/README.md DESTINATION ${PROJECT_BINARY_DIR}/python)
|
||||
execute_process(COMMAND ${Python3_EXECUTABLE} target_name.py
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} target_name.py
|
||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python
|
||||
OUTPUT_VARIABLE python_lib_target)
|
||||
|
||||
add_custom_target(copy_python ALL
|
||||
COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0)
|
||||
|
||||
add_custom_command(OUTPUT python/opm/${python_lib_target}
|
||||
add_custom_command(OUTPUT python/python/opm/${python_lib_target}
|
||||
DEPENDS ${PYTHON_CXX_DEPENDS}
|
||||
DEPENDS copy_python
|
||||
COMMAND ${Python3_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py
|
||||
build
|
||||
build_ext
|
||||
--build-lib=${PROJECT_BINARY_DIR}/python
|
||||
--build-lib=${PROJECT_BINARY_DIR}/python/python/opm
|
||||
--library-dirs=${_setup_lib_dirs}
|
||||
${_rpath_arg}
|
||||
--include-dirs=${_setup_include_dirs}
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
||||
COMMENT "Building python bindings at python/opm/${python_lib_target}")
|
||||
add_custom_target(opmcommon_python ALL DEPENDS python/opm/${python_lib_target})
|
||||
COMMENT "Building python bindings")
|
||||
add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/${python_lib_target})
|
||||
add_dependencies(opmcommon_python opmcommon)
|
||||
|
||||
# The install target is based on manually copying the python file tree to the
|
||||
@@ -429,7 +322,7 @@ if (OPM_ENABLE_PYTHON)
|
||||
# setup.py install manually - optionally with the generated script
|
||||
# setup-install.sh - and completely bypass cmake in the installation phase.
|
||||
if (OPM_INSTALL_PYTHON)
|
||||
install( CODE "execute_process(COMMAND ${Python3_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
|
||||
install( CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)")
|
||||
endif()
|
||||
|
||||
# Observe that if the opmcommon library has been built as a shared library the
|
||||
@@ -437,11 +330,11 @@ if (OPM_ENABLE_PYTHON)
|
||||
# testing.
|
||||
add_test(NAME python_tests
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python
|
||||
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${Python3_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python test
|
||||
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${PYTHON_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python/python/opm test
|
||||
)
|
||||
|
||||
set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python)
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python/python)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Let cmake configure some small shell scripts which can be used to simplify
|
||||
@@ -451,11 +344,6 @@ if (OPM_ENABLE_PYTHON)
|
||||
DESTINATION ${PROJECT_BINARY_DIR}
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
||||
|
||||
configure_file(python/setup-package.sh.in tmp/setup-package.sh)
|
||||
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-package.sh
|
||||
DESTINATION ${PROJECT_BINARY_DIR}
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE )
|
||||
|
||||
configure_file(python/setup-test.sh.in tmp/setup-test.sh)
|
||||
file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh
|
||||
DESTINATION ${PROJECT_BINARY_DIR}
|
||||
@@ -470,17 +358,11 @@ if (OPM_ENABLE_PYTHON)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# 2: Embed the Python interpreter for keywords like PYACTION and PYINPUT
|
||||
target_include_directories(opmcommon SYSTEM PRIVATE "${pybind11_INCLUDE_DIRS}")
|
||||
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
||||
add_subdirectory(python/pybind11)
|
||||
target_include_directories(opmcommon SYSTEM PRIVATE "python/pybind11/include;${PYTHON_INCLUDE_DIRS}")
|
||||
target_link_libraries(opmcommon PUBLIC ${PYTHON_LIBRARY})
|
||||
|
||||
add_definitions(-DEMBEDDED_PYTHON)
|
||||
endif()
|
||||
else()
|
||||
if (OPM_ENABLE_EMBEDDED_PYTHON)
|
||||
message(WARNING "Inconsistent settings OPM_ENABLE_PYTHON / OPM_ENABLE_EMBEDDED_PYTHON")
|
||||
set(OPM_ENABLE_EMBEDDED_PYTHON OFF CACHE BOOL "Enable embedded python?" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(DIRECTORY docs/man1 DESTINATION ${CMAKE_INSTALL_MANDIR}
|
||||
FILES_MATCHING PATTERN "*.1")
|
||||
|
||||
@@ -21,20 +21,18 @@
|
||||
# the library needs it.
|
||||
|
||||
list (APPEND MAIN_SOURCE_FILES
|
||||
src/opm/common/data/SimulationDataContainer.cpp
|
||||
src/opm/common/OpmLog/CounterLog.cpp
|
||||
src/opm/common/OpmLog/EclipsePRTLog.cpp
|
||||
src/opm/common/OpmLog/LogBackend.cpp
|
||||
src/opm/common/OpmLog/Logger.cpp
|
||||
src/opm/common/OpmLog/LogUtil.cpp
|
||||
src/opm/common/OpmLog/KeywordLocation.cpp
|
||||
src/opm/common/OpmLog/InfoLogger.cpp
|
||||
src/opm/common/OpmLog/OpmLog.cpp
|
||||
src/opm/common/OpmLog/StreamLog.cpp
|
||||
src/opm/common/OpmLog/TimerLog.cpp
|
||||
src/opm/common/utility/ActiveGridCells.cpp
|
||||
src/opm/common/utility/FileSystem.cpp
|
||||
src/opm/common/utility/numeric/MonotCubicInterpolator.cpp
|
||||
src/opm/common/utility/OpmInputError.cpp
|
||||
src/opm/common/utility/parameters/Parameter.cpp
|
||||
src/opm/common/utility/parameters/ParameterGroup.cpp
|
||||
src/opm/common/utility/parameters/ParameterTools.cpp
|
||||
@@ -46,31 +44,24 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/io/eclipse/SummaryNode.cpp
|
||||
src/opm/json/JsonObject.cpp
|
||||
src/opm/parser/eclipse/Deck/Deck.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckTree.cpp
|
||||
src/opm/parser/eclipse/Deck/FileDeck.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckItem.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckValue.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckKeyword.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckRecord.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckOutput.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckSection.cpp
|
||||
src/opm/parser/eclipse/Deck/ImportContainer.cpp
|
||||
src/opm/parser/eclipse/Deck/UDAValue.cpp
|
||||
src/opm/parser/eclipse/Python/Python.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/PyAction.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/AquiferConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/AquiferCT.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/Aquifetp.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/Aquancon.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/AquiferHelpers.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferCell.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferConnection.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/SingleNumericalAquifer.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquifers.cpp
|
||||
src/opm/parser/eclipse/EclipseState/AquiferConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/AquiferCT.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquifetp.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Aquancon.cpp
|
||||
src/opm/parser/eclipse/EclipseState/checkDeck.cpp
|
||||
src/opm/parser/eclipse/EclipseState/EclipseConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/EclipseState.cpp
|
||||
src/opm/parser/eclipse/EclipseState/EndpointScaling.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Edit/EDITNNC.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/Box.cpp
|
||||
@@ -81,22 +72,20 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/Grid/Fault.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/FaultFace.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/GridDims.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/MapAxes.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/NNC.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/Operate.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/PinchMode.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/setKeywordBox.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/TranCalculator.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Grid/TransMult.cpp
|
||||
src/opm/parser/eclipse/EclipseState/InitConfig/Equil.cpp
|
||||
src/opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/InitConfig/InitConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Runspec.cpp
|
||||
src/opm/parser/eclipse/EclipseState/TracerConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/MICPpara.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.cpp
|
||||
@@ -107,13 +96,8 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/Enums.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Events.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.cpp
|
||||
@@ -121,45 +105,31 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSale.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GConSump.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/KeywordHandlers.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/injection.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MessageLimits.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Network/Balance.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/RFTConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/RPTConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/RSTConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/ScheduleDeck.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/ScheduleState.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Tuning.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/WriteRestartFileEvents.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/injection.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/PAvg.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculatorCollection.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/NameOrder.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellMatcher.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WList.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellEconProductionLimits.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellFoamProperties.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellMICPProperties.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellPolymerProperties.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellBrineProperties.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/Well/WellTracerProperties.cpp
|
||||
@@ -171,20 +141,16 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.cpp
|
||||
src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/Aqudims.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/DenT.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/Eqldims.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/JFunc.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/PvtxTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/Regdims.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/SimpleTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/PolyInjTables.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/StandardCond.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/TableContainer.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/TableIndex.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp
|
||||
@@ -192,9 +158,7 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Tables/Tabdims.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParser.cpp
|
||||
@@ -203,13 +167,11 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQAssign.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQToken.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.cpp
|
||||
src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp
|
||||
src/opm/parser/eclipse/Parser/ErrorGuard.cpp
|
||||
@@ -225,6 +187,7 @@ if(ENABLE_ECL_INPUT)
|
||||
src/opm/parser/eclipse/Units/Dimension.cpp
|
||||
src/opm/parser/eclipse/Units/UnitSystem.cpp
|
||||
src/opm/parser/eclipse/Utility/Functional.cpp
|
||||
src/opm/parser/eclipse/Utility/Stringview.cpp
|
||||
)
|
||||
|
||||
|
||||
@@ -242,7 +205,6 @@ if(ENABLE_ECL_INPUT)
|
||||
python/cxx/eclipse_config.cpp
|
||||
python/cxx/eclipse_grid.cpp
|
||||
python/cxx/eclipse_state.cpp
|
||||
python/cxx/emodel_util.cpp
|
||||
python/cxx/export.cpp
|
||||
python/cxx/group.cpp
|
||||
python/cxx/log.cpp
|
||||
@@ -279,37 +241,26 @@ if(ENABLE_ECL_OUTPUT)
|
||||
src/opm/io/eclipse/EclOutput.cpp
|
||||
src/opm/io/eclipse/EclUtil.cpp
|
||||
src/opm/io/eclipse/EGrid.cpp
|
||||
src/opm/io/eclipse/EInit.cpp
|
||||
src/opm/io/eclipse/ERft.cpp
|
||||
src/opm/io/eclipse/ERst.cpp
|
||||
src/opm/io/eclipse/ERsm.cpp
|
||||
src/opm/io/eclipse/ESmry.cpp
|
||||
src/opm/io/eclipse/ExtESmry.cpp
|
||||
src/opm/io/eclipse/ESmry_write_rsm.cpp
|
||||
src/opm/io/eclipse/OutputStream.cpp
|
||||
src/opm/io/eclipse/ExtSmryOutput.cpp
|
||||
src/opm/io/eclipse/RestartFileView.cpp
|
||||
src/opm/io/eclipse/SummaryNode.cpp
|
||||
src/opm/io/eclipse/rst/action.cpp
|
||||
src/opm/io/eclipse/rst/aquifer.cpp
|
||||
src/opm/io/eclipse/rst/connection.cpp
|
||||
src/opm/io/eclipse/rst/group.cpp
|
||||
src/opm/io/eclipse/rst/header.cpp
|
||||
src/opm/io/eclipse/rst/udq.cpp
|
||||
src/opm/io/eclipse/rst/segment.cpp
|
||||
src/opm/io/eclipse/rst/state.cpp
|
||||
src/opm/io/eclipse/rst/well.cpp
|
||||
src/opm/output/eclipse/ActiveIndexByColumns.cpp
|
||||
src/opm/output/eclipse/AggregateActionxData.cpp
|
||||
src/opm/output/eclipse/AggregateAquiferData.cpp
|
||||
src/opm/output/eclipse/AggregateConnectionData.cpp
|
||||
src/opm/output/eclipse/AggregateGroupData.cpp
|
||||
src/opm/output/eclipse/AggregateNetworkData.cpp
|
||||
src/opm/output/eclipse/AggregateMSWData.cpp
|
||||
src/opm/output/eclipse/AggregateUDQData.cpp
|
||||
src/opm/output/eclipse/AggregateWellData.cpp
|
||||
src/opm/output/eclipse/AggregateWListData.cpp
|
||||
src/opm/output/eclipse/CreateActionRSTDims.cpp
|
||||
src/opm/output/eclipse/CreateActionxDims.cpp
|
||||
src/opm/output/eclipse/CreateDoubHead.cpp
|
||||
src/opm/output/eclipse/CreateInteHead.cpp
|
||||
src/opm/output/eclipse/CreateLogiHead.cpp
|
||||
@@ -322,19 +273,15 @@ if(ENABLE_ECL_OUTPUT)
|
||||
src/opm/output/eclipse/LoadRestart.cpp
|
||||
src/opm/output/eclipse/LogiHEAD.cpp
|
||||
src/opm/output/eclipse/RestartIO.cpp
|
||||
src/opm/output/eclipse/Inplace.cpp
|
||||
src/opm/output/eclipse/Summary.cpp
|
||||
src/opm/output/eclipse/Tables.cpp
|
||||
src/opm/output/eclipse/UDQDims.cpp
|
||||
src/opm/output/eclipse/RegionCache.cpp
|
||||
src/opm/output/eclipse/RestartValue.cpp
|
||||
src/opm/output/eclipse/WriteInit.cpp
|
||||
src/opm/output/eclipse/WriteRFT.cpp
|
||||
src/opm/output/eclipse/WriteRPT.cpp
|
||||
src/opm/output/eclipse/report/WELSPECS.cpp
|
||||
src/opm/output/data/Aquifer.cpp
|
||||
src/opm/output/data/Solution.cpp
|
||||
src/opm/utility/EModel.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -343,13 +290,12 @@ list (APPEND TEST_SOURCE_FILES
|
||||
tests/test_calculateCellVol.cpp
|
||||
tests/test_cmp.cpp
|
||||
tests/test_cubic.cpp
|
||||
tests/test_FileSystem.cpp
|
||||
tests/test_messagelimiter.cpp
|
||||
tests/test_nonuniformtablelinear.cpp
|
||||
tests/test_OpmInputError_format.cpp
|
||||
tests/test_OpmLog.cpp
|
||||
tests/test_param.cpp
|
||||
tests/test_RootFinders.cpp
|
||||
tests/test_SimulationDataContainer.cpp
|
||||
tests/test_sparsevector.cpp
|
||||
tests/test_uniformtablelinear.cpp
|
||||
)
|
||||
@@ -357,8 +303,6 @@ if(ENABLE_ECL_INPUT)
|
||||
list(APPEND TEST_SOURCE_FILES
|
||||
tests/rst_test.cpp
|
||||
tests/test_ERsm.cpp
|
||||
tests/test_GuideRate.cpp
|
||||
tests/test_RestartFileView.cpp
|
||||
tests/parser/ACTIONX.cpp
|
||||
tests/parser/ADDREGTests.cpp
|
||||
tests/parser/AquiferTests.cpp
|
||||
@@ -369,6 +313,8 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/parser/CopyRegTests.cpp
|
||||
tests/parser/DeckValueTests.cpp
|
||||
tests/parser/DeckTests.cpp
|
||||
tests/parser/DynamicStateTests.cpp
|
||||
tests/parser/DynamicVectorTests.cpp
|
||||
tests/parser/EclipseGridTests.cpp
|
||||
tests/parser/EmbeddedPython.cpp
|
||||
tests/parser/EqualRegTests.cpp
|
||||
@@ -380,20 +326,16 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/parser/FunctionalTests.cpp
|
||||
tests/parser/GeomodifierTests.cpp
|
||||
tests/parser/GroupTests.cpp
|
||||
tests/parser/ImportTests.cpp
|
||||
tests/parser/InitConfigTest.cpp
|
||||
tests/parser/IOConfigTests.cpp
|
||||
tests/parser/MICPTests.cpp
|
||||
tests/parser/MessageLimitTests.cpp
|
||||
tests/parser/MultiRegTests.cpp
|
||||
tests/parser/MultisegmentWellTests.cpp
|
||||
tests/parser/MULTREGTScannerTests.cpp
|
||||
tests/parser/NetworkTests.cpp
|
||||
tests/parser/OrderedMapTests.cpp
|
||||
tests/parser/ParseContextTests.cpp
|
||||
tests/parser/ParseContext_EXIT1.cpp
|
||||
tests/parser/ParseDATAWithDefault.cpp
|
||||
tests/parser/PAvgTests.cpp
|
||||
tests/parser/PYACTION.cpp
|
||||
tests/parser/RawKeywordTests.cpp
|
||||
tests/parser/test_ReportConfig.cpp
|
||||
@@ -403,7 +345,6 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/parser/RockTableTests.cpp
|
||||
tests/parser/RunspecTests.cpp
|
||||
tests/parser/SaltTableTests.cpp
|
||||
tests/parser/ScheduleSerializeTest.cpp
|
||||
tests/parser/ScheduleRestartTests.cpp
|
||||
tests/parser/ScheduleTests.cpp
|
||||
tests/parser/SectionTests.cpp
|
||||
@@ -418,39 +359,33 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/parser/TableManagerTests.cpp
|
||||
tests/parser/TableSchemaTests.cpp
|
||||
tests/parser/ThresholdPressureTest.cpp
|
||||
tests/parser/TimeMapTest.cpp
|
||||
tests/parser/TracerTests.cpp
|
||||
tests/parser/TransMultTests.cpp
|
||||
tests/parser/TuningTests.cpp
|
||||
tests/parser/UDQTests.cpp
|
||||
tests/parser/UnitTests.cpp
|
||||
tests/parser/integration/NNCTests.cpp
|
||||
tests/parser/ValueTests.cpp
|
||||
tests/parser/WellSolventTests.cpp
|
||||
tests/parser/WellTracerTests.cpp
|
||||
tests/parser/WellTests.cpp
|
||||
tests/parser/WLIST.cpp
|
||||
tests/parser/WriteRestartFileEventsTests.cpp
|
||||
tests/parser/WTEST.cpp)
|
||||
endif()
|
||||
if(ENABLE_ECL_OUTPUT)
|
||||
list (APPEND TEST_SOURCE_FILES
|
||||
tests/test_ActiveIndexByColumns.cpp
|
||||
tests/test_AggregateActionxData.cpp
|
||||
tests/test_AggregateAquiferData.cpp
|
||||
tests/test_AggregateWellData.cpp
|
||||
tests/test_AggregateGroupData.cpp
|
||||
tests/test_AggregateNetworkData.cpp
|
||||
tests/test_AggregateWListData.cpp
|
||||
tests/test_AggregateMSWData.cpp
|
||||
tests/test_AggregateConnectionData.cpp
|
||||
tests/test_AggregateUDQData.cpp
|
||||
tests/test_ArrayDimChecker.cpp
|
||||
tests/test_data_GuideRateValue.cpp
|
||||
tests/test_EclipseIO.cpp
|
||||
tests/test_DoubHEAD.cpp
|
||||
tests/test_InteHEAD.cpp
|
||||
tests/test_LinearisedOutputTable.cpp
|
||||
tests/test_LogiHEAD.cpp
|
||||
tests/test_LGOData.cpp
|
||||
tests/test_OutputStream.cpp
|
||||
tests/test_regionCache.cpp
|
||||
tests/test_PaddedOutputString.cpp
|
||||
@@ -458,8 +393,6 @@ if(ENABLE_ECL_OUTPUT)
|
||||
tests/test_RFT.cpp
|
||||
tests/test_rst.cpp
|
||||
tests/test_Solution.cpp
|
||||
tests/test_Serializer.cpp
|
||||
tests/test_Inplace.cpp
|
||||
tests/test_Summary.cpp
|
||||
tests/test_Summary_Group.cpp
|
||||
tests/test_Tables.cpp
|
||||
@@ -474,8 +407,8 @@ list (APPEND TEST_DATA_FILES
|
||||
)
|
||||
if(ENABLE_ECL_OUTPUT)
|
||||
list (APPEND TEST_DATA_FILES
|
||||
tests/GDFILE_NO_ACTNUM.DATA
|
||||
tests/EGRID_NO_ACTNUM.FEGRID
|
||||
tests/expect-wdims.chldg.err.out
|
||||
tests/expect-wdims.err.out
|
||||
tests/BASE_SIM.DATA
|
||||
tests/BASE_SIM_THPRES.DATA
|
||||
tests/RESTART_SIM.DATA
|
||||
@@ -487,24 +420,13 @@ if(ENABLE_ECL_OUTPUT)
|
||||
tests/summary_deck_non_constant_porosity.DATA
|
||||
tests/SUMMARY_EFF_FAC.DATA
|
||||
tests/SPE1CASE1.DATA
|
||||
tests/SPE1CASE1_RPTONLY.DATA
|
||||
tests/SPE1CASE1_SUMTHIN.DATA
|
||||
tests/SPE1CASE1.SMSPEC
|
||||
tests/SPE1CASE1A.SMSPEC
|
||||
tests/SPE1CASE1B.DATA
|
||||
tests/props_spe1case1b.inc
|
||||
tests/SPE9_CP_PACKED.DATA
|
||||
tests/SOFR_TEST.DATA
|
||||
tests/UDQ_BASE.DATA
|
||||
tests/UDQ_RESTART.DATA
|
||||
tests/UDQ_ACTIONX.X0007
|
||||
tests/UDQ_ACTIONX.DATA
|
||||
tests/UDQ_ACTIONX_RESTART.DATA
|
||||
tests/UDQ_TEST_WCONPROD_IUAD-2.DATA
|
||||
tests/9_4C_WINJ_GINJ_UDQ_MSW-UDARATE_TEST_PACK.DATA
|
||||
tests/UDQ_ACTIONX_TEST1.DATA
|
||||
tests/UDQ_ACTIONX_TEST1_U.DATA
|
||||
tests/TEST_AGGREGATE_MSW.DATA
|
||||
tests/include_example_pvt.txt
|
||||
tests/include_example_summary.txt
|
||||
tests/include_sgof.txt
|
||||
@@ -512,17 +434,10 @@ if(ENABLE_ECL_OUTPUT)
|
||||
tests/include_grid_3x5x4.grdecl
|
||||
tests/SPE1CASE2.DATA
|
||||
tests/SPE1CASE2_RESTART.DATA
|
||||
tests/SPE1CASE2_RESTART_SKIPREST.DATA
|
||||
tests/SPE1CASE2.X0060
|
||||
tests/PYACTION.DATA
|
||||
tests/0A4_GRCTRL_LRAT_LRAT_GGR_BASE_MODEL2_MSW_ALL.DATA
|
||||
tests/MOD4_TEST_IGRP-DATA.DATA
|
||||
tests/2_WLIFT_MODEL5_NOINC.DATA
|
||||
tests/TEST_NETWORK_ALL.DATA
|
||||
tests/TEST_WLIST.DATA
|
||||
tests/act1.py
|
||||
tests/MSW.DATA
|
||||
tests/MSW_2WELSEGS.DATA
|
||||
tests/EXIT_TEST.DATA
|
||||
tests/action_syntax_error.py
|
||||
tests/action_missing_run.py
|
||||
@@ -531,7 +446,7 @@ if(ENABLE_ECL_OUTPUT)
|
||||
tests/msim/MSIM_PYACTION.DATA
|
||||
tests/msim/action1.py
|
||||
tests/msim/action2.py
|
||||
tests/VFP_CASE.DATA)
|
||||
)
|
||||
endif()
|
||||
|
||||
list (APPEND EXAMPLE_SOURCE_FILES
|
||||
@@ -540,13 +455,6 @@ if(ENABLE_ECL_INPUT)
|
||||
list (APPEND TEST_DATA_FILES
|
||||
tests/ECLFILE.INIT
|
||||
tests/ECLFILE.FINIT
|
||||
tests/LGR_TESTMOD.EGRID
|
||||
tests/LGR_TESTMOD.INIT
|
||||
tests/LGR_TESTMOD.UNRST
|
||||
tests/LGR_TESTMOD.X0002
|
||||
tests/MODEL1_IX.INIT
|
||||
tests/MODEL1_IX.SMSPEC
|
||||
tests/MODEL1_IX.UNSMRY
|
||||
tests/SPE1CASE1.EGRID
|
||||
tests/SPE1CASE1.RFT
|
||||
tests/SPE1_TESTCASE.UNRST
|
||||
@@ -557,21 +465,13 @@ if(ENABLE_ECL_INPUT)
|
||||
tests/SPE1CASE1A.UNSMRY
|
||||
tests/SPE1CASE1_RST60.SMSPEC
|
||||
tests/SPE1CASE1_RST60.UNSMRY
|
||||
tests/SPE1CASE1_RST60.ESMRY
|
||||
tests/MODEL2_RESTART.DATA
|
||||
tests/restart/MODEL2.UNRST
|
||||
tests/UDQ_WCONPROD.DATA
|
||||
tests/UDQ_WCONPROD_GRID.grdecl
|
||||
tests/UDQ_WCONPROD_RESTART.DATA
|
||||
tests/UDQ_WCONPROD.X0006
|
||||
)
|
||||
list (APPEND EXAMPLE_SOURCE_FILES
|
||||
examples/opmi.cpp
|
||||
examples/opmpack.cpp
|
||||
examples/opmhash.cpp
|
||||
examples/rst_deck.cpp
|
||||
examples/wellgraph.cpp
|
||||
examples/make_ext_smry.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -584,14 +484,13 @@ if(ENABLE_ECL_INPUT)
|
||||
examples/opmi.cpp
|
||||
examples/opmpack.cpp
|
||||
examples/opmhash.cpp
|
||||
examples/rst_deck.cpp
|
||||
examples/make_esmry.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
list( APPEND PUBLIC_HEADER_FILES
|
||||
opm/common/ErrorMacros.hpp
|
||||
opm/common/Exceptions.hpp
|
||||
opm/common/data/SimulationDataContainer.hpp
|
||||
opm/common/OpmLog/CounterLog.hpp
|
||||
opm/common/OpmLog/EclipsePRTLog.hpp
|
||||
opm/common/OpmLog/LogBackend.hpp
|
||||
@@ -599,15 +498,12 @@ list( APPEND PUBLIC_HEADER_FILES
|
||||
opm/common/OpmLog/LogUtil.hpp
|
||||
opm/common/OpmLog/MessageFormatter.hpp
|
||||
opm/common/OpmLog/MessageLimiter.hpp
|
||||
opm/common/OpmLog/KeywordLocation.hpp
|
||||
opm/common/OpmLog/InfoLogger.hpp
|
||||
opm/common/OpmLog/Location.hpp
|
||||
opm/common/OpmLog/OpmLog.hpp
|
||||
opm/common/OpmLog/StreamLog.hpp
|
||||
opm/common/OpmLog/TimerLog.hpp
|
||||
opm/common/utility/Serializer.hpp
|
||||
opm/common/utility/ActiveGridCells.hpp
|
||||
opm/common/utility/FileSystem.hpp
|
||||
opm/common/utility/OpmInputError.hpp
|
||||
opm/common/utility/numeric/cmp.hpp
|
||||
opm/common/utility/platform_dependent/disable_warnings.h
|
||||
opm/common/utility/platform_dependent/reenable_warnings.h
|
||||
@@ -634,6 +530,7 @@ if(ENABLE_ECL_INPUT)
|
||||
list(APPEND PUBLIC_HEADER_FILES
|
||||
opm/io/eclipse/SummaryNode.hpp
|
||||
opm/json/JsonObject.hpp
|
||||
opm/parser/eclipse/Utility/Stringview.hpp
|
||||
opm/parser/eclipse/Utility/Functional.hpp
|
||||
opm/parser/eclipse/Utility/Typetools.hpp
|
||||
opm/parser/eclipse/Generator/KeywordGenerator.hpp
|
||||
@@ -653,13 +550,12 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp
|
||||
opm/parser/eclipse/EclipseState/InitConfig/FoamConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Util/Value.hpp
|
||||
opm/parser/eclipse/EclipseState/Util/IOrderSet.hpp
|
||||
opm/parser/eclipse/EclipseState/Util/OrderedMap.hpp
|
||||
opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/FieldData.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/Keywords.hpp
|
||||
opm/parser/eclipse/EclipseState/Edit/EDITNNC.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/GridDims.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/TranCalculator.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/TransMult.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp
|
||||
@@ -673,11 +569,9 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/BoxManager.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/MapAxes.hpp
|
||||
opm/parser/eclipse/EclipseState/Grid/MinpvMode.hpp
|
||||
opm/parser/eclipse/EclipseState/EndpointScaling.hpp
|
||||
opm/parser/eclipse/EclipseState/TracerConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/MICPpara.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/DenT.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/SimpleTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/StandardCond.hpp
|
||||
@@ -692,11 +586,8 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PlydhflfTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PlymwinjTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PlyshlogTable.hpp
|
||||
@@ -706,7 +597,6 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/SgcwmisTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/TableManager.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/EnptvdTable.hpp
|
||||
@@ -716,8 +606,6 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Tables/JFunc.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp
|
||||
@@ -745,7 +633,6 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Tables/SgwfnTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PvdsTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PvtoTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/PvtsolTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/Rock2dTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Tables/RockwnodTable.hpp
|
||||
@@ -761,14 +648,10 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Tables/TracerVdTable.hpp
|
||||
opm/parser/eclipse/EclipseState/EclipseState.hpp
|
||||
opm/parser/eclipse/EclipseState/EclipseConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/Aquancon.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/AquiferConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/AquiferCT.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/Aquifetp.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferCell.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquiferConnection.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/SingleNumericalAquifer.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquifers.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquancon.hpp
|
||||
opm/parser/eclipse/EclipseState/AquiferConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/AquiferCT.hpp
|
||||
opm/parser/eclipse/EclipseState/Aquifetp.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp
|
||||
@@ -777,51 +660,35 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/Enums.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/PyAction.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Network/Balance.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/ProductionControls.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/InjectionControls.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/PAvg.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculator.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/PAvgCalculatorCollection.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/NameOrder.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellMatcher.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellEconProductionLimits.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellFoamProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellBrineProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellMICPProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellPolymerProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellTracerProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellTestConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/RFTConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/RPTConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/RSTConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/ScheduleDeck.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/ScheduleState.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/WriteRestartFileEvents.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp
|
||||
@@ -832,17 +699,19 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Schedule/MessageLimits.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/Events.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/icd.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp
|
||||
opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp
|
||||
opm/parser/eclipse/EclipseState/SimulationConfig/BCConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/SimulationConfig/RockConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.hpp
|
||||
opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/checkDeck.hpp
|
||||
opm/parser/eclipse/EclipseState/Runspec.hpp
|
||||
@@ -850,26 +719,21 @@ if(ENABLE_ECL_INPUT)
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQContext.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQInput.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQToken.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunction.hpp
|
||||
opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQFunctionTable.hpp
|
||||
opm/parser/eclipse/Deck/DeckItem.hpp
|
||||
opm/parser/eclipse/Deck/Deck.hpp
|
||||
opm/parser/eclipse/Deck/FileDeck.hpp
|
||||
opm/parser/eclipse/Deck/DeckSection.hpp
|
||||
opm/parser/eclipse/Deck/DeckTree.hpp
|
||||
opm/parser/eclipse/Deck/DeckOutput.hpp
|
||||
opm/parser/eclipse/Deck/DeckValue.hpp
|
||||
opm/parser/eclipse/Deck/DeckKeyword.hpp
|
||||
opm/parser/eclipse/Deck/DeckRecord.hpp
|
||||
opm/parser/eclipse/Deck/ImportContainer.hpp
|
||||
opm/parser/eclipse/Deck/UDAValue.hpp
|
||||
opm/parser/eclipse/Deck/value_status.hpp
|
||||
opm/parser/eclipse/Python/Python.hpp)
|
||||
@@ -881,52 +745,38 @@ if(ENABLE_ECL_OUTPUT)
|
||||
opm/io/eclipse/EclOutput.hpp
|
||||
opm/io/eclipse/EclUtil.hpp
|
||||
opm/io/eclipse/EGrid.hpp
|
||||
opm/io/eclipse/EInit.hpp
|
||||
opm/io/eclipse/ERft.hpp
|
||||
opm/io/eclipse/ERst.hpp
|
||||
opm/io/eclipse/ERsm.hpp
|
||||
opm/io/eclipse/ESmry.hpp
|
||||
opm/io/eclipse/ExtESmry.hpp
|
||||
opm/io/eclipse/PaddedOutputString.hpp
|
||||
opm/io/eclipse/OutputStream.hpp
|
||||
opm/io/eclipse/ExtSmryOutput.hpp
|
||||
opm/io/eclipse/RestartFileView.hpp
|
||||
opm/io/eclipse/SummaryNode.hpp
|
||||
opm/io/eclipse/rst/action.hpp
|
||||
opm/io/eclipse/rst/aquifer.hpp
|
||||
opm/io/eclipse/rst/connection.hpp
|
||||
opm/io/eclipse/rst/group.hpp
|
||||
opm/io/eclipse/rst/header.hpp
|
||||
opm/io/eclipse/rst/segment.hpp
|
||||
opm/io/eclipse/rst/state.hpp
|
||||
opm/io/eclipse/rst/udq.hpp
|
||||
opm/io/eclipse/rst/well.hpp
|
||||
opm/output/data/Aquifer.hpp
|
||||
opm/output/data/Cells.hpp
|
||||
opm/output/data/GuideRateValue.hpp
|
||||
opm/output/data/Groups.hpp
|
||||
opm/output/data/Solution.hpp
|
||||
opm/output/data/Wells.hpp
|
||||
opm/output/eclipse/VectorItems/action.hpp
|
||||
opm/output/data/Groups.hpp
|
||||
opm/output/eclipse/VectorItems/aquifer.hpp
|
||||
opm/output/eclipse/VectorItems/connection.hpp
|
||||
opm/output/eclipse/VectorItems/group.hpp
|
||||
opm/output/eclipse/VectorItems/network.hpp
|
||||
opm/output/eclipse/VectorItems/intehead.hpp
|
||||
opm/output/eclipse/VectorItems/logihead.hpp
|
||||
opm/output/eclipse/VectorItems/msw.hpp
|
||||
opm/output/eclipse/VectorItems/tabdims.hpp
|
||||
opm/output/eclipse/VectorItems/well.hpp
|
||||
opm/output/eclipse/ActiveIndexByColumns.hpp
|
||||
opm/output/eclipse/AggregateActionxData.hpp
|
||||
opm/output/eclipse/AggregateAquiferData.hpp
|
||||
opm/output/eclipse/AggregateGroupData.hpp
|
||||
opm/output/eclipse/AggregateNetworkData.hpp
|
||||
opm/output/eclipse/AggregateConnectionData.hpp
|
||||
opm/output/eclipse/AggregateMSWData.hpp
|
||||
opm/output/eclipse/AggregateUDQData.hpp
|
||||
opm/output/eclipse/AggregateWellData.hpp
|
||||
opm/output/eclipse/AggregateWListData.hpp
|
||||
opm/output/eclipse/DoubHEAD.hpp
|
||||
opm/output/eclipse/EclipseGridInspector.hpp
|
||||
opm/output/eclipse/EclipseIO.hpp
|
||||
@@ -937,17 +787,14 @@ if(ENABLE_ECL_OUTPUT)
|
||||
opm/output/eclipse/RegionCache.hpp
|
||||
opm/output/eclipse/RestartIO.hpp
|
||||
opm/output/eclipse/RestartValue.hpp
|
||||
opm/output/eclipse/Inplace.hpp
|
||||
opm/output/eclipse/Summary.hpp
|
||||
opm/output/eclipse/Tables.hpp
|
||||
opm/output/eclipse/UDQDims.hpp
|
||||
opm/output/eclipse/WindowedArray.hpp
|
||||
opm/output/eclipse/WriteInit.hpp
|
||||
opm/output/eclipse/WriteRFT.hpp
|
||||
opm/output/eclipse/WriteRPT.hpp
|
||||
opm/output/eclipse/WriteRestartHelpers.hpp
|
||||
opm/output/OutputWriter.hpp
|
||||
opm/utility/EModel.hpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -6,16 +6,6 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${BASE_DIR}/tmp_gen/TestKeywords.cpp
|
||||
${BASE_DIR}/TestKeywords.cpp)
|
||||
|
||||
if (EXISTS ${BASE_DIR}/python/cxx)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${BASE_DIR}/tmp_gen/builtin_pybind11.cpp
|
||||
${BASE_DIR}/python/cxx/builtin_pybind11.cpp)
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${BASE_DIR}/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/Builtin.hpp
|
||||
${BASE_DIR}/include/opm/parser/eclipse/Parser/ParserKeywords/Builtin.hpp)
|
||||
|
||||
|
||||
file(GLOB HDRS ${BASE_DIR}/tmp_gen/include/opm/parser/eclipse/Parser/ParserKeywords/*.hpp)
|
||||
|
||||
|
||||
@@ -18,13 +18,13 @@ set(_testdir ${PROJECT_SOURCE_DIR}/tests/parser/data)
|
||||
opm_add_test(ParserTests
|
||||
SOURCES tests/parser/ParserTests.cpp
|
||||
LIBRARIES ${TEST_LIBS}
|
||||
TEST_ARGS -- ${_testdir}/)
|
||||
TEST_ARGS ${_testdir}/)
|
||||
list(APPEND EXTRA_TESTS ParserTests)
|
||||
|
||||
opm_add_test(ParserIncludeTests
|
||||
SOURCES tests/parser/ParserIncludeTests.cpp
|
||||
LIBRARIES ${TEST_LIBS}
|
||||
TEST_ARGS -- ${_testdir}/parser/)
|
||||
TEST_ARGS ${_testdir}/parser/)
|
||||
target_compile_definitions(ParserIncludeTests PRIVATE
|
||||
-DHAVE_CASE_SENSITIVE_FILESYSTEM=${HAVE_CASE_SENSITIVE_FILESYSTEM})
|
||||
list(APPEND EXTRA_TESTS ParserIncludeTests)
|
||||
@@ -32,21 +32,23 @@ list(APPEND EXTRA_TESTS ParserIncludeTests)
|
||||
opm_add_test(PvtxTableTests
|
||||
SOURCES tests/parser/PvtxTableTests.cpp
|
||||
LIBRARIES ${TEST_LIBS}
|
||||
TEST_ARGS -- ${_testdir}/integration_tests/)
|
||||
TEST_ARGS ${_testdir}/integration_tests/)
|
||||
list(APPEND EXTRA_TESTS PvtxTableTests)
|
||||
|
||||
opm_add_test(EclipseStateTests
|
||||
SOURCES tests/parser/EclipseStateTests.cpp
|
||||
LIBRARIES ${TEST_LIBS}
|
||||
TEST_ARGS -- ${_testdir}/integration_tests/)
|
||||
TEST_ARGS ${_testdir}/integration_tests/)
|
||||
list(APPEND EXTRA_TESTS EclipseStateTests)
|
||||
|
||||
foreach (test BoxTest
|
||||
CheckDeckValidity
|
||||
EclipseGridCreateFromDeck
|
||||
EDITNNCTests
|
||||
IncludeTest
|
||||
IntegrationTests
|
||||
IOConfigIntegrationTest
|
||||
NNCTests
|
||||
ParseKEYWORD
|
||||
Polymer
|
||||
ScheduleCreateFromDeck
|
||||
@@ -55,7 +57,7 @@ foreach (test BoxTest
|
||||
opm_add_test(${test}
|
||||
SOURCES tests/parser/integration/${test}.cpp
|
||||
LIBRARIES ${TEST_LIBS}
|
||||
TEST_ARGS -- ${_testdir}/integration_tests/)
|
||||
TEST_ARGS ${_testdir}/integration_tests/)
|
||||
list(APPEND EXTRA_TESTS ${test})
|
||||
endforeach ()
|
||||
|
||||
@@ -69,11 +71,6 @@ opm_add_test( rst_msw
|
||||
LIBRARIES ${TEST_LIBS}
|
||||
TEST_ARGS tests/MSW.DATA tests/MSW_RESTART.DATA )
|
||||
|
||||
add_test( NAME rst_deck_test
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/tests/rst_test_driver.sh ${PROJECT_BINARY_DIR}/bin/rst_deck ${PROJECT_BINARY_DIR}/bin/opmhash
|
||||
${PROJECT_SOURCE_DIR}/tests/SPE1CASE2_INCLUDE.DATA)
|
||||
|
||||
|
||||
# opm-tests dependent tests
|
||||
if(HAVE_OPM_TESTS)
|
||||
opm_add_test(parse_write ONLY_COMPILE
|
||||
@@ -118,17 +115,8 @@ if(HAVE_OPM_TESTS)
|
||||
opm_add_test("SPE9_CP_GROUP2" NO_COMPILE EXE_NAME parse_write TEST_ARGS "${OPM_TESTS_ROOT}/spe9group/SPE9_CP_GROUP.DATA")
|
||||
set_property(TEST NORNE_ATW2013
|
||||
PROPERTY ENVIRONMENT "OPM_ERRORS_IGNORE=PARSE_RANDOM_SLASH")
|
||||
|
||||
add_test( NAME rst_deck_test_norne
|
||||
COMMAND ${PROJECT_SOURCE_DIR}/tests/rst_test_driver.sh ${CMAKE_BINARY_DIR}/bin/rst_deck ${CMAKE_BINARY_DIR}/bin/opmhash
|
||||
${OPM_TESTS_ROOT}/norne/NORNE_ATW2013.DATA)
|
||||
|
||||
set_property(TEST rst_deck_test_norne
|
||||
PROPERTY ENVIRONMENT "OPM_ERRORS_IGNORE=PARSE_RANDOM_SLASH")
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
# JSON tests
|
||||
opm_add_test(jsonTests
|
||||
SOURCES tests/json/jsonTests.cpp
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
set(genkw_SOURCES src/opm/json/JsonObject.cpp
|
||||
src/opm/parser/eclipse/Parser/createDefaultKeywordList.cpp
|
||||
src/opm/parser/eclipse/Deck/UDAValue.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckTree.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckValue.cpp
|
||||
src/opm/parser/eclipse/Deck/Deck.cpp
|
||||
src/opm/parser/eclipse/Deck/DeckItem.cpp
|
||||
@@ -21,7 +20,7 @@ set(genkw_SOURCES src/opm/json/JsonObject.cpp
|
||||
src/opm/parser/eclipse/Parser/raw/StarToken.cpp
|
||||
src/opm/parser/eclipse/Units/Dimension.cpp
|
||||
src/opm/parser/eclipse/Units/UnitSystem.cpp
|
||||
src/opm/common/utility/OpmInputError.cpp
|
||||
src/opm/parser/eclipse/Utility/Stringview.cpp
|
||||
src/opm/common/OpmLog/OpmLog.cpp
|
||||
src/opm/common/OpmLog/Logger.cpp
|
||||
src/opm/common/OpmLog/StreamLog.cpp
|
||||
@@ -42,14 +41,7 @@ configure_file(src/opm/parser/eclipse/keyword_list.argv.in keyword_list.argv)
|
||||
|
||||
# Generate keyword source
|
||||
|
||||
set( genkw_argv keyword_list.argv
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserInit.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/include/
|
||||
opm/parser/eclipse/Parser/ParserKeywords
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/TestKeywords.cpp)
|
||||
|
||||
set( _tmp_output
|
||||
add_custom_command( OUTPUT
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/A.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/B.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/C.cpp
|
||||
@@ -76,11 +68,18 @@ set( _tmp_output
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/X.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/Y.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/Z.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserInit.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/TestKeywords.cpp)
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/TestKeywords.cpp
|
||||
COMMAND genkw keyword_list.argv
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/ParserInit.cpp
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/include/
|
||||
opm/parser/eclipse/Parser/ParserKeywords
|
||||
${PROJECT_BINARY_DIR}/tmp_gen/TestKeywords.cpp
|
||||
DEPENDS genkw ${keyword_files} src/opm/parser/eclipse/share/keywords/keyword_list.cmake
|
||||
)
|
||||
|
||||
|
||||
set( _target_output
|
||||
# To avoid some rebuilds
|
||||
add_custom_command(OUTPUT
|
||||
${PROJECT_BINARY_DIR}/ParserKeywords/A.cpp
|
||||
${PROJECT_BINARY_DIR}/ParserKeywords/B.cpp
|
||||
${PROJECT_BINARY_DIR}/ParserKeywords/C.cpp
|
||||
@@ -108,24 +107,7 @@ set( _target_output
|
||||
${PROJECT_BINARY_DIR}/ParserKeywords/Y.cpp
|
||||
${PROJECT_BINARY_DIR}/ParserKeywords/Z.cpp
|
||||
${PROJECT_BINARY_DIR}/TestKeywords.cpp
|
||||
${PROJECT_BINARY_DIR}/ParserInit.cpp)
|
||||
|
||||
|
||||
if (OPM_ENABLE_PYTHON)
|
||||
list(APPEND genkw_argv ${PROJECT_BINARY_DIR}/tmp_gen/builtin_pybind11.cpp)
|
||||
list(APPEND _tmp_output ${PROJECT_BINARY_DIR}/tmp_gen/builtin_pybind11.cpp)
|
||||
list(APPEND _target_output ${PROJECT_BINARY_DIR}/python/cxx/builtin_pybind11.cpp)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
add_custom_command( OUTPUT
|
||||
${_tmp_output}
|
||||
COMMAND genkw ${genkw_argv}
|
||||
DEPENDS genkw ${keyword_files} src/opm/parser/eclipse/share/keywords/keyword_list.cmake)
|
||||
|
||||
# To avoid some rebuilds
|
||||
add_custom_command(OUTPUT
|
||||
${_target_output}
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/A.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -DBASE_DIR=${PROJECT_BINARY_DIR} -P ${PROJECT_SOURCE_DIR}/CopyHeaders.cmake)
|
||||
${PROJECT_BINARY_DIR}/ParserInit.cpp
|
||||
DEPENDS ${PROJECT_BINARY_DIR}/tmp_gen/ParserKeywords/A.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -DBASE_DIR=${PROJECT_BINARY_DIR}
|
||||
-P ${PROJECT_SOURCE_DIR}/CopyHeaders.cmake)
|
||||
|
||||
49
cmake/Modules/BoostTargets.cmake
Normal file
49
cmake/Modules/BoostTargets.cmake
Normal file
@@ -0,0 +1,49 @@
|
||||
# make targets for boost if find module did not do the job
|
||||
|
||||
if(NOT TARGET Boost::system)
|
||||
add_library(Boost::system UNKNOWN IMPORTED)
|
||||
set_target_properties(Boost::system PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
IMPORTED_LOCATION "${Boost_SYSTEM_LIBRARY}"
|
||||
IMPORTED_LOCATION_DEBUG "${Boost_SYSTEM_LIBRARY_DEBUG}"
|
||||
IMPORTED_LOCATION_RELEASE "${Boost_SYSTEM_LIBRARY_RELEASE}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Boost::filesystem)
|
||||
add_library(Boost::filesystem UNKNOWN IMPORTED)
|
||||
set_target_properties(Boost::filesystem PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
INTERFACE_COMPILE_DEFINITIONS BOOST_FILESYSTEM_VERSION=3
|
||||
INTERFACE_LINK_LIBRARIES "${boost_system}"
|
||||
IMPORTED_LOCATION "${Boost_FILESYSTEM_LIBRARY}"
|
||||
IMPORTED_LOCATION_DEBUG "${Boost_FILESYSTEM_LIBRARY_DEBUG}"
|
||||
IMPORTED_LOCATION_RELEASE "${Boost_FILESYSTEM_LIBRARY_RELEASE}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Boost::regex)
|
||||
add_library(Boost::regex UNKNOWN IMPORTED)
|
||||
set_target_properties(Boost::regex PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${boost_system}"
|
||||
IMPORTED_LOCATION "${Boost_REGEX_LIBRARY}"
|
||||
IMPORTED_LOCATION_DEBUG "${Boost_REGEX_LIBRARY_DEBUG}"
|
||||
IMPORTED_LOCATION_RELEASE "${Boost_REGEX_LIBRARY_RELEASE}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Boost::unit_test_framework)
|
||||
add_library(Boost::unit_test_framework UNKNOWN IMPORTED)
|
||||
set_target_properties(Boost::unit_test_framework PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${boost_system}"
|
||||
IMPORTED_LOCATION "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}"
|
||||
IMPORTED_LOCATION_DEBUG "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY_DEBUG}"
|
||||
IMPORTED_LOCATION_RELEASE "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY_RELEASE}"
|
||||
)
|
||||
endif()
|
||||
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)
|
||||
@@ -1,31 +0,0 @@
|
||||
# - Find the GNU Multiprecision library.
|
||||
#
|
||||
# Will define the following imported target for usage:
|
||||
# - GMP::gmp Target for linking/compiling with C library
|
||||
# - GMP::gmpxx Target for linking/compiling with C++ library
|
||||
find_path(GMP_INCLUDE_DIR gmp.h)
|
||||
find_library(GMP_LIBRARY gmp)
|
||||
find_path(GMPXX_INCLUDE_DIR gmpxx.h)
|
||||
find_library(GMPXX_LIBRARY gmpxx)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GMP
|
||||
DEFAULT_MSG
|
||||
GMPXX_LIBRARY GMPXX_INCLUDE_DIR GMP_INCLUDE_DIR GMP_LIBRARY)
|
||||
|
||||
if(GMP_FOUND)
|
||||
if(NOT TARGET GMP::gmp)
|
||||
add_library(GMP::gmp UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(GMP::gmp PROPERTIES
|
||||
IMPORTED_LOCATION ${GMP_LIBRARY}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${GMP_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(NOT TARGET GMP::gmpxx)
|
||||
add_library(GMP::gmpxx UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(GMP::gmpxx PROPERTIES
|
||||
IMPORTED_LOCATION ${GMPXX_LIBRARY}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${GMPXX_INCLUDE_DIR}
|
||||
TARGET_LINK_LIBRARIES GMP::gmp)
|
||||
endif()
|
||||
endif()
|
||||
@@ -8,11 +8,7 @@
|
||||
# HAVE_METIS - like METIS_FOUND, but for the inclusion in config.h
|
||||
# METIS_INCLUDE_DIRS - incude paths to use libMETIS
|
||||
# METIS_LIBRARIES - Link these to use libMETIS
|
||||
# METIS::METIS - Imported metis target needed for DUNE 2.8.0
|
||||
# METIS_API_VERSION - The METIS api version scotch is supporting.
|
||||
|
||||
set(METIS_API_VERSION 0 CACHE STRING
|
||||
"METIS API version provided by METIS or scotch-metis library")
|
||||
set(METIS_SEARCH_PATH "/usr" "/usr/local" "/opt" "/opt/local")
|
||||
set(METIS_NO_DEFAULT_PATH "")
|
||||
if(METIS_ROOT)
|
||||
@@ -39,27 +35,9 @@ find_library(METIS_LIBRARIES
|
||||
${METIS_NO_DEFAULT_PATH})
|
||||
|
||||
set (METIS_FOUND FALSE)
|
||||
|
||||
if (METIS_INCLUDE_DIRS OR METIS_LIBRARIES)
|
||||
set(METIS_FOUND TRUE)
|
||||
set(HAVE_METIS TRUE)
|
||||
file(READ "${METIS_INCLUDE_DIRS}/metis.h" metisheader)
|
||||
string(REGEX MATCH "#define METIS_VER_MAJOR[ ]+([0-9]+)" METIS_MAJOR_VERSION ${metisheader})
|
||||
if(NOT METIS_API_VERSION AND METIS_MAJOR_VERSION)
|
||||
# string(REGEX REPLACE ".*#define METIS_VER_MAJOR[ ]+([0-9]+).*" "\\1"
|
||||
# METIS_MAJOR_VERSION "${metisheader}")
|
||||
if(METIS_MAJOR_VERSION GREATER_EQUAL 3 AND METIS_MAJOR_VERSION LESS 5)
|
||||
set(METIS_API_VERSION "3")
|
||||
else()
|
||||
set(METIS_API_VERSION "${METIS_MAJOR_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(METIS::METIS UNKNOWN IMPORTED)
|
||||
set_target_properties(METIS::METIS PROPERTIES
|
||||
IMPORTED_LOCATION ${METIS_LIBRARIES}
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${METIS_INCLUDE_DIRS}
|
||||
INTERFACE_COMPILE_DEFINITIONS METIS_API_VERSION=${METIS_API_VERSION})
|
||||
endif()
|
||||
|
||||
# print a message to indicate status of this package
|
||||
|
||||
@@ -70,20 +70,6 @@ if(PTSCOTCH_FOUND)
|
||||
set(PTSCOCH_LINK_FLAGS "${DUNE_MPI_LINK_FLAGS}"
|
||||
CACHE STRING "PT-Scotch link flags")
|
||||
set(HAVE_PTSCOTCH 1)
|
||||
if(NOT TARGET PTScotch::Scotch)
|
||||
add_library(PTScotch::Scotch UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(PTScotch::Scotch PROPERTIES
|
||||
IMPORTED_LOCATION "${SCOTCH_LIBRARY}"
|
||||
INCLUDE_DIRECTORIES "${PTSCOTCH_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${PTSCOTCHERR_LIBRARY}")
|
||||
endif()
|
||||
if(NOT TARGET PTScotch::PTScotch)
|
||||
add_library(PTScotch::PTScotch UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(PTScotch::PTScotch PROPERTIES
|
||||
IMPORTED_LOCATION "${PTSCOTCH_LIBRARY}"
|
||||
INCLUDE_DIRECTORIES "${PTSCOTCH_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "PTScotch::Scotch;${MPI_DUNE_LIBRARIES}")
|
||||
endif()
|
||||
# log result
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Determing location of PT-Scotch succeded:\n"
|
||||
|
||||
@@ -60,19 +60,6 @@ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MPI_C_COMPILE_FLAGS}")
|
||||
|
||||
include(CheckIncludeFile)
|
||||
check_include_file(parmetis.h PARMETIS_FOUND)
|
||||
|
||||
if(NOT PARMETIS_FOUND)
|
||||
# If we are using the ParMETIS bindings of PTScotch, we need
|
||||
# to use the scotch include path as partmetis.h includes scotch.h
|
||||
find_package(PTScotch)
|
||||
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PTSCOTCH_INCLUDE_DIR})
|
||||
unset(PARMETIS_FOUND CACHE) # force recheck of include file
|
||||
check_include_file(parmetis.h PARMETIS_FOUND)
|
||||
if(PARMETIS_FOUND)
|
||||
set(PARMETIS_SCOTCH_INCLUDE_DIRS ${PTSCOTCH_INCLUDE_DIRS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_search_parmetis_lib(PARMETIS_LIBRARY parmetis "The main ParMETIS library.")
|
||||
|
||||
# behave like a CMake module is supposed to behave
|
||||
@@ -90,7 +77,7 @@ find_package_handle_standard_args(
|
||||
cmake_pop_check_state()
|
||||
|
||||
if(PARMETIS_FOUND)
|
||||
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR} ${PARMETIS_SCOTCH_INCLUDE_DIRS})
|
||||
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR})
|
||||
set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARIES} ${MPI_C_LIBRARIES}
|
||||
CACHE FILEPATH "All libraries needed to link programs using ParMETIS")
|
||||
set(PARMETIS_LINK_FLAGS "${DUNE_C_LINK_FLAGS}"
|
||||
@@ -102,13 +89,6 @@ if(PARMETIS_FOUND)
|
||||
"Include directory: ${PARMETIS_INCLUDE_DIRS}\n"
|
||||
"Library directory: ${PARMETIS_LIBRARIES}\n\n")
|
||||
|
||||
if(NOT TARGET ParMETIS::ParMETIS)
|
||||
add_library(ParMETIS::ParMETIS UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(ParMETIS::ParMETIS PROPERTIES
|
||||
IMPORTED_LOCATION ${PARMETIS_LIBRARY}
|
||||
INCLUDE_DIRECTORIES "${PARMETIS_INCLUDE_DIRS}"
|
||||
INTERFACE_LINK_LIBRARIES "${METIS_LIBRARIES};${MPI_C_LIBRARIES}")
|
||||
endif()
|
||||
endif(PARMETIS_FOUND)
|
||||
|
||||
mark_as_advanced(PARMETIS_INCLUDE_DIRS PARMETIS_LIBRARIES HAVE_PARMETIS)
|
||||
|
||||
@@ -34,11 +34,6 @@ int main(void){
|
||||
if (QUADMATH_FOUND)
|
||||
set(QUADMATH_LIBRARIES "quadmath")
|
||||
set(HAVE_QUAD "${QUADMATH_FOUND}")
|
||||
add_library(QuadMath::QuadMath INTERFACE IMPORTED)
|
||||
set_target_properties(QuadMath::QuadMath PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES quadmath
|
||||
INTERFACE_COMPILE_DEFINITIONS _GLIBCXX_USE_FLOAT128
|
||||
INTERFACE_COMPILE_OPTIONS $<$<CXX_COMPILER_ID:GNU>:-fext-numeric-literals>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -280,32 +280,6 @@ if (SuiteSparse_LIBRARIES)
|
||||
list (REVERSE SuiteSparse_LIBRARIES)
|
||||
endif (SuiteSparse_LIBRARIES)
|
||||
|
||||
if(SuiteSparse_FOUND)
|
||||
if(NOT TARGET SuiteSparse::SuiteSparse)
|
||||
add_library(SuiteSparse::SuiteSparse INTERFACE IMPORTED GLOBAL)
|
||||
set_property(TARGET SuiteSparse::SuiteSparse PROPERTY
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${SuiteSparse_INCLUDE_DIRS})
|
||||
if(config_LIBRARY)
|
||||
set_property(TARGET SuiteSparse::SuiteSparse PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES ${config_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
foreach(_module ${SuiteSparse_MODULES})
|
||||
string (TOUPPER ${_module} _MODULE)
|
||||
if(SuiteSparse_${_MODULE}_FOUND)
|
||||
if(NOT TARGET SuiteSparse::${_module})
|
||||
message(STATUS "Creating target SuitSparse::${_module}")
|
||||
add_library(SuiteSparse::${_module} UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(SuiteSparse::${_module} PROPERTIES
|
||||
IMPORTED_LOCATION ${${_MODULE}_LIBRARY}
|
||||
INCLUDE_DIRECTORIES ${${_MODULE}_INCLUDE_DIRS}
|
||||
INTERFACE_LINK_LIBRARIES "${config_LIBRARY}")
|
||||
target_link_libraries(SuiteSparse::SuiteSparse
|
||||
INTERFACE SuiteSparse::${_module})
|
||||
endif()
|
||||
endif()
|
||||
endforeach(_module)
|
||||
endif()
|
||||
# print a message to indicate status of this package
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (SuiteSparse
|
||||
|
||||
@@ -180,16 +180,6 @@ if(SUPERLU_FOUND)
|
||||
if (SUPERLU_BLAS_LIBRARY)
|
||||
list(APPEND SUPERLU_LIBRARIES ${SUPERLU_BLAS_LIBRARY})
|
||||
endif()
|
||||
if(NOT TARGET SuperLU::SuperLU)
|
||||
add_library(SuperLU::SuperLU UNKNOWN IMPORTED GLOBAL)
|
||||
set_target_properties(SuperLU::SuperLU PROPERTIES
|
||||
IMPORTED_LOCATION ${SUPERLU_LIBRARY}
|
||||
INCLUDE_DIRECTORIES ${SUPERLU_INCLUDE_DIRS})
|
||||
if(SUPERLU_BLAS_LIBRARY)
|
||||
set_property(TARGET SuperLU::SuperLU PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES ${SUPERLU_BLAS_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
cmake_pop_check_state()
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
# Poor man's FindTBB that will create the CMake targets
|
||||
# used by DUNE.
|
||||
# If the TBB version is new enough it will ship its own
|
||||
# TBBConfig.cmake and we are good
|
||||
find_package(TBB QUIET CONFIG)
|
||||
|
||||
if(NOT TBB_FOUND)
|
||||
# Fall back to using pkgconfig
|
||||
find_package(PkgConfig QUIET)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PkgConfigTBB IMPORTED_TARGET GLOBAL tbb QUIET)
|
||||
if(NOT TARGET PkgConfig::PkgConfigTBB)
|
||||
# workaround bug in old FindPkgConfig.cmake which adds
|
||||
# pkgcfg_lib_PkgConfigTBB_atomic-NOTFOUND because it cannot
|
||||
# find the atomic lib of the compiler (not in platforms default
|
||||
# library path. It will therefore not create the target and we
|
||||
# try that manually.
|
||||
string(REPLACE ";pkgcfg_lib_PkgConfigTBB_atomic-NOTFOUND" "" _find_tbb_libs "${PkgConfigTBB_LINK_LIBRARIES}")
|
||||
if(_find_tbb_libs)
|
||||
add_library(PkgConfig::PkgConfigTBB INTERFACE IMPORTED GLOBAL)
|
||||
set_property(TARGET PkgConfig::PkgConfigTBB PROPERTY
|
||||
INTERFACE_LINK_LIBRARIES "${_find_tbb_libs}")
|
||||
endif()
|
||||
endif()
|
||||
if(TARGET PkgConfig::PkgConfigTBB)
|
||||
if(NOT TARGET TBB::tbb)
|
||||
message(STATUS "Found TBB library using pkg config")
|
||||
add_library(TBB::tbb ALIAS PkgConfig::PkgConfigTBB)
|
||||
endif()
|
||||
endif()
|
||||
endif(PKG_CONFIG_FOUND)
|
||||
else()
|
||||
message(STATUS "Found TBB library using config mode")
|
||||
endif(NOT TBB_FOUND)
|
||||
@@ -6,6 +6,10 @@
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
if ((NOT CJSON_ROOT) AND OPM_PARSER_ROOT)
|
||||
set( CJSON_ROOT ${OPM_PARSER_ROOT})
|
||||
endif()
|
||||
|
||||
if (CJSON_ROOT)
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
else (CJSON_ROOT)
|
||||
@@ -14,9 +18,10 @@ endif (CJSON_ROOT)
|
||||
|
||||
|
||||
find_path (CJSON_INCLUDE_DIR
|
||||
NAMES "cJSON.h"
|
||||
NAMES "cjson/cJSON.h"
|
||||
HINTS "${CJSON_ROOT}"
|
||||
PATH_SUFFIXES "cjson"
|
||||
PATHS "${PROJECT_SOURCE_DIR}"
|
||||
PATH_SUFFIXES "include" "external"
|
||||
DOC "Path to cjson library header files"
|
||||
${_no_default_path} )
|
||||
|
||||
@@ -31,7 +36,11 @@ string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PR
|
||||
find_library (CJSON_LIBRARY
|
||||
NAMES "cjson"
|
||||
HINTS "${CJSON_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../opm-parser"
|
||||
"${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}"
|
||||
"${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
"opm/json"
|
||||
DOC "Path to cjson library archive/shared object files"
|
||||
${_no_default_path} )
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@ find_opm_package (
|
||||
"BLAS REQUIRED;
|
||||
LAPACK REQUIRED;
|
||||
CxaDemangle;
|
||||
MPI;
|
||||
TBB;
|
||||
GMP
|
||||
MPI
|
||||
"
|
||||
# header to search for
|
||||
"dune/common/fvector.hh"
|
||||
@@ -30,7 +28,7 @@ find_opm_package (
|
||||
"dunecommon"
|
||||
|
||||
# defines to be added to compilations
|
||||
""
|
||||
"DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD=1"
|
||||
|
||||
# test program
|
||||
"#include <dune/common/fvector.hh>
|
||||
|
||||
@@ -24,8 +24,7 @@ find_opm_package (
|
||||
dune-alugrid;
|
||||
ZLIB;
|
||||
ZOLTAN;
|
||||
METIS;
|
||||
Quadmath
|
||||
METIS
|
||||
"
|
||||
# header to search for
|
||||
"dune/fem/space/shapefunctionset/legendre.hh"
|
||||
|
||||
@@ -33,7 +33,8 @@ find_opm_package (
|
||||
# test program
|
||||
"#include <dune/geometry/quadraturerules.hh>
|
||||
int main (void) {
|
||||
Dune::GeometryType gt = Dune::GeometryTypes::quadrilateral;
|
||||
Dune::GeometryType gt;
|
||||
gt.makeQuadrilateral();
|
||||
Dune::QuadratureRules<double, 2>::rule(gt, 2).size();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -16,36 +16,7 @@ function (linker_cmdline what INTO outvar FROM)
|
||||
# (you get an error message about argument not parsed). translate each
|
||||
# of the libraries into a linker option
|
||||
set (deplib_list "")
|
||||
set (deplib_list_tmp "")
|
||||
foreach (deplib IN LISTS ARGN)
|
||||
# resolve imported targets
|
||||
string(FIND ${deplib} "::" _sep)
|
||||
if (_sep GREATER "-1")
|
||||
set(_lib "")
|
||||
# the code below does not really work for imported interface library
|
||||
# as cmake will error out whene querying IMPORTED_LOCATION, because the
|
||||
# property is not whitelisted. I have no idea how to determine if
|
||||
# a library is an imported interface library
|
||||
# At least it works for resolving OpenMP::OpenMP_CXX
|
||||
#
|
||||
# get_property(_def TARGET ${deplib} PROPERTY IMPORTED_LOCATION DEFINED)
|
||||
# if (_def)
|
||||
# get_property(_def TARGET ${deplib} PROPERTY IMPORTED_LOCATION SET)
|
||||
# if (_def)
|
||||
# get_target_property(_tmp_lib ${deplib} IMPORTED_LOCATION)
|
||||
# list(APPEND _lib ${_tmp_lib})
|
||||
# endif()
|
||||
# endif()
|
||||
get_property(_def TARGET ${deplib} PROPERTY INTERFACE_LINK_LIBRARIES SET)
|
||||
if (_def)
|
||||
get_target_property(_tmp_lib ${deplib} INTERFACE_LINK_LIBRARIES)
|
||||
list(APPEND _lib ${_tmp_lib})
|
||||
endif()
|
||||
set(deplib ${_lib})
|
||||
endif()
|
||||
list(APPEND deplib_list_tmp ${deplib})
|
||||
endforeach()
|
||||
foreach (deplib IN LISTS deplib_list_tmp)
|
||||
# starts with a hyphen already? then just add it
|
||||
string (SUBSTRING ${deplib} 0 1 dash)
|
||||
if (${dash} STREQUAL "-")
|
||||
@@ -73,20 +44,18 @@ function (linker_cmdline what INTO outvar FROM)
|
||||
# is more or less lost. remove system default path, to lessen the
|
||||
# chance that we pick the wrong library
|
||||
if (NOT ((deplib_dir STREQUAL "/usr/lib") OR
|
||||
(deplib_dir STREQUAL "") OR
|
||||
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
|
||||
list (APPEND deplib_list "-L${deplib_dir}")
|
||||
endif ()
|
||||
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
|
||||
list (APPEND deplib_list "-L${deplib_dir}")
|
||||
endif (NOT ((deplib_dir STREQUAL "/usr/lib") OR
|
||||
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
|
||||
# if there was no translation of the name, the library is named
|
||||
# unconventionally (.so.3gf, I'm looking at you), so pass this
|
||||
# name unmodified to the linker switch
|
||||
if (deplib_orig STREQUAL deplib_name AND
|
||||
NOT deplib_orig STREQUAL "stdc++fs")
|
||||
if (deplib_orig STREQUAL deplib_name)
|
||||
list (APPEND deplib_list "-l:${deplib_orig}")
|
||||
else ()
|
||||
else (deplib_orig STREQUAL deplib_name)
|
||||
list (APPEND deplib_list "-l${deplib_name}")
|
||||
endif (deplib_orig STREQUAL deplib_name AND
|
||||
NOT deplib_orig STREQUAL "stdc++fs")
|
||||
endif (deplib_orig STREQUAL deplib_name)
|
||||
endif (${dash} STREQUAL "-")
|
||||
endforeach (deplib)
|
||||
# caller determines whether we want it returned as a list or a string
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
# Installs bash tab completion for a product
|
||||
macro(opm_add_bash_completion binary)
|
||||
option(USE_BASH_COMPLETIONS_DIR
|
||||
"Whether to use the new bash completion dir (/usr/share/bash-completion/completions) with load on demand"
|
||||
OFF)
|
||||
if(USE_BASH_COMPLETIONS_DIR)
|
||||
set(_BASH_COMPLETION_FILE ${binary})
|
||||
set(_BASH_COMPLETION_INSTALL_DIR ${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions)
|
||||
else()
|
||||
set(_BASH_COMPLETION_FILE ${binary}_bash_completion.sh)
|
||||
set(_BASH_COMPLETION_INSTALL_DIR ${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d)
|
||||
endif()
|
||||
set(PRODUCT ${binary})
|
||||
configure_file(${OPM_MACROS_ROOT}/etc/opm_bash_completion.sh.in ${_BASH_COMPLETION_FILE} @ONLY)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/${_BASH_COMPLETION_FILE} DESTINATION ${_BASH_COMPLETION_INSTALL_DIR})
|
||||
configure_file(${OPM_MACROS_ROOT}/etc/opm_bash_completion.sh.in ${binary}_bash_completion.sh @ONLY)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/${binary}_bash_completion.sh DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d)
|
||||
endmacro()
|
||||
|
||||
@@ -29,18 +29,12 @@ macro (opm_compile opm)
|
||||
|
||||
# create this library, if there are any compilation units
|
||||
link_directories (${${opm}_LIBRARY_DIRS})
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.12")
|
||||
# Some modules may still export definitions using -D, strip it
|
||||
string(REGEX REPLACE "-D" "" _clean_defs "${${opm}_DEFINITIONS}")
|
||||
add_compile_definitions(${_clean_defs})
|
||||
else()
|
||||
add_definitions(${${opm}_DEFINITIONS})
|
||||
endif()
|
||||
add_definitions (${${opm}_DEFINITIONS})
|
||||
set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}")
|
||||
if (${opm}_SOURCES)
|
||||
add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES})
|
||||
set_target_properties (${${opm}_TARGET} PROPERTIES
|
||||
SOVERSION ${${opm}_VERSION}
|
||||
SOVERSION ${${opm}_VERSION_MAJOR}
|
||||
VERSION ${${opm}_VERSION}
|
||||
LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}"
|
||||
POSITION_INDEPENDENT_CODE TRUE
|
||||
|
||||
@@ -106,13 +106,8 @@ macro (find_and_append_package_to prefix name)
|
||||
|
||||
# if we're told not to look for the package, pretend it was never found
|
||||
if (CMAKE_DISABLE_FIND_PACKAGE_${name})
|
||||
# If required send an error
|
||||
cmake_parse_arguments(FIND "REQUIRED" "" "" ${ARGN} )
|
||||
set (${name}_FOUND FALSE)
|
||||
set (${NAME}_FOUND FALSE)
|
||||
if (FIND_REQUIRED)
|
||||
message(SEND_ERROR "package ${name} but disable with CMAKE_DISABLE_FIND_PACKAGE_${name}")
|
||||
endif ()
|
||||
set (${name}_FOUND FALSE)
|
||||
set (${NAME}_FOUND FALSE)
|
||||
else ()
|
||||
# List of components might differ for every module. Therefore we will
|
||||
# need to research for a library multiple times. _search_components
|
||||
@@ -130,18 +125,9 @@ macro (find_and_append_package_to prefix name)
|
||||
# and the likes which is only done via opm_find_package
|
||||
if ( (NOT DEFINED ${name}_FOUND AND NOT DEFINED ${NAME}_FOUND )
|
||||
OR _search_components GREATER -1)
|
||||
string(REGEX MATCH "(opm)-.*" _is_opm ${name})
|
||||
string(REGEX MATCH "(opm)-.*" _is_opm ${name})
|
||||
if(NOT _is_opm)
|
||||
# When using Boost >= 1.70 and e.g. CMake 3.18 we need to make sure that
|
||||
# subsequent searches are using config mode too. Otherwise the library
|
||||
# list will be completely messed up. We use a set Boost_Dir to detect that
|
||||
# previous searches were done using config mode.
|
||||
if("${name}" STREQUAL "Boost" AND Boost_DIR)
|
||||
set(_CONFIG_MODE CONFIG)
|
||||
else()
|
||||
set(_CONFIG_MODE "")
|
||||
endif()
|
||||
find_package (${name} ${ARGN} ${_CONFIG_MODE})
|
||||
find_package (${name} ${ARGN})
|
||||
else()
|
||||
if(${name}_DIR)
|
||||
find_package (${name} ${${prefix}_VERSION_MAJOR}.${${prefix}_VERSION_MINOR} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH)
|
||||
@@ -172,21 +158,7 @@ macro (find_and_append_package_to prefix name)
|
||||
string (REPLACE "-" "_" NAME "${NAME}")
|
||||
|
||||
if (${name}_FOUND OR ${NAME}_FOUND)
|
||||
foreach (var IN LISTS _opm_proj_vars)
|
||||
if("${var}" STREQUAL "DEFINITIONS"
|
||||
AND CMAKE_VERSION VERSION_LESS "3.12")
|
||||
# For old Cmake versions we use add_definitions which
|
||||
# requires -D qualifier add that
|
||||
set(_defs)
|
||||
foreach(_def IN LISTS ${name}_${var})
|
||||
if(_def MATCHES "^[a-zA-Z].*")
|
||||
list(APPEND _defs "-D${_def}")
|
||||
else()
|
||||
list(APPEND _defs "${_def}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${name}_${var} "${_defs}")
|
||||
endif()
|
||||
foreach (var IN LISTS _opm_proj_vars)
|
||||
if (DEFINED ${name}_${var})
|
||||
list (APPEND ${prefix}_${var} ${${name}_${var}})
|
||||
# some packages define an uppercase version of their own name
|
||||
|
||||
@@ -135,13 +135,6 @@ if (NOT USE_MPI)
|
||||
set (CMAKE_DISABLE_FIND_PACKAGE_MPI TRUE)
|
||||
endif ()
|
||||
|
||||
# Compiler standard version needs to be requested here as prereqs is included
|
||||
# before OpmLibMain and some tests need/use CXX_STANDARD_VERSION (e.g. pybind11)
|
||||
# Languages and global compiler settings
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# quadmath must be explicitly enabled
|
||||
# This needs to be in OpmInit as prereqs is called before OpmLibMain is included.
|
||||
option (USE_QUADMATH "Use high precision floating point library (slow)" OFF)
|
||||
|
||||
@@ -20,6 +20,16 @@
|
||||
include (AddOptions)
|
||||
no_default_options ()
|
||||
|
||||
# Languages and global compiler settings
|
||||
if(CMAKE_VERSION VERSION_LESS 3.8)
|
||||
message(WARNING "CMake version does not support c++17, guessing -std=c++17")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||
else()
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
# Various compiler extension checks
|
||||
include(OpmCompilerChecks)
|
||||
|
||||
@@ -52,10 +62,7 @@ include (UseOptimization)
|
||||
|
||||
# turn on all warnings; this must be done before adding any
|
||||
# dependencies, in case they alter the list of warnings
|
||||
option(OPM_DISABLE_WARNINGS "Disable warning flags" OFF)
|
||||
if(NOT OPM_DISABLE_WARNINGS)
|
||||
include (UseWarnings)
|
||||
endif()
|
||||
include (UseWarnings)
|
||||
|
||||
# parallel programming
|
||||
include (UseOpenMP)
|
||||
|
||||
@@ -95,19 +95,10 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
|
||||
# compile with this option to avoid avalanche of warnings
|
||||
set (${module}_DEFINITIONS "${${module}_DEFINITIONS}")
|
||||
# -D to compile definitions for older CMake versions
|
||||
set (_D_PREFIX "")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.12")
|
||||
set(_D_PREFIX "-D")
|
||||
endif()
|
||||
foreach (_def IN ITEMS ${defs})
|
||||
if(_def MATCHES "^[A-Za-z].*")
|
||||
list (APPEND ${module}_DEFINITIONS "${_D_PREFIX}${_def}")
|
||||
endif()
|
||||
list (APPEND ${module}_DEFINITIONS "-D${_def}")
|
||||
endforeach (_def)
|
||||
|
||||
list (APPEND ${module}_DEFINITIONS ${defs})
|
||||
|
||||
# tidy the lists before returning them
|
||||
remove_dup_deps (${module})
|
||||
|
||||
@@ -124,34 +115,26 @@ macro (find_opm_package module deps header lib defs prog conf)
|
||||
# without config.h
|
||||
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
|
||||
|
||||
if(prog)
|
||||
# check that we can compile a small test-program
|
||||
include (CMakePushCheckState)
|
||||
cmake_push_check_state ()
|
||||
include (CheckCXXSourceCompiles)
|
||||
# only add these if they are actually found; otherwise it won't
|
||||
# compile and the variable won't be set
|
||||
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
|
||||
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
|
||||
# since we don't have any config.h yet
|
||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
|
||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
|
||||
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
|
||||
cmake_pop_check_state ()
|
||||
else(prog)
|
||||
if(${module}_FOUND)
|
||||
# No test code provided, mark compilation as successful
|
||||
# if module was founf
|
||||
set(HAVE_${MODULE} 1)
|
||||
endif(${module}_FOUND)
|
||||
endif(prog)
|
||||
# check that we can compile a small test-program
|
||||
include (CMakePushCheckState)
|
||||
cmake_push_check_state ()
|
||||
include (CheckCXXSourceCompiles)
|
||||
# only add these if they are actually found; otherwise it won't
|
||||
# compile and the variable won't be set
|
||||
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
|
||||
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
|
||||
# since we don't have any config.h yet
|
||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
|
||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
|
||||
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
|
||||
cmake_pop_check_state ()
|
||||
|
||||
# write status message in the same manner as everyone else
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (
|
||||
${module}
|
||||
DEFAULT_MSG
|
||||
${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS HAVE_${MODULE}
|
||||
${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS
|
||||
)
|
||||
|
||||
# some genius that coded the FindPackageHandleStandardArgs figured out
|
||||
|
||||
@@ -30,6 +30,7 @@ function (configure_pc_file name source dest prefix libdir includedir)
|
||||
set (minor "${${name}_VERSION_MINOR}")
|
||||
set (target "${${name}_LIBRARY}")
|
||||
linker_cmdline (STRING INTO target from ${target})
|
||||
|
||||
configure_file (${source} ${dest} @ONLY)
|
||||
endfunction (configure_pc_file name source dist prefix libdir includedir)
|
||||
|
||||
@@ -100,24 +101,16 @@ function (opm_cmake_config name)
|
||||
# and we have existing entries pointing to that install directory.
|
||||
# Since they will yield a duplicate in next replace anyways, we filter them out first
|
||||
# to get avoid those the bogus entries.
|
||||
# First with trailing / to change /usr/include/package to package and not /package
|
||||
# Fixes broken pkg-config files for Debian/Ubuntu packaging.
|
||||
string(FIND "${${name}_INCLUDE_DIRS}" "${PROJECT_SOURCE_DIR}" _source_in_include)
|
||||
string(REPLACE "${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}" "" ${name}_INCLUDE_DIRS "${${name}_INCLUDE_DIRS}")
|
||||
|
||||
if(_source_in_include GREATER "-1")
|
||||
string(REGEX REPLACE "${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}[;$]" "" ${name}_INCLUDE_DIRS "${${name}_INCLUDE_DIRS}")
|
||||
# Get rid of empty entries
|
||||
string(REPLACE ";;" ";" ${name}_INCLUDE_DIRS "${${name}_INCLUDE_DIRS}")
|
||||
|
||||
# replace the build directory with the target directory in the
|
||||
# variables that contains build paths
|
||||
string (REPLACE
|
||||
"${PROJECT_SOURCE_DIR}"
|
||||
"${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}"
|
||||
${name}_INCLUDE_DIRS
|
||||
"${${name}_INCLUDE_DIRS}"
|
||||
)
|
||||
endif()
|
||||
# replace the build directory with the target directory in the
|
||||
# variables that contains build paths
|
||||
string (REPLACE
|
||||
"${PROJECT_SOURCE_DIR}"
|
||||
"${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}"
|
||||
${name}_INCLUDE_DIRS
|
||||
"${${name}_INCLUDE_DIRS}"
|
||||
)
|
||||
string (REPLACE
|
||||
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
# When using Boost >= 1.70 and e.g. CMake 3.18 we need to make sure that
|
||||
# subsequent searches are using config mode too. Otherwise the library
|
||||
# list will be completely messed up. We use a set Boost_Dir to detect that
|
||||
# previous searches were done using config mode.
|
||||
if(Boost_DIR)
|
||||
set(_Boost_CONFIG_MODE CONFIG)
|
||||
endif()
|
||||
find_package (Boost 1.44.0 COMPONENTS unit_test_framework QUIET ${_Boost_CONFIG_MODE})
|
||||
find_package (Boost 1.44.0 COMPONENTS unit_test_framework QUIET)
|
||||
|
||||
if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
|
||||
# setup to do a test compile
|
||||
|
||||
@@ -63,9 +63,9 @@ if (CXX_COMPAT_GCC)
|
||||
|
||||
# use these options for release builds - full optimization
|
||||
add_options (ALL_LANGUAGES "${_prof_RELEASE}" ${_opt_rel} ${_opt_flags})
|
||||
option(WITH_NDEBUG "Disable asserts in release mode" OFF)
|
||||
if(NOT WITH_NDEBUG)
|
||||
add_options (ALL_LANGUAGES "${_prof_RELEASE}" -UNDEBUG)
|
||||
option(WITH_NDEBUG "Disable asserts in release mode" ON)
|
||||
if(WITH_NDEBUG)
|
||||
add_options (ALL_LANGUAGES "${_prof_RELEASE}" -DNDEBUG)
|
||||
endif()
|
||||
|
||||
else ()
|
||||
|
||||
@@ -24,16 +24,9 @@ if (cmake_build_type_upper_ MATCHES DEBUG)
|
||||
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
|
||||
"#define PROJECT_VERSION_HASH \"debug\"\n"
|
||||
"#define PROJECT_VERSION \"${${project}_LABEL} (debug)\"\n"
|
||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
||||
)
|
||||
|
||||
# Write header file with build timestamp
|
||||
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
|
||||
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
)
|
||||
else ()
|
||||
if (NOT GIT_FOUND)
|
||||
find_package (Git)
|
||||
@@ -50,15 +43,9 @@ else ()
|
||||
"#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n"
|
||||
"#define PROJECT_VERSION_HASH \"unknown git version\"\n"
|
||||
"#define PROJECT_VERSION \"${${project}_LABEL} (unknown git version)\"\n"
|
||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
||||
)
|
||||
# Write header file with build timestamp
|
||||
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
|
||||
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
)
|
||||
else ()
|
||||
add_custom_target (update-version ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
|
||||
138
cmake/Modules/compat-2.8.3/CMakeParseArguments.cmake
Normal file
138
cmake/Modules/compat-2.8.3/CMakeParseArguments.cmake
Normal file
@@ -0,0 +1,138 @@
|
||||
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
|
||||
#
|
||||
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for
|
||||
# parsing the arguments given to that macro or function.
|
||||
# It processes the arguments and defines a set of variables which hold the
|
||||
# values of the respective options.
|
||||
#
|
||||
# The <options> argument contains all options for the respective macro,
|
||||
# i.e. keywords which can be used when calling the macro without any value
|
||||
# following, like e.g. the OPTIONAL keyword of the install() command.
|
||||
#
|
||||
# The <one_value_keywords> argument contains all keywords for this macro
|
||||
# which are followed by one value, like e.g. DESTINATION keyword of the
|
||||
# install() command.
|
||||
#
|
||||
# The <multi_value_keywords> argument contains all keywords for this macro
|
||||
# which can be followed by more than one value, like e.g. the TARGETS or
|
||||
# FILES keywords of the install() command.
|
||||
#
|
||||
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
|
||||
# keywords listed in <options>, <one_value_keywords> and
|
||||
# <multi_value_keywords> a variable composed of the given <prefix>
|
||||
# followed by "_" and the name of the respective keyword.
|
||||
# These variables will then hold the respective value from the argument list.
|
||||
# For the <options> keywords this will be TRUE or FALSE.
|
||||
#
|
||||
# All remaining arguments are collected in a variable
|
||||
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether
|
||||
# your macro was called with unrecognized parameters.
|
||||
#
|
||||
# As an example here a my_install() macro, which takes similar arguments as the
|
||||
# real install() command:
|
||||
#
|
||||
# function(MY_INSTALL)
|
||||
# set(options OPTIONAL FAST)
|
||||
# set(oneValueArgs DESTINATION RENAME)
|
||||
# set(multiValueArgs TARGETS CONFIGURATIONS)
|
||||
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
# ...
|
||||
#
|
||||
# Assume my_install() has been called like this:
|
||||
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
|
||||
#
|
||||
# After the cmake_parse_arguments() call the macro will have set the following
|
||||
# variables:
|
||||
# MY_INSTALL_OPTIONAL = TRUE
|
||||
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
|
||||
# MY_INSTALL_DESTINATION = "bin"
|
||||
# MY_INSTALL_RENAME = "" (was not used)
|
||||
# MY_INSTALL_TARGETS = "foo;bar"
|
||||
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
|
||||
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
|
||||
#
|
||||
# You can the continue and process these variables.
|
||||
#
|
||||
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword
|
||||
# another recognized keyword follows, this is interpreted as the beginning of
|
||||
# the new option.
|
||||
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
|
||||
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
|
||||
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
|
||||
|
||||
|
||||
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
|
||||
# first set all result variables to empty/FALSE
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach(arg_name)
|
||||
|
||||
foreach(option ${_optionNames})
|
||||
set(${prefix}_${option} FALSE)
|
||||
endforeach(option)
|
||||
|
||||
set(${prefix}_UNPARSED_ARGUMENTS)
|
||||
|
||||
set(insideValues FALSE)
|
||||
set(currentArgName)
|
||||
|
||||
# now iterate over all arguments and fill the result variables
|
||||
foreach(currentArg ${ARGN})
|
||||
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
|
||||
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
|
||||
if(insideValues)
|
||||
if("${insideValues}" STREQUAL "SINGLE")
|
||||
set(${prefix}_${currentArgName} ${currentArg})
|
||||
set(insideValues FALSE)
|
||||
elseif("${insideValues}" STREQUAL "MULTI")
|
||||
list(APPEND ${prefix}_${currentArgName} ${currentArg})
|
||||
endif()
|
||||
else(insideValues)
|
||||
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
|
||||
endif(insideValues)
|
||||
else()
|
||||
if(NOT ${optionIndex} EQUAL -1)
|
||||
set(${prefix}_${currentArg} TRUE)
|
||||
set(insideValues FALSE)
|
||||
elseif(NOT ${singleArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "SINGLE")
|
||||
elseif(NOT ${multiArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "MULTI")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endforeach(currentArg)
|
||||
|
||||
# propagate the result variables to the caller:
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
|
||||
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
|
||||
endforeach(arg_name)
|
||||
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
|
||||
|
||||
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)
|
||||
47
cmake/Modules/compat-2.8.5/FindGit.cmake
Normal file
47
cmake/Modules/compat-2.8.5/FindGit.cmake
Normal file
@@ -0,0 +1,47 @@
|
||||
# The module defines the following variables:
|
||||
# GIT_EXECUTABLE - path to git command line client
|
||||
# GIT_FOUND - true if the command line client was found
|
||||
# Example usage:
|
||||
# find_package(Git)
|
||||
# if(GIT_FOUND)
|
||||
# message("git found: ${GIT_EXECUTABLE}")
|
||||
# endif()
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Look for 'git' or 'eg' (easy git)
|
||||
#
|
||||
set(git_names git eg)
|
||||
|
||||
# Prefer .cmd variants on Windows unless running in a Makefile
|
||||
# in the MSYS shell.
|
||||
#
|
||||
if(WIN32)
|
||||
if(NOT CMAKE_GENERATOR MATCHES "MSYS")
|
||||
set(git_names git.cmd git eg.cmd eg)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_program(GIT_EXECUTABLE
|
||||
NAMES ${git_names}
|
||||
PATH_SUFFIXES Git/cmd Git/bin
|
||||
DOC "git command line client"
|
||||
)
|
||||
mark_as_advanced(GIT_EXECUTABLE)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)
|
||||
61
cmake/Modules/compat-2.8.7/CMakePushCheckState.cmake
Normal file
61
cmake/Modules/compat-2.8.7/CMakePushCheckState.cmake
Normal file
@@ -0,0 +1,61 @@
|
||||
# This module defines two macros:
|
||||
# CMAKE_PUSH_CHECK_STATE()
|
||||
# and
|
||||
# CMAKE_POP_CHECK_STATE()
|
||||
# These two macros can be used to save and restore the state of the variables
|
||||
# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES
|
||||
# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake,
|
||||
# like e.g. check_function_exists() etc.
|
||||
# The variable contents are pushed on a stack, pushing multiple times is supported.
|
||||
# This is useful e.g. when executing such tests in a Find-module, where they have to be set,
|
||||
# but after the Find-module has been executed they should have the same value
|
||||
# as they had before.
|
||||
#
|
||||
# Usage:
|
||||
# cmake_push_check_state()
|
||||
# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
|
||||
# check_function_exists(...)
|
||||
# cmake_pop_check_state()
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2006-2011 Alexander Neundorf, <neundorf@kde.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
MACRO(CMAKE_PUSH_CHECK_STATE)
|
||||
|
||||
IF(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER)
|
||||
SET(_CMAKE_PUSH_CHECK_STATE_COUNTER 0)
|
||||
ENDIF()
|
||||
|
||||
MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
|
||||
|
||||
SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
|
||||
SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
|
||||
SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
|
||||
SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS})
|
||||
ENDMACRO(CMAKE_PUSH_CHECK_STATE)
|
||||
|
||||
MACRO(CMAKE_POP_CHECK_STATE)
|
||||
|
||||
# don't pop more than we pushed
|
||||
IF("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
|
||||
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
|
||||
|
||||
MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
|
||||
ENDIF()
|
||||
|
||||
ENDMACRO(CMAKE_POP_CHECK_STATE)
|
||||
624
cmake/Modules/compat-2.8.7/FindBLAS.cmake
Normal file
624
cmake/Modules/compat-2.8.7/FindBLAS.cmake
Normal file
@@ -0,0 +1,624 @@
|
||||
# - Find BLAS library
|
||||
# This module finds an installed fortran library that implements the BLAS
|
||||
# linear-algebra interface (see http://www.netlib.org/blas/).
|
||||
# The list of libraries searched for is taken
|
||||
# from the autoconf macro file, acx_blas.m4 (distributed at
|
||||
# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
|
||||
#
|
||||
# This module sets the following variables:
|
||||
# BLAS_FOUND - set to true if a library implementing the BLAS interface
|
||||
# is found
|
||||
# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
|
||||
# and -L).
|
||||
# BLAS_LIBRARIES - uncached list of libraries (using full path name) to
|
||||
# link against to use BLAS
|
||||
# BLAS95_LIBRARIES - uncached list of libraries (using full path name)
|
||||
# to link against to use BLAS95 interface
|
||||
# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
|
||||
# is found
|
||||
# BLA_STATIC if set on this determines what kind of linkage we do (static)
|
||||
# BLA_VENDOR if set checks only the specified vendor, if not set checks
|
||||
# all the possibilities
|
||||
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
|
||||
##########
|
||||
### List of vendors (BLA_VENDOR) valid in this module
|
||||
## Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model),
|
||||
## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic
|
||||
# C/CXX should be enabled to use Intel mkl
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckFortranFunctionExists)
|
||||
|
||||
set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
||||
# Check the language being used
|
||||
get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES )
|
||||
if( _LANGUAGES_ MATCHES Fortran )
|
||||
set( _CHECK_FORTRAN TRUE )
|
||||
elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) )
|
||||
set( _CHECK_FORTRAN FALSE )
|
||||
else()
|
||||
if(BLAS_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
|
||||
else(BLAS_FIND_REQUIRED)
|
||||
message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)")
|
||||
return()
|
||||
endif(BLAS_FIND_REQUIRED)
|
||||
endif( )
|
||||
|
||||
macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
|
||||
# This macro checks for the existence of the combination of fortran libraries
|
||||
# given by _list. If the combination is found, this macro checks (using the
|
||||
# Check_Fortran_Function_Exists macro) whether can link against that library
|
||||
# combination using the name of a routine given by _name using the linker
|
||||
# flags given by _flags. If the combination of libraries is found and passes
|
||||
# the link test, LIBRARIES is set to the list of complete library paths that
|
||||
# have been found. Otherwise, LIBRARIES is set to FALSE.
|
||||
|
||||
# N.B. _prefix is the prefix applied to the names of all cached variables that
|
||||
# are generated internally and marked advanced by this macro.
|
||||
|
||||
set(_libdir ${ARGN})
|
||||
|
||||
set(_libraries_work TRUE)
|
||||
set(${LIBRARIES})
|
||||
set(_combined_name)
|
||||
if (NOT _libdir)
|
||||
if (WIN32)
|
||||
set(_libdir ENV LIB)
|
||||
elseif (APPLE)
|
||||
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH)
|
||||
else ()
|
||||
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
|
||||
endif ()
|
||||
endif ()
|
||||
foreach(_library ${_list})
|
||||
set(_combined_name ${_combined_name}_${_library})
|
||||
|
||||
if(_libraries_work)
|
||||
if (BLA_STATIC)
|
||||
if (WIN32)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif ( WIN32 )
|
||||
if (APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
else (APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif (APPLE)
|
||||
else (BLA_STATIC)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# for ubuntu's libblas3gf and liblapack3gf packages
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
|
||||
endif ()
|
||||
endif (BLA_STATIC)
|
||||
find_library(${_prefix}_${_library}_LIBRARY
|
||||
NAMES ${_library}
|
||||
PATHS ${_libdir}
|
||||
)
|
||||
mark_as_advanced(${_prefix}_${_library}_LIBRARY)
|
||||
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
|
||||
set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
|
||||
endif(_libraries_work)
|
||||
endforeach(_library ${_list})
|
||||
if(_libraries_work)
|
||||
# Test this combination of libraries.
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threads})
|
||||
# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
|
||||
if (_CHECK_FORTRAN)
|
||||
check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
|
||||
else()
|
||||
check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
|
||||
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
|
||||
endif(_libraries_work)
|
||||
if(NOT _libraries_work)
|
||||
set(${LIBRARIES} FALSE)
|
||||
endif(NOT _libraries_work)
|
||||
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
|
||||
endmacro(Check_Fortran_Libraries)
|
||||
|
||||
set(BLAS_LINKER_FLAGS)
|
||||
set(BLAS_LIBRARIES)
|
||||
set(BLAS95_LIBRARIES)
|
||||
if ($ENV{BLA_VENDOR} MATCHES ".+")
|
||||
set(BLA_VENDOR $ENV{BLA_VENDOR})
|
||||
else ($ENV{BLA_VENDOR} MATCHES ".+")
|
||||
if(NOT BLA_VENDOR)
|
||||
set(BLA_VENDOR "All")
|
||||
endif(NOT BLA_VENDOR)
|
||||
endif ($ENV{BLA_VENDOR} MATCHES ".+")
|
||||
|
||||
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
# gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"goto2"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
dgemm
|
||||
""
|
||||
"f77blas;atlas"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
|
||||
if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"sgemm;dgemm;blas"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
# BLAS in Alpha CXML library?
|
||||
if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"cxml"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
# BLAS in Alpha DXML library? (now called CXML, see above)
|
||||
if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"dxml"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
# BLAS in Sun Performance library?
|
||||
if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
"-xlic_lib=sunperf"
|
||||
"sunperf;sunmath"
|
||||
""
|
||||
)
|
||||
if(BLAS_LIBRARIES)
|
||||
set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
|
||||
endif(BLAS_LIBRARIES)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
# BLAS in SCSL library? (SGI/Cray Scientific Library)
|
||||
if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"scsl"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
# BLAS in SGIMATH library?
|
||||
if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"complib.sgimath"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
|
||||
if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"essl;blas"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
#BLAS in acml library?
|
||||
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
|
||||
if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
|
||||
((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
|
||||
((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
|
||||
)
|
||||
# try to find acml in "standard" paths
|
||||
if( WIN32 )
|
||||
file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" )
|
||||
else()
|
||||
file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" )
|
||||
endif()
|
||||
if( WIN32 )
|
||||
file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" )
|
||||
else()
|
||||
file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" )
|
||||
endif()
|
||||
list(GET _ACML_ROOT 0 _ACML_ROOT)
|
||||
list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
|
||||
if( _ACML_ROOT )
|
||||
get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH )
|
||||
if( SIZEOF_INTEGER EQUAL 8 )
|
||||
set( _ACML_PATH_SUFFIX "_int64" )
|
||||
else()
|
||||
set( _ACML_PATH_SUFFIX "" )
|
||||
endif()
|
||||
if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
|
||||
set( _ACML_COMPILER32 "ifort32" )
|
||||
set( _ACML_COMPILER64 "ifort64" )
|
||||
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
|
||||
set( _ACML_COMPILER32 "sun32" )
|
||||
set( _ACML_COMPILER64 "sun64" )
|
||||
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" )
|
||||
set( _ACML_COMPILER32 "pgi32" )
|
||||
if( WIN32 )
|
||||
set( _ACML_COMPILER64 "win64" )
|
||||
else()
|
||||
set( _ACML_COMPILER64 "pgi64" )
|
||||
endif()
|
||||
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" )
|
||||
# 32 bit builds not supported on Open64 but for code simplicity
|
||||
# We'll just use the same directory twice
|
||||
set( _ACML_COMPILER32 "open64_64" )
|
||||
set( _ACML_COMPILER64 "open64_64" )
|
||||
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
|
||||
set( _ACML_COMPILER32 "nag32" )
|
||||
set( _ACML_COMPILER64 "nag64" )
|
||||
else() #if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
|
||||
set( _ACML_COMPILER32 "gfortran32" )
|
||||
set( _ACML_COMPILER64 "gfortran64" )
|
||||
endif()
|
||||
|
||||
if( BLA_VENDOR STREQUAL "ACML_MP" )
|
||||
set(_ACML_MP_LIB_DIRS
|
||||
"${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
|
||||
"${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" )
|
||||
else() #if( _BLAS_VENDOR STREQUAL "ACML" )
|
||||
set(_ACML_LIB_DIRS
|
||||
"${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
|
||||
"${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" )
|
||||
endif()
|
||||
endif()
|
||||
elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
|
||||
set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
|
||||
endif()
|
||||
|
||||
if( BLA_VENDOR STREQUAL "ACML_MP" )
|
||||
foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS})
|
||||
check_fortran_libraries (
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
"" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS}
|
||||
)
|
||||
if( BLAS_LIBRARIES )
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
elseif( BLA_VENDOR STREQUAL "ACML_GPU" )
|
||||
foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS})
|
||||
check_fortran_libraries (
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
"" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS}
|
||||
)
|
||||
if( BLAS_LIBRARIES )
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
else() #if( _BLAS_VENDOR STREQUAL "ACML" )
|
||||
foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} )
|
||||
check_fortran_libraries (
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
"" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS}
|
||||
)
|
||||
if( BLAS_LIBRARIES )
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"acml;acml_mv"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"acml_mp;acml_mv"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"acml;acml_mv;CALBLAS"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif () # ACML
|
||||
|
||||
# Apple BLAS library?
|
||||
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
dgemm
|
||||
""
|
||||
"Accelerate"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
|
||||
if ( NOT BLAS_LIBRARIES )
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
dgemm
|
||||
""
|
||||
"vecLib"
|
||||
""
|
||||
)
|
||||
endif ( NOT BLAS_LIBRARIES )
|
||||
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
|
||||
# Generic BLAS library?
|
||||
if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"blas"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
#BLAS in intel mkl 10 library? (em64t 64bit)
|
||||
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
|
||||
if (NOT WIN32)
|
||||
set(LM "-lm")
|
||||
endif ()
|
||||
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
|
||||
if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
|
||||
find_package(Threads)
|
||||
else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
|
||||
if (WIN32)
|
||||
if(BLA_F95)
|
||||
if(NOT BLAS95_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS95_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl_blas95;mkl_intel_c;mkl_intel_thread;mkl_core;libguide40"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS95_LIBRARIES)
|
||||
else(BLA_F95)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
SGEMM
|
||||
""
|
||||
"mkl_c_dll;mkl_intel_thread_dll;mkl_core_dll;libguide40"
|
||||
""
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif(BLA_F95)
|
||||
else(WIN32)
|
||||
if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
|
||||
if(BLA_F95)
|
||||
if(NOT BLAS95_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS95_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl_blas95;mkl_intel;mkl_intel_thread;mkl_core;guide"
|
||||
"${CMAKE_THREAD_LIBS_INIT};${LM}"
|
||||
)
|
||||
endif(NOT BLAS95_LIBRARIES)
|
||||
else(BLA_F95)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl_intel;mkl_intel_thread;mkl_core;guide"
|
||||
"${CMAKE_THREAD_LIBS_INIT}"
|
||||
"${LM}"
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif(BLA_F95)
|
||||
endif (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
|
||||
if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
|
||||
if(BLA_F95)
|
||||
if(NOT BLAS95_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS95_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl_blas95;mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
|
||||
"${CMAKE_THREAD_LIBS_INIT};${LM}"
|
||||
)
|
||||
endif(NOT BLAS95_LIBRARIES)
|
||||
else(BLA_F95)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
|
||||
"${CMAKE_THREAD_LIBS_INIT};${LM}"
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif(BLA_F95)
|
||||
endif (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
|
||||
endif (WIN32)
|
||||
#older vesions of intel mkl libs
|
||||
# BLAS in intel mkl library? (shared)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl;guide"
|
||||
"${CMAKE_THREAD_LIBS_INIT};${LM}"
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
#BLAS in intel mkl library? (static, 32bit)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl_ia32;guide"
|
||||
"${CMAKE_THREAD_LIBS_INIT};${LM}"
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
#BLAS in intel mkl library? (static, em64t 64bit)
|
||||
if(NOT BLAS_LIBRARIES)
|
||||
check_fortran_libraries(
|
||||
BLAS_LIBRARIES
|
||||
BLAS
|
||||
sgemm
|
||||
""
|
||||
"mkl_em64t;guide"
|
||||
"${CMAKE_THREAD_LIBS_INIT};${LM}"
|
||||
)
|
||||
endif(NOT BLAS_LIBRARIES)
|
||||
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
|
||||
endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
|
||||
if(BLA_F95)
|
||||
if(BLAS95_LIBRARIES)
|
||||
set(BLAS95_FOUND TRUE)
|
||||
else(BLAS95_LIBRARIES)
|
||||
set(BLAS95_FOUND FALSE)
|
||||
endif(BLAS95_LIBRARIES)
|
||||
|
||||
if(NOT BLAS_FIND_QUIETLY)
|
||||
if(BLAS95_FOUND)
|
||||
message(STATUS "A library with BLAS95 API found.")
|
||||
else(BLAS95_FOUND)
|
||||
if(BLAS_FIND_REQUIRED)
|
||||
message(FATAL_ERROR
|
||||
"A required library with BLAS95 API not found. Please specify library location.")
|
||||
else(BLAS_FIND_REQUIRED)
|
||||
message(STATUS
|
||||
"A library with BLAS95 API not found. Please specify library location.")
|
||||
endif(BLAS_FIND_REQUIRED)
|
||||
endif(BLAS95_FOUND)
|
||||
endif(NOT BLAS_FIND_QUIETLY)
|
||||
set(BLAS_FOUND TRUE)
|
||||
set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
|
||||
else(BLA_F95)
|
||||
if(BLAS_LIBRARIES)
|
||||
set(BLAS_FOUND TRUE)
|
||||
else(BLAS_LIBRARIES)
|
||||
set(BLAS_FOUND FALSE)
|
||||
endif(BLAS_LIBRARIES)
|
||||
|
||||
if(NOT BLAS_FIND_QUIETLY)
|
||||
if(BLAS_FOUND)
|
||||
message(STATUS "A library with BLAS API found.")
|
||||
else(BLAS_FOUND)
|
||||
if(BLAS_FIND_REQUIRED)
|
||||
message(FATAL_ERROR
|
||||
"A required library with BLAS API not found. Please specify library location."
|
||||
)
|
||||
else(BLAS_FIND_REQUIRED)
|
||||
message(STATUS
|
||||
"A library with BLAS API not found. Please specify library location."
|
||||
)
|
||||
endif(BLAS_FIND_REQUIRED)
|
||||
endif(BLAS_FOUND)
|
||||
endif(NOT BLAS_FIND_QUIETLY)
|
||||
endif(BLA_F95)
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
307
cmake/Modules/compat-2.8.7/FindLAPACK.cmake
Normal file
307
cmake/Modules/compat-2.8.7/FindLAPACK.cmake
Normal file
@@ -0,0 +1,307 @@
|
||||
# - Find LAPACK library
|
||||
# This module finds an installed fortran library that implements the LAPACK
|
||||
# linear-algebra interface (see http://www.netlib.org/lapack/).
|
||||
#
|
||||
# The approach follows that taken for the autoconf macro file, acx_lapack.m4
|
||||
# (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
|
||||
#
|
||||
# This module sets the following variables:
|
||||
# LAPACK_FOUND - set to true if a library implementing the LAPACK interface
|
||||
# is found
|
||||
# LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
|
||||
# and -L).
|
||||
# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
|
||||
# link against to use LAPACK
|
||||
# LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
|
||||
# link against to use LAPACK95
|
||||
# LAPACK95_FOUND - set to true if a library implementing the LAPACK f95
|
||||
# interface is found
|
||||
# BLA_STATIC if set on this determines what kind of linkage we do (static)
|
||||
# BLA_VENDOR if set checks only the specified vendor, if not set checks
|
||||
# all the possibilities
|
||||
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
|
||||
### List of vendors (BLA_VENDOR) valid in this module
|
||||
## Intel(mkl), ACML,Apple, NAS, Generic
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2007-2009 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
||||
get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
if (NOT _LANGUAGES_ MATCHES Fortran)
|
||||
include(CheckFunctionExists)
|
||||
else (NOT _LANGUAGES_ MATCHES Fortran)
|
||||
include(CheckFortranFunctionExists)
|
||||
endif (NOT _LANGUAGES_ MATCHES Fortran)
|
||||
|
||||
set(LAPACK_FOUND FALSE)
|
||||
set(LAPACK95_FOUND FALSE)
|
||||
|
||||
# TODO: move this stuff to separate module
|
||||
|
||||
macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads)
|
||||
# This macro checks for the existence of the combination of fortran libraries
|
||||
# given by _list. If the combination is found, this macro checks (using the
|
||||
# Check_Fortran_Function_Exists macro) whether can link against that library
|
||||
# combination using the name of a routine given by _name using the linker
|
||||
# flags given by _flags. If the combination of libraries is found and passes
|
||||
# the link test, LIBRARIES is set to the list of complete library paths that
|
||||
# have been found. Otherwise, LIBRARIES is set to FALSE.
|
||||
|
||||
# N.B. _prefix is the prefix applied to the names of all cached variables that
|
||||
# are generated internally and marked advanced by this macro.
|
||||
|
||||
set(_libraries_work TRUE)
|
||||
set(${LIBRARIES})
|
||||
set(_combined_name)
|
||||
if (NOT _libdir)
|
||||
if (WIN32)
|
||||
set(_libdir ENV LIB)
|
||||
elseif (APPLE)
|
||||
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH)
|
||||
else ()
|
||||
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
|
||||
endif ()
|
||||
endif ()
|
||||
foreach(_library ${_list})
|
||||
set(_combined_name ${_combined_name}_${_library})
|
||||
|
||||
if(_libraries_work)
|
||||
if (BLA_STATIC)
|
||||
if (WIN32)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif ( WIN32 )
|
||||
if (APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
else (APPLE)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif (APPLE)
|
||||
else (BLA_STATIC)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
# for ubuntu's libblas3gf and liblapack3gf packages
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
|
||||
endif ()
|
||||
endif (BLA_STATIC)
|
||||
find_library(${_prefix}_${_library}_LIBRARY
|
||||
NAMES ${_library}
|
||||
PATHS ${_libdir}
|
||||
)
|
||||
mark_as_advanced(${_prefix}_${_library}_LIBRARY)
|
||||
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
|
||||
set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
|
||||
endif(_libraries_work)
|
||||
endforeach(_library ${_list})
|
||||
|
||||
if(_libraries_work)
|
||||
# Test this combination of libraries.
|
||||
if(UNIX AND BLA_STATIC)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads})
|
||||
else(UNIX AND BLA_STATIC)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads})
|
||||
endif(UNIX AND BLA_STATIC)
|
||||
# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
|
||||
if (NOT _LANGUAGES_ MATCHES Fortran)
|
||||
check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
|
||||
else (NOT _LANGUAGES_ MATCHES Fortran)
|
||||
check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
|
||||
endif (NOT _LANGUAGES_ MATCHES Fortran)
|
||||
set(CMAKE_REQUIRED_LIBRARIES)
|
||||
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
|
||||
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
|
||||
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
|
||||
endif(_libraries_work)
|
||||
|
||||
if(_libraries_work)
|
||||
set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
|
||||
else(_libraries_work)
|
||||
set(${LIBRARIES} FALSE)
|
||||
endif(_libraries_work)
|
||||
|
||||
endmacro(Check_Lapack_Libraries)
|
||||
|
||||
|
||||
set(LAPACK_LINKER_FLAGS)
|
||||
set(LAPACK_LIBRARIES)
|
||||
set(LAPACK95_LIBRARIES)
|
||||
|
||||
|
||||
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
|
||||
find_package(BLAS)
|
||||
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
|
||||
find_package(BLAS REQUIRED)
|
||||
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
|
||||
|
||||
|
||||
if(BLAS_FOUND)
|
||||
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
|
||||
if ($ENV{BLA_VENDOR} MATCHES ".+")
|
||||
set(BLA_VENDOR $ENV{BLA_VENDOR})
|
||||
else ($ENV{BLA_VENDOR} MATCHES ".+")
|
||||
if(NOT BLA_VENDOR)
|
||||
set(BLA_VENDOR "All")
|
||||
endif(NOT BLA_VENDOR)
|
||||
endif ($ENV{BLA_VENDOR} MATCHES ".+")
|
||||
|
||||
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT LAPACK_LIBRARIES)
|
||||
check_lapack_libraries(
|
||||
LAPACK_LIBRARIES
|
||||
LAPACK
|
||||
cheev
|
||||
""
|
||||
"goto2"
|
||||
"${BLAS_LIBRARIES}"
|
||||
""
|
||||
)
|
||||
endif(NOT LAPACK_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
|
||||
|
||||
|
||||
#acml lapack
|
||||
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
|
||||
if (BLAS_LIBRARIES MATCHES ".+acml.+")
|
||||
set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Apple LAPACK library?
|
||||
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
|
||||
if(NOT LAPACK_LIBRARIES)
|
||||
check_lapack_libraries(
|
||||
LAPACK_LIBRARIES
|
||||
LAPACK
|
||||
cheev
|
||||
""
|
||||
"Accelerate"
|
||||
"${BLAS_LIBRARIES}"
|
||||
""
|
||||
)
|
||||
endif(NOT LAPACK_LIBRARIES)
|
||||
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
|
||||
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
|
||||
if ( NOT LAPACK_LIBRARIES )
|
||||
check_lapack_libraries(
|
||||
LAPACK_LIBRARIES
|
||||
LAPACK
|
||||
cheev
|
||||
""
|
||||
"vecLib"
|
||||
"${BLAS_LIBRARIES}"
|
||||
""
|
||||
)
|
||||
endif ( NOT LAPACK_LIBRARIES )
|
||||
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
|
||||
# Generic LAPACK library?
|
||||
if (BLA_VENDOR STREQUAL "Generic" OR
|
||||
BLA_VENDOR STREQUAL "ATLAS" OR
|
||||
BLA_VENDOR STREQUAL "All")
|
||||
if ( NOT LAPACK_LIBRARIES )
|
||||
check_lapack_libraries(
|
||||
LAPACK_LIBRARIES
|
||||
LAPACK
|
||||
cheev
|
||||
""
|
||||
"lapack"
|
||||
"${BLAS_LIBRARIES}"
|
||||
""
|
||||
)
|
||||
endif ( NOT LAPACK_LIBRARIES )
|
||||
endif ()
|
||||
#intel lapack
|
||||
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
|
||||
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
|
||||
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
|
||||
find_PACKAGE(Threads)
|
||||
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
|
||||
if (BLA_F95)
|
||||
if(NOT LAPACK95_LIBRARIES)
|
||||
check_lapack_libraries(
|
||||
LAPACK95_LIBRARIES
|
||||
LAPACK
|
||||
cheev
|
||||
""
|
||||
"mkl_lapack95"
|
||||
"${BLAS95_LIBRARIES}"
|
||||
"${CMAKE_THREAD_LIBS_INIT}"
|
||||
)
|
||||
endif(NOT LAPACK95_LIBRARIES)
|
||||
else(BLA_F95)
|
||||
if(NOT LAPACK_LIBRARIES)
|
||||
check_lapack_libraries(
|
||||
LAPACK_LIBRARIES
|
||||
LAPACK
|
||||
cheev
|
||||
""
|
||||
"mkl_lapack"
|
||||
"${BLAS_LIBRARIES}"
|
||||
"${CMAKE_THREAD_LIBS_INIT}"
|
||||
)
|
||||
endif(NOT LAPACK_LIBRARIES)
|
||||
endif(BLA_F95)
|
||||
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
|
||||
endif(BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
|
||||
else(BLAS_FOUND)
|
||||
message(STATUS "LAPACK requires BLAS")
|
||||
endif(BLAS_FOUND)
|
||||
|
||||
if(BLA_F95)
|
||||
if(LAPACK95_LIBRARIES)
|
||||
set(LAPACK95_FOUND TRUE)
|
||||
else(LAPACK95_LIBRARIES)
|
||||
set(LAPACK95_FOUND FALSE)
|
||||
endif(LAPACK95_LIBRARIES)
|
||||
if(NOT LAPACK_FIND_QUIETLY)
|
||||
if(LAPACK95_FOUND)
|
||||
message(STATUS "A library with LAPACK95 API found.")
|
||||
else(LAPACK95_FOUND)
|
||||
if(LAPACK_FIND_REQUIRED)
|
||||
message(FATAL_ERROR
|
||||
"A required library with LAPACK95 API not found. Please specify library location."
|
||||
)
|
||||
else(LAPACK_FIND_REQUIRED)
|
||||
message(STATUS
|
||||
"A library with LAPACK95 API not found. Please specify library location."
|
||||
)
|
||||
endif(LAPACK_FIND_REQUIRED)
|
||||
endif(LAPACK95_FOUND)
|
||||
endif(NOT LAPACK_FIND_QUIETLY)
|
||||
set(LAPACK_FOUND "${LAPACK95_FOUND}")
|
||||
set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}")
|
||||
else(BLA_F95)
|
||||
if(LAPACK_LIBRARIES)
|
||||
set(LAPACK_FOUND TRUE)
|
||||
else(LAPACK_LIBRARIES)
|
||||
set(LAPACK_FOUND FALSE)
|
||||
endif(LAPACK_LIBRARIES)
|
||||
|
||||
if(NOT LAPACK_FIND_QUIETLY)
|
||||
if(LAPACK_FOUND)
|
||||
message(STATUS "A library with LAPACK API found.")
|
||||
else(LAPACK_FOUND)
|
||||
if(LAPACK_FIND_REQUIRED)
|
||||
message(FATAL_ERROR
|
||||
"A required library with LAPACK API not found. Please specify library location."
|
||||
)
|
||||
else(LAPACK_FIND_REQUIRED)
|
||||
message(STATUS
|
||||
"A library with LAPACK API not found. Please specify library location."
|
||||
)
|
||||
endif(LAPACK_FIND_REQUIRED)
|
||||
endif(LAPACK_FOUND)
|
||||
endif(NOT LAPACK_FIND_QUIETLY)
|
||||
endif(BLA_F95)
|
||||
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
@@ -56,6 +56,7 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp"
|
||||
"#define PROJECT_VERSION_NAME \"${PROJECT_LABEL}\"\n"
|
||||
"#define PROJECT_VERSION_HASH \"${sha1}\"\n"
|
||||
"#define PROJECT_VERSION \"${PROJECT_LABEL} (${sha1})\"\n"
|
||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||
"#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n"
|
||||
)
|
||||
|
||||
@@ -65,11 +66,3 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp"
|
||||
execute_process (COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/project-version.tmp" "${PROJECT_BINARY_DIR}/project-version.h"
|
||||
)
|
||||
|
||||
# Write header file with build timestamp
|
||||
file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h"
|
||||
"#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
"#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
"#define BUILD_TIMESTAMP \"${build_timestamp}\"\n"
|
||||
"#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n"
|
||||
)
|
||||
|
||||
@@ -816,7 +816,7 @@ HTML_COLORSTYLE_GAMMA = 80
|
||||
# page will contain the date and time when the page was generated. Setting
|
||||
# this to NO can help when comparing the output of multiple runs.
|
||||
|
||||
HTML_TIMESTAMP = NO
|
||||
HTML_TIMESTAMP = YES
|
||||
|
||||
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
|
||||
# documentation will contain sections that can be hidden and shown after the
|
||||
|
||||
@@ -93,16 +93,6 @@ if(NOT @opm-project_NAME@_FOUND)
|
||||
|
||||
# this is the contents of config.h as far as our probes can tell:
|
||||
|
||||
# Require correct CMake standard. Needed for user modules as
|
||||
# some software will add incompatible compile switches like
|
||||
# -std=gnu++11 otherwise when search for (I guess because of
|
||||
# imported targets using INTERFACE_COMPILE_FEATURES), and will
|
||||
# break compilation because of missing c++17 features.
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD @CMAKE_CXX_STANDARD@)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
# The settings in this block do not mix well with the DEST_PREFIX
|
||||
# setting.
|
||||
@@ -114,7 +104,6 @@ if(NOT @opm-project_NAME@_FOUND)
|
||||
@OPM_PROJECT_EXTRA_CODE@
|
||||
# end extra code
|
||||
|
||||
include(OpmPackage)
|
||||
include(@opm-project_NAME@-prereqs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
2
debian/changelog
vendored
2
debian/changelog
vendored
@@ -1,4 +1,4 @@
|
||||
opm-common (2021.10-rfinal-1~bionic) bionic; urgency=medium
|
||||
opm-common (2020.04-1~xenial) xenial; urgency=medium
|
||||
|
||||
* New release
|
||||
|
||||
|
||||
2
debian/rules
vendored
2
debian/rules
vendored
@@ -20,7 +20,7 @@ override_dh_auto_build:
|
||||
|
||||
# consider using -DUSE_VERSIONED_DIR=ON if backporting
|
||||
override_dh_auto_configure:
|
||||
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-common1 -DWHOLE_PROG_OPTIM=ON -DUSE_RUNPATH=OFF -DWITH_NATIVE=OFF -DOPM_ENABLE_PYTHON=1 -DOPM_INSTALL_PYTHON=1 -DPYTHON_EXECUTABLE=/usr/bin/python3 -DOPM_ENABLE_EMBEDDED_PYTHON=1
|
||||
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_DOCDIR=share/doc/libopm-common1 -DWHOLE_PROG_OPTIM=ON -DUSE_RUNPATH=OFF -DWITH_NATIVE=OFF -DOPM_ENABLE_PYTHON=1 -DOPM_INSTALL_PYTHON=1 -DPYTHON_EXECUTABLE=/usr/bin/python3
|
||||
|
||||
override_dh_auto_install:
|
||||
dh_auto_install -- install-html
|
||||
|
||||
@@ -153,7 +153,7 @@ we currently have five different categories:
|
||||
|
||||
To infer the number of records in the keyword based on an
|
||||
internal calculation is not supported, hence for these keywords
|
||||
size is given as unknown, and the keywords are terminated when the
|
||||
size is given as unkown, and the keywords are terminated when the
|
||||
next valid keyword is found:
|
||||
|
||||
{"name" : "VFPPROD" , "size" : "UNKNOWN", ....
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
|
||||
.TH COMPAREECL "1" "April 2021" "compareECL 2020.04" "User Commands"
|
||||
.SH NAME
|
||||
compareECL \- Comparator for Eclipse files
|
||||
.SH DESCRIPTION
|
||||
compareECL compares ECLIPSE files (restart (.RST), unified restart (.UNRST), initial (.INIT), summary (.SMRY), unified summary (.UNSMRY) or .RFT) and gridsizes (from .EGRID or .GRID file) from two simulations.
|
||||
The program takes four arguments:
|
||||
.PP
|
||||
1. Case number 1, reference case (full path without extension)
|
||||
2. Case number 2, test case (full path without extension)
|
||||
3. Absolute tolerance
|
||||
4. Relative tolerance (between 0 and 1)
|
||||
.PP
|
||||
In addition, the program takes these options (which must be given before the arguments):
|
||||
.PP
|
||||
\fB\-a\fR Run a full analysis of errors.
|
||||
\fB\-h\fR Print help and exit.
|
||||
\fB\-d\fR Use report steps only when comparing results from summary files.
|
||||
\fB\-i\fR Execute integration test (regression test is default).
|
||||
.IP
|
||||
The integration test compares SGAS, SWAT and PRESSURE in unified restart files, and WOPR, WGPR, WWPR and WBHP (all wells) in summary file.
|
||||
.PP
|
||||
\fB\-k\fR Specify specific keyword to compare (capitalized), for examples \fB\-k\fR PRESSURE or \fB\-k\fR WOPR:A\-1H
|
||||
\fB\-l\fR Only do comparison for the last Report Step. This option is only valid for restart files.
|
||||
\fB\-n\fR Do not throw on errors.
|
||||
\fB\-p\fR Print keywords in both cases and exit.
|
||||
\fB\-r\fR compare a spesific report time step number in a restart file.
|
||||
\fB\-t\fR Specify ECLIPSE filetype to compare, (default behaviour is that all files are compared if found). Different possible arguments are:
|
||||
.TP
|
||||
\fB\-t\fR UNRST
|
||||
Compare two unified restart files (.UNRST). This the default value, so it is the same as not passing option \fB\-t\fR.
|
||||
.TP
|
||||
\fB\-t\fR EGRID
|
||||
Compare two EGrid files (.EGRID).
|
||||
.TP
|
||||
\fB\-t\fR INIT
|
||||
Compare two initial files (.INIT).
|
||||
.TP
|
||||
\fB\-t\fR RFT
|
||||
Compare two RFT files (.RFT).
|
||||
.TP
|
||||
\fB\-t\fR SMRY
|
||||
Compare two cases consistent of (unified) summary files.
|
||||
.PP
|
||||
\fB\-x\fR Allow extra keywords in case number 2. These additional keywords (not found in case number1) will be ignored in the comparison.
|
||||
.PP
|
||||
Example usage of the program:
|
||||
.PP
|
||||
compareECL \fB\-k\fR PRESSURE <path to first casefile> <path to second casefile> 1e\-3 1e\-5
|
||||
compareECL \fB\-t\fR INIT \fB\-k\fR PORO <path to first casefile> <path to second casefile> 1e\-3 1e\-5
|
||||
compareECL \fB\-i\fR <path to first casefile> <path to second casefile> 0.01 1e\-6
|
||||
.PP
|
||||
Exceptions are thrown (and hence program exits) when deviations are larger than the specified tolerances, or when the number of cells does not match \fB\-\-\fR either in the grid file or for a specific keyword. Information about the keyword, keyword occurrence (zero based) and cell coordinate is printed when an exception is thrown. For more information about how the cases are compared, see the documentation of the EclFilesComparator class.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B compareECL
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B compareECL
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info compareECL
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
@@ -1,24 +0,0 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
|
||||
.TH CONVERTECL "1" "April 2021" "convertECL 2020.04" "User Commands"
|
||||
.SH NAME
|
||||
convertECL \- Converter for Eclipse files (binary <-> formatted format)
|
||||
.SH DESCRIPTION
|
||||
convertECL needs one argument which is the input file to be converted. If this is a binary file the output file will be formatted. If the input file is formatted the output will be binary.
|
||||
.PP
|
||||
In addition, the program takes these options (which must be given before the arguments):
|
||||
.PP
|
||||
\fB\-h\fR Print help and exit.
|
||||
\fB\-l\fR list report step numbers in the selected restart file.
|
||||
\fB\-r\fR extract and convert a spesific report time step number from a unified restart file.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B convertECL
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B convertECL
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info convertECL
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
@@ -1,54 +0,0 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
|
||||
.TH OPMHASH "1" "April 2021" "opmhash 2020.04" "User Commands"
|
||||
.SH NAME
|
||||
opmhash \- Hasher for summary keywords in Eclipse files
|
||||
.SH DESCRIPTION
|
||||
opmhash: invalid option \fB\-\-\fR 'h'
|
||||
The purpose of the opmhash program is to load a deck and create a summary, by
|
||||
diffing two such summaries it is simple to determine if two decks are similar.
|
||||
For each keyword a hash of the normalized content is calculated. The output of
|
||||
the program will look like this:
|
||||
.TP
|
||||
RUNSPEC
|
||||
: 13167205945009276792
|
||||
.TP
|
||||
TITLE
|
||||
: 16047371705964514902
|
||||
.TP
|
||||
DIMENS
|
||||
: 1264233216877515756
|
||||
.TP
|
||||
NONNC
|
||||
: 10052807539267647959
|
||||
.TP
|
||||
OIL
|
||||
: 6013609912232720008
|
||||
.TP
|
||||
WATER
|
||||
: 14106203893673265964
|
||||
.TP
|
||||
Total
|
||||
: 7362809723723482303
|
||||
.PP
|
||||
Where the 'random' integer following each keyword is the hash of the content of
|
||||
that keyword. The hashing is insensitive to changes in white\-space and comments
|
||||
and file location. At the bottom comes a total hash of the complete content. The
|
||||
hash of each keyword is insensitive to shuffling of keywords, but the total hash
|
||||
depends on the keyword order.
|
||||
.SH OPTIONS
|
||||
.HP
|
||||
\fB\-l\fR : Add filename and linenumber information to each keyword.
|
||||
.HP
|
||||
\fB\-s\fR : Short form \- only print the hash of the complete deck.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B opmhash
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B opmhash
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info opmhash
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
@@ -1,42 +0,0 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
|
||||
.TH OPMPACK "1" "April 2021" "opmpack 2020.04" "User Commands"
|
||||
.SH NAME
|
||||
opmpack \- Validator and printer of deck in Eclipse files without comments
|
||||
.SH DESCRIPTION
|
||||
opmpack: invalid option \fB\-\-\fR 'h'
|
||||
.PP
|
||||
The opmpack program will load a deck, resolve all include
|
||||
files and then print it out again on stdout. All comments
|
||||
will be stripped and the value types will be validated.
|
||||
.PP
|
||||
By passing the option \fB\-o\fR you can redirect the output to a file
|
||||
or a directory.
|
||||
.PP
|
||||
Print on stdout:
|
||||
.TP
|
||||
opmpack
|
||||
\fI\,/path/to/case/CASE.DATA\/\fP
|
||||
.PP
|
||||
Print MY_CASE.DATA in /tmp:
|
||||
.IP
|
||||
opmpack \fB\-o\fR \fI\,/tmp\/\fP /path/to/MY_CASE.DATA
|
||||
.PP
|
||||
Print NEW_CASE in cwd:
|
||||
.IP
|
||||
opmpack \fB\-o\fR NEW_CASE.DATA path/to/MY_CASE.DATA
|
||||
.PP
|
||||
As an alternative to the \fB\-o\fR option you can use \fB\-c\fR; that is equivalent to \fB\-o\fR \-
|
||||
but restart and import files referred to in the deck are also copied. The \fB\-o\fR and
|
||||
\fB\-c\fR options are mutually exclusive.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B opmpack
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B opmpack
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info opmpack
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
@@ -1,7 +0,0 @@
|
||||
.TH RST_DECK
|
||||
.SH NAME
|
||||
rst_deck \- Create a version of deck ready for restart
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8.
|
||||
.TH SUMMARY "1" "April 2021" "summary 2020.04" "User Commands"
|
||||
.SH NAME
|
||||
summary \- Printer for summary keys in Eclipse summary files
|
||||
.SH DESCRIPTION
|
||||
summary needs a minimum of two arguments. First is smspec filename and then list of vectors
|
||||
.PP
|
||||
In addition, the program takes these options (which must be given before the arguments):
|
||||
.PP
|
||||
\fB\-h\fR Print help and exit.
|
||||
\fB\-l\fR list all summary vectors.
|
||||
\fB\-r\fR extract data only for report steps.
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B summary
|
||||
is maintained as a Texinfo manual. If the
|
||||
.B info
|
||||
and
|
||||
.B summary
|
||||
programs are properly installed at your site, the command
|
||||
.IP
|
||||
.B info summary
|
||||
.PP
|
||||
should give you access to the complete manual.
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
Module: opm-common
|
||||
Description: Open Porous Media Initiative shared infrastructure
|
||||
Version: 2021.10
|
||||
Label: 2021.10
|
||||
Version: 2020.04
|
||||
Label: 2020.04
|
||||
Maintainer: opm@opm-project.org
|
||||
MaintainerName: OPM community
|
||||
Url: http://opm-project.org
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
Copyright 2019 Equinor ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#include <opm/io/eclipse/ESmry.hpp>
|
||||
#include <opm/io/eclipse/EclUtil.hpp>
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
|
||||
|
||||
static void printHelp() {
|
||||
|
||||
std::cout << "\nThis program create one or more lodsmry files, designed for effective load on the demand. \n"
|
||||
<< "These files are created with input from the smspec and unsmry file. \n"
|
||||
<< "\nIn addition, the program takes these options (which must be given before the arguments):\n\n"
|
||||
<< "-f if ESMRY file exist, this will be replaced. Default behaviour is that existing file is kept.\n"
|
||||
<< "-n Maximum number of threads to be used if mulitple files should be created.\n"
|
||||
<< "-h Print help and exit.\n\n";
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int c = 0;
|
||||
#ifdef _OPENMP
|
||||
int max_threads = -1;
|
||||
#endif
|
||||
bool force = false;
|
||||
|
||||
while ((c = getopt(argc, argv, "fn:h")) != -1) {
|
||||
switch (c) {
|
||||
case 'f':
|
||||
force = true;
|
||||
break;
|
||||
case 'h':
|
||||
printHelp();
|
||||
return 0;
|
||||
case 'n':
|
||||
#ifdef _OPENMP
|
||||
max_threads = atoi(optarg);
|
||||
#else
|
||||
std::cerr << "OpenMP is disabled - using single thread only\n";
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
int argOffset = optind;
|
||||
|
||||
#ifdef _OPENMP
|
||||
int available_threads = omp_get_max_threads();
|
||||
|
||||
if (max_threads < 0)
|
||||
max_threads = available_threads-2;
|
||||
else if (max_threads > (available_threads - 1))
|
||||
max_threads = available_threads-1;
|
||||
|
||||
if (max_threads > (argc-argOffset))
|
||||
max_threads = argc-argOffset;
|
||||
|
||||
omp_set_num_threads(max_threads);
|
||||
#endif
|
||||
|
||||
auto lap0 = std::chrono::system_clock::now();
|
||||
|
||||
#pragma omp parallel for
|
||||
for (int f = argOffset; f < argc; f ++){
|
||||
Opm::filesystem::path inputFileName = argv[f];
|
||||
|
||||
Opm::filesystem::path esmryFileName = inputFileName.parent_path() / inputFileName.stem();
|
||||
esmryFileName = esmryFileName += ".ESMRY";
|
||||
|
||||
if (Opm::EclIO::fileExists(esmryFileName) && (force))
|
||||
remove (esmryFileName);
|
||||
|
||||
Opm::EclIO::ESmry smryFile(argv[f]);
|
||||
if (!smryFile.make_esmry_file()){
|
||||
std::cout << "\n! Warning, smspec already have one lod file, existing kept use option -f to replace this" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
auto lap1 = std::chrono::system_clock::now();
|
||||
std::chrono::duration<double> elapsed_seconds1 = lap1-lap0;
|
||||
std::cout << "\nruntime for creating " << (argc-argOffset) << " ESMRY files: " << elapsed_seconds1.count() << " seconds\n" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
||||
#include <opm/msim/msim.hpp>
|
||||
|
||||
@@ -39,12 +38,10 @@ int main(int /* argc */, char** argv) {
|
||||
Opm::ErrorGuard error_guard;
|
||||
auto python = std::make_shared<Opm::Python>();
|
||||
|
||||
Opm::OpmLog::setupSimpleDefaultLogging();
|
||||
Opm::Deck deck = parser.parseFile(deck_file, parse_context, error_guard);
|
||||
Opm::EclipseState state(deck);
|
||||
Opm::Schedule schedule(deck, state, parse_context, error_guard, python);
|
||||
Opm::SummaryConfig summary_config(deck, schedule, state.fieldProps(), state.aquifer(),
|
||||
parse_context, error_guard);
|
||||
Opm::SummaryConfig summary_config(deck, schedule, state.getTableManager(), parse_context, error_guard);
|
||||
|
||||
if (error_guard) {
|
||||
error_guard.dump();
|
||||
|
||||
@@ -18,11 +18,9 @@
|
||||
*/
|
||||
#include <getopt.h>
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <fmt/format.h>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
@@ -51,7 +49,7 @@ struct keyword {
|
||||
};
|
||||
|
||||
|
||||
std::vector<keyword> load_deck(const std::string& deck_file) {
|
||||
std::vector<keyword> load_deck(const char * deck_file) {
|
||||
Opm::ParseContext parseContext;
|
||||
Opm::ErrorGuard errors;
|
||||
Opm::Parser parser;
|
||||
@@ -75,7 +73,7 @@ std::vector<keyword> load_deck(const std::string& deck_file) {
|
||||
}
|
||||
|
||||
|
||||
std::size_t make_deck_hash(const std::vector<keyword>& keywords) {
|
||||
std::size_t deck_hash(const std::vector<keyword>& keywords) {
|
||||
std::stringstream ss;
|
||||
for (const auto& kw : keywords)
|
||||
ss << kw.content_hash;
|
||||
@@ -84,14 +82,15 @@ std::size_t make_deck_hash(const std::vector<keyword>& keywords) {
|
||||
}
|
||||
|
||||
|
||||
void print_keywords(const std::vector<keyword>& keywords, std::size_t deck_hash, bool location_info) {
|
||||
void print_keywords(const std::vector<keyword>& keywords, bool location_info) {
|
||||
for (const auto& kw : keywords) {
|
||||
if (location_info)
|
||||
fmt::print("{:8s} : {}:{} {} \n", kw.name, kw.filename, kw.line_number, kw.content_hash);
|
||||
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.filename << ":" << kw.line_number << " " << kw.content_hash << std::endl;
|
||||
else
|
||||
fmt::print("{:8s} : {} \n", kw.name, kw.content_hash);
|
||||
std::cout << std::setw(8) << std::left << kw.name << " : " << kw.content_hash << std::endl;
|
||||
}
|
||||
fmt::print("\n{:8s} : {}\n", "Total", deck_hash);
|
||||
std::cout << std::endl;
|
||||
std::cout << std::setw(8) << std::left << "Total" << " : " << deck_hash(keywords) << std::endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,12 +119,6 @@ Options:
|
||||
|
||||
-l : Add filename and linenumber information to each keyword.
|
||||
-s : Short form - only print the hash of the complete deck.
|
||||
-S : Silent form - will not print any deck output.
|
||||
|
||||
It is possible to add multiple deck arguments, they are then scanned repeatedly,
|
||||
and the decks are compared. In the case of multiple deck arguments the exit
|
||||
status of the program will be zero if all are equal and nonzero in case of
|
||||
differences.
|
||||
|
||||
)";
|
||||
std::cerr << help_text << std::endl;
|
||||
@@ -137,11 +130,10 @@ int main(int argc, char** argv) {
|
||||
int arg_offset = 1;
|
||||
bool location_info = false;
|
||||
bool short_form = false;
|
||||
bool silent = false;
|
||||
|
||||
while (true) {
|
||||
int c;
|
||||
c = getopt(argc, argv, "lsS");
|
||||
c = getopt(argc, argv, "ls");
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
@@ -152,53 +144,16 @@ int main(int argc, char** argv) {
|
||||
case 's':
|
||||
short_form = true;
|
||||
break;
|
||||
case 'S':
|
||||
silent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
arg_offset = optind;
|
||||
if (arg_offset >= argc)
|
||||
print_help_and_exit();
|
||||
|
||||
|
||||
std::vector<std::pair<std::string, std::size_t>> deck_hash_table;
|
||||
for (int iarg = arg_offset; iarg < argc; iarg++) {
|
||||
const std::string deck_file = argv[iarg];
|
||||
auto keywords = load_deck(deck_file);
|
||||
auto deck_hash = make_deck_hash(keywords);
|
||||
deck_hash_table.emplace_back(deck_file, deck_hash);
|
||||
if (silent)
|
||||
continue;
|
||||
|
||||
if (short_form)
|
||||
std::cout << deck_hash << std::endl;
|
||||
else
|
||||
print_keywords(keywords, deck_hash, location_info);
|
||||
}
|
||||
|
||||
if (deck_hash_table.size() > 1) {
|
||||
bool equal = true;
|
||||
const auto& [first_deck, first_hash] = deck_hash_table[0];
|
||||
for (std::size_t index = 1; index < deck_hash_table.size(); index++) {
|
||||
const auto& [deck, hash] = deck_hash_table[index];
|
||||
if (first_hash != hash)
|
||||
equal = false;
|
||||
|
||||
if (silent)
|
||||
continue;
|
||||
|
||||
fmt::print("{} {} {}\n",
|
||||
first_deck,
|
||||
(first_hash == hash) ? "==" : "!=",
|
||||
deck);
|
||||
}
|
||||
|
||||
if (equal)
|
||||
std::exit(EXIT_SUCCESS);
|
||||
else
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
auto keywords = load_deck(argv[arg_offset]);
|
||||
if (short_form)
|
||||
std::cout << deck_hash(keywords) << std::endl;
|
||||
else
|
||||
print_keywords(keywords, location_info);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <opm/common/OpmLog/StreamLog.hpp>
|
||||
#include <opm/common/OpmLog/LogUtil.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
|
||||
|
||||
void initLogging() {
|
||||
@@ -50,30 +49,29 @@ inline void loadDeck( const char * deck_file) {
|
||||
|
||||
std::cout << "Loading deck: " << deck_file << " ..... "; std::cout.flush();
|
||||
|
||||
Opm::time_point start;
|
||||
std::chrono::system_clock::time_point start;
|
||||
|
||||
start = Opm::TimeService::now();
|
||||
start = std::chrono::system_clock::now();
|
||||
auto deck = parser.parseFile(deck_file, parseContext, errors);
|
||||
auto deck_time = Opm::TimeService::now() - start;
|
||||
auto deck_time = std::chrono::system_clock::now() - start;
|
||||
|
||||
std::cout << "parse complete - creating EclipseState .... "; std::cout.flush();
|
||||
|
||||
start = Opm::TimeService::now();
|
||||
start = std::chrono::system_clock::now();
|
||||
Opm::EclipseState state( deck );
|
||||
auto state_time = Opm::TimeService::now() - start;
|
||||
auto state_time = std::chrono::system_clock::now() - start;
|
||||
|
||||
std::cout << "creating Schedule .... "; std::cout.flush();
|
||||
|
||||
start = Opm::TimeService::now();
|
||||
start = std::chrono::system_clock::now();
|
||||
Opm::Schedule schedule( deck, state, python);
|
||||
auto schedule_time = Opm::TimeService::now() - start;
|
||||
auto schedule_time = std::chrono::system_clock::now() - start;
|
||||
|
||||
std::cout << "creating SummaryConfig .... "; std::cout.flush();
|
||||
|
||||
start = Opm::TimeService::now();
|
||||
Opm::SummaryConfig summary( deck, schedule, state.fieldProps(), state.aquifer(),
|
||||
parseContext, errors );
|
||||
auto summary_time = Opm::TimeService::now() - start;
|
||||
start = std::chrono::system_clock::now();
|
||||
Opm::SummaryConfig summary( deck, schedule, state.getTableManager( ), parseContext, errors );
|
||||
auto summary_time = std::chrono::system_clock::now() - start;
|
||||
|
||||
std::cout << "complete." << std::endl << std::endl;
|
||||
std::cout << "Time: " << std::endl;
|
||||
|
||||
@@ -1,271 +0,0 @@
|
||||
/*
|
||||
Copyright 2021 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
#include <fmt/format.h>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/I.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/P.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/G.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/R.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParserKeywords/S.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/InputErrorAction.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/FileDeck.hpp>
|
||||
|
||||
namespace fs = Opm::filesystem;
|
||||
|
||||
const std::unordered_set<std::string> remove_from_solution = {"EQUIL", "PRESSURE", "SWAT", "SGAS"};
|
||||
|
||||
void print_help_and_exit(const std::optional<std::string> error_msg = {}) {
|
||||
|
||||
if (error_msg.has_value()) {
|
||||
std::cerr << "Error:" << std::endl;
|
||||
std::cerr << error_msg.value() << std::endl;
|
||||
std::cerr << "------------------------------------------------------" << std::endl;
|
||||
}
|
||||
|
||||
std::string keep_keywords;
|
||||
for (const auto& kw : Opm::FileDeck::rst_keep_in_solution)
|
||||
keep_keywords += kw + " ";
|
||||
|
||||
const std::string help_text = fmt::format(R"(
|
||||
|
||||
The rst_deck program will load a simulation deck and parameters for a restart
|
||||
and reformat the deck to become a restart deck. Before the updated deck is
|
||||
output the program will update the SOLUTION and SCHEDULE sections. All keywords
|
||||
from the SOLUTION section will be cleared out(1) and a RESTART keyword will be
|
||||
inserted. In the SCHEDULE section the program can either remove all keywords up
|
||||
until the restart date, or alternatively insert SKIPREST immediately following
|
||||
the SCHEDULE keyword(2).
|
||||
|
||||
When creating the updated restart deck the program can either link to unmodified
|
||||
include files with INCLUDE statements, create a copy of deck structure in an
|
||||
alternative location or create one large file with all keywords in the same
|
||||
file. Apart from the alterations to support restart the output deck will be
|
||||
equivalent to the input deck, but formatting is not retained and comments have
|
||||
been stripped away.
|
||||
|
||||
Arguments:
|
||||
|
||||
1. The data file we are starting with.
|
||||
|
||||
2. The basename of the restart file - with an optional path prefix and a :N to
|
||||
restart from step N(3). A restart step value of 0 is interpreted as a dry run
|
||||
- a deck which has not been set up for restart will be written out.
|
||||
|
||||
3. Basename of the restart deck we create, can optionally contain a path prefix;
|
||||
the path will be created if it does not already exist. This argument is
|
||||
optional, if it is not provided the program will dump a restart deck on
|
||||
stdout. If the argument corresponds to an existing directory the restart case
|
||||
will get the same name as the base case.
|
||||
|
||||
Options:
|
||||
|
||||
-s: Manipulate the SCHEDULE section by inserting a SKIPREST keyword immediately
|
||||
following the SCHEDULE keyword. If the -s option is not used the SCHEDULE
|
||||
section will be modified by removing all keywords until we reach the restart
|
||||
date. NB: Currently the -s option is required
|
||||
|
||||
-m: [share|inline|copy] The restart deck can reuse the unmodified include files
|
||||
from the base case, this is mode 'share' and is the default. With mode
|
||||
'inline' the restart deck will be one long file and with mode 'copy' the
|
||||
file structure of the base case will be retained. The default if no -m
|
||||
option is given is the 'share' mode.
|
||||
|
||||
In the case of 'share' and 'copy' the correct path to include files will be
|
||||
negotiated based on the path given to the output case in the third argument.
|
||||
If the restart deck is passed to stdout the include files will be resolved
|
||||
based on output in cwd.
|
||||
|
||||
Example:
|
||||
|
||||
rst_deck /path/to/history/HISTORY.DATA rst/HISTORY:30 /path/to/rst/RESTART -s
|
||||
|
||||
1: The program has a compiled list of keywords which will be retained in the
|
||||
SOLUTION section. The current value of that list is: {}
|
||||
|
||||
2: Current version of the program *only* supports the SKIPREST option, and the
|
||||
-s option is required.
|
||||
|
||||
3: The second argument is treated purely as a string and inserted verbatim into
|
||||
the updated restart deck. In a future version we might interpret the second
|
||||
argument as a file path and check the content and also do filesystem
|
||||
manipulations from it.
|
||||
|
||||
)", keep_keywords);
|
||||
|
||||
std::cerr << help_text << std::endl;
|
||||
if (error_msg.has_value())
|
||||
std::exit(EXIT_FAILURE);
|
||||
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct options {
|
||||
std::string input_deck;
|
||||
std::pair<std::string, int> restart;
|
||||
std::optional<std::string> target;
|
||||
|
||||
Opm::FileDeck::OutputMode mode{Opm::FileDeck::OutputMode::SHARE};
|
||||
bool skiprest{false};
|
||||
};
|
||||
|
||||
|
||||
Opm::FileDeck load_deck(const options& opt) {
|
||||
Opm::ParseContext parseContext(Opm::InputError::WARN);
|
||||
Opm::ErrorGuard errors;
|
||||
Opm::Parser parser;
|
||||
|
||||
/* Use the same default ParseContext as flow. */
|
||||
parseContext.update(Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE);
|
||||
parseContext.update(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN);
|
||||
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN);
|
||||
parseContext.update(Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN);
|
||||
auto deck = parser.parseFile(opt.input_deck, parseContext, errors);
|
||||
return Opm::FileDeck{ deck };
|
||||
}
|
||||
|
||||
|
||||
Opm::FileDeck::OutputMode mode(const std::string& mode_arg) {
|
||||
if (mode_arg == "inline")
|
||||
return Opm::FileDeck::OutputMode::INLINE;
|
||||
|
||||
if (mode_arg == "share")
|
||||
return Opm::FileDeck::OutputMode::SHARE;
|
||||
|
||||
if (mode_arg == "copy")
|
||||
return Opm::FileDeck::OutputMode::COPY;
|
||||
|
||||
print_help_and_exit(fmt::format("Mode argument: \'{}\' not recognized. Valid options are inline|share|copy", mode_arg));
|
||||
return Opm::FileDeck::OutputMode::INLINE;
|
||||
}
|
||||
|
||||
std::pair<std::string, std::size_t> split_restart(const std::string& restart_base) {
|
||||
auto sep_pos = restart_base.rfind(':');
|
||||
if (sep_pos == std::string::npos)
|
||||
print_help_and_exit(fmt::format("Expected restart argument on the form: BASE:NUMBER - e.g. HISTORY:60"));
|
||||
|
||||
return std::make_pair(restart_base.substr(0, sep_pos), std::stoi(restart_base.substr(sep_pos + 1)));
|
||||
}
|
||||
|
||||
|
||||
options load_options(int argc, char **argv) {
|
||||
options opt;
|
||||
while (true) {
|
||||
int c;
|
||||
c = getopt(argc, argv, "hm:s");
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch(c) {
|
||||
case 'm':
|
||||
opt.mode = mode(optarg);
|
||||
break;
|
||||
case 's':
|
||||
opt.skiprest = true;
|
||||
break;
|
||||
case 'h':
|
||||
print_help_and_exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto arg_offset = optind;
|
||||
if (arg_offset >= argc)
|
||||
print_help_and_exit();
|
||||
|
||||
opt.input_deck = argv[arg_offset];
|
||||
opt.restart = split_restart(argv[arg_offset + 1]);
|
||||
if ((argc - arg_offset) >= 3) {
|
||||
opt.target = argv[arg_offset + 2];
|
||||
if (opt.mode == Opm::FileDeck::OutputMode::COPY) {
|
||||
auto target = fs::path(opt.target.value()).parent_path();
|
||||
if (fs::exists(target)) {
|
||||
auto input = fs::path(opt.input_deck).parent_path();
|
||||
if (fs::equivalent(target, input))
|
||||
opt.mode = Opm::FileDeck::OutputMode::SHARE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (opt.mode == Opm::FileDeck::OutputMode::COPY)
|
||||
print_help_and_exit("When writing output to stdout you must use inline|share mode");
|
||||
}
|
||||
|
||||
return opt;
|
||||
}
|
||||
|
||||
|
||||
void update_solution(const options& opt, Opm::FileDeck& file_deck)
|
||||
{
|
||||
if (opt.restart.second == 0)
|
||||
return;
|
||||
|
||||
const auto solution = file_deck.find("SOLUTION");
|
||||
if (!solution.has_value())
|
||||
print_help_and_exit(fmt::format("Could not find SOLUTION section in input deck: {}", opt.input_deck));
|
||||
|
||||
auto summary = file_deck.find("SUMMARY");
|
||||
if (!summary.has_value())
|
||||
print_help_and_exit(fmt::format("Could not find SUMMARY section in input deck: {}", opt.input_deck));
|
||||
|
||||
file_deck.rst_solution(opt.restart.first, opt.restart.second);
|
||||
}
|
||||
|
||||
|
||||
void update_schedule(const options& opt, Opm::FileDeck& file_deck)
|
||||
{
|
||||
if (opt.restart.second == 0)
|
||||
return;
|
||||
|
||||
if (opt.skiprest)
|
||||
file_deck.insert_skiprest();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
auto options = load_options(argc, argv);
|
||||
auto file_deck = load_deck(options);
|
||||
update_solution(options, file_deck);
|
||||
update_schedule(options, file_deck);
|
||||
if (!options.target.has_value())
|
||||
file_deck.dump_stdout(fs::current_path(), options.mode);
|
||||
else {
|
||||
std::string target = options.target.value();
|
||||
if (fs::is_directory(target))
|
||||
file_deck.dump( fs::absolute(target), fs::path(options.input_deck).filename(), options.mode );
|
||||
else {
|
||||
auto target_path = fs::path( fs::absolute(options.target.value()) );
|
||||
file_deck.dump( fs::absolute(target_path.parent_path()), target_path.filename(), options.mode );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
Copyright 2013, 2020 Equinor ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <chrono>
|
||||
#include <sstream>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
#include <opm/parser/eclipse/Python/Python.hpp>
|
||||
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <opm/common/OpmLog/StreamLog.hpp>
|
||||
#include <opm/common/OpmLog/LogUtil.hpp>
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
|
||||
|
||||
inline void createDot(const Opm::Schedule& schedule, const std::string& casename)
|
||||
{
|
||||
std::cout << "Writing " << casename << ".gv .... "; std::cout.flush();
|
||||
std::ofstream os(casename + ".gv");
|
||||
os << "// This file was written by the 'wellgraph' utility from OPM.\n";
|
||||
os << "// Find the source code at github.com/OPM.\n";
|
||||
os << "// Convert output to PDF with 'dot -Tpdf " << casename << ".gv > " << casename << ".pdf'\n";
|
||||
os << "strict digraph \"" << casename << "\"\n{\n";
|
||||
const auto groupnames = schedule.groupNames();
|
||||
const std::size_t last = schedule.size() - 1;
|
||||
// Group -> Group relations.
|
||||
for (const auto& gn : groupnames) {
|
||||
const auto& g = schedule.getGroup(gn, last);
|
||||
const auto& children = g.groups();
|
||||
if (!children.empty()) {
|
||||
os << " \"" << gn << "\" -> {";
|
||||
for (const auto& child : children) {
|
||||
os << " \"" << child << '"';
|
||||
}
|
||||
os << " }\n";
|
||||
}
|
||||
}
|
||||
// Group -> Well relations.
|
||||
os << " node [shape=box]\n";
|
||||
for (const auto& gn : groupnames) {
|
||||
const auto& g = schedule.getGroup(gn, last);
|
||||
const auto& children = g.wells();
|
||||
if (!children.empty()) {
|
||||
os << " \"" << gn << "\" -> {";
|
||||
for (const auto& child : children) {
|
||||
os << " \"" << child << '"';
|
||||
}
|
||||
os << " }\n";
|
||||
}
|
||||
}
|
||||
// Color wells by injector or producer.
|
||||
for (const auto& w : schedule.getWellsatEnd()) {
|
||||
os << " \"" << w.name() << '"';
|
||||
if (w.isProducer() && w.isInjector()) {
|
||||
os << " [color=purple]\n";
|
||||
} else if (w.isProducer()) {
|
||||
os << " [color=red]\n";
|
||||
} else {
|
||||
os << " [color=blue]\n";
|
||||
}
|
||||
}
|
||||
os << "}\n";
|
||||
std::cout << "complete." << std::endl;
|
||||
}
|
||||
|
||||
|
||||
inline Opm::Schedule loadSchedule(const std::string& deck_file)
|
||||
{
|
||||
Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE},
|
||||
{Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN},
|
||||
{Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN},
|
||||
{Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}});
|
||||
Opm::ErrorGuard errors;
|
||||
Opm::Parser parser;
|
||||
auto python = std::make_shared<Opm::Python>();
|
||||
|
||||
std::cout << "Loading and parsing deck: " << deck_file << " ..... "; std::cout.flush();
|
||||
auto deck = parser.parseFile(deck_file, parseContext, errors);
|
||||
std::cout << "complete.\n";
|
||||
|
||||
std::cout << "Creating EclipseState .... "; std::cout.flush();
|
||||
Opm::EclipseState state( deck );
|
||||
std::cout << "complete.\n";
|
||||
|
||||
std::cout << "Creating Schedule .... "; std::cout.flush();
|
||||
Opm::Schedule schedule( deck, state, python);
|
||||
std::cout << "complete." << std::endl;
|
||||
|
||||
return schedule;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::ostringstream os;
|
||||
std::shared_ptr<Opm::StreamLog> string_log = std::make_shared<Opm::StreamLog>(os, Opm::Log::DefaultMessageTypes);
|
||||
Opm::OpmLog::addBackend( "STRING" , string_log);
|
||||
try {
|
||||
for (int iarg = 1; iarg < argc; iarg++) {
|
||||
const std::string filename = argv[iarg];
|
||||
const auto sched = loadSchedule(filename);
|
||||
const auto casename = Opm::filesystem::path(filename).stem();
|
||||
createDot(sched, casename);
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
std::cout << "\n\n***** Caught an exception: " << e.what() << std::endl;
|
||||
std::cout << "\n\n***** Printing log: "<< std::endl;
|
||||
std::cout << os.str();
|
||||
std::cout << "\n\n***** Exiting due to errors." << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
27
external/fmtlib/LICENSE.rst
vendored
27
external/fmtlib/LICENSE.rst
vendored
@@ -1,27 +0,0 @@
|
||||
Copyright (c) 2012 - present, Victor Zverovich
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
--- Optional exception to the license ---
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into a machine-executable object form of such
|
||||
source code, you may redistribute such embedded portions in such object form
|
||||
without including the above copyright and permission notices.
|
||||
12
external/fmtlib/README.opm
vendored
12
external/fmtlib/README.opm
vendored
@@ -1,12 +0,0 @@
|
||||
The include/ directory is a copy of the include directory from version 7.0.3 of
|
||||
the fmtlib distribution. The fmtlib can be found at https://github.com/fmtlib/fmt
|
||||
|
||||
The fmtlib code embedded here should be compiled in header only mode, to ensure
|
||||
that the symbol FMT_HEADER_ONLY must be defined before the the fmt/format.h
|
||||
header is included:
|
||||
|
||||
#define FMT_HEADER_ONLY
|
||||
#include <fmt/format.h>
|
||||
|
||||
....
|
||||
auto msg = fmt::format("Hello {}", "world");
|
||||
1123
external/fmtlib/include/fmt/chrono.h
vendored
1123
external/fmtlib/include/fmt/chrono.h
vendored
File diff suppressed because it is too large
Load Diff
566
external/fmtlib/include/fmt/color.h
vendored
566
external/fmtlib/include/fmt/color.h
vendored
@@ -1,566 +0,0 @@
|
||||
// Formatting library for C++ - color support
|
||||
//
|
||||
// Copyright (c) 2018 - present, Victor Zverovich and fmt contributors
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef FMT_COLOR_H_
|
||||
#define FMT_COLOR_H_
|
||||
|
||||
#include "format.h"
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
enum class color : uint32_t {
|
||||
alice_blue = 0xF0F8FF, // rgb(240,248,255)
|
||||
antique_white = 0xFAEBD7, // rgb(250,235,215)
|
||||
aqua = 0x00FFFF, // rgb(0,255,255)
|
||||
aquamarine = 0x7FFFD4, // rgb(127,255,212)
|
||||
azure = 0xF0FFFF, // rgb(240,255,255)
|
||||
beige = 0xF5F5DC, // rgb(245,245,220)
|
||||
bisque = 0xFFE4C4, // rgb(255,228,196)
|
||||
black = 0x000000, // rgb(0,0,0)
|
||||
blanched_almond = 0xFFEBCD, // rgb(255,235,205)
|
||||
blue = 0x0000FF, // rgb(0,0,255)
|
||||
blue_violet = 0x8A2BE2, // rgb(138,43,226)
|
||||
brown = 0xA52A2A, // rgb(165,42,42)
|
||||
burly_wood = 0xDEB887, // rgb(222,184,135)
|
||||
cadet_blue = 0x5F9EA0, // rgb(95,158,160)
|
||||
chartreuse = 0x7FFF00, // rgb(127,255,0)
|
||||
chocolate = 0xD2691E, // rgb(210,105,30)
|
||||
coral = 0xFF7F50, // rgb(255,127,80)
|
||||
cornflower_blue = 0x6495ED, // rgb(100,149,237)
|
||||
cornsilk = 0xFFF8DC, // rgb(255,248,220)
|
||||
crimson = 0xDC143C, // rgb(220,20,60)
|
||||
cyan = 0x00FFFF, // rgb(0,255,255)
|
||||
dark_blue = 0x00008B, // rgb(0,0,139)
|
||||
dark_cyan = 0x008B8B, // rgb(0,139,139)
|
||||
dark_golden_rod = 0xB8860B, // rgb(184,134,11)
|
||||
dark_gray = 0xA9A9A9, // rgb(169,169,169)
|
||||
dark_green = 0x006400, // rgb(0,100,0)
|
||||
dark_khaki = 0xBDB76B, // rgb(189,183,107)
|
||||
dark_magenta = 0x8B008B, // rgb(139,0,139)
|
||||
dark_olive_green = 0x556B2F, // rgb(85,107,47)
|
||||
dark_orange = 0xFF8C00, // rgb(255,140,0)
|
||||
dark_orchid = 0x9932CC, // rgb(153,50,204)
|
||||
dark_red = 0x8B0000, // rgb(139,0,0)
|
||||
dark_salmon = 0xE9967A, // rgb(233,150,122)
|
||||
dark_sea_green = 0x8FBC8F, // rgb(143,188,143)
|
||||
dark_slate_blue = 0x483D8B, // rgb(72,61,139)
|
||||
dark_slate_gray = 0x2F4F4F, // rgb(47,79,79)
|
||||
dark_turquoise = 0x00CED1, // rgb(0,206,209)
|
||||
dark_violet = 0x9400D3, // rgb(148,0,211)
|
||||
deep_pink = 0xFF1493, // rgb(255,20,147)
|
||||
deep_sky_blue = 0x00BFFF, // rgb(0,191,255)
|
||||
dim_gray = 0x696969, // rgb(105,105,105)
|
||||
dodger_blue = 0x1E90FF, // rgb(30,144,255)
|
||||
fire_brick = 0xB22222, // rgb(178,34,34)
|
||||
floral_white = 0xFFFAF0, // rgb(255,250,240)
|
||||
forest_green = 0x228B22, // rgb(34,139,34)
|
||||
fuchsia = 0xFF00FF, // rgb(255,0,255)
|
||||
gainsboro = 0xDCDCDC, // rgb(220,220,220)
|
||||
ghost_white = 0xF8F8FF, // rgb(248,248,255)
|
||||
gold = 0xFFD700, // rgb(255,215,0)
|
||||
golden_rod = 0xDAA520, // rgb(218,165,32)
|
||||
gray = 0x808080, // rgb(128,128,128)
|
||||
green = 0x008000, // rgb(0,128,0)
|
||||
green_yellow = 0xADFF2F, // rgb(173,255,47)
|
||||
honey_dew = 0xF0FFF0, // rgb(240,255,240)
|
||||
hot_pink = 0xFF69B4, // rgb(255,105,180)
|
||||
indian_red = 0xCD5C5C, // rgb(205,92,92)
|
||||
indigo = 0x4B0082, // rgb(75,0,130)
|
||||
ivory = 0xFFFFF0, // rgb(255,255,240)
|
||||
khaki = 0xF0E68C, // rgb(240,230,140)
|
||||
lavender = 0xE6E6FA, // rgb(230,230,250)
|
||||
lavender_blush = 0xFFF0F5, // rgb(255,240,245)
|
||||
lawn_green = 0x7CFC00, // rgb(124,252,0)
|
||||
lemon_chiffon = 0xFFFACD, // rgb(255,250,205)
|
||||
light_blue = 0xADD8E6, // rgb(173,216,230)
|
||||
light_coral = 0xF08080, // rgb(240,128,128)
|
||||
light_cyan = 0xE0FFFF, // rgb(224,255,255)
|
||||
light_golden_rod_yellow = 0xFAFAD2, // rgb(250,250,210)
|
||||
light_gray = 0xD3D3D3, // rgb(211,211,211)
|
||||
light_green = 0x90EE90, // rgb(144,238,144)
|
||||
light_pink = 0xFFB6C1, // rgb(255,182,193)
|
||||
light_salmon = 0xFFA07A, // rgb(255,160,122)
|
||||
light_sea_green = 0x20B2AA, // rgb(32,178,170)
|
||||
light_sky_blue = 0x87CEFA, // rgb(135,206,250)
|
||||
light_slate_gray = 0x778899, // rgb(119,136,153)
|
||||
light_steel_blue = 0xB0C4DE, // rgb(176,196,222)
|
||||
light_yellow = 0xFFFFE0, // rgb(255,255,224)
|
||||
lime = 0x00FF00, // rgb(0,255,0)
|
||||
lime_green = 0x32CD32, // rgb(50,205,50)
|
||||
linen = 0xFAF0E6, // rgb(250,240,230)
|
||||
magenta = 0xFF00FF, // rgb(255,0,255)
|
||||
maroon = 0x800000, // rgb(128,0,0)
|
||||
medium_aquamarine = 0x66CDAA, // rgb(102,205,170)
|
||||
medium_blue = 0x0000CD, // rgb(0,0,205)
|
||||
medium_orchid = 0xBA55D3, // rgb(186,85,211)
|
||||
medium_purple = 0x9370DB, // rgb(147,112,219)
|
||||
medium_sea_green = 0x3CB371, // rgb(60,179,113)
|
||||
medium_slate_blue = 0x7B68EE, // rgb(123,104,238)
|
||||
medium_spring_green = 0x00FA9A, // rgb(0,250,154)
|
||||
medium_turquoise = 0x48D1CC, // rgb(72,209,204)
|
||||
medium_violet_red = 0xC71585, // rgb(199,21,133)
|
||||
midnight_blue = 0x191970, // rgb(25,25,112)
|
||||
mint_cream = 0xF5FFFA, // rgb(245,255,250)
|
||||
misty_rose = 0xFFE4E1, // rgb(255,228,225)
|
||||
moccasin = 0xFFE4B5, // rgb(255,228,181)
|
||||
navajo_white = 0xFFDEAD, // rgb(255,222,173)
|
||||
navy = 0x000080, // rgb(0,0,128)
|
||||
old_lace = 0xFDF5E6, // rgb(253,245,230)
|
||||
olive = 0x808000, // rgb(128,128,0)
|
||||
olive_drab = 0x6B8E23, // rgb(107,142,35)
|
||||
orange = 0xFFA500, // rgb(255,165,0)
|
||||
orange_red = 0xFF4500, // rgb(255,69,0)
|
||||
orchid = 0xDA70D6, // rgb(218,112,214)
|
||||
pale_golden_rod = 0xEEE8AA, // rgb(238,232,170)
|
||||
pale_green = 0x98FB98, // rgb(152,251,152)
|
||||
pale_turquoise = 0xAFEEEE, // rgb(175,238,238)
|
||||
pale_violet_red = 0xDB7093, // rgb(219,112,147)
|
||||
papaya_whip = 0xFFEFD5, // rgb(255,239,213)
|
||||
peach_puff = 0xFFDAB9, // rgb(255,218,185)
|
||||
peru = 0xCD853F, // rgb(205,133,63)
|
||||
pink = 0xFFC0CB, // rgb(255,192,203)
|
||||
plum = 0xDDA0DD, // rgb(221,160,221)
|
||||
powder_blue = 0xB0E0E6, // rgb(176,224,230)
|
||||
purple = 0x800080, // rgb(128,0,128)
|
||||
rebecca_purple = 0x663399, // rgb(102,51,153)
|
||||
red = 0xFF0000, // rgb(255,0,0)
|
||||
rosy_brown = 0xBC8F8F, // rgb(188,143,143)
|
||||
royal_blue = 0x4169E1, // rgb(65,105,225)
|
||||
saddle_brown = 0x8B4513, // rgb(139,69,19)
|
||||
salmon = 0xFA8072, // rgb(250,128,114)
|
||||
sandy_brown = 0xF4A460, // rgb(244,164,96)
|
||||
sea_green = 0x2E8B57, // rgb(46,139,87)
|
||||
sea_shell = 0xFFF5EE, // rgb(255,245,238)
|
||||
sienna = 0xA0522D, // rgb(160,82,45)
|
||||
silver = 0xC0C0C0, // rgb(192,192,192)
|
||||
sky_blue = 0x87CEEB, // rgb(135,206,235)
|
||||
slate_blue = 0x6A5ACD, // rgb(106,90,205)
|
||||
slate_gray = 0x708090, // rgb(112,128,144)
|
||||
snow = 0xFFFAFA, // rgb(255,250,250)
|
||||
spring_green = 0x00FF7F, // rgb(0,255,127)
|
||||
steel_blue = 0x4682B4, // rgb(70,130,180)
|
||||
tan = 0xD2B48C, // rgb(210,180,140)
|
||||
teal = 0x008080, // rgb(0,128,128)
|
||||
thistle = 0xD8BFD8, // rgb(216,191,216)
|
||||
tomato = 0xFF6347, // rgb(255,99,71)
|
||||
turquoise = 0x40E0D0, // rgb(64,224,208)
|
||||
violet = 0xEE82EE, // rgb(238,130,238)
|
||||
wheat = 0xF5DEB3, // rgb(245,222,179)
|
||||
white = 0xFFFFFF, // rgb(255,255,255)
|
||||
white_smoke = 0xF5F5F5, // rgb(245,245,245)
|
||||
yellow = 0xFFFF00, // rgb(255,255,0)
|
||||
yellow_green = 0x9ACD32 // rgb(154,205,50)
|
||||
}; // enum class color
|
||||
|
||||
enum class terminal_color : uint8_t {
|
||||
black = 30,
|
||||
red,
|
||||
green,
|
||||
yellow,
|
||||
blue,
|
||||
magenta,
|
||||
cyan,
|
||||
white,
|
||||
bright_black = 90,
|
||||
bright_red,
|
||||
bright_green,
|
||||
bright_yellow,
|
||||
bright_blue,
|
||||
bright_magenta,
|
||||
bright_cyan,
|
||||
bright_white
|
||||
};
|
||||
|
||||
enum class emphasis : uint8_t {
|
||||
bold = 1,
|
||||
italic = 1 << 1,
|
||||
underline = 1 << 2,
|
||||
strikethrough = 1 << 3
|
||||
};
|
||||
|
||||
// rgb is a struct for red, green and blue colors.
|
||||
// Using the name "rgb" makes some editors show the color in a tooltip.
|
||||
struct rgb {
|
||||
FMT_CONSTEXPR rgb() : r(0), g(0), b(0) {}
|
||||
FMT_CONSTEXPR rgb(uint8_t r_, uint8_t g_, uint8_t b_) : r(r_), g(g_), b(b_) {}
|
||||
FMT_CONSTEXPR rgb(uint32_t hex)
|
||||
: r((hex >> 16) & 0xFF), g((hex >> 8) & 0xFF), b(hex & 0xFF) {}
|
||||
FMT_CONSTEXPR rgb(color hex)
|
||||
: r((uint32_t(hex) >> 16) & 0xFF),
|
||||
g((uint32_t(hex) >> 8) & 0xFF),
|
||||
b(uint32_t(hex) & 0xFF) {}
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
// color is a struct of either a rgb color or a terminal color.
|
||||
struct color_type {
|
||||
FMT_CONSTEXPR color_type() FMT_NOEXCEPT : is_rgb(), value{} {}
|
||||
FMT_CONSTEXPR color_type(color rgb_color) FMT_NOEXCEPT : is_rgb(true),
|
||||
value{} {
|
||||
value.rgb_color = static_cast<uint32_t>(rgb_color);
|
||||
}
|
||||
FMT_CONSTEXPR color_type(rgb rgb_color) FMT_NOEXCEPT : is_rgb(true), value{} {
|
||||
value.rgb_color = (static_cast<uint32_t>(rgb_color.r) << 16) |
|
||||
(static_cast<uint32_t>(rgb_color.g) << 8) | rgb_color.b;
|
||||
}
|
||||
FMT_CONSTEXPR color_type(terminal_color term_color) FMT_NOEXCEPT : is_rgb(),
|
||||
value{} {
|
||||
value.term_color = static_cast<uint8_t>(term_color);
|
||||
}
|
||||
bool is_rgb;
|
||||
union color_union {
|
||||
uint8_t term_color;
|
||||
uint32_t rgb_color;
|
||||
} value;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
// Experimental text formatting support.
|
||||
class text_style {
|
||||
public:
|
||||
FMT_CONSTEXPR text_style(emphasis em = emphasis()) FMT_NOEXCEPT
|
||||
: set_foreground_color(),
|
||||
set_background_color(),
|
||||
ems(em) {}
|
||||
|
||||
FMT_CONSTEXPR text_style& operator|=(const text_style& rhs) {
|
||||
if (!set_foreground_color) {
|
||||
set_foreground_color = rhs.set_foreground_color;
|
||||
foreground_color = rhs.foreground_color;
|
||||
} else if (rhs.set_foreground_color) {
|
||||
if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
|
||||
FMT_THROW(format_error("can't OR a terminal color"));
|
||||
foreground_color.value.rgb_color |= rhs.foreground_color.value.rgb_color;
|
||||
}
|
||||
|
||||
if (!set_background_color) {
|
||||
set_background_color = rhs.set_background_color;
|
||||
background_color = rhs.background_color;
|
||||
} else if (rhs.set_background_color) {
|
||||
if (!background_color.is_rgb || !rhs.background_color.is_rgb)
|
||||
FMT_THROW(format_error("can't OR a terminal color"));
|
||||
background_color.value.rgb_color |= rhs.background_color.value.rgb_color;
|
||||
}
|
||||
|
||||
ems = static_cast<emphasis>(static_cast<uint8_t>(ems) |
|
||||
static_cast<uint8_t>(rhs.ems));
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend FMT_CONSTEXPR text_style operator|(text_style lhs,
|
||||
const text_style& rhs) {
|
||||
return lhs |= rhs;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR text_style& operator&=(const text_style& rhs) {
|
||||
if (!set_foreground_color) {
|
||||
set_foreground_color = rhs.set_foreground_color;
|
||||
foreground_color = rhs.foreground_color;
|
||||
} else if (rhs.set_foreground_color) {
|
||||
if (!foreground_color.is_rgb || !rhs.foreground_color.is_rgb)
|
||||
FMT_THROW(format_error("can't AND a terminal color"));
|
||||
foreground_color.value.rgb_color &= rhs.foreground_color.value.rgb_color;
|
||||
}
|
||||
|
||||
if (!set_background_color) {
|
||||
set_background_color = rhs.set_background_color;
|
||||
background_color = rhs.background_color;
|
||||
} else if (rhs.set_background_color) {
|
||||
if (!background_color.is_rgb || !rhs.background_color.is_rgb)
|
||||
FMT_THROW(format_error("can't AND a terminal color"));
|
||||
background_color.value.rgb_color &= rhs.background_color.value.rgb_color;
|
||||
}
|
||||
|
||||
ems = static_cast<emphasis>(static_cast<uint8_t>(ems) &
|
||||
static_cast<uint8_t>(rhs.ems));
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend FMT_CONSTEXPR text_style operator&(text_style lhs,
|
||||
const text_style& rhs) {
|
||||
return lhs &= rhs;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR bool has_foreground() const FMT_NOEXCEPT {
|
||||
return set_foreground_color;
|
||||
}
|
||||
FMT_CONSTEXPR bool has_background() const FMT_NOEXCEPT {
|
||||
return set_background_color;
|
||||
}
|
||||
FMT_CONSTEXPR bool has_emphasis() const FMT_NOEXCEPT {
|
||||
return static_cast<uint8_t>(ems) != 0;
|
||||
}
|
||||
FMT_CONSTEXPR detail::color_type get_foreground() const FMT_NOEXCEPT {
|
||||
FMT_ASSERT(has_foreground(), "no foreground specified for this style");
|
||||
return foreground_color;
|
||||
}
|
||||
FMT_CONSTEXPR detail::color_type get_background() const FMT_NOEXCEPT {
|
||||
FMT_ASSERT(has_background(), "no background specified for this style");
|
||||
return background_color;
|
||||
}
|
||||
FMT_CONSTEXPR emphasis get_emphasis() const FMT_NOEXCEPT {
|
||||
FMT_ASSERT(has_emphasis(), "no emphasis specified for this style");
|
||||
return ems;
|
||||
}
|
||||
|
||||
private:
|
||||
FMT_CONSTEXPR text_style(bool is_foreground,
|
||||
detail::color_type text_color) FMT_NOEXCEPT
|
||||
: set_foreground_color(),
|
||||
set_background_color(),
|
||||
ems() {
|
||||
if (is_foreground) {
|
||||
foreground_color = text_color;
|
||||
set_foreground_color = true;
|
||||
} else {
|
||||
background_color = text_color;
|
||||
set_background_color = true;
|
||||
}
|
||||
}
|
||||
|
||||
friend FMT_CONSTEXPR_DECL text_style fg(detail::color_type foreground)
|
||||
FMT_NOEXCEPT;
|
||||
friend FMT_CONSTEXPR_DECL text_style bg(detail::color_type background)
|
||||
FMT_NOEXCEPT;
|
||||
|
||||
detail::color_type foreground_color;
|
||||
detail::color_type background_color;
|
||||
bool set_foreground_color;
|
||||
bool set_background_color;
|
||||
emphasis ems;
|
||||
};
|
||||
|
||||
FMT_CONSTEXPR text_style fg(detail::color_type foreground) FMT_NOEXCEPT {
|
||||
return text_style(/*is_foreground=*/true, foreground);
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR text_style bg(detail::color_type background) FMT_NOEXCEPT {
|
||||
return text_style(/*is_foreground=*/false, background);
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR text_style operator|(emphasis lhs, emphasis rhs) FMT_NOEXCEPT {
|
||||
return text_style(lhs) | rhs;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Char> struct ansi_color_escape {
|
||||
FMT_CONSTEXPR ansi_color_escape(detail::color_type text_color,
|
||||
const char* esc) FMT_NOEXCEPT {
|
||||
// If we have a terminal color, we need to output another escape code
|
||||
// sequence.
|
||||
if (!text_color.is_rgb) {
|
||||
bool is_background = esc == detail::data::background_color;
|
||||
uint32_t value = text_color.value.term_color;
|
||||
// Background ASCII codes are the same as the foreground ones but with
|
||||
// 10 more.
|
||||
if (is_background) value += 10u;
|
||||
|
||||
size_t index = 0;
|
||||
buffer[index++] = static_cast<Char>('\x1b');
|
||||
buffer[index++] = static_cast<Char>('[');
|
||||
|
||||
if (value >= 100u) {
|
||||
buffer[index++] = static_cast<Char>('1');
|
||||
value %= 100u;
|
||||
}
|
||||
buffer[index++] = static_cast<Char>('0' + value / 10u);
|
||||
buffer[index++] = static_cast<Char>('0' + value % 10u);
|
||||
|
||||
buffer[index++] = static_cast<Char>('m');
|
||||
buffer[index++] = static_cast<Char>('\0');
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
buffer[i] = static_cast<Char>(esc[i]);
|
||||
}
|
||||
rgb color(text_color.value.rgb_color);
|
||||
to_esc(color.r, buffer + 7, ';');
|
||||
to_esc(color.g, buffer + 11, ';');
|
||||
to_esc(color.b, buffer + 15, 'm');
|
||||
buffer[19] = static_cast<Char>(0);
|
||||
}
|
||||
FMT_CONSTEXPR ansi_color_escape(emphasis em) FMT_NOEXCEPT {
|
||||
uint8_t em_codes[4] = {};
|
||||
uint8_t em_bits = static_cast<uint8_t>(em);
|
||||
if (em_bits & static_cast<uint8_t>(emphasis::bold)) em_codes[0] = 1;
|
||||
if (em_bits & static_cast<uint8_t>(emphasis::italic)) em_codes[1] = 3;
|
||||
if (em_bits & static_cast<uint8_t>(emphasis::underline)) em_codes[2] = 4;
|
||||
if (em_bits & static_cast<uint8_t>(emphasis::strikethrough))
|
||||
em_codes[3] = 9;
|
||||
|
||||
size_t index = 0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (!em_codes[i]) continue;
|
||||
buffer[index++] = static_cast<Char>('\x1b');
|
||||
buffer[index++] = static_cast<Char>('[');
|
||||
buffer[index++] = static_cast<Char>('0' + em_codes[i]);
|
||||
buffer[index++] = static_cast<Char>('m');
|
||||
}
|
||||
buffer[index++] = static_cast<Char>(0);
|
||||
}
|
||||
FMT_CONSTEXPR operator const Char*() const FMT_NOEXCEPT { return buffer; }
|
||||
|
||||
FMT_CONSTEXPR const Char* begin() const FMT_NOEXCEPT { return buffer; }
|
||||
FMT_CONSTEXPR const Char* end() const FMT_NOEXCEPT {
|
||||
return buffer + std::char_traits<Char>::length(buffer);
|
||||
}
|
||||
|
||||
private:
|
||||
Char buffer[7u + 3u * 4u + 1u];
|
||||
|
||||
static FMT_CONSTEXPR void to_esc(uint8_t c, Char* out,
|
||||
char delimiter) FMT_NOEXCEPT {
|
||||
out[0] = static_cast<Char>('0' + c / 100);
|
||||
out[1] = static_cast<Char>('0' + c / 10 % 10);
|
||||
out[2] = static_cast<Char>('0' + c % 10);
|
||||
out[3] = static_cast<Char>(delimiter);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char>
|
||||
FMT_CONSTEXPR ansi_color_escape<Char> make_foreground_color(
|
||||
detail::color_type foreground) FMT_NOEXCEPT {
|
||||
return ansi_color_escape<Char>(foreground, detail::data::foreground_color);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
FMT_CONSTEXPR ansi_color_escape<Char> make_background_color(
|
||||
detail::color_type background) FMT_NOEXCEPT {
|
||||
return ansi_color_escape<Char>(background, detail::data::background_color);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
FMT_CONSTEXPR ansi_color_escape<Char> make_emphasis(emphasis em) FMT_NOEXCEPT {
|
||||
return ansi_color_escape<Char>(em);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
inline void fputs(const Char* chars, FILE* stream) FMT_NOEXCEPT {
|
||||
std::fputs(chars, stream);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
|
||||
std::fputws(chars, stream);
|
||||
}
|
||||
|
||||
template <typename Char> inline void reset_color(FILE* stream) FMT_NOEXCEPT {
|
||||
fputs(detail::data::reset_color, stream);
|
||||
}
|
||||
|
||||
template <> inline void reset_color<wchar_t>(FILE* stream) FMT_NOEXCEPT {
|
||||
fputs(detail::data::wreset_color, stream);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
inline void reset_color(basic_memory_buffer<Char>& buffer) FMT_NOEXCEPT {
|
||||
const char* begin = data::reset_color;
|
||||
const char* end = begin + sizeof(data::reset_color) - 1;
|
||||
buffer.append(begin, end);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
void vformat_to(basic_memory_buffer<Char>& buf, const text_style& ts,
|
||||
basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<Char>> args) {
|
||||
bool has_style = false;
|
||||
if (ts.has_emphasis()) {
|
||||
has_style = true;
|
||||
auto emphasis = detail::make_emphasis<Char>(ts.get_emphasis());
|
||||
buf.append(emphasis.begin(), emphasis.end());
|
||||
}
|
||||
if (ts.has_foreground()) {
|
||||
has_style = true;
|
||||
auto foreground = detail::make_foreground_color<Char>(ts.get_foreground());
|
||||
buf.append(foreground.begin(), foreground.end());
|
||||
}
|
||||
if (ts.has_background()) {
|
||||
has_style = true;
|
||||
auto background = detail::make_background_color<Char>(ts.get_background());
|
||||
buf.append(background.begin(), background.end());
|
||||
}
|
||||
detail::vformat_to(buf, format_str, args);
|
||||
if (has_style) detail::reset_color<Char>(buf);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
void vprint(std::FILE* f, const text_style& ts, const S& format,
|
||||
basic_format_args<buffer_context<Char>> args) {
|
||||
basic_memory_buffer<Char> buf;
|
||||
detail::vformat_to(buf, ts, to_string_view(format), args);
|
||||
buf.push_back(Char(0));
|
||||
detail::fputs(buf.data(), f);
|
||||
}
|
||||
|
||||
/**
|
||||
Formats a string and prints it to the specified file stream using ANSI
|
||||
escape sequences to specify text formatting.
|
||||
Example:
|
||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
|
||||
"Elapsed time: {0:.2f} seconds", 1.23);
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
void print(std::FILE* f, const text_style& ts, const S& format_str,
|
||||
const Args&... args) {
|
||||
detail::check_format_string<Args...>(format_str);
|
||||
using context = buffer_context<char_t<S>>;
|
||||
format_arg_store<context, Args...> as{args...};
|
||||
vprint(f, ts, format_str, basic_format_args<context>(as));
|
||||
}
|
||||
|
||||
/**
|
||||
Formats a string and prints it to stdout using ANSI escape sequences to
|
||||
specify text formatting.
|
||||
Example:
|
||||
fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
|
||||
"Elapsed time: {0:.2f} seconds", 1.23);
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
void print(const text_style& ts, const S& format_str, const Args&... args) {
|
||||
return print(stdout, ts, format_str, args...);
|
||||
}
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> vformat(
|
||||
const text_style& ts, const S& format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> buf;
|
||||
detail::vformat_to(buf, ts, to_string_view(format_str), args);
|
||||
return fmt::to_string(buf);
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Formats arguments and returns the result as a string using ANSI
|
||||
escape sequences to specify text formatting.
|
||||
|
||||
**Example**::
|
||||
|
||||
#include <fmt/color.h>
|
||||
std::string message = fmt::format(fmt::emphasis::bold | fg(fmt::color::red),
|
||||
"The answer is {}", 42);
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> format(const text_style& ts, const S& format_str,
|
||||
const Args&... args) {
|
||||
return vformat(ts, to_string_view(format_str),
|
||||
detail::make_args_checked<Args...>(format_str, args...));
|
||||
}
|
||||
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_COLOR_H_
|
||||
665
external/fmtlib/include/fmt/compile.h
vendored
665
external/fmtlib/include/fmt/compile.h
vendored
@@ -1,665 +0,0 @@
|
||||
// Formatting library for C++ - experimental format string compilation
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich and fmt contributors
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef FMT_COMPILE_H_
|
||||
#define FMT_COMPILE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace detail {
|
||||
|
||||
// A compile-time string which is compiled into fast formatting code.
|
||||
class compiled_string {};
|
||||
|
||||
template <typename S>
|
||||
struct is_compiled_string : std::is_base_of<compiled_string, S> {};
|
||||
|
||||
/**
|
||||
\rst
|
||||
Converts a string literal *s* into a format string that will be parsed at
|
||||
compile time and converted into efficient formatting code. Requires C++17
|
||||
``constexpr if`` compiler support.
|
||||
|
||||
**Example**::
|
||||
|
||||
// Converts 42 into std::string using the most efficient method and no
|
||||
// runtime format string processing.
|
||||
std::string s = fmt::format(FMT_COMPILE("{}"), 42);
|
||||
\endrst
|
||||
*/
|
||||
#define FMT_COMPILE(s) FMT_STRING_IMPL(s, fmt::detail::compiled_string)
|
||||
|
||||
template <typename T, typename... Tail>
|
||||
const T& first(const T& value, const Tail&...) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// Part of a compiled format string. It can be either literal text or a
|
||||
// replacement field.
|
||||
template <typename Char> struct format_part {
|
||||
enum class kind { arg_index, arg_name, text, replacement };
|
||||
|
||||
struct replacement {
|
||||
arg_ref<Char> arg_id;
|
||||
dynamic_format_specs<Char> specs;
|
||||
};
|
||||
|
||||
kind part_kind;
|
||||
union value {
|
||||
int arg_index;
|
||||
basic_string_view<Char> str;
|
||||
replacement repl;
|
||||
|
||||
FMT_CONSTEXPR value(int index = 0) : arg_index(index) {}
|
||||
FMT_CONSTEXPR value(basic_string_view<Char> s) : str(s) {}
|
||||
FMT_CONSTEXPR value(replacement r) : repl(r) {}
|
||||
} val;
|
||||
// Position past the end of the argument id.
|
||||
const Char* arg_id_end = nullptr;
|
||||
|
||||
FMT_CONSTEXPR format_part(kind k = kind::arg_index, value v = {})
|
||||
: part_kind(k), val(v) {}
|
||||
|
||||
static FMT_CONSTEXPR format_part make_arg_index(int index) {
|
||||
return format_part(kind::arg_index, index);
|
||||
}
|
||||
static FMT_CONSTEXPR format_part make_arg_name(basic_string_view<Char> name) {
|
||||
return format_part(kind::arg_name, name);
|
||||
}
|
||||
static FMT_CONSTEXPR format_part make_text(basic_string_view<Char> text) {
|
||||
return format_part(kind::text, text);
|
||||
}
|
||||
static FMT_CONSTEXPR format_part make_replacement(replacement repl) {
|
||||
return format_part(kind::replacement, repl);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char> struct part_counter {
|
||||
unsigned num_parts = 0;
|
||||
|
||||
FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
|
||||
if (begin != end) ++num_parts;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR int on_arg_id() { return ++num_parts, 0; }
|
||||
FMT_CONSTEXPR int on_arg_id(int) { return ++num_parts, 0; }
|
||||
FMT_CONSTEXPR int on_arg_id(basic_string_view<Char>) {
|
||||
return ++num_parts, 0;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR void on_replacement_field(int, const Char*) {}
|
||||
|
||||
FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin,
|
||||
const Char* end) {
|
||||
// Find the matching brace.
|
||||
unsigned brace_counter = 0;
|
||||
for (; begin != end; ++begin) {
|
||||
if (*begin == '{') {
|
||||
++brace_counter;
|
||||
} else if (*begin == '}') {
|
||||
if (brace_counter == 0u) break;
|
||||
--brace_counter;
|
||||
}
|
||||
}
|
||||
return begin;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR void on_error(const char*) {}
|
||||
};
|
||||
|
||||
// Counts the number of parts in a format string.
|
||||
template <typename Char>
|
||||
FMT_CONSTEXPR unsigned count_parts(basic_string_view<Char> format_str) {
|
||||
part_counter<Char> counter;
|
||||
parse_format_string<true>(format_str, counter);
|
||||
return counter.num_parts;
|
||||
}
|
||||
|
||||
template <typename Char, typename PartHandler>
|
||||
class format_string_compiler : public error_handler {
|
||||
private:
|
||||
using part = format_part<Char>;
|
||||
|
||||
PartHandler handler_;
|
||||
part part_;
|
||||
basic_string_view<Char> format_str_;
|
||||
basic_format_parse_context<Char> parse_context_;
|
||||
|
||||
public:
|
||||
FMT_CONSTEXPR format_string_compiler(basic_string_view<Char> format_str,
|
||||
PartHandler handler)
|
||||
: handler_(handler),
|
||||
format_str_(format_str),
|
||||
parse_context_(format_str) {}
|
||||
|
||||
FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
|
||||
if (begin != end)
|
||||
handler_(part::make_text({begin, to_unsigned(end - begin)}));
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR int on_arg_id() {
|
||||
part_ = part::make_arg_index(parse_context_.next_arg_id());
|
||||
return 0;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR int on_arg_id(int id) {
|
||||
parse_context_.check_arg_id(id);
|
||||
part_ = part::make_arg_index(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR int on_arg_id(basic_string_view<Char> id) {
|
||||
part_ = part::make_arg_name(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR void on_replacement_field(int, const Char* ptr) {
|
||||
part_.arg_id_end = ptr;
|
||||
handler_(part_);
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR const Char* on_format_specs(int, const Char* begin,
|
||||
const Char* end) {
|
||||
auto repl = typename part::replacement();
|
||||
dynamic_specs_handler<basic_format_parse_context<Char>> handler(
|
||||
repl.specs, parse_context_);
|
||||
auto it = parse_format_specs(begin, end, handler);
|
||||
if (*it != '}') on_error("missing '}' in format string");
|
||||
repl.arg_id = part_.part_kind == part::kind::arg_index
|
||||
? arg_ref<Char>(part_.val.arg_index)
|
||||
: arg_ref<Char>(part_.val.str);
|
||||
auto part = part::make_replacement(repl);
|
||||
part.arg_id_end = begin;
|
||||
handler_(part);
|
||||
return it;
|
||||
}
|
||||
};
|
||||
|
||||
// Compiles a format string and invokes handler(part) for each parsed part.
|
||||
template <bool IS_CONSTEXPR, typename Char, typename PartHandler>
|
||||
FMT_CONSTEXPR void compile_format_string(basic_string_view<Char> format_str,
|
||||
PartHandler handler) {
|
||||
parse_format_string<IS_CONSTEXPR>(
|
||||
format_str,
|
||||
format_string_compiler<Char, PartHandler>(format_str, handler));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Context, typename Id>
|
||||
void format_arg(
|
||||
basic_format_parse_context<typename Context::char_type>& parse_ctx,
|
||||
Context& ctx, Id arg_id) {
|
||||
ctx.advance_to(visit_format_arg(
|
||||
arg_formatter<OutputIt, typename Context::char_type>(ctx, &parse_ctx),
|
||||
ctx.arg(arg_id)));
|
||||
}
|
||||
|
||||
// vformat_to is defined in a subnamespace to prevent ADL.
|
||||
namespace cf {
|
||||
template <typename Context, typename OutputIt, typename CompiledFormat>
|
||||
auto vformat_to(OutputIt out, CompiledFormat& cf,
|
||||
basic_format_args<Context> args) -> typename Context::iterator {
|
||||
using char_type = typename Context::char_type;
|
||||
basic_format_parse_context<char_type> parse_ctx(
|
||||
to_string_view(cf.format_str_));
|
||||
Context ctx(out, args);
|
||||
|
||||
const auto& parts = cf.parts();
|
||||
for (auto part_it = std::begin(parts); part_it != std::end(parts);
|
||||
++part_it) {
|
||||
const auto& part = *part_it;
|
||||
const auto& value = part.val;
|
||||
|
||||
using format_part_t = format_part<char_type>;
|
||||
switch (part.part_kind) {
|
||||
case format_part_t::kind::text: {
|
||||
const auto text = value.str;
|
||||
auto output = ctx.out();
|
||||
auto&& it = reserve(output, text.size());
|
||||
it = std::copy_n(text.begin(), text.size(), it);
|
||||
ctx.advance_to(output);
|
||||
break;
|
||||
}
|
||||
|
||||
case format_part_t::kind::arg_index:
|
||||
advance_to(parse_ctx, part.arg_id_end);
|
||||
detail::format_arg<OutputIt>(parse_ctx, ctx, value.arg_index);
|
||||
break;
|
||||
|
||||
case format_part_t::kind::arg_name:
|
||||
advance_to(parse_ctx, part.arg_id_end);
|
||||
detail::format_arg<OutputIt>(parse_ctx, ctx, value.str);
|
||||
break;
|
||||
|
||||
case format_part_t::kind::replacement: {
|
||||
const auto& arg_id_value = value.repl.arg_id.val;
|
||||
const auto arg = value.repl.arg_id.kind == arg_id_kind::index
|
||||
? ctx.arg(arg_id_value.index)
|
||||
: ctx.arg(arg_id_value.name);
|
||||
|
||||
auto specs = value.repl.specs;
|
||||
|
||||
handle_dynamic_spec<width_checker>(specs.width, specs.width_ref, ctx);
|
||||
handle_dynamic_spec<precision_checker>(specs.precision,
|
||||
specs.precision_ref, ctx);
|
||||
|
||||
error_handler h;
|
||||
numeric_specs_checker<error_handler> checker(h, arg.type());
|
||||
if (specs.align == align::numeric) checker.require_numeric_argument();
|
||||
if (specs.sign != sign::none) checker.check_sign();
|
||||
if (specs.alt) checker.require_numeric_argument();
|
||||
if (specs.precision >= 0) checker.check_precision();
|
||||
|
||||
advance_to(parse_ctx, part.arg_id_end);
|
||||
ctx.advance_to(
|
||||
visit_format_arg(arg_formatter<OutputIt, typename Context::char_type>(
|
||||
ctx, nullptr, &specs),
|
||||
arg));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ctx.out();
|
||||
}
|
||||
} // namespace cf
|
||||
|
||||
struct basic_compiled_format {};
|
||||
|
||||
template <typename S, typename = void>
|
||||
struct compiled_format_base : basic_compiled_format {
|
||||
using char_type = char_t<S>;
|
||||
using parts_container = std::vector<detail::format_part<char_type>>;
|
||||
|
||||
parts_container compiled_parts;
|
||||
|
||||
explicit compiled_format_base(basic_string_view<char_type> format_str) {
|
||||
compile_format_string<false>(format_str,
|
||||
[this](const format_part<char_type>& part) {
|
||||
compiled_parts.push_back(part);
|
||||
});
|
||||
}
|
||||
|
||||
const parts_container& parts() const { return compiled_parts; }
|
||||
};
|
||||
|
||||
template <typename Char, unsigned N> struct format_part_array {
|
||||
format_part<Char> data[N] = {};
|
||||
FMT_CONSTEXPR format_part_array() = default;
|
||||
};
|
||||
|
||||
template <typename Char, unsigned N>
|
||||
FMT_CONSTEXPR format_part_array<Char, N> compile_to_parts(
|
||||
basic_string_view<Char> format_str) {
|
||||
format_part_array<Char, N> parts;
|
||||
unsigned counter = 0;
|
||||
// This is not a lambda for compatibility with older compilers.
|
||||
struct {
|
||||
format_part<Char>* parts;
|
||||
unsigned* counter;
|
||||
FMT_CONSTEXPR void operator()(const format_part<Char>& part) {
|
||||
parts[(*counter)++] = part;
|
||||
}
|
||||
} collector{parts.data, &counter};
|
||||
compile_format_string<true>(format_str, collector);
|
||||
if (counter < N) {
|
||||
parts.data[counter] =
|
||||
format_part<Char>::make_text(basic_string_view<Char>());
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
template <typename T> constexpr const T& constexpr_max(const T& a, const T& b) {
|
||||
return (a < b) ? b : a;
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
struct compiled_format_base<S, enable_if_t<is_compile_string<S>::value>>
|
||||
: basic_compiled_format {
|
||||
using char_type = char_t<S>;
|
||||
|
||||
FMT_CONSTEXPR explicit compiled_format_base(basic_string_view<char_type>) {}
|
||||
|
||||
// Workaround for old compilers. Format string compilation will not be
|
||||
// performed there anyway.
|
||||
#if FMT_USE_CONSTEXPR
|
||||
static FMT_CONSTEXPR_DECL const unsigned num_format_parts =
|
||||
constexpr_max(count_parts(to_string_view(S())), 1u);
|
||||
#else
|
||||
static const unsigned num_format_parts = 1;
|
||||
#endif
|
||||
|
||||
using parts_container = format_part<char_type>[num_format_parts];
|
||||
|
||||
const parts_container& parts() const {
|
||||
static FMT_CONSTEXPR_DECL const auto compiled_parts =
|
||||
compile_to_parts<char_type, num_format_parts>(
|
||||
detail::to_string_view(S()));
|
||||
return compiled_parts.data;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename S, typename... Args>
|
||||
class compiled_format : private compiled_format_base<S> {
|
||||
public:
|
||||
using typename compiled_format_base<S>::char_type;
|
||||
|
||||
private:
|
||||
basic_string_view<char_type> format_str_;
|
||||
|
||||
template <typename Context, typename OutputIt, typename CompiledFormat>
|
||||
friend auto cf::vformat_to(OutputIt out, CompiledFormat& cf,
|
||||
basic_format_args<Context> args) ->
|
||||
typename Context::iterator;
|
||||
|
||||
public:
|
||||
compiled_format() = delete;
|
||||
explicit constexpr compiled_format(basic_string_view<char_type> format_str)
|
||||
: compiled_format_base<S>(format_str), format_str_(format_str) {}
|
||||
};
|
||||
|
||||
#ifdef __cpp_if_constexpr
|
||||
template <typename... Args> struct type_list {};
|
||||
|
||||
// Returns a reference to the argument at index N from [first, rest...].
|
||||
template <int N, typename T, typename... Args>
|
||||
constexpr const auto& get(const T& first, const Args&... rest) {
|
||||
static_assert(N < 1 + sizeof...(Args), "index is out of bounds");
|
||||
if constexpr (N == 0)
|
||||
return first;
|
||||
else
|
||||
return get<N - 1>(rest...);
|
||||
}
|
||||
|
||||
template <int N, typename> struct get_type_impl;
|
||||
|
||||
template <int N, typename... Args> struct get_type_impl<N, type_list<Args...>> {
|
||||
using type = remove_cvref_t<decltype(get<N>(std::declval<Args>()...))>;
|
||||
};
|
||||
|
||||
template <int N, typename T>
|
||||
using get_type = typename get_type_impl<N, T>::type;
|
||||
|
||||
template <typename T> struct is_compiled_format : std::false_type {};
|
||||
|
||||
template <typename Char> struct text {
|
||||
basic_string_view<Char> data;
|
||||
using char_type = Char;
|
||||
|
||||
template <typename OutputIt, typename... Args>
|
||||
OutputIt format(OutputIt out, const Args&...) const {
|
||||
return write<Char>(out, data);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char>
|
||||
struct is_compiled_format<text<Char>> : std::true_type {};
|
||||
|
||||
template <typename Char>
|
||||
constexpr text<Char> make_text(basic_string_view<Char> s, size_t pos,
|
||||
size_t size) {
|
||||
return {{&s[pos], size}};
|
||||
}
|
||||
|
||||
// A replacement field that refers to argument N.
|
||||
template <typename Char, typename T, int N> struct field {
|
||||
using char_type = Char;
|
||||
|
||||
template <typename OutputIt, typename... Args>
|
||||
OutputIt format(OutputIt out, const Args&... args) const {
|
||||
// This ensures that the argument type is convertile to `const T&`.
|
||||
const T& arg = get<N>(args...);
|
||||
return write<Char>(out, arg);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char, typename T, int N>
|
||||
struct is_compiled_format<field<Char, T, N>> : std::true_type {};
|
||||
|
||||
// A replacement field that refers to argument N and has format specifiers.
|
||||
template <typename Char, typename T, int N> struct spec_field {
|
||||
using char_type = Char;
|
||||
mutable formatter<T, Char> fmt;
|
||||
|
||||
template <typename OutputIt, typename... Args>
|
||||
OutputIt format(OutputIt out, const Args&... args) const {
|
||||
// This ensures that the argument type is convertile to `const T&`.
|
||||
const T& arg = get<N>(args...);
|
||||
basic_format_context<OutputIt, Char> ctx(out, {});
|
||||
return fmt.format(arg, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char, typename T, int N>
|
||||
struct is_compiled_format<spec_field<Char, T, N>> : std::true_type {};
|
||||
|
||||
template <typename L, typename R> struct concat {
|
||||
L lhs;
|
||||
R rhs;
|
||||
using char_type = typename L::char_type;
|
||||
|
||||
template <typename OutputIt, typename... Args>
|
||||
OutputIt format(OutputIt out, const Args&... args) const {
|
||||
out = lhs.format(out, args...);
|
||||
return rhs.format(out, args...);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename L, typename R>
|
||||
struct is_compiled_format<concat<L, R>> : std::true_type {};
|
||||
|
||||
template <typename L, typename R>
|
||||
constexpr concat<L, R> make_concat(L lhs, R rhs) {
|
||||
return {lhs, rhs};
|
||||
}
|
||||
|
||||
struct unknown_format {};
|
||||
|
||||
template <typename Char>
|
||||
constexpr size_t parse_text(basic_string_view<Char> str, size_t pos) {
|
||||
for (size_t size = str.size(); pos != size; ++pos) {
|
||||
if (str[pos] == '{' || str[pos] == '}') break;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
template <typename Args, size_t POS, int ID, typename S>
|
||||
constexpr auto compile_format_string(S format_str);
|
||||
|
||||
template <typename Args, size_t POS, int ID, typename T, typename S>
|
||||
constexpr auto parse_tail(T head, S format_str) {
|
||||
if constexpr (POS !=
|
||||
basic_string_view<typename S::char_type>(format_str).size()) {
|
||||
constexpr auto tail = compile_format_string<Args, POS, ID>(format_str);
|
||||
if constexpr (std::is_same<remove_cvref_t<decltype(tail)>,
|
||||
unknown_format>())
|
||||
return tail;
|
||||
else
|
||||
return make_concat(head, tail);
|
||||
} else {
|
||||
return head;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename Char> struct parse_specs_result {
|
||||
formatter<T, Char> fmt;
|
||||
size_t end;
|
||||
};
|
||||
|
||||
template <typename T, typename Char>
|
||||
constexpr parse_specs_result<T, Char> parse_specs(basic_string_view<Char> str,
|
||||
size_t pos) {
|
||||
str.remove_prefix(pos);
|
||||
auto ctx = basic_format_parse_context<Char>(str);
|
||||
auto f = formatter<T, Char>();
|
||||
auto end = f.parse(ctx);
|
||||
return {f, pos + (end - str.data()) + 1};
|
||||
}
|
||||
|
||||
// Compiles a non-empty format string and returns the compiled representation
|
||||
// or unknown_format() on unrecognized input.
|
||||
template <typename Args, size_t POS, int ID, typename S>
|
||||
constexpr auto compile_format_string(S format_str) {
|
||||
using char_type = typename S::char_type;
|
||||
constexpr basic_string_view<char_type> str = format_str;
|
||||
if constexpr (str[POS] == '{') {
|
||||
if (POS + 1 == str.size())
|
||||
throw format_error("unmatched '{' in format string");
|
||||
if constexpr (str[POS + 1] == '{') {
|
||||
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
|
||||
} else if constexpr (str[POS + 1] == '}') {
|
||||
using type = get_type<ID, Args>;
|
||||
return parse_tail<Args, POS + 2, ID + 1>(field<char_type, type, ID>(),
|
||||
format_str);
|
||||
} else if constexpr (str[POS + 1] == ':') {
|
||||
using type = get_type<ID, Args>;
|
||||
constexpr auto result = parse_specs<type>(str, POS + 2);
|
||||
return parse_tail<Args, result.end, ID + 1>(
|
||||
spec_field<char_type, type, ID>{result.fmt}, format_str);
|
||||
} else {
|
||||
return unknown_format();
|
||||
}
|
||||
} else if constexpr (str[POS] == '}') {
|
||||
if (POS + 1 == str.size())
|
||||
throw format_error("unmatched '}' in format string");
|
||||
return parse_tail<Args, POS + 2, ID>(make_text(str, POS, 1), format_str);
|
||||
} else {
|
||||
constexpr auto end = parse_text(str, POS + 1);
|
||||
return parse_tail<Args, end, ID>(make_text(str, POS, end - POS),
|
||||
format_str);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args, typename S,
|
||||
FMT_ENABLE_IF(is_compile_string<S>::value ||
|
||||
detail::is_compiled_string<S>::value)>
|
||||
constexpr auto compile(S format_str) {
|
||||
constexpr basic_string_view<typename S::char_type> str = format_str;
|
||||
if constexpr (str.size() == 0) {
|
||||
return detail::make_text(str, 0, 0);
|
||||
} else {
|
||||
constexpr auto result =
|
||||
detail::compile_format_string<detail::type_list<Args...>, 0, 0>(
|
||||
format_str);
|
||||
if constexpr (std::is_same<remove_cvref_t<decltype(result)>,
|
||||
detail::unknown_format>()) {
|
||||
return detail::compiled_format<S, Args...>(to_string_view(format_str));
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
template <typename... Args, typename S,
|
||||
FMT_ENABLE_IF(is_compile_string<S>::value)>
|
||||
constexpr auto compile(S format_str) -> detail::compiled_format<S, Args...> {
|
||||
return detail::compiled_format<S, Args...>(to_string_view(format_str));
|
||||
}
|
||||
#endif // __cpp_if_constexpr
|
||||
|
||||
// Compiles the format string which must be a string literal.
|
||||
template <typename... Args, typename Char, size_t N>
|
||||
auto compile(const Char (&format_str)[N])
|
||||
-> detail::compiled_format<const Char*, Args...> {
|
||||
return detail::compiled_format<const Char*, Args...>(
|
||||
basic_string_view<Char>(format_str, N - 1));
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// DEPRECATED! use FMT_COMPILE instead.
|
||||
template <typename... Args>
|
||||
FMT_DEPRECATED auto compile(const Args&... args)
|
||||
-> decltype(detail::compile(args...)) {
|
||||
return detail::compile(args...);
|
||||
}
|
||||
|
||||
#if FMT_USE_CONSTEXPR
|
||||
# ifdef __cpp_if_constexpr
|
||||
|
||||
template <typename CompiledFormat, typename... Args,
|
||||
typename Char = typename CompiledFormat::char_type,
|
||||
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
||||
FMT_INLINE std::basic_string<Char> format(const CompiledFormat& cf,
|
||||
const Args&... args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
detail::buffer<Char>& base = buffer;
|
||||
cf.format(std::back_inserter(base), args...);
|
||||
return to_string(buffer);
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_compiled_format<CompiledFormat>::value)>
|
||||
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
|
||||
const Args&... args) {
|
||||
return cf.format(out, args...);
|
||||
}
|
||||
# endif // __cpp_if_constexpr
|
||||
#endif // FMT_USE_CONSTEXPR
|
||||
|
||||
template <typename CompiledFormat, typename... Args,
|
||||
typename Char = typename CompiledFormat::char_type,
|
||||
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
|
||||
CompiledFormat>::value)>
|
||||
std::basic_string<Char> format(const CompiledFormat& cf, const Args&... args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
using context = buffer_context<Char>;
|
||||
detail::buffer<Char>& base = buffer;
|
||||
detail::cf::vformat_to<context>(std::back_inserter(base), cf,
|
||||
make_format_args<context>(args...));
|
||||
return to_string(buffer);
|
||||
}
|
||||
|
||||
template <typename S, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
|
||||
FMT_INLINE std::basic_string<typename S::char_type> format(const S&,
|
||||
Args&&... args) {
|
||||
constexpr basic_string_view<typename S::char_type> str = S();
|
||||
if (str.size() == 2 && str[0] == '{' && str[1] == '}')
|
||||
return fmt::to_string(detail::first(args...));
|
||||
constexpr auto compiled = detail::compile<Args...>(S());
|
||||
return format(compiled, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename CompiledFormat, typename... Args,
|
||||
FMT_ENABLE_IF(std::is_base_of<detail::basic_compiled_format,
|
||||
CompiledFormat>::value)>
|
||||
OutputIt format_to(OutputIt out, const CompiledFormat& cf,
|
||||
const Args&... args) {
|
||||
using char_type = typename CompiledFormat::char_type;
|
||||
using context = format_context_t<OutputIt, char_type>;
|
||||
return detail::cf::vformat_to<context>(out, cf,
|
||||
make_format_args<context>(args...));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename S, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>
|
||||
OutputIt format_to(OutputIt out, const S&, const Args&... args) {
|
||||
constexpr auto compiled = detail::compile<Args...>(S());
|
||||
return format_to(out, compiled, args...);
|
||||
}
|
||||
|
||||
template <
|
||||
typename OutputIt, typename CompiledFormat, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value&& std::is_base_of<
|
||||
detail::basic_compiled_format, CompiledFormat>::value)>
|
||||
format_to_n_result<OutputIt> format_to_n(OutputIt out, size_t n,
|
||||
const CompiledFormat& cf,
|
||||
const Args&... args) {
|
||||
auto it =
|
||||
format_to(detail::truncating_iterator<OutputIt>(out, n), cf, args...);
|
||||
return {it.base(), it.count()};
|
||||
}
|
||||
|
||||
template <typename CompiledFormat, typename... Args>
|
||||
size_t formatted_size(const CompiledFormat& cf, const Args&... args) {
|
||||
return format_to(detail::counting_iterator(), cf, args...).count();
|
||||
}
|
||||
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_COMPILE_H_
|
||||
1882
external/fmtlib/include/fmt/core.h
vendored
1882
external/fmtlib/include/fmt/core.h
vendored
File diff suppressed because it is too large
Load Diff
1453
external/fmtlib/include/fmt/format-inl.h
vendored
1453
external/fmtlib/include/fmt/format-inl.h
vendored
File diff suppressed because it is too large
Load Diff
3729
external/fmtlib/include/fmt/format.h
vendored
3729
external/fmtlib/include/fmt/format.h
vendored
File diff suppressed because it is too large
Load Diff
78
external/fmtlib/include/fmt/locale.h
vendored
78
external/fmtlib/include/fmt/locale.h
vendored
@@ -1,78 +0,0 @@
|
||||
// Formatting library for C++ - std::locale support
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef FMT_LOCALE_H_
|
||||
#define FMT_LOCALE_H_
|
||||
|
||||
#include <locale>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
namespace detail {
|
||||
template <typename Char>
|
||||
typename buffer_context<Char>::iterator vformat_to(
|
||||
const std::locale& loc, buffer<Char>& buf,
|
||||
basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
using af = arg_formatter<typename buffer_context<Char>::iterator, Char>;
|
||||
return vformat_to<af>(std::back_inserter(buf), to_string_view(format_str),
|
||||
args, detail::locale_ref(loc));
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
std::basic_string<Char> vformat(
|
||||
const std::locale& loc, basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
detail::vformat_to(loc, buffer, format_str, args);
|
||||
return fmt::to_string(buffer);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> vformat(
|
||||
const std::locale& loc, const S& format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
return detail::vformat(loc, to_string_view(format_str), args);
|
||||
}
|
||||
|
||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> format(const std::locale& loc,
|
||||
const S& format_str, Args&&... args) {
|
||||
return detail::vformat(
|
||||
loc, to_string_view(format_str),
|
||||
detail::make_args_checked<Args...>(format_str, args...));
|
||||
}
|
||||
|
||||
template <typename S, typename OutputIt, typename... Args,
|
||||
typename Char = enable_if_t<
|
||||
detail::is_output_iterator<OutputIt>::value, char_t<S>>>
|
||||
inline OutputIt vformat_to(
|
||||
OutputIt out, const std::locale& loc, const S& format_str,
|
||||
format_args_t<type_identity_t<OutputIt>, Char> args) {
|
||||
using af = detail::arg_formatter<OutputIt, Char>;
|
||||
return vformat_to<af>(out, to_string_view(format_str), args,
|
||||
detail::locale_ref(loc));
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename S, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt>::value&&
|
||||
detail::is_string<S>::value)>
|
||||
inline OutputIt format_to(OutputIt out, const std::locale& loc,
|
||||
const S& format_str, Args&&... args) {
|
||||
detail::check_format_string<Args...>(format_str);
|
||||
using context = format_context_t<OutputIt, char_t<S>>;
|
||||
format_arg_store<context, Args...> as{args...};
|
||||
return vformat_to(out, loc, to_string_view(format_str),
|
||||
basic_format_args<context>(as));
|
||||
}
|
||||
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_LOCALE_H_
|
||||
450
external/fmtlib/include/fmt/os.h
vendored
450
external/fmtlib/include/fmt/os.h
vendored
@@ -1,450 +0,0 @@
|
||||
// Formatting library for C++ - optional OS-specific functionality
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef FMT_OS_H_
|
||||
#define FMT_OS_H_
|
||||
|
||||
#if defined(__MINGW32__) || defined(__CYGWIN__)
|
||||
// Workaround MinGW bug https://sourceforge.net/p/mingw/bugs/2024/.
|
||||
# undef __STRICT_ANSI__
|
||||
#endif
|
||||
|
||||
#include <cerrno>
|
||||
#include <clocale> // for locale_t
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <cstdlib> // for strtod_l
|
||||
|
||||
#if defined __APPLE__ || defined(__FreeBSD__)
|
||||
# include <xlocale.h> // for LC_NUMERIC_MASK on OS X
|
||||
#endif
|
||||
|
||||
#include "format.h"
|
||||
|
||||
// UWP doesn't provide _pipe.
|
||||
#if FMT_HAS_INCLUDE("winapifamily.h")
|
||||
# include <winapifamily.h>
|
||||
#endif
|
||||
#if FMT_HAS_INCLUDE("fcntl.h") && \
|
||||
(!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
|
||||
# include <fcntl.h> // for O_RDONLY
|
||||
# define FMT_USE_FCNTL 1
|
||||
#else
|
||||
# define FMT_USE_FCNTL 0
|
||||
#endif
|
||||
|
||||
#ifndef FMT_POSIX
|
||||
# if defined(_WIN32) && !defined(__MINGW32__)
|
||||
// Fix warnings about deprecated symbols.
|
||||
# define FMT_POSIX(call) _##call
|
||||
# else
|
||||
# define FMT_POSIX(call) call
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Calls to system functions are wrapped in FMT_SYSTEM for testability.
|
||||
#ifdef FMT_SYSTEM
|
||||
# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
|
||||
#else
|
||||
# define FMT_SYSTEM(call) ::call
|
||||
# ifdef _WIN32
|
||||
// Fix warnings about deprecated symbols.
|
||||
# define FMT_POSIX_CALL(call) ::_##call
|
||||
# else
|
||||
# define FMT_POSIX_CALL(call) ::call
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Retries the expression while it evaluates to error_result and errno
|
||||
// equals to EINTR.
|
||||
#ifndef _WIN32
|
||||
# define FMT_RETRY_VAL(result, expression, error_result) \
|
||||
do { \
|
||||
(result) = (expression); \
|
||||
} while ((result) == (error_result) && errno == EINTR)
|
||||
#else
|
||||
# define FMT_RETRY_VAL(result, expression, error_result) result = (expression)
|
||||
#endif
|
||||
|
||||
#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
/**
|
||||
\rst
|
||||
A reference to a null-terminated string. It can be constructed from a C
|
||||
string or ``std::string``.
|
||||
|
||||
You can use one of the following type aliases for common character types:
|
||||
|
||||
+---------------+-----------------------------+
|
||||
| Type | Definition |
|
||||
+===============+=============================+
|
||||
| cstring_view | basic_cstring_view<char> |
|
||||
+---------------+-----------------------------+
|
||||
| wcstring_view | basic_cstring_view<wchar_t> |
|
||||
+---------------+-----------------------------+
|
||||
|
||||
This class is most useful as a parameter type to allow passing
|
||||
different types of strings to a function, for example::
|
||||
|
||||
template <typename... Args>
|
||||
std::string format(cstring_view format_str, const Args & ... args);
|
||||
|
||||
format("{}", 42);
|
||||
format(std::string("{}"), 42);
|
||||
\endrst
|
||||
*/
|
||||
template <typename Char> class basic_cstring_view {
|
||||
private:
|
||||
const Char* data_;
|
||||
|
||||
public:
|
||||
/** Constructs a string reference object from a C string. */
|
||||
basic_cstring_view(const Char* s) : data_(s) {}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Constructs a string reference from an ``std::string`` object.
|
||||
\endrst
|
||||
*/
|
||||
basic_cstring_view(const std::basic_string<Char>& s) : data_(s.c_str()) {}
|
||||
|
||||
/** Returns the pointer to a C string. */
|
||||
const Char* c_str() const { return data_; }
|
||||
};
|
||||
|
||||
using cstring_view = basic_cstring_view<char>;
|
||||
using wcstring_view = basic_cstring_view<wchar_t>;
|
||||
|
||||
// An error code.
|
||||
class error_code {
|
||||
private:
|
||||
int value_;
|
||||
|
||||
public:
|
||||
explicit error_code(int value = 0) FMT_NOEXCEPT : value_(value) {}
|
||||
|
||||
int get() const FMT_NOEXCEPT { return value_; }
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
namespace detail {
|
||||
// A converter from UTF-16 to UTF-8.
|
||||
// It is only provided for Windows since other systems support UTF-8 natively.
|
||||
class utf16_to_utf8 {
|
||||
private:
|
||||
memory_buffer buffer_;
|
||||
|
||||
public:
|
||||
utf16_to_utf8() {}
|
||||
FMT_API explicit utf16_to_utf8(wstring_view s);
|
||||
operator string_view() const { return string_view(&buffer_[0], size()); }
|
||||
size_t size() const { return buffer_.size() - 1; }
|
||||
const char* c_str() const { return &buffer_[0]; }
|
||||
std::string str() const { return std::string(&buffer_[0], size()); }
|
||||
|
||||
// Performs conversion returning a system error code instead of
|
||||
// throwing exception on conversion error. This method may still throw
|
||||
// in case of memory allocation error.
|
||||
FMT_API int convert(wstring_view s);
|
||||
};
|
||||
|
||||
FMT_API void format_windows_error(buffer<char>& out, int error_code,
|
||||
string_view message) FMT_NOEXCEPT;
|
||||
} // namespace detail
|
||||
|
||||
/** A Windows error. */
|
||||
class windows_error : public system_error {
|
||||
private:
|
||||
FMT_API void init(int error_code, string_view format_str, format_args args);
|
||||
|
||||
public:
|
||||
/**
|
||||
\rst
|
||||
Constructs a :class:`fmt::windows_error` object with the description
|
||||
of the form
|
||||
|
||||
.. parsed-literal::
|
||||
*<message>*: *<system-message>*
|
||||
|
||||
where *<message>* is the formatted message and *<system-message>* is the
|
||||
system message corresponding to the error code.
|
||||
*error_code* is a Windows error code as given by ``GetLastError``.
|
||||
If *error_code* is not a valid error code such as -1, the system message
|
||||
will look like "error -1".
|
||||
|
||||
**Example**::
|
||||
|
||||
// This throws a windows_error with the description
|
||||
// cannot open file 'madeup': The system cannot find the file specified.
|
||||
// or similar (system message may vary).
|
||||
const char *filename = "madeup";
|
||||
LPOFSTRUCT of = LPOFSTRUCT();
|
||||
HFILE file = OpenFile(filename, &of, OF_READ);
|
||||
if (file == HFILE_ERROR) {
|
||||
throw fmt::windows_error(GetLastError(),
|
||||
"cannot open file '{}'", filename);
|
||||
}
|
||||
\endrst
|
||||
*/
|
||||
template <typename... Args>
|
||||
windows_error(int error_code, string_view message, const Args&... args) {
|
||||
init(error_code, message, make_format_args(args...));
|
||||
}
|
||||
};
|
||||
|
||||
// Reports a Windows error without throwing an exception.
|
||||
// Can be used to report errors from destructors.
|
||||
FMT_API void report_windows_error(int error_code,
|
||||
string_view message) FMT_NOEXCEPT;
|
||||
#endif // _WIN32
|
||||
|
||||
// A buffered file.
|
||||
class buffered_file {
|
||||
private:
|
||||
FILE* file_;
|
||||
|
||||
friend class file;
|
||||
|
||||
explicit buffered_file(FILE* f) : file_(f) {}
|
||||
|
||||
public:
|
||||
buffered_file(const buffered_file&) = delete;
|
||||
void operator=(const buffered_file&) = delete;
|
||||
|
||||
// Constructs a buffered_file object which doesn't represent any file.
|
||||
buffered_file() FMT_NOEXCEPT : file_(nullptr) {}
|
||||
|
||||
// Destroys the object closing the file it represents if any.
|
||||
FMT_API ~buffered_file() FMT_NOEXCEPT;
|
||||
|
||||
public:
|
||||
buffered_file(buffered_file&& other) FMT_NOEXCEPT : file_(other.file_) {
|
||||
other.file_ = nullptr;
|
||||
}
|
||||
|
||||
buffered_file& operator=(buffered_file&& other) {
|
||||
close();
|
||||
file_ = other.file_;
|
||||
other.file_ = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Opens a file.
|
||||
FMT_API buffered_file(cstring_view filename, cstring_view mode);
|
||||
|
||||
// Closes the file.
|
||||
FMT_API void close();
|
||||
|
||||
// Returns the pointer to a FILE object representing this file.
|
||||
FILE* get() const FMT_NOEXCEPT { return file_; }
|
||||
|
||||
// We place parentheses around fileno to workaround a bug in some versions
|
||||
// of MinGW that define fileno as a macro.
|
||||
FMT_API int(fileno)() const;
|
||||
|
||||
void vprint(string_view format_str, format_args args) {
|
||||
fmt::vprint(file_, format_str, args);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void print(string_view format_str, const Args&... args) {
|
||||
vprint(format_str, make_format_args(args...));
|
||||
}
|
||||
};
|
||||
|
||||
#if FMT_USE_FCNTL
|
||||
// A file. Closed file is represented by a file object with descriptor -1.
|
||||
// Methods that are not declared with FMT_NOEXCEPT may throw
|
||||
// fmt::system_error in case of failure. Note that some errors such as
|
||||
// closing the file multiple times will cause a crash on Windows rather
|
||||
// than an exception. You can get standard behavior by overriding the
|
||||
// invalid parameter handler with _set_invalid_parameter_handler.
|
||||
class file {
|
||||
private:
|
||||
int fd_; // File descriptor.
|
||||
|
||||
// Constructs a file object with a given descriptor.
|
||||
explicit file(int fd) : fd_(fd) {}
|
||||
|
||||
public:
|
||||
// Possible values for the oflag argument to the constructor.
|
||||
enum {
|
||||
RDONLY = FMT_POSIX(O_RDONLY), // Open for reading only.
|
||||
WRONLY = FMT_POSIX(O_WRONLY), // Open for writing only.
|
||||
RDWR = FMT_POSIX(O_RDWR), // Open for reading and writing.
|
||||
CREATE = FMT_POSIX(O_CREAT) // Create if the file doesn't exist.
|
||||
};
|
||||
|
||||
// Constructs a file object which doesn't represent any file.
|
||||
file() FMT_NOEXCEPT : fd_(-1) {}
|
||||
|
||||
// Opens a file and constructs a file object representing this file.
|
||||
FMT_API file(cstring_view path, int oflag);
|
||||
|
||||
public:
|
||||
file(const file&) = delete;
|
||||
void operator=(const file&) = delete;
|
||||
|
||||
file(file&& other) FMT_NOEXCEPT : fd_(other.fd_) { other.fd_ = -1; }
|
||||
|
||||
file& operator=(file&& other) FMT_NOEXCEPT {
|
||||
close();
|
||||
fd_ = other.fd_;
|
||||
other.fd_ = -1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Destroys the object closing the file it represents if any.
|
||||
FMT_API ~file() FMT_NOEXCEPT;
|
||||
|
||||
// Returns the file descriptor.
|
||||
int descriptor() const FMT_NOEXCEPT { return fd_; }
|
||||
|
||||
// Closes the file.
|
||||
FMT_API void close();
|
||||
|
||||
// Returns the file size. The size has signed type for consistency with
|
||||
// stat::st_size.
|
||||
FMT_API long long size() const;
|
||||
|
||||
// Attempts to read count bytes from the file into the specified buffer.
|
||||
FMT_API size_t read(void* buffer, size_t count);
|
||||
|
||||
// Attempts to write count bytes from the specified buffer to the file.
|
||||
FMT_API size_t write(const void* buffer, size_t count);
|
||||
|
||||
// Duplicates a file descriptor with the dup function and returns
|
||||
// the duplicate as a file object.
|
||||
FMT_API static file dup(int fd);
|
||||
|
||||
// Makes fd be the copy of this file descriptor, closing fd first if
|
||||
// necessary.
|
||||
FMT_API void dup2(int fd);
|
||||
|
||||
// Makes fd be the copy of this file descriptor, closing fd first if
|
||||
// necessary.
|
||||
FMT_API void dup2(int fd, error_code& ec) FMT_NOEXCEPT;
|
||||
|
||||
// Creates a pipe setting up read_end and write_end file objects for reading
|
||||
// and writing respectively.
|
||||
FMT_API static void pipe(file& read_end, file& write_end);
|
||||
|
||||
// Creates a buffered_file object associated with this file and detaches
|
||||
// this file object from the file.
|
||||
FMT_API buffered_file fdopen(const char* mode);
|
||||
};
|
||||
|
||||
// Returns the memory page size.
|
||||
long getpagesize();
|
||||
|
||||
class direct_buffered_file;
|
||||
|
||||
template <typename S, typename... Args>
|
||||
void print(direct_buffered_file& f, const S& format_str,
|
||||
const Args&... args);
|
||||
|
||||
// A buffered file with a direct buffer access and no synchronization.
|
||||
class direct_buffered_file {
|
||||
private:
|
||||
file file_;
|
||||
|
||||
enum { buffer_size = 4096 };
|
||||
char buffer_[buffer_size];
|
||||
int pos_;
|
||||
|
||||
void flush() {
|
||||
if (pos_ == 0) return;
|
||||
file_.write(buffer_, pos_);
|
||||
pos_ = 0;
|
||||
}
|
||||
|
||||
int free_capacity() const { return buffer_size - pos_; }
|
||||
|
||||
public:
|
||||
direct_buffered_file(cstring_view path, int oflag)
|
||||
: file_(path, oflag), pos_(0) {}
|
||||
|
||||
~direct_buffered_file() {
|
||||
flush();
|
||||
}
|
||||
|
||||
void close() {
|
||||
flush();
|
||||
file_.close();
|
||||
}
|
||||
|
||||
template <typename S, typename... Args>
|
||||
friend void print(direct_buffered_file& f, const S& format_str,
|
||||
const Args&... args) {
|
||||
// We could avoid double buffering.
|
||||
auto buf = fmt::memory_buffer();
|
||||
fmt::format_to(std::back_inserter(buf), format_str, args...);
|
||||
auto remaining_pos = 0;
|
||||
auto remaining_size = buf.size();
|
||||
while (remaining_size > detail::to_unsigned(f.free_capacity())) {
|
||||
auto size = f.free_capacity();
|
||||
memcpy(f.buffer_ + f.pos_, buf.data() + remaining_pos, size);
|
||||
f.pos_ += size;
|
||||
f.flush();
|
||||
remaining_pos += size;
|
||||
remaining_size -= size;
|
||||
}
|
||||
memcpy(f.buffer_ + f.pos_, buf.data() + remaining_pos, remaining_size);
|
||||
f.pos_ += static_cast<int>(remaining_size);
|
||||
}
|
||||
};
|
||||
#endif // FMT_USE_FCNTL
|
||||
|
||||
#ifdef FMT_LOCALE
|
||||
// A "C" numeric locale.
|
||||
class locale {
|
||||
private:
|
||||
# ifdef _WIN32
|
||||
using locale_t = _locale_t;
|
||||
|
||||
static void freelocale(locale_t loc) { _free_locale(loc); }
|
||||
|
||||
static double strtod_l(const char* nptr, char** endptr, _locale_t loc) {
|
||||
return _strtod_l(nptr, endptr, loc);
|
||||
}
|
||||
# endif
|
||||
|
||||
locale_t locale_;
|
||||
|
||||
public:
|
||||
using type = locale_t;
|
||||
locale(const locale&) = delete;
|
||||
void operator=(const locale&) = delete;
|
||||
|
||||
locale() {
|
||||
# ifndef _WIN32
|
||||
locale_ = FMT_SYSTEM(newlocale(LC_NUMERIC_MASK, "C", nullptr));
|
||||
# else
|
||||
locale_ = _create_locale(LC_NUMERIC, "C");
|
||||
# endif
|
||||
if (!locale_) FMT_THROW(system_error(errno, "cannot create locale"));
|
||||
}
|
||||
~locale() { freelocale(locale_); }
|
||||
|
||||
type get() const { return locale_; }
|
||||
|
||||
// Converts string to floating-point number and advances str past the end
|
||||
// of the parsed input.
|
||||
double strtod(const char*& str) const {
|
||||
char* end = nullptr;
|
||||
double result = strtod_l(str, &end, locale_);
|
||||
str = end;
|
||||
return result;
|
||||
}
|
||||
};
|
||||
using Locale FMT_DEPRECATED_ALIAS = locale;
|
||||
#endif // FMT_LOCALE
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_OS_H_
|
||||
167
external/fmtlib/include/fmt/ostream.h
vendored
167
external/fmtlib/include/fmt/ostream.h
vendored
@@ -1,167 +0,0 @@
|
||||
// Formatting library for C++ - std::ostream support
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef FMT_OSTREAM_H_
|
||||
#define FMT_OSTREAM_H_
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
template <typename Char> class basic_printf_parse_context;
|
||||
template <typename OutputIt, typename Char> class basic_printf_context;
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <class Char> class formatbuf : public std::basic_streambuf<Char> {
|
||||
private:
|
||||
using int_type = typename std::basic_streambuf<Char>::int_type;
|
||||
using traits_type = typename std::basic_streambuf<Char>::traits_type;
|
||||
|
||||
buffer<Char>& buffer_;
|
||||
|
||||
public:
|
||||
formatbuf(buffer<Char>& buf) : buffer_(buf) {}
|
||||
|
||||
protected:
|
||||
// The put-area is actually always empty. This makes the implementation
|
||||
// simpler and has the advantage that the streambuf and the buffer are always
|
||||
// in sync and sputc never writes into uninitialized memory. The obvious
|
||||
// disadvantage is that each call to sputc always results in a (virtual) call
|
||||
// to overflow. There is no disadvantage here for sputn since this always
|
||||
// results in a call to xsputn.
|
||||
|
||||
int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE {
|
||||
if (!traits_type::eq_int_type(ch, traits_type::eof()))
|
||||
buffer_.push_back(static_cast<Char>(ch));
|
||||
return ch;
|
||||
}
|
||||
|
||||
std::streamsize xsputn(const Char* s, std::streamsize count) FMT_OVERRIDE {
|
||||
buffer_.append(s, s + count);
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char> struct test_stream : std::basic_ostream<Char> {
|
||||
private:
|
||||
// Hide all operator<< from std::basic_ostream<Char>.
|
||||
void_t<> operator<<(null<>);
|
||||
void_t<> operator<<(const Char*);
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(std::is_convertible<T, int>::value &&
|
||||
!std::is_enum<T>::value)>
|
||||
void_t<> operator<<(T);
|
||||
};
|
||||
|
||||
// Checks if T has a user-defined operator<< (e.g. not a member of
|
||||
// std::ostream).
|
||||
template <typename T, typename Char> class is_streamable {
|
||||
private:
|
||||
template <typename U>
|
||||
static bool_constant<!std::is_same<decltype(std::declval<test_stream<Char>&>()
|
||||
<< std::declval<U>()),
|
||||
void_t<>>::value>
|
||||
test(int);
|
||||
|
||||
template <typename> static std::false_type test(...);
|
||||
|
||||
using result = decltype(test<T>(0));
|
||||
|
||||
public:
|
||||
static const bool value = result::value;
|
||||
};
|
||||
|
||||
// Write the content of buf to os.
|
||||
template <typename Char>
|
||||
void write_buffer(std::basic_ostream<Char>& os, buffer<Char>& buf) {
|
||||
const Char* buf_data = buf.data();
|
||||
using unsigned_streamsize = std::make_unsigned<std::streamsize>::type;
|
||||
unsigned_streamsize size = buf.size();
|
||||
unsigned_streamsize max_size = to_unsigned(max_value<std::streamsize>());
|
||||
do {
|
||||
unsigned_streamsize n = size <= max_size ? size : max_size;
|
||||
os.write(buf_data, static_cast<std::streamsize>(n));
|
||||
buf_data += n;
|
||||
size -= n;
|
||||
} while (size != 0);
|
||||
}
|
||||
|
||||
template <typename Char, typename T>
|
||||
void format_value(buffer<Char>& buf, const T& value,
|
||||
locale_ref loc = locale_ref()) {
|
||||
formatbuf<Char> format_buf(buf);
|
||||
std::basic_ostream<Char> output(&format_buf);
|
||||
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||
if (loc) output.imbue(loc.get<std::locale>());
|
||||
#endif
|
||||
output << value;
|
||||
output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
|
||||
buf.resize(buf.size());
|
||||
}
|
||||
|
||||
// Formats an object of type T that has an overloaded ostream operator<<.
|
||||
template <typename T, typename Char>
|
||||
struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>>
|
||||
: private formatter<basic_string_view<Char>, Char> {
|
||||
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
|
||||
-> decltype(ctx.begin()) {
|
||||
return formatter<basic_string_view<Char>, Char>::parse(ctx);
|
||||
}
|
||||
template <typename ParseCtx,
|
||||
FMT_ENABLE_IF(std::is_same<
|
||||
ParseCtx, basic_printf_parse_context<Char>>::value)>
|
||||
auto parse(ParseCtx& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename OutputIt>
|
||||
auto format(const T& value, basic_format_context<OutputIt, Char>& ctx)
|
||||
-> OutputIt {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
format_value(buffer, value, ctx.locale());
|
||||
basic_string_view<Char> str(buffer.data(), buffer.size());
|
||||
return formatter<basic_string_view<Char>, Char>::format(str, ctx);
|
||||
}
|
||||
template <typename OutputIt>
|
||||
auto format(const T& value, basic_printf_context<OutputIt, Char>& ctx)
|
||||
-> OutputIt {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
format_value(buffer, value, ctx.locale());
|
||||
return std::copy(buffer.begin(), buffer.end(), ctx.out());
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <typename Char>
|
||||
void vprint(std::basic_ostream<Char>& os, basic_string_view<Char> format_str,
|
||||
basic_format_args<buffer_context<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
detail::vformat_to(buffer, format_str, args);
|
||||
detail::write_buffer(os, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Prints formatted data to the stream *os*.
|
||||
|
||||
**Example**::
|
||||
|
||||
fmt::print(cerr, "Don't {}!", "panic");
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
void print(std::basic_ostream<Char>& os, const S& format_str, Args&&... args) {
|
||||
vprint(os, to_string_view(format_str),
|
||||
detail::make_args_checked<Args...>(format_str, args...));
|
||||
}
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_OSTREAM_H_
|
||||
2
external/fmtlib/include/fmt/posix.h
vendored
2
external/fmtlib/include/fmt/posix.h
vendored
@@ -1,2 +0,0 @@
|
||||
#include "os.h"
|
||||
#warning "fmt/posix.h is deprecated; use fmt/os.h instead"
|
||||
751
external/fmtlib/include/fmt/printf.h
vendored
751
external/fmtlib/include/fmt/printf.h
vendored
@@ -1,751 +0,0 @@
|
||||
// Formatting library for C++ - legacy printf implementation
|
||||
//
|
||||
// Copyright (c) 2012 - 2016, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#ifndef FMT_PRINTF_H_
|
||||
#define FMT_PRINTF_H_
|
||||
|
||||
#include <algorithm> // std::max
|
||||
#include <limits> // std::numeric_limits
|
||||
|
||||
#include "ostream.h"
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
namespace detail {
|
||||
|
||||
// Checks if a value fits in int - used to avoid warnings about comparing
|
||||
// signed and unsigned integers.
|
||||
template <bool IsSigned> struct int_checker {
|
||||
template <typename T> static bool fits_in_int(T value) {
|
||||
unsigned max = max_value<int>();
|
||||
return value <= max;
|
||||
}
|
||||
static bool fits_in_int(bool) { return true; }
|
||||
};
|
||||
|
||||
template <> struct int_checker<true> {
|
||||
template <typename T> static bool fits_in_int(T value) {
|
||||
return value >= (std::numeric_limits<int>::min)() &&
|
||||
value <= max_value<int>();
|
||||
}
|
||||
static bool fits_in_int(int) { return true; }
|
||||
};
|
||||
|
||||
class printf_precision_handler {
|
||||
public:
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
int operator()(T value) {
|
||||
if (!int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
|
||||
FMT_THROW(format_error("number is too big"));
|
||||
return (std::max)(static_cast<int>(value), 0);
|
||||
}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
||||
int operator()(T) {
|
||||
FMT_THROW(format_error("precision is not integer"));
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// An argument visitor that returns true iff arg is a zero integer.
|
||||
class is_zero_int {
|
||||
public:
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
bool operator()(T value) {
|
||||
return value == 0;
|
||||
}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
||||
bool operator()(T) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
|
||||
|
||||
template <> struct make_unsigned_or_bool<bool> { using type = bool; };
|
||||
|
||||
template <typename T, typename Context> class arg_converter {
|
||||
private:
|
||||
using char_type = typename Context::char_type;
|
||||
|
||||
basic_format_arg<Context>& arg_;
|
||||
char_type type_;
|
||||
|
||||
public:
|
||||
arg_converter(basic_format_arg<Context>& arg, char_type type)
|
||||
: arg_(arg), type_(type) {}
|
||||
|
||||
void operator()(bool value) {
|
||||
if (type_ != 's') operator()<bool>(value);
|
||||
}
|
||||
|
||||
template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
|
||||
void operator()(U value) {
|
||||
bool is_signed = type_ == 'd' || type_ == 'i';
|
||||
using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
|
||||
if (const_check(sizeof(target_type) <= sizeof(int))) {
|
||||
// Extra casts are used to silence warnings.
|
||||
if (is_signed) {
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<int>(static_cast<target_type>(value)));
|
||||
} else {
|
||||
using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<unsigned>(static_cast<unsigned_type>(value)));
|
||||
}
|
||||
} else {
|
||||
if (is_signed) {
|
||||
// glibc's printf doesn't sign extend arguments of smaller types:
|
||||
// std::printf("%lld", -42); // prints "4294967254"
|
||||
// but we don't have to do the same because it's a UB.
|
||||
arg_ = detail::make_arg<Context>(static_cast<long long>(value));
|
||||
} else {
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<typename make_unsigned_or_bool<U>::type>(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
|
||||
void operator()(U) {} // No conversion needed for non-integral types.
|
||||
};
|
||||
|
||||
// Converts an integer argument to T for printf, if T is an integral type.
|
||||
// If T is void, the argument is converted to corresponding signed or unsigned
|
||||
// type depending on the type specifier: 'd' and 'i' - signed, other -
|
||||
// unsigned).
|
||||
template <typename T, typename Context, typename Char>
|
||||
void convert_arg(basic_format_arg<Context>& arg, Char type) {
|
||||
visit_format_arg(arg_converter<T, Context>(arg, type), arg);
|
||||
}
|
||||
|
||||
// Converts an integer argument to char for printf.
|
||||
template <typename Context> class char_converter {
|
||||
private:
|
||||
basic_format_arg<Context>& arg_;
|
||||
|
||||
public:
|
||||
explicit char_converter(basic_format_arg<Context>& arg) : arg_(arg) {}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
void operator()(T value) {
|
||||
arg_ = detail::make_arg<Context>(
|
||||
static_cast<typename Context::char_type>(value));
|
||||
}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
||||
void operator()(T) {} // No conversion needed for non-integral types.
|
||||
};
|
||||
|
||||
// An argument visitor that return a pointer to a C string if argument is a
|
||||
// string or null otherwise.
|
||||
template <typename Char> struct get_cstring {
|
||||
template <typename T> const Char* operator()(T) { return nullptr; }
|
||||
const Char* operator()(const Char* s) { return s; }
|
||||
};
|
||||
|
||||
// Checks if an argument is a valid printf width specifier and sets
|
||||
// left alignment if it is negative.
|
||||
template <typename Char> class printf_width_handler {
|
||||
private:
|
||||
using format_specs = basic_format_specs<Char>;
|
||||
|
||||
format_specs& specs_;
|
||||
|
||||
public:
|
||||
explicit printf_width_handler(format_specs& specs) : specs_(specs) {}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
|
||||
unsigned operator()(T value) {
|
||||
auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
|
||||
if (detail::is_negative(value)) {
|
||||
specs_.align = align::left;
|
||||
width = 0 - width;
|
||||
}
|
||||
unsigned int_max = max_value<int>();
|
||||
if (width > int_max) FMT_THROW(format_error("number is too big"));
|
||||
return static_cast<unsigned>(width);
|
||||
}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
|
||||
unsigned operator()(T) {
|
||||
FMT_THROW(format_error("width is not integer"));
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char, typename Context>
|
||||
void vprintf(buffer<Char>& buf, basic_string_view<Char> format,
|
||||
basic_format_args<Context> args) {
|
||||
Context(std::back_inserter(buf), format, args).format();
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
// For printing into memory_buffer.
|
||||
template <typename Char, typename Context>
|
||||
FMT_DEPRECATED void printf(detail::buffer<Char>& buf,
|
||||
basic_string_view<Char> format,
|
||||
basic_format_args<Context> args) {
|
||||
return detail::vprintf(buf, format, args);
|
||||
}
|
||||
using detail::vprintf;
|
||||
|
||||
template <typename Char>
|
||||
class basic_printf_parse_context : public basic_format_parse_context<Char> {
|
||||
using basic_format_parse_context<Char>::basic_format_parse_context;
|
||||
};
|
||||
template <typename OutputIt, typename Char> class basic_printf_context;
|
||||
|
||||
/**
|
||||
\rst
|
||||
The ``printf`` argument formatter.
|
||||
\endrst
|
||||
*/
|
||||
template <typename OutputIt, typename Char>
|
||||
class printf_arg_formatter : public detail::arg_formatter_base<OutputIt, Char> {
|
||||
public:
|
||||
using iterator = OutputIt;
|
||||
|
||||
private:
|
||||
using char_type = Char;
|
||||
using base = detail::arg_formatter_base<OutputIt, Char>;
|
||||
using context_type = basic_printf_context<OutputIt, Char>;
|
||||
|
||||
context_type& context_;
|
||||
|
||||
void write_null_pointer(char) {
|
||||
this->specs()->type = 0;
|
||||
this->write("(nil)");
|
||||
}
|
||||
|
||||
void write_null_pointer(wchar_t) {
|
||||
this->specs()->type = 0;
|
||||
this->write(L"(nil)");
|
||||
}
|
||||
|
||||
public:
|
||||
using format_specs = typename base::format_specs;
|
||||
|
||||
/**
|
||||
\rst
|
||||
Constructs an argument formatter object.
|
||||
*buffer* is a reference to the output buffer and *specs* contains format
|
||||
specifier information for standard argument types.
|
||||
\endrst
|
||||
*/
|
||||
printf_arg_formatter(iterator iter, format_specs& specs, context_type& ctx)
|
||||
: base(iter, &specs, detail::locale_ref()), context_(ctx) {}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(fmt::detail::is_integral<T>::value)>
|
||||
iterator operator()(T value) {
|
||||
// MSVC2013 fails to compile separate overloads for bool and char_type so
|
||||
// use std::is_same instead.
|
||||
if (std::is_same<T, bool>::value) {
|
||||
format_specs& fmt_specs = *this->specs();
|
||||
if (fmt_specs.type != 's') return base::operator()(value ? 1 : 0);
|
||||
fmt_specs.type = 0;
|
||||
this->write(value != 0);
|
||||
} else if (std::is_same<T, char_type>::value) {
|
||||
format_specs& fmt_specs = *this->specs();
|
||||
if (fmt_specs.type && fmt_specs.type != 'c')
|
||||
return (*this)(static_cast<int>(value));
|
||||
fmt_specs.sign = sign::none;
|
||||
fmt_specs.alt = false;
|
||||
fmt_specs.fill[0] = ' '; // Ignore '0' flag for char types.
|
||||
// align::numeric needs to be overwritten here since the '0' flag is
|
||||
// ignored for non-numeric types
|
||||
if (fmt_specs.align == align::none || fmt_specs.align == align::numeric)
|
||||
fmt_specs.align = align::right;
|
||||
return base::operator()(value);
|
||||
} else {
|
||||
return base::operator()(value);
|
||||
}
|
||||
return this->out();
|
||||
}
|
||||
|
||||
template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
|
||||
iterator operator()(T value) {
|
||||
return base::operator()(value);
|
||||
}
|
||||
|
||||
/** Formats a null-terminated C string. */
|
||||
iterator operator()(const char* value) {
|
||||
if (value)
|
||||
base::operator()(value);
|
||||
else if (this->specs()->type == 'p')
|
||||
write_null_pointer(char_type());
|
||||
else
|
||||
this->write("(null)");
|
||||
return this->out();
|
||||
}
|
||||
|
||||
/** Formats a null-terminated wide C string. */
|
||||
iterator operator()(const wchar_t* value) {
|
||||
if (value)
|
||||
base::operator()(value);
|
||||
else if (this->specs()->type == 'p')
|
||||
write_null_pointer(char_type());
|
||||
else
|
||||
this->write(L"(null)");
|
||||
return this->out();
|
||||
}
|
||||
|
||||
iterator operator()(basic_string_view<char_type> value) {
|
||||
return base::operator()(value);
|
||||
}
|
||||
|
||||
iterator operator()(monostate value) { return base::operator()(value); }
|
||||
|
||||
/** Formats a pointer. */
|
||||
iterator operator()(const void* value) {
|
||||
if (value) return base::operator()(value);
|
||||
this->specs()->type = 0;
|
||||
write_null_pointer(char_type());
|
||||
return this->out();
|
||||
}
|
||||
|
||||
/** Formats an argument of a custom (user-defined) type. */
|
||||
iterator operator()(typename basic_format_arg<context_type>::handle handle) {
|
||||
handle.format(context_.parse_context(), context_);
|
||||
return this->out();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> struct printf_formatter {
|
||||
printf_formatter() = delete;
|
||||
|
||||
template <typename ParseContext>
|
||||
auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const T& value, FormatContext& ctx) -> decltype(ctx.out()) {
|
||||
detail::format_value(detail::get_container(ctx.out()), value);
|
||||
return ctx.out();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
This template formats data and writes the output through an output iterator.
|
||||
*/
|
||||
template <typename OutputIt, typename Char> class basic_printf_context {
|
||||
public:
|
||||
/** The character type for the output. */
|
||||
using char_type = Char;
|
||||
using iterator = OutputIt;
|
||||
using format_arg = basic_format_arg<basic_printf_context>;
|
||||
using parse_context_type = basic_printf_parse_context<Char>;
|
||||
template <typename T> using formatter_type = printf_formatter<T>;
|
||||
|
||||
private:
|
||||
using format_specs = basic_format_specs<char_type>;
|
||||
|
||||
OutputIt out_;
|
||||
basic_format_args<basic_printf_context> args_;
|
||||
parse_context_type parse_ctx_;
|
||||
|
||||
static void parse_flags(format_specs& specs, const Char*& it,
|
||||
const Char* end);
|
||||
|
||||
// Returns the argument with specified index or, if arg_index is -1, the next
|
||||
// argument.
|
||||
format_arg get_arg(int arg_index = -1);
|
||||
|
||||
// Parses argument index, flags and width and returns the argument index.
|
||||
int parse_header(const Char*& it, const Char* end, format_specs& specs);
|
||||
|
||||
public:
|
||||
/**
|
||||
\rst
|
||||
Constructs a ``printf_context`` object. References to the arguments are
|
||||
stored in the context object so make sure they have appropriate lifetimes.
|
||||
\endrst
|
||||
*/
|
||||
basic_printf_context(OutputIt out, basic_string_view<char_type> format_str,
|
||||
basic_format_args<basic_printf_context> args)
|
||||
: out_(out), args_(args), parse_ctx_(format_str) {}
|
||||
|
||||
OutputIt out() { return out_; }
|
||||
void advance_to(OutputIt it) { out_ = it; }
|
||||
|
||||
detail::locale_ref locale() { return {}; }
|
||||
|
||||
format_arg arg(int id) const { return args_.get(id); }
|
||||
|
||||
parse_context_type& parse_context() { return parse_ctx_; }
|
||||
|
||||
FMT_CONSTEXPR void on_error(const char* message) {
|
||||
parse_ctx_.on_error(message);
|
||||
}
|
||||
|
||||
/** Formats stored arguments and writes the output to the range. */
|
||||
template <typename ArgFormatter = printf_arg_formatter<OutputIt, Char>>
|
||||
OutputIt format();
|
||||
};
|
||||
|
||||
template <typename OutputIt, typename Char>
|
||||
void basic_printf_context<OutputIt, Char>::parse_flags(format_specs& specs,
|
||||
const Char*& it,
|
||||
const Char* end) {
|
||||
for (; it != end; ++it) {
|
||||
switch (*it) {
|
||||
case '-':
|
||||
specs.align = align::left;
|
||||
break;
|
||||
case '+':
|
||||
specs.sign = sign::plus;
|
||||
break;
|
||||
case '0':
|
||||
specs.fill[0] = '0';
|
||||
break;
|
||||
case ' ':
|
||||
if (specs.sign != sign::plus) {
|
||||
specs.sign = sign::space;
|
||||
}
|
||||
break;
|
||||
case '#':
|
||||
specs.alt = true;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Char>
|
||||
typename basic_printf_context<OutputIt, Char>::format_arg
|
||||
basic_printf_context<OutputIt, Char>::get_arg(int arg_index) {
|
||||
if (arg_index < 0)
|
||||
arg_index = parse_ctx_.next_arg_id();
|
||||
else
|
||||
parse_ctx_.check_arg_id(--arg_index);
|
||||
return detail::get_arg(*this, arg_index);
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Char>
|
||||
int basic_printf_context<OutputIt, Char>::parse_header(const Char*& it,
|
||||
const Char* end,
|
||||
format_specs& specs) {
|
||||
int arg_index = -1;
|
||||
char_type c = *it;
|
||||
if (c >= '0' && c <= '9') {
|
||||
// Parse an argument index (if followed by '$') or a width possibly
|
||||
// preceded with '0' flag(s).
|
||||
detail::error_handler eh;
|
||||
int value = parse_nonnegative_int(it, end, eh);
|
||||
if (it != end && *it == '$') { // value is an argument index
|
||||
++it;
|
||||
arg_index = value;
|
||||
} else {
|
||||
if (c == '0') specs.fill[0] = '0';
|
||||
if (value != 0) {
|
||||
// Nonzero value means that we parsed width and don't need to
|
||||
// parse it or flags again, so return now.
|
||||
specs.width = value;
|
||||
return arg_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
parse_flags(specs, it, end);
|
||||
// Parse width.
|
||||
if (it != end) {
|
||||
if (*it >= '0' && *it <= '9') {
|
||||
detail::error_handler eh;
|
||||
specs.width = parse_nonnegative_int(it, end, eh);
|
||||
} else if (*it == '*') {
|
||||
++it;
|
||||
specs.width = static_cast<int>(visit_format_arg(
|
||||
detail::printf_width_handler<char_type>(specs), get_arg()));
|
||||
}
|
||||
}
|
||||
return arg_index;
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Char>
|
||||
template <typename ArgFormatter>
|
||||
OutputIt basic_printf_context<OutputIt, Char>::format() {
|
||||
auto out = this->out();
|
||||
const Char* start = parse_ctx_.begin();
|
||||
const Char* end = parse_ctx_.end();
|
||||
auto it = start;
|
||||
while (it != end) {
|
||||
char_type c = *it++;
|
||||
if (c != '%') continue;
|
||||
if (it != end && *it == c) {
|
||||
out = std::copy(start, it, out);
|
||||
start = ++it;
|
||||
continue;
|
||||
}
|
||||
out = std::copy(start, it - 1, out);
|
||||
|
||||
format_specs specs;
|
||||
specs.align = align::right;
|
||||
|
||||
// Parse argument index, flags and width.
|
||||
int arg_index = parse_header(it, end, specs);
|
||||
if (arg_index == 0) on_error("argument not found");
|
||||
|
||||
// Parse precision.
|
||||
if (it != end && *it == '.') {
|
||||
++it;
|
||||
c = it != end ? *it : 0;
|
||||
if ('0' <= c && c <= '9') {
|
||||
detail::error_handler eh;
|
||||
specs.precision = parse_nonnegative_int(it, end, eh);
|
||||
} else if (c == '*') {
|
||||
++it;
|
||||
specs.precision = static_cast<int>(
|
||||
visit_format_arg(detail::printf_precision_handler(), get_arg()));
|
||||
} else {
|
||||
specs.precision = 0;
|
||||
}
|
||||
}
|
||||
|
||||
format_arg arg = get_arg(arg_index);
|
||||
// For d, i, o, u, x, and X conversion specifiers, if a precision is
|
||||
// specified, the '0' flag is ignored
|
||||
if (specs.precision >= 0 && arg.is_integral())
|
||||
specs.fill[0] =
|
||||
' '; // Ignore '0' flag for non-numeric types or if '-' present.
|
||||
if (specs.precision >= 0 && arg.type() == detail::type::cstring_type) {
|
||||
auto str = visit_format_arg(detail::get_cstring<Char>(), arg);
|
||||
auto str_end = str + specs.precision;
|
||||
auto nul = std::find(str, str_end, Char());
|
||||
arg = detail::make_arg<basic_printf_context>(basic_string_view<Char>(
|
||||
str,
|
||||
detail::to_unsigned(nul != str_end ? nul - str : specs.precision)));
|
||||
}
|
||||
if (specs.alt && visit_format_arg(detail::is_zero_int(), arg))
|
||||
specs.alt = false;
|
||||
if (specs.fill[0] == '0') {
|
||||
if (arg.is_arithmetic() && specs.align != align::left)
|
||||
specs.align = align::numeric;
|
||||
else
|
||||
specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
|
||||
// flag is also present.
|
||||
}
|
||||
|
||||
// Parse length and convert the argument to the required type.
|
||||
c = it != end ? *it++ : 0;
|
||||
char_type t = it != end ? *it : 0;
|
||||
using detail::convert_arg;
|
||||
switch (c) {
|
||||
case 'h':
|
||||
if (t == 'h') {
|
||||
++it;
|
||||
t = it != end ? *it : 0;
|
||||
convert_arg<signed char>(arg, t);
|
||||
} else {
|
||||
convert_arg<short>(arg, t);
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
if (t == 'l') {
|
||||
++it;
|
||||
t = it != end ? *it : 0;
|
||||
convert_arg<long long>(arg, t);
|
||||
} else {
|
||||
convert_arg<long>(arg, t);
|
||||
}
|
||||
break;
|
||||
case 'j':
|
||||
convert_arg<intmax_t>(arg, t);
|
||||
break;
|
||||
case 'z':
|
||||
convert_arg<size_t>(arg, t);
|
||||
break;
|
||||
case 't':
|
||||
convert_arg<std::ptrdiff_t>(arg, t);
|
||||
break;
|
||||
case 'L':
|
||||
// printf produces garbage when 'L' is omitted for long double, no
|
||||
// need to do the same.
|
||||
break;
|
||||
default:
|
||||
--it;
|
||||
convert_arg<void>(arg, c);
|
||||
}
|
||||
|
||||
// Parse type.
|
||||
if (it == end) FMT_THROW(format_error("invalid format string"));
|
||||
specs.type = static_cast<char>(*it++);
|
||||
if (arg.is_integral()) {
|
||||
// Normalize type.
|
||||
switch (specs.type) {
|
||||
case 'i':
|
||||
case 'u':
|
||||
specs.type = 'd';
|
||||
break;
|
||||
case 'c':
|
||||
visit_format_arg(detail::char_converter<basic_printf_context>(arg),
|
||||
arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
start = it;
|
||||
|
||||
// Format argument.
|
||||
out = visit_format_arg(ArgFormatter(out, specs, *this), arg);
|
||||
}
|
||||
return std::copy(start, it, out);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
using basic_printf_context_t =
|
||||
basic_printf_context<std::back_insert_iterator<detail::buffer<Char>>, Char>;
|
||||
|
||||
using printf_context = basic_printf_context_t<char>;
|
||||
using wprintf_context = basic_printf_context_t<wchar_t>;
|
||||
|
||||
using printf_args = basic_format_args<printf_context>;
|
||||
using wprintf_args = basic_format_args<wprintf_context>;
|
||||
|
||||
/**
|
||||
\rst
|
||||
Constructs an `~fmt::format_arg_store` object that contains references to
|
||||
arguments and can be implicitly converted to `~fmt::printf_args`.
|
||||
\endrst
|
||||
*/
|
||||
template <typename... Args>
|
||||
inline format_arg_store<printf_context, Args...> make_printf_args(
|
||||
const Args&... args) {
|
||||
return {args...};
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Constructs an `~fmt::format_arg_store` object that contains references to
|
||||
arguments and can be implicitly converted to `~fmt::wprintf_args`.
|
||||
\endrst
|
||||
*/
|
||||
template <typename... Args>
|
||||
inline format_arg_store<wprintf_context, Args...> make_wprintf_args(
|
||||
const Args&... args) {
|
||||
return {args...};
|
||||
}
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
inline std::basic_string<Char> vsprintf(
|
||||
const S& format,
|
||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
vprintf(buffer, to_string_view(format), args);
|
||||
return to_string(buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Formats arguments and returns the result as a string.
|
||||
|
||||
**Example**::
|
||||
|
||||
std::string message = fmt::sprintf("The answer is %d", 42);
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
inline std::basic_string<Char> sprintf(const S& format, const Args&... args) {
|
||||
using context = basic_printf_context_t<Char>;
|
||||
return vsprintf(to_string_view(format), make_format_args<context>(args...));
|
||||
}
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
inline int vfprintf(
|
||||
std::FILE* f, const S& format,
|
||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
vprintf(buffer, to_string_view(format), args);
|
||||
size_t size = buffer.size();
|
||||
return std::fwrite(buffer.data(), sizeof(Char), size, f) < size
|
||||
? -1
|
||||
: static_cast<int>(size);
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Prints formatted data to the file *f*.
|
||||
|
||||
**Example**::
|
||||
|
||||
fmt::fprintf(stderr, "Don't %s!", "panic");
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
typename Char = enable_if_t<detail::is_string<S>::value, char_t<S>>>
|
||||
inline int fprintf(std::FILE* f, const S& format, const Args&... args) {
|
||||
using context = basic_printf_context_t<Char>;
|
||||
return vfprintf(f, to_string_view(format),
|
||||
make_format_args<context>(args...));
|
||||
}
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
inline int vprintf(
|
||||
const S& format,
|
||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
||||
return vfprintf(stdout, to_string_view(format), args);
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Prints formatted data to ``stdout``.
|
||||
|
||||
**Example**::
|
||||
|
||||
fmt::printf("Elapsed time: %.2f seconds", 1.23);
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args,
|
||||
FMT_ENABLE_IF(detail::is_string<S>::value)>
|
||||
inline int printf(const S& format_str, const Args&... args) {
|
||||
using context = basic_printf_context_t<char_t<S>>;
|
||||
return vprintf(to_string_view(format_str),
|
||||
make_format_args<context>(args...));
|
||||
}
|
||||
|
||||
template <typename S, typename Char = char_t<S>>
|
||||
inline int vfprintf(
|
||||
std::basic_ostream<Char>& os, const S& format,
|
||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args) {
|
||||
basic_memory_buffer<Char> buffer;
|
||||
vprintf(buffer, to_string_view(format), args);
|
||||
detail::write_buffer(os, buffer);
|
||||
return static_cast<int>(buffer.size());
|
||||
}
|
||||
|
||||
/** Formats arguments and writes the output to the range. */
|
||||
template <typename ArgFormatter, typename Char,
|
||||
typename Context =
|
||||
basic_printf_context<typename ArgFormatter::iterator, Char>>
|
||||
typename ArgFormatter::iterator vprintf(
|
||||
detail::buffer<Char>& out, basic_string_view<Char> format_str,
|
||||
basic_format_args<type_identity_t<Context>> args) {
|
||||
typename ArgFormatter::iterator iter(out);
|
||||
Context(iter, format_str, args).template format<ArgFormatter>();
|
||||
return iter;
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Prints formatted data to the stream *os*.
|
||||
|
||||
**Example**::
|
||||
|
||||
fmt::fprintf(cerr, "Don't %s!", "panic");
|
||||
\endrst
|
||||
*/
|
||||
template <typename S, typename... Args, typename Char = char_t<S>>
|
||||
inline int fprintf(std::basic_ostream<Char>& os, const S& format_str,
|
||||
const Args&... args) {
|
||||
using context = basic_printf_context_t<Char>;
|
||||
return vfprintf(os, to_string_view(format_str),
|
||||
make_format_args<context>(args...));
|
||||
}
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_PRINTF_H_
|
||||
386
external/fmtlib/include/fmt/ranges.h
vendored
386
external/fmtlib/include/fmt/ranges.h
vendored
@@ -1,386 +0,0 @@
|
||||
// Formatting library for C++ - experimental range support
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
//
|
||||
// Copyright (c) 2018 - present, Remotion (Igor Schulz)
|
||||
// All Rights Reserved
|
||||
// {fmt} support for ranges, containers and types tuple interface.
|
||||
|
||||
#ifndef FMT_RANGES_H_
|
||||
#define FMT_RANGES_H_
|
||||
|
||||
#include <initializer_list>
|
||||
#include <type_traits>
|
||||
|
||||
#include "format.h"
|
||||
|
||||
// output only up to N items from the range.
|
||||
#ifndef FMT_RANGE_OUTPUT_LENGTH_LIMIT
|
||||
# define FMT_RANGE_OUTPUT_LENGTH_LIMIT 256
|
||||
#endif
|
||||
|
||||
FMT_BEGIN_NAMESPACE
|
||||
|
||||
template <typename Char> struct formatting_base {
|
||||
template <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char, typename Enable = void>
|
||||
struct formatting_range : formatting_base<Char> {
|
||||
static FMT_CONSTEXPR_DECL const size_t range_length_limit =
|
||||
FMT_RANGE_OUTPUT_LENGTH_LIMIT; // output only up to N items from the
|
||||
// range.
|
||||
Char prefix;
|
||||
Char delimiter;
|
||||
Char postfix;
|
||||
formatting_range() : prefix('{'), delimiter(','), postfix('}') {}
|
||||
static FMT_CONSTEXPR_DECL const bool add_delimiter_spaces = true;
|
||||
static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false;
|
||||
};
|
||||
|
||||
template <typename Char, typename Enable = void>
|
||||
struct formatting_tuple : formatting_base<Char> {
|
||||
Char prefix;
|
||||
Char delimiter;
|
||||
Char postfix;
|
||||
formatting_tuple() : prefix('('), delimiter(','), postfix(')') {}
|
||||
static FMT_CONSTEXPR_DECL const bool add_delimiter_spaces = true;
|
||||
static FMT_CONSTEXPR_DECL const bool add_prepostfix_space = false;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename RangeT, typename OutputIterator>
|
||||
OutputIterator copy(const RangeT& range, OutputIterator out) {
|
||||
for (auto it = range.begin(), end = range.end(); it != end; ++it)
|
||||
*out++ = *it;
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
OutputIterator copy(const char* str, OutputIterator out) {
|
||||
while (*str) *out++ = *str++;
|
||||
return out;
|
||||
}
|
||||
|
||||
template <typename OutputIterator>
|
||||
OutputIterator copy(char ch, OutputIterator out) {
|
||||
*out++ = ch;
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Return true value if T has std::string interface, like std::string_view.
|
||||
template <typename T> class is_like_std_string {
|
||||
template <typename U>
|
||||
static auto check(U* p)
|
||||
-> decltype((void)p->find('a'), p->length(), (void)p->data(), int());
|
||||
template <typename> static void check(...);
|
||||
|
||||
public:
|
||||
static FMT_CONSTEXPR_DECL const bool value =
|
||||
is_string<T>::value || !std::is_void<decltype(check<T>(nullptr))>::value;
|
||||
};
|
||||
|
||||
template <typename Char>
|
||||
struct is_like_std_string<fmt::basic_string_view<Char>> : std::true_type {};
|
||||
|
||||
template <typename... Ts> struct conditional_helper {};
|
||||
|
||||
template <typename T, typename _ = void> struct is_range_ : std::false_type {};
|
||||
|
||||
#if !FMT_MSC_VER || FMT_MSC_VER > 1800
|
||||
template <typename T>
|
||||
struct is_range_<
|
||||
T, conditional_t<false,
|
||||
conditional_helper<decltype(std::declval<T>().begin()),
|
||||
decltype(std::declval<T>().end())>,
|
||||
void>> : std::true_type {};
|
||||
#endif
|
||||
|
||||
/// tuple_size and tuple_element check.
|
||||
template <typename T> class is_tuple_like_ {
|
||||
template <typename U>
|
||||
static auto check(U* p) -> decltype(std::tuple_size<U>::value, int());
|
||||
template <typename> static void check(...);
|
||||
|
||||
public:
|
||||
static FMT_CONSTEXPR_DECL const bool value =
|
||||
!std::is_void<decltype(check<T>(nullptr))>::value;
|
||||
};
|
||||
|
||||
// Check for integer_sequence
|
||||
#if defined(__cpp_lib_integer_sequence) || FMT_MSC_VER >= 1900
|
||||
template <typename T, T... N>
|
||||
using integer_sequence = std::integer_sequence<T, N...>;
|
||||
template <size_t... N> using index_sequence = std::index_sequence<N...>;
|
||||
template <size_t N> using make_index_sequence = std::make_index_sequence<N>;
|
||||
#else
|
||||
template <typename T, T... N> struct integer_sequence {
|
||||
using value_type = T;
|
||||
|
||||
static FMT_CONSTEXPR size_t size() { return sizeof...(N); }
|
||||
};
|
||||
|
||||
template <size_t... N> using index_sequence = integer_sequence<size_t, N...>;
|
||||
|
||||
template <typename T, size_t N, T... Ns>
|
||||
struct make_integer_sequence : make_integer_sequence<T, N - 1, N - 1, Ns...> {};
|
||||
template <typename T, T... Ns>
|
||||
struct make_integer_sequence<T, 0, Ns...> : integer_sequence<T, Ns...> {};
|
||||
|
||||
template <size_t N>
|
||||
using make_index_sequence = make_integer_sequence<size_t, N>;
|
||||
#endif
|
||||
|
||||
template <class Tuple, class F, size_t... Is>
|
||||
void for_each(index_sequence<Is...>, Tuple&& tup, F&& f) FMT_NOEXCEPT {
|
||||
using std::get;
|
||||
// using free function get<I>(T) now.
|
||||
const int _[] = {0, ((void)f(get<Is>(tup)), 0)...};
|
||||
(void)_; // blocks warnings
|
||||
}
|
||||
|
||||
template <class T>
|
||||
FMT_CONSTEXPR make_index_sequence<std::tuple_size<T>::value> get_indexes(
|
||||
T const&) {
|
||||
return {};
|
||||
}
|
||||
|
||||
template <class Tuple, class F> void for_each(Tuple&& tup, F&& f) {
|
||||
const auto indexes = get_indexes(tup);
|
||||
for_each(indexes, std::forward<Tuple>(tup), std::forward<F>(f));
|
||||
}
|
||||
|
||||
template <typename Arg, FMT_ENABLE_IF(!is_like_std_string<
|
||||
typename std::decay<Arg>::type>::value)>
|
||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&) {
|
||||
return add_space ? " {}" : "{}";
|
||||
}
|
||||
|
||||
template <typename Arg, FMT_ENABLE_IF(is_like_std_string<
|
||||
typename std::decay<Arg>::type>::value)>
|
||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const Arg&) {
|
||||
return add_space ? " \"{}\"" : "\"{}\"";
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const char*) {
|
||||
return add_space ? " \"{}\"" : "\"{}\"";
|
||||
}
|
||||
FMT_CONSTEXPR const wchar_t* format_str_quoted(bool add_space, const wchar_t*) {
|
||||
return add_space ? L" \"{}\"" : L"\"{}\"";
|
||||
}
|
||||
|
||||
FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const char) {
|
||||
return add_space ? " '{}'" : "'{}'";
|
||||
}
|
||||
FMT_CONSTEXPR const wchar_t* format_str_quoted(bool add_space, const wchar_t) {
|
||||
return add_space ? L" '{}'" : L"'{}'";
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename T> struct is_tuple_like {
|
||||
static FMT_CONSTEXPR_DECL const bool value =
|
||||
detail::is_tuple_like_<T>::value && !detail::is_range_<T>::value;
|
||||
};
|
||||
|
||||
template <typename TupleT, typename Char>
|
||||
struct formatter<TupleT, Char, enable_if_t<fmt::is_tuple_like<TupleT>::value>> {
|
||||
private:
|
||||
// C++11 generic lambda for format()
|
||||
template <typename FormatContext> struct format_each {
|
||||
template <typename T> void operator()(const T& v) {
|
||||
if (i > 0) {
|
||||
if (formatting.add_prepostfix_space) {
|
||||
*out++ = ' ';
|
||||
}
|
||||
out = detail::copy(formatting.delimiter, out);
|
||||
}
|
||||
out = format_to(out,
|
||||
detail::format_str_quoted(
|
||||
(formatting.add_delimiter_spaces && i > 0), v),
|
||||
v);
|
||||
++i;
|
||||
}
|
||||
|
||||
formatting_tuple<Char>& formatting;
|
||||
size_t& i;
|
||||
typename std::add_lvalue_reference<decltype(
|
||||
std::declval<FormatContext>().out())>::type out;
|
||||
};
|
||||
|
||||
public:
|
||||
formatting_tuple<Char> formatting;
|
||||
|
||||
template <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
return formatting.parse(ctx);
|
||||
}
|
||||
|
||||
template <typename FormatContext = format_context>
|
||||
auto format(const TupleT& values, FormatContext& ctx) -> decltype(ctx.out()) {
|
||||
auto out = ctx.out();
|
||||
size_t i = 0;
|
||||
detail::copy(formatting.prefix, out);
|
||||
|
||||
detail::for_each(values, format_each<FormatContext>{formatting, i, out});
|
||||
if (formatting.add_prepostfix_space) {
|
||||
*out++ = ' ';
|
||||
}
|
||||
detail::copy(formatting.postfix, out);
|
||||
|
||||
return ctx.out();
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Char> struct is_range {
|
||||
static FMT_CONSTEXPR_DECL const bool value =
|
||||
detail::is_range_<T>::value && !detail::is_like_std_string<T>::value &&
|
||||
!std::is_convertible<T, std::basic_string<Char>>::value &&
|
||||
!std::is_constructible<detail::std_string_view<Char>, T>::value;
|
||||
};
|
||||
|
||||
template <typename RangeT, typename Char>
|
||||
struct formatter<RangeT, Char,
|
||||
enable_if_t<fmt::is_range<RangeT, Char>::value>> {
|
||||
formatting_range<Char> formatting;
|
||||
|
||||
template <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
return formatting.parse(ctx);
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
typename FormatContext::iterator format(const RangeT& values,
|
||||
FormatContext& ctx) {
|
||||
auto out = detail::copy(formatting.prefix, ctx.out());
|
||||
size_t i = 0;
|
||||
auto it = values.begin();
|
||||
auto end = values.end();
|
||||
for (; it != end; ++it) {
|
||||
if (i > 0) {
|
||||
if (formatting.add_prepostfix_space) *out++ = ' ';
|
||||
out = detail::copy(formatting.delimiter, out);
|
||||
}
|
||||
out = format_to(out,
|
||||
detail::format_str_quoted(
|
||||
(formatting.add_delimiter_spaces && i > 0), *it),
|
||||
*it);
|
||||
if (++i > formatting.range_length_limit) {
|
||||
out = format_to(out, " ... <other elements>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (formatting.add_prepostfix_space) *out++ = ' ';
|
||||
return detail::copy(formatting.postfix, out);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Char, typename... T> struct tuple_arg_join : detail::view {
|
||||
const std::tuple<T...>& tuple;
|
||||
basic_string_view<Char> sep;
|
||||
|
||||
tuple_arg_join(const std::tuple<T...>& t, basic_string_view<Char> s)
|
||||
: tuple{t}, sep{s} {}
|
||||
};
|
||||
|
||||
template <typename Char, typename... T>
|
||||
struct formatter<tuple_arg_join<Char, T...>, Char> {
|
||||
template <typename ParseContext>
|
||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
typename FormatContext::iterator format(
|
||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx) {
|
||||
return format(value, ctx, detail::make_index_sequence<sizeof...(T)>{});
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename FormatContext, size_t... N>
|
||||
typename FormatContext::iterator format(
|
||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx,
|
||||
detail::index_sequence<N...>) {
|
||||
return format_args(value, ctx, std::get<N>(value.tuple)...);
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
typename FormatContext::iterator format_args(
|
||||
const tuple_arg_join<Char, T...>&, FormatContext& ctx) {
|
||||
// NOTE: for compilers that support C++17, this empty function instantiation
|
||||
// can be replaced with a constexpr branch in the variadic overload.
|
||||
return ctx.out();
|
||||
}
|
||||
|
||||
template <typename FormatContext, typename Arg, typename... Args>
|
||||
typename FormatContext::iterator format_args(
|
||||
const tuple_arg_join<Char, T...>& value, FormatContext& ctx,
|
||||
const Arg& arg, const Args&... args) {
|
||||
using base = formatter<typename std::decay<Arg>::type, Char>;
|
||||
auto out = ctx.out();
|
||||
out = base{}.format(arg, ctx);
|
||||
if (sizeof...(Args) > 0) {
|
||||
out = std::copy(value.sep.begin(), value.sep.end(), out);
|
||||
ctx.advance_to(out);
|
||||
return format_args(value, ctx, args...);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
\rst
|
||||
Returns an object that formats `tuple` with elements separated by `sep`.
|
||||
|
||||
**Example**::
|
||||
|
||||
std::tuple<int, char> t = {1, 'a'};
|
||||
fmt::print("{}", fmt::join(t, ", "));
|
||||
// Output: "1, a"
|
||||
\endrst
|
||||
*/
|
||||
template <typename... T>
|
||||
FMT_CONSTEXPR tuple_arg_join<char, T...> join(const std::tuple<T...>& tuple,
|
||||
string_view sep) {
|
||||
return {tuple, sep};
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
FMT_CONSTEXPR tuple_arg_join<wchar_t, T...> join(const std::tuple<T...>& tuple,
|
||||
wstring_view sep) {
|
||||
return {tuple, sep};
|
||||
}
|
||||
|
||||
/**
|
||||
\rst
|
||||
Returns an object that formats `initializer_list` with elements separated by
|
||||
`sep`.
|
||||
|
||||
**Example**::
|
||||
|
||||
fmt::print("{}", fmt::join({1, 2, 3}, ", "));
|
||||
// Output: "1, 2, 3"
|
||||
\endrst
|
||||
*/
|
||||
template <typename T>
|
||||
arg_join<const T*, const T*, char> join(std::initializer_list<T> list,
|
||||
string_view sep) {
|
||||
return join(std::begin(list), std::end(list), sep);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
arg_join<const T*, const T*, wchar_t> join(std::initializer_list<T> list,
|
||||
wstring_view sep) {
|
||||
return join(std::begin(list), std::end(list), sep);
|
||||
}
|
||||
|
||||
FMT_END_NAMESPACE
|
||||
|
||||
#endif // FMT_RANGES_H_
|
||||
@@ -3,7 +3,7 @@
|
||||
declare -A configurations
|
||||
|
||||
declare -A EXTRA_MODULE_FLAGS
|
||||
EXTRA_MODULE_FLAGS[opm-simulators]="-DBUILD_EBOS_EXTENSIONS=ON -DBUILD_EBOS_DEBUG_EXTENSIONS=ON -DBUILD_FLOW_VARIANTS=ON -DOPM_ENABLE_PYTHON=ON -DBUILD_FLOW_POLY_GRID=ON"
|
||||
EXTRA_MODULE_FLAGS[opm-simulators]="-DBUILD_EBOS_EXTENSIONS=ON -DBUILD_EBOS_DEBUG_EXTENSIONS=ON -DBUILD_FLOW_VARIANTS=ON -DOPM_ENABLE_PYTHON=ON"
|
||||
EXTRA_MODULE_FLAGS[opm-common]="-DOPM_ENABLE_PYTHON=ON -DOPM_ENABLE_EMBEDDED_PYTHON=ON -DOPM_INSTALL_PYTHON=ON"
|
||||
|
||||
# Parse revisions from trigger comment and setup arrays
|
||||
@@ -222,12 +222,8 @@ function build_downstreams {
|
||||
|
||||
# $1 = Name of main module
|
||||
function build_module_full {
|
||||
PY_MAJOR=`python3 --version | awk -F ' ' '{print $2}' | awk -F '.' '{print $1}'`
|
||||
PY_MINOR=`python3 --version | awk -F ' ' '{print $2}' | awk -F '.' '{print $2}'`
|
||||
for configuration in ${!configurations[@]}
|
||||
do
|
||||
export PYTHONPATH="$WORKSPACE/$configuration/install/lib/python$PY_MAJOR.$PY_MINOR/dist-packages"
|
||||
|
||||
# Build upstream modules
|
||||
build_upstreams
|
||||
|
||||
|
||||
@@ -14,9 +14,6 @@ then
|
||||
if ! test -d $WORKSPACE/deps/opm-tests
|
||||
then
|
||||
cp $OPM_TESTS_ROOT_PREDEFINED $WORKSPACE/deps/opm-tests -R
|
||||
pushd $WORKSPACE/deps/opm-tests
|
||||
echo "opm-tests revision: `git rev-parse HEAD`"
|
||||
popd
|
||||
fi
|
||||
else
|
||||
# We need a full repo checkout
|
||||
@@ -32,9 +29,6 @@ else
|
||||
if ! test -d $WORKSPACE/deps/opm-tests
|
||||
then
|
||||
cp $OPM_TESTS_ROOT $WORKSPACE/deps/opm-tests -R
|
||||
pushd $WORKSPACE/deps/opm-tests
|
||||
echo "opmt-tests-revision: `git rev-parse HEAD`"
|
||||
popd
|
||||
fi
|
||||
fi
|
||||
OPM_TESTS_ROOT=$WORKSPACE/deps/opm-tests
|
||||
|
||||
@@ -37,14 +37,14 @@ do
|
||||
prnumber=${rev//[!0-9]/}
|
||||
BRANCH_NAME="${BRANCH_NAME}_${repo}_$prnumber"
|
||||
test -n "$REASON" && REASON+=" "
|
||||
REASON+="PR https://github.com/OPM/$repo/pull/$prnumber\n"
|
||||
REASON+="https://github.com/OPM/$repo/pull/$prnumber\n"
|
||||
fi
|
||||
done
|
||||
|
||||
# Do the commit
|
||||
export REASON
|
||||
export BRANCH_NAME
|
||||
$WORKSPACE/deps/opm-simulators/tests/update_reference_data.sh $OPM_TESTS_ROOT $WORKSPACE/$configuration/build-opm-simulators $WORKSPACE/$configuration/install/bin/convertECL
|
||||
$WORKSPACE/deps/opm-simulators/tests/update_reference_data.sh $OPM_TESTS_ROOT
|
||||
if test $? -eq 5
|
||||
then
|
||||
echo "No tests failed - no data to update. Exiting"
|
||||
@@ -90,7 +90,7 @@ fi
|
||||
|
||||
if [ -n "$DATA_PR" ]
|
||||
then
|
||||
curl -d "{ \"body\": \"Existing PR https://github.com/OPM/opm-tests/pull/$DATA_PR was updated\" }" -H "Authorization: token ${GH_TOKEN}" -X POST https://api.github.com/repos/OPM/$MAIN_REPO/issues/$PRNUMBER/comments
|
||||
curl -d "{ \"body\": \"Existing PR https://github.com/OPM/opm-tests/pull/$DATA_PR was updated\" }" -X POST https://api.github.com/repos/OPM/$MAIN_REPO/issues/$PRNUMBER/comments?access_token=$GH_TOKEN
|
||||
else
|
||||
git-open-pull -u jenkins4opm --base-account OPM --base-repo opm-tests -r /tmp/cmsg $BRANCH_NAME
|
||||
fi
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#ifndef ISIM_MAIN_HPP
|
||||
#define ISIM_MAIN_HPP
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
@@ -15,8 +14,6 @@
|
||||
|
||||
#include <opm/output/data/Solution.hpp>
|
||||
#include <opm/output/data/Wells.hpp>
|
||||
#include <opm/output/data/Groups.hpp>
|
||||
#include <opm/parser/eclipse/Deck/UDAValue.hpp>
|
||||
|
||||
|
||||
namespace Opm {
|
||||
@@ -26,13 +23,6 @@ class ParseContext;
|
||||
class Parser;
|
||||
class Python;
|
||||
class SummaryState;
|
||||
class UDQState;
|
||||
class WellTestState;
|
||||
|
||||
namespace Action {
|
||||
class State;
|
||||
}
|
||||
|
||||
class msim {
|
||||
|
||||
public:
|
||||
@@ -41,18 +31,16 @@ public:
|
||||
|
||||
msim(const EclipseState& state);
|
||||
|
||||
Opm::UDAValue uda_val();
|
||||
|
||||
void well_rate(const std::string& well, data::Rates::opt rate, std::function<well_rate_function> func);
|
||||
void solution(const std::string& field, std::function<solution_function> func);
|
||||
void run(Schedule& schedule, EclipseIO& io, bool report_only);
|
||||
void post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, const time_point& sim_time);
|
||||
void post_step(Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step);
|
||||
private:
|
||||
|
||||
void run_step(const Schedule& schedule, Action::State& action_state, WellTestState& wtest_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, EclipseIO& io) const;
|
||||
void run_step(const Schedule& schedule, Action::State& action_state, WellTestState& wtest_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io) const;
|
||||
void output(Action::State& action_state, WellTestState& wtest_state, SummaryState& st, const UDQState& udq_state, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupAndNetworkValues& group_data, EclipseIO& io) const;
|
||||
void simulate(const Schedule& schedule, WellTestState& wtest_state, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double seconds_elapsed, double time_step) const;
|
||||
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const;
|
||||
void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const;
|
||||
void output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const;
|
||||
void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const;
|
||||
|
||||
EclipseState state;
|
||||
std::map<std::string, std::map<data::Rates::opt, std::function<well_rate_function>>> well_rates;
|
||||
|
||||
@@ -18,9 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
#include <opm/output/eclipse/Inplace.hpp>
|
||||
#include <opm/output/eclipse/EclipseIO.hpp>
|
||||
#include <opm/output/eclipse/RestartValue.hpp>
|
||||
#include <opm/output/eclipse/Summary.hpp>
|
||||
@@ -31,10 +29,6 @@
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
|
||||
#include <opm/parser/eclipse/Parser/ErrorGuard.hpp>
|
||||
@@ -49,46 +43,38 @@ msim::msim(const EclipseState& state_arg) :
|
||||
void msim::run(Schedule& schedule, EclipseIO& io, bool report_only) {
|
||||
const double week = 7 * 86400;
|
||||
data::Solution sol;
|
||||
SummaryState st(TimeService::from_time_t(schedule.getStartTime()));
|
||||
UDQState udq_state(schedule.getUDQConfig(0).params().undefinedValue());
|
||||
WellTestState wtest_state;
|
||||
Action::State action_state;
|
||||
SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime()));
|
||||
Python python;
|
||||
|
||||
io.writeInitial();
|
||||
for (size_t report_step = 1; report_step < schedule.size(); report_step++) {
|
||||
data::Wells well_data;
|
||||
data::GroupAndNetworkValues group_nwrk_data;
|
||||
if (report_only)
|
||||
run_step(schedule, action_state, wtest_state, st, udq_state, sol, well_data, group_nwrk_data, report_step, io);
|
||||
run_step(schedule, st, sol, well_data, report_step, io);
|
||||
else {
|
||||
double time_step = std::min(week, 0.5*schedule.stepLength(report_step - 1));
|
||||
run_step(schedule, action_state, wtest_state, st, udq_state, sol, well_data, group_nwrk_data, report_step, time_step, io);
|
||||
run_step(schedule, st, sol, well_data, report_step, time_step, io);
|
||||
}
|
||||
auto sim_time = TimeService::from_time_t( schedule.simTime(report_step) );
|
||||
post_step(schedule, action_state, st, sol, well_data, group_nwrk_data, report_step, sim_time);
|
||||
post_step(schedule, st, sol, well_data, report_step);
|
||||
const auto& exit_status = schedule.exitStatus();
|
||||
if (exit_status.has_value())
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UDAValue msim::uda_val() {
|
||||
return UDAValue();
|
||||
}
|
||||
|
||||
|
||||
void msim::post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, data::GroupAndNetworkValues& /* grp_nwrk_data */, size_t report_step, const time_point& sim_time) {
|
||||
const auto& actions = schedule[report_step].actions.get();
|
||||
void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, size_t report_step) {
|
||||
const auto& actions = schedule.actions(report_step);
|
||||
if (actions.empty())
|
||||
return;
|
||||
|
||||
Action::Context context( st , schedule[report_step].wlist_manager.get());
|
||||
Action::Context context( st );
|
||||
|
||||
for (const auto& action : actions.pending(action_state, std::chrono::system_clock::to_time_t(sim_time))) {
|
||||
auto result = action->eval(context);
|
||||
auto sim_time = schedule.simTime(report_step);
|
||||
for (const auto& action : actions.pending(sim_time)) {
|
||||
auto result = action->eval(sim_time, context);
|
||||
if (result)
|
||||
schedule.applyAction(report_step, sim_time, *action, result, {});
|
||||
schedule.applyAction(report_step, *action, result);
|
||||
}
|
||||
|
||||
for (const auto& pyaction : actions.pending_python())
|
||||
@@ -97,12 +83,12 @@ void msim::post_step(Schedule& schedule, Action::State& action_state, SummarySta
|
||||
|
||||
|
||||
|
||||
void msim::run_step(const Schedule& schedule, Action::State& action_state, WellTestState& wtest_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& grp_nwrk_data, size_t report_step, EclipseIO& io) const {
|
||||
this->run_step(schedule, action_state, wtest_state, st, udq_state, sol, well_data, grp_nwrk_data, report_step, schedule.stepLength(report_step - 1), io);
|
||||
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const {
|
||||
this->run_step(schedule, st, sol, well_data, report_step, schedule.stepLength(report_step - 1), io);
|
||||
}
|
||||
|
||||
|
||||
void msim::run_step(const Schedule& schedule, Action::State& action_state, WellTestState& wtest_state, SummaryState& st, UDQState& udq_state, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& group_nwrk_data, size_t report_step, double dt, EclipseIO& io) const {
|
||||
void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const {
|
||||
double start_time = schedule.seconds(report_step - 1);
|
||||
double end_time = schedule.seconds(report_step);
|
||||
double seconds_elapsed = start_time;
|
||||
@@ -112,52 +98,44 @@ void msim::run_step(const Schedule& schedule, Action::State& action_state, WellT
|
||||
if ((seconds_elapsed + time_step) > end_time)
|
||||
time_step = end_time - seconds_elapsed;
|
||||
|
||||
this->simulate(schedule, wtest_state, st, sol, well_data, group_nwrk_data, report_step, seconds_elapsed, time_step);
|
||||
this->simulate(schedule, st, sol, well_data, report_step, seconds_elapsed, time_step);
|
||||
|
||||
Opm::data::Group group_data;
|
||||
|
||||
seconds_elapsed += time_step;
|
||||
|
||||
io.summary().eval(st,
|
||||
report_step,
|
||||
seconds_elapsed,
|
||||
this->state,
|
||||
schedule,
|
||||
well_data,
|
||||
group_nwrk_data,
|
||||
{},
|
||||
{},
|
||||
{},
|
||||
group_data,
|
||||
{});
|
||||
|
||||
schedule.getUDQConfig( report_step ).eval(report_step, schedule.wellMatcher(report_step), st, udq_state);
|
||||
|
||||
this->output(action_state,
|
||||
wtest_state,
|
||||
st,
|
||||
udq_state,
|
||||
this->output(st,
|
||||
report_step,
|
||||
(seconds_elapsed < end_time),
|
||||
seconds_elapsed,
|
||||
sol,
|
||||
well_data,
|
||||
group_nwrk_data,
|
||||
io);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void msim::output(Action::State& action_state, WellTestState& wtest_state, SummaryState& st, const UDQState& udq_state, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupAndNetworkValues& group_nwrk_data, EclipseIO& io) const {
|
||||
RestartValue value(sol, well_data, group_nwrk_data, {});
|
||||
io.writeTimeStep(action_state,
|
||||
wtest_state,
|
||||
st,
|
||||
udq_state,
|
||||
void msim::output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const {
|
||||
RestartValue value(sol, well_data);
|
||||
io.writeTimeStep(st,
|
||||
report_step,
|
||||
substep,
|
||||
seconds_elapsed,
|
||||
std::move(value));
|
||||
value);
|
||||
}
|
||||
|
||||
|
||||
void msim::simulate(const Schedule& schedule, WellTestState&, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupAndNetworkValues& /* group_nwrk_data */, size_t report_step, double seconds_elapsed, double time_step) const {
|
||||
void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const {
|
||||
for (const auto& sol_pair : this->solutions) {
|
||||
auto func = sol_pair.second;
|
||||
func(this->state, schedule, sol, report_step, seconds_elapsed + time_step);
|
||||
@@ -166,17 +144,15 @@ void msim::simulate(const Schedule& schedule, WellTestState&, const SummaryState
|
||||
for (const auto& well_pair : this->well_rates) {
|
||||
const std::string& well_name = well_pair.first;
|
||||
const auto& sched_well = schedule.getWell(well_name, report_step);
|
||||
bool well_open = (sched_well.getStatus() == Well::Status::OPEN);
|
||||
if (sched_well.getStatus() != Well::Status::OPEN)
|
||||
continue;
|
||||
|
||||
data::Well& well = well_data[well_name];
|
||||
for (const auto& rate_pair : well_pair.second) {
|
||||
auto rate = rate_pair.first;
|
||||
auto func = rate_pair.second;
|
||||
|
||||
if (well_open)
|
||||
well.rates.set(rate, func(this->state, schedule, st, sol, report_step, seconds_elapsed + time_step));
|
||||
else
|
||||
well.rates.set(rate, 0.0);
|
||||
well.rates.set(rate, func(this->state, schedule, st, sol, report_step, seconds_elapsed + time_step));
|
||||
}
|
||||
|
||||
// This is complete bogus; a temporary fix to pass an assert() in the
|
||||
|
||||
@@ -16,10 +16,6 @@ list(APPEND opm-common_DEPS
|
||||
# various runtime library enhancements
|
||||
"Boost 1.44.0 COMPONENTS system unit_test_framework REQUIRED"
|
||||
"OpenMP QUIET"
|
||||
"cjson"
|
||||
# Still it produces compile errors complaining that it
|
||||
# cannot format UDQVarType. Hence we use the same version
|
||||
# as the embedded one.
|
||||
"fmt 7.0.3"
|
||||
)
|
||||
|
||||
find_package_deps(opm-common)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
do { \
|
||||
std::ostringstream oss__; \
|
||||
oss__ << "[" << __FILE__ << ":" << __LINE__ << "] " << message; \
|
||||
::Opm::OpmLog::error(oss__.str()); \
|
||||
Opm::OpmLog::error(oss__.str()); \
|
||||
throw Exception(oss__.str()); \
|
||||
} while (false)
|
||||
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INFO_LOGGER_HPP
|
||||
#define INFO_LOGGER_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
/*
|
||||
A small utility class to use in the situation where the first N messages
|
||||
should go to OpmLog::info() and then the subsequent messages should go to
|
||||
OpmLog::note()
|
||||
*/
|
||||
|
||||
class InfoLogger {
|
||||
public:
|
||||
InfoLogger(const std::string& context_arg, std::size_t info_limit);
|
||||
void operator()(const std::string& msg);
|
||||
private:
|
||||
std::string context;
|
||||
std::size_t info_limit;
|
||||
std::size_t info_count=0;
|
||||
void (*log_function)(const std::string&);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -17,62 +17,39 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEYWORD_LOCATION_HPP
|
||||
#define KEYWORD_LOCATION_HPP
|
||||
|
||||
#include <string>
|
||||
#ifndef LOCATION_HPP
|
||||
#define LOCATION_HPP
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class KeywordLocation {
|
||||
class Location {
|
||||
public:
|
||||
/*
|
||||
Observe that many error messages whcih should print out the name of the
|
||||
problem keyword along with the location {} placeholders can be used. The
|
||||
convention is:
|
||||
|
||||
{keyword} -> keyword
|
||||
{file} -> filename
|
||||
{line} -> lineno
|
||||
|
||||
This convention must be adhered to at the call site *creating the output
|
||||
string*.
|
||||
*/
|
||||
|
||||
std::string keyword;
|
||||
std::string filename = "<memory string>";
|
||||
std::size_t lineno = 0;
|
||||
|
||||
KeywordLocation() = default;
|
||||
KeywordLocation(std::string kw, std::string fname, std::size_t lno) :
|
||||
keyword(std::move(kw)),
|
||||
Location() = default;
|
||||
Location(std::string fname, std::size_t lno) :
|
||||
filename(std::move(fname)),
|
||||
lineno(lno)
|
||||
{}
|
||||
|
||||
|
||||
std::string format(const std::string& msg_fmt) const;
|
||||
|
||||
static KeywordLocation serializeObject()
|
||||
static Location serializeObject()
|
||||
{
|
||||
KeywordLocation result;
|
||||
result.keyword = "KW";
|
||||
Location result;
|
||||
result.filename = "test";
|
||||
result.lineno = 1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool operator==(const KeywordLocation& data) const {
|
||||
return keyword == data.keyword &&
|
||||
filename == data.filename &&
|
||||
bool operator==(const Location& data) const {
|
||||
return filename == data.filename &&
|
||||
lineno == data.lineno;
|
||||
}
|
||||
|
||||
template<class Serializer>
|
||||
void serializeOp(Serializer& serializer)
|
||||
{
|
||||
serializer(keyword);
|
||||
serializer(filename);
|
||||
serializer(lineno);
|
||||
}
|
||||
@@ -23,9 +23,9 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace Opm {
|
||||
#include <opm/common/OpmLog/Location.hpp>
|
||||
|
||||
class KeywordLocation;
|
||||
namespace Opm {
|
||||
|
||||
namespace Log {
|
||||
namespace MessageType {
|
||||
@@ -59,8 +59,8 @@ namespace Log {
|
||||
|
||||
|
||||
bool isPower2(int64_t x);
|
||||
std::string fileMessage(const KeywordLocation& location, const std::string& msg);
|
||||
std::string fileMessage(int64_t messageType , const KeywordLocation& location , const std::string& msg);
|
||||
std::string fileMessage(const Location& location, const std::string& msg);
|
||||
std::string fileMessage(int64_t messageType , const Location& location , const std::string& msg);
|
||||
std::string prefixMessage(int64_t messageType , const std::string& msg);
|
||||
std::string colorCodeMessage(int64_t messageType , const std::string& msg);
|
||||
|
||||
|
||||
@@ -88,8 +88,6 @@ public:
|
||||
}
|
||||
|
||||
|
||||
static bool stdoutIsTerminal();
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Logger> getLogger();
|
||||
static std::shared_ptr<Logger> m_logger;
|
||||
|
||||
191
opm/common/data/SimulationDataContainer.hpp
Normal file
191
opm/common/data/SimulationDataContainer.hpp
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
Copyright 2016 Statoil ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SIMULATION_DATA_CONTAINER_HPP
|
||||
#define SIMULATION_DATA_CONTAINER_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
/// The SimulationDataContainer is a simple container to manage
|
||||
/// simulation data. The container is instantiated with information
|
||||
/// of how many cells, faces and phases are present in the
|
||||
/// reservoirmodel. You can then add data to the container by using the
|
||||
///
|
||||
/// registerCellData()
|
||||
/// registerFaceData()
|
||||
///
|
||||
/// functions. The container owns and manages the data, but
|
||||
/// mutable references are returned with the getCellData() and
|
||||
/// getFaceData() methods, and the content will typically be
|
||||
/// modified by external scope.
|
||||
class SimulationDataContainer
|
||||
{
|
||||
public:
|
||||
/// Main constructor setting the sizes for the contained data
|
||||
/// types.
|
||||
/// \param num_cells number of elements in cell data vectors
|
||||
/// \param num_faces number of elements in face data vectors
|
||||
/// \param num_phases number of phases, the number of components
|
||||
/// in any data vector must equal 1 or this
|
||||
/// number (this behaviour and argument is deprecated).
|
||||
SimulationDataContainer(size_t num_cells, size_t num_faces, size_t num_phases);
|
||||
|
||||
/// Copy constructor.
|
||||
/// Must be defined explicitly because class contains non-value objects
|
||||
/// (the reference pointers pressure_ref_ etc.) that should not simply
|
||||
/// be copied.
|
||||
SimulationDataContainer(const SimulationDataContainer&);
|
||||
|
||||
/// Copy assignment operator.
|
||||
/// Must be defined explicitly because class contains non-value objects
|
||||
/// (the reference pointers pressure_ref_ etc.) that should not simply
|
||||
/// be copied.
|
||||
SimulationDataContainer& operator=(const SimulationDataContainer&);
|
||||
|
||||
/// Efficient O(1) swap.
|
||||
void swap(SimulationDataContainer& other);
|
||||
|
||||
size_t numPhases() const;
|
||||
size_t numFaces() const;
|
||||
size_t numCells() const;
|
||||
|
||||
bool hasCellData( const std::string& name ) const;
|
||||
|
||||
/// Will register a data vector of size numCells() *
|
||||
/// components.
|
||||
void registerCellData( const std::string& name , size_t components , double initialValue = 0.0 );
|
||||
std::vector<double>& getCellData( const std::string& name );
|
||||
const std::vector<double>& getCellData( const std::string& name ) const;
|
||||
|
||||
bool hasFaceData( const std::string& name ) const;
|
||||
void registerFaceData( const std::string& name , size_t components , double initialValue = 0.0 );
|
||||
std::vector<double>& getFaceData( const std::string& name );
|
||||
const std::vector<double>& getFaceData( const std::string& name ) const;
|
||||
|
||||
/// Will return the number of components of the celldata with
|
||||
/// name @name:
|
||||
///
|
||||
/// numCellDataComponents( "PRESSURE" ) -> 1
|
||||
/// numCellDataComponents( "SATURATION" ) -> 3
|
||||
///
|
||||
/// for a three phase model.
|
||||
size_t numCellDataComponents( const std::string& name ) const;
|
||||
bool equal(const SimulationDataContainer& other) const;
|
||||
|
||||
|
||||
/// Will set the values of component nr @component in the
|
||||
/// field @key. All the cells in @cells will be set to the
|
||||
/// values in @values.
|
||||
void setCellDataComponent( const std::string& key , size_t component , const std::vector<int>& cells , const std::vector<double>& values);
|
||||
|
||||
// Direct explicit field access for certain default fields.
|
||||
// These methods are all deprecated, and will eventually be moved to
|
||||
// concrete subclasses.
|
||||
|
||||
std::vector<double>& pressure ();
|
||||
std::vector<double>& temperature ();
|
||||
std::vector<double>& saturation ();
|
||||
|
||||
std::vector<double>& facepressure();
|
||||
std::vector<double>& faceflux ();
|
||||
|
||||
const std::vector<double>& pressure () const;
|
||||
const std::vector<double>& temperature () const;
|
||||
const std::vector<double>& saturation () const;
|
||||
|
||||
const std::vector<double>& facepressure() const;
|
||||
const std::vector<double>& faceflux () const;
|
||||
|
||||
const std::map<std::string, std::vector<double>>& cellData() const;
|
||||
std::map<std::string, std::vector<double>>& cellData();
|
||||
|
||||
private:
|
||||
void addDefaultFields();
|
||||
void setReferencePointers();
|
||||
|
||||
size_t m_num_cells;
|
||||
size_t m_num_faces;
|
||||
size_t m_num_phases;
|
||||
|
||||
std::map< std::string , std::vector<double> > m_cell_data;
|
||||
std::map< std::string , std::vector<double> > m_face_data;
|
||||
|
||||
std::vector<double>* pressure_ref_;
|
||||
std::vector<double>* temperature_ref_;
|
||||
std::vector<double>* saturation_ref_;
|
||||
std::vector<double>* facepressure_ref_;
|
||||
std::vector<double>* faceflux_ref_;
|
||||
};
|
||||
|
||||
|
||||
// Inline implementations of the direct accessors required to guarantee
|
||||
// performance.
|
||||
|
||||
|
||||
inline std::vector<double>& SimulationDataContainer::pressure( ) {
|
||||
return *pressure_ref_;
|
||||
}
|
||||
|
||||
inline std::vector<double>& SimulationDataContainer::temperature() {
|
||||
return *temperature_ref_;
|
||||
}
|
||||
|
||||
inline std::vector<double>& SimulationDataContainer::saturation() {
|
||||
return *saturation_ref_;
|
||||
}
|
||||
|
||||
inline std::vector<double>& SimulationDataContainer::facepressure() {
|
||||
return *facepressure_ref_;
|
||||
}
|
||||
|
||||
inline std::vector<double>& SimulationDataContainer::faceflux() {
|
||||
return *faceflux_ref_;
|
||||
}
|
||||
|
||||
inline const std::vector<double>& SimulationDataContainer::pressure( ) const {
|
||||
return *pressure_ref_;
|
||||
}
|
||||
|
||||
inline const std::vector<double>& SimulationDataContainer::temperature() const {
|
||||
return *temperature_ref_;
|
||||
}
|
||||
|
||||
inline const std::vector<double>& SimulationDataContainer::saturation() const {
|
||||
return *saturation_ref_;
|
||||
}
|
||||
|
||||
inline const std::vector<double>& SimulationDataContainer::facepressure() const {
|
||||
return *facepressure_ref_;
|
||||
}
|
||||
|
||||
inline const std::vector<double>& SimulationDataContainer::faceflux() const {
|
||||
return *faceflux_ref_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -20,7 +20,7 @@
|
||||
#define OPM_FILESYSTEM_HPP
|
||||
|
||||
#if __cplusplus < 201703L || \
|
||||
(defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
|
||||
(defined(__GNUC__) && __GNUC__ < 8)
|
||||
#include <experimental/filesystem>
|
||||
#else
|
||||
#include <filesystem>
|
||||
@@ -32,13 +32,10 @@
|
||||
namespace Opm
|
||||
{
|
||||
#if __cplusplus < 201703L || \
|
||||
(defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__))
|
||||
(defined(__GNUC__) && __GNUC__ < 8)
|
||||
namespace filesystem = std::experimental::filesystem;
|
||||
filesystem::path proximate(const filesystem::path& p,
|
||||
const filesystem::path& base = filesystem::current_path());
|
||||
#else
|
||||
namespace filesystem = std::filesystem;
|
||||
using filesystem::proximate;
|
||||
#endif
|
||||
|
||||
// A poor man's filesystem::unique_path
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 Equinor ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef OPM_ERROR_HPP
|
||||
#define OPM_ERROR_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <opm/common/OpmLog/KeywordLocation.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
/*
|
||||
The OpmInputError is a custom exception class which can be used to signal
|
||||
errors in input handling. The importance of the OpmInputError exception is
|
||||
*not* the tecnical functionality it provides, but rather the convention
|
||||
surrounding it, when and how it should be used.
|
||||
|
||||
The OpmInputError should be used in situations which are "close to user
|
||||
input", the root cause can either be incorrect user input or a bug/limitation
|
||||
in opm. OpmInputError should only be used in situations where we have a good
|
||||
understanding of the underlying issue, and can provide a good error message.
|
||||
|
||||
The local error handling should be complete when the OpmInputError is
|
||||
instantiated, it should not be caught and rethrown in order to e.g. add
|
||||
additional context or log messages. In order to avoid inadvertendly catching
|
||||
this exception in a catch all block.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class OpmInputError : public std::exception {
|
||||
public:
|
||||
/*
|
||||
The message string will be used as format string in the fmt::format()
|
||||
function as, and optional {} markers can be used to inject keyword,
|
||||
filename and linenumber into the final what() message. The placeholders
|
||||
must use named arguments
|
||||
|
||||
{keyword} -> loc.keyword
|
||||
{file} -> loc.filename
|
||||
{line} -> loc.lineno
|
||||
|
||||
additionally, the message can contain any number of positional
|
||||
arguments to add further context to the message.
|
||||
|
||||
KeywordLocation loc("KW", "file.inc", 100);
|
||||
OpmInputError("Error at line {line} in file {file} - keyword: {keyword} ignored", location);
|
||||
OpmInputError("Error at line {line} in file {file} - keyword: {keyword} has invalid argument {}", invalid_argument);
|
||||
*/
|
||||
|
||||
template<typename ... Args>
|
||||
OpmInputError(const std::string& reason, const KeywordLocation& location, const Args& ...furtherLocations)
|
||||
: locations { location, furtherLocations... }
|
||||
, m_what {
|
||||
locations.size() == 1
|
||||
? formatSingle(reason, locations[0])
|
||||
: formatMultiple(reason, locations)
|
||||
}
|
||||
{ }
|
||||
|
||||
/*
|
||||
Allows for the initialisation of an OpmInputError from another exception.
|
||||
|
||||
Usage:
|
||||
|
||||
try {
|
||||
.
|
||||
.
|
||||
.
|
||||
} catch (const Opm::OpmInputError&) {
|
||||
throw;
|
||||
} catch (const std::exception& e) {
|
||||
std::throw_with_nested(Opm::OpmInputError(e, location));
|
||||
}
|
||||
*/
|
||||
OpmInputError(const std::exception& error, const KeywordLocation& location)
|
||||
: locations { location }
|
||||
, m_what { formatException(error, locations[0]) }
|
||||
{ }
|
||||
|
||||
const char * what() const throw()
|
||||
{
|
||||
return this->m_what.c_str();
|
||||
}
|
||||
|
||||
|
||||
static std::string format(const std::string& msg_format, const KeywordLocation& loc);
|
||||
|
||||
private:
|
||||
// The location member is here for debugging; depending on the msg_fmt
|
||||
// passed in the constructor we might not have captured all the information
|
||||
// in the location argument passed to the constructor.
|
||||
std::vector<KeywordLocation> locations;
|
||||
|
||||
std::string m_what;
|
||||
|
||||
static std::string formatException(const std::exception& e, const KeywordLocation& loc);
|
||||
static std::string formatSingle(const std::string& reason, const KeywordLocation&);
|
||||
static std::string formatMultiple(const std::string& reason, const std::vector<KeywordLocation>&);
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 Equinor ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_SERIALIZER_HPP
|
||||
#define OPM_SERIALIZER_HPP
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm {
|
||||
/*
|
||||
This is a very basic serialization class used to support serialization of
|
||||
small state objects from opm common. The main serialization code used in
|
||||
opm/flow is initiated and controlled from the restart code, and therefor
|
||||
slightly cumbersome to use for objects which should be serialized not as part
|
||||
of the restart code.
|
||||
*/
|
||||
|
||||
|
||||
class Serializer {
|
||||
public:
|
||||
Serializer() = default;
|
||||
explicit Serializer(const std::vector<char>& buffer_arg) :
|
||||
buffer(buffer_arg)
|
||||
{}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void put(const T& value) {
|
||||
this->pack(std::addressof(value), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void put(const T* ) {
|
||||
throw std::logic_error("Serializer can not pack pointers");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T get() {
|
||||
T value;
|
||||
std::memcpy(&value, &this->buffer[this->read_pos], sizeof(T));
|
||||
this->read_pos += sizeof(T);
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void put_vector(const std::vector<T>& values) {
|
||||
this->put(values.size());
|
||||
this->pack(values.data(), values.size() * sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> get_vector() {
|
||||
std::size_t size = this->get<std::size_t>();
|
||||
std::vector<T> values(size);
|
||||
for (std::size_t index=0; index < size; index++)
|
||||
values[index] = this->get<T>();
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
void put_map(const std::unordered_map<K,T>& values) {
|
||||
this->put(values.size());
|
||||
for (const auto& value_pair : values) {
|
||||
this->put(value_pair.first);
|
||||
this->put(value_pair.second);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
std::unordered_map<K,T> get_map() {
|
||||
std::unordered_map<K,T> values;
|
||||
auto size = this->get<std::size_t>();
|
||||
for (std::size_t index = 0; index < size; index++) {
|
||||
auto key = this->get<K>();
|
||||
auto value = this->get<T>();
|
||||
values.insert( std::make_pair(key,value) );
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
std::vector<char> buffer;
|
||||
private:
|
||||
void pack(const void * ptr, std::size_t value_size) {
|
||||
std::size_t write_pos = this->buffer.size();
|
||||
std::size_t new_size = write_pos + value_size;
|
||||
this->buffer.resize( new_size );
|
||||
std::memcpy(&this->buffer[write_pos], ptr, value_size);
|
||||
}
|
||||
|
||||
std::size_t read_pos = 0;
|
||||
};
|
||||
|
||||
template <>
|
||||
void inline Serializer::put(const std::string& value) {
|
||||
this->put(value.size());
|
||||
if (value.empty())
|
||||
return;
|
||||
|
||||
this->pack(value.c_str(), value.size());
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string inline Serializer::get<std::string>() {
|
||||
std::string::size_type length = this->get<std::string::size_type>();
|
||||
if (length == 0)
|
||||
return std::string{};
|
||||
|
||||
this->read_pos += length;
|
||||
return {std::addressof(this->buffer[this->read_pos - length]), length};
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -107,25 +103,6 @@ inline std::vector<std::string> split_string(const std::string& input,
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string format_double(double d) {
|
||||
double integral_part;
|
||||
const double decimal_part = std::modf(d, &integral_part);
|
||||
|
||||
if (decimal_part == 0)
|
||||
return std::to_string(static_cast<int>(d));
|
||||
else
|
||||
return std::to_string(d);
|
||||
}
|
||||
|
||||
|
||||
inline std::optional<double> try_parse_double(const std::string& token) {
|
||||
char * end_ptr;
|
||||
auto value = std::strtod(token.c_str(), &end_ptr);
|
||||
if (std::strlen(end_ptr) == 0)
|
||||
return value;
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
}
|
||||
#endif //OPM_UTILITY_STRING_HPP
|
||||
|
||||
@@ -22,32 +22,9 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
|
||||
|
||||
namespace Opm {
|
||||
|
||||
using time_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::duration<int64_t, std::ratio<1,1000>>>;
|
||||
|
||||
namespace TimeService {
|
||||
std::time_t to_time_t(const time_point& tp);
|
||||
time_point from_time_t(std::time_t t);
|
||||
time_point now();
|
||||
|
||||
std::time_t advance(const std::time_t tp, const double sec);
|
||||
std::time_t makeUTCTime(std::tm timePoint);
|
||||
const std::unordered_map<std::string , int>& eclipseMonthIndices();
|
||||
const std::unordered_map<int, std::string>& eclipseMonthNames();
|
||||
int eclipseMonth(const std::string& name);
|
||||
bool valid_month(const std::string& month_name);
|
||||
|
||||
std::time_t mkdatetime(int in_year, int in_month, int in_day, int hour, int minute, int second);
|
||||
std::time_t mkdate(int in_year, int in_month, int in_day);
|
||||
std::time_t timeFromEclipse(const DeckRecord &dateRecord);
|
||||
}
|
||||
|
||||
class TimeStampUTC
|
||||
{
|
||||
public:
|
||||
@@ -122,8 +99,6 @@ namespace Opm {
|
||||
TimeStampUTC operator+(const TimeStampUTC& lhs, std::chrono::duration<double> delta);
|
||||
std::time_t asTimeT(const TimeStampUTC& tp);
|
||||
std::time_t asLocalTimeT(const TimeStampUTC& tp);
|
||||
time_point asTimePoint(const TimeStampUTC& tp);
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@
|
||||
#define OPM_ROOTFINDERS_HEADER
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
@@ -37,18 +35,15 @@ namespace Opm
|
||||
{
|
||||
static double handleBracketingFailure(const double x0, const double x1, const double f0, const double f1)
|
||||
{
|
||||
std::ostringstream sstr;
|
||||
sstr << "Error in parameters, zero not bracketed: [a, b] = ["
|
||||
<< x0 << ", " << x1 << "] f(a) = " << f0 << " f(b) = " << f1;
|
||||
OpmLog::debug(sstr.str());
|
||||
OPM_THROW_NOLOG(std::runtime_error, sstr.str());
|
||||
OPM_THROW(std::runtime_error, "Error in parameters, zero not bracketed: [a, b] = ["
|
||||
<< x0 << ", " << x1 << "] f(a) = " << f0 << " f(b) = " << f1);
|
||||
return -1e100; // Never reached.
|
||||
}
|
||||
static double handleTooManyIterations(const double x0, const double x1, const int maxiter)
|
||||
{
|
||||
OPM_THROW(std::runtime_error, "Maximum number of iterations exceeded: " << maxiter << "\n"
|
||||
<< "Current interval is [" << std::min(x0, x1) << ", "
|
||||
<< std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1));
|
||||
<< std::max(x0, x1) << "]");
|
||||
return -1e100; // Never reached.
|
||||
}
|
||||
};
|
||||
@@ -69,7 +64,7 @@ namespace Opm
|
||||
OPM_REPORT;
|
||||
std::cerr << "Maximum number of iterations exceeded: " << maxiter
|
||||
<< ", current interval is [" << std::min(x0, x1) << ", "
|
||||
<< std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1);
|
||||
<< std::max(x0, x1) << "]";
|
||||
return 0.5*(x0 + x1);
|
||||
}
|
||||
};
|
||||
@@ -129,7 +124,7 @@ namespace Opm
|
||||
iterations_used = 0;
|
||||
// In every iteraton, x1 is the last point computed,
|
||||
// and x0 is the last point computed that makes it a bracket.
|
||||
while (fabs(x1 - x0) >= eps) {
|
||||
while (fabs(x1 - x0) >= 1e-9*eps) {
|
||||
double xnew = regulaFalsiStep(x0, x1, f0, f1);
|
||||
double fnew = f(xnew);
|
||||
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
|
||||
@@ -226,7 +221,7 @@ namespace Opm
|
||||
iterations_used = 0;
|
||||
// In every iteraton, x1 is the last point computed,
|
||||
// and x0 is the last point computed that makes it a bracket.
|
||||
while (fabs(x1 - x0) >= eps) {
|
||||
while (fabs(x1 - x0) >= 1e-9*eps) {
|
||||
double xnew = regulaFalsiStep(x0, x1, f0, f1);
|
||||
double fnew = f(xnew);
|
||||
// cout << "xnew = " << xnew << " fnew = " << fnew << endl;
|
||||
@@ -332,7 +327,7 @@ namespace Opm
|
||||
// and x0 is the last point computed that makes it a bracket.
|
||||
double width = fabs(x1 - x0);
|
||||
double contraction = 1.0;
|
||||
while (width >= eps) {
|
||||
while (width >= 1e-9 * eps) {
|
||||
// If we are contracting sufficiently to at least halve
|
||||
// the interval width in two iterations we use regula
|
||||
// falsi. Otherwise, we take a bisection step to avoid
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Created: Mon Jun 29 15:28:59 2009
|
||||
//
|
||||
// Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
// Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
//
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
#include <array>
|
||||
#include <math.h>
|
||||
|
||||
#ifndef CALCULATE_CELLVOL
|
||||
#define CALCULATE_CELLVOL
|
||||
|
||||
double calculateCellVol(const std::array<double,8>& X, const std::array<double,8>& Y, const std::array<double,8>& Z);
|
||||
double calculateCylindricalCellVol(const double R1, const double R2, const double dTheta, const double dZ);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created: Tue Jun 2 16:00:21 2009
|
||||
//
|
||||
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Author(s): B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created: Tue Jun 2 19:11:11 2009
|
||||
//
|
||||
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Author(s): B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created: Tue Jun 2 19:06:46 2009
|
||||
//
|
||||
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Author(s): B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
@@ -142,7 +142,7 @@ namespace Opm {
|
||||
assignments.push_back(std::make_pair(name, value));
|
||||
continue;
|
||||
}
|
||||
OpmLog::warning("Too many assignments (' "
|
||||
OpmLog::warning("Too many assignements (' "
|
||||
+ ID_delimiter_assignment
|
||||
+ "') detected in argument " + to_string(i));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created: Tue Jun 2 19:05:54 2009
|
||||
//
|
||||
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Author(s): B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created: Tue Jun 2 19:05:02 2009
|
||||
//
|
||||
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Author(s): B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created: Tue Jun 2 19:04:15 2009
|
||||
//
|
||||
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Author(s): B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//
|
||||
// Created: Tue Jun 2 19:02:19 2009
|
||||
//
|
||||
// Author(s): Bård Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Author(s): B<EFBFBD>rd Skaflestad <bard.skaflestad@sintef.no>
|
||||
// Atgeirr F Rasmussen <atgeirr@sintef.no>
|
||||
//
|
||||
// $Date$
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#define OPM_IO_EGRID_HPP
|
||||
|
||||
#include <opm/io/eclipse/EclFile.hpp>
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
@@ -35,7 +34,7 @@ namespace Opm { namespace EclIO {
|
||||
class EGrid : public EclFile
|
||||
{
|
||||
public:
|
||||
explicit EGrid(const std::string& filename, std::string grid_name = "global");
|
||||
explicit EGrid(const std::string& filename);
|
||||
|
||||
int global_index(int i, int j, int k) const;
|
||||
int active_index(int i, int j, int k) const;
|
||||
@@ -45,69 +44,20 @@ public:
|
||||
std::array<int, 3> ijk_from_active_index(int actInd) const;
|
||||
std::array<int, 3> ijk_from_global_index(int globInd) const;
|
||||
|
||||
void getCellCorners(int globindex, std::array<double,8>& X, std::array<double,8>& Y, std::array<double,8>& Z);
|
||||
void getCellCorners(const std::array<int, 3>& ijk, std::array<double,8>& X, std::array<double,8>& Y, std::array<double,8>& Z);
|
||||
|
||||
std::vector<std::array<float, 3>> getXYZ_layer(int layer, bool bottom=false);
|
||||
std::vector<std::array<float, 3>> getXYZ_layer(int layer, const std::array<int, 4>& box, bool bottom=false);
|
||||
void getCellCorners(int globindex, std::array<double,8>& X, std::array<double,8>& Y, std::array<double,8>& Z) const;
|
||||
void getCellCorners(const std::array<int, 3>& ijk, std::array<double,8>& X, std::array<double,8>& Y, std::array<double,8>& Z) const;
|
||||
|
||||
int activeCells() const { return nactive; }
|
||||
int totalNumberOfCells() const { return nijk[0] * nijk[1] * nijk[2]; }
|
||||
|
||||
void load_grid_data();
|
||||
void load_nnc_data();
|
||||
bool is_radial() const { return m_radial; }
|
||||
|
||||
const std::vector<int>& hostCellsGlobalIndex() const { return host_cells; }
|
||||
std::vector<std::array<int, 3>> hostCellsIJK();
|
||||
|
||||
// zero based: i1, j1,k1, i2,j2,k2, transmisibility
|
||||
using NNCentry = std::tuple<int, int, int, int, int, int, float>;
|
||||
std::vector<NNCentry> get_nnc_ijk();
|
||||
|
||||
const std::vector<std::string>& list_of_lgrs() const { return lgr_names; }
|
||||
|
||||
const std::vector<float>& get_mapaxes() const { return m_mapaxes; }
|
||||
const std::string& get_mapunits() const { return m_mapunits; }
|
||||
|
||||
private:
|
||||
Opm::filesystem::path inputFileName, initFileName;
|
||||
std::string m_grid_name;
|
||||
bool m_radial;
|
||||
|
||||
std::vector<float> m_mapaxes;
|
||||
std::string m_mapunits;
|
||||
|
||||
std::array<int, 3> nijk;
|
||||
std::array<int, 3> host_nijk;
|
||||
|
||||
int nactive;
|
||||
mutable bool m_nncs_loaded;
|
||||
|
||||
std::vector<int> act_index;
|
||||
std::vector<int> glob_index;
|
||||
|
||||
std::vector<float> coord_array;
|
||||
std::vector<float> zcorn_array;
|
||||
|
||||
std::vector<int> nnc1_array;
|
||||
std::vector<int> nnc2_array;
|
||||
std::vector<float> transnnc_array;
|
||||
std::vector<int> host_cells;
|
||||
|
||||
std::vector<std::string> lgr_names;
|
||||
|
||||
int zcorn_array_index;
|
||||
int coord_array_index;
|
||||
int actnum_array_index;
|
||||
int nnc1_array_index;
|
||||
int nnc2_array_index;
|
||||
|
||||
std::vector<float> get_zcorn_from_disk(int layer, bool bottom);
|
||||
|
||||
void getCellCorners(const std::array<int, 3>& ijk, const std::vector<float>& zcorn_layer,
|
||||
std::array<double,4>& X, std::array<double,4>& Y, std::array<double,4>& Z);
|
||||
|
||||
};
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 Equinor ASA.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_IO_EINIT_HPP
|
||||
#define OPM_IO_EINIT_HPP
|
||||
|
||||
#include <opm/io/eclipse/EclFile.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace Opm { namespace EclIO {
|
||||
|
||||
class EInit : public EclFile
|
||||
{
|
||||
public:
|
||||
explicit EInit(const std::string& filename);
|
||||
|
||||
const std::vector<std::string>& list_of_lgrs() const { return lgr_names; }
|
||||
|
||||
std::vector<EclFile::EclEntry> list_arrays() const;
|
||||
std::vector<EclFile::EclEntry> list_arrays(const std::string& grid_name) const;
|
||||
|
||||
const std::array<int, 3>& grid_dimension(const std::string& grid_name = "global") const;
|
||||
int activeCells(const std::string& grid_name = "global") const;
|
||||
|
||||
bool hasLGR(const std::string& name) const;
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getInitData(const std::string& name, const std::string& grid_name = "global")
|
||||
{
|
||||
return this->ImplgetInitData<T>(name, grid_name);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& ImplgetInitData(const std::string& name, const std::string& grid_name = "global");
|
||||
|
||||
private:
|
||||
std::array<int, 3> global_nijk;
|
||||
std::vector<std::array<int, 3>> lgr_nijk;
|
||||
|
||||
int global_nactive;
|
||||
std::vector<int> lgr_nactive;
|
||||
|
||||
std::vector<std::string> lgr_names;
|
||||
|
||||
std::map<std::string,int> global_array_index;
|
||||
std::vector<std::map<std::string,int>> lgr_array_index;
|
||||
|
||||
int get_array_index(const std::string& name, const std::string& grid_name) const;
|
||||
int get_lgr_index(const std::string& grid_name) const;
|
||||
};
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
||||
#endif // OPM_IO_EINIT_HPP
|
||||
@@ -27,7 +27,6 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Opm { namespace EclIO { namespace OutputStream {
|
||||
class Restart;
|
||||
}}}
|
||||
@@ -38,64 +37,43 @@ class ERst : public EclFile
|
||||
{
|
||||
public:
|
||||
explicit ERst(const std::string& filename);
|
||||
|
||||
bool hasReportStepNumber(int number) const;
|
||||
bool hasLGR(const std::string& gridname, int reportStepNumber) const;
|
||||
|
||||
void loadReportStepNumber(int number);
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber)
|
||||
{
|
||||
return getRestartData<T>(name,reportStepNumber, 0);
|
||||
}
|
||||
const std::vector<T>& getRst(const std::string& name, int reportStepNumber, int occurrence);
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber, int occurrence);
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(int index, int reportStepNumber)
|
||||
{
|
||||
const std::vector<T>& getRst(int index, int reportStepNumber){
|
||||
auto indRange = this->getIndexRange(reportStepNumber);
|
||||
return this->get<T>(index + std::get<0>(indRange));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(const std::string& name, int reportStepNumber, const std::string& lgr_name);
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& getRestartData(int index, int reportStepNumber, const std::string& lgr_name);
|
||||
|
||||
int occurrence_count(const std::string& name, int reportStepNumber) const;
|
||||
int count(const std::string& name, int reportStepNumber) const;
|
||||
size_t numberOfReportSteps() const { return seqnum.size(); };
|
||||
|
||||
const std::vector<int>& listOfReportStepNumbers() const { return seqnum; }
|
||||
|
||||
|
||||
std::vector<EclEntry> listOfRstArrays(int reportStepNumber);
|
||||
std::vector<EclEntry> listOfRstArrays(int reportStepNumber, const std::string& lgr_name);
|
||||
|
||||
friend class OutputStream::Restart;
|
||||
|
||||
private:
|
||||
int nReports;
|
||||
std::vector<int> seqnum; // report step numbers, from SEQNUM array in restart file
|
||||
mutable std::unordered_map<int,bool> reportLoaded;
|
||||
std::unordered_map<int,bool> reportLoaded;
|
||||
std::map<int, std::pair<int,int>> arrIndexRange; // mapping report step number to array indeces (start and end)
|
||||
std::vector<std::vector<std::string>> lgr_names; // report step numbers, from SEQNUM array in restart file
|
||||
|
||||
void initUnified();
|
||||
void initSeparate(const int number);
|
||||
|
||||
int get_start_index_lgrname(int number, const std::string& lgr_name);
|
||||
|
||||
int getArrayIndex(const std::string& name, int seqnum, int occurrence);
|
||||
int getArrayIndex(const std::string& name, int number, const std::string& lgr_name);
|
||||
|
||||
std::tuple<int,int> getIndexRange(int reportStepNumber) const;
|
||||
int getArrayIndex(const std::string& name, int seqnum, int occurrence) const;
|
||||
std::tuple<int,int> getIndexRange(int reportStepNumber) const;
|
||||
|
||||
std::streampos
|
||||
restartStepWritePosition(const int seqnumValue) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
||||
@@ -28,14 +28,12 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <opm/common/utility/FileSystem.hpp>
|
||||
#include <opm/common/utility/TimeService.hpp>
|
||||
#include <opm/io/eclipse/SummaryNode.hpp>
|
||||
|
||||
namespace Opm { namespace EclIO {
|
||||
|
||||
using ArrSourceEntry = std::tuple<std::string, std::string, int, uint64_t>;
|
||||
using TimeStepEntry = std::tuple<int, int, uint64_t>;
|
||||
using RstEntry = std::tuple<std::string, int>;
|
||||
|
||||
class ESmry
|
||||
{
|
||||
@@ -50,18 +48,16 @@ public:
|
||||
|
||||
const std::vector<float>& get(const std::string& name) const;
|
||||
const std::vector<float>& get(const SummaryNode& node) const;
|
||||
std::vector<time_point> dates() const;
|
||||
std::vector<std::chrono::system_clock::time_point> dates() const;
|
||||
|
||||
std::vector<float> get_at_rstep(const std::string& name) const;
|
||||
std::vector<float> get_at_rstep(const SummaryNode& node) const;
|
||||
std::vector<time_point> dates_at_rstep() const;
|
||||
std::vector<std::chrono::system_clock::time_point> dates_at_rstep() const;
|
||||
|
||||
void LoadData(const std::vector<std::string>& vectList) const;
|
||||
void LoadData() const;
|
||||
|
||||
bool make_esmry_file();
|
||||
|
||||
time_point startdate() const { return startdat; }
|
||||
std::chrono::system_clock::time_point startdate() const { return startdat; }
|
||||
|
||||
const std::vector<std::string>& keywordList() const;
|
||||
std::vector<std::string> keywordList(const std::string& pattern) const;
|
||||
@@ -69,31 +65,24 @@ public:
|
||||
|
||||
int timestepIdxAtReportstepStart(const int reportStep) const;
|
||||
|
||||
size_t numberOfTimeSteps() const { return nTstep; }
|
||||
size_t numberOfTimeSteps() const { return timeStepList.size(); }
|
||||
|
||||
const std::string& get_unit(const std::string& name) const;
|
||||
const std::string& get_unit(const SummaryNode& node) const;
|
||||
|
||||
void write_rsm(std::ostream&) const;
|
||||
void write_rsm_file(std::optional<filesystem::path> = std::nullopt) const;
|
||||
|
||||
bool all_steps_available();
|
||||
void write_rsm_file(std::optional<Opm::filesystem::path> = std::nullopt) const;
|
||||
|
||||
private:
|
||||
|
||||
filesystem::path inputFileName;
|
||||
RstEntry restart_info;
|
||||
|
||||
Opm::filesystem::path inputFileName;
|
||||
int nI, nJ, nK, nSpecFiles;
|
||||
bool fromSingleRun;
|
||||
size_t nVect, nTstep;
|
||||
size_t nVect;
|
||||
|
||||
std::vector<bool> formattedFiles;
|
||||
std::vector<std::string> dataFileList;
|
||||
mutable std::vector<std::vector<float>> vectorData;
|
||||
mutable std::vector<bool> vectorLoaded;
|
||||
std::vector<TimeStepEntry> timeStepList;
|
||||
std::vector<TimeStepEntry> miniStepList;
|
||||
std::vector<std::map<int, int>> arrayPos;
|
||||
std::vector<std::string> keyword;
|
||||
std::map<std::string, int> keyword_index;
|
||||
@@ -102,26 +91,23 @@ private:
|
||||
std::vector<std::vector<std::string>> keywordListSpecFile;
|
||||
|
||||
std::vector<int> seqIndex;
|
||||
std::vector<int> mini_steps;
|
||||
|
||||
void ijk_from_global_index(int glob, int &i, int &j, int &k) const;
|
||||
|
||||
std::vector<SummaryNode> summaryNodes;
|
||||
std::unordered_map<std::string, std::string> kwunits;
|
||||
|
||||
time_point startdat;
|
||||
std::chrono::system_clock::time_point startdat;
|
||||
|
||||
std::vector<std::string> checkForMultipleResultFiles(const filesystem::path& rootN, bool formatted) const;
|
||||
std::vector<std::string> checkForMultipleResultFiles(const Opm::filesystem::path& rootN, bool formatted) const;
|
||||
|
||||
void getRstString(const std::vector<std::string>& restartArray,
|
||||
filesystem::path& pathRst,
|
||||
filesystem::path& rootN) const;
|
||||
Opm::filesystem::path& pathRst,
|
||||
Opm::filesystem::path& rootN) const;
|
||||
|
||||
void updatePathAndRootName(filesystem::path& dir, filesystem::path& rootN) const;
|
||||
void updatePathAndRootName(Opm::filesystem::path& dir, Opm::filesystem::path& rootN) const;
|
||||
|
||||
|
||||
std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num,
|
||||
const std::optional<Opm::EclIO::lgr_info> lgr_info) const;
|
||||
std::string makeKeyString(const std::string& keyword, const std::string& wgname, int num) const;
|
||||
|
||||
std::string unpackNumber(const SummaryNode&) const;
|
||||
std::string lookupKey(const SummaryNode&) const;
|
||||
@@ -143,10 +129,6 @@ private:
|
||||
|
||||
std::vector<std::tuple <std::string, uint64_t>> getListOfArrays(std::string filename, bool formatted);
|
||||
std::vector<int> makeKeywPosVector(int speInd) const;
|
||||
std::string read_string_from_disk(std::fstream& fileH, uint64_t size) const;
|
||||
|
||||
void read_ministeps_from_disk();
|
||||
int read_ministep_formatted(std::fstream& fileH);
|
||||
};
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
||||
@@ -19,10 +19,11 @@
|
||||
#ifndef OPM_IO_ECLFILE_HPP
|
||||
#define OPM_IO_ECLFILE_HPP
|
||||
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <opm/io/eclipse/EclIOdata.hpp>
|
||||
|
||||
#include <ios>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <tuple>
|
||||
@@ -34,13 +35,8 @@ namespace Opm { namespace EclIO {
|
||||
class EclFile
|
||||
{
|
||||
public:
|
||||
struct Formatted {
|
||||
bool value;
|
||||
};
|
||||
|
||||
explicit EclFile(const std::string& filename, bool preload = false);
|
||||
EclFile(const std::string& filename, Formatted fmt, bool preload = false);
|
||||
bool formattedInput() const { return formatted; }
|
||||
bool formattedInput() { return formatted; }
|
||||
|
||||
void loadData(); // load all data
|
||||
void loadData(const std::string& arrName); // load all arrays with array name equal to arrName
|
||||
@@ -59,8 +55,6 @@ public:
|
||||
using EclEntry = std::tuple<std::string, eclArrType, int64_t>;
|
||||
std::vector<EclEntry> getList() const;
|
||||
|
||||
const std::vector<int>& getElementSizeList() const { return array_element_size; }
|
||||
|
||||
template <typename T>
|
||||
const std::vector<T>& get(int arrIndex);
|
||||
|
||||
@@ -72,7 +66,6 @@ public:
|
||||
|
||||
const std::vector<std::string>& arrayNames() const { return array_name; }
|
||||
std::size_t size() const;
|
||||
bool is_ix() const;
|
||||
|
||||
protected:
|
||||
bool formatted;
|
||||
@@ -87,7 +80,6 @@ protected:
|
||||
std::vector<std::string> array_name;
|
||||
std::vector<eclArrType> array_type;
|
||||
std::vector<int64_t> array_size;
|
||||
std::vector<int> array_element_size;
|
||||
|
||||
std::vector<uint64_t> ifStreamPos;
|
||||
|
||||
@@ -96,7 +88,19 @@ protected:
|
||||
template<class T>
|
||||
const std::vector<T>& getImpl(int arrIndex, eclArrType type,
|
||||
const std::unordered_map<int, std::vector<T>>& array,
|
||||
const std::string& typeStr);
|
||||
const std::string& typeStr)
|
||||
{
|
||||
if (array_type[arrIndex] != type) {
|
||||
std::string message = "Array with index " + std::to_string(arrIndex) + " is not of type " + typeStr;
|
||||
OPM_THROW(std::runtime_error, message);
|
||||
}
|
||||
|
||||
if (!arrayLoaded[arrIndex]) {
|
||||
loadData(arrIndex);
|
||||
}
|
||||
|
||||
return array.at(arrIndex);
|
||||
}
|
||||
|
||||
std::streampos
|
||||
seekPosition(const std::vector<std::string>::size_type arrIndex) const;
|
||||
@@ -106,11 +110,7 @@ private:
|
||||
|
||||
void loadBinaryArray(std::fstream& fileH, std::size_t arrIndex);
|
||||
void loadFormattedArray(const std::string& fileStr, std::size_t arrIndex, int64_t fromPos);
|
||||
void load(bool preload);
|
||||
|
||||
std::vector<unsigned int> get_bin_logi_raw_values(int arrIndex) const;
|
||||
std::vector<std::string> get_fmt_real_raw_str_values(int arrIndex) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}} // namespace Opm::EclIO
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user