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

Commit

Permalink
Merge branch '4-write-a-basic-test-simulation-and-user-guide-for-sphe…
Browse files Browse the repository at this point in the history
…rical-harmonics-use' into 3-convert-the-basic-installation-instructions-from-the-readmemd-file-to-the-first-section-of-the-getting-started-section-of-the-documentation
  • Loading branch information
daminton committed Feb 29, 2024
2 parents a56dd5d + 4b3f764 commit 259314b
Show file tree
Hide file tree
Showing 81 changed files with 5,733 additions and 2,387 deletions.
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ swiftest-*
__pycache__*
_cmake*
_dependencies
!SHTOOLS
!SHTOOLS/**


#Documentation
!.readthedocs.yaml
!docs/
!docs/**/*
docs/_build/
!docs/_build/
docs/_build/**/*
docs/generated/
docs/generated/**/*
Expand All @@ -64,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
2 changes: 1 addition & 1 deletion README_tables/add_body_kwargs.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| ```Gmass``` | Gravitational mass value(s) of bodies. Only for massive bodies. Only ```mass``` **OR** ```Gmass``` may be set. | float or array-like of floats
| ```radius``` | Radius value(s) of bodies. Only for massive bodies. | float or array-like of floats
| ```rhill``` | Hill Radius value(s) of bodies. Only for massive bodies. | float or array-like of floats
| ```rot``` | Rotation rate vector(s) of bodies in degrees/sec. Only for massive bodies. Only used if ```rotation``` is set to ```True```. | (n,3) array-like of floats
| ```rot``` | Rotation rate vector(s) of bodies in degrees/TU. Only for massive bodies. Only used if ```rotation``` is set to ```True```. | (n,3) array-like of floats
| ```Ip``` | Principal axes moments of inertia vector(s) of bodies. Only for massive bodies. Only used if ```rotation``` is set to ```True```. | (n,3) array-like of floats
| ```J2``` | The unitless value of the spherical harmonic term equal to J2*R^2 where R is the radius of the central body. | float or array-like of floats
| ```J4``` | The unitless value of the spherical harmonic term equal to J4*R^4 where R is the radius of the central body. | float or array-like of floats
1 change: 1 addition & 0 deletions SHTOOLS
Submodule SHTOOLS added at 8b74bb
27 changes: 21 additions & 6 deletions buildscripts/_build_getopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ SCRIPT_DIR=$(realpath $(dirname $0))
ROOT_DIR=$(realpath ${SCRIPT_DIR}/..)

# Get platform and architecture
read -r OS ARCH < <($SCRIPT_DIR/get_platform.sh)
OS=$(uname -s)
ARCH=$(uname -m)

# Parse arguments
USTMT="Usage: ${0} [-d /path/to/dependency/source] [-p /prefix/path] [-m MACOSX_DEPLOYMENT_TARGET]"
Expand Down Expand Up @@ -53,8 +54,22 @@ BUILD_DIR=${BUILD_DIR:-"${HOME}/Downloads"}
PREFIX=${PREFIX:-"/usr/local"}
DEPENDENCY_DIR=${DEPENDENCY_DIR:-${BUILD_DIR}}

mkdir -p ${DEPENDENCY_DIR}
mkdir -p ${PREFIX}/lib
mkdir -p ${PREFIX}/include
mkdir -p ${PREFIX}/share
mkdir -p ${PREFIX}/bin

case $OS in
Linux*)
. ${SCRIPT_DIR}/set_environment_linux.sh
;;
MacOSX|Darwin)
. ${SCRIPT_DIR}/set_environment_macos.sh
;;

*)
printf "Unknown compiler type: ${OS}\n"
echo "Valid options are Linux, MacOSX, or Darwin"
printf $USTMT
exit 1
;;
esac


mkdir -p ${DEPENDENCY_DIR}
1 change: 1 addition & 0 deletions buildscripts/build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ ${SCRIPT_DIR}/build_zlib.sh ${ARGS}
${SCRIPT_DIR}/build_hdf5.sh ${ARGS}
${SCRIPT_DIR}/build_netcdf-c.sh ${ARGS}
${SCRIPT_DIR}/build_netcdf-fortran.sh ${ARGS}
${SCRIPT_DIR}/build_shtools.sh ${ARGS}

printf "\n"
printf "*********************************************************\n"
Expand Down
13 changes: 6 additions & 7 deletions buildscripts/build_hdf5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
# You should have received a copy of the GNU General Public License along with Swiftest.
# If not, see: https://www.gnu.org/licenses.

HDF5_VER="1_14_2"
ZLIB_VER="1.3"
HDF5_VER="1_14_3"
ZLIB_VER="1.3.1"

SCRIPT_DIR=$(realpath $(dirname $0))
set -a
Expand All @@ -27,7 +27,7 @@ printf "*********************************************************\n"
printf "* STARTING DEPENDENCY BUILD *\n"
printf "*********************************************************\n"
printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n"
printf "Installing to ${PREFIX}\n"
printf "Installing to ${HDF5_ROOT}\n"
printf "\n"

