diff --git a/.gitignore b/.gitignore index 319d66928..49b1a5835 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,12 @@ src/exp src/user/CylindricalDisk.cc src/user/EllipsoidForce.cc src/user/SLSphere.cc + +# Python generated files +*.egg-info +_skbuild +build.log +__pycache__ + +# Needed for cmake configs +!*Config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index dbede3fe3..22b0c83f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,64 +10,77 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) -# Compiler flags. Not all tested thoroughly... -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # using Clang - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") -elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - # using GCC -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - # using intel - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qno-offload") -elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - # using Visual Studio C++ -endif() - -# Required compiler features -add_compile_options(-D_REENTRANT) +# Search extern first +list(PREPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/extern ) +# Build options +option(BUILD_COMMON_LIBRARIES "Build the exputil and expcoefs libraries" ON) +option(INSTALL_HEADERS "Install headers for exputil and expcoefs" OFF) +option(INSTALL_CMAKE_FIND "Installs the Cmake find_package helpers" OFF) +option(ENABLE_NBODY "Enable EXP n-body" ON) +option(ENABLE_PYEXP "Enable the Python bindings" ON) +option(ENABLE_PNG "Enable PNG graphics support" OFF) +option(ENABLE_CUDA "Enable CUDA" OFF) +option(ENABLE_SLURM "Enable SLURM checkpointing support" OFF) +option(ENABLE_XDR "Enable RPC/XDR support for Tipsy standard" OFF) +option(ENABLE_VTK "Configure VTK if available" OFF) +option(ENABLE_CUDA_SINGLE "Use real*4 instead of real*8 for CUDA" OFF) +option(ENABLE_DSMC "Enable DSMC module" OFF) +option(ENABLE_USER "Enable basic user modules" ON) +option(ENABLE_SLCHECK "Enable *careful* Sturm-Liouville solutions" ON) +option(ENABLE_TESTS "Enable build tests for EXP, pyEXP and helpers" ON) +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) +option(BUILD_DOCS "Build documentation" OFF) +option(BUILD_UTILS "Build the utility executables" ON) +option(USE_SUBMODULES "Pull submodules from the EXP git distribution." ON) +option(ENABLE_COMPILER_WARNINGS "Add extra warnings to compile time" OFF) + +if(ENABLE_COMPILER_WARNINGS) + set(WARN_OPTIONS + $<$,$>:-Wall> + $<$,$>:-Wextra> + $<$,$>:-Wpedantic> + $<$,$>:-pedantic> + ) +endif() + +set(DEFAULT_COMPILER_OPTIONS + -D_REENTRANT + $<$:-stdlib=libc++> + $<$:-qno-offload> + ) + +add_compile_options(${DEFAULT_COMPILER_OPTIONS} ${WARN_OPTIONS}) + +# If USE_SUBMODULES is ON # Check and enforce that we are a git repository. Necessary for # submodules to work correctly. +if(USE_SUBMODULES) if(EXISTS "${PROJECT_SOURCE_DIR}/.git") message(STATUS "Checking that we are a git repository - good") else() message(STATUS "Checking that we are a git repository - NO") message(SEND_ERROR "You need to 'git clone ${CMAKE_PROJECT_HOMEPAGE_URL}'. Please don't use the zip download.") endif() - -# Build options -option(ENABLE_NBODY "Enable EXP n-body" ON) -option(ENABLE_PYEXP "Enable the Python bindings" ON) -option(ENABLE_PNG "Enable PNG graphics support" FALSE) -option(ENABLE_CUDA "Enable CUDA" FALSE) -option(ENABLE_SLURM "Enable SLURM checkpointing support" FALSE) -option(ENABLE_XDR "Enable RPC/XDR support for Tipsy standard" FALSE) -option(ENABLE_VTK "Configure VTK if available" FALSE) -option(ENABLE_CUDA_SINGLE "Use real*4 instead of real*8 for CUDA" FALSE) -option(ENABLE_USER "Enable basic user modules" ON) -option(ENABLE_SLCHECK "Enable *careful* Sturm-Liouville solutions" TRUE) -option(ENABLE_TESTS "Enable build tests for EXP, pyEXP and helpers" ON) -option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -option(BUILD_DOCS "Build documentation" OFF) +endif() # Set mpirun launcher for CTest - set(EXP_MPI_LAUNCH "mpirun" CACHE STRING "Command to run an MPI application (for unit tests only)") # Find newest version if multiple versions are available - set(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL) set(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC) # Package support - find_package(MPI REQUIRED COMPONENTS C CXX) find_package(OpenMP) find_package(FFTW) find_package(HDF5 COMPONENTS C CXX HL REQUIRED) -find_package(TIRPC) # Check for alternative Sun rpc support find_package(Eigen3 REQUIRED) -find_package(PNG) + +if(ENABLE_PNG) + find_package(PNG REQUIRED) +endif() # Check for FE include(FEENABLE) @@ -160,6 +173,7 @@ endif() # Only include RPC support if the installer wants XDR if(ENABLE_XDR) + find_package(TIRPC) # Check for alternative Sun rpc support if(TIRPC_FOUND OR HAVE_RPC_TYPES) set(HAVE_XDR TRUE CACHE BOOL "We have an XDR implementation") message(STATUS "We have an XDR implementation; Tipsy standard files will be supported.") @@ -179,35 +193,37 @@ set(CUDA_EXP_DATTRIB "4" CACHE STRING "Number of real particle attributes for Cuda particle structure") add_compile_definitions(DATTRIB_CUDA=${CUDA_EXP_DATTRIB}) -# Get the current working branch -execute_process( - COMMAND git rev-parse --abbrev-ref HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_BRANCH - OUTPUT_STRIP_TRAILING_WHITESPACE -) - # Git submodule updates -execute_process( - COMMAND git submodule update --init --recursive - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE GIT_SUBMOD_RESULT -) +if(USE_SUBMODULES) + # Get the current working branch + execute_process( + COMMAND git rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + execute_process( + COMMAND git submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT + ) + + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init --recursive failed ${GIT_SUBMOD_RESULT}, please checkout submodules") + else() + message(STATUS "Submodules updated successfully - good") + endif() -if(NOT GIT_SUBMOD_RESULT EQUAL "0") - message(FATAL_ERROR "git submodule update --init --recursive failed ${GIT_SUBMOD_RESULT}, please checkout submodules") -else() - message(STATUS "Submodules updated successfully - good") + # Get the latest abbreviated commit hash of the working branch + execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) endif() -# Get the latest abbreviated commit hash of the working branch -execute_process( - COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE GIT_COMMIT - OUTPUT_STRIP_TRAILING_WHITESPACE -) - # Get the build date execute_process( COMMAND date +%Y-%m-%d\ %H:%M:%S\ %Z @@ -216,14 +232,21 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -include_directories(${PROJECT_SOURCE_DIR}/extern/yaml-cpp/include) -include_directories(${PROJECT_SOURCE_DIR}/extern/pybind11/include) - -# Report to the user -message("Configuring build for ${GIT_BRANCH}/${GIT_COMMIT} at ${COMPILE_TIME}") +if (USE_SUBMODULES) + message("Configuring build for ${GIT_BRANCH}/${GIT_COMMIT} at ${COMPILE_TIME}") + include_directories(${PROJECT_SOURCE_DIR}/extern/yaml-cpp/include) + add_subdirectory(extern/yaml-cpp) +else() + find_package(yaml-cpp REQUIRED) +endif() -add_subdirectory(extern/yaml-cpp) -add_subdirectory(extern/pybind11) +if (USE_SUBMODULES AND ENABLE_PYEXP) + message("Configuring pybind11 for ${GIT_BRANCH}/${GIT_COMMIT} at ${COMPILE_TIME}") + add_subdirectory(extern/pybind11) + include_directories(${PROJECT_SOURCE_DIR}/extern/pybind11/include) +elseif(ENABLE_PYEXP) + find_package(pybind11 CONFIG REQUIRED) +endif() # Set options for the HighFive git submodule in extern set(HIGHFIVE_EXAMPLES OFF CACHE BOOL "Do not build the examples") @@ -232,20 +255,33 @@ set(HIGHFIVE_USE_BOOST OFF CACHE BOOL "Do not use Boost in HighFive") set(HIGHFIVE_UNIT_TESTS OFF CACHE BOOL "Turn off internal testing for HighFIve") set(H5_USE_EIGEN TRUE CACHE BOOL "Eigen3 support in HighFive") -add_subdirectory(extern/HighFive EXCLUDE_FROM_ALL) +find_package(HighFive 3) + +if (NOT HighFive_FOUND) + add_subdirectory(extern/HighFive EXCLUDE_FROM_ALL) +endif() # Configure the remaining native subdirectories -add_subdirectory(exputil) -add_subdirectory(expui) +if (BUILD_COMMON_LIBRARIES) + add_subdirectory(exputil) + add_subdirectory(expui) +endif() + if (ENABLE_NBODY) add_subdirectory(src) endif() -add_subdirectory(utils) + +if (BUILD_UTILS) + add_subdirectory(utils) +endif() + if (ENABLE_PYEXP) add_subdirectory(pyEXP) endif() -add_subdirectory(extern/user-modules) +if (ENABLE_USER) + add_subdirectory(extern/user-modules) +endif() # Build the tests; set ENABLE_TEST=OFF to disable if(ENABLE_TESTS) @@ -254,12 +290,12 @@ if(ENABLE_TESTS) endif() # try to find pybind11 and build wrapper python module -find_package(Python3 COMPONENTS Interpreter Development) -message(STATUS "python3 include dirs: ${Python3_INCLUDE_DIRS}") +# find_package(Python3 COMPONENTS Interpreter Development) +# message(STATUS "python3 include dirs: ${Python3_INCLUDE_DIRS}") # Force installation of the yaml-cpp libraries -install(TARGETS yaml-cpp DESTINATION lib) +# install(TARGETS yaml-cpp DESTINATION lib) # Check for doxygen is the user wants web docs if (BUILD_DOCS) @@ -341,9 +377,7 @@ set(CMAKE_CXX_FLAGS_UBSAN CACHE STRING "Flags used by the C++ compiler during UndefinedBehaviourSanitizer builds." FORCE) -# Make the config_exp.h file in the build directory, add the build dir -# to the CMake include path. This allows for multiple configurations -# from the same source. -configure_file(${CMAKE_SOURCE_DIR}/config_cmake.h_in ${CMAKE_BINARY_DIR}/config_exp.h) -include_directories(${PROJECT_BINARY_DIR}) - +# Make the config_exp.h file in the build directory, +# to be added to the private include path by modules +configure_file(config_cmake.h_in ${CMAKE_BINARY_DIR}/config/config_exp.h) +configure_file(config_cmake.h_in ${CMAKE_BINARY_DIR}/config_exp.h) diff --git a/cmake/FindTIRPC.cmake b/cmake/FindTIRPC.cmake index 870de61f5..571821df3 100644 --- a/cmake/FindTIRPC.cmake +++ b/cmake/FindTIRPC.cmake @@ -19,56 +19,60 @@ # find_package(PkgConfig) -pkg_check_modules(PC_TIRPC QUIET TIRPC) +pkg_check_modules(TIRPC QUIET libtirpc) -find_path( - TIRPC_INCLUDE_DIR - NAMES - "rpc/types.h" - "tpc/xdr.h" - PATHS - ENV CPATH - ENV C_INCLUDE_PATH - ENV CPLUS_INCLUDE_PATH - ENV RPC_PATH - PATH_SUFFIXES - "include/tirpc" - DOC - "Path to the Sun RPC include directory" -) +if (NOT TIRPC_FOUND) + find_path( + TIRPC_INCLUDE_DIR + NAMES + "rpc/types.h" + "tpc/xdr.h" + PATHS + ENV CPATH + ENV C_INCLUDE_PATH + ENV CPLUS_INCLUDE_PATH + ENV RPC_PATH + PATH_SUFFIXES + "include/tirpc" + DOC + "Path to the Sun RPC include directory" + ) -find_library(TIRPC_LIBRARY - NAMES tirpc - PATH_SUFFIXES - "lib" - "lib64" - "lib/x86_64-linux-gnu" - DOC - "Path to the Sun RPC library" -) + find_library(TIRPC_LIBRARY + NAMES tirpc + PATH_SUFFIXES + "lib" + "lib64" + "lib/x86_64-linux-gnu" + DOC + "Path to the Sun RPC library" + ) -set(TIRPC_VERSION ${PC_TIRPC_VERSION}) + set(TIRPC_VERSION ${PC_TIRPC_VERSION}) -include(FindPackageHandleStandardArgs) + include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(TIRPC - FOUND_VAR - TIRPC_FOUND - REQUIRED_VARS - TIRPC_LIBRARY - TIRPC_INCLUDE_DIR - ) + find_package_handle_standard_args(TIRPC + FOUND_VAR + TIRPC_FOUND + REQUIRED_VARS + TIRPC_LIBRARY + TIRPC_INCLUDE_DIR + ) -if(TIRPC_FOUND) - set(TIRPC_LIBRARIES "${TIRPC_LIBRARY}") - set(TIRPC_INCLUDE_DIRS "${TIRPC_INCLUDE_DIR}") - set(TIRPC_DEFINITIONS "${PC_TIRPC_CFLAGS_OTHER}") + if(TIRPC_FOUND) + set(TIRPC_LIBRARIES "${TIRPC_LIBRARY}") + set(TIRPC_INCLUDE_DIRS "${TIRPC_INCLUDE_DIR}") + set(TIRPC_DEFINITIONS "${PC_TIRPC_CFLAGS_OTHER}") - add_library(TIRPC::TIRPC UNKNOWN IMPORTED) - set_target_properties(TIRPC::TIRPC - PROPERTIES - IMPORTED_LOCATION "${TIRPC_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${PC_TIRPC_CFLAGS_OTHER}" - INTERFACE_INCLUDE_DIRECTORIES "${TIRPC_INCLUDE_DIR}") + add_library(TIRPC::TIRPC UNKNOWN IMPORTED) + set_target_properties(TIRPC::TIRPC + PROPERTIES + IMPORTED_LOCATION "${TIRPC_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_TIRPC_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${TIRPC_INCLUDE_DIR}") + endif() +else () + message(STATUS "Found TIRPC: ${TIRPC_LINK_LIBRARIES}") endif() diff --git a/environment.yaml b/environment.yaml new file mode 100644 index 000000000..c96142924 --- /dev/null +++ b/environment.yaml @@ -0,0 +1,23 @@ +name: exp +channels: + - conda-forge +dependencies: + - python=3.12 + - boost + - eigen=3 + - fftw + - hdf5=1.14 + # - highfive # conda version is too old + - pybind11 + - openmpi + - yaml-cpp + - scikit-build + - gcc=13.2.0 + - gfortran=13.2.0 + # - libpng # Conda only supplies libpng 1.6 - EXP requires 1.2 + - libtirpc + - zlib + - gxx=13.2.0 + - libgomp=13.2.0 + - libgcc-ng=13.2.0 + - libgfortran-ng=13.2.0 diff --git a/expui/CMakeLists.txt b/expui/CMakeLists.txt index 8690817f7..c2a59facb 100644 --- a/expui/CMakeLists.txt +++ b/expui/CMakeLists.txt @@ -1,59 +1,121 @@ -set(bin_PROGRAMS nativetoh5 h5compare viewcoefs h5power makecoefs testread) +# Make the expui shared library +set(expui_SOURCES BasisFactory.cc BiorthBasis.cc BiorthBess.cc FieldBasis.cc + CoefContainer.cc CoefStruct.cc FieldGenerator.cc expMSSA.cc + Coefficients.cc KMeans.cc Centering.cc ParticleIterator.cc + Koopman.cc) + +add_library(expui ${expui_SOURCES}) +add_dependencies(expui exputil) + +set(common_LINKLIBS ${DEP_LIB} ${OpenMP_CXX_LIBRARIES} + ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES} + ${MPI_CXX_LIBRARIES} + ${YAML_CPP_LIBRARIES} ${EXPUTIL} + ${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} + HighFive) + +set(common_INCLUDE + ${DEP_INC} ${HDF5_INCLUDE_DIRS} + ${EIGEN3_INCLUDE_DIR} ${FFTW_INCLUDE_DIRS} + $) -set(common_LINKLIB OpenMP::OpenMP_CXX MPI::MPI_CXX yaml-cpp exputil - ${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) +set(common_INCLUDE_PRIVATE + $ + $) -if(PNG_FOUND) - list(APPEND common_LINKLIB PNG::PNG) +# if(HighFive_FOUND) +# list(APPEND common_LINKLIBS HighFive) +# else() +# list(APPEND common_INCLUDE_PRIVATE $) +# endif() + +if(USE_SUBMODULES) + list(APPEND common_INCLUDE_PRIVATE + $) + list(APPEND common_LINKLIBS yaml-cpp) endif() -set(common_INCLUDE $ - $ - $ - ${CMAKE_BINARY_DIR} ${DEP_INC} ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. ${HighFive_SOURCE_DIR}/include - ${HDF5_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${FFTW_INCLUDE_DIRS}) +find_package(EXPutil QUIET) + +if(EXPutil_FOUND) + list(PREPEND common_LINKLIBS EXP::EXPutil) + list(PREPEND common_INCLUDE ${EXPutil_INCLUDE_DIRS}) +else() + list(PREPEND common_LINKLIBS exputil) #internal name + list(PREPEND common_INCLUDE_PRIVATE $) +endif() +if(PNG_FOUND AND ENABLE_PNG) + list(APPEND common_LINKLIBS PNG::PNG) + list(APPEND common_INCLUDE ${PNG_INCLUDE_DIRS}) + add_definitions(${PNG_DEFINITIONS}) +endif() if(ENABLE_CUDA) list(APPEND common_INCLUDE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDAToolkit_INCLUDE_DIRS}) - list(APPEND common_LINKLIB CUDA::cudart CUDA::nvToolsExt) + list(APPEND common_LINKLIBS CUDA::cudart CUDA::nvToolsExt) endif() if(SLURM_FOUND) - list(APPEND common_LINKLIB ${SLURM_LIBRARY}) + list(APPEND common_LINKLIBS ${SLURM_LIBRARY}) endif() -if(ENABLE_XDR AND TIRPC_FOUND) - list(APPEND common_INCLUDE ${TIRPC_INCLUDE_DIRS}) - list(APPEND common_LINKLIB ${TIRPC_LIBRARIES}) -endif() +# TODO: Replace this globbing with a list of actually public headers +file(GLOB expui_PUBLIC_HEADERS "*.[hH]") +set_target_properties (expui PROPERTIES + OUTPUT_NAME expui + EXPORT_NAME EXPui + PUBLIC_HEADER "${expui_PUBLIC_HEADERS}") -# Make the expui shared library -# -set(expui_SOURCES BasisFactory.cc BiorthBasis.cc FieldBasis.cc - CoefContainer.cc CoefStruct.cc FieldGenerator.cc expMSSA.cc - Coefficients.cc KMeans.cc Centering.cc ParticleIterator.cc - Koopman.cc BiorthBess.cc) -add_library(expui ${expui_SOURCES}) -set_target_properties(expui PROPERTIES OUTPUT_NAME expui) target_include_directories(expui PUBLIC ${common_INCLUDE}) -target_link_libraries(expui PUBLIC ${common_LINKLIB}) - -install(TARGETS expui DESTINATION lib) +target_include_directories(expui PRIVATE ${common_INCLUDE_PRIVATE}) +target_link_libraries(expui PUBLIC ${common_LINKLIBS}) # Configure and build the test routines -# -add_executable(nativetoh5 coefstoh5.cc) -add_executable(h5compare h5compare.cc) -add_executable(viewcoefs viewcoefs.cc) -add_executable(h5power h5power.cc) -add_executable(makecoefs makecoefs.cc) -add_executable(testread testread.cc) - -foreach(program ${bin_PROGRAMS}) - target_link_libraries(${program} expui exputil ${common_LINKLIB}) - target_include_directories(${program} PUBLIC ${common_INCLUDE}) - target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS}) - install(TARGETS ${program} DESTINATION bin) -endforeach() +if (ENABLE_TESTS) + set(bin_PROGRAMS nativetoh5 h5compare viewcoefs h5power makecoefs testread) + + add_executable(nativetoh5 coefstoh5.cc) + add_executable(h5compare h5compare.cc) + add_executable(viewcoefs viewcoefs.cc) + add_executable(h5power h5power.cc) + add_executable(makecoefs makecoefs.cc) + add_executable(testread testread.cc) + + foreach(program ${bin_PROGRAMS}) + target_link_libraries(${program} PUBLIC expui ${common_LINKLIBS}) + target_include_directories(${program} PUBLIC ${common_INCLUDE}) + target_include_directories(${program} PRIVATE ${common_INCLUDE_PRIVATE}) + target_compile_options(${program} PUBLIC ${OpenMP_CXX_FLAGS}) + endforeach() +endif() + +install (TARGETS expui + EXPORT EXPuiTargets + LIBRARY DESTINATION lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION include/expui) + +if (INSTALL_CMAKE_FIND) + # Set up cmake configs + set(CMAKEPACKAGE_INSTALL_DIR share/EXPui/cmake) + install (EXPORT EXPuiTargets + FILE EXPuiTargets.cmake + NAMESPACE EXP:: + DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}) + + include(CMakePackageConfigHelpers) + configure_package_config_file(EXPuiConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/EXPuiConfig.cmake + INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} + PATH_VARS CMAKEPACKAGE_INSTALL_DIR CMAKE_INSTALL_PREFIX + ) + + write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EXPuiVersion.cmake + VERSION ${CMAKE_PROJECT_VERSION} + COMPATIBILITY SameMinorVersion ) + + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/EXPuiConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/EXPuiVersion.cmake + DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} ) +endif() diff --git a/expui/Coefficients.H b/expui/Coefficients.H index d6a121815..92633a9e9 100644 --- a/expui/Coefficients.H +++ b/expui/Coefficients.H @@ -14,7 +14,7 @@ #include // The EXP native coefficient classes -#include +#include "CoefStruct.H" namespace CoefClasses { diff --git a/expui/EXPuiConfig.cmake.in b/expui/EXPuiConfig.cmake.in new file mode 100644 index 000000000..93dd6f8b3 --- /dev/null +++ b/expui/EXPuiConfig.cmake.in @@ -0,0 +1,17 @@ +# Generates the cmake find_package files for EXPui + +@PACKAGE_INIT@ + +if(NOT TARGET EXP::EXPui) + include(@PACKAGE_CMAKEPACKAGE_INSTALL_DIR@/EXPuiTargets.cmake) +endif() + +set_and_check(EXPui_INCLUDE_DIRS @PACKAGE_CMAKE_INSTALL_PREFIX@/include/expui) +set_and_check(EXPui_LIBRARY_DIRS @PACKAGE_CMAKE_INSTALL_PREFIX@/lib) +set_and_check(EXPui_LIBRARIES @PACKAGE_CMAKE_INSTALL_PREFIX@/lib/libexpui.so) + +check_required_components(EXPui) + +if (EXPui_FOUND) + find_package_message(EXPui "Found EXPui: ${EXPui_LIBRARIES}" "[${EXPui_LIBRARIES}][${EXPui_INCLUDE_DIRS}]") +endif() diff --git a/expui/Koopman.cc b/expui/Koopman.cc index cc85cca1f..9808ee8e8 100644 --- a/expui/Koopman.cc +++ b/expui/Koopman.cc @@ -44,8 +44,6 @@ #include -#include - #include #include #include diff --git a/expui/expMSSA.cc b/expui/expMSSA.cc index b136d2e7d..953c4d8d7 100644 --- a/expui/expMSSA.cc +++ b/expui/expMSSA.cc @@ -37,8 +37,6 @@ #include -#include - #include #include #include diff --git a/exputil/CMakeLists.txt b/exputil/CMakeLists.txt index 87a25087a..e0ee09c48 100644 --- a/exputil/CMakeLists.txt +++ b/exputil/CMakeLists.txt @@ -1,4 +1,3 @@ - set(ODE_SRC rk4.cc bs.cc odesolve.cc) set(SYMP_SRC sia4.cc) set(ROOT_SRC rtbis.cc rtsafe.cc brent.cc zbrent.cc mnbrak.cc zbrak.cc zbrac.cc) @@ -43,37 +42,96 @@ set(exputil_SOURCES ${ODE_SRC} ${ROOT_SRC} ${QUAD_SRC} ${QPDISTF_SRC} ${BESSEL_SRC} ${OPTIMIZATION_SRC} ${SLEDGE_SRC} ${PARTICLE_SRC} ${CUDA_SRC}) -set(common_INCLUDE_DIRS $ - $ - $ ${CMAKE_BINARY_DIR} - $ - $ - ${DEP_INC} ${EIGEN3_INCLUDE_DIR} ${HDF5_INCLUDE_DIRS} - ${FFTW_INCLUDE_DIRS}) +set(common_INCLUDE + $ + ${YAML_CPP_INCLUDE_DIR} ${DEP_INC} ${EIGEN3_INCLUDE_DIR} + ${HDF5_INCLUDE_DIRS} ${FFTW_INCLUDE_DIRS}) + +set(common_INCLUDE_PRIVATE + $ + $ + $) -set(common_LINKLIBS ${DEP_LIB} OpenMP::OpenMP_CXX MPI::MPI_CXX - yaml-cpp ${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} - ${FFTW_DOUBLE_LIB}) +set(common_LINKLIBS + ${DEP_LIB} ${OpenMP_CXX_LIBRARIES} ${MPI_CXX_LIBRARIES} + ${YAML_CPP_LIBRARIES} ${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} + ${FFTW_DOUBLE_LIB} HighFive) + +# if(HighFive_FOUND) +# list(APPEND common_LINKLIBS HighFive) +# else() +# list(APPEND common_INCLUDE_PRIVATE $) +# endif() + +if(USE_SUBMODULES) + list(APPEND common_INCLUDE_PRIVATE + $) + list(APPEND common_LINKLIBS yaml-cpp) +endif() if(ENABLE_CUDA) - list(APPEND common_INCLUDE_DIRS ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDAToolkit_INCLUDE_DIRS}) - list(APPEND common_LINKLIB CUDA::cudart CUDA::nvToolsExt) + list(APPEND common_INCLUDE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDAToolkit_INCLUDE_DIRS}) + list(APPEND common_LINKLIBS CUDA::cudart CUDA::nvToolsExt) endif() if(ENABLE_XDR AND TIRPC_FOUND) - list(APPEND common_INCLUDE_DIRS ${TIRPC_INCLUDE_DIRS}) - list(APPEND common_LINKLIB ${TIRPC_LIBRARIES}) + list(APPEND common_INCLUDE ${TIRPC_INCLUDE_DIRS}) + list(APPEND common_LINKLIBS ${TIRPC_LIBRARIES}) +endif() + +if(PNG_FOUND AND ENABLE_PNG) + list(APPEND common_LINKLIBS PNG::PNG) + list(APPEND common_INCLUDE ${PNG_INCLUDE_DIRS}) + add_definitions(${PNG_DEFINITIONS}) endif() +# TODO: Replace this globbing with a list of actually public headers +file(GLOB exputil_PUBLIC_HEADERS "../include/*.[hH]") + # shared lib +add_library(exputil ${exputil_SOURCES} ${exputil_PUBLIC_HEADERS}) + +set_target_properties(exputil PROPERTIES + OUTPUT_NAME exputil + EXPORT_NAME EXPutil + PUBLIC_HEADER "${exputil_PUBLIC_HEADERS}") -add_library(exputil ${exputil_SOURCES}) -set_target_properties(exputil PROPERTIES OUTPUT_NAME exputil) -target_include_directories(exputil PUBLIC ${common_INCLUDE_DIRS}) +target_include_directories(exputil PUBLIC ${common_INCLUDE}) +target_include_directories(exputil PRIVATE ${common_INCLUDE_PRIVATE}) target_link_libraries(exputil PUBLIC ${common_LINKLIBS}) -install(TARGETS exputil DESTINATION lib) +install(TARGETS exputil + EXPORT EXPutilTargets + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include/exputil) + +install (DIRECTORY $ + DESTINATION include/exputil) -# HDF5 info +# install (DIRECTORY $ +# DESTINATION include/exputil) -message(STATUS "HDF5 include dirs: ${HDF5_INCLUDE_DIRS}") +install (DIRECTORY $ + DESTINATION include/exputil) + +if (INSTALL_CMAKE_FIND) + # Set up cmake configs + set(CMAKEPACKAGE_INSTALL_DIR share/EXPutil/cmake) + install (EXPORT EXPutilTargets + FILE EXPutilTargets.cmake + NAMESPACE EXP:: + DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}) + + include(CMakePackageConfigHelpers) + configure_package_config_file(EXPutilConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/EXPutilConfig.cmake + INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} + PATH_VARS CMAKEPACKAGE_INSTALL_DIR CMAKE_INSTALL_PREFIX + ) + write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EXPutilVersion.cmake + VERSION ${CMAKE_PROJECT_VERSION} + COMPATIBILITY SameMinorVersion ) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/EXPutilConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/EXPutilVersion.cmake + DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}) +endif() diff --git a/exputil/EXPutilConfig.cmake.in b/exputil/EXPutilConfig.cmake.in new file mode 100644 index 000000000..35c2ee5f9 --- /dev/null +++ b/exputil/EXPutilConfig.cmake.in @@ -0,0 +1,15 @@ +# Generates the cmake find_package files for EXPutil + +@PACKAGE_INIT@ + +if(NOT TARGET EXP::EXPutil) + include(@PACKAGE_CMAKEPACKAGE_INSTALL_DIR@/EXPutilTargets.cmake) +endif() + +set_and_check(EXPutil_INCLUDE_DIRS @PACKAGE_CMAKE_INSTALL_PREFIX@/include/exputil) +set_and_check(EXPutil_LIBRARY_DIRS @PACKAGE_CMAKE_INSTALL_PREFIX@/lib) +set_and_check(EXPutil_LIBRARIES @PACKAGE_CMAKE_INSTALL_PREFIX@/lib/libexputil.so) + +check_required_components(EXPutil) + +find_package_message(EXPutil "Found EXPutil: ${EXPutil_LIBRARIES}" "[${EXPutil_LIBRARIES}][${EXPutil_INCLUDE_DIRS}]") diff --git a/include/Coefs.H b/include/Coefs.H index de04e1c57..66dbab93e 100644 --- a/include/Coefs.H +++ b/include/Coefs.H @@ -6,7 +6,7 @@ #include // YAML support -#include "src/coef.H" +#include "coef.H" struct CylCoefs { diff --git a/include/EXPcommonConfig.cmake.in b/include/EXPcommonConfig.cmake.in new file mode 100644 index 000000000..bd6a471f6 --- /dev/null +++ b/include/EXPcommonConfig.cmake.in @@ -0,0 +1,11 @@ +# Generates the cmake find_package files for EXPutil + +@PACKAGE_INIT@ + +if(NOT TARGET EXP::EXPcommon) + include(@PACKAGE_CMAKEPACKAGE_INSTALL_DIR@/EXPcommonTargets.cmake) +endif() + +set_and_check(EXPcommon_INCLUDE_DIRS @PACKAGE_CMAKE_INSTALL_PREFIX@/include/expcommon) + +check_required_components(EXPcommon) diff --git a/packaging/conda/EXP-libraries/build.sh b/packaging/conda/EXP-libraries/build.sh new file mode 100644 index 000000000..2ea8fea30 --- /dev/null +++ b/packaging/conda/EXP-libraries/build.sh @@ -0,0 +1 @@ +python -m pip install . --prefix ${PREFIX} --upgrade -vv --no-deps --no-build-isolation diff --git a/packaging/conda/EXP-libraries/conda_build_config.yaml b/packaging/conda/EXP-libraries/conda_build_config.yaml new file mode 100644 index 000000000..88143ae1c --- /dev/null +++ b/packaging/conda/EXP-libraries/conda_build_config.yaml @@ -0,0 +1,10 @@ +mpi: + - openmpi + # - mpich + +target_platform: + - linux-64 + # - linux-aarch64 + # - linux-ppc64le + # - osx-64 + # - osx-arm64 diff --git a/packaging/conda/EXP-libraries/meta.yaml b/packaging/conda/EXP-libraries/meta.yaml new file mode 100644 index 000000000..de9e38ed2 --- /dev/null +++ b/packaging/conda/EXP-libraries/meta.yaml @@ -0,0 +1,57 @@ +{% set name = "EXP-libraries" %} +{% set version = "7.7.28" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: file:///home/georgia/Projects/umass/unity/user_support/martin_exp/packaging/pypi/EXP-libraries/dist/EXP-libraries-7.7.28.tar.gz + sha256: 7edc7f0b3b8d648c436666f873316c02190ad37b57ca3fd5373d33b924e494b8 + +build: + number: 0 + +requirements: + build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('fortran') }} + - {{ mpi }}-mpicc + - {{ mpi }}-mpicxx + - {{ mpi }}-mpifort + - setuptools >=42 + - scikit-build >=0.13 + - cmake >=3.21 + - ninja + - pip + - eigen + - highfive + host: + - {{ mpi }} + - hdf5 >=1.8.20 + - boost-cpp + - fftw + - libtirpc # [linux-64] + - yaml-cpp + - zlib + - libpng + run: + - {{ mpi }} + - _openmp_mutex + - hdf5 >=1.8.20 + - boost-cpp + - fftw + - libtirpc # [linux-64] + - yaml-cpp + - libpng + +about: + summary: Nbody EXPansion Code - Libraries + license: GPL-3.0 AND MIT + license_file: + - LICENSE + +extra: + recipe-maintainers: + - georgiastuart diff --git a/packaging/conda/EXP-nbody/build.sh b/packaging/conda/EXP-nbody/build.sh new file mode 100644 index 000000000..2ea8fea30 --- /dev/null +++ b/packaging/conda/EXP-nbody/build.sh @@ -0,0 +1 @@ +python -m pip install . --prefix ${PREFIX} --upgrade -vv --no-deps --no-build-isolation diff --git a/packaging/conda/EXP-nbody/conda_build_config.yaml b/packaging/conda/EXP-nbody/conda_build_config.yaml new file mode 100644 index 000000000..88143ae1c --- /dev/null +++ b/packaging/conda/EXP-nbody/conda_build_config.yaml @@ -0,0 +1,10 @@ +mpi: + - openmpi + # - mpich + +target_platform: + - linux-64 + # - linux-aarch64 + # - linux-ppc64le + # - osx-64 + # - osx-arm64 diff --git a/packaging/conda/EXP-nbody/meta.yaml b/packaging/conda/EXP-nbody/meta.yaml new file mode 100644 index 000000000..4e4ca86c9 --- /dev/null +++ b/packaging/conda/EXP-nbody/meta.yaml @@ -0,0 +1,59 @@ +{% set name = "EXP-nbody" %} +{% set version = "7.7.28" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: file:///home/georgia/Projects/umass/unity/user_support/martin_exp/packaging/pypi/EXP-nbody/dist/EXP-nbody-7.7.28.tar.gz + sha256: 85efc71e353b096566b24626762a68eaa45a507c4d799db94016b4f4c678571f + +build: + number: 0 + +requirements: + build: + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('fortran') }} + - {{ mpi }}-mpicc + - {{ mpi }}-mpicxx + - {{ mpi }}-mpifort + - setuptools >=42 + - scikit-build >=0.13 + - cmake >=3.21 + - ninja + - pip + - eigen + - highfive + host: + - {{ mpi }} + - hdf5 >=1.8.20 + - boost-cpp + - fftw + - libtirpc # [linux-64] + - yaml-cpp + - zlib + - libpng + - exp-libraries + run: + - {{ mpi }} + - _openmp_mutex + - hdf5 >=1.8.20 + - boost-cpp + - fftw + - libtirpc # [linux-64] + - yaml-cpp + - libpng + - exp-libraries + +about: + summary: Nbody EXPansion Code - Nbody + license: GPL-3.0 AND MIT + license_file: + - LICENSE + +extra: + recipe-maintainers: + - georgiastuart diff --git a/packaging/conda/pyEXP/build.sh b/packaging/conda/pyEXP/build.sh new file mode 100644 index 000000000..2ea8fea30 --- /dev/null +++ b/packaging/conda/pyEXP/build.sh @@ -0,0 +1 @@ +python -m pip install . --prefix ${PREFIX} --upgrade -vv --no-deps --no-build-isolation diff --git a/packaging/conda/pyEXP/conda_build_config.yaml b/packaging/conda/pyEXP/conda_build_config.yaml new file mode 100644 index 000000000..67be1913a --- /dev/null +++ b/packaging/conda/pyEXP/conda_build_config.yaml @@ -0,0 +1,13 @@ +python: + - 3.8 + +mpi: + - openmpi + # - mpich + +target_platform: + # - linux-64 + # - linux-aarch64 + # - linux-ppc64le + # - osx-64 + - osx-arm64 diff --git a/packaging/conda/pyEXP/meta.yaml b/packaging/conda/pyEXP/meta.yaml new file mode 100644 index 000000000..fe6c02f26 --- /dev/null +++ b/packaging/conda/pyEXP/meta.yaml @@ -0,0 +1,62 @@ +{% set name = "pyEXP" %} +{% set version = "7.7.28" %} + +package: + name: {{ name|lower }} + version: {{ version }} + +source: + url: file:///home/georgia/Projects/umass/unity/user_support/martin_exp/packaging/pypi/pyEXP/dist/pyEXP-7.7.28.tar.gz + sha256: 63564ac26c59b1b5b90e823a514c215f5bf829eddc434d3c880251084cd59bd0 + +build: + number: 0 + +requirements: + build: + - python + - {{ compiler('c') }} + - {{ compiler('cxx') }} + - {{ compiler('fortran') }} + - {{ mpi }}-mpicc + - {{ mpi }}-mpicxx + - {{ mpi }}-mpifort + - setuptools >=42 + - scikit-build >=0.13 + - cmake >=3.21 + - ninja + - pip + - pybind11 + - eigen + - highfive ==2.4.1 + host: + - python + - {{ mpi }} + - hdf5 >=1.8.20 + - boost-cpp + # - fftw + # - libtirpc # [linux-64] + # - yaml-cpp + # - zlib + # - libpng + - exp-libraries =={{ version }} + run: + - python + - {{ mpi }} + # - _openmp_mutex + - hdf5 >=1.8.20 + - boost-cpp + # - fftw + # - libtirpc # [linux-64] + # - yaml-cpp + # - libpng + - exp-libraries =={{ version }} +about: + summary: Nbody EXPansion Code - Libraries + license: GPL-3.0 AND MIT + license_file: + - LICENSE + +extra: + recipe-maintainers: + - georgiastuart diff --git a/packaging/pypi/EXP-libraries/.gitignore b/packaging/pypi/EXP-libraries/.gitignore new file mode 100644 index 000000000..b3d92f6d3 --- /dev/null +++ b/packaging/pypi/EXP-libraries/.gitignore @@ -0,0 +1,6 @@ +* +!pyproject.toml +!setup.py +!MANIFEST.in +!.gitignore +!README_explib.md \ No newline at end of file diff --git a/packaging/pypi/EXP-libraries/MANIFEST.in b/packaging/pypi/EXP-libraries/MANIFEST.in new file mode 100644 index 000000000..5bd234961 --- /dev/null +++ b/packaging/pypi/EXP-libraries/MANIFEST.in @@ -0,0 +1,6 @@ +graft . +exclude MANIFEST.in +exclude .gitignore +prune _skbuild +prune dist +prune __pycache__ diff --git a/packaging/pypi/EXP-libraries/README_explib.md b/packaging/pypi/EXP-libraries/README_explib.md new file mode 100644 index 000000000..3c7fcff56 --- /dev/null +++ b/packaging/pypi/EXP-libraries/README_explib.md @@ -0,0 +1,13 @@ +# EXP-libraries PyPi Package + +This package requires... +- C, C++, and Fortran compilers +- an MPI distribution and compilers +- HDF5 >= 1.8.20 +- Boost +- FFTW +- Eigen3 +- HighFive +- yaml-cpp +- png +- zlib \ No newline at end of file diff --git a/packaging/pypi/EXP-libraries/pyproject.toml b/packaging/pypi/EXP-libraries/pyproject.toml new file mode 100644 index 000000000..b3db3dc1f --- /dev/null +++ b/packaging/pypi/EXP-libraries/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires = [ + "setuptools>=42", + "scikit-build>=0.13", + "cmake>=3.21", + "ninja" + ] +build-backend = "setuptools.build_meta" diff --git a/packaging/pypi/EXP-libraries/setup.py b/packaging/pypi/EXP-libraries/setup.py new file mode 100644 index 000000000..bdc6011b8 --- /dev/null +++ b/packaging/pypi/EXP-libraries/setup.py @@ -0,0 +1,134 @@ +from skbuild import setup + +version="7.7.99" + +# Setup for the CopyAndSdist subclass + +import os +import pathlib +import shutil + +from setuptools.command.sdist import sdist + +class CopyAndSdist(sdist): + file_list = [] + directory_list = [] + def run(self): + self.copy_src() + super().run() + self.clean_src() + + @classmethod + def clean_src(cls): + print(f"Cleaning the packaging directory, {os.getcwd()}...") + for file in cls.file_list: + try: + os.remove(file) + except (FileNotFoundError, TypeError): + try: + os.remove(file[1]) + except FileNotFoundError: + print(f"File {file} did not exist") + print(f"Removed file {file}") + + for directory in cls.directory_list: + try: + shutil.rmtree(directory, ignore_errors=True) + except TypeError: + shutil.rmtree(directory[1], ignore_errors=True) + print(f"Removed directory {directory}") + + @classmethod + def copy_src(cls): + # Set up the necessary source files + rootdir = pathlib.Path.cwd().joinpath("../../..").resolve() + + for directory in cls.directory_list: + if isinstance(directory, list): + src = directory[0] + dest = directory[1] + else: + src = directory + dest = directory + shutil.copytree(rootdir.joinpath(src), pathlib.Path.cwd().joinpath(dest), dirs_exist_ok=True) + + for file in cls.file_list: + if isinstance(file, list): + src = file[0] + dest = file[1] + else: + src = file + dest = file + shutil.copy(rootdir.joinpath(src), pathlib.Path.cwd().joinpath(dest)) + + +CopyAndSdist.file_list = [ + 'AUTHORS', + 'ChangeLog', + 'CMakeLists.txt', + 'config_cmake.h_in', + 'COPYING', + 'INSTALL', + 'INSTALL.md', + 'LICENSE', + 'NEWS', + 'README.md', + 'extern/HighFive/LICENSE', + 'extern/HighFive/README.md', + 'extern/HighFive/CMakeLists.txt', +] + +# Directories +CopyAndSdist.directory_list = [ + 'cmake', + 'expui', + 'exputil', + 'extern/rapidxml', + 'extern/png++', + 'extern/HighFive/include', + 'extern/HighFive/cmake', + 'include', +] + +# Install specifications + +setup( + name="EXP-libraries", + version=version, + description="Nbody EXPansion Code - Libraries", + author="", + license="GPL-3.0", + packages=["EXP-libexputil", "EXP-libexpui"], + python_requires=">=3.8", + package_dir={ + "EXP-libexputil": "exputil", + "EXP-libexpui": "expui" + }, + cmdclass={ + "sdist": CopyAndSdist, + }, + cmake_install_dir="", + cmake_minimum_required_version="3.21", + cmake_languages=("C", "CXX", "Fortran"), + cmake_args=[ + "-DCMAKE_CXX_STANDARD=17", + "-DINSTALL_HEADERS=ON", + "-DBUILD_COMMON_LIBRARIES=ON", + "-DINSTALL_CMAKE_FIND=ON", + "-DENABLE_NBODY=OFF", + "-DENABLE_PYEXP=OFF", + "-DBUILD_UTILS=OFF", + "-DUSE_SUBMODULES=OFF", + "-DENABLE_PNG=OFF", # png++ is only compatible with libpng 1.2.X - defunct + "-DENABLE_USER=OFF", + "-DENABLE_TESTS=OFF", + "-DENABLE_XDR=ON", + "-DENABLE_DSMC=OFF", + "-DCMAKE_BUILD_TYPE=RELEASE", + "-Wno-dev" + ] + # extras_require={ + # "cuda": [] + # } +) + diff --git a/packaging/pypi/EXP-nbody/.gitignore b/packaging/pypi/EXP-nbody/.gitignore new file mode 100644 index 000000000..b3d92f6d3 --- /dev/null +++ b/packaging/pypi/EXP-nbody/.gitignore @@ -0,0 +1,6 @@ +* +!pyproject.toml +!setup.py +!MANIFEST.in +!.gitignore +!README_explib.md \ No newline at end of file diff --git a/packaging/pypi/EXP-nbody/MANIFEST.in b/packaging/pypi/EXP-nbody/MANIFEST.in new file mode 100644 index 000000000..5bd234961 --- /dev/null +++ b/packaging/pypi/EXP-nbody/MANIFEST.in @@ -0,0 +1,6 @@ +graft . +exclude MANIFEST.in +exclude .gitignore +prune _skbuild +prune dist +prune __pycache__ diff --git a/packaging/pypi/EXP-nbody/README_explib.md b/packaging/pypi/EXP-nbody/README_explib.md new file mode 100644 index 000000000..9c3629fa8 --- /dev/null +++ b/packaging/pypi/EXP-nbody/README_explib.md @@ -0,0 +1,11 @@ +# EXP-Nbody PyPi Package + +This package requires... +- C and C++ compilers +- an MPI distribution and compilers +- HDF5 >= 1.8.20 +- Boost +- FFTW +- Eigen3 +- HighFive +- yaml-cpp \ No newline at end of file diff --git a/packaging/pypi/EXP-nbody/pyproject.toml b/packaging/pypi/EXP-nbody/pyproject.toml new file mode 100644 index 000000000..b3db3dc1f --- /dev/null +++ b/packaging/pypi/EXP-nbody/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires = [ + "setuptools>=42", + "scikit-build>=0.13", + "cmake>=3.21", + "ninja" + ] +build-backend = "setuptools.build_meta" diff --git a/packaging/pypi/EXP-nbody/setup.py b/packaging/pypi/EXP-nbody/setup.py new file mode 100644 index 000000000..6c1112d30 --- /dev/null +++ b/packaging/pypi/EXP-nbody/setup.py @@ -0,0 +1,132 @@ +from skbuild import setup + +version="7.7.99" + +# Setup for the CopyAndSdist subclass + +import os +import pathlib +import shutil + +from setuptools.command.sdist import sdist + +class CopyAndSdist(sdist): + file_list = [] + directory_list = [] + def run(self): + self.copy_src() + super().run() + self.clean_src() + + @classmethod + def clean_src(cls): + print(f"Cleaning the packaging directory, {os.getcwd()}...") + for file in cls.file_list: + try: + os.remove(file) + except (FileNotFoundError, TypeError): + try: + os.remove(file[1]) + except FileNotFoundError: + print(f"File {file} did not exist") + print(f"Removed file {file}") + + for directory in cls.directory_list: + try: + shutil.rmtree(directory, ignore_errors=True) + except TypeError: + shutil.rmtree(directory[1], ignore_errors=True) + print(f"Removed directory {directory}") + + @classmethod + def copy_src(cls): + # Set up the necessary source files + rootdir = pathlib.Path.cwd().joinpath("../../..").resolve() + + for directory in cls.directory_list: + if isinstance(directory, list): + src = directory[0] + dest = directory[1] + else: + src = directory + dest = directory + shutil.copytree(rootdir.joinpath(src), pathlib.Path.cwd().joinpath(dest), dirs_exist_ok=True) + + for file in cls.file_list: + if isinstance(file, list): + src = file[0] + dest = file[1] + else: + src = file + dest = file + shutil.copy(rootdir.joinpath(src), pathlib.Path.cwd().joinpath(dest)) + + +CopyAndSdist.file_list = [ + 'AUTHORS', + 'ChangeLog', + 'CMakeLists.txt', + 'config_cmake.h_in', + 'COPYING', + 'INSTALL', + 'INSTALL.md', + 'LICENSE', + 'NEWS', + 'README.md', + 'extern/HighFive/LICENSE', + 'extern/HighFive/README.md', + 'extern/HighFive/CMakeLists.txt', +] + +# Directories +CopyAndSdist.directory_list = [ + 'cmake', + 'src', + 'extern/HighFive/include', + 'extern/HighFive/cmake', +] + +# Install specifications + +setup( + name="EXP-nbody", + version=version, + description="Nbody EXPansion Code - Nbody", + author="", + license="GPL-3.0", + packages=["EXP-nbody"], + python_requires=">=3.8", + install_requires=[ + 'exp-libraries' + ], + package_dir={ + "EXP-nbody": "src" + }, + cmdclass={ + "sdist": CopyAndSdist, + }, + cmake_install_dir="", + cmake_minimum_required_version="3.21", + cmake_languages=("C", "CXX", "Fortran"), + cmake_args=[ + "-DCMAKE_CXX_STANDARD=17", + "-DINSTALL_HEADERS=OFF", + "-DBUILD_COMMON_LIBRARIES=OFF", + "-DINSTALL_CMAKE_FIND=ON", + "-DENABLE_NBODY=ON", + "-DENABLE_PYEXP=OFF", + "-DBUILD_UTILS=OFF", + "-DUSE_SUBMODULES=OFF", + "-DENABLE_PNG=OFF", # png++ is only compatible with libpng 1.2.X - defunct "-DENABLE_USER=OFF", + "-DENABLE_USER=OFF", + "-DENABLE_TESTS=OFF", + "-DENABLE_XDR=ON", + "-DENABLE_DSMC=OFF", # missing from extern so need clarification on what dependency it needs + "-DCMAKE_BUILD_TYPE=RELEASE", + "-Wno-dev" + ] + # extras_require={ + # "cuda": [] + # } +) + diff --git a/packaging/pypi/README.md b/packaging/pypi/README.md new file mode 100644 index 000000000..26acad7b4 --- /dev/null +++ b/packaging/pypi/README.md @@ -0,0 +1,8 @@ +# EXP PyPi Packages + +These directories are not meant to be used directly with `pip install`. Instead, +run `python setup.py sdist` to create a source distribution, then run +`pip install dist/-.tar.gz` to install to your python +environment. + +Requirements for individual packages are located in the individual directories. \ No newline at end of file diff --git a/packaging/pypi/helpers.py b/packaging/pypi/helpers.py new file mode 100644 index 000000000..2f9ec273f --- /dev/null +++ b/packaging/pypi/helpers.py @@ -0,0 +1,40 @@ +import os +import pathlib +import shutil + +from setuptools.command.sdist import sdist + +class CopyAndSdist(sdist): + file_list = [] + directory_list = [] + def run(self): + self.copy_src() + super().run() + self.clean_src() + + @classmethod + def clean_src(cls): + print(f"Cleaning the packaging directory, {os.getcwd()}...") + for file in cls.file_list: + try: + os.remove(file) + print(f"Removed file {file}") + except FileNotFoundError: + print(f"File {file} did not exist") + + for directory in cls.directory_list: + shutil.rmtree(directory, ignore_errors=True) + print(f"Removed directory {directory}") + + @classmethod + def copy_src(cls): + # Set up the necessary source files + rootdir = pathlib.Path.cwd().joinpath("../../..").resolve() + + for file in cls.file_list: + shutil.copy(rootdir.joinpath(file), pathlib.Path.cwd().joinpath(file)) + + for directory in cls.directory_list: + shutil.copytree(rootdir.joinpath(directory), pathlib.Path.cwd().joinpath(directory), dirs_exist_ok=True) + + diff --git a/packaging/pypi/pyEXP/.gitignore b/packaging/pypi/pyEXP/.gitignore new file mode 100644 index 000000000..50a56c11b --- /dev/null +++ b/packaging/pypi/pyEXP/.gitignore @@ -0,0 +1,5 @@ +* +!pyproject.toml +!setup.py +!.gitignore +!MANIFEST.in \ No newline at end of file diff --git a/packaging/pypi/pyEXP/MANIFEST.in b/packaging/pypi/pyEXP/MANIFEST.in new file mode 100644 index 000000000..5bd234961 --- /dev/null +++ b/packaging/pypi/pyEXP/MANIFEST.in @@ -0,0 +1,6 @@ +graft . +exclude MANIFEST.in +exclude .gitignore +prune _skbuild +prune dist +prune __pycache__ diff --git a/packaging/pypi/pyEXP/pyproject.toml b/packaging/pypi/pyEXP/pyproject.toml new file mode 100644 index 000000000..b3db3dc1f --- /dev/null +++ b/packaging/pypi/pyEXP/pyproject.toml @@ -0,0 +1,8 @@ +[build-system] +requires = [ + "setuptools>=42", + "scikit-build>=0.13", + "cmake>=3.21", + "ninja" + ] +build-backend = "setuptools.build_meta" diff --git a/packaging/pypi/pyEXP/setup.py b/packaging/pypi/pyEXP/setup.py new file mode 100644 index 000000000..58cfdd1a7 --- /dev/null +++ b/packaging/pypi/pyEXP/setup.py @@ -0,0 +1,128 @@ +from skbuild import setup + +version="7.7.99" + +# Setup for the CopyAndSdist subclass + +import os +import pathlib +import shutil + +from setuptools.command.sdist import sdist + +class CopyAndSdist(sdist): + file_list = [] + directory_list = [] + def run(self): + self.copy_src() + super().run() + self.clean_src() + + @classmethod + def clean_src(cls): + print(f"Cleaning the packaging directory, {os.getcwd()}...") + for file in cls.file_list: + try: + os.remove(file) + except (FileNotFoundError, TypeError): + try: + os.remove(file[1]) + except FileNotFoundError: + print(f"File {file} did not exist") + print(f"Removed file {file}") + + for directory in cls.directory_list: + try: + shutil.rmtree(directory, ignore_errors=True) + except TypeError: + shutil.rmtree(directory[1], ignore_errors=True) + print(f"Removed directory {directory}") + + @classmethod + def copy_src(cls): + # Set up the necessary source files + rootdir = pathlib.Path.cwd().joinpath("../../..").resolve() + + for directory in cls.directory_list: + if isinstance(directory, list): + src = directory[0] + dest = directory[1] + else: + src = directory + dest = directory + shutil.copytree(rootdir.joinpath(src), pathlib.Path.cwd().joinpath(dest), dirs_exist_ok=True) + + for file in cls.file_list: + if isinstance(file, list): + src = file[0] + dest = file[1] + else: + src = file + dest = file + shutil.copy(rootdir.joinpath(src), pathlib.Path.cwd().joinpath(dest)) + + +CopyAndSdist.file_list = [ + 'AUTHORS', + 'ChangeLog', + 'CMakeLists.txt', + 'config_cmake.h_in', + 'COPYING', + 'INSTALL', + 'INSTALL.md', + 'LICENSE', + 'NEWS', + 'README.md', + 'extern/HighFive/LICENSE', + 'extern/HighFive/README.md', + 'extern/HighFive/CMakeLists.txt', +] + +# Directories +CopyAndSdist.directory_list = [ + 'cmake', + 'pyEXP', + 'extern/HighFive/include', + 'extern/HighFive/cmake', +] + +# Install specifications + +setup( + name="pyEXP", + version=version, + description="Nbody EXPansion Code - pyEXP", + author="", + license="GPL-3.0", + packages=["pyEXP"], + python_requires=">=3.8", + install_requires=[ + 'exp-libraries' + ], + package_dir={ + "pyEXP": "pyEXP" + }, + cmdclass={ + "sdist": CopyAndSdist, + }, + cmake_install_dir="", + cmake_minimum_required_version="3.21", + cmake_languages=("C", "CXX"), + cmake_args=[ + "-DCMAKE_CXX_STANDARD=17", + "-DBUILD_COMMON_LIBRARIES=OFF", + "-DINSTALL_HEADERS=OFF", + "-DINSTALL_CMAKE_FIND=OFF", + "-DENABLE_NBODY=OFF", + "-DENABLE_PYEXP=ON", + "-DBUILD_UTILS=OFF", + "-DUSE_SUBMODULES=OFF", + "-DENABLE_PNG=OFF", # PNG enabling only depends on the core libraries + "-DENABLE_USER=OFF", + "-DENABLE_TESTS=OFF", + "-DENABLE_XDR=ON", + "-DENABLE_DSMC=OFF", # missing from extern so need clarification on what dependency it needs + "-DCMAKE_BUILD_TYPE=RELEASE", + "-Wno-dev" + ] +) diff --git a/packaging/spack/exp-code/packages/exp/package.py b/packaging/spack/exp-code/packages/exp/package.py new file mode 100644 index 000000000..45a6a178a --- /dev/null +++ b/packaging/spack/exp-code/packages/exp/package.py @@ -0,0 +1,96 @@ +# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other +# Spack Project Developers. See the top-level COPYRIGHT file for details. +# +# SPDX-License-Identifier: (Apache-2.0 OR MIT) + +# ---------------------------------------------------------------------------- +# If you submit this package back to Spack as a pull request, +# please first remove this boilerplate and all FIXME comments. +# +# This is a template package file for Spack. We've put "FIXME" +# next to all the things you'll want to change. Once you've handled +# them, you can save this file and test your package like this: +# +# spack install libexp +# +# You can edit this file again by typing: +# +# spack edit libexp +# +# See the Spack documentation for more information on packaging. +# ---------------------------------------------------------------------------- + +from spack.package import * + + +class Exp(CMakePackage): + """FIXME: Put a proper description of your package here.""" + + # FIXME: Add a proper url for your package's homepage here. + homepage = "https://www.example.com" + url = "https://github.com/EXP-code/EXP/archive/refs/tags/v7.7.99.tar.gz" + git = "https://github.com/georgiastuart/EXP.git" + + maintainers("georgiastuart") + license("GPL-3.0-or-later", checked_by="georgiastuart") + + version("develop", branch="build-tools") + version("7.7.99", sha256="c28394fef7de19ba1f4db771d05a9a373dd18ae3ca1b757a9ea424eee78b460d") + + depends_on("highfive@develop +mpi", type="build") # Needs HighFive 3 + depends_on("eigen@3:", type="build") + depends_on("boost +math") + depends_on("mpi") + depends_on("fftw@3:") + depends_on("hdf5@1.8.20:1.9,1.10.2: +cxx +hl") + depends_on("yaml-cpp@0.8:,develop") + depends_on("zlib") + + depends_on("c", type="build") + depends_on("cxx", type="build") + depends_on("fortran", type="build") + + variant("python", default=False, description="Build the pyEXP Python module.") + depends_on("python@3.8:", when="+python") + depends_on("py-pybind11", when="+python", type="build") + + variant("xdr", default=False, description="Enable RPC/XDR support for Tipsy standard.") + depends_on("libtirpc", when="+xdr") + + variant("nbody", default=True, description="Build the nbody library and executable.") + variant("utils", default=True, description="Build utility executables.") + + variant("slurm", default=False, description="Enable SLURM checkpointing support.") + depends_on("slurm", when="+slurm") + + variant("vtk", default=False, description="Configure VTK.") + depends_on("vtk", when="+vtk") + + variant("docs", default=False, description="Build the documentation.") + depends_on("doxygen", when="+docs") + + variant("tests", default=False, description="Build the test suite.") + + def cmake_bool(self, variant): + return "ON" if self.spec.satisfies(f"+{variant}") else "OFF" + + def cmake_args(self): + args = [ + "-DCMAKE_CXX_STANDARD=17", + "-DINSTALL_HEADERS=ON", + "-DBUILD_COMMON_LIBRARIES=ON", + "-DINSTALL_CMAKE_FIND=ON", + f"-DENABLE_NBODY={self.cmake_bool('nbody')}", + f"-DENABLE_PYEXP={self.cmake_bool('python')}", + f"-DBUILD_UTILS={self.cmake_bool('utils')}", + f"-DENABLE_SLURM={self.cmake_bool('slurm')}", + f"-DBUILD_DOCS={self.cmake_bool('docs')}", + f"-DUSE_SUBMODULES={'ON' if self.spec.satisfies('@:7.7.99') else 'OFF'}", + "-DENABLE_PNG=OFF", # png++ is only compatible with libpng 1.2.X - defunct + "-DENABLE_USER=OFF", + f"-DENABLE_TESTS={self.cmake_bool('tests')}", + f"-DENABLE_XDR={self.cmake_bool('xdr')}", + "-DENABLE_DSMC=OFF", + "-Wno-dev" + ] + return args diff --git a/packaging/spack/exp-code/repo.yaml b/packaging/spack/exp-code/repo.yaml new file mode 100644 index 000000000..06b271036 --- /dev/null +++ b/packaging/spack/exp-code/repo.yaml @@ -0,0 +1,2 @@ +repo: + namespace: 'exp-code' diff --git a/pyEXP/CMakeLists.txt b/pyEXP/CMakeLists.txt index d47080e6e..4b2e71b63 100644 --- a/pyEXP/CMakeLists.txt +++ b/pyEXP/CMakeLists.txt @@ -1,46 +1,71 @@ -find_package (Python3 COMPONENTS Interpreter Development) +find_package(Python3 REQUIRED) +find_package(PythonExtensions QUIET) + +# Copy Python init file to build directory +configure_file(__init__.py __init__.py COPYONLY) # Default build environment -# -set(common_LINKLIB OpenMP::OpenMP_CXX MPI::MPI_CXX yaml-cpp - exputil ${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) +set(common_LINKLIBS ${OpenMP_CXX_LIBRARIES} ${MPI_CXX_LIBRARIES} + ${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} + HighFive) + +set(common_INCLUDE $ + ${DEP_INC} ${CMAKE_CURRENT_SOURCE_DIR} + ${HDF5_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} + ${EXPutil_INCLUDE_DIRS} ${EXPui_INCLUDE_DIRS} ${EXPcommon_INCLUDE_DIRS}) -if(PNG_FOUND) - list(APPEND common_LINKLIB PNG::PNG) +set(common_INCLUDE_PRIVATE + ${CMAKE_BINARY_DIR}/config) + +find_package(EXPutil QUIET) +if(EXPutil_FOUND) + list(APPEND common_LINKLIBS EXP::EXPutil) + list(APPEND common_INCLUDE ${EXPutil_INCLUDE_DIRS}) +else() + list(APPEND common_LINKLIBS exputil) #internal name + list(APPEND common_INCLUDE_PRIVATE $) endif() -set(common_INCLUDE $ - $ - $ - ${CMAKE_BINARY_DIR} ${DEP_INC} ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. ${HighFive_SOURCE_DIR}/include - ${HDF5_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR}) +find_package(EXPui QUIET) +if(EXPui_FOUND) + list(APPEND common_LINKLIBS EXP::EXPui) + list(APPEND common_INCLUDE ${EXPui_INCLUDE_DIRS}) +else() + list(APPEND common_LINKLIBS expui) #internal name + list(APPEND common_INCLUDE_PRIVATE $) +endif() -if(ENABLE_CUDA) - list(APPEND common_LINKLIB CUDA::cudart CUDA::nvToolsExt) +if(USE_SUBMODULES) + list(APPEND common_INCLUDE_PRIVATE + $) + list(APPEND common_LINKLIBS yaml-cpp) endif() -if(SLURM_FOUND) - list(APPEND common_LINKLIB ${SLURM_LIBRARY}) +if(ENABLE_CUDA) + list(APPEND common_LINKLIBS CUDA::cudart CUDA::nvToolsExt) endif() -if(ENABLE_XDR AND TIRPC_FOUND) - list(APPEND common_LINKLIB ${TIRPC_LIBRARIES}) +if(SLURM_FOUND) + list(APPEND common_LINKLIBS ${SLURM_LIBRARY}) endif() # Build and configure the installation of the Python bindings -# -pybind11_add_module(pyEXP PyWrappers.cc CoefWrappers.cc +pybind11_add_module(_pyEXP PyWrappers.cc CoefWrappers.cc UtilWrappers.cc BasisWrappers.cc FieldWrappers.cc ParticleReaderWrappers.cc MSSAWrappers.cc EDMDWrappers.cc) -target_link_libraries(pyEXP PUBLIC expui exputil ${common_LINKLIB}) -target_include_directories(pyEXP PUBLIC ${common_INCLUDE}) -target_compile_options(pyEXP PUBLIC ${OpenMP_CXX_FLAGS}) -get_target_property(cxxflags pyEXP COMPILE_OPTIONS) -message("The project has set the following flags: ${cxxflags}") - -install(TARGETS pyEXP - RUNTIME DESTINATION bin - LIBRARY DESTINATION "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages" - ARCHIVE DESTINATION "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages") +target_link_libraries(_pyEXP PUBLIC ${common_LINKLIBS} ) +target_include_directories(_pyEXP PUBLIC ${common_INCLUDE}) +target_include_directories(_pyEXP PRIVATE ${common_INCLUDE_PRIVATE}) +target_compile_options(_pyEXP PUBLIC ${OpenMP_CXX_FLAGS}) + +if(PYTHON_RELATIVE_SITE_PACKAGES_DIR) + install(TARGETS _pyEXP DESTINATION ${PYTHON_RELATIVE_SITE_PACKAGES_DIR}/pyEXP) + install(FILES "__init__.py" DESTINATION ${PYTHON_RELATIVE_SITE_PACKAGES_DIR}/pyEXP) +else() + install(TARGETS _pyEXP + RUNTIME DESTINATION bin + LIBRARY DESTINATION "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/pyEXP" + ARCHIVE DESTINATION "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/pyEXP") + install(FILES "__init__.py" DESTINATION lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/pyEXP) +endif() diff --git a/pyEXP/PyWrappers.cc b/pyEXP/PyWrappers.cc index 5f719688d..03c9e0190 100644 --- a/pyEXP/PyWrappers.cc +++ b/pyEXP/PyWrappers.cc @@ -14,7 +14,7 @@ extern void FieldGeneratorClasses(py::module &m); extern void ParticleReaderClasses(py::module &m); extern void UtilityClasses (py::module &m); -PYBIND11_MODULE(pyEXP, m) +PYBIND11_MODULE(_pyEXP, m) { m.doc() = "pyEXP\n" @@ -99,7 +99,7 @@ PYBIND11_MODULE(pyEXP, m) "dynamical features in simulations that are hard to find `by eye'.\n\n" "Please send comments, suggestions, and particularly good cookies to:\n" "mdw@umass.edu (Martin Weinberg)\n\n"; - + auto mod_coefs = m.def_submodule("coefs", "Classes for reading, passing and " "manipulating coefficient sets"); @@ -121,11 +121,11 @@ PYBIND11_MODULE(pyEXP, m) auto mod_mssa = m.def_submodule("mssa", "Tools to apply Multivariate Singular " "Spectrum Analysis (MSSA) to the coefficients " "computed using the 'basis' classes"); - + auto mod_edmd = m.def_submodule("edmd", "Tools to apply extended Dynamical Mode " "Decomposition to the coefficients computed using " "the 'basis' classes"); - + auto mod_util = m.def_submodule("util", "Miscellaneous tools that support the " "others. Currently these contain several " "centering algorithms."); diff --git a/pyEXP/__init__.py b/pyEXP/__init__.py new file mode 100644 index 000000000..5e6ed9e77 --- /dev/null +++ b/pyEXP/__init__.py @@ -0,0 +1 @@ +from ._pyEXP import * diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 04bd285ae..d88315748 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ - set(CUDA_SRC) if (ENABLE_CUDA) list(APPEND CUDA_SRC cudaPolarBasis.cu cudaSphericalBasis.cu @@ -22,47 +21,118 @@ set(exp_SOURCES Basis.cc Bessel.cc Component.cc ParticleFerry.cc chkSlurm.c chkTimer.cc GravKernel.cc ${CUDA_SRC} CenterFile.cc PolarBasis.cc FlatDisk.cc signals.cc) -set(common_INCLUDE_DIRS - $ - $ - $ - $ - ${CMAKE_BINARY_DIR} ${DEP_INC} - ${CMAKE_CURRENT_SOURCE_DIR} - ${EIGEN3_INCLUDE_DIR}) +set(common_INCLUDE + $ + ${EXPUTIL_INCLUDE} + ${EXPUI_INCLUDE} + ${HDF5_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR}) + +set(common_INCLUDE_PRIVATE + $ + $ + $) + +set(DSMC_LIBS) +if (ENABLE_DSMC) + add_subdirectory(${PROJECT_SOURCE_DIR}/extern/DSMC/src DSMC) + list(APPEND DSMC_LIBS expdsmc) +endif() + +set(common_LINKLIBS + ${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES} + ${DSMC_LIBS} ${DEP_LIB} + HighFive + ${OpenMP_CXX_LIBRARIES} ${MPI_CXX_LIBRARIES} + ${YAML_CPP_LIBRARIES} ${VTK_LIBRARIES} + ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) + +find_package(EXPutil) +if(EXPutil_FOUND) + list(APPEND common_LINKLIBS EXP::EXPutil) + list(APPEND common_INCLUDE ${EXPutil_INCLUDE_DIRS}) +else() + list(APPEND common_LINKLIBS exputil) #internal name + list(APPEND common_INCLUDE_PRIVATE $) +endif() + +find_package(EXPui QUIET) +if(EXPui_FOUND) + list(APPEND common_LINKLIBS EXP::EXPui) + list(APPEND common_INCLUDE ${EXPui_INCLUDE_DIRS}) +else() + list(APPEND common_LINKLIBS expui) #internal name + list(APPEND common_INCLUDE_PRIVATE $) +endif() -set(common_LINKLIB exputil expui OpenMP::OpenMP_CXX MPI::MPI_CXX - yaml-cpp ${VTK_LIBRARIES}) +if(USE_SUBMODULES) + list(APPEND common_INCLUDE_PRIVATE + $) + list(APPEND common_LINKLIBS yaml-cpp) +endif() if(PNG_FOUND) - list(APPEND common_LINKLIB PNG::PNG) + list(APPEND common_LINKLIBS PNG::PNG) + list(APPEND common_INCLUDE ${PNG_INCLUDE_DIRS}) + add_definitions(${PNG_DEFINITIONS}) endif() if(ENABLE_CUDA) - list(APPEND common_INCLUDE_DIRS ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDAToolkit_INCLUDE_DIRS}) - list(APPEND common_LINKLIB CUDA::cudart CUDA::nvToolsExt) + list(APPEND common_INCLUDE ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES} ${CUDAToolkit_INCLUDE_DIRS}) + list(APPEND common_LINKLIBS CUDA::cudart CUDA::nvToolsExt) endif() if(SLURM_FOUND) - list(APPEND common_LINKLIB ${SLURM_LIBRARY}) + list(APPEND common_LINKLIBS ${SLURM_LIBRARY}) endif() if(ENABLE_XDR AND TIRPC_FOUND) - list(APPEND common_LINKLIB ${TIRPC_LIBRARY}) + list(APPEND common_INCLUDE ${TIRPC_INCLUDE_DIRS}) + list(APPEND common_LINKLIBS ${TIRPC_LIBRARY}) endif() + add_library(EXPlib ${exp_SOURCES}) + set_target_properties(EXPlib PROPERTIES OUTPUT_NAME EXPlib) -target_include_directories(EXPlib PUBLIC ${common_INCLUDE_DIRS}) -target_link_libraries(EXPlib PUBLIC ${common_LINKLIB}) +set_target_properties (EXPlib PROPERTIES EXPORT_NAME EXPnbody) +target_include_directories(EXPlib PUBLIC ${common_INCLUDE}) +target_include_directories(EXPlib PRIVATE ${common_INCLUDE_PRIVATE}) +target_link_libraries(EXPlib PUBLIC ${common_LINKLIBS}) if (ENABLE_USER) add_subdirectory(user) endif() -add_executable(exp expand.cc) -target_include_directories(exp PUBLIC ${common_INCLUDE_DIRS}) -target_link_libraries(exp PUBLIC ${common_LINKLIB} EXPlib) +add_executable(exp expand.cc expand.H) +target_include_directories(exp PRIVATE ${common_INCLUDE_PRIVATE}) +target_include_directories(exp PUBLIC ${common_INCLUDE}) +target_link_libraries(exp PUBLIC EXPlib ${common_LINKLIBS}) +target_compile_options(exp PUBLIC ${OpenMP_CXX_FLAGS}) + +install(TARGETS EXPlib exp + EXPORT EXPnbodyTargets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + PUBLIC_HEADER DESTINATION include/exputil) + +if (INSTALL_CMAKE_FIND) + # Set up cmake configs + set(CMAKEPACKAGE_INSTALL_DIR share/EXPnbody/cmake) + install (EXPORT EXPnbodyTargets + FILE EXPnbodyTargets.cmake + NAMESPACE EXP:: + DESTINATION ${CMAKEPACKAGE_INSTALL_DIR}) -install(TARGETS EXPlib DESTINATION lib) -install(TARGETS exp DESTINATION bin) + include(CMakePackageConfigHelpers) + configure_package_config_file(EXPnbodyConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/EXPnbodyConfig.cmake + INSTALL_DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} + PATH_VARS CMAKEPACKAGE_INSTALL_DIR CMAKE_INSTALL_PREFIX + ) + write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EXPnbodyVersion.cmake + VERSION ${CMAKE_PROJECT_VERSION} + COMPATIBILITY SameMinorVersion ) + install (FILES ${CMAKE_CURRENT_BINARY_DIR}/EXPnbodyConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/EXPnbodyVersion.cmake + DESTINATION ${CMAKEPACKAGE_INSTALL_DIR} ) +endif() \ No newline at end of file diff --git a/src/EXPnbodyConfig.cmake.in b/src/EXPnbodyConfig.cmake.in new file mode 100644 index 000000000..69e23cc5f --- /dev/null +++ b/src/EXPnbodyConfig.cmake.in @@ -0,0 +1,13 @@ +# Generates the cmake find_package files for EXPnbody + +@PACKAGE_INIT@ + +if(NOT TARGET EXP::EXPnbody) + include(@PACKAGE_CMAKEPACKAGE_INSTALL_DIR@/EXPnbodyTargets.cmake) +endif() + +set_and_check(EXPnbody_INCLUDE_DIRS @PACKAGE_CMAKE_INSTALL_PREFIX@/include/expnbody) +set_and_check(EXPnbody_LIBRARY_DIRS @PACKAGE_CMAKE_INSTALL_PREFIX@/lib) +set_and_check(EXPnbody_LIBRARIES @PACKAGE_CMAKE_INSTALL_PREFIX@/lib/libexpnbody.so) + +check_required_components(EXPnbody) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9aee83328..d9d592b72 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,21 +6,21 @@ if(ENABLE_PYEXP) # Check that pyEXP can be loaded; does not execute anything add_test(NAME pyexpLoadTest COMMAND ${CMAKE_COMMAND} -E env - PYTHONPATH=${CMAKE_BINARY_DIR}/pyEXP:$ENV{PYTHONPATH} + PYTHONPATH=${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH} ${PYTHON_EXECUTABLE} import.py WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}") # Make a spherical basis using pyEXP add_test(NAME pyexpSphBasisTest COMMAND ${CMAKE_COMMAND} -E env - PYTHONPATH=${CMAKE_BINARY_DIR}/pyEXP:$ENV{PYTHONPATH} + PYTHONPATH=${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH} ${PYTHON_EXECUTABLE} sph_basis.py WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/Halo") # Make a cylindrical basis using pyEXP add_test(NAME pyexpCylBasisTest COMMAND ${CMAKE_COMMAND} -E env - PYTHONPATH=${CMAKE_BINARY_DIR}/pyEXP:$ENV{PYTHONPATH} + PYTHONPATH=${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH} ${PYTHON_EXECUTABLE} cyl_basis.py WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/Disk") @@ -52,16 +52,16 @@ endif() if(ENABLE_NBODY) # Check that exp executes; does not test any functionality add_test(NAME expExecuteTest - COMMAND ${EXP_MPI_LAUNCH} ${CMAKE_BINARY_DIR}/src/exp -v) + COMMAND ${EXP_MPI_LAUNCH} -- ${CMAKE_BINARY_DIR}/src/exp -v) # Makes some spherical ICs using utils/ICs/gensph add_test(NAME makeICTest - COMMAND ${EXP_MPI_LAUNCH} ${CMAKE_BINARY_DIR}/utils/ICs/gensph -N 10000 -i SLGridSph.model + COMMAND ${EXP_MPI_LAUNCH} -- ${CMAKE_BINARY_DIR}/utils/ICs/gensph -N 10000 -i SLGridSph.model WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Halo) # Runs those ICs using exp add_test(NAME expNbodyTest - COMMAND ${EXP_MPI_LAUNCH} ${CMAKE_BINARY_DIR}/src/exp config.yml + COMMAND ${EXP_MPI_LAUNCH} -- ${CMAKE_BINARY_DIR}/src/exp config.yml WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Halo) set_tests_properties(expNbodyTest PROPERTIES DEPENDS makeICTest) @@ -69,7 +69,7 @@ if(ENABLE_NBODY) # Check OUTLOG file for a sane 2T/W mean and stdv add_test(NAME expNbodyCheck2TW COMMAND ${CMAKE_COMMAND} -E env - PYTHONPATH=${CMAKE_BINARY_DIR}/pyEXP:$ENV{PYTHONPATH} + PYTHONPATH=${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH} ${PYTHON_EXECUTABLE} check.py WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Halo) @@ -81,7 +81,7 @@ if(ENABLE_NBODY) # Read coefficient file with pyEXP add_test(NAME pyEXPCoefReadTest COMMAND ${CMAKE_COMMAND} -E env - PYTHONPATH=${CMAKE_BINARY_DIR}/pyEXP:$ENV{PYTHONPATH} + PYTHONPATH=${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH} ${PYTHON_EXECUTABLE} readCoefs.py WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/Halo") set_tests_properties(pyEXPCoefReadTest PROPERTIES DEPENDS makeNbodyTest) @@ -104,12 +104,12 @@ if(ENABLE_NBODY) # Makes some cube ICs using utils/ICs/cubeics add_test(NAME makeCubeICTest - COMMAND ${EXP_MPI_LAUNCH} ${CMAKE_BINARY_DIR}/utils/ICs/cubeics -N 4000 -z -d 2,2,2 + COMMAND ${EXP_MPI_LAUNCH} -- ${CMAKE_BINARY_DIR}/utils/ICs/cubeics -N 4000 -z -d 2,2,2 WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Cube) # Runs those ICs using exp add_test(NAME expCubeTest - COMMAND ${EXP_MPI_LAUNCH} ${CMAKE_BINARY_DIR}/src/exp + COMMAND ${EXP_MPI_LAUNCH} -- ${CMAKE_BINARY_DIR}/src/exp WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Cube) set_tests_properties(expCubeTest PROPERTIES DEPENDS makeCubeICTest) @@ -117,7 +117,7 @@ if(ENABLE_NBODY) # Check OUTLOG file for mean position add_test(NAME expCubeCheckPos COMMAND ${CMAKE_COMMAND} -E env - PYTHONPATH=${CMAKE_BINARY_DIR}/pyEXP:$ENV{PYTHONPATH} + PYTHONPATH=${CMAKE_BINARY_DIR}:$ENV{PYTHONPATH} ${PYTHON_EXECUTABLE} check.py WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/Cube) diff --git a/tests/Cube/.gitignore b/tests/Cube/.gitignore new file mode 100644 index 000000000..66924cc8a --- /dev/null +++ b/tests/Cube/.gitignore @@ -0,0 +1,4 @@ +* +!check.py +!config.yml +!.gitignore \ No newline at end of file diff --git a/tests/Halo/.gitignore b/tests/Halo/.gitignore new file mode 100644 index 000000000..bbdc918da --- /dev/null +++ b/tests/Halo/.gitignore @@ -0,0 +1,4 @@ +* +!*.py +!config.yaml +!.gitignore \ No newline at end of file diff --git a/utils/Analysis/CMakeLists.txt b/utils/Analysis/CMakeLists.txt index d06dbe69c..ffc7c1874 100644 --- a/utils/Analysis/CMakeLists.txt +++ b/utils/Analysis/CMakeLists.txt @@ -5,7 +5,7 @@ set(bin_PROGRAMS diskcoef halocoef diskcoef diskprof haloprof slabprof pcatest readcoefsD readcoefsH sphprof pspxvalH pspxvalH2 pspxvalD pspxvalD2 pspKLH pspKLD diskeof yaml_diff kdtest) -set(common_LINKLIB OpenMP::OpenMP_CXX MPI::MPI_CXX yaml-cpp exputil +set(common_LINKLIB OpenMP::OpenMP_CXX MPI::MPI_CXX yaml-cpp::yaml-cpp exputil ${VTK_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}) if(PNG_FOUND) @@ -32,7 +32,7 @@ set(common_INCLUDE $ add_executable(diskcoef diskprof_coef.cc) add_executable(halocoef haloprof_coef.cc SphSL.cc) -add_executable(diskprof diskprof.cc) +add_executable(diskprof diskprof.cc) add_executable(haloprof haloprof.cc SphSL.cc) add_executable(slabprof slabprof.cc) add_executable(psphisto psphisto.cc) diff --git a/utils/ICs/CMakeLists.txt b/utils/ICs/CMakeLists.txt index 06cbb8b18..93faa87cf 100644 --- a/utils/ICs/CMakeLists.txt +++ b/utils/ICs/CMakeLists.txt @@ -19,6 +19,7 @@ endif() set(common_INCLUDE $ $ + $ $ $ $ diff --git a/utils/MSSA/CMakeLists.txt b/utils/MSSA/CMakeLists.txt index c4db00080..bfcc91351 100644 --- a/utils/MSSA/CMakeLists.txt +++ b/utils/MSSA/CMakeLists.txt @@ -2,20 +2,12 @@ set(bin_PROGRAMS exp_haloN disk_noise halo_noise expmssa) set(common_LINKLIB yaml-cpp exputil ${VTK_LIBRARIES} ${EIGEN3_LIBRARIES} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} - ${FFTW_DOUBLE_LIB}) + ${FFTW_DOUBLE_LIB} ${FFTW3_LIBRARIES} ${PNG_LIBRARIES}) if(PNG_FOUND) list(APPEND common_LINKLIB PNG::PNG) endif() -set(common_INCLUDE $ - $ - $ ${CMAKE_BINARY_DIR} - $ - ${DEP_INC} ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. ${EIGEN3_INCLUDE_DIR} ${FFTW_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS}) - if(ENABLE_CUDA) list(APPEND common_LINKLIB CUDA::cudart CUDA::nvToolsExt) endif() @@ -28,6 +20,13 @@ if(ENABLE_XDR AND TIRPC_FOUND) list(APPEND common_LINKLIB ${TIRPC_LIBRARIES}) endif() +set(common_INCLUDE $ + $ + $ + ${CMAKE_BINARY_DIR} ${DEP_INC} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/.. ${HDF5_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} + ${YAML_CPP_INCLUDE_DIR} ${FFTW_INCLUDE_DIRS} ${FFTW3_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS}) + add_executable(exp_haloN exp_haloN.cc Coefs.cc) add_executable(disk_noise exp_disk_noise.cc Coefs.cc) add_executable(halo_noise exp_halo_noise.cc Coefs.cc) @@ -35,7 +34,7 @@ add_executable(expmssa expmssa.cc Coefs.cc CoefDB.cc KMeans.cc) foreach(program ${bin_PROGRAMS}) target_link_libraries(${program} ${common_LINKLIB} OpenMP::OpenMP_CXX MPI::MPI_CXX) - target_include_directories(${program} PUBLIC ${common_INCLUDE}) + target_include_directories(${program} BEFORE PUBLIC ${common_INCLUDE}) install(TARGETS ${program} DESTINATION bin) endforeach() diff --git a/utils/PhaseSpace/CMakeLists.txt b/utils/PhaseSpace/CMakeLists.txt index 71d1c2141..0753ff54b 100644 --- a/utils/PhaseSpace/CMakeLists.txt +++ b/utils/PhaseSpace/CMakeLists.txt @@ -32,7 +32,7 @@ set(common_INCLUDE $ $ $ - $ + $ $ ${CMAKE_BINARY_DIR} ${DEP_INC} ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/utils/SL/CMakeLists.txt b/utils/SL/CMakeLists.txt index 55fe30615..3f8e495c5 100644 --- a/utils/SL/CMakeLists.txt +++ b/utils/SL/CMakeLists.txt @@ -1,7 +1,7 @@ set(bin_PROGRAMS slcheck slshift orthochk diskpot qtest eoftest oftest slabchk) - + set(common_LINKLIB OpenMP::OpenMP_CXX MPI::MPI_CXX yaml-cpp exputil ${VTK_LIBRARIES}) @@ -16,6 +16,7 @@ endif() set(common_INCLUDE $ $ + $ $ $ ${CMAKE_BINARY_DIR} ${DEP_INC} diff --git a/utils/SL/oftest.cc b/utils/SL/oftest.cc index 1c16b36f5..61df9dac4 100644 --- a/utils/SL/oftest.cc +++ b/utils/SL/oftest.cc @@ -24,7 +24,7 @@ class genE double R, a; double f(double x) { return R - (1.0 - (1.0 + x)*exp(-x)); }; double df(double x){ return -x*exp(-x); }; - + public: genE(double a) : a(a) { @@ -44,7 +44,7 @@ class genE x += delF; if (fabs(delF)(filename)->default_value("testof")) ; - + //=================== // Parse options //=================== @@ -124,7 +124,7 @@ int main(int argc, char** argv) return exp(-r/A) * 0.5*(1.0 + std::erf((rmax - 5.0*delta - r)/delta)) / (A*A); }; - + // Generate the orthogonal function instance // OrthoFunction ortho(nmax, densfunc, rmin, rmax, scale, 2); @@ -133,11 +133,11 @@ int main(int argc, char** argv) // Output file for grid // std::ofstream out(filename + ".dat"); - + // Define some representative limits // double Rmax = 4.0*A; - + // Grid spacing // if (logr) { @@ -153,23 +153,24 @@ int main(int argc, char** argv) if (logr) R = exp(R); out << std::setw(18) << R; - for (auto v : ortho(R)) - out << std::setw(18) << v; + auto p = ortho(R); + for (int i=0; i coef(nmax, 0.0); - + for (int n=0; n