opm-core-2015.04.patch 9.53 KB
Newer Older
1
From b30c947ee7b40f6e58e6d03e682c92c535568366 Mon Sep 17 00:00:00 2001
2
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
3
Date: Tue, 4 Aug 2015 17:09:53 +0200
4
5
6
7
Subject: adapt opm-core such that it can be used by Dumux

---
 cmake/Modules/Findopm-parser.cmake     | 179 ++++++---------------------------
8
 cmake/Modules/opm-core-prereqs.cmake   |   2 +-
9
10
 cmake/Modules/opm-parser-prereqs.cmake |  20 ++++
 opm/core/linalg/call_umfpack.c         |  12 +--
11
 4 files changed, 59 insertions(+), 154 deletions(-)
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
 create mode 100644 cmake/Modules/opm-parser-prereqs.cmake

diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake
index f69a491..fe721a0 100644
--- a/cmake/Modules/Findopm-parser.cmake
+++ b/cmake/Modules/Findopm-parser.cmake
@@ -1,159 +1,44 @@
-# Find the OPM Eclipse input parser.
+# - Find OPM parser library
 #
-# Set the cache variable OPM_PARSER_ROOT to the install location of the
-# library, or OPM_ROOT to the parent directory of the build tree.
-#
-# If found, it sets these variables:
-#
-#       HAVE_OPM_PARSER              Defined if a test program compiled
-#       OPM_PARSER_INCLUDE_DIRS      Header file directories
-#       OPM_PARSER_LIBRARIES         Archives and shared objects
-
-include (FindPackageHandleStandardArgs)
-
-# variables to pass on to other packages
-if (FIND_QUIETLY)
-  set (OPM_PARSER_QUIET "QUIET")
-else ()
-  set (OPM_PARSER_QUIET "")
-endif ()
-
-# use lowercase versions of the variables if those are set
-if (opm-parser_ROOT)
-  set (OPM_PARSER_ROOT ${opm-parser_ROOT})
-endif ()
-if (opm_ROOT)
-  set (OPM_ROOT ${opm_ROOT})
-endif ()
-
-# inherit "suite" root if not specifically set for this library
-if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT)
-  set (OPM_PARSER_ROOT "${OPM_ROOT}/opm-parser")
-endif ()
-
-# Detect the build dir suffix or subdirectory
-string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1"  BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}")
-
-# if a root is specified, then don't search in system directories
-# or in relative directories to this one
-if (OPM_PARSER_ROOT)
-  set (_no_default_path "NO_DEFAULT_PATH")
-  set (_opm_parser_source "")
-  set (_opm_parser_build "")
-else ()
-  set (_no_default_path "")
-  set (_opm_parser_source
-    "${PROJECT_SOURCE_DIR}/../opm-parser")
-  set (_opm_parser_build
-    "${PROJECT_BINARY_DIR}/../opm-parser"
-    "${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}"
-    "${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}")
-endif ()
+# Defines the following variables:
+#   opm-parser_INCLUDE_DIRS    Directory of header files
+#   opm-parser_LIBRARIES       Directory of shared object files
+#   opm-parser_DEFINITIONS     Defines that must be set to compile
+#   opm-parser_CONFIG_VARS     List of defines that should be in config.h
+#   HAVE_OPM_CORE            Binary value to use in config.h
 
-# use this header as signature
-find_path (OPM_PARSER_INCLUDE_DIR
-  NAMES "opm/parser/eclipse/Parser/Parser.hpp"
-  HINTS "${OPM_PARSER_ROOT}"
-  PATHS ${_opm_parser_source}
-  PATH_SUFFIXES "include"
-  DOC "Path to OPM parser header files"
-  ${_no_default_path} )
+# Copyright (C) 2012 Uni Research AS
+# This code is licensed under The GNU General Public License v3.0
 
