|
| 1 | +#!/bin/bash |
| 2 | +set -eu |
| 3 | + |
| 4 | + |
| 5 | +## Constants |
| 6 | +# |
| 7 | +VER="3.22.0" |
| 8 | + |
| 9 | +PETSC_DIR="${ISSM_DIR}/externalpackages/petsc/src" # DO NOT CHANGE THIS |
| 10 | +PREFIX="${ISSM_DIR}/externalpackages/petsc/install" # Set to location where external package should be installed |
| 11 | + |
| 12 | +# Download source |
| 13 | +${ISSM_DIR}/scripts/DownloadExternalPackage.sh "https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-${VER}.tar.gz" "petsc-${VER}.tar.gz" |
| 14 | + |
| 15 | +# Unpack source |
| 16 | +tar -zxvf petsc-${VER}.tar.gz |
| 17 | + |
| 18 | +# Cleanup |
| 19 | +rm -rf ${PREFIX} ${PETSC_DIR} |
| 20 | +mkdir -p ${PETSC_DIR} |
| 21 | + |
| 22 | +# Move source to $PETSC_DIR |
| 23 | +mv petsc-${VER}/* ${PETSC_DIR} |
| 24 | +rm -rf petsc-${VER} |
| 25 | + |
| 26 | +# Configure |
| 27 | +# |
| 28 | +# NOTE: |
| 29 | +# - Cannot use --with-fpic option when compiling static libs, |
| 30 | +# |
| 31 | +# Cannot determine compiler PIC flags if shared libraries is turned off |
| 32 | +# Either run using --with-shared-libraries or --with-pic=0 and supply the |
| 33 | +# compiler PIC flag via CFLAGS, CXXXFLAGS, and FCFLAGS |
| 34 | +# |
| 35 | +cd ${PETSC_DIR} |
| 36 | +./configure \ |
| 37 | + --prefix="${PREFIX}" \ |
| 38 | + --PETSC_DIR="${PETSC_DIR}" \ |
| 39 | + --LDFLAGS="${LDFLAGS}" \ |
| 40 | + --with-shared-libraries=0 \ |
| 41 | + --CFLAGS="-fPIC" \ |
| 42 | + --CXXFLAGS="-fPIC" \ |
| 43 | + --FFLAGS="-fPIC" \ |
| 44 | + --with-debugging=0 \ |
| 45 | + --with-valgrind=0 \ |
| 46 | + --with-x=0 \ |
| 47 | + --with-ssl=0 \ |
| 48 | + --download-fblaslapack=1 \ |
| 49 | + --download-metis=1 \ |
| 50 | + --download-mpich="https://www.mpich.org/static/downloads/4.2.0/mpich-4.2.0.tar.gz" \ |
| 51 | + --download-mumps=1 \ |
| 52 | + --download-parmetis=1 \ |
| 53 | + --download-scalapack=1 \ |
| 54 | + --download-zlib=1 |
| 55 | + |
| 56 | +# Compile and install |
| 57 | +make |
| 58 | +make install |
| 59 | + |
| 60 | +# Need to make symlinks from libmpich* to libmpi* |
| 61 | +ln -s ${PREFIX}/lib/libmpi.a ${PREFIX}/lib/libmpich.a |
| 62 | +ln -s ${PREFIX}/lib/libmpicxx.a ${PREFIX}/lib/libmpichcxx.a |
| 63 | +ln -s ${PREFIX}/lib/libmpifort.a ${PREFIX}/lib/libmpichf90.a |
| 64 | + |
| 65 | +# Need to make sure classic linker is used (should be able to remove this once MPICH fixes it) |
| 66 | +if [[ ${LDFLAGS} =~ "-Wl,-ld_classic" ]]; then |
| 67 | + sed -i'' -e 's/-Wl,-commons,use_dylibs//g' ${PREFIX}/bin/mpicc |
| 68 | + sed -i'' -e 's/-Wl,-commons,use_dylibs//g' ${PREFIX}/bin/mpicxx |
| 69 | +fi |
0 commit comments