BootStrap: library
From: centos:7

%post
        yum -y install epel-release
        yum -y update
        yum -y install vim-enhanced \
            ccache gcc-c++ gcc-gfortran clang gdb valgrind-openmpi \
            make cmake cmake3 ninja-build patch which file git Lmod \
            libpng-devel libjpeg-devel openmpi-devel mpich-devel python-devel python36-devel \
            hdf5-devel python36-virtualenv python36-pip python-pip \
            netcdf-devel netcdf-cxx-devel netcdf-mpich-devel netcdf-openmpi-devel \
            python-virtualenv fftw-devel voro++-devel eigen3-devel gsl-devel openblas-devel enchant \
            blas-devel lapack-devel libyaml-devel openkim-models kim-api-devel
        yum clean all

        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi

        # manually install Plumed
        mkdir plumed
        cd plumed
        version=2.6.0
        curl -L -o plumed.tar.gz https://github.com/plumed/plumed2/releases/download/v${version}/plumed-src-${version}.tgz
        tar -xzf plumed.tar.gz
        cd plumed-${version}
        ./configure --disable-doc --prefix=/usr
        make
        make install
        # fix up installation for CentOS and Fedora
        mv -v /usr/lib/pkgconfig/plumed* /usr/share/pkgconfig/
        cd ../../
        rm -rvf plumed

        # set custom prompt indicating the container name
        CUSTOM_PROMPT_ENV=/.singularity.d/env/99-zz_custom_prompt.sh
        cat >$CUSTOM_PROMPT_ENV <<EOF
#!/bin/bash
PS1="[centos7:\u@\h] \W> "
EOF
        chmod 755 $CUSTOM_PROMPT_ENV


%environment
        LC_ALL=C
        export LC_ALL

        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi
        # tell OpenMPI to not try using Infiniband
        OMPI_MCA_btl="^openib"
        # do not warn about unused components as this messes up testing
        OMPI_MCA_btl_base_warn_component_unused="0"
        export OMPI_MCA_btl OMPI_MCA_btl_base_warn_component_unused

%labels
        Author akohlmey, rbberger
