Merge branch 'master' into gravity-in-wells

This commit is contained in:
Bård Skaflestad
2012-10-24 22:43:25 +02:00
5 changed files with 106 additions and 15 deletions

66
m4/cxx0x_compiler.m4 Normal file
View File

@@ -0,0 +1,66 @@
# whether compiler accepts -std=c++11 or -std=c++0x
# can be disabled by --disable-gxx0xcheck
AC_DEFUN([GXX0X],[
save_CXX="$CXX"
# put this check first, so we get disable C++11 if C++0x is
AC_ARG_ENABLE(gxx0xcheck,
AC_HELP_STRING([--disable-gxx0xcheck],
[try flag -std=c++0x to enable C++0x features [[default=yes]]]),
[gxx0xcheck=$enableval],
[gxx0xcheck=yes])
AC_ARG_ENABLE(gxx11check,
AC_HELP_STRING([--disable-gxx11check],
[try flag -std=c++11 to enable C++11 features [[default=yes]]]),
[gxx11check=$enableval],
[gxx11check=yes])
# try flag -std=c++11
AC_CACHE_CHECK([whether $CXX accepts -std=c++11], dune_cv_gplusplus_accepts_cplusplus11, [
AC_REQUIRE([AC_PROG_CXX])
if test "x$GXX" = xyes && test "x$gxx11check" = xyes && test "x$gxx0xcheck" = xyes ; then
AC_LANG_PUSH([C++])
CXX="$CXX -std=c++11"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <iostream>
#include <array>
],)],
[dune_cv_gplusplus_accepts_cplusplus11=yes],
[dune_cv_gplusplus_accepts_cplusplus11=no])
AC_LANG_POP([C++])
else
dune_cv_gplusplus_accepts_cplusplus11=disabled
fi
])
if test "x$dune_cv_gplusplus_accepts_cplusplus11" == "xyes" ; then
CXX="$save_CXX -std=c++11"
CXXCPP="$CXXCPP -std=c++11"
else
CXX="$save_CXX"
# try flag -std=c++0x instead
AC_CACHE_CHECK([whether $CXX accepts -std=c++0x], dune_cv_gplusplus_accepts_cplusplus0x, [
AC_REQUIRE([AC_PROG_CXX])
if test "x$GXX" = xyes && test "x$gxx0xcheck" = xyes; then
AC_LANG_PUSH([C++])
CXX="$CXX -std=c++0x"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <iostream>
#include <array>
],)],
[dune_cv_gplusplus_accepts_cplusplus0x=yes],
[dune_cv_gplusplus_accepts_cplusplus0x=no])
AC_LANG_POP([C++])
else
dune_cv_gplusplus_accepts_cplusplus0x=disabled
fi
])
if test "x$dune_cv_gplusplus_accepts_cplusplus0x" == "xyes" ; then
CXX="$save_CXX -std=c++0x"
CXXCPP="$CXXCPP -std=c++0x"
else
CXX="$save_CXX"
fi
fi
])

17
m4/cxx0x_nullptr.m4 Normal file
View File

@@ -0,0 +1,17 @@
AC_DEFUN([NULLPTR_CHECK],[
AC_CACHE_CHECK([whether nullptr is supported], dune_cv_nullptr_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
char* ch = nullptr;
if(ch!=nullptr) { ; }
])],
[dune_cv_nullptr_support=yes],
[dune_cv_nullptr_support=no])
AC_LANG_POP
])
if test "x$dune_cv_nullptr_support" = xyes; then
AC_DEFINE(HAVE_NULLPTR, 1, [Define to 1 if nullptr is supported])
fi
])

14
m4/cxx0x_static_assert.m4 Normal file
View File

@@ -0,0 +1,14 @@
AC_DEFUN([STATIC_ASSERT_CHECK],[
AC_CACHE_CHECK([whether static_assert is supported], dune_cv_static_assert_support, [
AC_REQUIRE([AC_PROG_CXX])
AC_REQUIRE([GXX0X])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[static_assert(true,"MSG")])],
[dune_cv_static_assert_support=yes],
[dune_cv_static_assert_support=no])
AC_LANG_POP
])
if test "x$dune_cv_static_assert_support" = xyes; then
AC_DEFINE(HAVE_STATIC_ASSERT, 1, [Define to 1 if static_assert is supported])
fi
])

View File

@@ -5,6 +5,11 @@ dnl -*- autoconf -*-
AC_DEFUN([OPM_CORE_CHECKS],
[
# Language features
GXX0X
STATIC_ASSERT_CHECK
NULLPTR_CHECK
# Checks for libraries.
# Bring in numerics support (standard library component)

View File

@@ -762,27 +762,16 @@ namespace Opm
}
}
// macro to insert const_cast to get a round bug in GCC 4.6.3 where it
// suddenly believes that "this" is a const pointer, although we are not
// in a const method.
#if ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ == 6 ) && ( __GNUC_PATCHLEVEL__ == 3 )
#define CONST_CAST(T,v) const_cast<T>(v)
#else
#define CONST_CAST(T,v) v
#endif
std::pair<WellNode*, double> WellNode::getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
const std::vector<double>& well_surfacerates_phase,
ProductionSpecification::ControlMode mode)
{
const int np = phaseUsage().num_phases;
const int index = self_index_*np;
// note: CONST_CAST is just to work around a bug in GCC 4.6.3; it
// is not really needed, and should be a harmless no-op.
return std::make_pair<WellNode*, double>(CONST_CAST(WellNode*,this),
rateByMode(&well_reservoirrates_phase[index],
&well_surfacerates_phase[index],
mode));
return std::pair<WellNode*, double>(this,
rateByMode(&well_reservoirrates_phase[index],
&well_surfacerates_phase[index],
mode));
}
void WellNode::applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,