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

Commit

Permalink
Merge branch 'master' into debug
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Dec 20, 2023
2 parents c10137a + 4301f6b commit c365506
Show file tree
Hide file tree
Showing 90 changed files with 1,950 additions and 1,357 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ _dependencies
!.readthedocs.yaml
!docs/
!docs/**/*
docs/**/*.ai
docs/_build/
docs/_build/**/*
docs/generated/
docs/generated/**/*
docs/**/*.DS_Store
docs/**/*.swp


docs/
!docs/_static/**/*.png
!docs/_static/**/*.svg
**/*.ai
docs/_static/fortran_docs/
docs/_static/fortran_docs/*/**
!fortran_docs.md
!README_figs/*

#Docker and Singularity files
Expand Down
12 changes: 6 additions & 6 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

apt_packages:
- graphviz
jobs:
pre_build:
- ford fortran_docs.md
- DOC_BUILD=1 pip install .
python:
install:
- requirements: docs/requirements.txt
193 changes: 100 additions & 93 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,111 +13,118 @@
##################################################
CMAKE_MINIMUM_REQUIRED(VERSION 3.6.0...3.27.1)
SET(SKBUILD_PROJECT_NAME "swiftest" CACHE STRING "Name of project set by scikit-build")
SET(SKBUILD_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/bin" CACHE STRING "Install location of binary executable")

# Get version stored in text file
FILE(READ "version.txt" VERSION)
PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran VERSION ${VERSION})

# Use the old method to get Python packages, as that's what scikit-build uses
IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27")
CMAKE_POLICY(SET CMP0148 OLD)
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)

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})
IF (APPLE)
SET(CMAKE_INSTALL_RPATH "@loader_path")
ELSEIF (LINUX)
SET(CMAKE_INSTALL_RPATH $ORIGIN)
# Check if DOC_BUILD environment variable is set and skip build if it is
IF (DEFINED ENV{DOC_BUILD})
MESSAGE(STATUS "DOC_BUILD is set. Skipping build process.")
PROJECT(${SKBUILD_PROJECT_NAME} VERSION ${VERSION})
ELSE()
SET(SKBUILD_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/bin" CACHE STRING "Install location of binary executable")
PROJECT(${SKBUILD_PROJECT_NAME} LANGUAGES C Fortran VERSION ${VERSION})
# Use the old method to get Python packages, as that's what scikit-build uses
IF (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.27")
CMAKE_POLICY(SET CMP0148 OLD)
ENDIF ()
ELSE ()
SET(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
SET(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
ENDIF ()

# Have the .mod files placed in the include folder
SET(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)

# Add our local modules to the module ldpath
FILE(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" LOCAL_MODULE_PATH)
LIST(APPEND CMAKE_MODULE_PATH ${LOCAL_MODULE_PATH})

IF (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
SET(COMPILER_OPTIONS "Intel" CACHE STRING "Compiler identified as Intel")
ELSEIF (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
SET(COMPILER_OPTIONS "GNU" CACHE STRING "Compiler identified as gfortran")
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")
ENDIF()

FIND_PACKAGE(NETCDF_Fortran REQUIRED)
IF (MSVC)
FIND_PACKAGE(HDF5 NAMES hdf5 COMPONENTS C HL REQUIRED CONFIG)
MESSAGE(STATUS "HDF5_FOUND: ${HDF5_FOUND}")
MESSAGE(STATUS "HDF5_VERSION: ${HDF5_VERSION}")
MESSAGE(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}")
MESSAGE(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}")
ELSE ()
FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
ENDIF ()

# Ensure scikit-build modules
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
#####################################
IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
SET(CMAKE_INSTALL_PREFIX "C:\\Program Files\\swiftest")
FILE(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX} CMAKE_INSTALL_PREFIX)
SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Path for install")
ELSE()
SET(CMAKE_INSTALL_PREFIX /usr/local CACHE PATH "Path for install")
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)

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})
IF (APPLE)
SET(CMAKE_INSTALL_RPATH "@loader_path")
ELSEIF (LINUX)
SET(CMAKE_INSTALL_RPATH $ORIGIN)
ENDIF ()
ELSE ()
SET(INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR})
SET(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
SET(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
ENDIF ()

# Have the .mod files placed in the include folder
SET(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod)

# Add our local modules to the module ldpath
FILE(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules" LOCAL_MODULE_PATH)
LIST(APPEND CMAKE_MODULE_PATH ${LOCAL_MODULE_PATH})

IF (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
SET(COMPILER_OPTIONS "Intel" CACHE STRING "Compiler identified as Intel")
ELSEIF (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
SET(COMPILER_OPTIONS "GNU" CACHE STRING "Compiler identified as gfortran")
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")
ENDIF()

FIND_PACKAGE(NETCDF_Fortran REQUIRED)
IF (MSVC)
FIND_PACKAGE(HDF5 NAMES hdf5 COMPONENTS C HL REQUIRED CONFIG)
MESSAGE(STATUS "HDF5_FOUND: ${HDF5_FOUND}")
MESSAGE(STATUS "HDF5_VERSION: ${HDF5_VERSION}")
MESSAGE(STATUS "HDF5_LIBRARIES: ${HDF5_LIBRARIES}")
MESSAGE(STATUS "HDF5_INCLUDE_DIRS: ${HDF5_INCLUDE_DIRS}")
ELSE ()
FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
ENDIF ()

# Make sure paths are correct for Unix or Windows style
FILE(TO_CMAKE_PATH ${SRC} SRC)
FILE(TO_CMAKE_PATH ${PY} PY)
# Ensure scikit-build modules
FIND_PACKAGE(Python COMPONENTS Interpreter Development.Module REQUIRED)

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

# Determine compiler options
IF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
MESSAGE(FATAL_ERROR "Fortran compiler does not support F90")
ENDIF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
INCLUDE(SetParallelizationLibrary)
SET(SRC "${CMAKE_SOURCE_DIR}/src")
SET(PY "${CMAKE_SOURCE_DIR}/swiftest")

IF (COMPILER_OPTIONS STREQUAL "Intel" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
INCLUDE(SetMKL)
ENDIF ()
INCLUDE(SetSwiftestFlags)
#####################################
# Tell how to install this executable
#####################################
IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
SET(CMAKE_INSTALL_PREFIX "C:\\Program Files\\swiftest")
FILE(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX} CMAKE_INSTALL_PREFIX)
SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Path for install")
ELSE()
SET(CMAKE_INSTALL_PREFIX /usr/local CACHE PATH "Path for install")
ENDIF()

# The source for the SWIFTEST binary and have it placed in the bin folder
ADD_SUBDIRECTORY(${SRC} ${CMAKE_INSTALL_BINDIR})
ADD_SUBDIRECTORY(${PY})

# 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})

# Determine compiler options
IF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90)
MESSAGE(FATAL_ERROR "Fortran compiler does not support F90")
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)



# The source for the SWIFTEST binary and have it placed in the bin folder
ADD_SUBDIRECTORY(${SRC} ${CMAKE_INSTALL_BINDIR})
ADD_SUBDIRECTORY(${PY})

ENDIF()
# Add a distclean target to the Makefile
ADD_CUSTOM_TARGET(distclean
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_SOURCE_DIR}/distclean.cmake"
Expand Down
2 changes: 2 additions & 0 deletions distclean.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ELSE()
ENDIF()

SET(CIBW_DIR "_skbuild" "swiftest.egg-info" "_cmake_test_compile")
SET(DOC_DIR "docs/_build" "docs/_static/fortran_docs")

MACRO(GET_PARENT_DIRECTORIES search_string return_list grandparents)
FILE(GLOB_RECURSE new_list ${search_string})
Expand Down Expand Up @@ -66,6 +67,7 @@ SET(DEL ${TOPDIRECTORIES}
${CMAKETESTING}
${CMAKETESTFILES}
${CIBW_DIR}
${DOC_DIR}
)

# If we are not in the build dir, delete that as well
Expand Down
Loading

0 comments on commit c365506

Please sign in to comment.