-# backup: if we didn't find any headers there, but a CMakeCache.txt,
-# then it is probably a build directory; read the CMake cache of
-# opm-parser to figure out where the source directory is
-if ((NOT OPM_PARSER_INCLUDE_DIR) AND
-        (OPM_PARSER_ROOT AND (EXISTS "${OPM_PARSER_ROOT}/CMakeCache.txt")))
-  set (_regex "^OPMParser_SOURCE_DIR:STATIC=\(.*\)$")
-  file (STRINGS
-        "${OPM_PARSER_ROOT}/CMakeCache.txt"
-        _cache_entry
-        REGEX "${_regex}")
-  string(REGEX REPLACE "${_regex}" "\\1"
-        OPM_PARSER_INCLUDE_DIR
-        "${_cache_entry}")
-  if (OPM_PARSER_INCLUDE_DIR)
-        set (OPM_PARSER_INCLUDE_DIR "${OPM_PARSER_INCLUDE_DIR}"
-          CACHE PATH "Path to OPM parser header files" FORCE)
-  endif ()
-endif ()
+# use the generic find routine
+include (opm-parser-prereqs)
+include (OpmPackage)
+find_opm_package (
+  # module name
+  "opm-parser"
 
-# find out the size of a pointer. this is required to only search for
-# libraries in the directories relevant for the architecture
-if (CMAKE_SIZEOF_VOID_P)
-  math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
-endif ()
+  # dependencies
+  "${opm-parser_DEPS}"
 
-# these libraries constitute the parser core
-find_library (OPM_PARSER_LIBRARY
-  NAMES "Parser"
-  HINTS "${OPM_PARSER_ROOT}"
-  PATHS ${_opm_parser_build}
-  PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
-                "opm/parser/eclipse"
-  DOC "Path to OPM parser library archive/shared object files"
-  ${_no_default_path} )
+  # header to search for
+  "opm/parser/eclipse/Parser/Parser.hpp"
 
-# find the OPM-parser wrapper library around cJSON
-find_library (OPM_JSON_LIBRARY
-  NAMES "opm-json"
-  HINTS "${OPM_PARSER_ROOT}"
-  PATHS ${_opm_parser_build}
-  PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
-                "opm/json"
-  DOC "Path to OPM JSON library archive/shared object files"
-  ${_no_default_path} )
+  # library to search for
+  "Parser;opm-json"
 
-# get the prerequisite ERT libraries
-if (NOT ERT_FOUND)
-  find_package(ERT ${OPM_PARSER_QUIET})
-endif ()
+  # defines to be added to compilations
+  "HAVE_OPM_PARSER"
 
-# get the prerequisite Boost libraries
-find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex ${OPM_PARSER_QUIET})
-
-if (ERT_FOUND AND Boost_FOUND AND
-    OPM_PARSER_LIBRARY AND OPM_JSON_LIBRARY AND OPM_PARSER_INCLUDE_DIR)
-  # setup list of all required libraries to link with opm-parser. notice that
-  # we use the plural form to get *all* the libraries needed by cjson
-  set (opm-parser_INCLUDE_DIRS
-    ${OPM_PARSER_INCLUDE_DIR}
-    ${Boost_INCLUDE_DIRS}
-    ${ERT_INCLUDE_DIRS})
-
-  set (opm-parser_LIBRARIES
-    ${OPM_PARSER_LIBRARY}
-    ${OPM_JSON_LIBRARY}
-    ${Boost_LIBRARIES}
-    ${ERT_LIBRARIES})
-
-  # see if we can compile a minimum example
-  # CMake logical test doesn't handle lists (sic)
-  include (CMakePushCheckState)
-  include (CheckCSourceCompiles)
-  cmake_push_check_state ()
-  set (CMAKE_REQUIRED_INCLUDES ${opm-parser_INCLUDE_DIRS})
-  set (CMAKE_REQUIRED_LIBRARIES ${opm-parser_LIBRARIES})
-
-  check_cxx_source_compiles (
-      "#include <cstdlib>
+  # test program
+"#include <cstdlib>
 #include <opm/parser/eclipse/Deck/Deck.hpp>
 
 int main (void) {
    return EXIT_SUCCESS;
-}" HAVE_OPM_PARSER)
-  cmake_pop_check_state ()
-endif()
-
-# if the test program didn't compile, but was required to do so, bail
-# out now and display an error; otherwise limp on
-set (OPM_PARSER_FIND_REQUIRED ${opm-parser_FIND_REQUIRED})
-find_package_handle_standard_args (opm-parser
-  DEFAULT_MSG
-  opm-parser_INCLUDE_DIRS opm-parser_LIBRARIES HAVE_OPM_PARSER
-    )
-
-set (opm-parser_CONFIG_VARS "HAVE_OPM_PARSER;HAVE_REGEX")
-set (opm-parser_FOUND ${OPM-PARSER_FOUND})
-
-mark_as_advanced(opm-parser_LIBRARIES opm-parser_INCLUDE_DIRS OPM-PARSER_FOUND)
+}
+"
+  # config variables
+  "${opm-parser_CONFIG_VAR}"
+  )
+include (UseDynamicBoost)
+#debug_find_vars ("opm-parser")
210
211
212
213
214
215
216
217
218
219
220
221
222
diff --git a/cmake/Modules/opm-core-prereqs.cmake b/cmake/Modules/opm-core-prereqs.cmake
index ec118c5..ed35dcb 100644
--- a/cmake/Modules/opm-core-prereqs.cmake
+++ b/cmake/Modules/opm-core-prereqs.cmake
@@ -18,7 +18,7 @@ set (opm-core_DEPS
 	"CXX11Features REQUIRED"
 	# various runtime library enhancements
 	"Boost 1.44.0
-		COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
+		COMPONENTS date_time filesystem system iostreams unit_test_framework regex REQUIRED"
 	# matrix library
 	"BLAS REQUIRED"
 	"LAPACK REQUIRED"
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
diff --git a/cmake/Modules/opm-parser-prereqs.cmake b/cmake/Modules/opm-parser-prereqs.cmake
new file mode 100644
index 0000000..309e12e
--- /dev/null
+++ b/cmake/Modules/opm-parser-prereqs.cmake
@@ -0,0 +1,20 @@
+# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
+# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
+
+# defines that must be present in config.h for our headers
+set (opm-parser_CONFIG_VAR
+	HAVE_REGEX
+	)
+
+# dependencies
+set (opm-parser_DEPS
+	# compile with C99 support if available
+	"C99"
+	# compile with C++0x/11 support if available
+	"CXX11Features REQUIRED"
+	# various runtime library enhancements
+	"Boost 1.44.0
+		COMPONENTS filesystem date_time system unit_test_framework regex REQUIRED"
+	# Ensembles-based Reservoir Tools (ERT)
+	"ERT REQUIRED"
+	)
diff --git a/opm/core/linalg/call_umfpack.c b/opm/core/linalg/call_umfpack.c
index 8290009..f673dbc 100644
--- a/opm/core/linalg/call_umfpack.c
+++ b/opm/core/linalg/call_umfpack.c
@@ -43,11 +43,11 @@
 #include <opm/core/linalg/call_umfpack.h>
 
 struct CSCMatrix {
-    UF_long  n;
-    UF_long  nnz;
+    long  n;
+    long  nnz;
 
-    UF_long *p;
-    UF_long *i;
+    long *p;
+    long *i;
     double  *x;
 };
 
@@ -69,7 +69,7 @@ csc_deallocate(struct CSCMatrix *csc)
 
 /* ---------------------------------------------------------------------- */
 static struct CSCMatrix *
-csc_allocate(UF_long n, UF_long nnz)
+csc_allocate(long n, long nnz)
 /* ---------------------------------------------------------------------- */
 {
     struct CSCMatrix *new;
@@ -102,7 +102,7 @@ csr_to_csc(const int        *ia,
            struct CSCMatrix *csc)
 /* ---------------------------------------------------------------------- */
 {
-    UF_long i, nz;
+    long i, nz;
 
     /* Clear garbage, prepare for counting */
     for (i = 0; i <= csc->n; i++) { csc->p[i] = 0; }
-- 
2.1.4