Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Merge branch 'oblate_coord_rot' into debug
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Mar 1, 2024
2 parents d9d646f + cc8d4fe commit 80bf131
Show file tree
Hide file tree
Showing 91 changed files with 6,359 additions and 3,154 deletions.
13 changes: 7 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ swiftest-*
__pycache__*
_cmake*
_dependencies
!SHTOOLS
!SHTOOLS/**


#Documentation
!.readthedocs.yaml
!docs/
!docs/**/*
docs/_build/
!docs/_build/
docs/_build/**/*
docs/generated/
docs/generated/**/*
docs/**/*.DS_Store
docs/**/*.swp
docs/
!docs/_static/**/*.png
!docs/_static/**/*.svg
**/*.ai
Expand All @@ -65,14 +66,14 @@ docs/_static/fortran_docs/*/**
!environment.yml
!.dockerignore

swiftest/_bindings.cpython*
bin/
build/*
hdf5-*
netcdf-c-*
netcdf-fortran-*
zlib-*
lib*

actions-runner*

env/**
venv/**

sandbox/**
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "SHTOOLS"]
path = SHTOOLS
url = https://github.com/profminton/SHTOOLS
64 changes: 42 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
##################################################
# Define the project and the depencies that it has
##################################################
CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0...3.27.1)
CMAKE_MINIMUM_REQUIRED(VERSION 3.23.1...3.28.3)
SET(SKBUILD_PROJECT_NAME "swiftest" CACHE STRING "Name of project set by scikit-build")

# Get version stored in text file
Expand All @@ -28,27 +28,44 @@ ELSE()
CMAKE_POLICY(SET CMP0148 OLD)
ENDIF ()

# The following section is modified from Numpy f2py documentation
IF(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
MESSAGE(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n")
ENDIF()

# Set some options the user may choose
OPTION(USE_COARRAY "Use Coarray Fortran for parallelization of test particles" OFF)
OPTION(USE_OPENMP "Use OpenMP for parallelization" ON)
OPTION(USE_SIMD "Use SIMD vectorization" ON)
OPTION(BUILD_SHARED_LIBS "Build using shared libraries" ON)

# Define the paths to the source code and python files
SET(SRC "${CMAKE_SOURCE_DIR}/src")
SET(PY "${CMAKE_SOURCE_DIR}/swiftest")

# Make sure paths are correct for Unix or Windows style
FILE(TO_CMAKE_PATH ${SRC} SRC)
FILE(TO_CMAKE_PATH ${PY} PY)

INCLUDE(GNUInstallDirs)
IF (SKBUILD)
SET(INSTALL_BINDIR ${SKBUILD_PLATLIB_DIR}/${SKBUILD_PROJECT_NAME})
SET(INSTALL_LIBDIR ${SKBUILD_PLATLIB_DIR}/${SKBUILD_PROJECT_NAME})
SET(INSTALL_INCLUDEDIR ${INSTALL_LIBDIR})
SET(INSTALL_BINDIR ${SKBUILD_SCRIPTS_DIR})
SET(INSTALL_LIBDIR ${SKBUILD_DATA_DIR}/lib)
SET(INSTALL_INCLUDEDIR ${SKBUILD_HEADERS_DIR})
SET(INSTALL_PYPROJ ${SKBUILD_PLATLIB_DIR}/${SKBUILD_PROJECT_NAME})
IF (APPLE)
SET(CMAKE_INSTALL_RPATH "@loader_path")
SET(CMAKE_INSTALL_RPATH "@loader_path;${CMAKE_BINARY_DIR}/bin")
ELSEIF (LINUX)
SET(CMAKE_INSTALL_RPATH $ORIGIN)
SET(CMAKE_INSTALL_RPATH "@ORIGIN;${CMAKE_BINARY_DIR}/bin")
ENDIF ()
ELSE ()
SET(INSTALL_PYPROJ ${PY})
SET(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
SET(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
ENDIF ()

SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Have the .mod files placed in the include folder
SET(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)
Expand All @@ -57,6 +74,7 @@ ELSE()
FILE(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" LOCAL_MODULE_PATH)
LIST(APPEND CMAKE_MODULE_PATH ${LOCAL_MODULE_PATH})

# Add in the external dependency libraries
IF (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
SET(COMPILER_OPTIONS "Intel" CACHE STRING "Compiler identified as Intel")
ELSEIF (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
Expand All @@ -65,10 +83,22 @@ ELSE()
MESSAGE(FATAL_ERROR "Compiler ${CMAKE_Fortran_COMPILER_ID} not recognized!")
ENDIF ()

# The following section is modified from Numpy f2py documentation
IF(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
MESSAGE(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n")
IF (COMPILER_OPTIONS STREQUAL "GNU")
IF (APPLE)
SET(BLA_VENDOR "Apple" CACHE STRING "BLAS vendor")
ELSE ()
SET(BLA_VENDOR "OpenBLAS" CACHE STRING "BLAS vendor")
ENDIF ()
ELSEIF (COMPILER_OPTIONS STREQUAL "INTEL")
SET(BLA_VENDOR "Intel10_64lp" CACHE STRING "BLAS vendor")
ENDIF()
SET(BLA_STATIC ON)
FIND_PACKAGE(BLAS REQUIRED)
FIND_PACKAGE(LAPACK REQUIRED)
FIND_PACKAGE(FFTW3 REQUIRED)
FIND_PACKAGE(SHTOOLS REQUIRED)



FIND_PACKAGE(NETCDF_Fortran REQUIRED)
IF (MSVC)
Expand All @@ -85,9 +115,6 @@ ELSE()
FIND_PACKAGE(Python COMPONENTS Interpreter Development.Module REQUIRED)


SET(SRC "${CMAKE_SOURCE_DIR}/src")
SET(PY "${CMAKE_SOURCE_DIR}/swiftest")

#####################################
# Tell how to install this executable
#####################################
Expand All @@ -99,11 +126,6 @@ ELSE()
SET(CMAKE_INSTALL_PREFIX /usr/local CACHE PATH "Path for install")
ENDIF()


# Make sure paths are correct for Unix or Windows style
FILE(TO_CMAKE_PATH ${SRC} SRC)
FILE(TO_CMAKE_PATH ${PY} PY)

# Set the name of the swiftest library
SET(SWIFTEST_LIBRARY ${SKBUILD_PROJECT_NAME})

Expand All @@ -113,13 +135,11 @@ ELSE()
ENDIF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
INCLUDE(SetParallelizationLibrary)

IF (COMPILER_OPTIONS STREQUAL "Intel" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
INCLUDE(SetMKL)
ENDIF ()
INCLUDE(SetSwiftestFlags)



IF (NOT BUILD_SHARED_LIBS)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()
# The source for the SWIFTEST binary and have it placed in the bin folder
ADD_SUBDIRECTORY(${SRC} ${CMAKE_INSTALL_BINDIR})
ADD_SUBDIRECTORY(${PY})
Expand Down
67 changes: 15 additions & 52 deletions Dockerfile.GNU-Linux
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
# dynamically.

# This build target compiles all dependencies and the swiftest driver itself
FROM continuumio/miniconda3:23.5.2-0 as build-deps
FROM ubuntu:focal-20240123 as build-deps
SHELL ["/bin/bash", "--login", "-c"]
ENV PATH="/opt/conda/bin:${PATH}"
WORKDIR /swiftest

ENV INSTALL_DIR=/usr/local
Expand All @@ -29,69 +28,29 @@ ENV LD_LIBRARY_PATH="${INSTALL_DIR}/lib"
ENV LDFLAGS="-L${INSTALL_DIR}/lib"
ENV CPPFLAGS="-I${INSTALL_DIR}/include"

COPY ./buildscripts/swiftest-build-env.yml ./
COPY ./buildscripts/fetch_dependencies.sh ./
RUN ./fetch_dependencies.sh -d ./
COPY ./buildscripts/ ./buildscripts/
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
m4 && \
rm -rf /var/lib/apt/lists/* && \
buildscripts/build_dependencies.sh -p ${INSTALL_DIR}

# Get the HDF5, NetCDF-C, and NetCDF-Fortran libraries
RUN conda update --all -y && \
conda install conda-libmamba-solver -y && \
conda config --set solver libmamba && \
conda env create --file swiftest-build-env.yml --name swiftest-build-env && \
conda init bash && \
echo "conda activate swiftest-build-env" >> ~/.bashrc

RUN cd zlib-* && \
./configure \
--prefix=${INSTALL_DIR} \
--static && \
make && make install && \
cd ../hdf5-* && \
./configure \
--prefix=${INSTALL_DIR} \
--disable-shared \
--enable-build-mode=production \
--disable-fortran \
--disable-java \
--disable-cxx \
--with-zlib=${INSTALL_DIR} && \
make && make install && \
cd ../netcdf-c-* && \
./configure \
--prefix=${INSTALL_DIR} \
--disable-shared \
--disable-dap \
--disable-libxml2 \
--disable-byterange && \
make && make install && \
cd ../netcdf-fortran-* && \
export CFLAGS="-fPIC" && \
export FCFLAGS="${CFLAGS}" && \
export FFLAGS=${CFLAGS} && \
export LIBS=$(${INSTALL_DIR}/bin/nc-config --libs --static) && \
./configure --disable-shared --prefix=${NFDIR} && \
make && make install

FROM continuumio/miniconda3:23.5.2-0 as build-swiftest
FROM ubuntu:focal-20240123 as build-swiftest
SHELL ["/bin/bash", "--login", "-c"]
ENV SHELL="/bin/bash"
WORKDIR /swiftest

# Copy build artifacts over to the swiftest package builder stage
ENV INSTALL_DIR=/usr/local
COPY --from=build-deps ${INSTALL_DIR}/ ${INSTALL_DIR}/
COPY --from=build-deps /opt/conda/envs/ /opt/conda/envs/
COPY --from=build-deps /root/.bashrc /root/

# Compile the Swiftest project
COPY ./cmake/ ./cmake/
COPY ./pyproject.toml ./
COPY ./src/ ./src/
COPY ./swiftest/ ./swiftest/
COPY ./tests/ ./tests/
COPY ./CMakeLists.txt ./
COPY ./setup.py ./
COPY ./environment.yml ./
COPY ./pyproject.toml ./
COPY ./requirements.txt ./
COPY ./version.txt ./

# Generate the build environment in conda
Expand All @@ -107,4 +66,8 @@ RUN export NFCFG="${INSTALL_DIR}/bin/nf-config" && \

#Export the generated wheel file to the host machine
FROM scratch as export-wheel
COPY --from=build-swiftest /swiftest/dist/ ./
COPY --from=build-swiftest /swiftest/dist/ ./

FROM scratch as export-driver
COPY --from=build-swiftest /swiftest/build/bin/swiftest_driver ./
COPY --from=build-swiftest /swiftest/build/bin/libswiftest.so ./
47 changes: 8 additions & 39 deletions Dockerfile.Intel
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,12 @@ ENV LD_LIBRARY_PATH="${INSTALL_DIR}/lib"
ENV LDFLAGS="-L${INSTALL_DIR}/lib"
ENV CPPFLAGS="-I${INSTALL_DIR}/include"

COPY ./buildscripts/fetch_dependencies.sh ./
COPY ./buildscripts/ ./buildscripts/
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
m4 && \
rm -rf /var/lib/apt/lists/* && \
./fetch_dependencies.sh -d ./

# Get the HDF5, NetCDF-C, and NetCDF-Fortran libraries
RUN cd zlib-* && \
./configure \
--prefix=${INSTALL_DIR} \
--static && \
make && make install && \
cd ../hdf5-* && \
./configure \
--prefix=${INSTALL_DIR} \
--disable-shared \
--enable-build-mode=production \
--disable-fortran \
--disable-java \
--disable-cxx \
--with-zlib=${INSTALL_DIR} && \
make && make install && \
cd ../netcdf-c-* && \
./configure \
--prefix=${INSTALL_DIR} \
--disable-shared \
--disable-dap \
--disable-libxml2 \
--disable-byterange && \
make && make install
RUN cd netcdf-fortran-* && \
export CFLAGS="-fPIC" && \
export FCFLAGS="${CFLAGS} -standard-semantics" && \
export FFLAGS=${CFLAGS} && \
export LIBS=$(${INSTALL_DIR}/bin/nc-config --libs --static) && \
./configure --disable-shared --prefix=${NFDIR} && \
make && make install
buildscripts/build_dependencies.sh -p ${INSTALL_DIR}

FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build-swiftest
ENV SCRIPT_DIR="buildscripts"
Expand All @@ -98,18 +66,15 @@ ENV LD_LIBRARY_PATH="${INSTALL_DIR}/lib:${LD_LIBRARY_PATH}"
COPY --from=build-deps ${INSTALL_DIR}/ ${INSTALL_DIR}/

# Compile the Swiftest project
COPY ./requirements.txt ./
COPY ./environment.yml ./
COPY ./cmake/ ./cmake/
COPY ./pyproject.toml ./
COPY ./setup.py ./
COPY ./src/ ./src/
COPY ./swiftest/ ./swiftest/
COPY ./tests/ ./tests/
COPY ./CMakeLists.txt ./
COPY ./version.txt ./
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install python3-pip python3.8-venv -y

# Generate the build environment in conda
ENV PIP_ROOT_USER_ACTION=ignore
ENV LDFLAGS="-L${INSTALL_DIR}/lib"
ENV CFLAGS="-fPIC"
Expand All @@ -123,4 +88,8 @@ RUN export NFCFG="${INSTALL_DIR}/bin/nf-config" && \

#Export the generated wheel file to the host machine
FROM scratch as export-wheel
COPY --from=build-swiftest /swiftest/dist/ ./
COPY --from=build-swiftest /swiftest/dist/ ./

FROM scratch as export-driver
COPY --from=build-swiftest /swiftest/build/bin/swiftest_driver ./
COPY --from=build-swiftest /swiftest/build/bin/libswiftest.so ./
Loading

0 comments on commit 80bf131

Please sign in to comment.