diff --git a/bin/installexternal.sh b/bin/installexternal.sh index c4aabda510fe0adf776d3bd76f6e2e0360b0b8b5..e1b2c2b22ecf50fdeebfbcfe3eb984b2040de780 100755 --- a/bin/installexternal.sh +++ b/bin/installexternal.sh @@ -65,7 +65,7 @@ installErt() if [ ! -e ert ]; then git clone -b release/2016.04 https://github.com/Ensembles/ert.git fi - + if test "$DOWNLOAD_ONLY" == "y"; then return fi @@ -80,13 +80,13 @@ installErt() cd $TOPDIR/ert mkdir build cd build - cmake ../devel + cmake ../devel make # show additional information echo "Ert has been built in directory ert/build." echo "Do not change this directory otherwise opm will not find ert!" - + cd $TOPDIR } @@ -113,6 +113,39 @@ installFoamGrid() fi } +installGLPK() +{ + cd $EXTDIR + rm -rf glpk* standalone + + if [ ! -e glpk-4.60.tar.gz ]; then + wget http://ftp.gnu.org/gnu/glpk/glpk-4.60.tar.gz + fi + + if test "$DOWNLOAD_ONLY" == "y"; then + return + fi + + if test "$CLEANUP" == "y"; then + rm -rf glpk + return + fi + + mkdir glpk + tar zxvf glpk-4.60.tar.gz --strip-components=1 -C glpk + cd glpk + + ./configure + make + + # show additional information + echo "In addition, it might be necessary to set manually" + echo "the glpk path in the CMAKE_FLAGS section of the .opts-file:" + echo " -DGLPK_ROOT=/path/to/glpk \\" + + cd $TOPDIR +} + installGStat() { cd $EXTDIR @@ -218,6 +251,39 @@ installMultidomainGrid() cd $TOPDIR } +installNLOPT() +{ + cd $EXTDIR + rm -rf nlopt* standalone + + if [ ! -e nlopt-2.4.2.tar.gz ]; then + wget http://ab-initio.mit.edu/nlopt/nlopt-2.4.2.tar.gz + fi + + if test "$DOWNLOAD_ONLY" == "y"; then + return + fi + + if test "$CLEANUP" == "y"; then + rm -rf nlopt + return + fi + + mkdir nlopt + tar zxvf nlopt-2.4.2.tar.gz --strip-components=1 -C nlopt + cd nlopt + + ./configure + make + + # show additional information + echo "In addition, it might be necessary to set manually" + echo "the nlopt path in the CMAKE_FLAGS section of the .opts-file:" + echo " -DNLOPT_ROOT=/path/to/nlopt \\" + + cd $TOPDIR +} + installOPM() { cd $TOPDIR @@ -246,7 +312,7 @@ installOPM() if [ ! -e opm-grid ]; then git clone -b release/2016.04 https://github.com/OPM/opm-grid fi - + if test "$DOWNLOAD_ONLY" == "y"; then return fi @@ -264,7 +330,7 @@ installOPM() echo "Applying patch for opm-parser" cd $TOPDIR/opm-parser patch -p1 < $TOPDIR/dumux/patches/opm-parser-2016.04.patch - + echo "Applying patch for opm-common" cd $TOPDIR/opm-common patch -p1 < $TOPDIR/dumux/patches/opm-common-2016.04.patch @@ -400,10 +466,12 @@ usage() echo " alugrid Download dune-alugrid." echo " ert Download and build ert." echo " foamgrid Download dune-foamgrid." + echo " glpk Download and install glpk." echo " gstat Download and install gstat." echo " metis Install the METIS graph partitioner." echo " multidomain Download dune-multidomain." echo " multidomaingrid Download and patch dune-multidomaingrid." + echo " nlopt Download and install nlopt." echo " opm Download opm modules required for dune-cornerpoint." echo " pdelab Download dune-pdelab." echo " typetree Download dune-typetree." @@ -443,8 +511,8 @@ for TMP in "$@"; do MPILIBS=$($MPICONFIG --libs) MPILIBDIR=$(echo $MPILIBS | sed "s/.*-L\([^[:blank:]]*\).*/\1/") - # consistency check - if test "$ENABLE_MPI" == "y" -a -z "$MPICXX"; then + # consistency check + if test "$ENABLE_MPI" == "y" -a -z "$MPICXX"; then echo "" echo "Compiler mpicxx not found although ENABLE_MPI is set in this script!" echo "Please make sure that your MPI environment is set up or that you turn it off." @@ -454,7 +522,7 @@ for TMP in "$@"; do echo "" exit -1 - fi + fi ;; "--clean") @@ -466,10 +534,12 @@ for TMP in "$@"; do installAluGrid installErt installFoamGrid + installGLPK installGStat installMETIS installMultidomain installMultidomainGrid + installNLOPT installOPM installPDELab installTypeTree @@ -487,6 +557,11 @@ for TMP in "$@"; do SOMETHING_DONE="y" installFoamGrid ;; + glpk) + SOMETHING_DONE="y" + createExternalDirectory + installGLPK + ;; gstat) SOMETHING_DONE="y" createExternalDirectory @@ -505,6 +580,11 @@ for TMP in "$@"; do SOMETHING_DONE="y" installMultidomainGrid ;; + nlopt) + SOMETHING_DONE="y" + createExternalDirectory + installNLOPT + ;; opm) SOMETHING_DONE="y" installOPM diff --git a/cmake/modules/DumuxMacros.cmake b/cmake/modules/DumuxMacros.cmake index b3e7328fe322bd418bc3868ec9876ee20c19e031..97ea267aa20896c27b595383c0da5ffef223763a 100644 --- a/cmake/modules/DumuxMacros.cmake +++ b/cmake/modules/DumuxMacros.cmake @@ -4,9 +4,11 @@ include(AddInputFileLinks) include(DumuxDoxygen) include(DumuxTestMacros) +find_package(GLPK) find_package(Gstat) find_package(Gnuplot) set(HAVE_GNUPLOT ${GNUPLOT_FOUND}) +find_package(NLOPT) find_package(Valgrind) find_package(PTScotch) diff --git a/cmake/modules/FindGLPK.cmake b/cmake/modules/FindGLPK.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ad2590240afcbb35a9d612cb340ecdb2803bbc4f --- /dev/null +++ b/cmake/modules/FindGLPK.cmake @@ -0,0 +1,100 @@ +# +# Module that checks whether GLPK is available and usable. +# +# Variables used by this module which you may want to set: +# GLPK_ROOT Path list to search for GLPK +# +# Sets the follwing variable: +# +# GLPK_FOUND True if GLPK available and usable. +# GLPK_INCLUDE_DIRS Path to the GLPK include dirs. +# GLPK_LIBRARIES Name to the GLPK library. +# + +# look for header files, only at positions given by the user +find_path(GLPK_INCLUDE_DIR + NAMES glpk.h + PATHS ${GLPK_PREFIX} + ${GLPK_ROOT} + "${CMAKE_SOURCE_DIR}/../external/glpk" + PATH_SUFFIXES "glpk" "include/glpk" "include" "SRC" "src" + NO_DEFAULT_PATH +) + +# look for header files, including default paths +find_path(GLPK_INCLUDE_DIR + NAMES glpk.h + PATH_SUFFIXES "glpk" "include/glpk" "include" "SRC" "src" +) + +# look for library, only at positions given by the user +find_library(GLPK_LIBRARY + NAMES "glpk" + PATHS ${GLPK_PREFIX} + ${GLPK_ROOT} + "${CMAKE_SOURCE_DIR}/../external/glpk" + PATH_SUFFIXES "lib" "lib32" "lib64" "libglpk" "src" "src/.libs" + NO_DEFAULT_PATH +) + +# look for library files, including default paths +find_library(GLPK_LIBRARY + NAMES "glpk" + PATH_SUFFIXES "lib" "lib32" "lib64" "libglpk" +) + +# check version specific macros +include(CheckCSourceCompiles) +include(CMakePushCheckState) +cmake_push_check_state() + +# we need if clauses here because variable is set variable-NOTFOUND +# +if(GLPK_INCLUDE_DIR) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GLPK_INCLUDE_DIR}) +endif(GLPK_INCLUDE_DIR) +if(GLPK_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GLPK_LIBRARY}) +endif(GLPK_LIBRARY) + +# handle package arguments +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "GLPK" + DEFAULT_MSG + GLPK_INCLUDE_DIR + GLPK_LIBRARY +) + +mark_as_advanced(GLPK_INCLUDE_DIR GLPK_LIBRARY) + +# if both headers and library are found, store results +if(GLPK_FOUND) + set(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR}) + set(GLPK_LIBRARIES ${GLPK_LIBRARY}) + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining location of GLPK succeeded:\n" + "Include directory: ${GLPK_INCLUDE_DIRS}\n" + "Library directory: ${GLPK_LIBRARIES}\n\n") + set(GLPK_DUNE_COMPILE_FLAGS "${GLPK_INCLUDE_DIRS}" + CACHE STRING "Compile flags used by DUNE when compiling GLPK programs") + set(GLPK_DUNE_LIBRARIES ${GLPK_LIBRARIES} + CACHE STRING "Libraries used by DUNE when linking GLPK programs") +else(GLPK_FOUND) + # log errornous result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining location of GLPK failed:\n" + "Include directory: ${GLPK_INCLUDE_DIRS}\n" + "Library directory: ${GLPK_LIBRARIES}\n\n") +endif(GLPK_FOUND) + +# set HAVE_GLPK for config.h +set(HAVE_GLPK ${GLPK_FOUND}) + +# register all GLPK related flags +if(GLPK_FOUND) + dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_GLPK=1" + LIBRARIES "${GLPK_DUNE_LIBRARIES}" + INCLUDE_DIRS "${GLPK_INCLUDE_DIRS}") +endif() diff --git a/cmake/modules/FindNLOPT.cmake b/cmake/modules/FindNLOPT.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2dfb17210fc2e21eb1f9ab89e8e0efe195172524 --- /dev/null +++ b/cmake/modules/FindNLOPT.cmake @@ -0,0 +1,101 @@ +# +# Module that checks whether NLOPT is available and usable. +# +# Variables used by this module which you may want to set: +# NLOPT_ROOT Path list to search for NLOPT +# +# Sets the follwing variable: +# +# NLOPT_FOUND True if NLOPT available and usable. +# NLOPT_INCLUDE_DIRS Path to the NLOPT include dirs. +# NLOPT_LIBRARIES Name to the NLOPT library. +# + +# look for header files, only at positions given by the user +find_path(NLOPT_INCLUDE_DIR + NAMES nlopt.h + PATHS ${NLOPT_PREFIX} + ${NLOPT_ROOT} + "${CMAKE_SOURCE_DIR}/../external/nlopt" + PATH_SUFFIXES "nlopt" "include/nlopt" "include" "SRC" "src" "api" + NO_DEFAULT_PATH +) + +# look for header files, including default paths +find_path(NLOPT_INCLUDE_DIR + NAMES nlopt.h + PATH_SUFFIXES "nlopt" "include/nlopt" "include" "SRC" "src" +) + +# look for library, only at positions given by the user +find_library(NLOPT_LIBRARY + NAMES "nlopt" + PATHS ${NLOPT_PREFIX} + ${NLOPT_ROOT} + ${NLOPT_ROOT} + "${CMAKE_SOURCE_DIR}/../external/nlopt" + PATH_SUFFIXES "lib" "lib32" "lib64" "libnlopt" ".libs" + NO_DEFAULT_PATH +) + +# look for library files, including default paths +find_library(NLOPT_LIBRARY + NAMES "nlopt" + PATH_SUFFIXES "lib" "lib32" "lib64" "libnlopt" +) + +# check version specific macros +include(CheckCSourceCompiles) +include(CMakePushCheckState) +cmake_push_check_state() + +# we need if clauses here because variable is set variable-NOTFOUND +# +if(NLOPT_INCLUDE_DIR) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${NLOPT_INCLUDE_DIR}) +endif(NLOPT_INCLUDE_DIR) +if(NLOPT_LIBRARY) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${NLOPT_LIBRARY}) +endif(NLOPT_LIBRARY) + +# behave like a CMake module is supposed to behave +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + "NLOPT" + DEFAULT_MSG + NLOPT_INCLUDE_DIR + NLOPT_LIBRARY +) + +mark_as_advanced(NLOPT_INCLUDE_DIR NLOPT_LIBRARY) + +# if both headers and library are found, store results +if(NLOPT_FOUND) + set(NLOPT_INCLUDE_DIRS ${NLOPT_INCLUDE_DIR}) + set(NLOPT_LIBRARIES ${NLOPT_LIBRARY}) + # log result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining location of NLOPT succeeded:\n" + "Include directory: ${NLOPT_INCLUDE_DIRS}\n" + "Library directory: ${NLOPT_LIBRARIES}\n\n") + set(NLOPT_DUNE_COMPILE_FLAGS "${NLOPT_INCLUDE_DIRS}" + CACHE STRING "Compile flags used by DUNE when compiling NLOPT programs") + set(NLOPT_DUNE_LIBRARIES ${NLOPT_LIBRARIES} + CACHE STRING "Libraries used by DUNE when linking NLOPT programs") +else(NLOPT_FOUND) + # log errornous result + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining location of NLOPT failed:\n" + "Include directory: ${NLOPT_INCLUDE_DIRS}\n" + "Library directory: ${NLOPT_LIBRARIES}\n\n") +endif(NLOPT_FOUND) + +# set HAVE_NLOPT for config.h +set(HAVE_NLOPT ${NLOPT_FOUND}) + +# register all NLOPT related flags +if(NLOPT_FOUND) + dune_register_package_flags(COMPILE_DEFINITIONS "ENABLE_NLOPT=1" + LIBRARIES "${NLOPT_DUNE_LIBRARIES}" + INCLUDE_DIRS "${NLOPT_INCLUDE_DIRS}") +endif()