printf "*********************************************************\n"
Expand Down Expand Up @@ -60,13 +60,11 @@ printf "CPPFLAGS: ${CPPFLAGS}\n"
printf "CPATH: ${CPATH}\n"
printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n"
printf "LDFLAGS: ${LDFLAGS}\n"
printf "INSTALL_PREFIX: ${HDF5_ROOT}\n"
printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/hdfsrc

HDF5_ROOT=${PREFIX}
ZLIB_ROOT=${PREFIX}
SZIP_ROOT=${PREFIX}
if [ $OS = "MacOSX" ]; then
ZLIB_LIBRARY="${ZLIB_ROOT}/lib/libz.dylib"
else
Expand All @@ -85,6 +83,7 @@ ARGLIST="-DCMAKE_INSTALL_PREFIX:PATH=${HDF5_ROOT} \
-DHDF5_BUILD_FORTRAN:BOOL=OFF \
-DHDF5_BUILD_EXAMPLES:BOOL=ON \
-DBUILD_TESTING:BOOL=ON \
-DBUILD_STATIC_LIBS:BOOL=OFF \
-DHDF5_BUILD_JAVA:BOOL=OFF"

if [ $OS = "MacOSX" ]; then
Expand All @@ -94,7 +93,7 @@ fi
cmake -B build -C ./config/cmake/cacheinit.cmake -G Ninja ${ARGLIST} .

cmake --build build -j${NPROC} --config Release
if [ -w ${PREFIX} ]; then
if [ -w ${HDF5_ROOT} ]; then
cmake --install build
else
sudo cmake --install build
Expand Down
9 changes: 4 additions & 5 deletions buildscripts/build_netcdf-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ printf "*********************************************************\n"
printf "* STARTING DEPENDENCY BUILD *\n"
printf "*********************************************************\n"
printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n"
printf "Installing to ${PREFIX}\n"
printf "Installing to ${NCDIR}\n"
printf "\n"

NC_VER="4.9.2"
Expand All @@ -48,16 +48,15 @@ printf "CPATH: ${CPATH}\n"
printf "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}\n"
printf "LDFLAGS: ${LDFLAGS}\n"
printf "HDF5_ROOT: ${HDF5_ROOT}\n"
printf "INSTALL_PREFIX: ${NCDIR}\n"
printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/netcdf-c-*
NCDIR="${PREFIX}"
ZLIB_ROOT=${PREFIX}
cmake -B build -S . -G Ninja \
-DCMAKE_BUILD_TYPE:STRING="Release" \
-DHDF5_DIR:PATH=${HDF5_ROOT}/cmake \
-DHDF5_ROOT:PATH=${HDF5_ROOT} \
-DCMAKE_FIND_ROOT_PATH:PATH="${PREFIX}" \
-DCMAKE_FIND_ROOT_PATH:PATH="${NCDIR}" \
-DCMAKE_INSTALL_PREFIX:STRING="${NCDIR}" \
-DENABLE_DAP:BOOL=OFF \
-DENABLE_BYTERANGE:BOOL=OFF \
Expand All @@ -68,7 +67,7 @@ cmake -B build -S . -G Ninja \
-DENABLE_REMOTE_FORTRAN_BOOTSTRAP:BOOL=ON

cmake --build build -j${NPROC}
if [ -w ${PREFIX} ]; then
if [ -w ${NCDIR} ]; then
cmake --install build
else
sudo cmake --install build
Expand Down
5 changes: 2 additions & 3 deletions buildscripts/build_netcdf-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ printf "*********************************************************\n"
printf "* STARTING DEPENDENCY BUILD *\n"
printf "*********************************************************\n"
printf "Using ${OS} compilers:\nFC: ${FC}\nCC: ${CC}\nCXX: ${CXX}\n"
printf "Installing to ${PREFIX}\n"
printf "Installing to ${NFDIR}\n"
printf "\n"

NF_VER="4.6.1"
Expand All @@ -49,7 +49,6 @@ printf "LDFLAGS: ${LDFLAGS}\n"
printf "*********************************************************\n"

cd ${DEPENDENCY_DIR}/netcdf-fortran-*
NFDIR="${PREFIX}"
NCLIBDIR=$(${NCDIR}/bin/nc-config --libdir)
if [ $OS = "MacOSX" ]; then
netCDF_LIBRARIES="${NCLIBDIR}/libnetcdf.dylib"
Expand All @@ -62,7 +61,7 @@ cmake -B build -S . -G Ninja \
-DCMAKE_INSTALL_PREFIX:PATH=${NFDIR} \
-DCMAKE_INSTALL_LIBDIR="lib"
cmake --build build -j${NPROC}
if [ -w ${PREFIX} ]; then
if [ -w ${NFDIR} ]; then
cmake --install build
else
sudo cmake --install build
Expand Down
Loading

0 comments on commit 259314b

Please sign in to comment.