| 1 | #!/bin/bash
|
|---|
| 2 | set -eu
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | # Constants
|
|---|
| 6 | #
|
|---|
| 7 | DAK_ROOT=${ISSM_DIR}/externalpackages/dakota
|
|---|
| 8 | VER="6.2"
|
|---|
| 9 |
|
|---|
| 10 | ## Environment
|
|---|
| 11 | #
|
|---|
| 12 | # Find libgfortran and so we do not have to hardcode it
|
|---|
| 13 | #
|
|---|
| 14 | # NOTE:
|
|---|
| 15 | # - Assumes user installed gfortran via Homebrew.
|
|---|
| 16 | # - Searches for libgfortran.a as it is easier to find it.
|
|---|
| 17 | #
|
|---|
| 18 | # TODO: Refactor this to work with other gfortran installations.
|
|---|
| 19 | #
|
|---|
| 20 | LIBGFORTRAN=$(mdfind -onlyin /usr -name libgfortran | grep -n libgfortran.a | grep -v i386 | sed "s/[0-9]*://g" | head -1) # Should retrieve a copy of gfortran that is compiled from source before returning one that is installed via package manager
|
|---|
| 21 | LIBGFORTRAN_ROOT=${LIBGFORTRAN%/*}
|
|---|
| 22 |
|
|---|
| 23 | export BLAS_LIBS="-L${ISSM_DIR}/externalpackages/petsc/install/lib -lfblas -L${LIBGFORTRAN_ROOT} -lgfortran" # Need to export BLAS_LIBS *and* pass it as an option to CMake to ensure that external packages also find it
|
|---|
| 24 | export BOOST_ROOT=${ISSM_DIR}/externalpackages/boost/install
|
|---|
| 25 | export DAK_BUILD=${DAK_ROOT}/build
|
|---|
| 26 | export DAK_INSTALL=${DAK_ROOT}/install
|
|---|
| 27 | export DAK_SRC=${DAK_ROOT}/src
|
|---|
| 28 | export GSL_HOME=${ISSM_DIR}/externalpackages/gsl/install
|
|---|
| 29 | export LAPACK_LIBS="-L${ISSM_DIR}/externalpackages/petsc/install/lib -lflapack -L${LIBGFORTRAN_ROOT} -lgfortran" # Need to export LAPACK_LIBS *and* pass it as an option to CMake to ensure that external packages also find it
|
|---|
| 30 |
|
|---|
| 31 | # Cleanup
|
|---|
| 32 | rm -rf build install src
|
|---|
| 33 | mkdir build install src
|
|---|
| 34 |
|
|---|
| 35 | # Download source
|
|---|
| 36 | ${ISSM_DIR}/scripts/DownloadExternalPackage.sh "https://issm.ess.uci.edu/files/externalpackages/dakota-${VER}-public.src.tar.gz" "dakota-${VER}-public-src.tar.gz"
|
|---|
| 37 |
|
|---|
| 38 | # Unpack source
|
|---|
| 39 | tar -zxvf dakota-${VER}-public-src.tar.gz
|
|---|
| 40 |
|
|---|
| 41 | # Move source to 'src' directory
|
|---|
| 42 | mv dakota-${VER}.0.src/* src
|
|---|
| 43 | rm -rf dakota-${VER}.0.src
|
|---|
| 44 |
|
|---|
| 45 | # Copy customized source and configuration files to 'src' directory
|
|---|
| 46 | cp configs/${VER}/packages/DDACE/src/Analyzer/MainEffectsExcelOutput.cpp ${DAK_SRC}/packages/DDACE/src/Analyzer
|
|---|
| 47 | cp configs/${VER}/packages/surfpack/src/surfaces/nkm/NKM_KrigingModel.cpp ${DAK_SRC}/packages/surfpack/src/surfaces/nkm
|
|---|
| 48 | cp configs/${VER}/src/DakotaInterface.cpp ${DAK_SRC}/src
|
|---|
| 49 | cp configs/${VER}/src/NonDLocalReliability.cpp ${DAK_SRC}/src
|
|---|
| 50 | cp configs/${VER}/src/NonDSampling.cpp ${DAK_SRC}/src
|
|---|
| 51 |
|
|---|
| 52 | # Copy customized source and configuration files specific to Mac to 'src' directory
|
|---|
| 53 | cp configs/${VER}/mac/cmake/BuildDakotaCustom.cmake ${DAK_SRC}/cmake
|
|---|
| 54 | cp configs/${VER}/mac/cmake/DakotaDev.cmake ${DAK_SRC}/cmake
|
|---|
| 55 | cp configs/${VER}/mac/cmake/InstallDarwinDylibs.cmake ${DAK_SRC}/cmake
|
|---|
| 56 | cp configs/${VER}/mac/packages/VPISparseGrid/src/sandia_rules.cpp ${DAK_SRC}/packages/VPISparseGrid/src
|
|---|
| 57 |
|
|---|
| 58 | # Configure
|
|---|
| 59 | cd ${DAK_BUILD}
|
|---|
| 60 | cmake \
|
|---|
| 61 | -DBUILD_SHARED_LIBS=ON \
|
|---|
| 62 | -DBUILD_STATIC_LIBS=OFF \
|
|---|
| 63 | -DCMAKE_C_COMPILER=${MPI_HOME}/bin/mpicc \
|
|---|
| 64 | -DCMAKE_CXX_COMPILER=${MPI_HOME}/bin/mpicxx \
|
|---|
| 65 | -DCMAKE_Fortran_COMPILER=${MPI_HOME}/bin/mpif77 \
|
|---|
| 66 | -DCMAKE_CXX_FLAGS="-fdelayed-template-parsing" \
|
|---|
| 67 | -DBoost_NO_BOOST_CMAKE=TRUE \
|
|---|
| 68 | -DHAVE_ACRO=OFF \
|
|---|
| 69 | -DHAVE_JEGA=OFF \
|
|---|
| 70 | -DHAVE_QUESO=ON \
|
|---|
| 71 | -DDAKOTA_HAVE_GSL=ON \
|
|---|
| 72 | -C${DAK_SRC}/cmake/BuildDakotaCustom.cmake \
|
|---|
| 73 | -C${DAK_SRC}/cmake/DakotaDev.cmake \
|
|---|
| 74 | ${DAK_SRC}
|
|---|
| 75 |
|
|---|
| 76 | # Compile and install
|
|---|
| 77 | if [ $# -eq 0 ]; then
|
|---|
| 78 | make
|
|---|
| 79 | make install
|
|---|
| 80 | else
|
|---|
| 81 | make -j $1
|
|---|
| 82 | make -j $1 install
|
|---|
| 83 | fi
|
|---|
| 84 |
|
|---|
| 85 | cd ${DAK_INSTALL}
|
|---|
| 86 |
|
|---|
| 87 | # Comment out definition of HAVE_MPI in Teuchos config header file in order to
|
|---|
| 88 | # avoid conflict with our definition
|
|---|
| 89 | sed -i -e "s/#define HAVE_MPI/\/* #define HAVE_MPI *\//g" include/Teuchos_config.h
|
|---|
| 90 |
|
|---|
| 91 | # Set install_name for all shared libraries
|
|---|
| 92 | cd ${DAK_INSTALL}/lib
|
|---|
| 93 | for name in *.dylib; do
|
|---|
| 94 | install_name_tool -id ${DAK_INSTALL}/lib/${name} ${name}
|
|---|
| 95 | done
|
|---|
| 96 |
|
|---|
| 97 | ## Patch install names for certain libraries
|
|---|
| 98 | #
|
|---|
| 99 | # TODO: Figure out how to reconfigure source to apply these install names at compile time
|
|---|
| 100 | #
|
|---|
| 101 | install_name_tool -change libdakota_src_fortran.dylib ${DAK_INSTALL}/lib/libdakota_src_fortran.dylib libdakota_src.dylib
|
|---|
| 102 | install_name_tool -change liblhs_mod.dylib ${DAK_INSTALL}/lib/liblhs_mod.dylib liblhs.dylib
|
|---|
| 103 | install_name_tool -change liblhs_mods.dylib ${DAK_INSTALL}/lib/liblhs_mods.dylib liblhs.dylib
|
|---|
| 104 | install_name_tool -change liblhs_mod.dylib ${DAK_INSTALL}/lib/liblhs_mod.dylib liblhs_mods.dylib
|
|---|
| 105 | install_name_tool -change libteuchos.dylib ${DAK_INSTALL}/lib/libteuchos.dylib liboptpp.dylib
|
|---|
| 106 | install_name_tool -change libdfftpack.dylib ${DAK_INSTALL}/lib/libdfftpack.dylib libpecos.dylib
|
|---|
| 107 | install_name_tool -change liblhs.dylib ${DAK_INSTALL}/lib/liblhs.dylib libpecos.dylib
|
|---|
| 108 | install_name_tool -change liblhs_mod.dylib ${DAK_INSTALL}/lib/liblhs_mod.dylib libpecos.dylib
|
|---|
| 109 | install_name_tool -change liblhs_mods.dylib ${DAK_INSTALL}/lib/liblhs_mods.dylib libpecos.dylib
|
|---|
| 110 | install_name_tool -change libpecos_src.dylib ${DAK_INSTALL}/lib/libpecos_src.dylib libpecos.dylib
|
|---|
| 111 | install_name_tool -change libteuchos.dylib ${DAK_INSTALL}/lib/libteuchos.dylib libpecos.dylib
|
|---|
| 112 | install_name_tool -change libdfftpack.dylib ${DAK_INSTALL}/lib/libdfftpack.dylib libpecos_src.dylib
|
|---|
| 113 | install_name_tool -change liblhs.dylib ${DAK_INSTALL}/lib/liblhs.dylib libpecos_src.dylib
|
|---|
| 114 | install_name_tool -change liblhs_mod.dylib ${DAK_INSTALL}/lib/liblhs_mod.dylib libpecos_src.dylib
|
|---|
| 115 | install_name_tool -change liblhs_mods.dylib ${DAK_INSTALL}/lib/liblhs_mods.dylib libpecos_src.dylib
|
|---|
| 116 | install_name_tool -change libteuchos.dylib ${DAK_INSTALL}/lib/libteuchos.dylib libpecos_src.dylib
|
|---|
| 117 | install_name_tool -change libsurfpack_fortran.dylib ${DAK_INSTALL}/lib/libsurfpack_fortran.dylib libsurfpack.dylib
|
|---|