From c052e4c5ca0d3b4455e638fe4eeddc8d0a0f13e1 Mon Sep 17 00:00:00 2001 From: David Minton Date: Thu, 10 Aug 2023 22:16:59 -0400 Subject: [PATCH 1/5] Began process to develop a more robust set of build scripts for all of my test platforms --- .dockerignore | 20 ++ .gitignore | 5 + Dockerfile | 348 +++++++++++++++-------------- buildscripts/.gitignore | 1 + buildscripts/build_all.sh | 71 ++++++ buildscripts/build_dependencies.sh | 104 +++++++++ buildscripts/fetch_dependencies.sh | 19 ++ buildscripts/get_platform.sh | 59 +++++ src/CMakeLists.txt | 7 +- swiftest/CMakeLists.txt | 1 - 10 files changed, 462 insertions(+), 173 deletions(-) create mode 100644 .dockerignore create mode 100644 buildscripts/.gitignore create mode 100755 buildscripts/build_all.sh create mode 100755 buildscripts/build_dependencies.sh create mode 100755 buildscripts/fetch_dependencies.sh create mode 100755 buildscripts/get_platform.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..a852af2f5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,20 @@ +# Ignore everything +* +# Whitelist what is necessary +!setup.py +!version.txt +!environment.yml +!pyproject.toml +!requirements.txt +!distclean.cmake +!cmake/Modules/*.cmake +!CMakeLists.txt +!src/CMakeLists.txt +!swiftest/CMakeLists.txt +!swiftest/tests/CMakeLists.txt +!swiftest/*.py +!swiftest/*.pyx +!swiftest/*.h +!swiftest/tests/*.py +!src/*/*.f90 +!buildscripts/*.sh \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8bbdc2e7b..945b01fd1 100644 --- a/.gitignore +++ b/.gitignore @@ -40,8 +40,13 @@ dump* !singularity/ !Dockerfile !environment.yml +!.dockerignore bin/ build/* +hdf5-* +netcdf-c-* +netcdf-fortran-* +zlib-* diff --git a/Dockerfile b/Dockerfile index 569cd3ef5..4d735d994 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,172 +13,184 @@ # dynamically. # This build target compiles all dependencies and the swiftest driver itself -FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build_deps - -ENV INSTALL_DIR="/usr/local" -ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" -ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icx" -ENV CXX="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icpx" -ENV F77="${FC}" -ENV CFLAGS="-fPIC" - -# Get the HDF5, NetCDF-C, and NetCDF-Fortran libraries -RUN wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz && \ - wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz && \ - wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz | tar xvz && \ - wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz - -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - m4 && \ - rm -rf /var/lib/apt/lists/* - -RUN cd zlib-1.2.13 && \ - ./configure --prefix=${INSTALL_DIR} --static && \ - make && \ - make install - -RUN cd hdf5-1.14.1-2 && \ - ./configure --disable-shared \ - --enable-build-mode=production \ - --disable-fortran \ - --disable-java \ - --disable-cxx \ - --prefix=${INSTALL_DIR} \ - --with-zlib=${INSTALL_DIR} && \ - make && \ - make install - -RUN cd netcdf-c-4.9.2 && \ - ./configure --disable-shared \ - --disable-dap \ - --disable-libxml2 \ - --disable-byterange \ - --prefix=${INSTALL_DIR} && \ - make && \ - make install - -ENV NCDIR="${INSTALL_DIR}" -ENV NFDIR="${INSTALL_DIR}" -ENV HDF5_ROOT="${INSTALL_DIR}" -ENV HDF5_LIBDIR="${HDF5_ROOT}/lib" -ENV HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" -ENV HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" - -# NetCDF-Fortran library -ENV FCFLAGS="${CFLAGS} -standard-semantics" -ENV FFLAGS=${CFLAGS} -ENV CPPFLAGS="-I${INSTALL_DIR}/include" -ENV LIBS="-L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -lnetcdf -lhdf5_hl -lhdf5 -lm -lz" -RUN cd netcdf-fortran-4.6.1 && \ - ./configure --disable-shared --prefix=${NFDIR} && \ - make && \ - make install - -FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build_driver -SHELL ["/bin/bash", "-c"] - -# The MACHINE_CODE_VALUE argument is a string that is used when compiling the swiftest_driver. It is appended to the "-x" compiler -# option: (-x${MACHINE_CODE_VALUE}). The default value is set to "sse2" which allows for certain SIMD instructions to be used while -# remaining # compatible with a wide range of CPUs. To get the highest performance, you can pass "host" as an argument, but the -# compiled binary # would only run on a CPU with an architecture compatible with the one that the build was performed on. -# For more details and other options, see: -# https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/x-qx.html -ARG MACHINE_CODE_VALUE="sse2" - -ARG BUILD_TYPE="RELEASE" - -# Additional CMAKE options: -ARG EXTRA_CMAKE_OPTIONS="" - -ENV INSTALL_DIR="/usr/local" -ENV NETCDF_HOME=${INSTALL_DIR} -ENV NETCDF_FORTRAN_HOME=${NETCDF_HOME} -ENV NETCDF_LIBRARY=${NETCDF_HOME} -ENV FOR_COARRAY_NUM_IMAGES=1 -ENV OMP_NUM_THREADS=1 -ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" -ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc" -ENV CXX="${ONEAPI_ROOT}/mpi/latest/bin/mpicxx" -ENV FFLAGS="-fPIC -standard-semantics" -ENV LDFLAGS="-L${INSTALL_DIR}/lib" -ENV LIBS="-lhdf5_hl -lhdf5 -lz" -ENV PATH /root/miniconda3/bin:$PATH - -COPY --from=build_deps ${INSTALL_DIR}/. ${INSTALL_DIR}/ - -COPY ./environment.yml /swiftest/ - -RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh && \ - /bin/bash Miniconda3-py311_23.5.2-0-Linux-x86_64.sh -b && \ - /root/miniconda3/bin/conda init bash && \ - source /root/.bashrc && conda update --all -y && \ - conda install conda-libmamba-solver -y && \ - conda config --set solver libmamba && \ - cd swiftest && \ - conda env create -f environment.yml && \ - conda init bash && \ - echo "conda activate swiftest-env" >> ~/.bashrc && \ - source ~/.bashrc && \ - conda install -c conda-forge scikit-build -y&& \ - conda install -c anaconda cython -y - -COPY ./cmake/ /swiftest/cmake/ -COPY ./src/ /swiftest/src/ -COPY ./CMakeLists.txt /swiftest/ -COPY ./swiftest/ /swiftest/swiftest/ -COPY ./version.txt /swiftest/ -COPY ./setup.py /swiftest/ -COPY ./requirements.txt /swiftest/ -COPY ./pyproject.toml /swiftest/ -RUN cd swiftest && \ - pip install . -v - -# This build target creates a container that executes just the driver program -FROM ubuntu:20.04 as driver -COPY --from=build_driver /usr/local/bin/swiftest_driver /usr/local/bin/ -ENTRYPOINT ["/usr/local/bin/swiftest_driver"] - -# This build target exports the binary to the host -FROM scratch AS export_driver -COPY --from=build_driver /usr/local/bin/swiftest_driver / - -# This build target exports the static library to the host -FROM scratch as export_library -COPY --from=build_driver /usr/local/lib/libswiftest.a / - -# This build target exports the module file to the host -FROM scratch as export_module -COPY --from=build_driver /swiftest/include/ /swiftest/ - -# This build target creates a container with a conda environment with all dependencies needed to run the Python front end and -# analysis tools -FROM continuumio/miniconda3 as python +ARG BUILDIMAGE="intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" +FROM ${BUILDIMAGE} as build-deps SHELL ["/bin/bash", "--login", "-c"] -ENV INSTALL_DIR="/usr/local" -ENV CONDA_DIR="/opt/conda" -ENV SHELL="/bin/bash" -ENV PATH="${CONDA_DIR}/bin:${PATH}" -ENV LD_LIBRARY_PATH="${INSTALL_DIR}/lib" - -COPY --from=build_driver ${INSTALL_DIR}/bin/swiftest_driver ${CONDA_DIR}/bin/swiftest_driver -COPY --from=build_driver ${INSTALL_DIR}/lib/libswiftest.a ${CONDA_DIR}/conda/lib/libswiftest.a -COPY --from=build_driver /swiftest/include/ ${CONDA_DIR}/include/swiftest/ -COPY ./python/. ${CONDA_DIR}/pkgs/swiftest/ -COPY environment.yml . - -RUN conda update --all -y && \ - conda install conda-libmamba-solver -y && \ - conda config --set solver libmamba && \ - conda env create -f environment.yml && \ - conda init bash && \ - echo "conda activate swiftest-env" >> ~/.bashrc && \ - conda clean --all -y && \ - mkdir -p /.astropy && \ - chmod -R 777 /.astropy && \ - mkdir -p /.cache/matplotlib && \ - mkdir -p /.config/matplotlib && \ - chmod -R 777 /.cache/matplotlib && \ - chmod -R 777 /.config/matplotlib - -ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "swiftest-env"] \ No newline at end of file +WORKDIR /swiftest +COPY . ./ +RUN buildscripts/fetch_dependencies.sh +RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \ + buildscripts/build_dependencies.sh Intel; \ + else \ + conda init bash && \ + conda update --all -y && \ + conda env create --file environment.yml --name swiftest-build-env && \ + echo "conda activate swiftest-build-env" >> ~/.bashrc && \ + source ~/.bashrc && \ + conda update all -y && \ + conda install -c conda-forge scikit-build cython cmake gfortran -y &&\ + buildscripts/build_dependencies.sh GNU; \ + fi + +# RUN buildscripts/make_environment.sh +# RUN echo "conda activate swiftest-build-env" >> ~/.bashrc +# RUN source ~/.bashrc && conda activate swiftest-build-env +# RUN conda update all -y +# RUN conda install -c conda-forge scikit-build cython cmake gfortran --name swiftest-build-env -y +# RUN buildscripts/build_dependencies.sh GNU + +# ENV INSTALL_DIR="/usr/local" +# ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" +# ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icx" +# ENV CXX="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icpx" +# ENV F77="${FC}" +# ENV CFLAGS="-fPIC" + +# # Get the HDF5, NetCDF-C, and NetCDF-Fortran libraries +# RUN wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz && \ +# wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz && \ +# wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz | tar xvz && \ +# wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz + +# RUN apt-get update && \ +# DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +# m4 && \ +# rm -rf /var/lib/apt/lists/* + +# RUN cd zlib-1.2.13 && \ +# ./configure --prefix=${INSTALL_DIR} --static && \ +# make && \ +# make install + +# RUN cd hdf5-1.14.1-2 && \ +# ./configure --disable-shared \ +# --enable-build-mode=production \ +# --disable-fortran \ +# --disable-java \ +# --disable-cxx \ +# --prefix=${INSTALL_DIR} \ +# --with-zlib=${INSTALL_DIR} && \ +# make && \ +# make install + +# RUN cd netcdf-c-4.9.2 && \ +# ./configure --disable-shared \ +# --disable-dap \ +# --disable-libxml2 \ +# --disable-byterange \ +# --prefix=${INSTALL_DIR} && \ +# make && \ +# make install + +# ENV NCDIR="${INSTALL_DIR}" +# ENV NFDIR="${INSTALL_DIR}" +# ENV HDF5_ROOT="${INSTALL_DIR}" +# ENV HDF5_LIBDIR="${HDF5_ROOT}/lib" +# ENV HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +# ENV HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" + +# # NetCDF-Fortran library +# ENV FCFLAGS="${CFLAGS} -standard-semantics" +# ENV FFLAGS=${CFLAGS} +# ENV CPPFLAGS="-I${INSTALL_DIR}/include" +# ENV LIBS="-L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -lnetcdf -lhdf5_hl -lhdf5 -lm -lz" +# RUN cd netcdf-fortran-4.6.1 && \ +# ./configure --disable-shared --prefix=${NFDIR} && \ +# make && \ +# make install + +# FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build_driver +# SHELL ["/bin/bash", "-c"] + +# # The MACHINE_CODE_VALUE argument is a string that is used when compiling the swiftest_driver. It is appended to the "-x" compiler +# # option: (-x${MACHINE_CODE_VALUE}). The default value is set to "sse2" which allows for certain SIMD instructions to be used while +# # remaining # compatible with a wide range of CPUs. To get the highest performance, you can pass "host" as an argument, but the +# # compiled binary # would only run on a CPU with an architecture compatible with the one that the build was performed on. +# # For more details and other options, see: +# # https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/x-qx.html +# ARG MACHINE_CODE_VALUE="sse2" + +# ARG BUILD_TYPE="RELEASE" + +# # Additional CMAKE options: +# ARG EXTRA_CMAKE_OPTIONS="" + +# ENV INSTALL_DIR="/usr/local" +# ENV NETCDF_HOME=${INSTALL_DIR} +# ENV NETCDF_FORTRAN_HOME=${NETCDF_HOME} +# ENV NETCDF_LIBRARY=${NETCDF_HOME} +# ENV FOR_COARRAY_NUM_IMAGES=1 +# ENV OMP_NUM_THREADS=1 +# ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" +# ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc" +# ENV CXX="${ONEAPI_ROOT}/mpi/latest/bin/mpicxx" +# ENV FFLAGS="-fPIC -standard-semantics" +# ENV LDFLAGS="-L${INSTALL_DIR}/lib" +# ENV LIBS="-lhdf5_hl -lhdf5 -lz" +# ENV PATH /root/miniconda3/bin:$PATH + +# COPY --from=build_deps ${INSTALL_DIR}/. ${INSTALL_DIR}/ + +# COPY ./environment.yml /swiftest/ + +# RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh && \ +# /bin/bash Miniconda3-py311_23.5.2-0-Linux-x86_64.sh -b && \ +# /root/miniconda3/bin/conda init bash && \ +# source /root/.bashrc && conda update --all -y && \ +# conda install conda-libmamba-solver -y && \ +# conda config --set solver libmamba && \ +# cd swiftest && \ +# conda env create -f environment.yml && \ +# conda init bash && \ +# echo "conda activate swiftest-env" >> ~/.bashrc && \ +# source ~/.bashrc && \ +# conda install -c conda-forge scikit-build -y&& \ +# conda install -c anaconda cython -y + +# COPY ./cmake/ /swiftest/cmake/ +# COPY ./src/ /swiftest/src/ +# COPY ./CMakeLists.txt /swiftest/ +# COPY ./swiftest/ /swiftest/swiftest/ +# COPY ./version.txt /swiftest/ +# COPY ./setup.py /swiftest/ +# COPY ./requirements.txt /swiftest/ +# COPY ./pyproject.toml /swiftest/ + +# ENV CMAKE_ARGS="-DMACHINE_CODE_VALUE=${MACHINE_CODE_VALUE} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF ${EXTRA_CMAKE_OPTIONS}" + +# # RUN cd swiftest && \ +# # pip install . -v + +# # This build target creates a container that executes just the driver program +# FROM ubuntu:20.04 as driver +# COPY --from=build_driver /root/miniconda3/envs/swiftest-env/bin/swiftest_driver /usr/local/bin/ +# ENTRYPOINT ["/usr/local/bin/swiftest_driver"] + +# # This build target exports the binary to the host +# FROM scratch AS export_driver +# COPY --from=driver /usr/local/bin/swiftest_driver / + +# # This build target creates a container with a conda environment with all dependencies needed to run the Python front end and +# # analysis tools +# FROM continuumio/miniconda3 as python +# SHELL ["/bin/bash", "--login", "-c"] +# ENV INSTALL_DIR="/usr/local" +# ENV CONDA_DIR="/opt/conda" +# ENV SHELL="/bin/bash" +# ENV PATH="${CONDA_DIR}/bin:${PATH}" + +# COPY --from=build_driver /root/miniconda3/envs/swiftest-env/ ${CONDA_DIR}/envs/ +# RUN conda update --all -y && \ +# conda install conda-libmamba-solver -y && \ +# conda config --set solver libmamba && \ +# conda init bash && \ +# echo "conda activate swiftest-env" >> ~/.bashrc && \ +# conda clean --all -y && \ +# mkdir -p /.astropy && \ +# chmod -R 777 /.astropy && \ +# mkdir -p /.cache/matplotlib && \ +# mkdir -p /.config/matplotlib && \ +# chmod -R 777 /.cache/matplotlib && \ +# chmod -R 777 /.config/matplotlib + +# ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "swiftest-env"] \ No newline at end of file diff --git a/buildscripts/.gitignore b/buildscripts/.gitignore new file mode 100644 index 000000000..e2ee4346f --- /dev/null +++ b/buildscripts/.gitignore @@ -0,0 +1 @@ +!*.sh \ No newline at end of file diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh new file mode 100755 index 000000000..a3bd51563 --- /dev/null +++ b/buildscripts/build_all.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# This script will determine the steps necessary to set up an appropriate build environment necessary to build Swiftest and all its +# dependencies. The steps that are executed depend on the combination of platform and architecture, as follows: +# +# Linux amd64/x86_64: +# Docker present: The build scripts will run inside a Docker container with Intel compilers (preferred). +# Docker not present: The build scripts will run inside a custom conda environment and build with Intel compilers if available, +# or GNU compiler compilers otherwise. +# Linux aarch64/arm64: +# Docker present: The build scripts will run inside a Docker container with GNU compilers +# Docker not present: The build scripts will run inside a custom conda environment with GNU compilers +# Mac OS (Darwin): +# The build scripts will run inside a custom conda environment with GNU compilers +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. + + +# Determine the platform and architecture +SCRIPT_DIR=$(dirname "$0") +echo $SCRIPT_DIR +read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) + +# Determine if we are in the correct directory (the script can either be run from the Swiftest project root directory or the +# buildscripts directory) +if [ ! -f "./setup.py" ]; then + if [ -f "../setup.py" ]; then + cd .. + else + echo "Error: setup.py not found in . or .." + exit 1 + fi +fi + +VERSION=$( cat version.txt ) +echo "Building Swiftest version ${VERSION} for ${OS}-${ARCH}" + +case $OS in + Linux) + # Determine if Docker is available + if command -v docker &> /dev/null; then + echo "Docker detected" + if [ "$ARCH" = "x86_64" ]; then + BUILDIMAGE="intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" + else + BUILDIMAGE="condaforge/miniforge3:23.1.0-4" + fi + cmd="docker build --tag swiftest:latest --tag swiftest:${VERSION} --build-arg BUILDIMAGE=\"${BUILDIMAGE}\" ." + echo "Executing Docker build:\n${cmd}" + eval "$cmd" + exit 0 + else + echo "Docker not detected" + fi + ;; + MacOSX) + ;; + *) + echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" + exit 1 + ;; +esac + + + diff --git a/buildscripts/build_dependencies.sh b/buildscripts/build_dependencies.sh new file mode 100755 index 000000000..ae40f81ea --- /dev/null +++ b/buildscripts/build_dependencies.sh @@ -0,0 +1,104 @@ +#!/bin/bash +# This script will build all of the dependency libraries needed by Swiftest. Builds the following from source: +# Zlib, hdf5, netcdf-c, netcdf-fortran +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. +SCRIPT_DIR=$(dirname "$0") +cd $SCRIPT_DIR/.. + +USTMT="Usage: $0 <{Intel}|GNU>" +if [[ ( $@ == "--help") || $@ == "-h" ]] +then + echo $USTMT + exit 0 +fi +COMPILER=${1:-Intel} + +case $COMPILER in + Intel) + if command -v ifx &> /dev/null; then + export FC=$(command -v ifx) + export CC=$(command -v icx) + export CXX=$(command -v icpx) + elif command -v ifort &> /dev/null; then + export FC=$(command -v ifort) + export CC=$(command -v icc) + export CXX=$(command -v icpc) + else + echo "Error. Cannot find valid Intel fortran compiler." + exit 1 + fi + export F77="${FC}" + ;; + GNU) + export FC=$(command -v gfortran) + export CC=$(command -v gcc) + export CXX=$(command -v g++) + ;; + *) + echo "Unknown compiler type: ${COMPILER}" + echo $USTMT + exit 1 + ;; +esac +export F77=${FC} +echo "Using $COMPILER compilers:\nFC: $FC\nCC: $CC\nCXX: $CXX\n" + +export INSTALL_DIR=$(realpath .)/usr/local +mkdir -p ${INSTALL_DIR} +export NCDIR="${INSTALL_DIR}" +export NFDIR="${INSTALL_DIR}" +export HDF5_ROOT="${INSTALL_DIR}" +export HDF5_LIBDIR="${HDF5_ROOT}/lib" +export HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +export HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" + +export LDFLAGS="-L${INSTALL_DIR}/lib" +export CPATH="${INSTALL_DIR}/include" +export CFLAGS="-fPIC" + +cd zlib-1.2.13 +./configure --prefix=${INSTALL_DIR} --static +make +make install +cd ../hdf5-1.14.1-2 +./configure --disable-shared \ + --enable-build-mode=production \ + --disable-fortran \ + --disable-java \ + --disable-cxx \ + --prefix=${INSTALL_DIR} \ + --with-zlib=${INSTALL_DIR} +make +make install + +cd ../netcdf-c-4.9.2 +./configure --disable-shared \ + --disable-dap \ + --disable-byterange \ + --prefix=${INSTALL_DIR} +make +make check +make install + +if [ $COMPILER = "Intel" ]; then + export FCFLAGS="${CFLAGS} -standard-semantics" + export FFLAGS=${CFLAGS} +else + export FCFLAGS="${CFLAGS}" + export FFFLAGS="${CFLAGS}" +fi + +export LIBS="$(${INSTALL_DIR}/bin/nc-config --libs)" +cd ../netcdf-fortran-4.6.1 +./configure --disable-shared --with-pic --prefix=${NFDIR} +make +make check +make install diff --git a/buildscripts/fetch_dependencies.sh b/buildscripts/fetch_dependencies.sh new file mode 100755 index 000000000..469d0f147 --- /dev/null +++ b/buildscripts/fetch_dependencies.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# This script will download all of the dependency libraries needed by Swiftest. +# Zlib, hdf5, netcdf-c, netcdf-fortran +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. + +SCRIPT_DIR=$(dirname "$0") +cd $SCRIPT_DIR/.. +wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz +wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz +wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz +wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz | tar xvz diff --git a/buildscripts/get_platform.sh b/buildscripts/get_platform.sh new file mode 100755 index 000000000..c30592d7f --- /dev/null +++ b/buildscripts/get_platform.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# This script will determine the platform (OS and architecture) and format them in a way that other scripts can make use of. +# +# The following combinations are valid: +# Linux x86_64 +# Linux aarch64 +# MacOSX x86_64 +# MacOSX arm64 +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. + + +# Determine the platform and architecture +OS=$(uname -s) +ARCH=$(uname -m) + +case $ARCH in + x86_64) + ;; + amd64) + ARCH="x86_64" + ;; + arm64) + if [ "$OS" = "Linux" ]; then + ARCH="aarch64" + fi + ;; + aarch64) + if [ "$OS" = "Darwin" ]; then + ARCH="arm64" + fi + ;; + *) + echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" + exit 1 + ;; +esac + + +case $OS in + Linux) + ;; + Darwin) + OS="MacOSX" + ;; + *) + echo "Swiftest is currently not configured to build for platform ${OS}-${ARCH}" + exit 1 + ;; +esac + +echo $OS $ARCH diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9cab5f7f3..00bcf31f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,6 +34,7 @@ ENDIF () # RELEASE, PROFILING, and TESTING. INCLUDE(SetFortranFlags) + # Add the source files SET(STRICT_MATH_FILES ${SRC}/collision/collision_generate.f90 @@ -127,7 +128,6 @@ ENDIF () # Turn preprocessor on for all files SET_SOURCE_FILES_PROPERTIES(${SWIFTEST_src} ${DRIVER_src} PROPERTIES Fortran_PREPROCESS ON) - #Set strict vs fast math flags STRING(TOUPPER "${CMAKE_BUILD_TYPE}" BT) IF(BT STREQUAL "RELEASE" OR BT STREQUAL "PROFILE") @@ -142,12 +142,11 @@ ELSEIF(BT STREQUAL "PROFILE") ENDIF() ##################################################### -# Add the needed libraries and special compiler flags +# Add the needed libraries ##################################################### - # Create a library from the source files, except the driver SET(SWIFTEST_LIBRARY swiftest) -ADD_LIBRARY(${SWIFTEST_LIBRARY} ${SWIFTEST_src}) +ADD_LIBRARY(${SWIFTEST_LIBRARY} ${netcdff} ${SWIFTEST_src}) # Define the executable name SET(SWIFTEST_DRIVER swiftest_driver) diff --git a/swiftest/CMakeLists.txt b/swiftest/CMakeLists.txt index 8b41bc03c..5633f4fc7 100644 --- a/swiftest/CMakeLists.txt +++ b/swiftest/CMakeLists.txt @@ -13,7 +13,6 @@ CMAKE_POLICY(SET CMP0148 OLD) SET(CYTHON_FLAGS "--directive binding=True,boundscheck=False,wraparound=False,embedsignature=True,always_allow_keywords=True" CACHE STRING "The directives for Cython compilation.") -FIND_PACKAGE(PythonInterp REQUIRED) FIND_PACKAGE(Cython REQUIRED) FIND_PACKAGE(PythonExtensions REQUIRED) From e438bdd1c16003dac65a9029afee0b84537494bc Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Aug 2023 11:38:51 -0400 Subject: [PATCH 2/5] Continuted improvements to automated build scripts --- .dockerignore | 3 ++- Dockerfile | 21 ++++++---------- buildscripts/.gitignore | 3 ++- buildscripts/build_all.sh | 3 +-- buildscripts/build_dependencies.sh | 11 ++++---- buildscripts/fetch_dependencies.sh | 7 ++++-- buildscripts/make_environment.sh | 39 +++++++++++++++++++++++++++++ buildscripts/swiftest-build-env.yml | 15 +++++++++++ 8 files changed, 77 insertions(+), 25 deletions(-) create mode 100755 buildscripts/make_environment.sh create mode 100644 buildscripts/swiftest-build-env.yml diff --git a/.dockerignore b/.dockerignore index a852af2f5..1d60b6d6e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,4 +17,5 @@ !swiftest/*.h !swiftest/tests/*.py !src/*/*.f90 -!buildscripts/*.sh \ No newline at end of file +!buildscripts/*.sh +!buildscripts/*.yml diff --git a/Dockerfile b/Dockerfile index 4d735d994..125417410 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,30 +15,23 @@ # This build target compiles all dependencies and the swiftest driver itself ARG BUILDIMAGE="intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" FROM ${BUILDIMAGE} as build-deps +ENV SCRIPT_DIR="buildscripts" SHELL ["/bin/bash", "--login", "-c"] +ENV SHELL="/bin/bash" WORKDIR /swiftest COPY . ./ -RUN buildscripts/fetch_dependencies.sh +RUN ${SCRIPT_DIR}/fetch_dependencies.sh RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \ - buildscripts/build_dependencies.sh Intel; \ + ${SCRIPT_DIR}/build_dependencies.sh Intel; \ else \ conda init bash && \ - conda update --all -y && \ - conda env create --file environment.yml --name swiftest-build-env && \ + conda update --name base conda -y && \ + ${SCRIPT_DIR}/make_environment.sh && \ echo "conda activate swiftest-build-env" >> ~/.bashrc && \ source ~/.bashrc && \ - conda update all -y && \ - conda install -c conda-forge scikit-build cython cmake gfortran -y &&\ - buildscripts/build_dependencies.sh GNU; \ + ${SCRIPT_DIR}/build_dependencies.sh GNU; \ fi -# RUN buildscripts/make_environment.sh -# RUN echo "conda activate swiftest-build-env" >> ~/.bashrc -# RUN source ~/.bashrc && conda activate swiftest-build-env -# RUN conda update all -y -# RUN conda install -c conda-forge scikit-build cython cmake gfortran --name swiftest-build-env -y -# RUN buildscripts/build_dependencies.sh GNU - # ENV INSTALL_DIR="/usr/local" # ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" # ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icx" diff --git a/buildscripts/.gitignore b/buildscripts/.gitignore index e2ee4346f..120c12345 100644 --- a/buildscripts/.gitignore +++ b/buildscripts/.gitignore @@ -1 +1,2 @@ -!*.sh \ No newline at end of file +!*.sh +!*.yml \ No newline at end of file diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh index a3bd51563..e64d22c14 100755 --- a/buildscripts/build_all.sh +++ b/buildscripts/build_all.sh @@ -24,7 +24,6 @@ # Determine the platform and architecture SCRIPT_DIR=$(dirname "$0") -echo $SCRIPT_DIR read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) # Determine if we are in the correct directory (the script can either be run from the Swiftest project root directory or the @@ -49,7 +48,7 @@ case $OS in if [ "$ARCH" = "x86_64" ]; then BUILDIMAGE="intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" else - BUILDIMAGE="condaforge/miniforge3:23.1.0-4" + BUILDIMAGE="condaforge/mambaforge:23.1.0-4" fi cmd="docker build --tag swiftest:latest --tag swiftest:${VERSION} --build-arg BUILDIMAGE=\"${BUILDIMAGE}\" ." echo "Executing Docker build:\n${cmd}" diff --git a/buildscripts/build_dependencies.sh b/buildscripts/build_dependencies.sh index ae40f81ea..066b9f180 100755 --- a/buildscripts/build_dependencies.sh +++ b/buildscripts/build_dependencies.sh @@ -11,11 +11,12 @@ # You should have received a copy of the GNU General Public License along with Swiftest. # If not, see: https://www.gnu.org/licenses. SCRIPT_DIR=$(dirname "$0") -cd $SCRIPT_DIR/.. +BUILD_DIR=${SCRIPT_DIR}/../build +mkdir -p ${BUILD_DIR} +cd $BUILD_DIR USTMT="Usage: $0 <{Intel}|GNU>" -if [[ ( $@ == "--help") || $@ == "-h" ]] -then +if [[ ( $@ == "--help") || $@ == "-h" ]]; then echo $USTMT exit 0 fi @@ -51,7 +52,7 @@ esac export F77=${FC} echo "Using $COMPILER compilers:\nFC: $FC\nCC: $CC\nCXX: $CXX\n" -export INSTALL_DIR=$(realpath .)/usr/local +export INSTALL_DIR=${BUILD_DIR} mkdir -p ${INSTALL_DIR} export NCDIR="${INSTALL_DIR}" export NFDIR="${INSTALL_DIR}" @@ -93,7 +94,7 @@ if [ $COMPILER = "Intel" ]; then export FFLAGS=${CFLAGS} else export FCFLAGS="${CFLAGS}" - export FFFLAGS="${CFLAGS}" + export FFLAGS="${CFLAGS}" fi export LIBS="$(${INSTALL_DIR}/bin/nc-config --libs)" diff --git a/buildscripts/fetch_dependencies.sh b/buildscripts/fetch_dependencies.sh index 469d0f147..2330d3683 100755 --- a/buildscripts/fetch_dependencies.sh +++ b/buildscripts/fetch_dependencies.sh @@ -10,9 +10,12 @@ # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License along with Swiftest. # If not, see: https://www.gnu.org/licenses. +SCRIPT_DIR=$(realpath $(dirname $0)) +BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) + +mkdir -p ${BUILD_DIR} +cd $BUILD_DIR -SCRIPT_DIR=$(dirname "$0") -cd $SCRIPT_DIR/.. wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz diff --git a/buildscripts/make_environment.sh b/buildscripts/make_environment.sh new file mode 100755 index 000000000..152c0ca0f --- /dev/null +++ b/buildscripts/make_environment.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# This script will create a miniforge3 conda environment in order to execute the build +# Zlib, hdf5, netcdf-c, netcdf-fortran +# +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. + +SCRIPT_DIR=$(realpath $(dirname $0)) + +# Determine if mamba/conda is already installed on the system. If not, install Mambaforge +if command -v mamba; then + CONDABIN="mamba" +elif command -v conda; then + CONDABIN="conda" +else + BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) + mkdir -p ${BUILD_DIR} + read -r OS ARCH < <(${SCRIPT_DIR}/get_platform.sh) + unset PYTHONPATH + cd $BUILD_DIR + wget https://github.com/conda-forge/miniforge/releases/download/23.1.0-4/Mambaforge-23.1.0-4-${OS}-${ARCH}.sh + + MYSHELL=$(basename $SHELL) + INSTALL_DIR=${HOME}/mambaforge + ${SHELL} Mambaforge-23.1.0-4-${OS}-${ARCH}.sh -b -p ${INSTALL_DIR} + rm Mambaforge-23.1.0-4-${OS}-${ARCH}.sh + + CONDABIN="${INSTALL_DIR}/condabin/mamba" + ${CONDABIN} init $MYSHELL + ${CONDABIN} update --name base mamba -y +fi +cd $SCRIPT_DIR +${CONDABIN} env create --file swiftest-build-env.yml --name swiftest-build-env \ No newline at end of file diff --git a/buildscripts/swiftest-build-env.yml b/buildscripts/swiftest-build-env.yml new file mode 100644 index 000000000..0521c0639 --- /dev/null +++ b/buildscripts/swiftest-build-env.yml @@ -0,0 +1,15 @@ +name: swiftest-build-env + +channels: + - conda-forge + - defaults + +dependencies: + - python>=3.8 + - compilers>=1.6 + - setuptools>=42 + - scikit-build>=0.17 + - cmake>=3.5.0 + - cython>=3.0.0 + - make + - ninja \ No newline at end of file From 4602c195797a2a554383797269fa9dc99bb87b3d Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Aug 2023 13:44:52 -0400 Subject: [PATCH 3/5] Fixes to build scripts so that they can work with Docker or just conda/mamba --- Dockerfile | 9 +++------ buildscripts/build_all.sh | 14 ++++++-------- buildscripts/build_dependencies.sh | 4 ++-- ...ke_environment.sh => make_build_environment.sh} | 13 +++++++++---- 4 files changed, 20 insertions(+), 20 deletions(-) rename buildscripts/{make_environment.sh => make_build_environment.sh} (85%) diff --git a/Dockerfile b/Dockerfile index 125417410..61b835958 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,13 +23,10 @@ COPY . ./ RUN ${SCRIPT_DIR}/fetch_dependencies.sh RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; then \ ${SCRIPT_DIR}/build_dependencies.sh Intel; \ - else \ - conda init bash && \ - conda update --name base conda -y && \ - ${SCRIPT_DIR}/make_environment.sh && \ + else \ + ${SCRIPT_DIR}/make_build_environment.sh && \ echo "conda activate swiftest-build-env" >> ~/.bashrc && \ - source ~/.bashrc && \ - ${SCRIPT_DIR}/build_dependencies.sh GNU; \ + /bin/bash -lic "${SCRIPT_DIR}/build_dependencies.sh GNU"; \ fi # ENV INSTALL_DIR="/usr/local" diff --git a/buildscripts/build_all.sh b/buildscripts/build_all.sh index e64d22c14..fdcceb037 100755 --- a/buildscripts/build_all.sh +++ b/buildscripts/build_all.sh @@ -23,20 +23,18 @@ # Determine the platform and architecture -SCRIPT_DIR=$(dirname "$0") +SCRIPT_DIR=$(realpath $(dirname $0)) +ROOT_DIR=$(realpath ${SCRIPT_DIR}/..) +BUILD_DIR=$(realpath ${ROOT_DIR}/build) read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh) # Determine if we are in the correct directory (the script can either be run from the Swiftest project root directory or the # buildscripts directory) -if [ ! -f "./setup.py" ]; then - if [ -f "../setup.py" ]; then - cd .. - else - echo "Error: setup.py not found in . or .." +if [ ! -f "${ROOT_DIR}/setup.py" ]; then + echo "Error: setup.py not found" exit 1 - fi fi - +cd ${ROOT_DIR} VERSION=$( cat version.txt ) echo "Building Swiftest version ${VERSION} for ${OS}-${ARCH}" diff --git a/buildscripts/build_dependencies.sh b/buildscripts/build_dependencies.sh index 066b9f180..b06b1e8a8 100755 --- a/buildscripts/build_dependencies.sh +++ b/buildscripts/build_dependencies.sh @@ -10,8 +10,8 @@ # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # You should have received a copy of the GNU General Public License along with Swiftest. # If not, see: https://www.gnu.org/licenses. -SCRIPT_DIR=$(dirname "$0") -BUILD_DIR=${SCRIPT_DIR}/../build +SCRIPT_DIR=$(realpath $(dirname $0)) +BUILD_DIR=$(realpath ${SCRIPT_DIR}/../build) mkdir -p ${BUILD_DIR} cd $BUILD_DIR diff --git a/buildscripts/make_environment.sh b/buildscripts/make_build_environment.sh similarity index 85% rename from buildscripts/make_environment.sh rename to buildscripts/make_build_environment.sh index 152c0ca0f..fb42fc110 100755 --- a/buildscripts/make_environment.sh +++ b/buildscripts/make_build_environment.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # This script will create a miniforge3 conda environment in order to execute the build # Zlib, hdf5, netcdf-c, netcdf-fortran # @@ -31,9 +31,14 @@ else ${SHELL} Mambaforge-23.1.0-4-${OS}-${ARCH}.sh -b -p ${INSTALL_DIR} rm Mambaforge-23.1.0-4-${OS}-${ARCH}.sh - CONDABIN="${INSTALL_DIR}/condabin/mamba" - ${CONDABIN} init $MYSHELL - ${CONDABIN} update --name base mamba -y + CONDABIN="mamba" + if [ $MYSHELL != "bash" ]; then + $INSTALL_DIR/condabin/$CONDABIN init $MYSHELL + fi + $INSTALL_DIR/condabin/$CONDABIN init bash + source ~/.bashrc + export PATH=${INSTALL_DIR}/bin:$PATH fi cd $SCRIPT_DIR +${CONDABIN} update --name base ${CONDABIN} -y ${CONDABIN} env create --file swiftest-build-env.yml --name swiftest-build-env \ No newline at end of file From 7b0ba5f1400e8a504e1442f64d6ee9d6af5178ac Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Aug 2023 13:46:00 -0400 Subject: [PATCH 4/5] Added missing m4 package --- buildscripts/swiftest-build-env.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/buildscripts/swiftest-build-env.yml b/buildscripts/swiftest-build-env.yml index 0521c0639..914b3ffdb 100644 --- a/buildscripts/swiftest-build-env.yml +++ b/buildscripts/swiftest-build-env.yml @@ -12,4 +12,5 @@ dependencies: - cmake>=3.5.0 - cython>=3.0.0 - make + - m4 - ninja \ No newline at end of file From a5d044f84421d9886d807fe75bba58db5a43009e Mon Sep 17 00:00:00 2001 From: David Minton Date: Fri, 11 Aug 2023 13:47:14 -0400 Subject: [PATCH 5/5] Cleaned cruft from Dockerfile --- Dockerfile | 157 +---------------------------------------------------- 1 file changed, 1 insertion(+), 156 deletions(-) diff --git a/Dockerfile b/Dockerfile index 61b835958..211f9e323 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,159 +28,4 @@ RUN if [ "$BUILDIMAGE" = "intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04" ]; the echo "conda activate swiftest-build-env" >> ~/.bashrc && \ /bin/bash -lic "${SCRIPT_DIR}/build_dependencies.sh GNU"; \ fi - -# ENV INSTALL_DIR="/usr/local" -# ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" -# ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icx" -# ENV CXX="${ONEAPI_ROOT}/mpi/latest/bin/mpicc -cc=icpx" -# ENV F77="${FC}" -# ENV CFLAGS="-fPIC" - -# # Get the HDF5, NetCDF-C, and NetCDF-Fortran libraries -# RUN wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz && \ -# wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz && \ -# wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz | tar xvz && \ -# wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz - -# RUN apt-get update && \ -# DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ -# m4 && \ -# rm -rf /var/lib/apt/lists/* - -# RUN cd zlib-1.2.13 && \ -# ./configure --prefix=${INSTALL_DIR} --static && \ -# make && \ -# make install - -# RUN cd hdf5-1.14.1-2 && \ -# ./configure --disable-shared \ -# --enable-build-mode=production \ -# --disable-fortran \ -# --disable-java \ -# --disable-cxx \ -# --prefix=${INSTALL_DIR} \ -# --with-zlib=${INSTALL_DIR} && \ -# make && \ -# make install - -# RUN cd netcdf-c-4.9.2 && \ -# ./configure --disable-shared \ -# --disable-dap \ -# --disable-libxml2 \ -# --disable-byterange \ -# --prefix=${INSTALL_DIR} && \ -# make && \ -# make install - -# ENV NCDIR="${INSTALL_DIR}" -# ENV NFDIR="${INSTALL_DIR}" -# ENV HDF5_ROOT="${INSTALL_DIR}" -# ENV HDF5_LIBDIR="${HDF5_ROOT}/lib" -# ENV HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" -# ENV HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" - -# # NetCDF-Fortran library -# ENV FCFLAGS="${CFLAGS} -standard-semantics" -# ENV FFLAGS=${CFLAGS} -# ENV CPPFLAGS="-I${INSTALL_DIR}/include" -# ENV LIBS="-L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -lnetcdf -lhdf5_hl -lhdf5 -lm -lz" -# RUN cd netcdf-fortran-4.6.1 && \ -# ./configure --disable-shared --prefix=${NFDIR} && \ -# make && \ -# make install - -# FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build_driver -# SHELL ["/bin/bash", "-c"] - -# # The MACHINE_CODE_VALUE argument is a string that is used when compiling the swiftest_driver. It is appended to the "-x" compiler -# # option: (-x${MACHINE_CODE_VALUE}). The default value is set to "sse2" which allows for certain SIMD instructions to be used while -# # remaining # compatible with a wide range of CPUs. To get the highest performance, you can pass "host" as an argument, but the -# # compiled binary # would only run on a CPU with an architecture compatible with the one that the build was performed on. -# # For more details and other options, see: -# # https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/x-qx.html -# ARG MACHINE_CODE_VALUE="sse2" - -# ARG BUILD_TYPE="RELEASE" - -# # Additional CMAKE options: -# ARG EXTRA_CMAKE_OPTIONS="" - -# ENV INSTALL_DIR="/usr/local" -# ENV NETCDF_HOME=${INSTALL_DIR} -# ENV NETCDF_FORTRAN_HOME=${NETCDF_HOME} -# ENV NETCDF_LIBRARY=${NETCDF_HOME} -# ENV FOR_COARRAY_NUM_IMAGES=1 -# ENV OMP_NUM_THREADS=1 -# ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" -# ENV CC="${ONEAPI_ROOT}/mpi/latest/bin/mpicc" -# ENV CXX="${ONEAPI_ROOT}/mpi/latest/bin/mpicxx" -# ENV FFLAGS="-fPIC -standard-semantics" -# ENV LDFLAGS="-L${INSTALL_DIR}/lib" -# ENV LIBS="-lhdf5_hl -lhdf5 -lz" -# ENV PATH /root/miniconda3/bin:$PATH - -# COPY --from=build_deps ${INSTALL_DIR}/. ${INSTALL_DIR}/ - -# COPY ./environment.yml /swiftest/ - -# RUN wget https://repo.anaconda.com/miniconda/Miniconda3-py311_23.5.2-0-Linux-x86_64.sh && \ -# /bin/bash Miniconda3-py311_23.5.2-0-Linux-x86_64.sh -b && \ -# /root/miniconda3/bin/conda init bash && \ -# source /root/.bashrc && conda update --all -y && \ -# conda install conda-libmamba-solver -y && \ -# conda config --set solver libmamba && \ -# cd swiftest && \ -# conda env create -f environment.yml && \ -# conda init bash && \ -# echo "conda activate swiftest-env" >> ~/.bashrc && \ -# source ~/.bashrc && \ -# conda install -c conda-forge scikit-build -y&& \ -# conda install -c anaconda cython -y - -# COPY ./cmake/ /swiftest/cmake/ -# COPY ./src/ /swiftest/src/ -# COPY ./CMakeLists.txt /swiftest/ -# COPY ./swiftest/ /swiftest/swiftest/ -# COPY ./version.txt /swiftest/ -# COPY ./setup.py /swiftest/ -# COPY ./requirements.txt /swiftest/ -# COPY ./pyproject.toml /swiftest/ - -# ENV CMAKE_ARGS="-DMACHINE_CODE_VALUE=${MACHINE_CODE_VALUE} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DBUILD_SHARED_LIBS=OFF ${EXTRA_CMAKE_OPTIONS}" - -# # RUN cd swiftest && \ -# # pip install . -v - -# # This build target creates a container that executes just the driver program -# FROM ubuntu:20.04 as driver -# COPY --from=build_driver /root/miniconda3/envs/swiftest-env/bin/swiftest_driver /usr/local/bin/ -# ENTRYPOINT ["/usr/local/bin/swiftest_driver"] - -# # This build target exports the binary to the host -# FROM scratch AS export_driver -# COPY --from=driver /usr/local/bin/swiftest_driver / - -# # This build target creates a container with a conda environment with all dependencies needed to run the Python front end and -# # analysis tools -# FROM continuumio/miniconda3 as python -# SHELL ["/bin/bash", "--login", "-c"] -# ENV INSTALL_DIR="/usr/local" -# ENV CONDA_DIR="/opt/conda" -# ENV SHELL="/bin/bash" -# ENV PATH="${CONDA_DIR}/bin:${PATH}" - -# COPY --from=build_driver /root/miniconda3/envs/swiftest-env/ ${CONDA_DIR}/envs/ -# RUN conda update --all -y && \ -# conda install conda-libmamba-solver -y && \ -# conda config --set solver libmamba && \ -# conda init bash && \ -# echo "conda activate swiftest-env" >> ~/.bashrc && \ -# conda clean --all -y && \ -# mkdir -p /.astropy && \ -# chmod -R 777 /.astropy && \ -# mkdir -p /.cache/matplotlib && \ -# mkdir -p /.config/matplotlib && \ -# chmod -R 777 /.cache/matplotlib && \ -# chmod -R 777 /.config/matplotlib - -# ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "swiftest-env"] \ No newline at end of file +RUN pip install . \ No newline at end of file