diff --git a/.gitignore b/.gitignore index 674a2f7f4..5056a889a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,13 @@ dump* !docs/*/*/* !README_figs/* +#Docker and Singularity files +!docker/ +!singularity/ +!Dockerfile +!environment.yml + bin/ build/* -disruption_headon/swiftest_driver.sh + + diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ce5af9cf..961683f3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,14 +28,12 @@ IF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90) ENDIF(NOT CMAKE_Fortran_COMPILER_SUPPORTS_F90) # Set some options the user may choose -# Uncomment the below if you want the user to choose a parallelization library -OPTION(USE_MPI "Use the MPI library for parallelization" ON) +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(CONTAINERIZE "Compiling for use in a Docker/Singularity container" OFF) +OPTION(BUILD_SHARED_LIBS "Build using shared libraries" ON) - -# Locate and set parallelization libraries. There are some CMake peculiarities -# taken care of here, such as the fact that the FindOpenMP routine doesn't know -# about Fortran. INCLUDE(${CMAKE_MODULE_PATH}/SetParallelizationLibrary.cmake) INCLUDE(${CMAKE_MODULE_PATH}/SetUpNetCDF.cmake) INCLUDE(${CMAKE_MODULE_PATH}/SetMKL.cmake) @@ -46,7 +44,6 @@ INCLUDE(${CMAKE_MODULE_PATH}/SetFortranFlags.cmake) INCLUDE_DIRECTORIES($ENV{NETCDF_FORTRAN_HOME}/include;$ENV{NETCDF_HOME}/include) - # There is an error in CMAKE with this flag for pgf90. Unset it GET_FILENAME_COMPONENT(FCNAME ${CMAKE_Fortran_COMPILER} NAME) IF(FCNAME STREQUAL "pgf90") diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..ce3e615c3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,158 @@ +# Copyright 2023 - David Minton +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. +# +# This Dockerfile will build the Swiftest driver program with minimal external dependencies using the Intel Oneapi toolkit. +# This is done by building static versions of a minimal set of libraries that NetCDF-Fortran needs (Netcdf-C, HDF5, and Zlib). +# These, along with the Intel runtime libraries, are linked statically to the executable. Only the OS-specific libraries are linked +# dynamically. + +# This build target compiles all dependencies and the swiftest driver itself +FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build_deps + +ENV INSTALL_DIR="/usr/local" +ENV CC="${ONEAPI_ROOT}/compiler/latest/linux/bin/icx" +ENV FC="${ONEAPI_ROOT}/compiler/latest/linux/bin/ifx" +ENV CXX="${ONEAPI_ROOT}/compiler/latest/linux/bin/icpx" +ENV F77="${FC}" + +# Get the HDF5, NetCDF-C, and NetCDF-Fortran libraries +RUN wget -qO- https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.14/hdf5-1.14.1/src/hdf5-1.14.1-2.tar.gz | tar xvz && \ + wget -qO- https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz | tar xvz && \ + wget -qO- https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz | tar xvz && \ + wget -qO- https://www.zlib.net/zlib-1.2.13.tar.gz | tar xvz + +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + m4 && \ + rm -rf /var/lib/apt/lists/* + +RUN cd zlib-1.2.13 && \ + ./configure --prefix=${INSTALL_DIR} --static && \ + make && \ + make install + +RUN cd hdf5-1.14.1-2 && \ + ./configure --disable-shared \ + --enable-build-mode=production \ + --disable-fortran \ + --disable-java \ + --disable-cxx \ + --prefix=${INSTALL_DIR} \ + --with-zlib=${INSTALL_DIR} && \ + make && \ + make install + +RUN cd netcdf-c-4.9.2 && \ + ./configure --disable-shared \ + --disable-dap \ + --disable-libxml2 \ + --disable-byterange \ + --prefix=${INSTALL_DIR} && \ + make && \ + make install + +ENV NCDIR="${INSTALL_DIR}" +ENV NFDIR="${INSTALL_DIR}" +ENV HDF5_ROOT="${INSTALL_DIR}" +ENV HDF5_LIBDIR="${HDF5_ROOT}/lib" +ENV HDF5_INCLUDE_DIR="${HDF5_ROOT}/include" +ENV HDF5_PLUGIN_PATH="${HDF5_LIBDIR}/plugin" + +# NetCDF-Fortran library +ENV CFLAGS="-fPIC" +ENV FCFLAGS="${CFLAGS} -standard-semantics" +ENV FFLAGS=${CFLAGS} +ENV CPPFLAGS="-I${INSTALL_DIR}/include" +ENV LIBS="-L/usr/local/lib -L/usr/lib/x86_64-linux-gnu -lnetcdf -lhdf5_hl -lhdf5 -lm -lz" +RUN cd netcdf-fortran-4.6.1 && \ + ./configure --disable-shared --prefix=${NFDIR} && \ + make && \ + make install + +FROM intel/oneapi-hpckit:2023.1.0-devel-ubuntu20.04 as build_driver +COPY --from=build_deps /usr/local/. /usr/local/ +ENV INSTALL_DIR="/usr/local" +ENV CC="${ONEAPI_ROOT}/compiler/latest/linux/bin/icx" +ENV FC="${ONEAPI_ROOT}/compiler/latest/linux/bin/ifx" +ENV CXX="${ONEAPI_ROOT}/compiler/latest/linux/bin/icpx" +ENV F77="${FC}" + +# The MACHINE_CODE_VALUE argument is a string that is used when compiling the swiftest_driver. It is appended to the "-x" compiler +# option: (-x${MACHINE_CODE_VALUE}). The default value is set to "sse2" which allows for certain SIMD instructions to be used while +# remaining # compatible with a wide range of CPUs. To get the highest performance, you can pass "host" as an argument, but the +# compiled binary # would only run on a CPU with an architecture compatible with the one that the build was performed on. +# For more details and other options, see: +# https://www.intel.com/content/www/us/en/docs/fortran-compiler/developer-guide-reference/2023-1/x-qx.html +ARG MACHINE_CODE_VALUE="sse2" + +# Build type options are DEBUG, RELEASE, PROFILE, or TESTING. +ARG BUILD_TYPE="RELEASE" + +# Swiftest +ENV NETCDF_HOME=${INSTALL_DIR} +ENV NETCDF_FORTRAN_HOME=${NETCDF_HOME} +ENV NETCDF_LIBRARY=${NETCDF_HOME} +ENV FOR_COARRAY_NUM_IMAGES=1 +ENV OMP_NUM_THREADS=1 +ENV FC="${ONEAPI_ROOT}/mpi/latest/bin/mpiifort" +ENV FFLAGS="-fPIC -standard-semantics" +ENV LDFLAGS="-L/usr/local/lib" +ENV LIBS="-lhdf5_hl -lhdf5 -lz" +COPY ./cmake/ /swiftest/cmake/ +COPY ./src/ /swiftest/src/ +COPY ./CMakeLists.txt /swiftest/ +RUN cd swiftest && \ + cmake -S . -B build -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ + -DMACHINE_CODE_VALUE=${MACHINE_CODE} \ + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DUSE_COARRAY=OFF \ + -DBUILD_SHARED_LIBS=OFF && \ + cmake --build build && \ + cmake --install build + +# This build target creates a container that executes just the driver program +FROM ubuntu:20.04 as driver +COPY --from=build_driver /usr/local/bin/swiftest_driver /usr/local/bin/ +ENTRYPOINT ["/usr/local/bin/swiftest_driver"] + +# This build target exports the binary to the host +FROM scratch AS export_driver +COPY --from=build_driver /usr/local/bin/swiftest_driver / + +# This build target creates a container with a conda environment with all dependencies needed to run the Python front end and +# analysis tools +FROM continuumio/miniconda3 as python +SHELL ["/bin/bash", "--login", "-c"] +ENV SHELL="/bin/bash" +ENV PATH="/opt/conda/bin:${PATH}" +ENV LD_LIBRARY_PATH="/usr/local/lib" + +RUN conda update --all -y && \ + conda install conda-libmamba-solver -y && \ + conda config --set solver libmamba + +COPY environment.yml . +RUN conda env create -f environment.yml && \ + conda init bash && \ + echo "conda activate swiftest-env" >> ~/.bashrc + +COPY ./python/. /opt/conda/pkgs/ +COPY --from=build_driver /usr/local/bin/swiftest_driver /opt/conda/bin/swiftest_driver + +# Start new shell to activate the environment and install Swiftest +RUN cd /opt/conda/pkgs/swiftest && conda develop . && \ + conda clean --all -y && \ + mkdir -p /.astropy && \ + chmod -R 777 /.astropy && \ + mkdir -p /.cache/matplotlib && \ + mkdir -p /.config/matplotlib && \ + chmod -R 777 /.cache/matplotlib && \ + chmod -R 777 /.config/matplotlib + +ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "swiftest-env"] \ No newline at end of file diff --git a/README.md b/README.md index 033d86834..3671832cb 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,9 @@ Swiftest also includes the collisional fragmentation algorithm **Fraggle**, an a #### Installation -**System Requirements** +In order to use Swiftest, you need to have a working `swiftest_driver` executable. Currently, this can be obtained by either compiling the source code on the system you plan to run simulations on (fastest), or by running it from a Docker/Singularity container compiled for an x86_64 CPU using the Intel Fortran compiler (slower) or compiled using the GNU/gfortran compiler (slowest). + +**Building the `swiftest_driver` executable** Swiftest is designed to be downloaded, compiled, and run on a Linux based system. It is untested on Windows systems. @@ -103,6 +105,29 @@ $ make The Swiftest executable, called ```swiftest_driver```, should now be created in the ```/swiftest/bin/``` directory. +**Download the `swiftest_driver` as a Docker or Singularity container.** + +The Swiftest driver is available as a Docker container on DockerHub in two versions: Intel and GNU. The Intel version was compiled for the x86_64 CPU using the Intel classic Fortran compiler. The GNU version was compliled for the x86_64 CPU using gfortran. The Intel version is faster than the GNU version (though not as fast as a native compile to the target CPU that you wish to run it on due to vectorization optimizations that Swiftest takes advantage of), however it is much larger: The Intel version is ~2.7GB while the GNU version is ~300MB. The Singularity container pulls from the same DockerHub container. + +To facilitate installation of the container, we provide a set of shell scripts to help automate the process of installing container versions of the executable. To install the default Intel version of the docker container from within the `swiftest\` project directory + +``` +$ cd docker +$ . ./install.sh +``` + +To install the GNU version: + +``` +$ cd docker +$ . ./install.sh gnu +``` + +The Singularity versions are installed the same way, just replace `cd docker` with `cd singularity` above. + +Whether installing either the Docker or Singularity containers, the install script will copy an executable shell script `swiftest_driver` into `swiftest/bin/`. Not that when installing the Singularity container, the install script will set an environment variable called `SWIFTEST_SIF` that must point to the aboslute path of the container file called `swiftest_driver.sif`. To use the driver script in a future shell, rather than running the install script again, we suggest adding the environment variable definition to your shell startup script (e.g. add `export SWIFTEST_SIF="/path/to/swiftest/singularity/swiftest.sif"` to your `.zshrc`) + + **Swiftest Python Package** Included with Swiftest, in the ```/swiftest/python/swiftest/``` directory, is a Python package designed to facilitate seamless data processing and analysis. The Python package, also called Swiftest, can be used to generate input files, run Swiftest simulations, and process output files in the NetCDF file format. diff --git a/apptainer/.gitignore b/apptainer/.gitignore new file mode 100644 index 000000000..baed94e88 --- /dev/null +++ b/apptainer/.gitignore @@ -0,0 +1,4 @@ +!bin/ +!bin/swiftest_driver +!bin/swiftest +!install.sh diff --git a/apptainer/bin/swiftest b/apptainer/bin/swiftest new file mode 100755 index 000000000..5d91b80d6 --- /dev/null +++ b/apptainer/bin/swiftest @@ -0,0 +1,4 @@ +#!/bin/sh -- +OMP_NUM_THREADS=${OMP_NUM_THREADS:-`nproc --all`} +FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES:-1} +apptainer run --bind $(pwd):$(pwd) --cleanenv --env OMP_NUM_THREADS=${OMP_NUM_THREADS},FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES} ${SWIFTEST_SIF} "$@" \ No newline at end of file diff --git a/apptainer/bin/swiftest_driver b/apptainer/bin/swiftest_driver new file mode 100755 index 000000000..e88be2805 --- /dev/null +++ b/apptainer/bin/swiftest_driver @@ -0,0 +1,4 @@ +#!/bin/sh -- +OMP_NUM_THREADS=${OMP_NUM_THREADS:-`nproc --all`} +FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES:-1} +apptainer exec --bind $(pwd):$(pwd) --env OMP_NUM_THREADS=${OMP_NUM_THREADS},FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES} ${SWIFTEST_SIF} swiftest_driver "$@" \ No newline at end of file diff --git a/apptainer/install.sh b/apptainer/install.sh new file mode 100755 index 000000000..5d84ca34a --- /dev/null +++ b/apptainer/install.sh @@ -0,0 +1,21 @@ +#!/bin/sh -- +# This will install the Apptainer version of the swiftest_driver in place of the native compiled version into ../bin as +# well as the swiftest_python script that is used to execute a Python input file. +# The swiftest.sif file will be copied to the SIF_DIR directory. The default location is ${HOME}/.apptainer. +# To change this, just set environment variable SIF_DIR prior to running this script. +# +# The script takes an optional argument "tag" if you want to pull a container other than "latest". +# +# In order to use one executable script, the SWIFTEST_SIF environment variable must be set to point to the location of swiftest.sif, +# which requires this script to be called via source: +# $ source ./install.sh +# or +# $ . ./install.sh +TAG=${1:-latest} + +SIF_DIR=${SIF_DIR:-${HOME}/.apptainer} +echo "Installing ${SIF_DIR}/swiftest.sif container from mintongroup/swiftest:${TAG} Docker container" +apptainer pull --force ${SIF_DIR}/swiftest.sif docker://mintongroup/swiftest:${TAG} +cp -rf bin/swiftest ../bin/ +cp -rf bin/swiftest_driver ../bin/ +export SWIFTEST_SIF=${SIF_DIR}/swiftest.sif \ No newline at end of file diff --git a/cmake/Modules/FindCoarray_Fortran.cmake b/cmake/Modules/FindCoarray_Fortran.cmake new file mode 100644 index 000000000..314371326 --- /dev/null +++ b/cmake/Modules/FindCoarray_Fortran.cmake @@ -0,0 +1,104 @@ +# Copyright 2022 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh +# This file is part of Swiftest. +# Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +# Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# You should have received a copy of the GNU General Public License along with Swiftest. +# If not, see: https://www.gnu.org/licenses. + +# - Finds Coarray support +# This module can be used to detect Coarray support in a compiler. +# If the compiler supports Coarray, the flags required to compile with +# coarray support are set. +# +# This module was modified from the standard FindOpenMP module to find Fortran +# flags. +# +# The following variables are set: +# Coarray_Fortran_FLAGS - flags to add to the Fortran compiler for Coarray +# support. In general, you must use these at both +# compile- and link-time. +# OMP_NUM_PROCS - the max number of processors available to Coarray + +#============================================================================= + +INCLUDE (${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) + +STRING(TOUPPER "${CMAKE_BUILD_TYPE}" BT) +IF(BT STREQUAL "DEBUG") + SET (Coarray_Fortran_FLAG_CANDIDATES + #Intel + "-coarray=single" + #Intel windows + "/Qcoarray:single" + #Gnu + "-fcoarray=single" + #Empty, if compiler automatically accepts coarray + " " + ) +ELSE() + SET (Coarray_Fortran_FLAG_CANDIDATES + #Intel + "-coarray=distributed" + #Intel windows + "/Qcoarray:distributed" + #Gnu + "-fcoarray=lib -lcaf_mpi" + #Empty, if compiler automatically accepts coarray + " " + ) +ENDIF() + + +IF (DEFINED Coarray_Fortran_FLAGS) + SET (Coarray_Fortran_FLAG_CANDIDATES) +ENDIF (DEFINED Coarray_Fortran_FLAGS) + +# check fortran compiler. also determine number of processors +FOREACH (FLAG ${Coarray_Fortran_FLAG_CANDIDATES}) + SET (SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + SET (CMAKE_REQUIRED_FLAGS "${FLAG}") + UNSET (Coarray_FLAG_DETECTED CACHE) + MESSAGE (STATUS "Try Coarray Fortran flag = [${FLAG}]") + FILE (WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCoarray.f90" +" +program TestCoarray + integer, codimension[*] :: i + write(*,'(I2)',ADVANCE='NO') num_images() +end program TestCoarray +") + SET (MACRO_CHECK_FUNCTION_DEFINITIONS + "-DCoarray_FLAG_DETECTED ${CMAKE_REQUIRED_FLAGS}") + TRY_RUN (Coarray_RUN_FAILED Coarray_FLAG_DETECTED ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCoarray.f90 + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + COMPILE_OUTPUT_VARIABLE OUTPUT + RUN_OUTPUT_VARIABLE OMP_NUM_PROCS_INTERNAL) + IF (Coarray_FLAG_DETECTED) + FILE (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran compiler supports Coarray passed with " + "the following output:\n${OUTPUT}\n\n") + SET (Coarray_FLAG_DETECTED 1) + IF (Coarray_RUN_FAILED) + MESSAGE (FATAL_ERROR "Coarray found, but test code did not run") + ENDIF (Coarray_RUN_FAILED) + SET (Coarray_Fortran_FLAGS_INTERNAL "${FLAG}") + BREAK () + ELSE () + FILE (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran compiler supports Coarray failed with " + "the following output:\n${OUTPUT}\n\n") + SET (Coarray_FLAG_DETECTED 0) + ENDIF (Coarray_FLAG_DETECTED) +ENDFOREACH (FLAG ${Coarray_Fortran_FLAG_CANDIDATES}) + +SET (Coarray_Fortran_FLAGS "${Coarray_Fortran_FLAGS_INTERNAL}" + CACHE STRING "Fortran compiler flags for Coarray parallization") + +# handle the standard arguments for FIND_PACKAGE +FIND_PACKAGE_HANDLE_STANDARD_ARGS (Coarray_Fortran DEFAULT_MSG + Coarray_Fortran_FLAGS) + +MARK_AS_ADVANCED(Coarray_Fortran_FLAGS) diff --git a/cmake/Modules/FindNETCDF.cmake b/cmake/Modules/FindNETCDF.cmake index 2355ad900..003d5b195 100644 --- a/cmake/Modules/FindNETCDF.cmake +++ b/cmake/Modules/FindNETCDF.cmake @@ -8,11 +8,14 @@ # If not, see: https://www.gnu.org/licenses. # - Finds the NetCDF libraries -find_path(NETCDF_INCLUDE_DIR NAMES netcdf.mod HINTS ENV NETCDF_FORTRAN_HOME) -find_library(NETCDF_LIBRARY NAMES netcdf HINTS ENV NETCDF_FORTRAN_HOME) -find_library(NETCDF_FORTRAN_LIBRARY NAMES netcdff HINTS ENV NETCDF_FORTRAN_HOME) + +find_path(NETCDF_INCLUDE_DIR NAMES netcdf.mod HINTS ENV NETCDF_FORTRAN_HOME ENV CPATH) +find_library(NETCDF_FORTRAN_LIBRARY NAMES netcdff HINTS ENV NETCDF_FORTRAN_HOME ENV LD_LIBRARY_PATH) +find_library(NETCDF_LIBRARY NAMES netcdf HINTS ENV NETCDF_FORTRAN_HOME ENV LD_LIBRARY_PATH) set(NETCDF_FOUND TRUE) set(NETCDF_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR}) -set(NETCDF_LIBRARIES ${NETCDF_LIBRARY} ${NETCDF_FORTRAN_LIBRARY}) +# Note for posterity: When building static libraries, NETCDF_FORTRAN_LIBRARY must come *before* NETCDF_LIBRARY. Otherwise you get a bunch of "undefined reference to" errors +set(NETCDF_LIBRARIES ${NETCDF_FORTRAN_LIBRARY} ${NETCDF_LIBRARY}) + mark_as_advanced(NETCDF_LIBRARY NETCDF_FORTRAN_LIBRARY NETCDF_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/Modules/FindOpenMP_Fortran.cmake b/cmake/Modules/FindOpenMP_Fortran.cmake index 32777569e..06d679e7c 100644 --- a/cmake/Modules/FindOpenMP_Fortran.cmake +++ b/cmake/Modules/FindOpenMP_Fortran.cmake @@ -25,24 +25,19 @@ INCLUDE (${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -SET (OpenMP_Fortran_FLAG_CANDIDATES - #Intel - "-qopenmp" - #Intel windows - "/Qopenmp" - #Gnu - "-fopenmp" - #Portland Group - "-mp" - #Empty, if compiler automatically accepts openmp - " " - #Sun - "-xopenmp" - #HP - "+Oopenmp" - #IBM XL C/c++ - "-qsmp" -) +IF (USE_SIMD) + SET (OpenMP_Fortran_FLAG_CANDIDATES + "-qopenmp" # Intel + "/Qopenmp" # Intel Windows + "-fopenmp" # GNU + ) +ELSE () + SET (OpenMP_Fortran_FLAG_CANDIDATES + "-qopenmp -qno-openmp-simd" # Intel + "/Qopenmp-simd-" # Intel Windows + "-fopenmp" # GNU + ) +ENDIF (USE_SIMD) IF (DEFINED OpenMP_Fortran_FLAGS) SET (OpenMP_Fortran_FLAG_CANDIDATES) diff --git a/cmake/Modules/SetCompileFlag.cmake b/cmake/Modules/SetCompileFlag.cmake index 4141c4773..d094009ed 100644 --- a/cmake/Modules/SetCompileFlag.cmake +++ b/cmake/Modules/SetCompileFlag.cmake @@ -45,6 +45,7 @@ FUNCTION(SET_COMPILE_FLAG FLAGVAR FLAGVAL LANG) SET(FAIL_REGEX "ignoring unknown option" # Intel "invalid argument" # Intel + "not supported" # Intel ifx "unrecognized .*option" # GNU "[Uu]nknown switch" # Portland Group "ignoring unknown option" # MSVC diff --git a/cmake/Modules/SetFortranFlags.cmake b/cmake/Modules/SetFortranFlags.cmake index 97009a25e..4c8cc9b85 100644 --- a/cmake/Modules/SetFortranFlags.cmake +++ b/cmake/Modules/SetFortranFlags.cmake @@ -19,36 +19,48 @@ INCLUDE(${CMAKE_MODULE_PATH}/SetCompileFlag.cmake) # Make sure the build type is uppercase STRING(TOUPPER "${CMAKE_BUILD_TYPE}" BT) +SET(BUILD_TYPE_MSG "Choose the type of build, options are DEBUG, RELEASE, PROFILE, or TESTING.") + IF(BT STREQUAL "RELEASE") SET(CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are DEBUG, RELEASE, PROFILE, or TESTING." + ${BUILD_TYPE_MSG} FORCE) ELSEIF(BT STREQUAL "DEBUG") SET (CMAKE_BUILD_TYPE DEBUG CACHE STRING - "Choose the type of build, options are DEBUG, RELEASE, PROFILE, or TESTING." + ${BUILD_TYPE_MSG} FORCE) ELSEIF(BT STREQUAL "TESTING") SET (CMAKE_BUILD_TYPE TESTING CACHE STRING - "Choose the type of build, options are DEBUG, RELEASE, PROFILE, or TESTING." + ${BUILD_TYPE_MSG} FORCE) ELSEIF(BT STREQUAL "PROFILE") SET (CMAKE_BUILD_TYPE PROFILE CACHE STRING - "Choose the type of build, options are DEBUG, RELEASE, PROFILE, or TESTING." - FORCE) + ${BUILD_TYPE_MSG} + FORCE) ELSEIF(NOT BT) SET(CMAKE_BUILD_TYPE RELEASE CACHE STRING - "Choose the type of build, options are DEBUG, RELEASE, PROFILE, or TESTING." + ${BUILD_TYPE_MSG} FORCE) MESSAGE(STATUS "CMAKE_BUILD_TYPE not given, defaulting to RELEASE") ELSE() - MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE not valid, choices are DEBUG, RELEASE, PROFILE, or TESTING") + MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE not valid! ${BUILD_TYPE_MSG}") ENDIF(BT STREQUAL "RELEASE") +IF (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + IF (APPLE) + SET(MACHINE_CODE_VALUE "tune=native" CACHE STRING "Tells the compiler which processor features it may target, including which instruction sets and optimizations it may generate.") + ELSE () + SET(MACHINE_CODE_VALUE "arch=native" CACHE STRING "Tells the compiler which processor features it may target, including which instruction sets and optimizations it may generate.") + ENDIF () +ELSE () + SET(MACHINE_CODE_VALUE "host" CACHE STRING "Tells the compiler which processor features it may target, including which instruction sets and optimizations it may generate.") +ENDIF () + ######################################################### # If the compiler flags have already been set, return now ######################################################### -IF(CMAKE_Fortran_FLAGS_RELEASE AND CMAKE_Fortran_FLAGS_TESTING AND CMAKE_Fortran_FLAGS_DEBUG AND CMAKE_Fortran_FLAGS_PROFILE) +IF(CMAKE_Fortran_FLAGS_RELEASE AND CMAKE_Fortran_FLAGS_TESTING AND CMAKE_Fortran_FLAGS_DEBUG AND CMAKE_Fortran_FLAGS_PROFILE ) RETURN () ENDIF(CMAKE_Fortran_FLAGS_RELEASE AND CMAKE_Fortran_FLAGS_TESTING AND CMAKE_Fortran_FLAGS_DEBUG AND CMAKE_Fortran_FLAGS_PROFILE) @@ -64,28 +76,91 @@ ENDIF(CMAKE_Fortran_FLAGS_RELEASE AND CMAKE_Fortran_FLAGS_TESTING AND CMAKE_Fort ### GENERAL FLAGS ### ##################### +# Free form +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-ffree-form" # GNU + ) + # Don't add underscores in symbols for C-compatability SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" - Fortran "-fno-underscoring") + Fortran "-fno-underscoring" # GNU + ) +# Compile code assuming that IEEE signaling NaNs may generate user-visible traps during floating-point operations. +# Setting this option disables optimizations that may change the number of exceptions visible with signaling NaNs. +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-fsignaling-nans " # GNU + ) + +# Allows for lines longer than 80 characters without truncation +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-ffree-line-length-none" # GNU (gfortran) + ) -# There is some bug where -march=native doesn't work on Mac -IF(APPLE) - SET(GNUNATIVE "-mtune=native") -ELSE() - SET(GNUNATIVE "-march=native") -ENDIF() -# Optimize for the host's architecture +# Disables right margin wrapping in list-directed output +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-no-wrap-margin" # Intel + "/wrap-margin-" # Intel Windows + ) + +# Aligns a variable to a specified boundary and offset +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-align all -align array64byte" # Intel + "/align:all /align:array64byte" # Intel Windows + ) + +# Enables changing the variable and array memory layout SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" - Fortran "-xhost" # Intel - "/QxHost" # Intel Windows - ${GNUNATIVE} # GNU - "-ta=host" # Portland Group + Fortran "-pad" # Intel + "/Qpad" # Intel Windows + ) +IF (NOT BUILD_SHARED_LIBS) + # Use static Intel libraries + SET_COMPILE_FLAG(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS}" + Fortran "-static-intel" # Intel + ) + # Use static Intel MPI libraries + SET_COMPILE_FLAG(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS}" + Fortran "-static_mpi" # Intel + ) + + IF (USE_OPENMP) + SET_COMPILE_FLAG(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS}" + Fortran "-qopenmp-link=static" # Intel + ) + ENDIF (USE_OPENMP) +ENDIF () + +IF (USE_SIMD) + # Enables OpenMP SIMD compilation when OpenMP parallelization is disabled. + IF (NOT USE_OPENMP) + SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-qno-openmp -qopenmp-simd" # Intel + Fortran "/Qopenmp- /Qopenmp-simd" # Intel Windows + ) + ENDIF (NOT USE_OPENMP) + + # Optimize for an old enough processor that it should run on most computers + SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-x${MACHINE_CODE_VALUE}" # Intel + "/Qx${MACHINE_CODE_VALUE}" # Intel Windows + "-m${MACHINE_CODE_VALUE}" # GNU + ) + + # Generate an extended set of vector functions + SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" + Fortran "-vecabi=cmdtarget" # Intel + Fortran "/Qvecabi:cmdtarget" # Intel Windows + ) +ENDIF (USE_SIMD) + + + + ################### ### DEBUG FLAGS ### ################### -# NOTE: debugging symbols (-g or /debug:full) are already on by default # Disable optimizations SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" @@ -99,41 +174,62 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-warn all" # Intel "/warn:all" # Intel Windows "-Wall" # GNU - # Portland Group (on by default) + ) +# This enables some extra warning flags that are not enabled by -Wall +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" + Fortran "-Wextra" # GNU + ) + +# Disable the warning that arrays may be uninitialized, which comes up due to a known bug in gfortran +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" + Fortran "-Wno-maybe-uninitialized" # GNU + ) +# Disable the warning about unused dummy arguments. These primarily occur due to interface rules for type-bound procedures used in extendable types. +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" + Fortran "-Wno-unused-dummy-argument" # GNU ) +# Tells the compiler to issue compile-time messages for nonstandard language elements (Fortran 2018). +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" + Fortran "-stand f18" # Intel + "/stand:f18" # Intel Windows + "-fstd=f2018" # GNU + ) + # Traceback SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-traceback" # Intel/Portland Group + Fortran "-traceback" # Intel Group "/traceback" # Intel Windows "-fbacktrace" # GNU (gfortran) - "-ftrace=full" # GNU (g95) ) # Sanitize SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fsanitize=address" # Gnu + Fortran "-fsanitize=address, undefined" # Gnu ) # Check everything SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-check" # Intel - "/check" # Intel Windows + Fortran "-check all" # Intel + "/check:all" # Intel Windows "-fcheck=all" # GNU ) SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fstack-check" # GNU + Fortran "-fstack-check" # GNU ) # Initializes matrices/arrays with NaN values SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-init=snan,arrays" # Intel + Fortran "-init=snan,arrays" # Intel + "/Qinit:snan,arrays" # Intel Windows + "-finit-real=snan" # GNU ) # Does not generate an interface block for each routine in a source file SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-nogen-interfaces" # Intel + "/nogen-interfaces" # Intel Windows ) # Does not generate aposition independent executable @@ -144,74 +240,48 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" # Does not set denormal results from floating-point calculations to zero SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-no-ftz" # Intel + "/Qftz-" # Intel Windows ) # Enables floating-point invalid, divide-by-zero, and overflow exceptions SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fpe-all=0" # Intel + Fortran "-fpe-all=0" # Intel + "/fpe-all:0" # Intel Windows "-ffpe-trap=zero,overflow,underflow" # GNU ) -# Improves floating-point precision and consistency -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-mp1" # Intel - ) - -# Strict model for floating-point calculations (precise and except) +# List of floating-point exceptions, whose flag status is printed to ERROR_UNIT when invoking STOP and ERROR STOP SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fp-model strict" # Intel + Fortran "-ffpe-summary=all" # GNU ) # Enables floating-point invalid, divide-by-zero, and overflow exceptions SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fpe0" # Intel + Fortran "-fpe0" # Intel + "/fpe:0" # Intel Windows ) # Enables debug info SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" Fortran "-debug all" # Intel + "/debug:all" # Intel Windows ) -# Aligns a variable to a specified boundary and offset -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-align all -align array64byte" # Intel - ) - -# Enables changing the variable and array memory layout -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-pad" # Intel - ) - -# Enables additional interprocedural optimizations for a single file cimpilation -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-ip" # Intel - ) - -# Improves precision when dividing floating-points -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-prec-div" # Intel - ) - -# Improves precision when taking the square root of floating-points -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-prec-sqrt" # Intel - ) - -# Treat parentheses in accordance with the Fortran standard (ifort 10 only) +# Disables additional interprocedural optimizations for a single file compilation SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-assume protect-parens" # Intel + Fortran "-no-ip" # Intel + "/Qip-" # Intel Windows ) -# Checks the bounds of arrays at run-time +# Disables prefetch insertion optimization SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-CB" # Intel + Fortran "-qno-opt-prefetch" # Intel + "/Qopt-prefetch-" # Intel Windows ) - -# Allows for lines longer than 80 characters without truncation + SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-no-wrap-margin" # Intel - "-ffree-line-length-none" # GNU (gfortran) - ) + Fortran "-fstack-check" # GNU + ) ##################### ### TESTING FLAGS ### @@ -219,8 +289,8 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" # Optimizations SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_TESTING "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran REQUIRED "-O3" # All compilers not on Windows - "/O3" # Intel Windows + Fortran REQUIRED "-O3" # All compilers not on Windows + "/O3" # Intel Windows ) ##################### @@ -230,10 +300,9 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_TESTING "${CMAKE_Fortran_FLAGS_DEBUG}" # Unroll loops SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-unroll" # Intel - "/unroll" # Intel Windows - "-funroll-loops" # GNU - "-Munroll" # Portland Group + Fortran "-unroll" # Intel + "/unroll" # Intel Windows + "-funroll-loops" # GNU ) # Inline functions @@ -241,99 +310,105 @@ SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" Fortran "-inline" # Intel "/Qinline" # Intel Windows "-finline-functions" # GNU - "-Minline" # Portland Group - ) - - -# Allows for lines longer than 80 characters without truncation -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-no-wrap-margin" # Intel - "-ffree-line-length-none" # GNU (gfortran) - ) - -# Disables prefetch insertion optimization -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-qopt-prefetch=0" # Intel ) # Calls the Matrix Multiply library SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-qopt-matmul" # Intel + Fortran "-qopt-matmul" # Intel + "/Qopt-matmul" # Intel Windows ) # Saves the compiler options and version number to the executable SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-sox" # Intel - ) - -# Enforces vectorization of loops -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-simd" # Intel + Fortran "-sox" # Intel ) # Aligns a variable to a specified boundary and offset SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-align all" # Intel - ) - -# Assume all objects are contiguous in memory -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-assume contiguous_assumed_shape" # Intel - ) - -# Generate an extended set of vector functions -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-vecabi=cmdtarget" # Intel + Fortran "-align all" # Intel + "/align:all" # Intel Windows ) # No floating-point exceptions SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-fp-model no-except" # Intel + Fortran "-fp-model no-except" # Intel + "/fp:no-except" # Intel Windows ) # Generate fused multiply-add instructions -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-fma" # Intel + SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" + Fortran "-fma" # Intel + "/Qfma" # Intel Windows ) -# Generate fused multiply-add instructions -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-qmkl=cluster" # Intel - Fortran "-qmkl" # Intel - Fortran "-mkl" # Old Intel +# Tells the compiler to link to certain libraries in the Intel oneAPI Math Kernel Library (oneMKL). + SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" + Fortran "-qmkl=cluster" # Intel + "-qmkl" # Intel + "/Qmkl:cluster" # Intel Windows + "/Qmkl" # Intel Windows ) +# Enables additional interprocedural optimizations for a single file compilation +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" + Fortran "-ip" # Intel + "/Qip" # Intel Windows + ) + + ##################### ### MATH FLAGS ### ##################### # Some subroutines require more strict floating point operation optimizations for repeatability SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" - Fortran "-fp-model=precise -prec-div -prec-sqrt -assume protect-parens" # Intel - "/fp:precise /Qprec-div /Qprec-sqrt /assume:protect-parens" # Intel Windows - ) + Fortran "-fp-model=precise" # Intel + "/fp:precise" # Intel Windows + "-fno-unsafe-math-optimizations" # GNU + ) +# Disable transformations and optimizations that assume default floating-point rounding behavior. +SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" + Fortran "-frounding-math" + ) + +SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" + Fortran "-prec-div" # Intel + "/Qprec-div" # Intel Windows + ) + +SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" + Fortran "-prec-sqrt" # Intel + "/Qprec-sqrt" # Intel Windows + ) + +SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" + Fortran "-assume protect-parens" # Intel + "/assume:protect-parens" # Intel Windows + ) + +# Improves floating-point precision and consistency +SET_COMPILE_FLAG(STRICTMATH_FLAGS "${STRICTMATH_FLAGS}" + Fortran "-mp1" # Intel + "/Qprec" # Intel Windows + ) # Most subroutines can use aggressive optimization of floating point operations without problems. SET_COMPILE_FLAG(FASTMATH_FLAGS "${FASTMATH_FLAGS}" - Fortran "-fp-model=fast" - "/fp:fast" - ) + Fortran "-fp-model=fast" # Intel + "/fp:fast" # Intel Windows + "-ffast-math" # GNU + ) + + +SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" + Fortran ${STRICTMATH_FLAGS} + ) ##################### ### PROFILE FLAGS ### ##################### # Enables the optimization reports to be generated SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS_RELEASE}" - Fortran "-pg -qopt-report=5 -traceback -p -g3" # Intel - "/Qopt-report:5 /traceback -g3" # Windows Intel - "-pg -fbacktrace" + Fortran "-O2 -pg -qopt-report=5 -traceback -p -g3" # Intel + "/O2 /Qopt-report:5 /traceback /Z7" # Intel Windows + "-O2 -pg -fbacktrace" # GNU ) - -# Sanitize -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fsanitize=address,undefined" # Gnu - ) - - -SET_COMPILE_FLAG(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" - Fortran "-fstack-check" # GNU - ) diff --git a/cmake/Modules/SetParallelizationLibrary.cmake b/cmake/Modules/SetParallelizationLibrary.cmake index 224806406..505a77d62 100644 --- a/cmake/Modules/SetParallelizationLibrary.cmake +++ b/cmake/Modules/SetParallelizationLibrary.cmake @@ -7,11 +7,6 @@ # You should have received a copy of the GNU General Public License along with Swiftest. # If not, see: https://www.gnu.org/licenses. -# Turns on either OpenMP or MPI -# If both are requested, the other is disabled -# When one is turned on, the other is turned off -# If both are off, we explicitly disable them just in case - IF (USE_OPENMP) # Find OpenMP IF (NOT OpenMP_Fortran_FLAGS) @@ -20,23 +15,22 @@ IF (USE_OPENMP) MESSAGE (FATAL_ERROR "Fortran compiler does not support OpenMP") ENDIF (NOT OpenMP_Fortran_FLAGS) ENDIF (NOT OpenMP_Fortran_FLAGS) - # Turn of MPI ENDIF (USE_OPENMP) -IF (USE_MPI) - # Find MPI - IF (NOT MPI_Fortran_FOUND) - FIND_PACKAGE (MPI REQUIRED) - ENDIF (NOT MPI_Fortran_FOUND) -ENDIF (USE_MPI) +IF (USE_COARRAY) + IF (NOT Coarray_Fortran_FLAGS) + FIND_PACKAGE (Coarray_Fortran) + IF (NOT Coarray_Fortran_FLAGS) + MESSAGE (FATAL_ERROR "Fortran compiler does not support Coarrays") + ENDIF (NOT Coarray_Fortran_FLAGS) + ENDIF (NOT Coarray_Fortran_FLAGS) +ENDIF (USE_COARRAY) -IF (NOT USE_OPENMP AND NOT USE_MPI) - # Turn off both OpenMP and MPI +IF (NOT USE_OPENMP AND NOT USE_COARRAY) + # Turn off both OpenMP and CAF SET (OMP_NUM_PROCS 0 CACHE STRING "Number of processors OpenMP may use" FORCE) UNSET (OpenMP_Fortran_FLAGS CACHE) + UNSET (Coarray_Fortran_FLAGS CACHE) UNSET (GOMP_Fortran_LINK_FLAGS CACHE) - UNSET (MPI_FOUND CACHE) - UNSET (MPI_COMPILER CACHE) - UNSET (MPI_LIBRARY CACHE) -ENDIF (NOT USE_OPENMP AND NOT USE_MPI) +ENDIF (NOT USE_OPENMP AND NOT USE_COARRAY) diff --git a/docker/.gitignore b/docker/.gitignore new file mode 100644 index 000000000..5c73deb60 --- /dev/null +++ b/docker/.gitignore @@ -0,0 +1,6 @@ +* +!.gitignore +!install.sh +!bin +!bin/swiftest +!bin/swiftest_driver diff --git a/docker/bin/swiftest b/docker/bin/swiftest new file mode 100755 index 000000000..8c985e065 --- /dev/null +++ b/docker/bin/swiftest @@ -0,0 +1,4 @@ +#!/bin/sh -- +OMP_NUM_THREADS=${OMP_NUM_THREADS:-`nproc --all`} +FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES:-1} +docker run -v $(pwd):$(pwd) -w $(pwd) --user "$(id -u):$(id -g)" -ti -e OMP_NUM_THREADS -e FOR_COARRAY_NUM_IMAGES mintongroup/swiftest "$@" \ No newline at end of file diff --git a/docker/bin/swiftest_driver b/docker/bin/swiftest_driver new file mode 100755 index 000000000..146509c36 --- /dev/null +++ b/docker/bin/swiftest_driver @@ -0,0 +1,4 @@ +#!/bin/sh -- +OMP_NUM_THREADS=${OMP_NUM_THREADS:-`nproc --all`} +FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES:-1} +docker run -v $(pwd):$(pwd) -w $(pwd) --user "$(id -u):$(id -g)" -ti --entrypoint /usr/local/bin/swiftest_driver -e OMP_NUM_THREADS -e FOR_COARRAY_NUM_IMAGES MintonGroup/swiftest "$@" \ No newline at end of file diff --git a/docker/install.sh b/docker/install.sh new file mode 100755 index 000000000..296223149 --- /dev/null +++ b/docker/install.sh @@ -0,0 +1,6 @@ +#!/bin/sh -- +tag=${1:-latest} +echo "Installing swiftest:${tag} Docker container and executable script" +docker pull mintongroup/swiftest:${tag} +cp -rf bin/swiftest ../bin/ +cp -rf bin/swiftest_driver ../bin/ \ No newline at end of file diff --git a/environment.yml b/environment.yml new file mode 100644 index 000000000..0e1dbb387 --- /dev/null +++ b/environment.yml @@ -0,0 +1,22 @@ +name: swiftest-env + +channels: + - conda-forge + - defaults + +dependencies: + - numpy + - scipy + - matplotlib + - pandas + - xarray + - h5netcdf + - netcdf4 + - dask + - bottleneck + - astropy + - astroquery + - tqdm + - x264 + - ffmpeg + - conda-build \ No newline at end of file diff --git a/examples/.gitignore b/examples/.gitignore index 90ecccf87..dbdf17577 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -9,3 +9,4 @@ !solar_impact !Swifter_Swiftest !swiftest_performance +!rmvs_swifter_comparison diff --git a/examples/Basic_Simulation/initial_conditions.py b/examples/Basic_Simulation/initial_conditions.py index 564c2ebee..813bd8dfb 100755 --- a/examples/Basic_Simulation/initial_conditions.py +++ b/examples/Basic_Simulation/initial_conditions.py @@ -54,13 +54,13 @@ capom_pl = default_rng().uniform(0.0, 360.0, npl) omega_pl = default_rng().uniform(0.0, 360.0, npl) capm_pl = default_rng().uniform(0.0, 360.0, npl) -GM_pl = (np.array([6e23, 8e23, 1e24, 3e24, 5e24]) / sim.param['MU2KG']) * sim.GU -R_pl = np.full(npl, (3 * (GM_pl / sim.GU) / (4 * np.pi * density_pl)) ** (1.0 / 3.0)) -Rh_pl = a_pl * ((GM_pl) / (3 * sim.GU)) ** (1.0 / 3.0) +M_pl = np.array([6e23, 8e23, 1e24, 3e24, 5e24]) * sim.KG2MU +R_pl = np.full(npl, (3 * M_pl/ (4 * np.pi * density_pl)) ** (1.0 / 3.0)) Ip_pl = np.full((npl,3),0.4,) rot_pl = np.zeros((npl,3)) +mtiny = 1.01 * np.max(M_pl) -sim.add_body(name=name_pl, a=a_pl, e=e_pl, inc=inc_pl, capom=capom_pl, omega=omega_pl, capm=capm_pl, Gmass=GM_pl, radius=R_pl, rhill=Rh_pl, Ip=Ip_pl, rot=rot_pl) +sim.add_body(name=name_pl, a=a_pl, e=e_pl, inc=inc_pl, capom=capom_pl, omega=omega_pl, capm=capm_pl, mass=M_pl, radius=R_pl, Ip=Ip_pl, rot=rot_pl) # Add 10 user-defined test particles. ntp = 10 @@ -74,10 +74,10 @@ capm_tp = default_rng().uniform(0.0, 360.0, ntp) sim.add_body(name=name_tp, a=a_tp, e=e_tp, inc=inc_tp, capom=capom_tp, omega=omega_tp, capm=capm_tp) - -# Run the simulation. Arguments may be defined here or thorugh the swiftest.Simulation() method. -#sim.run(tstart=0.0, tstop=1.0e3, dt=0.01, istep_out=100, dump_cadence=10) -sim.set_parameter(tstart=0.0, tstop=1.0e3, dt=0.01, istep_out=100, dump_cadence=0) +sim.set_parameter(tstart=0.0, tstop=1.0e3, dt=0.01, istep_out=100, dump_cadence=0, compute_conservation_values=True, mtiny=mtiny) # Display the run configuration parameters. sim.get_parameter() sim.save() + +# Run the simulation. Arguments may be defined here or thorugh the swiftest.Simulation() method. +sim.run() diff --git a/examples/rmvs_swifter_comparison/.gitignore b/examples/rmvs_swifter_comparison/.gitignore new file mode 100644 index 000000000..4d901ba7d --- /dev/null +++ b/examples/rmvs_swifter_comparison/.gitignore @@ -0,0 +1,4 @@ +* +!.gitignore +!1pl_1tp_encounter +!8pl_16tp_encounters diff --git a/examples/rmvs_swifter_comparison/1pl_1tp_encounter/.gitignore b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/.gitignore new file mode 100644 index 000000000..89c2a1c6c --- /dev/null +++ b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore +!init_cond.py +!swiftest_vs_swifter.py +!swiftest_vs_swifter.ipynb diff --git a/examples/rmvs_swifter_comparison/1pl_1tp_encounter/init_cond.py b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/init_cond.py new file mode 100755 index 000000000..9d997f720 --- /dev/null +++ b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/init_cond.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +import numpy as np +import swiftest + +# Simple initial conditions of a circular planet with one test particle in a close encounter state +# Simulation start, stop, and output cadence times +t_0 = 0 # simulation start time +deltaT = 0.25 * swiftest.JD2S / swiftest.YR2S # simulation step size +end_sim = 0.15 +t_print = deltaT #output interval to print results + +iout = int(np.ceil(t_print / deltaT)) + +radius = np.double(4.25875607065041e-05) +Gmass = np.double(0.00012002693582795244940133) +apl = np.longdouble(1.0) +atp = np.longdouble(1.01) +vpl = np.longdouble(2 * np.pi) +vtp = np.longdouble(2 * np.pi / np.sqrt(atp)) + +p_pl = np.array([apl, 0.0, 0.0], dtype=np.double) +v_pl = np.array([0.0, vpl, 0.0], dtype=np.double) + +p_tp = np.array([atp, 0.0, 0.0], dtype=np.double) +v_tp = np.array([0.0, vtp, 0.0], dtype=np.double) + +rhill = np.double(apl * 0.0100447248332378922085) + +sim = swiftest.Simulation(simdir="swiftest_sim",init_cond_format="XV", general_relativity=False, integrator="RMVS") +sim.clean() +sim.add_solar_system_body(["Sun"]) +sim.add_body(name=["Planet"], rh=[p_pl], vh=[v_pl], Gmass=[Gmass], radius=[radius], rhill=[rhill]) +sim.add_body(name=["TestParticle"], rh=[p_tp], vh=[v_tp]) +sim.set_parameter(tstart=t_0, tstop=end_sim, dt=deltaT, istep_out=iout, dump_cadence=0) +sim.save() + +sim.set_parameter(simdir="swifter_sim",codename="Swifter",init_cond_file_type="ASCII",output_format="XV",output_file_type="REAL8") +sim.save() \ No newline at end of file diff --git a/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swiftest_vs_swifter.ipynb b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swiftest_vs_swifter.ipynb new file mode 100644 index 000000000..5f5f7b2ba --- /dev/null +++ b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swiftest_vs_swifter.ipynb @@ -0,0 +1,159 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import swiftest" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Reading Swifter file /home/daminton/git_debug/swiftest/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swifter_sim/param.in\n", + "Reading in time 1.355e-01\n", + "Creating Dataset\n", + "Successfully converted 199 output frames.\n", + "Swifter simulation data stored as xarray DataSet .data\n" + ] + } + ], + "source": [ + "swiftersim = swiftest.Simulation(simdir=\"swifter_sim\", read_data=True, codename=\"Swifter\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Reading Swiftest file /home/daminton/git_debug/swiftest/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swiftest_sim/param.in\n", + "\n", + "Creating Dataset from NetCDF file\n", + "Successfully converted 1 output frames.\n", + "\n", + "Creating Dataset from NetCDF file\n", + "Successfully converted 221 output frames.\n", + "Swiftest simulation data stored as xarray DataSet .data\n", + "Reading initial conditions file as .init_cond\n", + "Finished reading Swiftest dataset files.\n" + ] + } + ], + "source": [ + "swiftestsim = swiftest.Simulation(simdir=\"swiftest_sim\",read_data=True)\n", + "swiftestsim.data = swiftestsim.data.swap_dims({\"name\" : \"id\"})" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "swiftdiff = swiftestsim.data - swiftersim.data" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABBsAAAEiCAYAAAC4D9oGAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAxNElEQVR4nO3de1RVdf7/8dfhLsrFS4IUInZRHLsJI2KR1jioZWXaN9MirbT8zhQptUyzlZcmHKvVmJqWDnmZb6nzzZyxGXNkKqxGROWLZsnPzPCWEGkF3gLEz++PhjMeQQTc5xw2PB9rnbU6n/PZe7/3aa838HJfHMYYIwAAAAAAAIv4eLsAAAAAAADQvBA2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2AAAAAAAASxE2oMV55513dPXVV6tVq1Zq3769BgwYoBMnTkiSxowZo6FDh2rGjBnq2LGjQkND9eijj6qiosK5/Pr163XjjTcqPDxc7du315AhQ7R3716XbRw6dEj33nuv2rVrp9atWyshIUG5ubnOz9977z3Fx8crKChIXbt21YwZM3T69Gm37K8xRgMGDNCgQYNkjJEk/fjjj+rcubOmTp3qlm0CsF5L61379u2Tj4+Ptm3b5jI+b948xcTEOPsZgKarpfUtSerSpYscDkeNF9ASETagRSkqKtLIkSP10EMPqaCgQNnZ2Ro2bJjLL60ffPCBCgoK9NFHH2nFihVas2aNZsyY4fz8xIkTSk9P19atW/XBBx/Ix8dHd911l86cOSNJOn78uPr166fDhw9r7dq12rFjhyZNmuT8/B//+Ifuv/9+paWladeuXXrjjTe0dOlSvfDCC+et+6233lKbNm3qfL311lu1LutwOLRs2TJt2bJFc+fOlSSNHz9eERERmj59+sV+pQA8oCX2ri5dumjAgAFasmSJy/iSJUs0ZswYfnkHmriW2LckaevWrSoqKlJRUZEOHTqkPn36KDk5+WK/TsCeDNCC5OXlGUlm3759tX4+evRo065dO3PixAnn2MKFC02bNm1MVVVVrcuUlJQYSWbnzp3GGGPeeOMNExISYo4ePVrr/OTkZJORkeEy9qc//cl06tTpvHWXlZWZPXv21PkqKyurc9///Oc/m8DAQDNlyhQTHBxsdu/eXed8AE1HS+1dq1atMm3btjU//fSTMcaY7du3G4fDYQoLC8+7DICmoaX2rbOlpaWZmJgYU1JSUq/5QHND2IAW5fTp0+ZXv/qVCQkJMXfffbdZtGiR+f77752fjx492tx8880uy2zfvt3lh+VXX31lRo4caWJjY01ISIhp3bq1kWT+/ve/G2OM+e///m9z0003nbeG4OBgExQUZFq3bu18BQUFGUkuP3DdYeTIkUaSWbhwoVu3A8BaLbV3lZeXm0suucSsWLHCGPPzL+633HKLW7YFwFottW9Ve+ONN0zr1q3N9u3b3bodoCnjMgq0KL6+vsrKytL777+vHj16aN68eerWrZsKCwsvuGz1Kbu33367jh49qsWLFys3N9d5XWD1NYatWrWqcz1nzpzRjBkztH37dudr586d2rNnj4KCgmpd5mJP6ZOkkydPKi8vT76+vtqzZ88F9xdA09FSe1dAQIBSU1O1ZMkSVVRU6O2339ZDDz10wX0G4H0ttW9JUnZ2th5//HEtX75c11577QX3F2iu/LxdAOB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PWz0888/V69evSRJX375pctndT3FAQAAAAAANE0nTpzQtddeqwcffNDlioDGaFTYUH2zSAAAAAAA0DwMHjxYgwcPtmRdjQobAAAAAABA/RhjdKqyyuPbbeXv67WrDwgbAAAAAABwo1OVVerx3D88vt1dMwcqOMA7f/Y36mkUAAAAAAAA58OZDQAAAAAAuFErf1/tmjnQK9v1FsIGAAAAAADcyOFweO1yBm9pWXsLAAAAAABqdfz4cX311VfO94WFhdq+fbvatWunzp07N2hdhA0AAAAAAEDbtm3TzTff7Hyfnp4uSRo9erSWLl3aoHURNgAAAAAAAPXv31/GGEvWxdMoAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAACApQgbAAAAAABo4WbNmqVf/vKXCgkJUceOHTV06FDt3r270esjbAAAAAAAoIXbuHGjfvvb32rz5s3KysrS6dOnlZKSohMnTjRqfX4W1wcAAAAAAGxm/fr1Lu+XLFmijh07Ki8vTzfddFOD10fYAAAAAACAOxkjVZ70/Hb9gyWHo1GLlpaWSpLatWvXqOUJGwAAAAAAcKfKk1JGlOe3+8xhKaB1gxczxig9PV033nijevbs2ahNEzYAAAAAAACnxx57TJ999pk+/fTTRq/DNmHDDz/8oLS0NK1du1aSdMcdd2jevHkKDw8/7zLGGM2YMUOLFi3SDz/8oMTERL322mv6xS9+IUn6/vvvNW3aNG3YsEEHDx5Uhw4dNHToUD3//PMKCwvzxG4BAAAAAJo7/+CfzzLwxnYb6PHHH9fatWv18ccf67LLLmv0pm0TNowaNUqHDh1y3rTikUceUWpqqt57773zLvPiiy/qlVde0dKlS3XVVVfpd7/7nX79619r9+7dCgkJ0eHDh3X48GG9/PLL6tGjh/bv36/x48fr8OHDeueddzy1awAAAACA5szhaNTlDJ5kjNHjjz+uNWvWKDs7W7GxsRe1PluEDQUFBVq/fr02b96sxMRESdLixYuVlJSk3bt3q1u3bjWWMcZozpw5mjp1qoYN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q1bp6+//lrDhw/XjTfeqBEjRkiSHnzwQe3bt08rV65UVFSU1qxZo0GDBmnnzp268sorPbqfAJoP+hYAu6FvAfZE2ABchLCwMAUEBCg4ONh5Kt//+3//r8a8yspKLVy4UJdffrkk6e6779af/vQnffvtt2rTpo169Oihm2++WR999JFGjBihvXv3asWKFTp06JCioqIkSU899ZTWr1+vJUuWKCMjw3M7CaBZoW8BsBv6FmBPhA2ABwQHBzt/8ElSRESEunTpojZt2riMlZSUSJL+7//+T8YYXXXVVS7rKS8vV/v27T1TNIAWjb4FwG7oW0DTQtgAeIC/v7/Le4fDUevYmTNnJElnzpyRr6+v8vLy5Ovr6zLv7B+YAOAu9C0AdkPfApoWwgbgIgUEBLjcaMgK119/vaqqqlRSUqLk5GRL1w0A9C0AdkPfAuyHp1EAF6lLly7Kzc3Vvn37dOTIEWdafjGuuuoq3XfffXrggQf07rvvqrCwUFu3btXs2bO1bt06C6oG0JLRtwDYDX0LsB/CBuAiPfXUU/L19VWPHj10ySWX6MCBA5asd8mSJXrggQf05JNPqlu3brrjjjuUm5ur6OhoS9YPoOWibwGwG/oWYD8OY4zxdhEAAAAAAKD54MwGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgKcIGAAAAAABgqf8PkSwGwQz1DMEAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "swiftdiff['rh'].plot(x=\"time\",hue=\"id\",col=\"space\")" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABBwAAAEiCAYAAABa08F/AAAAOXRFWHRTb2Z0d2FyZQ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V11drcWLF+uHP/yhJOmaa67Riy++qK+++kpt2rRR7969ddFFF+mDDz7Q+PHjtWPHDr388svat2+fUlJSJEl33HGH8vLytGzZMi1cuDBwbxKArZHHAIQzchgQ3ig4ABaIj493/QUnScnJyUpPT1ebNm3cjpWVlUmSPvroIxlj1KNHD7frVFZWqkOHDoEJGgBOQR4DEM7IYUBoouAAWCA6OtrtucPhaPBYbW2tJKm2tlaRkZHavHmzIiMj3dqd+hcjAAQKeQxAOCOHAaGJggNwBjExMW4bDFmhX79+qqmpUVlZmYYNG2bptQHgdOQxAOGMHAaEL+5SAZxBenq6CgsLtWvXLh06dMhVGW+OHj166Prrr9cNN9ygP/3pT9q5c6c2btyohx56SG+//bYFUQPAv5HHAIQzchgQvig4AGdwxx13KDIyUr1791anTp20Z88eS667bNky3XDDDbr99tvVs2dPjR07VoWFhUpNTbXk+gBQhzwGIJyRw4Dw5TDGmGAHAQAAAAAA7IUZDgAAAAAAwHIUHAAAAAAAgOUoOAAAAAAAAMtRcAAAAAAAAJaj4AAAAAAAACxHwQEAAAAAAFiOggMAAAAAALAcBQcAAAAAAGA5Cg4AAAAAAMByFBwAAAAAAIDlKDgAAAAAAADLUXAAAAAAAACW+38PTmcaR2/46AAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "swiftdiff['vh'].plot(x=\"time\",hue=\"id\",col=\"space\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python (My debug_env Kernel)", + "language": "python", + "name": "debug_env" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swiftest_vs_swifter.py b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swiftest_vs_swifter.py new file mode 100644 index 000000000..dce7c1358 --- /dev/null +++ b/examples/rmvs_swifter_comparison/1pl_1tp_encounter/swiftest_vs_swifter.py @@ -0,0 +1,9 @@ +import swiftest +import numpy as np + +swiftersim = swiftest.Simulation(simdir="swifter_sim", read_data=True, codename="Swifter") +swiftestsim = swiftest.Simulation(simdir="swiftest_sim",read_data=True) +swiftestsim.data = swiftestsim.data.swap_dims({"name" : "id"}) +swiftdiff = swiftestsim.data - swiftersim.data +swiftdiff['rh'].plot(x="time",hue="id",col="space") +swiftdiff['vh'].plot(x="time",hue="id",col="space") \ No newline at end of file diff --git a/examples/rmvs_swifter_comparison/8pl_16tp_encounters/.gitignore b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/.gitignore new file mode 100644 index 000000000..89c2a1c6c --- /dev/null +++ b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore +!init_cond.py +!swiftest_vs_swifter.py +!swiftest_vs_swifter.ipynb diff --git a/examples/rmvs_swifter_comparison/8pl_16tp_encounters/init_cond.py b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/init_cond.py new file mode 100755 index 000000000..725c123b1 --- /dev/null +++ b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/init_cond.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +import numpy as np +import swiftest + +tstart = 0.0 +dt = 1.0 +tstop = 365.25e2 +tstep_out = 100*dt + +sim = swiftest.Simulation(simdir="swiftest_sim",init_cond_format="XV",output_format="XV",general_relativity=False, integrator="RMVS", rhill_present=True, MU="Msun", DU="AU", TU="d") +sim.clean() +sim.add_solar_system_body(["Sun","Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"]) + +plname = sim.init_cond['name'].where(sim.init_cond['name'] != "Sun", drop=True) +pl = sim.init_cond.sel(name=plname) + +for i,n in enumerate(pl.name): + pli = pl.sel(name=n) + rstart = 2 * pli['radius'].data[0] # Start the test particles at a multiple of the planet radius away + vstart = 1.5 * np.sqrt(2 * pli['Gmass'].data[0] / rstart) # Start the test particle velocities at a multiple of the escape speed + rstart_vec = np.array([rstart / np.sqrt(2.0), rstart / np.sqrt(2.0), 0.0]) + vstart_vec = np.array([vstart, 0.0, 0.0]) + rp = pli['rh'].data[0] + vp = pli['vh'].data[0] + sim.add_body(name=[f"TestParticle{100+i}",f"TestParticle{200+i}"],rh=[rp+rstart_vec, rp-rstart_vec],vh=[vp+vstart_vec, vp-vstart_vec]) + + +sim.set_parameter(tstart=tstart, tstop=tstop, dt=dt, tstep_out=tstep_out, dump_cadence=0) +sim.save() + +sim.set_parameter(simdir="swifter_sim",codename="Swifter",init_cond_file_type="ASCII",output_file_type="REAL8") +sim.save() diff --git a/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swiftest_vs_swifter.ipynb b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swiftest_vs_swifter.ipynb new file mode 100644 index 000000000..322bbb1d2 --- /dev/null +++ b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swiftest_vs_swifter.ipynb @@ -0,0 +1,229 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "import swiftest" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Reading Swifter file /home/daminton/git_debug/swiftest/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swifter_sim/param.in\n", + "Reading in time 2.330e+04\n", + "Creating Dataset\n", + "Successfully converted 234 output frames.\n", + "Swifter simulation data stored as xarray DataSet .data\n" + ] + } + ], + "source": [ + "swiftersim = swiftest.Simulation(simdir=\"swifter_sim\", read_data=True, codename=\"Swifter\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Reading Swiftest file /home/daminton/git_debug/swiftest/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swiftest_sim/param.in\n", + "\n", + "Creating Dataset from NetCDF file\n", + "Successfully converted 1 output frames.\n", + "\n", + "Creating Dataset from NetCDF file\n", + "Successfully converted 367 output frames.\n", + "Swiftest simulation data stored as xarray DataSet .data\n", + "Reading initial conditions file as .init_cond\n", + "Finished reading Swiftest dataset files.\n" + ] + } + ], + "source": [ + "swiftestsim = swiftest.Simulation(simdir=\"swiftest_sim\",read_data=True)\n", + "swiftestsim.data = swiftestsim.data.swap_dims({\"name\" : \"id\"})" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "swiftdiff = swiftestsim.data - swiftersim.data" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "plid = swiftdiff['id'].where(swiftdiff['id'] < 9, drop=True)\n", + "tpid = swiftdiff['id'].where(swiftdiff['id'] >= 9, drop=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABB0AAAEiCAYAAAC1EapBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA3rElEQVR4nO3de3xU1bn/8e9kkglJCIFEcoNwqQURAqhgEVABoVwKVEQ94kEFPfqrlYsWe7xgq6JC9I/6Qu0RxXIitgL2VGM5HsBiJVCKwRigIlBucicYQUi45rp+f9iMjlxMJrNn79nzeb9e0yYze9Z+VkaelTyznj0eY4wRAAAAAABAiMXYHQAAAAAAAHAnig4AAAAAAMASFB0AAAAAAIAlKDoAA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wDAaj6fT5mZmXaHAQCWIc8BcDvyHBC5aK+Aq0ycOFErV67UCy+8II/HI4/Ho9dffz1gO97rr7+uli1b6r333tMll1yixMRE3XTTTTp58qTmz5+vDh06qFWrVpoyZYpqa2v9Y1dVVemhhx5SmzZtlJSUpD59+qiwsNCeiQKIWuQ5AG5HngPchZ0OcJUXXnhB27ZtU25urp566ilJ0qZNm8467tSpU3rxxRe1aNEiHT9+XGPHjtXYsWPVsmVLLVmyRJ9//rluvPFGXX311brlllskSXfeead2796tRYsWKTs7WwUFBRo+fLg2btyoTp06hXWeAKIXeQ6A25HnAHeh6ABXSUlJkc/nU2Jion8L3j//+c+zjquurtacOXN08cUXS5Juuukm/f73v9cXX3yh5s2bq2vXrho0aJBWrFihW265RTt37tTChQu1f/9+ZWdnS5J++ctfatmyZcrPz9esWbPCN0kAUY08B8DtyHOAu1B0QFRKTEz0L1CSlJGRoQ4dOqh58+YB95WVlUmS1q1bJ2OMOnfuHDBOZWWl0tLSwhM0ADQCeQ6A25HngMhA0QFRKS4uLuB7j8dzzvvq6uokSXV1dfJ6vSopKZHX6w047tsLGwA4BXkOgNuR54DIQNEBruPz+QIuGBQKl19+uWpra1VWVqZrrrkmpGMDQGOR5wC4HXkOcA8+vQKu06FDB61du1a7d+/W4cOH/dXtpujcubPGjx+vO+64Q++884527dql4uJiPffcc1qyZEkIogaAhiPPAXA78hzgHhQd4Dq//OUv5fV61bVrV7Vu3Vp79+4Nybj5+fm644479OCDD+qSSy7RT3/6U61du1Y5OTkhGR8AGoo8B8DtyHOAe3iMMcbuIAAAAAAAgPuw0wEAAAAAAFiCogMAAAAAALAERQcAAAAAAGAJig4AAAAAAMASFB0AAAAAAIAlKDoAAAAAAABLUHQAAAAAAACWoOgAAAAAAAAsQdEBAAAAAABYgqIDAAAAAACwBEUHAAAAAABgCYoOAAAAAADAEv8frvvT42z6qrcAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "swiftdiff.sel(id=plid)['rh'].plot(x=\"time\",hue=\"id\",col=\"space\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABCUAAAF8CAYAAAD4sQEKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAABRaklEQVR4nO3de3xU1bn/8e+e3BNCIEBIUkiIF1ABY0REFCWoBaKiFG+oBwG16pFLbawXtCq0Cl5aDlZ+orYaaKtieypItQellYAchEIwBxTkZhAQYgQhgdxmMrN+f0BGA0lIJjPZmcnnfV5zyuy9Zq9n7ZDH5GGttS1jjBEAAAAAAEArc9gdAAAAAAAAaJ8oSgAAAAAAAFtQlAAAAAAAALagKAEAAAAAAGxBUQIAAAAAANiCogQAAAAAALAFRQkAAAAAAGALihIAAAAAAMAW4XYHAAAAAABAqHK73XK5XHaHYZvIyEg5HA3Ph6AoAQAAAACAnxljVFxcrMOHD9sdiq0cDocyMjIUGRlZ73nLGGNaOSYAAAAAAELa/v37dfjwYSUlJSk2NlaWZdkdUqvzeDzat2+fIiIilJaWVu89YKYEAAAAAAB+5Ha7vQWJLl262B2Orbp166Z9+/appqZGERERJ51no0sAAAAAAPyodg+J2NhYmyOxX+2yDbfbXe95ihIAAAAAAARAe1yycaJT3QOKEgAAAAAAwBYUJQAAAAAACHLZ2dm6//77Gzzfq1cvzZkzp9XiaSo2ugQAAAAAIMi988479W4k2dZRlAAAAAAAIMglJibaHYJPWL4BAAAAAECQ++HyjZKSEo0aNUoxMTHKyMjQG2+8YW9wjWCmBAAAAAAAIWTChAnas2ePPvroI0VGRmrq1KkqKSmxO6x6UZQAAAAAACBEbNu2T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AAAA2IKiBAAAAAAAsAVFCQAAAAAAYAuKEgAAAAAAwBYUJRA0/vu//1v9+/dXTEyMunTpoiuvvFLl5eWSpAkTJmj06NGaMWOGkpKS1LFjR91zzz1yOp3ezy9dulRDhgxRp06d1KVLF11zzTXauXNnnT727t2rsWPHKjExUXFxcbrgggu0du1a7/m///3vGjBggKKjo3XaaadpxowZqqmpCch4jTG68sorNXLkSBljJEmHDx9WWlqaHnvssYD0CaB1tbe8tmvXLjkcDq1fv77O8RdffFHp6eneXAcgeLW3vCZJvXr1kmVZJ72AYLVy5UqNGjVKqampsixLixcvrnPeGKPp06crNTVVMTExys7O1ueff+5zfxQlEBT279+vW265RXfccYe2bNmi/Px8jRkzps4PsP/617+0ZcsWLV++XG+99ZYWLVqkGTNmeM+Xl5crNzdX69at07/+9S85HA795Cc/kcfjkSQdPXpUQ4cO1b59+7RkyRL93//9nx566CHv+Q8++ED/8R//oalTp2rz5s165ZVXNH/+fD399NMNxv3GG2+oQ4cOjb7eeOONej9rWZYWLFigf//73/rd734nSbr33nvVvXt3TZ8+vaW3FIDN2mNe69Wrl6688krl5eXVOZ6Xl6cJEybwQzwQ5NpjXpOkdevWaf/+/dq/f7/27t2riy66SJdeemlLbydgm/LycmVmZmru3Ln1nn/uuec0e/ZszZ07V+vWrVNycrJ+/OMf68iRI751aNqhFStWmGuuucakpKQYSWbRokVtor/NmzebUaNGmY4dO5oOHTqYQYMGma+++iqgsQWLgoICI8ns2rWr3vPjx483iYmJpry83Hts3rx5pkOHDsbtdtf7mZKSEiPJbNq0yRhjzCuvvGLi4+PNwYMH621/6aWXmpkzZ9Y59qc//cmkpKQ0GHdZWZnZvn17o6+ysrJGx/6Xv/zFREVFmWnTppnY2FizdevWRtsDCA7tNa+9/fbbpnPnzqaqqsoYY0xhYaGxLMsUFRU1+BkAwaG95rUfmjp1qklPTzclJSVNao/QVVlZaTZv3mwqKyvtDqVFTvz91ePxmOTkZPPMM894j1VVVZmEhATz8ssv13uNU92LcN9KGcG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UY5WsX/ziF1q6dKny8vI0c+ZMv/dZUlKio0eP6plnntFTTz2lZ599VkuXLtWYMWO0fPlyDR061O99Bpu1a9fqX//6l4YPH66kpCStXbtW3377rc4++2xvG6fTqTvvvFO//OUv9dVXX+nJJ5/U5MmT5XA41LlzZ3Xp0kWvvvqqUlJStHv3bj3yyCN1+rjllls0c+ZMjR49WrNmzVJKSoo+/fRTpaamavDgwXriiSd0zTXXqGfPnrrxxhvlcDi0ceNGbdq0SU899VS9cbd0OuD777+v119/XZ988onOP/98PfLIIxo/frw2btxYZyokgODTXvOaJJ199tm66KKL9PDDD+uOO+445b98AggO7TGvVVZWatSoUTrvvPN09913e/8VWZKSk5N9uiZCVETssRkLdvXtJ7V/r4uLi5WSkuI9XlJScsp/lGiQPzfBCEY6YeOOv/zlL0aSiYuLq/MKDw83N910kzHGmKKiIiOp0dekSZOa1J8xxnz99ddGkrnlllvqHB81apQZO3asX8cbrDZv3mxGjBhhunXrZqKiokzv3r3Niy++6D0/fvx4c91115knnnjCdOnSxXTo0MHcdddd3o3UjDFm2bJl5uyzzzZRUVHm3HPPNfn5+Sd9PXbt2mWuv/5607FjRxMbG2suuOACs3btWu/5pUuXmosvvtjExMSYjh07mgsvvNC8+uqrARlzSUmJ6d69e53Nmlwul7nwwgu9fxcBBK/2mNd+6LXXXjOSzL///e+A9wWgdbTHvNbY7wVo30J9o8tnn33We6y6urpFG11axztqtyzL0qJFi7zLJN5++23ddttt+vzzzxUWFlanbYcOHZScnCyXy3XS85JP1Llz53orRSf2Jx2rGMfFxenJJ5/UL3/5S+/xhx9+WKtWrdL//u//+j7AdmLChAk6fPjwSc/QBYBgFep57emnn9bChQu1adMmu0MB0EpCPa8BP1RVVaWioiJlZGQE3cMLjh49qh07dkiSsrKyNHv2bA0bNkyJiYlKS0vTs88+q1mzZikvL09nnnmmZs6cqfz8fG3durXeWUenuhcs3zhBVlaW3G63SkpKGny+cEREhM466yy/9RkZGamBAwdq69atdY5v27ZN6enpfusHAAC7HT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LN9xOqapUiulkazgAfNPkosTQoUO9f77tttt0+eWX68wzzwxIUAAAAACar3ajy3axp0REtBTVUaouO7bZJUUJICj59PSN22+/Xa+99pqeeeYZf8cDAAAAwEcR7emRoJIU1+1YUeJPY44VKZqjQ3dpwnuBiQtAk/lUlHA6nfrDH/6gZcuW6YILLlBcXFyd87Nnz/ZLcAAAAACazrunhMdjcyStJOVc6budUunu5n/WWeH/eIAQsHLlSj3//PMqKCjQ/v37tWjRIo0ePbpOmy1btujhhx/WihUr5PF41LdvX/3lL39RWlpas/vzqSjx2Wef6fzzz5ckbdu2rc45iw1mAAAAAFtEOI49XK/dzJT4ySvSoHsljw8b7YdH+T8eIASUl5crMzNTEydO1PXXX3/S+Z07d2rIkCG68847NWPGDCUkJGjLli2Kjm7mbKXjfCpK1G56CQAAAKDt8O4p0R42upSOFRbSLrI7CiCk5OTkKCcnp8Hzjz32mK666io999xz3mOnnXaaz/05fP4kAAAAgDal3e0pAQQJY4ycTqctL+PHfODxePT++++rd+/eGjFihJKSkjRo0CAtXrzY52v6NFMCAAAAQNvz/Z4SFCWAtsTlcmnmzJm29P3oo48qMjLSL9cqKSnR0aNH9cwzz+ipp57Ss88+q6VLl2rMmDFavnx5nad2NhVFCQAAACBE1M6UcDFTAkAAeI5vonvdddfp5z//uSTpvPPO0+rVq/Xyyy9TlAAAAADas9o9JZzMlADalIiICD366KO29e0vXbt2VXh4uM4555w6x88++2ytWrXKp2tSlAAAAABCRO1MiRpmSgBtimVZfltCYafIyEgNHDhQW7durXN827ZtSk9P9+maFCUAAACAEBHBTAkALXT06FHt2LHD+76oqEiFhYVKTExUWlqaHnzwQd1888267LLLNGzYMC1dulR///vflZ+f71N/FCUAAACAEOHd6JKZEgB8tH79eg0bNsz7Pjc3V5I0fvx4zZ8/Xz/5yU/08ssva9asWZo6dar69Omjv/3tbxoyZIhP/VGUAAAAAEKE95GgzJQA4KPs7OxTPkb0jjvu0B133OGX/hx+uQoAAAAA29VudMmeEgCCBUUJAAAA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mAQLHktlHOaMeS1hgTbGMlr/lVZWWk2b95sKisrjTHH7me5s9yWl8fjaXb8kydPNj169DBffvllg22KioqMJPPpp582616ciJkS9XA6nSooKNDw4cPrHB8+fLhWr15tU1SN2759u1JTU5WRkaGxY8fqyy+/lCQVFRWpuLi4zliioqI0dOhQ71gKCgrkcrnqtElNTVW/fv28bT755BMlJCRo0KBB3jYXXXSREhISWv2etOaYPvnkE/Xr10+pqaneNiNGjFB1dbUKCgoCOs78/HwlJSWpd+/e+ulPf6qSkhLvuWAb34lr0drL17AtIa+13bzWnr4fyGvBNca2LtjyWnvJaVL7+n4grwXXGO1kWZZiI2JteTVnPwljjCZPnqx33nlHH330kTIyMgJ4V46hKFGPAwcOyO12q3v37nWOd+/eXcXFxTZF1bBBgwbpj3/8oz744AP9/ve/V3FxsS6++GIdPHjQG29jYykuLlZkZKQ6d+7caJukpKST+k5KSmr1e9KaYyouLj6pn86dOysyMjKg487JydEbb7yhjz76SL/97W+1bt06XX755aqurvbGFSzjM/WsRWsPX8O2hrxWf5u2kNfay/cDeS24xhgMgimvtaecVhtLbXw/FGrfD+S14BojmmbSpEn685//rDfffFPx8fEqLi5WcXGxKiu/35fiu+++U2FhoTZv3ixJ2rp1qwoLC33+WvH0jUacWFEyxvi8a2kg5eTkeP/cv39/DR48WKeffroWLFjg3WzHl7Gc2Ka+9nbek9Yakx3jvvnmm71/7tevny644AKlp6fr/fff15gxYxr8XFscX+1atFWrVp10LpS/hm0Vea3t/t0I9e8H8lrD2uIYg0kw5LX2mNOk0P9+IK81rC2OEU0zb948SVJ2dnad43l5eZowYYIkacmSJZo4caL33NixYyVJTz75pKZPn97sPpkpUY+uXbsqLCzspEpPSUnJSRW8tiguLk79+/fX9u3bvTs7NzaW5ORkOZ1OHTp0qNE233zzzUl9ffvtt61+T1pzTMnJySf1c+jQIblcrlYdd0pKitLT07V9+3ZvXMEwvilTpmjJkiVavny5evTo4T3eHr+GdiOv1d+mLeS19vr9QF5ruI3dYwwWwZzXQ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aJ2gAaAA5DUCoIa8hWFiWJSs21u4wTskYoylTpmjRokXKz89XRkbGSW1qCxLbt2/X8uXLW/y9Q1ECaERERESd95Zl1XvM4/FIkjwej8LCwlRQUKCwsLA67X74H0cAsAM5DUCoIa8B/jVp0iS9+eabevfddxUfH6/i4mJJx2YvxcTEqKamRjfccIM2bNig9957T26329smMTFRkZGRze6TogTarcjIyDqbHvlDVlaW3G63SkpKdOmll/r12gDQGHIagFBDXgNa37x58yQdeyTvD+Xl5WnChAnau3evlixZIkk677zz6rRZvnz5SZ9rCooSaLd69eqltWvXateuXerQoYO3gt4SvXv31m233abbb79dv/3tb5WVlaUDBw7oo48+Uv/+/XXVVVf5IXIAOBk5DUCoIa8Brc8Y0+j5Xr16nbJNc/FIULRbv/jFLxQWFqZzzjlH3bp10+7du/1y3by8PN1+++164IEH1KdPH1177bVau3atevbs6ZfrA0B9yGkAQg15DWgfLOPvMgcAAAAAAO1YVVWVioqKlJGRoejoaLvDsdWp7gUzJQAAAAAAgC0oSgAAAAAAAFtQlAAAAAAAALagKAEAAAAAAGxBUQIAAAAAANiCogQAAAAAALAFRQkAAAAAAGALihIAAAAAAMAWFCUAAAAAAIBmzZqlgQMHKj4+XklJSRo9erS2bt1ap8306dN11llnKS4uTp07d9aVV16ptWvX+twnRQkAAAAAAKAVK1Zo0qRJWrNmjZYtW6aamhoNHz5c5eXl3ja9e/fW3LlztWnTJq1atUq9evXS8OHD9e233/rUp2WMMf4aAAAAAAAA7V1VVZWKioqUkZGh6Ohou8Px2bfffqukpCStWLFCl112Wb1tysrKlJCQoH/+85+64oorTjp/qnsR7veoAQAAAACAlzFGNU6PLX2HRzpkWZZPny0tLZUkJSYm1nve6XTq1VdfVUJCgjIzM32Lz6dPAQAAAACAJqlxevTqz1bY0vfdLwxVRFRYsz9njFFubq6GDBmifv361Tn33nvvaezYsaqoqFBKSoqWLVumrl27+hQfe0oAAAAAAIA6Jk+erI0bN+qtt9466dywYcNUWFio1atXa+TIkbrppptUUlLi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qLS1Vdna2UlJSvK+33347YH0yUwIAAAAAAMiXLSfr20eiOZgpAQAAAAAAbEFRAgAAAAAA2IKiBAAAAAAAsAVFCQAAAAAAYAuKEgAAAAAABIAvG0eGmlPdA4oSAAAAAAD4UUREhCSpoqLC5kjs53Q6JUlhYWH1nueRoAAAAAAA+FFYWJg6deqkkpISSVJsbKwsy7I5qtbn8Xj07bffKjY2VuHh9ZcfKEoAAAAAAOBnycnJkuQtTLRXDodDaWlpDRZlLMMiFwAAAAAAAsLtdsvlctkdhm0iIyPlcDS8cwRFCQAAAAAAYAs2ugQAAAAAALagKAEAAAAAAGxBUQIAAAAAANiCogQAAAAAALAFRQkAAAAAAGALihIAAAAAAMAWFCUAAAAAAIAt/j9ks5r9Lam6pwAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "swiftdiff.sel(id=tpid)['rh'].plot(x=\"time\",hue=\"id\",col=\"space\")" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABBMAAAEiCAYAAACr2JryAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA61klEQVR4nO3deXRU9f3/8ddkmclCCARIyEgCuABCkFJQiIiAWDAshaL9Un4UAxYsVbQYLRXtV8Qq2NPWgxsIfjksomC/RShWQFEJ1C+LhEUREEHCIiSmoBAIkPXz+8NmTEyAmWQmd5bn45w5h7nb5/1JyPtm3nnfe23GGCMAAAAAAAA3hVkdAAAAAAAACCwUEwAAAAAAgEcoJgAAAAAAAI9QTAAAAAAAAB6hmAAAAAAAADxCMQEAAAAAAHiEYgI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rRt29bExcWZ2NhYI8m88847xhhjfvOb35hbb731kjHExMSYqKgoExsb63pFRUUZSdVOmL4watQoI8nMmTPHp+MA8J1QzWPFxcWmRYsWZunSpcaY734Jv+2223wyFgDfC9VcVmnu3LkmNjbW7Nq1y6fjAIEgpC9zyMjI0NNPP60RI0bUur6kpERTpkzRVVddpdjYWPXo0UPZ2dk+G0+SNm/erMzMTPXt21dt2rTRvffeqy5dutS43jTUhIeHa926dVqzZo06duyoF198Ue3bt1dubu4V961sox06dKhOnTqlV199VVu3bnVdd1d5DV90dPRlj1NRUaHp06dr165drtfu3bt14MABRUVF1bpPfVvqJOn8+fPavn27wsPDdeDAgSvOF4B/CtU8ZrfbNWbMGC1YsEAlJSV64403dM8991xxzgD8U6jmMknKzs7WAw88oMWLF6tLly5XnC8Q7CKsDsCfjRs3TocPH9ayZcvkdDq1YsUK3XHHHdq9e7euu+46n4x5yy23aNWqVbrnnnvkdDqVnZ2tL774Qs8//7xPxgskNptNvXr1Uq9evfTEE0+odevWWrFihbKysiRJn3zyiS5cuOA6AW3ZskWNGjVSq1atdOrUKe3bt09z5851Xd/20UcfVTv+DTfcoP/5n//RN998o4SEhBrj//jHP9b+/ft17bXXuh3zT3/6U/Xo0eOy2yQlJV12/cMPP6ywsDCtWbNGgwYN0uDBg3Xbbbe5HQMA/xGqeWz8+PFKS0vT7NmzVVpaetmiOgD/F4q57ODBg7rzzjv12GOPkcOASla3RvgL/eCyg4MHDxqbzWaOHz9ebbv+/fubqVOnen28SsXFxebuu+82kkxERISx2+1m8eLF9R4v0G3ZssU888wzZtu2bebIkSPmb3/7m7Hb7Wb16tXGmO9a6ho1amRGjRpl9uzZY1avXm2SkpLMo48+aowxpry83DRr1sz88pe/NAcOHDAffPCBufHGG6t9H4qLi027du1M7969zUcffWS+/PJL8/e//91s2rTJGGPM2rVrTUREhJk2bZr57LPPzN69e82yZcvM448/7rN5//Of/zR2u91s377dGGPMH/7wB9OqVatq7YQAAkOo5rFKN998s7Hb7WbixIk+HwuA74RiLjt//rzp0KGDue2228yJEydMXl6e6wWEMooJ//HDD/d/+9vfjKRq12LFxsaaiIgI81//9V/GGGNyc3ONpMu+7r//frfGq/TnP//ZtGvXzqxatcp88skn5sUXXzSNGjUy69at88W0A8bevXvNwIEDTYsWLYzD4TDt2rUzL774omt9ZmamGTZsmHniiSdMs2bNTKNGjcz48eNdN/wyxph169aZ66+/3jgcDnPDDTeY7OzsGt+Hw4cPmzvvvNM0btzYxMTEmO7du5utW7e61q9du9bcfPPNJjo62jRu3NjcdNNNZt68eT6Zc0FBgUlKSqp2g6HS0lJz0003uf4PAggcoZjHqpo/f76RZD7++GOfjwXAd0Ixl13ud34glNmM4SHP0nftWitWrNDw4cMlSW+++aZGjx6tPXv2KDw8vNq2jRo1UsuWLVVaWlrjmbg/1LRp01pbpn44niRduHBB8fHxWrFihQYPHuxaPn78eH311Vdau3Zt3ScY5MaOHavTp09r5cqVVocCAHUS7HnsmWee0bJly7R7926rQwHgQ8GeywB8j3smXELXrl1VXl6ugoKCSz5DNjIyUh06dPDamKWlpSotLVVYWPX7YoaHh7ueqwsAQCA5d+6c9u3bpxdffFF//OMfrQ4HAAB4SUgXE86dO6eDBw+63ufm5mrXrl1KSEhQu3btNHr0aN19993661//qq5du+rkyZP68MMP1blzZw0aNMir46Wmpqpx48bq06ePfve73yk6OlqtW7fWhg0btHjxYj333HNemTMAAA1p0qRJWrp0qYYPH85THAAACCIhfZlDdna2+vXrV2N5ZmamFi5cqNLSUj399NNavHixjh8/rmbNmik9PV3Tp09X586dvT6eJOXn52vq1Kl677339M0336h169a699579dBDD7kepwMAAAAAgJVCupgAAAAAAAA8F3blTQAAAAAAAL5HMQEAAAAAAHgk5G7AWFFRoRMnTiguLo57EABoMMYYnT17Vk6ns8YTW+qCXAagoZHHAAQDb+eyUBZyxYQTJ04oJSXF6jAAhKhjx46pVatW9T4OuQyAVchjAIKBt3JZKAu5YkJcXJyk7/7zNG7c2OJoAISKwsJCpaSkuHJQfZHLADQ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ExOju+66S0VFRVq0aJHatGmjpk2b6oEHHlB5ebnr2CUlJZoyZYquuuoqxcbGqkePHsrOzrZmogCCGrkMQKAjjwGBjc4EhJznn39eX3zxhdLS0vTUU09Jkvbs2VNju/Pnz+uFF17QsmXLdPbsWY0YMUIjRoxQkyZNtHr1ah06dEh33nmnbrnlFo0cOVKSNG7cOB0+fFjLli2T0+nUihUrdMcdd2j37t267rrrGnSeAIIbuQxAoCOPAYGNYgJCTnx8vOx2u2JiYlxtdJ9//nmN7UpLSzVnzhxdc801kqS77rpLr732mr7++ms1atRIHTt2VL9+/bR+/XqNHDlSX375pZYuXaqvvvpKTqdTkvTII49o7dq1WrBggWbMmNFwkwQQ9MhlAAIdeQwIbBQTgEuIiYlxnbQkKSkpSW3atFGjRo2qLSsoKJAk7dixQ8YYtWvXrtpxiouL1axZs4YJGgB+gFwGINCRxwD/RDEBuITIyMhq7202W63LKioqJEkVFRUKDw/X9u3bFR4eXm27qic7AGhI5DIAgY48BvgnigkISXa7vdpNeryha9euKi8vV0FBgXr37u3VYwNAbchlAAIdeQwIXDzNASGpTZs22rp1qw4fPqyTJ0+6Ktn10a5dO40ePVp333233nrrLeXm5mrbtm3605/+pNWrV3shagCojlwGINCRx4DARTEBIemRRx5ReHi4OnbsqBYtWujo0aNeOe6CBQt099136+GHH1b79u3105/+VFu3blVKSopXjg8AVZHLAAQ68hgQuGzGGGN1EAAAAAAAIHDQmQAAAAAAADxCMQEAAAAAAHiEYgIAAAAAAPAIxQQAAAAAAOARigkAAAAAAMAjFBMAAAAAAIBHKCYAAAAAAACPUEwAAAAAAAAeoZgAAAAAAAA8QjEBAAAAAAB4hGICAAAAAADwCMUEAAAAAADgkf8PxuKdV/0SKioAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "swiftdiff.sel(id=plid)['vh'].plot(x=\"time\",hue=\"id\",col=\"space\")" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAABCQAAAF8CAYAAAAXc2o0AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjYuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8o6BhiAAAACXBIWXMAAA9hAAAPYQGoP6dpAABQ40lEQVR4nO3deXhV1aH+8XdnHgiBAJkKhKiAaBAjIKAoQWkgMooDiD8ErFMZvBiHOlwRrYLaykWlILQ04AB4bwXEoWCqhEgZSgIpKIigQRASIwgBQuas3x80R2JCIIeTM+X7eZ7zPJy9195rrROyCG/WXssyxhgBAAAAAAA4kY+rGwAAAAAAAJoeAgkAAAAAAOB0BBIAAAAAAMDpCCQAAAAAAIDTEUgAAAAAAACnI5AAAAAAAABORyABAAAAAACcjkACAAAAAAA4nZ+rGwAAAAAAgDeqrKxUeXm5q5vhMv7+/vL19T3reQIJAAAAAAAcyBij/Px8HTt2zNVNcbkWLVooOjpalmXVOkcgAQAAAACAA1WHEZGRkQoJCanzP+PezhijU6dOqaCgQJIUExNTqwyBBAAAAAAADlJZWWkLI1q1auXq5rhUcHCwJKmgoECRkZG1Ht9gUUsAAAAAABykes2IkJAQF7fEPVR/DnWtpUEgAQAAAACAgzXFxzTqUt/nQCABAAAAAACcjkACAAAAAAAPl5SUpKlTp571fIcOHTR79mynted8sKglAAAAAAAebvny5fL393d1MxqEQAIAAAAAAA8XERHh6iY0GI9sAAAAAADg4c58ZKOgoEBDhw5VcHCw4uPj9c4777i2cWfBDAkAAAAAALzI+PHjdeDAAX322WcKCAjQgw8+qIKCAlc3qxYCCQAAAAAAvMTXX3+tv//979q0aZN69eolSVq4cKG6dOni4pbVxiMbAAAAAAB4iV27dsnPz089evSwHbv00kvVokUL1zXqLAgkAAAAAADwEsYYSZJlWS5uybkRSAAAAAAA4CW6dO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atdKQIUP0zTff1Kjj+++/1+jRoxUREaHQ0FD16NFDmzdvtp3/4IMP1L17dwUFBemiiy7Ss88+q4qKikbprzFGAwYM0KBBg2SMkSQdO3ZM7du311NPPdUodQJoPE1tDNu3b598fHyUlZVV4/jrr7+uuLg427gGwDM0tTFMkjp06CDLsmq9AE+TmZmpoUOHKjY2VpZlaeXKlTXOG2M0ffp0xcbGKjg4WElJSfryyy/tro9AAl4nLy9Pd9xxh+6++27t2rVLGRkZGjlyZI0faD/99FPt2rVLa9eu1dKlS7VixQo9++yztvNFRUVKTU3Vli1b9Omnn8rHx0c333yzqqqqJEknT55Uv379dOjQIa1atUr//ve/9dhjj9nOr1mzRv/v//0/Pfjgg9q5c6fmz5+vRYsW6YUXXjhru9955x01a9as3tc777xT57WWZWnx4sX617/+pddee02S9MADDygqKkrTp0+/0I8UgBM1xTGsQ4cOGjBggNLS0mocT0tL0/jx4/mhHvAgTXEMk6QtW7YoLy9PeXl5+v7779W7d29dd911F/pxAk5XVFSkbt26ac6cOXWef/nllzVr1izNmTNHW7ZsUXR0tH7961/rxIkT9lVocN7WrVtnhgwZYmJiYowks2LFikatb8aMGaZHjx6mWbNmpk2bNmb48OHmq6++qlGmqqrKPPPMMyYmJsYEBQWZfv36mS+++KJR2+XusrOzjSSzb9++Os+PGzfOREREmKKiItuxefPmmWbNmpnKyso6rykoKDCSzI4dO4wxxsyfP9+EhYWZI0eO1Fn+uuuuMzNmzKhx7K233jIxMTFnbffx48fNnj176n0dP3683r7/7//+rwkMDDRPPPGECQkJMbt37663PAD301THsHfffde0bNnSlJSUGGOMycnJMZZlmdzc3LNeA8D9NNUx7EwPPvigiYuLMwUFBedVHt6nuLjY7Ny50xQXF7u6KRfkl//nraqqMtHR0ebFF1+0HSspKTHh4eHmjTfeOOt96vs8CCQa4OOPPzZPPfWUee+995wSSAwcONCkpaWZL774wuTk5JjBgweb9u3bm5MnT9rKvPjiiyYsLMy89957ZseOHWbUqFEmJibmvAdMb1RRUWFuvPFGExYWZm699VazYMEC89NPP9nOjxs3zvTv37/GNTk5OTX+8dy7d6+54447THx8vAkLCzOhoaFGkvnoo4+MMcb89re/Nddff/1Z2xASEmKCgoJMaGio7RUUFGQk1fgHuDHccccdRpKZN29eo9YDoHE01TGstLTUtGnTxixdutQYc/oH+htuuKFR6gLQeJrqGFZt/vz5JjQ01OTk5DRqPXBvtf4DXlVlTOlJ17yqquzuxy//z/vNN98YSWbr1q01yg0bNszcdddd5/95nMHPvnkVTVNKSopSUlLOer6srEz//d//rXfeeUfHjh1TQkKCXnrpJSUlJdlV3+rVq2u8T0tLU2RkpLKzs3X99dfLGKPZs2frqaee0siRIyVJixcvVlRUlJYsWaL777/frno9na+vr9LT07VhwwZ98sknev311/XUU09p8+bNio+Pr/fa6mnBQ4cOVbt27fTnP/9ZsbGxqqqqUkJCgu35xuDg4HrvU1VVpWeffdb2dTlTUFBQnde888475/yazZ8/X3feeedZz586dUrZ2dny9fXVnj176r0XAPfUVMewgIAAjR07VmlpaRo5cqSWLFmi2bNn13s/AO6nqY5hkpSRkaEpU6Zo6dKl6tatW733QhNTfkqaEeuaup88JAWEOuRW+fn5kqSoqKgax6OiovTdd9/ZdU8CCQeaMGGC9u3bp2XLlik2NlYrVqzQoEGDtGPHDnXs2PGC719YWChJioiIkCTl5uYqPz9fycnJtjKBgYHq16+fNmzY0GQDCen0P2jXXnutrr32Wk2bNk1xcXFasWKFUlNTJUn//ve/VVxcbPsHbdOmTWrWrJnatm2rI0eOaNeuXZo/f77t2b/169fXuP8VV1yhv/zlL/rpp59sX48zXXXVVdq9e7cuueSS827zsGHD1KtXr3rL/PKb/5cefvhh+fj46O9//7tuuukmDR48WDfccMN5twGAe2iqY9g999yjhIQEzZ07V+Xl5XX+ZwKA+2uKY9jevXt1yy236Mknn2Tsgtf75dpOxhi713sikHCQb775RkuXLtX333+v2NjT6dcjjzyi1atXKy0tTTNmzLig+xtjlJqaqr59+yohIUFS4yRU3mDz5s369NNPlZycrMjISG3evFk//vijunT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ftWjRQgUFBZKkkJAQWZbl4lY5nzFGp06dUkFBgVq0aCFfX99aZSzDPBIAAAAAABzGGKP8/HwdO3bM1U1xuRYtWig6OrrOUIZAAgAAAACARlBZWany8nJXN8Nl/P3965wZUY1AAgAAAAAAOB2LWgIAAAAAAKcjkAAAAAAAAE5HIAEAAAAAAJyOQAIAAAAAADgdgQQAAAAAAHA6AgkAAAAAAOB0BBIAAAAAAMDp/j/wI+7NcdMSwwAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "swiftdiff.sel(id=tpid)['vh'].plot(x=\"time\",hue=\"id\",col=\"space\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python (My debug_env Kernel)", + "language": "python", + "name": "debug_env" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swiftest_vs_swifter.py b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swiftest_vs_swifter.py new file mode 100644 index 000000000..dce7c1358 --- /dev/null +++ b/examples/rmvs_swifter_comparison/8pl_16tp_encounters/swiftest_vs_swifter.py @@ -0,0 +1,9 @@ +import swiftest +import numpy as np + +swiftersim = swiftest.Simulation(simdir="swifter_sim", read_data=True, codename="Swifter") +swiftestsim = swiftest.Simulation(simdir="swiftest_sim",read_data=True) +swiftestsim.data = swiftestsim.data.swap_dims({"name" : "id"}) +swiftdiff = swiftestsim.data - swiftersim.data +swiftdiff['rh'].plot(x="time",hue="id",col="space") +swiftdiff['vh'].plot(x="time",hue="id",col="space") \ No newline at end of file diff --git a/python/swiftest/swiftest/init_cond.py b/python/swiftest/swiftest/init_cond.py index 30fb46c6d..1b140f119 100644 --- a/python/swiftest/swiftest/init_cond.py +++ b/python/swiftest/swiftest/init_cond.py @@ -233,7 +233,7 @@ def vec2xr(param: Dict, **kwargs: Any): Parameters ---------- param : dict - Swiftest paramuration parameters. + Swiftest simulation parameters. name : str or array-like of str, optional Name or names of Bodies. If none passed, name will be "Body" id : int or array-like of int, optional @@ -252,9 +252,9 @@ def vec2xr(param: Dict, **kwargs: Any): capm : float or array-like of float, optional mean anomaly for param['IN_FORM'] == "EL" rh : (n,3) array-like of float, optional - Position vector array. This can be used instead of passing v1, v2, and v3 sepearately for "XV" input format + Position vector array. vh : (n,3) array-like of float, optional - Velocity vector array. This can be used instead of passing v4, v5, and v6 sepearately for "XV" input format + Velocity vector array. Gmass : float or array-like of float, optional G*mass values if these are massive bodies (only one of mass or Gmass can be passed) radius : float or array-like of float, optional @@ -277,15 +277,17 @@ def vec2xr(param: Dict, **kwargs: Any): space_coords = np.array(["x","y","z"]) vector_vars = ["rh","vh","Ip","rot"] - scalar_vars = ["name","a","e","inc","capom","omega","capm","Gmass","radius","rhill","J2","J4"] - time_vars = ["rh","vh","Ip","rot","a","e","inc","capom","omega","capm","Gmass","radius","rhill","J2","J4"] + scalar_vars = ["name","a","e","inc","capom","omega","capm","Gmass","radius","rhill","j2rp2","j4rp4"] + time_vars = ["rh","vh","Ip","rot","a","e","inc","capom","omega","capm","Gmass","radius","rhill","j2rp2","j4rp4"] # Check for valid keyword arguments kwargs = {k:kwargs[k] for k,v in kwargs.items() if v is not None} - if "rot" not in kwargs and "Gmass" in kwargs: - kwargs['rot'] = np.zeros((len(kwargs['Gmass']),3)) - if "Ip" not in kwargs and "Gmass" in kwargs: - kwargs['Ip'] = np.full((len(kwargs['Gmass']),3), 0.4) + + if "ROTATION" in param and param['ROTATION'] == True: + if "rot" not in kwargs and "Gmass" in kwargs: + kwargs['rot'] = np.zeros((len(kwargs['Gmass']),3)) + if "Ip" not in kwargs and "Gmass" in kwargs: + kwargs['Ip'] = np.full((len(kwargs['Gmass']),3), 0.4) if "time" not in kwargs: kwargs["time"] = np.array([0.0]) diff --git a/python/swiftest/swiftest/io.py b/python/swiftest/swiftest/io.py index 6a376d387..32a10f34d 100644 --- a/python/swiftest/swiftest/io.py +++ b/python/swiftest/swiftest/io.py @@ -16,6 +16,7 @@ import sys import tempfile import re +import os # This defines features that are new in Swiftest and not in Swifter (for conversion between param.in files) newfeaturelist = ("RESTART", @@ -27,12 +28,19 @@ "YARKOVSKY", "YORP", "IN_FORM", + "NC_IN", "SEED", "INTERACTION_LOOPS", "ENCOUNTER_CHECK", + "ENCOUNTER_CHECK_PLPL", + "ENCOUNTER_CHECK_PLTP", "TSTART", "DUMP_CADENCE", - "ENCOUNTER_SAVE") + "ENCOUNTER_SAVE", + "MIN_GMFRAG", + "NFRAG_REDUCTION", + "COLLISION_MODEL", + "COARRAY") # This list defines features that are booleans, so must be converted to/from string when writing/reading from file bool_param = ["RESTART", @@ -46,7 +54,8 @@ "ENERGY", "GR", "YARKOVSKY", - "YORP"] + "YORP", + "COARRAY"] int_param = ["ISTEP_OUT", "DUMP_CADENCE"] float_param = ["T0", "TSTART", "TSTOP", "DT", "CHK_RMIN", "CHK_RMAX", "CHK_EJECT", "CHK_QMIN", "DU2M", "MU2KG", @@ -59,7 +68,7 @@ # This defines Xarray Dataset variables that are strings, which must be processed due to quirks in how NetCDF-Fortran # handles strings differently than Python's Xarray. -string_varnames = ["name", "particle_type", "status", "origin_type", "stage", "regime"] +string_varnames = ["name", "particle_type", "origin_type", "stage", "regime"] char_varnames = ["space"] int_varnames = ["id", "ntp", "npl", "nplm", "discard_body_id", "collision_id", "status"] @@ -475,6 +484,7 @@ def swifter_stream(f, param): tlab : string list Labels for the tvec data """ + while True: # Loop until you read the end of file try: # Read single-line header @@ -484,32 +494,52 @@ def swifter_stream(f, param): t = record[0] npl = record[1][0] - 1 ntp = record[2][0] - - pvec = np.empty((6, npl)) + + if param['OUT_FORM'] == 'XV': + rpvec = np.empty((npl,3)) + vpvec = np.empty((npl,3)) + rtvec = np.empty((ntp,3)) + vtvec = np.empty((ntp,3)) + elif param['OUT_FORM'] == 'EL': + elempvec = np.empty((npl,6)) + elemtvec = np.empty((ntp,6)) plid = np.empty(npl, dtype='int') - tvec = np.empty((6, ntp)) tpid = np.empty(ntp, dtype='int') if npl > 0: GMpl = np.empty(npl) Rpl = np.empty(npl) for i in range(npl): # Read single-line pl frame for - record = f.read_record(' 0: for i in range(ntp): - record = f.read_record(' 0: - plid = f.read_ints() - dtstr = f'({npl[0]},)a{NAMELEN}' - names = f.read_record(np.dtype(dtstr)) - plnames = [] - for i in range(npl[0]): - plnames.append(np.char.strip(str(names[i], encoding='utf-8'))) - p1 = f.read_reals(np.float64) - p2 = f.read_reals(np.float64) - p3 = f.read_reals(np.float64) - p4 = f.read_reals(np.float64) - p5 = f.read_reals(np.float64) - p6 = f.read_reals(np.float64) - if param['OUT_FORM'] == 'XVEL': - p7 = f.read_reals(np.float64) - p8 = f.read_reals(np.float64) - p9 = f.read_reals(np.float64) - p10 = f.read_reals(np.float64) - p11 = f.read_reals(np.float64) - p12 = f.read_reals(np.float64) - GMpl = f.read_reals(np.float64) - if param['RHILL_PRESENT']: - rhill = f.read_reals(np.float64) - Rpl = f.read_reals(np.float64) - if param['ROTATION']: - Ipplx = f.read_reals(np.float64) - Ipply = f.read_reals(np.float64) - Ipplz = f.read_reals(np.float64) - rotplx = f.read_reals(np.float64) - rotply = f.read_reals(np.float64) - rotplz = f.read_reals(np.float64) - if param['TIDES']: - k2pl = f.read_reals(np.float64) - Qpl = f.read_reals(np.float64) - if ntp[0] > 0: - tpid = f.read_ints() - dtstr = f'({ntp[0]},)a{NAMELEN}' - names = f.read_record(np.dtype(dtstr)) - tpnames = [] - for i in range(npl[0]): - tpnames.append(np.char.strip(str(names[i], encoding='utf-8'))) - t1 = f.read_reals(np.float64) - t2 = f.read_reals(np.float64) - t3 = f.read_reals(np.float64) - t4 = f.read_reals(np.float64) - t5 = f.read_reals(np.float64) - t6 = f.read_reals(np.float64) - if param['OUT_FORM'] == 'XVEL': - t7 = f.read_reals(np.float64) - t8 = f.read_reals(np.float64) - t9 = f.read_reals(np.float64) - t10 = f.read_reals(np.float64) - t11 = f.read_reals(np.float64) - t12 = f.read_reals(np.float64) - - clab, plab, tlab, infolab_float, infolab_int, infolab_str = make_swiftest_labels(param) - - if npl > 0: - pvec = np.vstack([p1, p2, p3, p4, p5, p6]) - if param['OUT_FORM'] == 'XVEL': - pvec = np.vstack([pvec, p7, p8, p9, p10, p11, p12]) - pvec = np.vstack([pvec, GMpl, Rpl]) - else: - if param['OUT_FORM'] == 'XVEL': - pvec = np.empty((14, 0)) - else: - pvec = np.empty((8, 0)) - plid = np.empty(0) - plnames = np.empty(0) - if ntp > 0: - tvec = np.vstack([t1, t2, t3, t4, t5, t6]) - if param['OUT_FORM'] == 'XVEL': - tvec = np.vstack([tvec, t7, t8, t9, t10, t11, t12]) - else: - if param['OUT_FORM'] == 'XVEL': - tvec = np.empty((12, 0)) - else: - tvec = np.empty((6, 0)) - tpid = np.empty(0) - tpnames = np.empty(0) - cvec = np.array([Mcb, Rcb, J2cb, J4cb]) - if param['RHILL_PRESENT']: - if npl > 0: - pvec = np.vstack([pvec, rhill]) - if param['ROTATION']: - cvec = np.vstack([cvec, Ipcbx, Ipcby, Ipcbz, rotcbx, rotcby, rotcbz]) - if npl > 0: - pvec = np.vstack([pvec, Ipplx, Ipply, Ipplz, rotplx, rotply, rotplz]) - if param['TIDES']: - cvec = np.vstack([cvec, k2cb, Qcb]) - if npl > 0: - pvec = np.vstack([pvec, k2pl, Qpl]) - yield t, cbid, cbnames, cvec.T, clab, \ - npl, plid, plnames, pvec.T, plab, \ - ntp, tpid, tpnames, tvec.T, tlab - + if param['OUT_FORM'] == 'XV': + yield t, npl, [plid, rpvec, vpvec, GMpl, Rpl], plab, \ + ntp, [tpid, rtvec, vtvec], tlab + elif param['OUT_FORM'] == 'EL': + yield t, npl, [plid, elempvec, GMpl, Rpl], plab, \ + ntp, [tpid, elemtvec], tlab def swifter2xr(param, verbose=True): """ @@ -776,28 +574,25 @@ def swifter2xr(param, verbose=True): pl = [] tp = [] with FortranFile(param['BIN_OUT'], 'r') as f: - for t, npl, plid, pvec, plab, \ - ntp, tpid, tvec, tlab in swifter_stream(f, param): - # Prepare frames by adding an extra axis for the time coordinate - plframe = np.expand_dims(pvec, axis=0) - tpframe = np.expand_dims(tvec, axis=0) - - # Create xarray DataArrays out of each body type - plxr = xr.DataArray(plframe, dims=dims, coords={'time': t, 'id': plid, 'vec': plab}) - tpxr = xr.DataArray(tpframe, dims=dims, coords={'time': t, 'id': tpid, 'vec': tlab}) + for t, npl, pvec, plab, \ + ntp, tvec, tlab in swifter_stream(f, param): - pl.append(plxr) - tp.append(tpxr) sys.stdout.write('\r' + f"Reading in time {t[0]:.3e}") sys.stdout.flush() + + pvec_args = dict(zip(plab,pvec)) + pl.append(swiftest.init_cond.vec2xr(param,time=t,**pvec_args)) + if ntp > 0: + tvec_args = dict(zip(tlab,tvec)) + tp.append(swiftest.init_cond.vec2xr(param,time=t,**tvec_args)) + + plds = xr.concat(pl, dim='time') + if len(tp) > 0: + tpds = xr.concat(tp, dim='time') - plda = xr.concat(pl, dim='time') - tpda = xr.concat(tp, dim='time') - - plds = plda.to_dataset(dim='vec') - tpds = tpda.to_dataset(dim='vec') if verbose: print('\nCreating Dataset') - ds = xr.combine_by_coords([plds, tpds]) + if len(tp) > 0: + ds = xr.combine_by_coords([plds, tpds]) if verbose: print(f"Successfully converted {ds.sizes['time']} output frames.") return ds @@ -1225,7 +1020,7 @@ def swiftest_xr2infile(ds, param, in_type="NETCDF_DOUBLE", infile_name=None,fram print(f"{in_type} is an unknown file type") -def swifter_xr2infile(ds, param, framenum=-1): +def swifter_xr2infile(ds, param, simdir=os.getcwd, framenum=-1): """ Writes a set of Swifter input files from a single frame of a Swiftest xarray dataset @@ -1264,7 +1059,7 @@ def swifter_xr2infile(ds, param, framenum=-1): if param['IN_TYPE'] == 'ASCII': # Swiftest Central body file - plfile = open(param['PL_IN'], 'w') + plfile = open(os.path.join(simdir,param['PL_IN']), 'w') print(pl.id.count().values + 1, file=plfile) print(cb.id.values[0], GMSun, file=plfile) print('0.0 0.0 0.0', file=plfile) @@ -1277,21 +1072,20 @@ def swifter_xr2infile(ds, param, framenum=-1): print(i.values, pli['Gmass'].values, file=plfile) if param['CHK_CLOSE']: print(pli['radius'].values, file=plfile) - print(pli['rh'].values[0,0], pli['ry'].values[0,1], pli['rh'].values[0,2], file=plfile) - print(pli['vh'].values[0,0], pli['vh'].values[0,1], pli['vh'].values[0,2], file=plfile) + print(pli['rh'].values[0], pli['rh'].values[1], pli['rh'].values[2], file=plfile) + print(pli['vh'].values[0], pli['vh'].values[1], pli['vh'].values[2], file=plfile) plfile.close() # TP file - tpfile = open(param['TP_IN'], 'w') + tpfile = open(os.path.join(simdir,param['TP_IN']), 'w') print(tp.id.count().values, file=tpfile) for i in tp.id: tpi = tp.sel(id=i) print(i.values, file=tpfile) - print(tpi['rh'].values[0,0], tpi['ry'].values[0,1], tpi['rh'].values[0,2], file=tpfile) - print(tpi['vh'].values[0,0], tpi['vh'].values[0,1], tpi['vh'].values[0,2], file=tpfile) + print(tpi['rh'].values[0], tpi['rh'].values[1], tpi['rh'].values[2], file=tpfile) + print(tpi['vh'].values[0], tpi['vh'].values[1], tpi['vh'].values[2], file=tpfile) tpfile.close() else: - # Now make Swiftest files print(f"{param['IN_TYPE']} is an unknown input file type") return @@ -1841,11 +1635,13 @@ def swiftest2swifter_param(swiftest_param, J2=0.0, J4=0.0): DU2M = swifter_param.pop("DU2M", 1.0) TU2S = swifter_param.pop("TU2S", 1.0) GR = swifter_param.pop("GR", None) - if GR is not None: - if GR: - swifter_param['C'] = swiftest.einsteinC * np.longdouble(TU2S) / np.longdouble(DU2M) + # if GR is not None: + # if GR: + # swifter_param['C'] = swiftest.einsteinC * np.longdouble(TU2S) / np.longdouble(DU2M) for key in newfeaturelist: tmp = swifter_param.pop(key, None) + if "ISTEP_DUMP" not in swifter_param: + swifter_param["ISTEP_DUMP"] = swifter_param["ISTEP_OUT"] swifter_param['J2'] = J2 swifter_param['J4'] = J4 if swifter_param['OUT_STAT'] == "REPLACE": @@ -1856,11 +1652,6 @@ def swiftest2swifter_param(swiftest_param, J2=0.0, J4=0.0): swifter_param['OUT_TYPE'] = 'REAL4' if swifter_param['OUT_FORM'] == 'XVEL': swifter_param['OUT_FORM'] = 'XV' - IN_FORM = swifter_param.pop("IN_FORM", None) - INTERACTION_LOOPS = swifter_param.pop("INTERACTION_LOOPS", None) - ENCOUNTER_CHECK = swifter_param.pop("ENCOUNTER_CHECK", None) - ENCOUNTER_CHECK_PLPL = swifter_param.pop("ENCOUNTER_CHECK_PLPL", None) - ENCOUNTER_CHECK_PLTP = swifter_param.pop("ENCOUNTER_CHECK_PLTP", None) swifter_param['! VERSION'] = "Swifter parameter file converted from Swiftest" return swifter_param diff --git a/python/swiftest/swiftest/simulation_class.py b/python/swiftest/swiftest/simulation_class.py index 991758441..399ab0d38 100644 --- a/python/swiftest/swiftest/simulation_class.py +++ b/python/swiftest/swiftest/simulation_class.py @@ -299,6 +299,11 @@ def __init__(self,read_param: bool = False, Parameter input file equivalent: `ENCOUNTER_CHECK` dask : bool, default False Use Dask to lazily load data (useful for very large datasets) + coarray : bool, default False + If true, will employ Coarrays on test particle structures to run in single program/multiple data parallel mode. + *Note" In order to use this capability, Swiftest must be compiled for Coarray support. Only certain integrators + can use Coarrays: RMVS, WHM, Helio are all compatible, but SyMBA is not, due to the way tp-pl close encounters + are handeled. verbose : bool, default True If set to True, then more information is printed by Simulation methods as they are executed. Setting to False suppresses most messages other than errors. @@ -340,7 +345,6 @@ def __init__(self,read_param: bool = False, # Parameters are set in reverse priority order. First the defaults, then values from a pre-existing input file, # then using the arguments passed via **kwargs. - #-------------------------- # Lowest Priority: Defaults: #-------------------------- @@ -366,7 +370,7 @@ def __init__(self,read_param: bool = False, self.read_encounters = read_encounters if read_param or read_data: - if self.read_param(read_init_cond = True, dask=dask): + if self.read_param(read_init_cond = True, dask=dask, **kwargs): # We will add the parameter file to the kwarg list. This will keep the set_parameter method from # overriding everything with defaults when there are no arguments passed to Simulation() kwargs['param_file'] = self.param_file @@ -400,9 +404,9 @@ def _run_swiftest_driver(self): """ # Get current environment variables - env = os.environ.copy() cmd = f"{env['SHELL']} -l {self.driver_script}" + def _type_scrub(output_data): int_vars = ["ILOOP","NPL","NTP","NPLM"] @@ -466,6 +470,9 @@ def _type_scrub(output_data): sys.exit() except: warnings.warn(f"Error executing main swiftest_driver program", stacklevel=2) + res = p.communicate() + for line in res[1]: + print(line, end='') sys.exit() pbar.close() @@ -498,11 +505,9 @@ def run(self,dask: bool = False, **kwargs): if not self.binary_source.exists(): msg = "Path to swiftest_driver has not been set!" - msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_path)}" + msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_source.parent)}" warnings.warn(msg,stacklevel=2) return - else: - shutil.copy2(self.binary_source, self.driver_executable) if not self.restart: self.clean() @@ -824,7 +829,8 @@ def set_parameter(self, verbose: bool = True, **kwargs): "ephemeris_date": "MBCL", "restart": False, "encounter_save" : "NONE", - "simdir" : self.simdir + "coarray" : False, + "simdir" : self.simdir, } param_file = kwargs.pop("param_file",None) @@ -845,8 +851,8 @@ def set_parameter(self, verbose: bool = True, **kwargs): # Setters returning parameter dictionary values param_dict = {} - param_dict.update(self.set_unit_system(**kwargs)) param_dict.update(self.set_integrator(**kwargs)) + param_dict.update(self.set_unit_system(**kwargs)) param_dict.update(self.set_simulation_time(**kwargs)) param_dict.update(self.set_init_cond_files(**kwargs)) param_dict.update(self.set_output_files(**kwargs)) @@ -886,7 +892,7 @@ def get_parameter(self, **kwargs): return param_dict def set_integrator(self, - codename: Literal["Swiftest", "Swifter", "Swift"] | None = None, + codename: None | Literal["Swiftest", "Swifter", "Swift"] = "Swiftest", integrator: Literal["symba","rmvs","whm","helio"] | None = None, mtiny: float | None = None, gmtiny: float | None = None, @@ -921,7 +927,7 @@ def set_integrator(self, # TODO: Improve how it finds the executable binary update_list = [] - + if codename is not None: valid_codename = ["Swiftest", "Swifter", "Swift"] if codename.title() not in valid_codename: @@ -937,18 +943,22 @@ def set_integrator(self, update_list.append("codename") if self.codename == "Swiftest": self.binary_source = Path(_pyfile).parent.parent.parent.parent / "bin" / "swiftest_driver" - self.binary_path = self.simdir.resolve() - self.driver_executable = self.binary_path / "swiftest_driver" + self.driver_executable = self.binary_source if not self.binary_source.exists(): - warnings.warn(f"Cannot find the Swiftest driver in {str(self.binary_path)}",stacklevel=2) + warnings.warn(f"Cannot find the Swiftest driver at {str(self.binary_source)}",stacklevel=2) self.driver_executable = None else: - if self.binary_path.exists(): + if self.binary_source.exists(): self.driver_executable.resolve() else: - self.binary_path = "NOT IMPLEMENTED FOR THIS CODE" + self.binary_source = "NOT IMPLEMENTED FOR THIS CODE" self.driver_executable = None update_list.append("driver_executable") + + if self.codename == "Swifter": + J2 = self.param.pop("J2",0.0) + J4 = self.param.pop("J4",0.0) + self.param = io.swiftest2swifter_param(self.param, J2, J4) if integrator is not None: valid_integrator = ["symba","rmvs","whm","helio"] @@ -1006,7 +1016,8 @@ def get_integrator(self,arg_list: str | List[str] | None = None, verbose: bool | valid_instance_vars = {"codename": self.codename, "integrator": self.integrator, "param_file": str(self.param_file), - "driver_executable": str(self.driver_executable)} + "driver_executable": str(self.driver_executable) + } try: self.integrator @@ -1065,6 +1076,7 @@ def set_feature(self, interaction_loops: Literal["TRIANGULAR", "FLAT"] | None = None, encounter_check_loops: Literal["TRIANGULAR", "SORTSWEEP"] | None = None, encounter_save: Literal["NONE", "TRAJECTORY", "CLOSEST", "BOTH"] | None = None, + coarray: bool | None = None, verbose: bool | None = None, simdir: str | os.PathLike = None, **kwargs: Any @@ -1130,6 +1142,11 @@ def set_feature(self, * "SORTSWEEP" : A Sort-Sweep algorithm is used to reduce the population of potential close encounter bodies. This algorithm is still in development, and does not necessarily speed up the encounter checking. Use with caution. + coarray : bool, default False + If true, will employ Coarrays on test particle structures to run in single program/multiple data parallel mode. + *Note" In order to use this capability, Swiftest must be compiled for Coarray support. Only certain integrators + can use Coarrays: RMVS, WHM, Helio are all compatible, but SyMBA is not, due to the way tp-pl close encounters + are handeled. tides: bool, optional Turns on tidal model (IN DEVELOPMENT - IGNORED) Yarkovsky: bool, optional @@ -1160,113 +1177,21 @@ def set_feature(self, if close_encounter_check is not None: self.param["CHK_CLOSE"] = close_encounter_check update_list.append("close_encounter_check") - - if general_relativity is not None: - self.param["GR"] = general_relativity - update_list.append("general_relativity") - - fragmentation_models = ["FRAGGLE"] - if collision_model is not None: - collision_model = collision_model.upper() - fragmentation = collision_model in fragmentation_models - if self.codename != "Swiftest" and self.integrator != "symba" and fragmentation: - warnings.warn("Fragmentation is only available on Swiftest SyMBA.",stacklevel=2) - self.param['COLLISION_MODEL'] = "MERGE" - else: - self.param['COLLISION_MODEL'] = collision_model - update_list.append("collision_model") - if fragmentation: - if "MIN_GMFRAG" not in self.param and minimum_fragment_mass is None and minimum_fragment_gmass is None: - warnings.warn("Minimum fragment mass is not set. Set it using minimum_fragment_gmass or minimum_fragment_mass",stacklevel=2) - else: - update_list.append("minimum_fragment_gmass") - - if minimum_fragment_gmass is not None and minimum_fragment_mass is not None: - warnings.warn("Only set either minimum_fragment_mass or minimum_fragment_gmass, but not both!",stacklevel=2) - - if minimum_fragment_gmass is not None: - self.param["MIN_GMFRAG"] = minimum_fragment_gmass - if "minmum_fragment_gmass" not in update_list: - update_list.append("minimum_fragment_gmass") - elif minimum_fragment_mass is not None: - self.param["MIN_GMFRAG"] = minimum_fragment_mass * self.GU - if "minimum_fragment_gmass" not in update_list: - update_list.append("minimum_fragment_gmass") - - if nfrag_reduction is not None: - self.param["NFRAG_REDUCTION"] = nfrag_reduction - update_list.append("nfrag_reduction") - - if rotation is not None: - self.param['ROTATION'] = rotation - update_list.append("rotation") - - if self.param['COLLISION_MODEL'] == "FRAGGLE" and not self.param['ROTATION']: - self.param['ROTATION'] = True - update_list.append("rotation") - - if compute_conservation_values is not None: - self.param["ENERGY"] = compute_conservation_values - update_list.append("compute_conservation_values") - + + if rhill_present is not None: + self.param["RHILL_PRESENT"] = rhill_present + update_list.append("rhill_present") + if extra_force is not None: self.param["EXTRA_FORCE"] = extra_force update_list.append("extra_force") - if big_discard is not None: if self.codename != "Swifter": self.param["BIG_DISCARD"] = False else: self.param["BIG_DISCARD"] = big_discard - update_list.append("big_discard") - - if rhill_present is not None: - self.param["RHILL_PRESENT"] = rhill_present - update_list.append("rhill_present") - - if restart is not None: - self.param["RESTART"] = restart - update_list.append("restart") - - if interaction_loops is not None: - valid_vals = ["TRIANGULAR", "FLAT"] - interaction_loops = interaction_loops.upper() - if interaction_loops not in valid_vals: - msg = f"{interaction_loops} is not a valid option for interaction loops." - msg += f"\nMust be one of {valid_vals}" - warnings.warn(msg,stacklevel=2) - if "INTERACTION_LOOPS" not in self.param: - self.param["INTERACTION_LOOPS"] = valid_vals[0] - else: - self.param["INTERACTION_LOOPS"] = interaction_loops - update_list.append("interaction_loops") - - if encounter_check_loops is not None: - valid_vals = ["TRIANGULAR", "SORTSWEEP"] - encounter_check_loops = encounter_check_loops.upper() - if encounter_check_loops not in valid_vals: - msg = f"{encounter_check_loops} is not a valid option for interaction loops." - msg += f"\nMust be one of {valid_vals}" - warnings.warn(msg,stacklevel=2) - if "ENCOUNTER_CHECK" not in self.param: - self.param["ENCOUNTER_CHECK"] = valid_vals[0] - else: - self.param["ENCOUNTER_CHECK"] = encounter_check_loops - update_list.append("encounter_check_loops") - - if encounter_save is not None: - valid_vals = ["NONE", "TRAJECTORY", "CLOSEST", "BOTH"] - encounter_save = encounter_save.upper() - if encounter_save not in valid_vals: - msg = f"{encounter_save} is not a valid option for encounter_save." - msg += f"\nMust be one of {valid_vals}" - warnings.warn(msg,stacklevel=2) - if "ENCOUNTER_SAVE" not in self.param: - self.param["ENCOUNTER_SAVE"] = valid_vals[0] - else: - self.param["ENCOUNTER_SAVE"] = encounter_save - update_list.append("encounter_save") + update_list.append("big_discard") if simdir is not None: self.simdir = Path(simdir) @@ -1275,12 +1200,108 @@ def set_feature(self, msg = f"Cannot create the {self.simdir.resolve()} directory: File exists." msg += "\nDelete the file or change the location of param_file" raise NotADirectoryError(msg) - self.binary_path = self.simdir.resolve() - self.driver_executable = self.binary_path / "swiftest_driver" self.param_file = Path(kwargs.pop("param_file","param.in")) - self.param["TIDES"] = False - + if self.codename == "Swiftest": + if general_relativity is not None: + self.param["GR"] = general_relativity + update_list.append("general_relativity") + + fragmentation_models = ["FRAGGLE"] + if collision_model is not None: + collision_model = collision_model.upper() + fragmentation = collision_model in fragmentation_models + if self.codename != "Swiftest" and self.integrator != "symba" and fragmentation: + warnings.warn("Fragmentation is only available on Swiftest SyMBA.",stacklevel=2) + self.param['COLLISION_MODEL'] = "MERGE" + else: + self.param['COLLISION_MODEL'] = collision_model + update_list.append("collision_model") + if fragmentation: + if "MIN_GMFRAG" not in self.param and minimum_fragment_mass is None and minimum_fragment_gmass is None: + warnings.warn("Minimum fragment mass is not set. Set it using minimum_fragment_gmass or minimum_fragment_mass",stacklevel=2) + else: + update_list.append("minimum_fragment_gmass") + + if minimum_fragment_gmass is not None and minimum_fragment_mass is not None: + warnings.warn("Only set either minimum_fragment_mass or minimum_fragment_gmass, but not both!",stacklevel=2) + + if minimum_fragment_gmass is not None: + self.param["MIN_GMFRAG"] = minimum_fragment_gmass + if "minmum_fragment_gmass" not in update_list: + update_list.append("minimum_fragment_gmass") + elif minimum_fragment_mass is not None: + self.param["MIN_GMFRAG"] = minimum_fragment_mass * self.GU + if "minimum_fragment_gmass" not in update_list: + update_list.append("minimum_fragment_gmass") + + if nfrag_reduction is not None: + self.param["NFRAG_REDUCTION"] = nfrag_reduction + update_list.append("nfrag_reduction") + + if rotation is not None: + self.param['ROTATION'] = rotation + update_list.append("rotation") + + if self.param['COLLISION_MODEL'] == "FRAGGLE" and not self.param['ROTATION']: + self.param['ROTATION'] = True + update_list.append("rotation") + + if compute_conservation_values is not None: + self.param["ENERGY"] = compute_conservation_values + update_list.append("compute_conservation_values") + + if restart is not None: + self.param["RESTART"] = restart + update_list.append("restart") + + if interaction_loops is not None: + valid_vals = ["TRIANGULAR", "FLAT"] + interaction_loops = interaction_loops.upper() + if interaction_loops not in valid_vals: + msg = f"{interaction_loops} is not a valid option for interaction loops." + msg += f"\nMust be one of {valid_vals}" + warnings.warn(msg,stacklevel=2) + if "INTERACTION_LOOPS" not in self.param: + self.param["INTERACTION_LOOPS"] = valid_vals[0] + else: + self.param["INTERACTION_LOOPS"] = interaction_loops + update_list.append("interaction_loops") + + if encounter_check_loops is not None: + valid_vals = ["TRIANGULAR", "SORTSWEEP"] + encounter_check_loops = encounter_check_loops.upper() + if encounter_check_loops not in valid_vals: + msg = f"{encounter_check_loops} is not a valid option for interaction loops." + msg += f"\nMust be one of {valid_vals}" + warnings.warn(msg,stacklevel=2) + if "ENCOUNTER_CHECK" not in self.param: + self.param["ENCOUNTER_CHECK"] = valid_vals[0] + else: + self.param["ENCOUNTER_CHECK"] = encounter_check_loops + update_list.append("encounter_check_loops") + + if encounter_save is not None: + valid_vals = ["NONE", "TRAJECTORY", "CLOSEST", "BOTH"] + encounter_save = encounter_save.upper() + if encounter_save not in valid_vals: + msg = f"{encounter_save} is not a valid option for encounter_save." + msg += f"\nMust be one of {valid_vals}" + warnings.warn(msg,stacklevel=2) + if "ENCOUNTER_SAVE" not in self.param: + self.param["ENCOUNTER_SAVE"] = valid_vals[0] + else: + self.param["ENCOUNTER_SAVE"] = encounter_save + update_list.append("encounter_save") + + if coarray is not None: + if self.codename == "Swiftest": + self.param["COARRAY"] = coarray + update_list.append("coarray") + + self.param["TIDES"] = False + + feature_dict = self.get_feature(update_list, verbose) return feature_dict @@ -1321,6 +1342,7 @@ def get_feature(self, arg_list: str | List[str] | None = None, verbose: bool | N "big_discard": "BIG_DISCARD", "interaction_loops": "INTERACTION_LOOPS", "encounter_check_loops": "ENCOUNTER_CHECK", + "coarray" : "COARRAY", "restart": "RESTART" } @@ -1418,13 +1440,19 @@ def ascii_file_input_error_msg(codename): if "IN_FORM" in self.param: init_cond_format = self.param['IN_FORM'] else: - init_cond_format = "EL" + if self.codename.title() == "Swiftest": + init_cond_format = "EL" + else: + init_cond_format = "XV" if init_cond_file_type is None: if "IN_TYPE" in self.param: init_cond_file_type = self.param['IN_TYPE'] else: - init_cond_file_type = "NETCDF_DOUBLE" + if self.codename.title() == "Swiftest": + init_cond_file_type = "NETCDF_DOUBLE" + else: + init_cond_file_type = "ASCII" if self.codename.title() == "Swiftest": init_cond_keys = ["CB", "PL", "TP"] @@ -1641,10 +1669,11 @@ def set_output_files(self, else: self.param['BIN_OUT'] = output_file_name - if output_format != "XV" and self.codename != "Swiftest": - warnings.warn(f"{output_format} is not compatible with {self.codename}. Setting to XV",stacklevel=2) - output_format = "XV" - self.param["OUT_FORM"] = output_format + if output_format is not None: + if output_format != "XV" and self.codename != "Swiftest": + warnings.warn(f"{output_format} is not compatible with {self.codename}. Setting to XV",stacklevel=2) + output_format = "XV" + self.param["OUT_FORM"] = output_format if self.restart: self.param["OUT_STAT"] = "APPEND" @@ -1882,11 +1911,12 @@ def set_unit_system(self, if all(key in self.param for key in ["MU2KG","DU2M","TU2S"]): self.GU = constants.GC * self.param["TU2S"] ** 2 * self.param["MU2KG"] / self.param["DU2M"] ** 3 - if recompute_unit_values and \ - MU2KG_old != self.param['MU2KG'] or \ - DU2M_old != self.param['DU2M'] or \ - TU2S_old != self.param['TU2S']: - self.update_param_units(MU2KG_old, DU2M_old, TU2S_old) + if "MU2KG" in self.param and "DU2M" in self.param and "TU2S" in self.param: + if recompute_unit_values and \ + MU2KG_old != self.param['MU2KG'] or \ + DU2M_old != self.param['DU2M'] or \ + TU2S_old != self.param['TU2S']: + self.update_param_units(MU2KG_old, DU2M_old, TU2S_old) unit_dict = self.get_unit_system(update_list, verbose) @@ -2203,9 +2233,9 @@ def add_solar_system_body(self, values = list(np.hsplit(np.array(body_list[0],dtype=np.dtype(object)),17)) else: values = list(np.squeeze(np.hsplit(np.array(body_list,np.dtype(object)),17))) - keys = ["id","name","a","e","inc","capom","omega","capm","rh","vh","Gmass","radius","rhill","Ip","rot","J2","J4"] + keys = ["id","name","a","e","inc","capom","omega","capm","rh","vh","Gmass","radius","rhill","Ip","rot","j2rp2","j4rp4"] kwargs = dict(zip(keys,values)) - scalar_floats = ["a","e","inc","capom","omega","capm","Gmass","radius","rhill","J2","J4"] + scalar_floats = ["a","e","inc","capom","omega","capm","Gmass","radius","rhill","j2rp2","j4rp4"] vector_floats = ["rh","vh","Ip","rot"] scalar_ints = ["id"] @@ -2328,14 +2358,14 @@ def _get_instance_var(self, arg_list: str | List[str], valid_arg: Dict, verbose: Parameters ---------- arg_list: str | List[str] - A single string or list of strings containing the names of the the instance variable to get. + A single string or list of strings containing the names of the the instance variable to get. valid_arg: dict - A dictionary where the key is the parameter argument and the value is the equivalent instance variable value. + A dictionary where the key is the parameter argument and the value is the equivalent instance variable value. verbose: bool, optional - If passed, it will override the Simulation object's verbose flag + If passed, it will override the Simulation object's verbose flag **kwargs - A dictionary of additional keyword argument. This allows this method to be called by the more general - get_parameter method, which takes all possible Simulation parameters as arguments, so these are ignored. + A dictionary of additional keyword argument. This allows this method to be called by the more general + get_parameter method, which takes all possible Simulation parameters as arguments, so these are ignored. Returns ------- @@ -2414,7 +2444,7 @@ def add_body(self, Hill's radius values if these are massive bodies rot: (3) or (n,3) array-like of float, optional Rotation rate vectors if these are massive bodies with rotation enabled. - Ip: (3) or (n,3) array-like of flaot, optional + Ip: (3) or (n,3) array-like of float, optional Principal axes moments of inertia vectors if these are massive bodies with rotation enabled. Returns @@ -2431,7 +2461,7 @@ def input_to_array(val,t,n=None): elif t == "i": t = np.int64 elif t == "s": - t = np.str + t = str if val is None: return None, n @@ -2531,7 +2561,7 @@ def input_to_array_3d(val,n=None): Gmass = self.GU * mass dsnew = init_cond.vec2xr(self.param, name=name, a=a, e=e, inc=inc, capom=capom, omega=omega, capm=capm, id=id, - Gmass=Gmass, radius=radius, rhill=rhill, Ip=Ip, rh=rh, vh=vh,rot=rot, J2=J2, J4=J4, time=time) + Gmass=Gmass, radius=radius, rhill=rhill, Ip=Ip, rh=rh, vh=vh,rot=rot, j2rp2=J2, j4rp4=J4, time=time) dsnew = self._combine_and_fix_dsnew(dsnew) self.save(verbose=False) @@ -2602,7 +2632,8 @@ def read_param(self, codename: Literal["Swiftest", "Swifter", "Swift"] | None = None, read_init_cond : bool | None = None, verbose: bool | None = None, - dask: bool = False): + dask: bool = False, + **kwargs : Any): """ Reads in an input parameter file and stores the values in the param dictionary. @@ -2721,7 +2752,6 @@ def write_param(self, self.driver_script = os.path.join(self.simdir, "swiftest_driver.sh") with open(self.driver_script, 'w') as f: f.write(f"#{self._shell_full}\n") - f.write(f"source ~/.{self._shell}rc\n") f.write(f"cd {self.simdir}\n") f.write(f"{str(self.driver_executable)} {self.integrator} {str(self.param_file)} compact\n") @@ -2958,18 +2988,15 @@ def save(self, self.write_param(param_file=param_file,**kwargs) if not self.binary_source.exists(): msg = "Path to swiftest_driver has not been set!" - msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_path)}" + msg += f"\nMake sure swiftest_driver is compiled and the executable is in {str(self.binary_source.parent)}" warnings.warn(msg,stacklevel=2) return - else: - shutil.copy2(self.binary_source, self.driver_executable) elif codename == "Swifter": - if codename == "Swiftest": - swifter_param = io.swiftest2swifter_param(param) - else: - swifter_param = param - io.swifter_xr2infile(self.data, swifter_param, framenum) - self.write_param(param_file, param=swifter_param,**kwargs) + swifter_param = io.swiftest2swifter_param(param) + if "rhill" in self.data: + swifter_param['RHILL_PRESENT'] = 'YES' + io.swifter_xr2infile(self.data, swifter_param, self.simdir, framenum) + self.write_param(codename=codename,param_file=param_file,param=swifter_param,**kwargs) else: warnings.warn(f'Saving to {codename} not supported',stacklevel=2) diff --git a/singularity/.gitignore b/singularity/.gitignore new file mode 100644 index 000000000..baed94e88 --- /dev/null +++ b/singularity/.gitignore @@ -0,0 +1,4 @@ +!bin/ +!bin/swiftest_driver +!bin/swiftest +!install.sh diff --git a/singularity/bin/swiftest b/singularity/bin/swiftest new file mode 100755 index 000000000..a384860fe --- /dev/null +++ b/singularity/bin/swiftest @@ -0,0 +1,4 @@ +#!/bin/sh -- +OMP_NUM_THREADS=${OMP_NUM_THREADS:-`nproc --all`} +FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES:-1} +singularity run --bind $(pwd):$(pwd) --cleanenv --env OMP_NUM_THREADS=${OMP_NUM_THREADS},FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES} ${SWIFTEST_SIF} "$@" \ No newline at end of file diff --git a/singularity/bin/swiftest_driver b/singularity/bin/swiftest_driver new file mode 100755 index 000000000..024e93115 --- /dev/null +++ b/singularity/bin/swiftest_driver @@ -0,0 +1,4 @@ +#!/bin/sh -- +OMP_NUM_THREADS=${OMP_NUM_THREADS:-`nproc --all`} +FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES:-1} +singularity exec --bind $(pwd):$(pwd) --env OMP_NUM_THREADS=${OMP_NUM_THREADS},FOR_COARRAY_NUM_IMAGES=${FOR_COARRAY_NUM_IMAGES} ${SWIFTEST_SIF} swiftest_driver "$@" \ No newline at end of file diff --git a/singularity/install.sh b/singularity/install.sh new file mode 100755 index 000000000..233ee187f --- /dev/null +++ b/singularity/install.sh @@ -0,0 +1,21 @@ +#!/bin/sh -- +# This will install the Singularity version of the swiftest_driver in place of the native compiled version into ../bin as +# well as the swiftest_python script that is used to execute a Python input file. +# The swiftest.sif file will be copied to the SIF_DIR directory. The default location is ${HOME}/.singularity. +# To change this, just set environment variable SIF_DIR prior to running this script. +# +# The script takes an optional argument "tag" if you want to pull a container other than "latest". +# +# In order to use one executable script, the SWIFTEST_SIF environment variable must be set to point to the location of swiftest.sif, +# which requires this script to be called via source: +# $ source ./install.sh +# or +# $ . ./install.sh +TAG=${1:-latest} + +SIF_DIR=${SIF_DIR:-${HOME}/.singularity} +echo "Installing ${SIF_DIR}/swiftest.sif container from mintongroup/swiftest:${TAG} Docker container" +singularity pull --force ${SIF_DIR}/swiftest.sif docker://mintongroup/swiftest:${TAG} +cp -rf bin/swiftest ../bin/ +cp -rf bin/swiftest_driver ../bin/ +export SWIFTEST_SIF=${SIF_DIR}/swiftest.sif \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1f657d65c..f360bcdbc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,17 +13,41 @@ # Add the source files SET(STRICT_MATH_FILES - ${SRC}/swiftest/swiftest_kick.f90 - ${SRC}/helio/helio_kick.f90 - ${SRC}/rmvs/rmvs_kick.f90 - ${SRC}/symba/symba_kick.f90 - ${SRC}/whm/whm_kick.f90 - ${SRC}/swiftest/swiftest_user.f90 + ${SRC}/collision/collision_generate.f90 + ${SRC}/collision/collision_io.f90 + ${SRC}/collision/collision_util.f90 ${SRC}/fraggle/fraggle_generate.f90 ${SRC}/fraggle/fraggle_util.f90 ${SRC}/fraggle/fraggle_module.f90 + ${SRC}/helio/helio_drift.f90 + ${SRC}/helio/helio_gr.f90 + ${SRC}/helio/helio_kick.f90 + ${SRC}/helio/helio_step.f90 ${SRC}/misc/lambda_function_module.f90 ${SRC}/misc/solver_module.f90 + ${SRC}/netcdf_io/netcdf_io_implementations.f90 + ${SRC}/operator/operator_module.f90 + ${SRC}/operator/operator_cross.f90 + ${SRC}/operator/operator_mag.f90 + ${SRC}/operator/operator_unit.f90 + ${SRC}/rmvs/rmvs_kick.f90 + ${SRC}/rmvs/rmvs_step.f90 + ${SRC}/swiftest/swiftest_drift.f90 + ${SRC}/swiftest/swiftest_gr.f90 + ${SRC}/swiftest/swiftest_io.f90 + ${SRC}/swiftest/swiftest_kick.f90 + ${SRC}/swiftest/swiftest_user.f90 + ${SRC}/swiftest/swiftest_obl.f90 + ${SRC}/swiftest/swiftest_orbel.f90 + ${SRC}/symba/symba_drift.f90 + ${SRC}/symba/symba_gr.f90 + ${SRC}/symba/symba_kick.f90 + ${SRC}/symba/symba_step.f90 + ${SRC}/whm/whm_coord.f90 + ${SRC}/whm/whm_drift.f90 + ${SRC}/whm/whm_gr.f90 + ${SRC}/whm/whm_kick.f90 + ${SRC}/whm/whm_step.f90 ) SET(FAST_MATH_FILES @@ -33,7 +57,6 @@ SET(FAST_MATH_FILES ${SRC}/misc/io_progress_bar_module.f90 ${SRC}/encounter/encounter_module.f90 ${SRC}/collision/collision_module.f90 - ${SRC}/operator/operator_module.f90 ${SRC}/walltime/walltime_module.f90 ${SRC}/swiftest/swiftest_module.f90 ${SRC}/whm/whm_module.f90 @@ -41,72 +64,63 @@ SET(FAST_MATH_FILES ${SRC}/helio/helio_module.f90 ${SRC}/symba/symba_module.f90 ${SRC}/collision/collision_check.f90 - ${SRC}/collision/collision_generate.f90 - ${SRC}/collision/collision_io.f90 ${SRC}/collision/collision_regime.f90 ${SRC}/collision/collision_resolve.f90 - ${SRC}/collision/collision_util.f90 ${SRC}/encounter/encounter_check.f90 ${SRC}/encounter/encounter_io.f90 ${SRC}/encounter/encounter_util.f90 - ${SRC}/helio/helio_drift.f90 - ${SRC}/helio/helio_gr.f90 - ${SRC}/helio/helio_step.f90 ${SRC}/helio/helio_util.f90 - ${SRC}/netcdf_io/netcdf_io_implementations.f90 - ${SRC}/operator/operator_cross.f90 - ${SRC}/operator/operator_mag.f90 - ${SRC}/operator/operator_unit.f90 ${SRC}/rmvs/rmvs_discard.f90 ${SRC}/rmvs/rmvs_encounter_check.f90 - ${SRC}/rmvs/rmvs_step.f90 ${SRC}/rmvs/rmvs_util.f90 ${SRC}/swiftest/swiftest_discard.f90 - ${SRC}/swiftest/swiftest_drift.f90 - ${SRC}/swiftest/swiftest_gr.f90 - ${SRC}/swiftest/swiftest_io.f90 - ${SRC}/swiftest/swiftest_obl.f90 - ${SRC}/swiftest/swiftest_orbel.f90 ${SRC}/swiftest/swiftest_util.f90 ${SRC}/symba/symba_discard.f90 - ${SRC}/symba/symba_drift.f90 ${SRC}/symba/symba_encounter_check.f90 - ${SRC}/symba/symba_gr.f90 - ${SRC}/symba/symba_step.f90 ${SRC}/symba/symba_util.f90 ${SRC}/walltime/walltime_implementations.f90 - ${SRC}/whm/whm_coord.f90 - ${SRC}/whm/whm_drift.f90 - ${SRC}/whm/whm_gr.f90 - ${SRC}/whm/whm_step.f90 ${SRC}/whm/whm_util.f90 ${SRC}/swiftest/swiftest_driver.f90 ) -set(SWIFTEST_src ${FAST_MATH_FILES} ${STRICT_MATH_FILES}) +SET(COARRAY_FILES + ${SRC}/coarray/coarray_module.f90 + ${SRC}/coarray/coarray_clone.f90 + ${SRC}/coarray/coarray_collect.f90 + ${SRC}/swiftest/swiftest_coarray.f90 + ${SRC}/whm/whm_coarray.f90 + ${SRC}/rmvs/rmvs_coarray.f90 +) + +IF(USE_COARRAY) + set(SWIFTEST_src ${COARRAY_FILES} ${FAST_MATH_FILES} ${STRICT_MATH_FILES}) +ELSE() + set(SWIFTEST_src ${FAST_MATH_FILES} ${STRICT_MATH_FILES}) +ENDIF(USE_COARRAY) # Define the executable in terms of the source files ADD_EXECUTABLE(${SWIFTEST_DRIVER} ${SWIFTEST_src}) +# Turn preprocessor on for all files +SET_SOURCE_FILES_PROPERTIES(${SWIFTEST_src} PROPERTIES Fortran_PREPROCESS ON) + ##################################################### # Add the needed libraries and special compiler flags ##################################################### -# # Uncomment if you need to link to BLAS and LAPACK -TARGET_LINK_LIBRARIES(${SWIFTEST_DRIVER} ${NETCDF_LIBRARIES} ${NETCDF_FORTRAN_LIBRARIES}) +TARGET_LINK_LIBRARIES(${SWIFTEST_DRIVER} PRIVATE ${NETCDF_FORTRAN_LIBRARIES} ${NETCDF_LIBRARIES} $ENV{LIBS}) IF(USE_OPENMP) - SET_TARGET_PROPERTIES(${SWIFTEST_DRIVER} PROPERTIES - COMPILE_FLAGS "${OpenMP_Fortran_FLAGS}" - LINK_FLAGS "${OpenMP_Fortran_FLAGS}") -ELSEIF(USE_MPI) - SET_TARGET_PROPERTIES(${SWIFTEST_DRIVER} PROPERTIES - COMPILE_FLAGS "${MPI_Fortran_COMPILE_FLAGS}" - LINK_FLAGS "${MPI_Fortran_LINK_FLAGS}") - INCLUDE_DIRECTORIES(${MPI_Fortran_INCLUDE_PATH}) - TARGET_LINK_LIBRARIES(${SWIFTEST_DRIVER} ${MPI_Fortran_LIBRARIES}) + SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY COMPILE_FLAGS "${OpenMP_Fortran_FLAGS} ") + SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY LINK_FLAGS "${OpenMP_Fortran_FLAGS} ") ENDIF(USE_OPENMP) +IF(USE_COARRAY) + TARGET_COMPILE_DEFINITIONS(${SWIFTEST_DRIVER} PRIVATE -DCOARRAY) + SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY COMPILE_FLAGS "${Coarray_Fortran_FLAGS} ") + SET_PROPERTY(TARGET ${SWIFTEST_DRIVER} APPEND_STRING PROPERTY LINK_FLAGS "${Coarray_Fortran_FLAGS} ") +ENDIF(USE_COARRAY) + ##################################### # Tell how to install this executable @@ -127,3 +141,29 @@ IF(BT STREQUAL "RELEASE" OR BT STREQUAL "PROFILE") SET_PROPERTY(SOURCE ${FAST_MATH_FILES} APPEND_STRING PROPERTY COMPILE_FLAGS "${FASTMATH_FLAGS}") ENDIF() +IF(BT STREQUAL "DEBUG") + ADD_DEFINITIONS(-DDEBUG) +ELSEIF(BT STREQUAL "PROFILE") + ADD_DEFINITIONS(-DPROFILE) +ENDIF() + +# Check to see if the compiler allows for local-spec in do concurrent statements. Set a preprocessor variable if it does +IF (USE_OPENMP) + SET(TESTFILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}") + SET(TESTFILE "${TESTFILE}/CMakeTmp/testFortranDoConcurrentLoc.f90") + FILE(WRITE "${TESTFILE}" +" +program TestDoConcurrentLoc +integer :: i +real,dimension(10) :: a +do concurrent(i = 1:10) shared(a) + a(i) = i +end do +end program TestDoConcurrentLoc +") + TRY_COMPILE(DOCONLOC_WORKS ${CMAKE_BINARY_DIR} ${TESTFILE} + COMPILE_DEFINITIONS "${CMAKE_Fortran_FLAGS}" OUTPUT_VARIABLE OUTPUT) + IF (DOCONLOC_WORKS) + TARGET_COMPILE_DEFINITIONS(${SWIFTEST_DRIVER} PRIVATE -DDOCONLOC) + ENDIF (DOCONLOC_WORKS) +ENDIF (USE_OPENMP) diff --git a/src/base/base_module.f90 b/src/base/base_module.f90 index 0a9429dbc..51266238f 100644 --- a/src/base/base_module.f90 +++ b/src/base/base_module.f90 @@ -13,93 +13,111 @@ module base !! Base type definitions. This allows the collision and encounter modules to be defined before the swiftest module. !! use globals +#ifdef COARRAY + use coarray +#endif implicit none public - !> User defined parameters that are read in from the parameters input file. !> Each paramter is initialized to a default values. type, abstract :: base_parameters - character(len=:), allocatable :: integrator !! Name of the nbody integrator used - character(len=:), allocatable :: param_file_name !! The name of the parameter file - real(DP) :: t0 = 0.0_DP !! Integration reference time - real(DP) :: tstart = -1.0_DP !! Integration start time - real(DP) :: tstop = -1.0_DP !! Integration stop time - real(DP) :: dt = -1.0_DP !! Time step - integer(I8B) :: iloop = 0_I8B !! Main loop counter - integer(I8B) :: nloops = 0_I8B !! Total number of loops to execute - character(STRMAX) :: incbfile = CB_INFILE !! Name of input file for the central body - character(STRMAX) :: inplfile = PL_INFILE !! Name of input file for massive bodies - character(STRMAX) :: intpfile = TP_INFILE !! Name of input file for test particles - character(STRMAX) :: nc_in = NC_INFILE !! Name of system input file for NetCDF input - character(STRMAX) :: in_type = "NETCDF_DOUBLE" !! Data representation type of input data files - character(STRMAX) :: in_form = "XV" !! Format of input data files ("EL" or ["XV"]) - integer(I4B) :: istep_out = -1 !! Number of time steps between saved outputs - integer(I4B) :: nstep_out = -1 !! Total number of saved outputs - real(DP) :: fstep_out = 1.0_DP !! The output step time stretching factor - logical :: ltstretch = .false. !! Whether to employ time stretching or not - character(STRMAX) :: outfile = BIN_OUTFILE !! Name of output binary file - character(STRMAX) :: out_type = "NETCDF_DOUBLE" !! Binary format of output file - character(STRMAX) :: out_form = "XVEL" !! Data to write to output file - character(STRMAX) :: out_stat = 'NEW' !! Open status for output binary file - integer(I4B) :: dump_cadence = 10 !! Number of output steps between dumping simulation data to file - real(DP) :: rmin = -1.0_DP !! Minimum heliocentric radius for test particle - real(DP) :: rmax = -1.0_DP !! Maximum heliocentric radius for test particle - real(DP) :: rmaxu = -1.0_DP !! Maximum unbound heliocentric radius for test particle - real(DP) :: qmin = -1.0_DP !! Minimum pericenter distance for test particle - character(STRMAX) :: qmin_coord = "HELIO" !! Coordinate frame to use for qmin (["HELIO"] or "BARY") - real(DP) :: qmin_alo = -1.0_DP !! Minimum semimajor axis for qmin - real(DP) :: qmin_ahi = -1.0_DP !! Maximum semimajor axis for qmin - real(QP) :: MU2KG = -1.0_QP !! Converts mass units to grams - real(QP) :: TU2S = -1.0_QP !! Converts time units to seconds - real(QP) :: DU2M = -1.0_QP !! Converts distance unit to centimeters - real(DP) :: GU = -1.0_DP !! Universal gravitational constant in the system units - real(DP) :: inv_c2 = -1.0_DP !! Inverse speed of light squared in the system units - real(DP) :: GMTINY = -1.0_DP !! Smallest G*mass that is fully gravitating - real(DP) :: min_GMfrag = -1.0_DP !! Smallest G*mass that can be produced in a fragmentation event - real(DP) :: nfrag_reduction = 30.0_DP !! Reduction factor for limiting the number of fragments in a collision - integer(I4B), dimension(:), allocatable :: seed !! Random seeds for fragmentation modeling - logical :: lmtiny_pl = .false. !! Include semi-interacting massive bodies - character(STRMAX) :: collision_model = "MERGE" !! The Coll - character(STRMAX) :: encounter_save = "NONE" !! Indicate if and how encounter data should be saved - logical :: lenc_save_trajectory = .false. !! Indicates that when encounters are saved, the full trajectory through recursion steps are saved - logical :: lenc_save_closest = .false. !! Indicates that when encounters are saved, the closest approach distance between pairs of bodies is saved - character(NAMELEN) :: interaction_loops = "ADAPTIVE" !! Method used to compute interaction loops. Options are "TRIANGULAR", "FLAT", or "ADAPTIVE" - character(NAMELEN) :: encounter_check_plpl = "ADAPTIVE" !! Method used to compute pl-pl encounter checks. Options are "TRIANGULAR", "SORTSWEEP", or "ADAPTIVE" - character(NAMELEN) :: encounter_check_pltp = "ADAPTIVE" !! Method used to compute pl-tp encounter checks. Options are "TRIANGULAR", "SORTSWEEP", or "ADAPTIVE" - - ! The following are used internally, and are not set by the user, but instead are determined by the input value of INTERACTION_LOOPS + character(STRMAX) :: integrator !! Name of the nbody integrator used + character(STRMAX) :: param_file_name !! The name of the parameter file + real(DP) :: t0 = 0.0_DP !! Integration reference time + real(DP) :: tstart = -1.0_DP !! Integration start time + real(DP) :: tstop = -1.0_DP !! Integration stop time + real(DP) :: dt = -1.0_DP !! Time step + integer(I8B) :: iloop = 0_I8B !! Main loop counter + integer(I8B) :: nloops = 0_I8B !! Total number of loops to execute + integer(I8B) :: istart = 0_I8B !! Starting index for loop counter + integer(I4B) :: iout = 0 !! Output cadence counter + integer(I4B) :: idump = 0 !! Dump cadence counter + integer(I4B) :: nout = 0 !! Current output step + integer(I4B) :: istep = 0 !! Current value of istep (used for time stretching) + character(STRMAX) :: incbfile = CB_INFILE !! Name of input file for the central body + character(STRMAX) :: inplfile = PL_INFILE !! Name of input file for massive bodies + character(STRMAX) :: intpfile = TP_INFILE !! Name of input file for test particles + character(STRMAX) :: nc_in = NC_INFILE !! Name of system input file for NetCDF input + character(STRMAX) :: in_type = "NETCDF_DOUBLE" !! Data representation type of input data files + character(STRMAX) :: in_form = "XV" !! Format of input data files ("EL" or ["XV"]) + integer(I4B) :: istep_out = -1 !! Number of time steps between saved outputs + integer(I4B) :: nstep_out = -1 !! Total number of saved outputs + real(DP) :: fstep_out = 1.0_DP !! The output step time stretching factor + logical :: ltstretch = .false. !! Whether to employ time stretching or not + character(STRMAX) :: outfile = BIN_OUTFILE !! Name of output binary file + character(STRMAX) :: out_type = "NETCDF_DOUBLE" !! Binary format of output file + character(STRMAX) :: out_form = "XVEL" !! Data to write to output file + character(STRMAX) :: out_stat = 'NEW' !! Open status for output binary file + integer(I4B) :: dump_cadence = 10 !! Number of output steps between dumping simulation data to file + real(DP) :: rmin = -1.0_DP !! Minimum heliocentric radius for test particle + real(DP) :: rmax = -1.0_DP !! Maximum heliocentric radius for test particle + real(DP) :: rmaxu = -1.0_DP !! Maximum unbound heliocentric radius for test particle + real(DP) :: qmin = -1.0_DP !! Minimum pericenter distance for test particle + character(STRMAX) :: qmin_coord = "HELIO" !! Coordinate frame to use for qmin (["HELIO"] or "BARY") + real(DP) :: qmin_alo = -1.0_DP !! Minimum semimajor axis for qmin + real(DP) :: qmin_ahi = -1.0_DP !! Maximum semimajor axis for qmin + real(QP) :: MU2KG = -1.0_QP !! Converts mass units to grams + real(QP) :: TU2S = -1.0_QP !! Converts time units to seconds + real(QP) :: DU2M = -1.0_QP !! Converts distance unit to centimeters + real(DP) :: GU = -1.0_DP !! Universal gravitational constant in the system units + real(DP) :: inv_c2 = -1.0_DP !! Inverse speed of light squared in the system units + real(DP) :: GMTINY = -1.0_DP !! Smallest G*mass that is fully gravitating + real(DP) :: min_GMfrag = -1.0_DP !! Smallest G*mass that can be produced in a fragmentation event + real(DP) :: nfrag_reduction = 30.0_DP !! Reduction factor for limiting the number of collision fragments + integer(I4B), dimension(:), allocatable :: seed !! Random seeds for fragmentation modeling + logical :: lmtiny_pl = .false. !! Include semi-interacting massive bodies + character(STRMAX) :: collision_model = "MERGE" !! The Coll + character(STRMAX) :: encounter_save = "NONE" !! Indicate if and how encounter data should be saved + logical :: lenc_save_trajectory = .false. !! Indicates that when encounters are saved, the full trajectory + !! through recursion steps are saved + logical :: lenc_save_closest = .false. !! Indicates that when encounters are saved, the closest approach + !! distance between pairs of bodies is saved + character(NAMELEN):: interaction_loops = "ADAPTIVE" !! Method used to compute interaction loops. + !! Options are "TRIANGULAR", "FLAT", or "ADAPTIVE" + character(NAMELEN):: encounter_check_plpl = "ADAPTIVE" !! Method used to compute pl-pl encounter checks. + !! Options are "TRIANGULAR", "SORTSWEEP", or "ADAPTIVE" + character(NAMELEN):: encounter_check_pltp = "ADAPTIVE" !! Method used to compute pl-tp encounter checks. + !! Options are "TRIANGULAR", "SORTSWEEP", or "ADAPTIVE" + logical :: lcoarray = .false. !! Use Coarrays for test particle parallelization. + + ! The following are not set by the user, but instead are determined by the input value of INTERACTION_LOOPS logical :: lflatten_interactions = .false. !! Use the flattened upper triangular matrix for pl-pl interaction loops - logical :: lencounter_sas_plpl = .false. !! Use the Sort and Sweep algorithm to prune the encounter list before checking for close encounters - logical :: lencounter_sas_pltp = .false. !! Use the Sort and Sweep algorithm to prune the encounter list before checking for close encounters + logical :: lencounter_sas_plpl = .false. !! Use the Sort and Sweep algorithm to prune the encounter list before checking + !! for close encounters + logical :: lencounter_sas_pltp = .false. !! Use the Sort and Sweep algorithm to prune the encounter list before checking + !! for close encounters ! Logical flags to turn on or off various features of the code - logical :: lrhill_present = .false. !! Hill radii are given as an input rather than calculated by the code (can be used to inflate close encounter regions manually) + logical :: lrhill_present = .false. !! Hill radii are given as an input rather than calculated by the code (can be used to + !! inflate close encounter regions manually) logical :: lextra_force = .false. !! User defined force function turned on logical :: lbig_discard = .false. !! Save big bodies on every discard logical :: lclose = .false. !! Turn on close encounters logical :: lenergy = .false. !! Track the total energy of the system - logical :: loblatecb = .false. !! Calculate acceleration from oblate central body (automatically turns true if nonzero J2 is input) + logical :: loblatecb = .false. !! Calculate acceleration from oblate central body (automatically turns true if nonzero J2 + !! is input) logical :: lrotation = .false. !! Include rotation states of big bodies logical :: ltides = .false. !! Include tidal dissipation - ! Initial values to pass to the energy report subroutine (usually only used in the case of a restart, otherwise these will be updated with initial conditions values) - real(DP) :: E_orbit_orig = 0.0_DP !! Initial orbital energy + ! Initial values to pass to the energy report subroutine (usually only used in the case of a restart, otherwise these will be + ! updated with initial conditions values) + real(DP) :: E_orbit_orig = 0.0_DP !! Initial orbital energy real(DP) :: GMtot_orig = 0.0_DP !! Initial system mass - real(DP), dimension(NDIM) :: L_total_orig = 0.0_DP !! Initial total angular momentum vector - real(DP), dimension(NDIM) :: L_orbit_orig = 0.0_DP !! Initial orbital angular momentum - real(DP), dimension(NDIM) :: L_spin_orig = 0.0_DP !! Initial spin angular momentum vector - real(DP), dimension(NDIM) :: L_escape = 0.0_DP !! Angular momentum of bodies that escaped the system (used for bookeeping) + real(DP), dimension(NDIM) :: L_total_orig = 0.0_DP !! Initial total angular momentum vector + real(DP), dimension(NDIM) :: L_orbit_orig = 0.0_DP !! Initial orbital angular momentum + real(DP), dimension(NDIM) :: L_spin_orig = 0.0_DP !! Initial spin angular momentum vector + real(DP), dimension(NDIM) :: L_escape = 0.0_DP !! Angular momentum of escaped bodies (used for bookeeping) real(DP) :: GMescape = 0.0_DP !! Mass of bodies that escaped the system (used for bookeeping) - real(DP) :: E_collisions = 0.0_DP !! Energy lost from system due to collisions - real(DP) :: E_untracked = 0.0_DP !! Energy gained from system due to escaped bodies + real(DP) :: E_collisions = 0.0_DP !! Energy lost from system due to collisions + real(DP) :: E_untracked = 0.0_DP !! Energy gained from system due to escaped bodies logical :: lfirstenergy = .true. !! This is the first time computing energe logical :: lfirstkick = .true. !! Initiate the first kick in a symplectic step logical :: lrestart = .false. !! Indicates whether or not this is a restarted run - character(len=:), allocatable :: display_style !! Style of the output display {"STANDARD", "COMPACT"}). Default is "STANDARD" - integer(I4B) :: display_unit !! File unit number for display (either to stdout or to a log file) - logical :: log_output = .false. !! Logs the output to file instead of displaying it on the terminal + character(NAMELEN) :: display_style !! Style of the output display {["STANDARD"], "COMPACT"}). + integer(I4B) :: display_unit !! File unit number for display (either to stdout or to a log file) + logical :: log_output = .false. !! Logs the output to file instead of displaying it on the terminal ! Future features not implemented or in development logical :: lgr = .false. !! Turn on GR @@ -111,6 +129,9 @@ module base procedure(abstract_io_param_reader), deferred :: reader procedure(abstract_io_param_writer), deferred :: writer procedure(abstract_io_read_in_param), deferred :: read_in +#ifdef COARRAY + procedure :: coclone => base_coclone_param +#endif end type base_parameters abstract interface @@ -126,8 +147,10 @@ subroutine abstract_io_param_reader(self, unit, iotype, v_list, iostat, iomsg) implicit none class(base_parameters), intent(inout) :: self !! Collection of parameters integer(I4B), intent(in) :: unit !! File unit number - character(len=*), intent(in) :: iotype !! Dummy argument passed to the input/output procedure contains the text from the char-literal-constant, prefixed with DT. - !! If you do not include a char-literal-constant, the iotype argument contains only DT. + character(len=*), intent(in) :: iotype !! Dummy argument passed to the input/output procedure contains the + !! text from the char-literal-constant, prefixed with DT. If you do + !! not include a char-literal-constant, the iotype argument contains + !! only DT. character(len=*), intent(in) :: v_list(:) !! The first element passes the integrator code to the reader integer(I4B), intent(out) :: iostat !! IO status code character(len=*), intent(inout) :: iomsg !! Message to pass if iostat /= 0 @@ -138,8 +161,10 @@ subroutine abstract_io_param_writer(self, unit, iotype, v_list, iostat, iomsg) implicit none class(base_parameters), intent(in) :: self !! Collection of parameters integer(I4B), intent(in) :: unit !! File unit number - character(len=*), intent(in) :: iotype !! Dummy argument passed to the input/output procedure contains the text from the char-literal-constant, prefixed with DT. - !! If you do not include a char-literal-constant, the iotype argument contains only DT. + character(len=*), intent(in) :: iotype !! Dummy argument passed to the input/output procedure contains the + !! text from the char-literal-constant, prefixed with DT. If you do + !! not include a char-literal-constant, the iotype argument contains + !! only DT. integer(I4B), intent(in) :: v_list(:) !! Not used in this procedure integer(I4B), intent(out) :: iostat !! IO status code character(len=*), intent(inout) :: iomsg !! Message to pass if iostat /= 0 @@ -157,7 +182,8 @@ end subroutine abstract_io_read_in_param type :: base_storage_frame class(*), allocatable :: item contains - procedure :: store => base_util_copy_store !! Stores a snapshot of the nbody system so that later it can be retrieved for saving to file. + procedure :: store => base_util_copy_store !! Stores a snapshot of the nbody system so that later it can be + !! retrieved for saving to file. generic :: assignment(=) => store final :: base_final_storage_frame end type @@ -168,25 +194,26 @@ end subroutine abstract_io_read_in_param integer(I4B) :: nframes !! Total number of frames that can be stored !! An class that establishes the pattern for various storage objects - type(base_storage_frame), dimension(:), allocatable :: frame !! Array of stored frames - integer(I4B) :: iframe = 0 !! Index of the last frame stored in the system - integer(I4B) :: nid !! Number of unique id values in all saved snapshots - integer(I4B), dimension(:), allocatable :: idvals !! The set of unique id values contained in the snapshots - integer(I4B), dimension(:), allocatable :: idmap !! The id value -> index map - integer(I4B) :: nt !! Number of unique time values in all saved snapshots - real(DP), dimension(:), allocatable :: tvals !! The set of unique time values contained in the snapshots - integer(I4B), dimension(:), allocatable :: tmap !! The t value -> index map + type(base_storage_frame), dimension(:), allocatable :: frame !! Array of stored frames + integer(I4B) :: iframe = 0 !! Index of the last frame stored in the system + integer(I4B) :: nid !! Number of unique id values in all saved snapshots + integer(I4B), dimension(:), allocatable :: idvals !! The set of unique id values contained in the snapshots + integer(I4B), dimension(:), allocatable :: idmap !! The id value -> index map + integer(I4B) :: nt !! Number of unique time values in all saved snapshots + real(DP), dimension(:), allocatable :: tvals !! The set of unique time values contained in the snapshots + integer(I4B), dimension(:), allocatable :: tmap !! The t value -> index map contains procedure :: dealloc => base_util_dealloc_storage !! Deallocates all allocatables - procedure :: reset => base_util_reset_storage !! Resets the storage object back to its original state by removing all of the saved items from the storage frames + procedure :: reset => base_util_reset_storage !! Resets the storage object back to its original state by removing all of + !! the saved items from the storage frames procedure :: resize => base_util_resize_storage !! Resizes storage if it is too small procedure :: setup => base_util_setup_storage !! Sets up a storage system with a set number of frames procedure :: save => base_util_snapshot_save !! Takes a snapshot of the current system end type base_storage - !> Class definition for the particle origin information object. This object is used to track time, location, and collisional regime - !> of fragments produced in collisional events. + !> Class definition for the particle origin information object. This object is used to track time, location, and collisional + !> regime of fragments produced in collisional events. type, abstract :: base_particle_info end type base_particle_info @@ -206,14 +233,6 @@ end subroutine abstract_util_dealloc_object end interface - type, abstract, extends(base_object) :: base_multibody - integer(I4B) :: nbody = 0 !! Number of bodies - integer(I4B), dimension(:), allocatable :: id !! Identifier - contains - procedure :: dealloc => base_util_dealloc_multibody - end type base_multibody - - !> Class definition for the kinship relationships used in bookkeeping multiple collisions bodies in a single time step. type, abstract :: base_kinship end type base_kinship @@ -223,36 +242,318 @@ end subroutine abstract_util_dealloc_object type, abstract :: base_nbody_system end type base_nbody_system + + interface util_append + module procedure base_util_append_arr_char_string + module procedure base_util_append_arr_DP + module procedure base_util_append_arr_DPvec + module procedure base_util_append_arr_I4B + module procedure base_util_append_arr_logical + end interface + + interface util_fill + module procedure base_util_fill_arr_char_string + module procedure base_util_fill_arr_DP + module procedure base_util_fill_arr_DPvec + module procedure base_util_fill_arr_I4B + module procedure base_util_fill_arr_logical + end interface + + interface util_resize + module procedure base_util_resize_arr_char_string + module procedure base_util_resize_arr_DP + module procedure base_util_resize_arr_DPvec + module procedure base_util_resize_arr_I4B + module procedure base_util_resize_arr_logical + end interface + + interface util_sort + module procedure base_util_sort_i4b + module procedure base_util_sort_index_i4b + module procedure base_util_sort_index_I4B_I8Bind + module procedure base_util_sort_index_I8B_I8Bind + module procedure base_util_sort_sp + module procedure base_util_sort_index_sp + module procedure base_util_sort_dp + module procedure base_util_sort_index_dp + end interface + + interface util_sort_rearrange + module procedure base_util_sort_rearrange_arr_char_string + module procedure base_util_sort_rearrange_arr_DP + module procedure base_util_sort_rearrange_arr_DPvec + module procedure base_util_sort_rearrange_arr_I4B + module procedure base_util_sort_rearrange_arr_I4B_I8Bind + module procedure base_util_sort_rearrange_arr_logical + module procedure base_util_sort_rearrange_arr_logical_I8Bind + end interface + + interface util_spill + module procedure base_util_spill_arr_char_string + module procedure base_util_spill_arr_DP + module procedure base_util_spill_arr_DPvec + module procedure base_util_spill_arr_I4B + module procedure base_util_spill_arr_I8B + module procedure base_util_spill_arr_logical + end interface + + interface util_unique + module procedure base_util_unique_DP + module procedure base_util_unique_I4B + end interface + contains - subroutine base_util_copy_store(self, source) + subroutine base_util_append_arr_char_string(arr, source, nold, lsource_mask) !! author: David A. Minton !! - !! Stores a snapshot of the nbody system so that later it can be retrieved for saving to file. + !! Append a single array of character string type onto another. If the destination array is not allocated, or is not big + !! enough, this will allocate space for it. implicit none - class(base_storage_frame), intent(inout) :: self !! Swiftest storage frame object - class(*), intent(in) :: source !! Swiftest n-body system object + ! Arguments + character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Destination array + character(len=STRMAX), dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at + !! arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to + ! Internals + integer(I4B) :: nnew, nsrc, nend_orig + + if (.not.allocated(source)) return + + if (present(lsource_mask)) then + nsrc = count(lsource_mask(:)) + else + nsrc = size(source) + end if + if (nsrc == 0) return + + if (.not.allocated(arr)) then + nend_orig = 0 + allocate(arr(nsrc)) + else + if (present(nold)) then + nend_orig = nold + else + nend_orig = size(arr) + end if + call util_resize(arr, nend_orig + nsrc) + end if + nnew = nend_orig + nsrc + + if (present(lsource_mask)) then + arr(nend_orig + 1:nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) + else + arr(nend_orig + 1:nnew) = source(1:nsrc) + end if - if (allocated(self%item)) deallocate(self%item) - allocate(self%item, source=source) - return - end subroutine base_util_copy_store + end subroutine base_util_append_arr_char_string + + + subroutine base_util_append_arr_DP(arr, source, nold, lsource_mask) + !! author: David A. Minton + !! + !! Append a single array of double precision type onto another. If the destination array is not allocated, or is not big + !! enough, this will allocate space for it. + implicit none + ! Arguments + real(DP), dimension(:), allocatable, intent(inout) :: arr !! Destination array + real(DP), dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at + !! arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to + ! Internals + integer(I4B) :: nnew, nsrc, nend_orig + + if (.not.allocated(source)) return + + if (present(lsource_mask)) then + nsrc = count(lsource_mask(:)) + else + nsrc = size(source) + end if + if (nsrc == 0) return + + if (.not.allocated(arr)) then + nend_orig = 0 + allocate(arr(nsrc)) + else + if (present(nold)) then + nend_orig = nold + else + nend_orig = size(arr) + end if + call util_resize(arr, nend_orig + nsrc) + end if + nnew = nend_orig + nsrc + + if (present(lsource_mask)) then + arr(nend_orig + 1:nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) + else + arr(nend_orig + 1:nnew) = source(1:nsrc) + end if + + return + end subroutine base_util_append_arr_DP + + + subroutine base_util_append_arr_DPvec(arr, source, nold, lsource_mask) + !! author: David A. Minton + !! + !! Append a single array of double precision vector type of size (NDIM, n) onto another. If the destination array is not + !! allocated, or is not big enough, this will allocate space for it. + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Destination array + real(DP), dimension(:,:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at + !! arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to + ! Internals + integer(I4B) :: nnew, nsrc, nend_orig + + if (.not.allocated(source)) return + + if (present(lsource_mask)) then + nsrc = count(lsource_mask(:)) + else + nsrc = size(source,dim=2) + end if + if (nsrc == 0) return + + if (.not.allocated(arr)) then + nend_orig = 0 + allocate(arr(NDIM,nsrc)) + else + if (present(nold)) then + nend_orig = nold + else + nend_orig = size(arr,dim=2) + end if + call util_resize(arr, nend_orig + nsrc) + end if + nnew = nend_orig + nsrc + + if (present(lsource_mask)) then + arr(1, nend_orig + 1:nnew) = pack(source(1,1:nsrc), lsource_mask(1:nsrc)) + arr(2, nend_orig + 1:nnew) = pack(source(2,1:nsrc), lsource_mask(1:nsrc)) + arr(3, nend_orig + 1:nnew) = pack(source(3,1:nsrc), lsource_mask(1:nsrc)) + else + arr(:,nend_orig + 1:nnew) = source(:,1:nsrc) + end if + + return + end subroutine base_util_append_arr_DPvec + + + subroutine base_util_append_arr_I4B(arr, source, nold, lsource_mask) + !! author: David A. Minton + !! + !! Append a single array of integer(I4B) onto another. If the destination array is not allocated, or is not big enough, + !! this will allocate space for it. + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array + integer(I4B), dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at + !! arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to + ! Internals + integer(I4B) :: nnew, nsrc, nend_orig + + if (.not.allocated(source)) return + + if (present(lsource_mask)) then + nsrc = count(lsource_mask(:)) + else + nsrc = size(source) + end if + if (nsrc == 0) return + + if (.not.allocated(arr)) then + nend_orig = 0 + allocate(arr(nsrc)) + else + if (present(nold)) then + nend_orig = nold + else + nend_orig = size(arr) + end if + call util_resize(arr, nend_orig + nsrc) + end if + nnew = nend_orig + nsrc + + if (present(lsource_mask)) then + arr(nend_orig + 1:nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) + else + arr(nend_orig + 1:nnew) = source(1:nsrc) + end if + + return + end subroutine base_util_append_arr_I4B - subroutine base_util_dealloc_multibody(self) + subroutine base_util_append_arr_logical(arr, source, nold, lsource_mask) !! author: David A. Minton !! - !! Finalize the multibody body object - deallocates all allocatables + !! Append a single array of logical type onto another. If the destination array is not allocated, or is not big enough, + !! this will allocate space for it. implicit none - ! Argument - class(base_multibody), intent(inout) :: self + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array + logical, dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at + !! arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to + ! Internals + integer(I4B) :: nnew, nsrc, nend_orig + + if (.not.allocated(source)) return + + if (present(lsource_mask)) then + nsrc = count(lsource_mask(:)) + else + nsrc = size(source) + end if + if (nsrc == 0) return + + if (.not.allocated(arr)) then + nend_orig = 0 + allocate(arr(nsrc)) + else + if (present(nold)) then + nend_orig = nold + else + nend_orig = size(arr) + end if + call util_resize(arr, nend_orig + nsrc) + end if + nnew = nend_orig + nsrc + + if (present(lsource_mask)) then + arr(nend_orig + 1:nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) + else + arr(nend_orig + 1:nnew) = source(:) + end if + + return + end subroutine base_util_append_arr_logical + - self%nbody = 0 - if (allocated(self%id)) deallocate(self%id) + subroutine base_util_copy_store(self, source) + !! author: David A. Minton + !! + !! Stores a snapshot of the nbody system so that later it can be retrieved for saving to file. + implicit none + class(base_storage_frame), intent(inout) :: self !! Swiftest storage frame object + class(*), intent(in) :: source !! Swiftest n-body system object + if (allocated(self%item)) deallocate(self%item) + allocate(self%item, source=source) + return - end subroutine base_util_dealloc_multibody + end subroutine base_util_copy_store subroutine base_util_dealloc_param(self) @@ -263,9 +564,6 @@ subroutine base_util_dealloc_param(self) ! Arguments class(base_parameters),intent(inout) :: self !! Collection of parameters - if (allocated(self%integrator)) deallocate(self%integrator) - if (allocated(self%param_file_name)) deallocate(self%param_file_name) - if (allocated(self%display_style)) deallocate(self%display_style) if (allocated(self%seed)) deallocate(self%seed) return @@ -302,7 +600,8 @@ subroutine base_util_exit(code) character(*), parameter :: BAR = '("------------------------------------------------")' character(*), parameter :: SUCCESS_MSG = '(/, "Normal termination of Swiftest (version ", f3.1, ")")' character(*), parameter :: FAIL_MSG = '(/, "Terminating Swiftest (version ", f3.1, ") due to error!!")' - character(*), parameter :: USAGE_MSG = '("Usage: swiftest [bs|helio|ra15|rmvs|symba|tu4|whm] [standard|compact|progress|NONE]")' + character(*), parameter :: USAGE_MSG = '("Usage: swiftest ' // & + '[{standard}|compact|progress]")' character(*), parameter :: HELP_MSG = USAGE_MSG select case(code) @@ -324,10 +623,115 @@ subroutine base_util_exit(code) end subroutine base_util_exit + subroutine base_util_fill_arr_char_string(keeps, inserts, lfill_list) + !! author: David A. Minton + !! + !! Performs a fill operation on a single array of type character strings + !! This is the inverse of a spill operation + implicit none + ! Arguments + character(len=STRMAX), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + character(len=STRMAX), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the + !! keeps + + if (.not.allocated(keeps) .or. .not.allocated(inserts)) return + + keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) + keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) + + return + end subroutine base_util_fill_arr_char_string + + + subroutine base_util_fill_arr_DP(keeps, inserts, lfill_list) + !! author: David A. Minton + !! + !! Performs a fill operation on a single array of type DP + !! This is the inverse of a spill operation + implicit none + ! Arguments + real(DP), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + real(DP), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps + + if (.not.allocated(keeps) .or. .not.allocated(inserts)) return + + keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) + keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) + + return + end subroutine base_util_fill_arr_DP + + + subroutine base_util_fill_arr_DPvec(keeps, inserts, lfill_list) + !! author: David A. Minton + !! + !! Performs a fill operation on a single array of DP vectors with shape (NDIM, n) + !! This is the inverse of a spill operation + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: keeps !! Array of values to keep + real(DP), dimension(:,:), allocatable, intent(in) :: inserts !! Array of values to insert into keep + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps + ! Internals + integer(I4B) :: i + + if (.not.allocated(keeps) .or. .not.allocated(inserts)) return + + do i = 1, NDIM + keeps(i,:) = unpack(keeps(i,:), .not.lfill_list(:), keeps(i,:)) + keeps(i,:) = unpack(inserts(i,:), lfill_list(:), keeps(i,:)) + end do + + return + end subroutine base_util_fill_arr_DPvec + + + subroutine base_util_fill_arr_I4B(keeps, inserts, lfill_list) + !! author: David A. Minton + !! + !! Performs a fill operation on a single array of type I4B + !! This is the inverse of a spill operation + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + integer(I4B), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps + + if (.not.allocated(keeps) .or. .not.allocated(inserts)) return + + keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) + keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) + + return + end subroutine base_util_fill_arr_I4B + + + subroutine base_util_fill_arr_logical(keeps, inserts, lfill_list) + !! author: David A. Minton + !! + !! Performs a fill operation on a single array of logicals + !! This is the inverse of a spill operation + implicit none + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + logical, dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps + + if (.not.allocated(keeps) .or. .not.allocated(inserts)) return + + keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) + keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) + + return + end subroutine base_util_fill_arr_logical + subroutine base_util_reset_storage(self) !! author: David A. Minton !! - !! Resets the storage object back to its original state by removing all of the saved items from the storage frames, but does not deallocate the frames + !! Resets the storage object back to its original state by removing all of the saved items from the storage frames, but + !! does not deallocate the frames implicit none ! Arguments class(base_storage), intent(inout) :: self @@ -351,6 +755,237 @@ subroutine base_util_reset_storage(self) return end subroutine base_util_reset_storage + + subroutine base_util_resize_arr_char_string(arr, nnew) + !! author: David A. Minton + !! + !! Resizes an array component of type character string. nnew = 0 will deallocate. + implicit none + ! Arguments + character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Array to resize + integer(I4B), intent(in) :: nnew !! New size + ! Internals + character(len=STRMAX), dimension(:), allocatable :: tmp !! Temp. storage array in case the input array is already allocated + integer(I4B) :: nold !! Old size + + if (nnew < 0) return + + if (nnew == 0) then + if (allocated(arr)) deallocate(arr) + return + end if + + if (allocated(arr)) then + nold = size(arr) + else + nold = 0 + end if + + if (nnew == nold) return + + allocate(tmp(nnew)) + if (nold > 0) then + if (nnew > nold) then + tmp(1:nold) = arr(1:nold) + tmp(nold+1:nnew) = "" + else + tmp(1:nnew) = arr(1:nnew) + end if + else + tmp(1:nnew) = "" + end if + call move_alloc(tmp, arr) + + return + end subroutine base_util_resize_arr_char_string + + + subroutine base_util_resize_arr_DP(arr, nnew) + !! author: David A. Minton + !! + !! Resizes an array component of double precision type. Passing nnew = 0 will deallocate. + implicit none + ! Arguments + real(DP), dimension(:), allocatable, intent(inout) :: arr !! Array to resize + integer(I4B), intent(in) :: nnew !! New size + ! Internals + real(DP), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + integer(I4B) :: nold !! Old size + real(DP), parameter :: init_val = 0.0_DP + + if (nnew < 0) return + + if (nnew == 0) then + if (allocated(arr)) deallocate(arr) + return + end if + + if (allocated(arr)) then + nold = size(arr) + else + nold = 0 + end if + + if (nnew == nold) return + + allocate(tmp(nnew)) + if (nold > 0) then + if (nnew > nold) then + tmp(1:nold) = arr(1:nold) + tmp(nold+1:nnew) = init_val + else + tmp(1:nnew) = arr(1:nnew) + end if + else + tmp(1:nnew) = init_val + end if + call move_alloc(tmp, arr) + + return + end subroutine base_util_resize_arr_DP + + + subroutine base_util_resize_arr_DPvec(arr, nnew) + !! author: David A. Minton + !! + !! Resizes an array component of double precision vectors of size (NDIM, n). Passing nnew = 0 will deallocate. + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Array to resize + integer(I4B), intent(in) :: nnew !! New size + ! Internals + real(DP), dimension(:,:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + integer(I4B) :: nold !! Old size + real(DP), dimension(NDIM), parameter :: init_val = 0.0_DP + integer(I4B) :: i + + if (nnew < 0) return + + if (nnew == 0) then + if (allocated(arr)) deallocate(arr) + return + end if + + if (allocated(arr)) then + nold = size(arr, dim=2) + else + nold = 0 + end if + + if (nnew == nold) return + + allocate(tmp(NDIM, nnew)) + if (nold > 0) then + if (nnew > nold) then + tmp(:,1:nold) = arr(:,1:nold) + do i = nold+1, nnew + tmp(:,i) = init_val(:) + end do + else + tmp(:,1:nnew) = arr(:,1:nnew) + end if + else + do i = 1, nnew + tmp(:, i) = init_val(:) + end do + end if + call move_alloc(tmp, arr) + + return + + return + end subroutine base_util_resize_arr_DPvec + + + subroutine base_util_resize_arr_I4B(arr, nnew) + !! author: David A. Minton + !! + !! Resizes an array component of integer type. Passing nnew = 0 will deallocate. + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Array to resize + integer(I4B), intent(in) :: nnew !! New size + ! Internals + integer(I4B), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + integer(I4B) :: nold !! Old size + integer(I4B), parameter :: init_val = -1 + + if (nnew < 0) return + + if (nnew == 0) then + if (allocated(arr)) deallocate(arr) + return + end if + + if (allocated(arr)) then + nold = size(arr) + else + nold = 0 + end if + + if (nnew == nold) return + + allocate(tmp(nnew)) + if (nold > 0) then + if (nnew > nold) then + tmp(1:nold) = arr(1:nold) + tmp(nold+1:nnew) = init_val + else + tmp(1:nnew) = arr(1:nnew) + end if + else + tmp(1:nnew) = init_val + end if + call move_alloc(tmp, arr) + + return + end subroutine base_util_resize_arr_I4B + + + subroutine base_util_resize_arr_logical(arr, nnew) + !! author: David A. Minton + !! + !! Resizes an array component of logical type. Passing nnew = 0 will deallocate. + implicit none + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: arr !! Array to resize + integer(I4B), intent(in) :: nnew !! New size + ! Internals + logical, dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + integer(I4B) :: nold !! Old size + logical, parameter :: init_val = .false. + + if (nnew < 0) return + + if (nnew == 0) then + if (allocated(arr)) deallocate(arr) + return + end if + + if (allocated(arr)) then + nold = size(arr) + else + nold = 0 + end if + + if (nnew == nold) return + + allocate(tmp(nnew)) + if (nold > 0) then + if (nnew > nold) then + tmp(1:nold) = arr(1:nold) + tmp(nold+1:nnew) = init_val + else + tmp(1:nnew) = arr(1:nnew) + end if + else + tmp = init_val + end if + call move_alloc(tmp, arr) + + return + end subroutine base_util_resize_arr_logical + subroutine base_util_resize_storage(self, nnew) !! author: David A. Minton @@ -402,13 +1037,15 @@ end subroutine base_util_setup_storage subroutine base_util_snapshot_save(self, snapshot) !! author: David A. Minton !! - !! Checks the current size of the storage object against the required size and extends it by a factor of 2 more than requested if it is too small. - !! Note: The reason to extend it by a factor of 2 is for performance. When there are many enounters per step, resizing every time you want to add an - !! encounter takes significant computational effort. Resizing by a factor of 2 is a tradeoff between performance (fewer resize calls) and memory managment - !! Memory usage grows by a factor of 2 each time it fills up, but no more. + !! Checks the current size of the storage object against the required size and extends it by a factor of 2 more than + !! requested if it is too small. + !! Note: The reason to extend it by a factor of 2 is for performance. When there are many enounters per step, resizing + !! every time you want to add an encounter takes significant computational effort. Resizing by a factor of 2 is a tradeoff + !! between performance (fewer resize calls) and memory managment. Memory usage grows by a factor of 2 each time it fills + !! up, but no more. implicit none ! Arguments - class(base_storage), intent(inout) :: self !! Storage ncounter storage object + class(base_storage), intent(inout) :: self !! Storage encounter storage object class(*), intent(in) :: snapshot !! Object to snapshot ! Internals integer(I4B) :: nnew, nold @@ -426,18 +1063,1115 @@ subroutine base_util_snapshot_save(self, snapshot) return end subroutine base_util_snapshot_save - - subroutine base_final_storage(self) + + subroutine base_util_spill_arr_char_string(keeps, discards, lspill_list, ldestructive) !! author: David A. Minton !! - !! Finalizer for the storage object + !! Performs a spill operation on a single array of type character strings + !! This is the inverse of a spill operation implicit none ! Arguments - class(base_storage), intent(inout) :: self + character(len=STRMAX), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + character(len=STRMAX), dimension(:), allocatable, intent(inout) :: discards !! Array of discards + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into + !! the discards + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not + !! this operation should alter the keeps + !! array or not + ! Internals + integer(I4B) :: nspill, nkeep, nlist + character(len=STRMAX), dimension(:), allocatable :: tmp !! Array of values to keep - call self%dealloc() - return + nkeep = count(.not.lspill_list(:)) + nspill = count(lspill_list(:)) + nlist = size(lspill_list(:)) + + if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return + if (.not.allocated(discards)) then + allocate(discards(nspill)) + else if (size(discards) /= nspill) then + deallocate(discards) + allocate(discards(nspill)) + end if + + discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) + if (ldestructive) then + if (nkeep > 0) then + allocate(tmp(nkeep)) + tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) + call move_alloc(tmp, keeps) + else + deallocate(keeps) + end if + end if + + return + end subroutine base_util_spill_arr_char_string + + + subroutine base_util_spill_arr_DP(keeps, discards, lspill_list, ldestructive) + !! author: David A. Minton + !! + !! Performs a spill operation on a single array of type DP + !! This is the inverse of a spill operation + implicit none + ! Arguments + real(DP), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + real(DP), dimension(:), allocatable, intent(inout) :: discards !! Array of discards + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation + !! should alter the keeps array or not + ! Internals + integer(I4B) :: nspill, nkeep, nlist + real(DP), dimension(:), allocatable :: tmp !! Array of values to keep + + nkeep = count(.not.lspill_list(:)) + nspill = count(lspill_list(:)) + nlist = size(lspill_list(:)) + + if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return + if (.not.allocated(discards)) then + allocate(discards(nspill)) + else if (size(discards) /= nspill) then + deallocate(discards) + allocate(discards(nspill)) + end if + + discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) + if (ldestructive) then + if (nkeep > 0) then + allocate(tmp(nkeep)) + tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) + call move_alloc(tmp, keeps) + else + deallocate(keeps) + end if + end if + + return + end subroutine base_util_spill_arr_DP + + + subroutine base_util_spill_arr_DPvec(keeps, discards, lspill_list, ldestructive) + !! author: David A. Minton + !! + !! Performs a spill operation on a single array of DP vectors with shape (NDIM, n) + !! This is the inverse of a spill operation + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: keeps !! Array of values to keep + real(DP), dimension(:,:), allocatable, intent(inout) :: discards !! Array discards + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this + !! operation should alter the keeps array or not + ! Internals + integer(I4B) :: i, nspill, nkeep, nlist + real(DP), dimension(:,:), allocatable :: tmp !! Array of values to keep + + nkeep = count(.not.lspill_list(:)) + nspill = count(lspill_list(:)) + nlist = size(lspill_list(:)) + + if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return + if (.not.allocated(discards)) then + allocate(discards(NDIM, nspill)) + else if (size(discards, dim=2) /= nspill) then + deallocate(discards) + allocate(discards(NDIM, nspill)) + end if + + do i = 1, NDIM + discards(i,:) = pack(keeps(i,1:nlist), lspill_list(1:nlist)) + end do + if (ldestructive) then + if (nkeep > 0) then + allocate(tmp(NDIM, nkeep)) + do i = 1, NDIM + tmp(i, :) = pack(keeps(i, 1:nlist), .not. lspill_list(1:nlist)) + end do + call move_alloc(tmp, keeps) + else + deallocate(keeps) + end if + end if + + return + end subroutine base_util_spill_arr_DPvec + + + subroutine base_util_spill_arr_I4B(keeps, discards, lspill_list, ldestructive) + !! author: David A. Minton + !! + !! Performs a spill operation on a single array of type I4B + !! This is the inverse of a spill operation + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + integer(I4B), dimension(:), allocatable, intent(inout) :: discards !! Array of discards + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards + logical, intent(in) :: ldestructive!! Logical flag indicating whether or not this + !! operation should alter the keeps array or not + ! Internals + integer(I4B) :: nspill, nkeep, nlist + integer(I4B), dimension(:), allocatable :: tmp !! Array of values to keep + + nkeep = count(.not.lspill_list(:)) + nspill = count(lspill_list(:)) + nlist = size(lspill_list(:)) + + if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return + if (.not.allocated(discards)) then + allocate(discards(nspill)) + else if (size(discards) /= nspill) then + deallocate(discards) + allocate(discards(nspill)) + end if + + discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) + if (ldestructive) then + if (nkeep > 0) then + allocate(tmp(nkeep)) + tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) + call move_alloc(tmp, keeps) + else + deallocate(keeps) + end if + end if + + return + end subroutine base_util_spill_arr_I4B + + + subroutine base_util_spill_arr_I8B(keeps, discards, lspill_list, ldestructive) + !! author: David A. Minton + !! + !! Performs a spill operation on a single array of type I4B + !! This is the inverse of a spill operation + implicit none + ! Arguments + integer(I8B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + integer(I8B), dimension(:), allocatable, intent(inout) :: discards !! Array of discards + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards + logical, intent(in) :: ldestructive!! Logical flag indicating whether or not this + !! operation should alter the keeps array or not + ! Internals + integer(I4B) :: nspill, nkeep, nlist + integer(I8B), dimension(:), allocatable :: tmp !! Array of values to keep + + nkeep = count(.not.lspill_list(:)) + nspill = count(lspill_list(:)) + nlist = size(lspill_list(:)) + + if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return + if (.not.allocated(discards)) then + allocate(discards(nspill)) + else if (size(discards) /= nspill) then + deallocate(discards) + allocate(discards(nspill)) + end if + + discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) + if (ldestructive) then + if (nkeep > 0) then + allocate(tmp(nkeep)) + tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) + call move_alloc(tmp, keeps) + else + deallocate(keeps) + end if + end if + + return + end subroutine base_util_spill_arr_I8B + + + subroutine base_util_spill_arr_logical(keeps, discards, lspill_list, ldestructive) + !! author: David A. Minton + !! + !! Performs a spill operation on a single array of logicals + !! This is the inverse of a spill operation + implicit none + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep + logical, dimension(:), allocatable, intent(inout) :: discards !! Array of discards + logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards + logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation + !! should alter the keeps array or no + ! Internals + integer(I4B) :: nspill, nkeep, nlist + logical, dimension(:), allocatable :: tmp !! Array of values to keep + + nkeep = count(.not.lspill_list(:)) + nspill = count(lspill_list(:)) + nlist = size(lspill_list(:)) + + if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return + if (.not.allocated(discards)) then + allocate(discards(nspill)) + else if (size(discards) /= nspill) then + deallocate(discards) + allocate(discards(nspill)) + end if + + discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) + if (ldestructive) then + if (nkeep > 0) then + allocate(tmp(nkeep)) + tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) + call move_alloc(tmp, keeps) + else + deallocate(keeps) + end if + end if + + return + end subroutine base_util_spill_arr_logical + + + pure subroutine base_util_sort_dp(arr) + !! author: David A. Minton + !! + !! Sort input DP precision array in place into ascending numerical order using quicksort. + !! + implicit none + ! Arguments + real(DP), dimension(:), intent(inout) :: arr + + call base_util_sort_qsort_DP(arr) + + return + end subroutine base_util_sort_dp + + + pure subroutine base_util_sort_index_dp(arr, ind) + !! author: David A. Minton + !! + !! Sort input DP precision array by index in ascending numerical order using quick sort. + !! This algorithm works well for partially sorted arrays (which is usually the case here). + !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously + !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. + !! + implicit none + ! Arguments + real(DP), dimension(:), intent(in) :: arr + integer(I4B), dimension(:), allocatable, intent(inout) :: ind + ! Internals + integer(I4B) :: n, i + real(DP), dimension(:), allocatable :: tmparr + + n = size(arr) + if (.not.allocated(ind)) then + allocate(ind(n)) + ind = [(i, i=1, n)] + end if + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) + call base_util_sort_qsort_DP(tmparr, ind) + + return + end subroutine base_util_sort_index_dp + + + recursive pure subroutine base_util_sort_qsort_DP(arr, ind) + !! author: David A. Minton + !! + !! Sort input DP precision array by index in ascending numerical order using quicksort sort. + !! + implicit none + ! Arguments + real(DP), dimension(:), intent(inout) :: arr + integer(I4B),dimension(:),intent(out), optional :: ind + !! Internals + integer :: iq + + if (size(arr) > 1) then + if (present(ind)) then + call base_util_sort_partition_DP(arr, iq, ind) + call base_util_sort_qsort_DP(arr(:iq-1),ind(:iq-1)) + call base_util_sort_qsort_DP(arr(iq:), ind(iq:)) + else + call base_util_sort_partition_DP(arr, iq) + call base_util_sort_qsort_DP(arr(:iq-1)) + call base_util_sort_qsort_DP(arr(iq:)) + end if + end if + + return + end subroutine base_util_sort_qsort_DP + + + pure subroutine base_util_sort_partition_DP(arr, marker, ind) + !! author: David A. Minton + !! + !! Partition function for quicksort on DP type + !! + implicit none + ! Arguments + real(DP), intent(inout), dimension(:) :: arr + integer(I4B), intent(inout), dimension(:), optional :: ind + integer(I4B), intent(out) :: marker + ! Internals + integer(I4B) :: i, j, itmp, narr, ipiv + real(DP) :: temp + real(DP) :: x ! pivot point + + narr = size(arr) + + ! Get center as pivot, as this is likely partially sorted + ipiv = narr / 2 + x = arr(ipiv) + i = 0 + j = narr + 1 + + do + j = j - 1 + do + if (arr(j) <= x) exit + j = j - 1 + end do + i = i + 1 + do + if (arr(i) >= x) exit + i = i + 1 + end do + if (i < j) then + ! exchange A(i) and A(j) + temp = arr(i) + arr(i) = arr(j) + arr(j) = temp + if (present(ind)) then + itmp = ind(i) + ind(i) = ind(j) + ind(j) = itmp + end if + else if (i == j) then + marker = i + 1 + return + else + marker = i + return + endif + end do + + return + end subroutine base_util_sort_partition_DP + + + pure subroutine base_util_sort_i4b(arr) + !! author: David A. Minton + !! + !! Sort input integer array in place into ascending numerical order using quick sort. + !! This algorithm works well for partially sorted arrays (which is usually the case here) + !! + implicit none + ! Arguments + integer(I4B), dimension(:), intent(inout) :: arr + + call base_util_sort_qsort_I4B(arr) + + return + end subroutine base_util_sort_i4b + + + pure subroutine base_util_sort_index_I4B(arr, ind) + !! author: David A. Minton + !! + !! Sort input integer array by index in ascending numerical order using quicksort. + !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously + !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. + !! + implicit none + ! Arguments + integer(I4B), dimension(:), intent(in) :: arr + integer(I4B), dimension(:), allocatable, intent(inout) :: ind + ! Internals + integer(I4B) :: n, i + integer(I4B), dimension(:), allocatable :: tmparr + + n = size(arr) + if (.not.allocated(ind)) then + allocate(ind(n)) + ind = [(i, i=1, n)] + end if + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) + call base_util_sort_qsort_I4B(tmparr, ind) + + return + end subroutine base_util_sort_index_I4B + + + pure subroutine base_util_sort_index_I4B_I8Bind(arr, ind) + !! author: David A. Minton + !! + !! Sort input integer array by index in ascending numerical order using quicksort. + !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously + !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. + !! + implicit none + ! Arguments + integer(I4B), dimension(:), intent(in) :: arr + integer(I8B), dimension(:), allocatable, intent(inout) :: ind + ! Internals + integer(I8B) :: n, i + integer(I4B), dimension(:), allocatable :: tmparr + + n = size(arr) + if (.not.allocated(ind)) then + allocate(ind(n)) + ind = [(i, i=1_I8B, n)] + end if + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) + call base_util_sort_qsort_I4B_I8Bind(tmparr, ind) + + return + end subroutine base_util_sort_index_I4B_I8Bind + + + pure subroutine base_util_sort_index_I8B_I8Bind(arr, ind) + !! author: David A. Minton + !! + !! Sort input integer array by index in ascending numerical order using quicksort. + !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously + !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. + !! + implicit none + ! Arguments + integer(I8B), dimension(:), intent(in) :: arr + integer(I8B), dimension(:), allocatable, intent(inout) :: ind + ! Internals + integer(I8B) :: n, i + integer(I8B), dimension(:), allocatable :: tmparr + + n = size(arr) + if (.not.allocated(ind)) then + allocate(ind(n)) + ind = [(i, i=1_I8B, n)] + end if + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) + call base_util_sort_qsort_I8B_I8Bind(tmparr, ind) + + return + end subroutine base_util_sort_index_I8B_I8Bind + + + recursive pure subroutine base_util_sort_qsort_I4B(arr, ind) + !! author: David A. Minton + !! + !! Sort input I4B array by index in ascending numerical order using quicksort. + !! + implicit none + ! Arguments + integer(I4B), dimension(:), intent(inout) :: arr + integer(I4B), dimension(:), intent(out), optional :: ind + ! Internals + integer(I4B) :: iq + + if (size(arr) > 1) then + if (present(ind)) then + call base_util_sort_partition_I4B(arr, iq, ind) + call base_util_sort_qsort_I4B(arr(:iq-1),ind(:iq-1)) + call base_util_sort_qsort_I4B(arr(iq:), ind(iq:)) + else + call base_util_sort_partition_I4B(arr, iq) + call base_util_sort_qsort_I4B(arr(:iq-1)) + call base_util_sort_qsort_I4B(arr(iq:)) + end if + end if + + return + end subroutine base_util_sort_qsort_I4B + + + recursive pure subroutine base_util_sort_qsort_I4B_I8Bind(arr, ind) + !! author: David A. Minton + !! + !! Sort input I4B array by index in ascending numerical order using quicksort. + !! + implicit none + ! Arguments + integer(I4B), dimension(:), intent(inout) :: arr + integer(I8B), dimension(:), intent(out), optional :: ind + ! Internals + integer(I8B) :: iq + + if (size(arr) > 1_I8B) then + if (present(ind)) then + call base_util_sort_partition_I4B_I8Bind(arr, iq, ind) + call base_util_sort_qsort_I4B_I8Bind(arr(:iq-1_I8B),ind(:iq-1_I8B)) + call base_util_sort_qsort_I4B_I8Bind(arr(iq:), ind(iq:)) + else + call base_util_sort_partition_I4B_I8Bind(arr, iq) + call base_util_sort_qsort_I4B_I8Bind(arr(:iq-1_I8B)) + call base_util_sort_qsort_I4B_I8Bind(arr(iq:)) + end if + end if + + return + end subroutine base_util_sort_qsort_I4B_I8Bind + + + recursive pure subroutine base_util_sort_qsort_I8B_I8Bind(arr, ind) + !! author: David A. Minton + !! + !! Sort input I8B array by index in ascending numerical order using quicksort. + !! + implicit none + ! Arguments + integer(I8B), dimension(:), intent(inout) :: arr + integer(I8B), dimension(:), intent(out), optional :: ind + ! Internals + integer(I8B) :: iq + + if (size(arr) > 1_I8B) then + if (present(ind)) then + call base_util_sort_partition_I8B_I8Bind(arr, iq, ind) + call base_util_sort_qsort_I8B_I8Bind(arr(:iq-1_I8B),ind(:iq-1_I8B)) + call base_util_sort_qsort_I8B_I8Bind(arr(iq:), ind(iq:)) + else + call base_util_sort_partition_I8B_I8Bind(arr, iq) + call base_util_sort_qsort_I8B_I8Bind(arr(:iq-1_I8B)) + call base_util_sort_qsort_I8B_I8Bind(arr(iq:)) + end if + end if + + return + end subroutine base_util_sort_qsort_I8B_I8Bind + + + pure subroutine base_util_sort_partition_I4B(arr, marker, ind) + !! author: David A. Minton + !! + !! Partition function for quicksort on I4B type + !! + implicit none + ! Arguments + integer(I4B), intent(inout), dimension(:) :: arr + integer(I4B), intent(inout), dimension(:), optional :: ind + integer(I4B), intent(out) :: marker + ! Internals + integer(I4B) :: i, j, itmp, narr, ipiv + integer(I4B) :: temp + integer(I4B) :: x ! pivot point + + narr = size(arr) + + ! Get center as pivot, as this is likely partially sorted + ipiv = narr / 2 + x = arr(ipiv) + i = 0 + j = narr + 1 + + do + j = j - 1 + do + if (arr(j) <= x) exit + j = j - 1 + end do + i = i + 1 + do + if (arr(i) >= x) exit + i = i + 1 + end do + if (i < j) then + ! exchange A(i) and A(j) + temp = arr(i) + arr(i) = arr(j) + arr(j) = temp + if (present(ind)) then + itmp = ind(i) + ind(i) = ind(j) + ind(j) = itmp + end if + else if (i == j) then + marker = i + 1 + return + else + marker = i + return + endif + end do + + return + end subroutine base_util_sort_partition_I4B + + + pure subroutine base_util_sort_partition_I4B_I8Bind(arr, marker, ind) + !! author: David A. Minton + !! + !! Partition function for quicksort on I4B type + !! + implicit none + ! Arguments + integer(I4B), intent(inout), dimension(:) :: arr + integer(I8B), intent(inout), dimension(:), optional :: ind + integer(I8B), intent(out) :: marker + ! Internals + integer(I8B) :: i, j, itmp, narr, ipiv + integer(I4B) :: temp + integer(I8B) :: x ! pivot point + + narr = size(arr) + + ! Get center as pivot, as this is likely partially sorted + ipiv = narr / 2_I8B + x = arr(ipiv) + i = 0_I8B + j = narr + 1_I8B + + do + j = j - 1_I8B + do + if (arr(j) <= x) exit + j = j - 1_I8B + end do + i = i + 1_I8B + do + if (arr(i) >= x) exit + i = i + 1_I8B + end do + if (i < j) then + ! exchange A(i) and A(j) + temp = arr(i) + arr(i) = arr(j) + arr(j) = temp + if (present(ind)) then + itmp = ind(i) + ind(i) = ind(j) + ind(j) = itmp + end if + else if (i == j) then + marker = i + 1_I8B + return + else + marker = i + return + endif + end do + + return + end subroutine base_util_sort_partition_I4B_I8Bind + + + pure subroutine base_util_sort_partition_I8B_I8Bind(arr, marker, ind) + !! author: David A. Minton + !! + !! Partition function for quicksort on I8B type with I8B index + !! + implicit none + ! Arguments + integer(I8B), intent(inout), dimension(:) :: arr + integer(I8B), intent(inout), dimension(:), optional :: ind + integer(I8B), intent(out) :: marker + ! Internals + integer(I8B) :: i, j, itmp, narr, ipiv + integer(I8B) :: temp + integer(I8B) :: x ! pivot point + + narr = size(arr) + + ! Get center as pivot, as this is likely partially sorted + ipiv = narr / 2_I8B + x = arr(ipiv) + i = 0_I8B + j = narr + 1_I8B + + do + j = j - 1_I8B + do + if (arr(j) <= x) exit + j = j - 1_I8B + end do + i = i + 1_I8B + do + if (arr(i) >= x) exit + i = i + 1_I8B + end do + if (i < j) then + ! exchange A(i) and A(j) + temp = arr(i) + arr(i) = arr(j) + arr(j) = temp + if (present(ind)) then + itmp = ind(i) + ind(i) = ind(j) + ind(j) = itmp + end if + else if (i == j) then + marker = i + 1_I8B + return + else + marker = i + return + endif + end do + + return + end subroutine base_util_sort_partition_I8B_I8Bind + + + pure subroutine base_util_sort_sp(arr) + !! author: David A. Minton + !! + !! Sort input DP precision array in place into ascending numerical order using quicksort. + !! + implicit none + ! Arguments + real(SP), dimension(:), intent(inout) :: arr + + call base_util_sort_qsort_SP(arr) + + return + end subroutine base_util_sort_sp + + + pure subroutine base_util_sort_index_sp(arr, ind) + !! author: David A. Minton + !! + !! Sort input DP precision array by index in ascending numerical order using quicksort. + !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously + !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. + !! + implicit none + ! Arguments + real(SP), dimension(:), intent(in) :: arr + integer(I4B), dimension(:), allocatable, intent(inout) :: ind + ! Internals + integer(I4B) :: n, i + real(SP), dimension(:), allocatable :: tmparr + + n = size(arr) + if (.not.allocated(ind)) then + allocate(ind(n)) + ind = [(i, i=1, n)] + end if + allocate(tmparr, mold=arr) + tmparr(:) = arr(ind(:)) + call base_util_sort_qsort_SP(tmparr, ind) + + return + end subroutine base_util_sort_index_sp + + + recursive pure subroutine base_util_sort_qsort_SP(arr, ind) + !! author: David A. Minton + !! + !! Sort input DP precision array by index in ascending numerical order using quicksort. + !! + implicit none + ! Arguments + real(SP), dimension(:), intent(inout) :: arr + integer(I4B),dimension(:),intent(out), optional :: ind + !! Internals + integer :: iq + + if (size(arr) > 1) then + if (present(ind)) then + call base_util_sort_partition_SP(arr, iq, ind) + call base_util_sort_qsort_SP(arr(:iq-1),ind(:iq-1)) + call base_util_sort_qsort_SP(arr(iq:), ind(iq:)) + else + call base_util_sort_partition_SP(arr, iq) + call base_util_sort_qsort_SP(arr(:iq-1)) + call base_util_sort_qsort_SP(arr(iq:)) + end if + end if + + return + end subroutine base_util_sort_qsort_SP + + + pure subroutine base_util_sort_partition_SP(arr, marker, ind) + !! author: David A. Minton + !! + !! Partition function for quicksort on SP type + !! + implicit none + ! Arguments + real(SP), intent(inout), dimension(:) :: arr + integer(I4B), intent(inout), dimension(:), optional :: ind + integer(I4B), intent(out) :: marker + ! Internals + integer(I4B) :: i, j, itmp, narr, ipiv + real(SP) :: temp + real(SP) :: x ! pivot point + + narr = size(arr) + + ! Get center as pivot, as this is likely partially sorted + ipiv = narr / 2 + x = arr(ipiv) + i = 0 + j = narr + 1 + + do + j = j - 1 + do + if (arr(j) <= x) exit + j = j - 1 + end do + i = i + 1 + do + if (arr(i) >= x) exit + i = i + 1 + end do + if (i < j) then + ! exchange A(i) and A(j) + temp = arr(i) + arr(i) = arr(j) + arr(j) = temp + if (present(ind)) then + itmp = ind(i) + ind(i) = ind(j) + ind(j) = itmp + end if + else if (i == j) then + marker = i + 1 + return + else + marker = i + return + endif + end do + + return + end subroutine base_util_sort_partition_SP + + + pure subroutine base_util_sort_rearrange_arr_char_string(arr, ind, n) + !! author: David A. Minton + !! + !! Rearrange a single array of character string in-place from an index list. + implicit none + ! Arguments + character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Destination array + integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against + integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange + ! Internals + character(len=STRMAX), dimension(:), allocatable :: tmp !! Temporary copy of arry used during rearrange operation + + if (.not. allocated(arr) .or. n <= 0) return + allocate(tmp, mold=arr) + tmp(1:n) = arr(ind) + call move_alloc(tmp, arr) + + return + end subroutine base_util_sort_rearrange_arr_char_string + + + pure subroutine base_util_sort_rearrange_arr_DP(arr, ind, n) + !! author: David A. Minton + !! + !! Rearrange a single array of DP type in-place from an index list. + implicit none + ! Arguments + real(DP), dimension(:), allocatable, intent(inout) :: arr !! Destination array + integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against + integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange + ! Internals + real(DP), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + + if (.not. allocated(arr) .or. n <= 0) return + allocate(tmp, mold=arr) + tmp(1:n) = arr(ind) + call move_alloc(tmp, arr) + + return + end subroutine base_util_sort_rearrange_arr_DP + + + pure subroutine base_util_sort_rearrange_arr_DPvec(arr, ind, n) + !! author: David A. Minton + !! + !! Rearrange a single array of (NDIM,n) DP-type vectors in-place from an index list. + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Destination array + integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against + integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange + ! Internals + real(DP), dimension(:,:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + + if (.not. allocated(arr) .or. n <= 0) return + allocate(tmp, mold=arr) + tmp(:,1:n) = arr(:, ind) + call move_alloc(tmp, arr) + + return + end subroutine base_util_sort_rearrange_arr_DPvec + + + pure subroutine base_util_sort_rearrange_arr_I4B(arr, ind, n) + !! author: David A. Minton + !! + !! Rearrange a single array of integers in-place from an index list. + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array + integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against + integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange + ! Internals + integer(I4B), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + + if (.not. allocated(arr) .or. n <= 0) return + allocate(tmp, mold=arr) + tmp(1:n) = arr(ind) + call move_alloc(tmp, arr) + + return + end subroutine base_util_sort_rearrange_arr_I4B + + pure subroutine base_util_sort_rearrange_arr_I4B_I8Bind(arr, ind, n) + !! author: David A. Minton + !! + !! Rearrange a single array of integers in-place from an index list. + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array + integer(I8B), dimension(:), intent(in) :: ind !! Index to rearrange against + integer(I8B), intent(in) :: n !! Number of elements in arr and ind to rearrange + ! Internals + integer(I4B), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + + if (.not. allocated(arr) .or. n <= 0_I8B) return + allocate(tmp, mold=arr) + tmp(1:n) = arr(ind) + call move_alloc(tmp, arr) + + return + end subroutine base_util_sort_rearrange_arr_I4B_I8Bind + + + pure subroutine base_util_sort_rearrange_arr_logical_I8Bind(arr, ind, n) + !! author: David A. Minton + !! + !! Rearrange a single array of logicals in-place from an index list. + implicit none + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array + integer(I8B), dimension(:), intent(in) :: ind !! Index to rearrange against + integer(I8B), intent(in) :: n !! Number of elements in arr and ind to rearrange + ! Internals + logical, dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + + if (.not. allocated(arr) .or. n <= 0) return + allocate(tmp, mold=arr) + tmp(1:n) = arr(ind) + call move_alloc(tmp, arr) + + return + end subroutine base_util_sort_rearrange_arr_logical_I8Bind + + + pure subroutine base_util_sort_rearrange_arr_logical(arr, ind, n) + !! author: David A. Minton + !! + !! Rearrange a single array of logicals in-place from an index list. + implicit none + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array + integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against + integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange + ! Internals + logical, dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + + if (.not. allocated(arr) .or. n <= 0) return + allocate(tmp, mold=arr) + tmp(1:n) = arr(ind) + call move_alloc(tmp, arr) + + return + end subroutine base_util_sort_rearrange_arr_logical + + + subroutine base_util_unique_DP(input_array, output_array, index_map) + !! author: David A. Minton + !! + !! Takes an input unsorted integer array and returns a new array of sorted, unique values (DP version) + implicit none + ! Arguments + real(DP), dimension(:), intent(in) :: input_array !! Unsorted input array + real(DP), dimension(:), allocatable, intent(out) :: output_array !! Sorted array of unique values + integer(I4B), dimension(:), allocatable, intent(out) :: index_map !! An array of the same size as input_array that such + !! that any for any index i, + !! output_array(index_map(i)) = input_array(i) + ! Internals + real(DP), dimension(:), allocatable :: unique_array + integer(I4B) :: n + real(DP) :: lo, hi + + allocate(unique_array, mold=input_array) + allocate(index_map(size(input_array))) + lo = minval(input_array) - 1 + hi = maxval(input_array) + + n = 0 + do + n = n + 1 + lo = minval(input_array(:), mask=input_array(:) > lo) + unique_array(n) = lo + where(abs(input_array(:) - lo) < epsilon(1.0_DP) * lo) index_map(:) = n + if (lo >= hi) exit + enddo + allocate(output_array(n), source=unique_array(1:n)) + + return + end subroutine base_util_unique_DP + + + subroutine base_util_unique_I4B(input_array, output_array, index_map) + !! author: David A. Minton + !! + !! Takes an input unsorted integer array and returns a new array of sorted, unique values (I4B version) + implicit none + ! Arguments + integer(I4B), dimension(:), intent(in) :: input_array !! Unsorted input array + integer(I4B), dimension(:), allocatable, intent(out) :: output_array !! Sorted array of unique values + integer(I4B), dimension(:), allocatable, intent(out) :: index_map !! An array of the same size as input_array that such + !! that any for any index i, + !! output_array(index_map(i)) = input_array(i) + ! Internals + integer(I4B), dimension(:), allocatable :: unique_array + integer(I4B) :: n, lo, hi + + allocate(unique_array, mold=input_array) + allocate(index_map, mold=input_array) + lo = minval(input_array) - 1 + hi = maxval(input_array) + + n = 0 + do + n = n + 1 + lo = minval(input_array(:), mask=input_array(:) > lo) + unique_array(n) = lo + where(input_array(:) == lo) index_map(:) = n + if (lo >= hi) exit + enddo + allocate(output_array(n), source=unique_array(1:n)) + + return + end subroutine base_util_unique_I4B + + + subroutine base_final_storage(self) + !! author: David A. Minton + !! + !! Finalizer for the storage object + implicit none + ! Arguments + class(base_storage), intent(inout) :: self + + call self%dealloc() + return end subroutine base_final_storage @@ -453,5 +2187,97 @@ subroutine base_final_storage_frame(self) return end subroutine base_final_storage_frame +#ifdef COARRAY + subroutine base_coclone_param(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 parameter to all other images in a parameter coarray + implicit none + ! Arguments + class(base_parameters),intent(inout),codimension[*] :: self !! Collection of parameters + ! Internals + + call coclone(self%integrator) + call coclone(self%param_file_name) + call coclone(self%t0) + call coclone(self%tstart) + call coclone(self%tstop) + call coclone(self%dt) + call coclone(self%iloop) + call coclone(self%nloops) + call coclone(self%incbfile) + call coclone(self%inplfile) + call coclone(self%intpfile) + call coclone(self%nc_in) + call coclone(self%in_type) + call coclone(self%in_form) + call coclone(self%istep_out) + call coclone(self%nstep_out) + call coclone(self%fstep_out) + call coclone(self%ltstretch) + call coclone(self%outfile) + call coclone(self%out_type) + call coclone(self%out_form) + call coclone(self%out_stat) + call coclone(self%dump_cadence) + call coclone(self%rmin) + call coclone(self%rmax) + call coclone(self%rmaxu) + call coclone(self%qmin) + call coclone(self%qmin_coord) + call coclone(self%qmin_alo) + call coclone(self%qmin_ahi) + call coclone(self%MU2KG) + call coclone(self%TU2S) + call coclone(self%DU2M) + call coclone(self%GU) + call coclone(self%inv_c2) + call coclone(self%GMTINY) + call coclone(self%min_GMfrag) + call coclone(self%nfrag_reduction) + call coclone(self%lmtiny_pl) + call coclone(self%collision_model) + call coclone(self%encounter_save) + call coclone(self%lenc_save_trajectory) + call coclone(self%lenc_save_closest ) + call coclone(self%interaction_loops ) + call coclone(self%encounter_check_plpl) + call coclone(self%encounter_check_pltp) + call coclone(self%lflatten_interactions) + call coclone(self%lencounter_sas_plpl) + call coclone(self%lencounter_sas_pltp ) + call coclone(self%lrhill_present) + call coclone(self%lextra_force ) + call coclone(self%lbig_discard ) + call coclone(self%lclose ) + call coclone(self%lenergy ) + call coclone(self%loblatecb ) + call coclone(self%lrotation ) + call coclone(self%ltides ) + call coclone(self%E_orbit_orig ) + call coclone(self%GMtot_orig ) + call coclonevec(self%L_total_orig) + call coclonevec(self%L_orbit_orig) + call coclonevec(self%L_spin_orig) + call coclonevec(self%L_escape) + call coclone(self%GMescape ) + call coclone(self%E_collisions ) + call coclone(self%E_untracked ) + call coclone(self%lfirstenergy) + call coclone(self%lfirstkick ) + call coclone(self%lrestart ) + call coclone(self%display_style) + call coclone(self%display_unit ) + call coclone(self%log_output ) + call coclone(self%lgr ) + call coclone(self%lyarkovsky) + call coclone(self%lyorp ) + call coclone(self%seed) + call coclone(self%lcoarray) + + return + end subroutine base_coclone_param +#endif + end module base diff --git a/src/coarray/coarray_clone.f90 b/src/coarray/coarray_clone.f90 new file mode 100644 index 000000000..893cff147 --- /dev/null +++ b/src/coarray/coarray_clone.f90 @@ -0,0 +1,507 @@ +!! Copyright 2023 - David Minton +!! This file is part of Swiftest. +!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +!! You should have received a copy of the GNU General Public License along with Swiftest. +!! If not, see: https://www.gnu.org/licenses. + +submodule (coarray) s_coarray_clone + use swiftest +contains + + module subroutine coarray_component_clone_char(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! character scalar version + implicit none + ! Arguments + character(len=*), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + character(len=STRMAX),allocatable :: tmp[:] + integer(I4B) :: img, si + + allocate(tmp[*]) + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + sync all + if (this_image() == si) then + do img = 1, num_images() + tmp[img] = var + end do + sync images(*) + else + sync images(si) + var = tmp[si] + end if + deallocate(tmp) + + return + end subroutine coarray_component_clone_char + + + module subroutine coarray_component_clone_DP(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! real(DP) scalar version + implicit none + ! Arguments + real(DP), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + real(DP),allocatable :: tmp[:] + integer(I4B) :: img, si + + allocate(tmp[*]) + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + sync all + if (this_image() == si) then + do img = 1, num_images() + tmp[img] = var + end do + sync images(*) + else + sync images(si) + var = tmp[si] + end if + + deallocate(tmp) + + return + end subroutine coarray_component_clone_DP + + + module subroutine coarray_component_clone_DP_arr1D(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! real(DP) 1D allocatable array version + implicit none + ! Arguments + real(DP), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + real(DP), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: img, si + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + + allocate(isalloc[*]) + allocate(n[*]) + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + isalloc = allocated(var) + if (isalloc) n = size(var) + sync all + if (.not. isalloc[si]) return + + allocate(tmp(n[si])[*]) + if (this_image() == si) then + do img = 1, num_images() + tmp(:)[img] = var + end do + sync images(*) + else + sync images(si) + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + deallocate(isalloc,n,tmp) + + return + end subroutine coarray_component_clone_DP_arr1D + + + module subroutine coarray_component_clone_DP_arr2D(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! real(DP) 2D allocatable array version + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + real(DP), dimension(:,:), codimension[:], allocatable :: tmp + integer(I4B) :: img, si + integer(I4B), allocatable :: n1[:], n2[:] + logical, allocatable :: isalloc[:] + + allocate(n1[*]) + allocate(n2[*]) + allocate(isalloc[*]) + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + isalloc = allocated(var) + if (isalloc) then + n1 = size(var,dim=1) + n2 = size(var,dim=2) + end if + sync all + if (.not. isalloc[si]) return + + allocate(tmp(n1[si],n2[si])[*]) + if (this_image() == si) then + do img = 1, num_images() + tmp(:,:)[img] = var(:,:) + end do + sync images(*) + else + sync images(si) + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + + deallocate(isalloc,n1,n2,tmp) + + return + end subroutine coarray_component_clone_DP_arr2D + + + module subroutine coarray_component_clone_DP_vec1D(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! real(DP) 1D (NDIM) array version + implicit none + ! Arguments + real(DP), dimension(:), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + real(DP), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: img, si + integer(I4B), allocatable :: n[:] + + allocate(n[*]) + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + allocate(tmp(NDIM)[*]) + if (this_image() == si) then + do img = 1, num_images() + tmp(:)[img] = var(:) + end do + sync images(*) + else + sync images(si) + var(:) = tmp(:)[si] + end if + + deallocate(tmp) + + return + end subroutine coarray_component_clone_DP_vec1D + + + module subroutine coarray_component_clone_DP_vec2D(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! real(DP) 1D allocatable array version + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + real(DP), dimension(:,:), codimension[:], allocatable :: tmp + integer(I4B) :: img, si + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + + allocate(isalloc[*]) + allocate(n[*]) + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + isalloc = allocated(var) + if (isalloc) n = size(var,dim=2) + sync all + if (.not. isalloc[si]) return + + allocate(tmp(NDIM,n[si])[*]) + if (this_image() == si) then + do img = 1, num_images() + tmp(:,:)[img] = var(:,:) + end do + sync images(*) + else + sync images(si) + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine coarray_component_clone_DP_vec2D + + + module subroutine coarray_component_clone_I4B(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! integer(I4B) scalar version + implicit none + ! Arguments + integer(I4B), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + integer(I4B),allocatable :: tmp[:] + integer(I4B) :: img, si + + allocate(tmp[*]) + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + if (this_image() == si) then + do img = 1, num_images() + tmp[img] = var + end do + sync images(*) + else + sync images(si) + var = tmp[si] + end if + + deallocate(tmp) + + return + end subroutine coarray_component_clone_I4B + + + module subroutine coarray_component_clone_I4B_arr1D(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! integer(I4B) 1D allocatable array version + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + integer(I4B), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: img, si + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + + allocate(isalloc[*]) + allocate(n[*]) + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + isalloc = allocated(var) + if (isalloc) n = size(var) + sync all + if (.not. isalloc[si]) return + + allocate(tmp(n[si])[*]) + if (this_image() == si) then + do img = 1, num_images() + tmp(:)[img] = var + end do + sync images(*) + else + sync images(si) + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine coarray_component_clone_I4B_arr1D + + + module subroutine coarray_component_clone_I8B(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! integer(I4B) scalar version + implicit none + ! Arguments + integer(I8B), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + integer(I8B),allocatable :: tmp[:] + integer(I4B) :: img, si + + allocate(tmp[*]) + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + if (this_image() == si) then + do img = 1, num_images() + tmp[img] = var + end do + sync images(*) + else + sync images(si) + var = tmp[si] + end if + + deallocate(tmp) + + return + end subroutine coarray_component_clone_I8B + + + module subroutine coarray_component_clone_lgt(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! logical scalar version + implicit none + ! Arguments + logical, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + logical,allocatable :: tmp[:] + integer(I4B) :: img, si + + allocate(tmp[*]) + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + if (this_image() == si) then + do img = 1, num_images() + tmp[img] = var + end do + sync images(*) + else + sync images(si) + var = tmp[si] + end if + + deallocate(tmp) + + return + end subroutine coarray_component_clone_lgt + + + module subroutine coarray_component_clone_lgt_arr1D(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! logical 1D allocatable array version + implicit none + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + logical, dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: img, si + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + + allocate(isalloc[*]) + allocate(n[*]) + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + isalloc = allocated(var) + if (isalloc) n = size(var) + sync all + if (.not. isalloc[si]) return + + allocate(tmp(n[si])[*]) + if (this_image() == si) then + do img = 1, num_images() + tmp(:)[img] = var + end do + sync images(*) + else + sync images(si) + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine coarray_component_clone_lgt_arr1D + + + module subroutine coarray_component_clone_QP(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! real(DP) scalar version + implicit none + ! Arguments + real(QP), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + real(QP),allocatable :: tmp[:] + integer(I4B) :: img, si + + allocate(tmp[*]) + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + if (this_image() == si) then + do img = 1, num_images() + tmp[img] = var + end do + sync images(*) + else + sync images(si) + var = tmp[si] + end if + + deallocate(tmp) + + return + end subroutine coarray_component_clone_QP + +end submodule s_coarray_clone \ No newline at end of file diff --git a/src/coarray/coarray_collect.f90 b/src/coarray/coarray_collect.f90 new file mode 100644 index 000000000..0c27e110d --- /dev/null +++ b/src/coarray/coarray_collect.f90 @@ -0,0 +1,333 @@ +!! Copyright 2023 - David Minton +!! This file is part of Swiftest. +!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +!! You should have received a copy of the GNU General Public License along with Swiftest. +!! If not, see: https://www.gnu.org/licenses. + +submodule (coarray) s_coarray_collect + use swiftest +contains + + module subroutine coarray_component_collect_DP_arr1D(var,dest_img) + !! author: David A. Minton + !! + !! Collects components of a coarray derived type from all images and combines them into destination image component. The default destination image is 1 + !! real(DP) 1D allocatable array version + implicit none + ! Arguments + real(DP), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + ! Internals + real(DP), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: i,img, ti, di, istart, iend, nmax + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + real(DP), dimension(:), allocatable :: vari1 + + allocate(isalloc[*]) + allocate(n[*]) + + if (present(dest_img)) then + di = dest_img + else + di = 1 + end if + + isalloc = allocated(var) + if (isalloc) then + n = size(var) + else + n = 0 + end if + + sync all + + nmax = 0 + do img = 1, num_images() + if (n[img] > nmax) nmax = n[img] + end do + + allocate(tmp(nmax)[*]) + if (isalloc) tmp(1:n) = var(1:n) + + if (this_image() == di) then + do img = 1, num_images() + if (img /= di) then + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) + n = n + n[img] + end if + end do + sync images(*) + else + sync images(di) + if (allocated(var)) deallocate(var) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine coarray_component_collect_DP_arr1D + + + module subroutine coarray_component_collect_DP_arr2D(var,dest_img) + !! author: David A. Minton + !! + !! Collects components of a coarray derived type from all images and combines them into destination image component . The default destination image is 1 + !! real(DP) 2D allocatable array version + implicit none + ! Arguments + real(DP), dimension(:,:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + ! Internals + real(DP), dimension(:,:), codimension[:], allocatable :: tmp + integer(I4B) :: i, img, ti, di, ntot, istart, iend, nmax + integer(I4B), allocatable :: n1[:], n2[:] + logical, allocatable :: isalloc[:] + real(DP), dimension(:,:), allocatable :: vari1 + + allocate(n1[*]) + allocate(n2[*]) + allocate(isalloc[*]) + + if (present(dest_img)) then + di = dest_img + else + di = 1 + end if + + isalloc = allocated(var) + if (isalloc) then + n1 = size(var,dim=1) + n2 = size(var,dim=2) + else + n1 = 0 + n2 = 0 + end if + sync all + + nmax = 0 + do img = 1, num_images() + if (n2[img] > nmax) nmax = n2[img] + end do + + allocate(tmp(NDIM,nmax)[*]) + if (isalloc) tmp(:,1:n2) = var(:,1:n2) + + if (this_image() == di) then + do img = 1, num_images() + if (img /= di) then + allocate(vari1,source=tmp(:,1:n2[img])[img]) + call util_append(var, vari1) + n2 = n2 + n2[img] + end if + end do + sync images(*) + else + sync images(di) + if (allocated(var)) deallocate(var) + end if + + deallocate(isalloc,n1,n2,tmp) + + return + end subroutine coarray_component_collect_DP_arr2D + + + module subroutine coarray_component_collect_I4B(var,dest_img) + !! author: David A. Minton + !! + !! Sums this component of a coarray derived type from all images and places the value in the destination image component. The default destination image is 1 + !! integer(I4B) version + implicit none + ! Arguments + integer(I4B), intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + ! Internals + integer(I4B), allocatable :: tmp[:] + integer(I4B) :: img, di + + if (present(dest_img)) then + di = dest_img + else + di = 1 + end if + + allocate(tmp[*], source=var) + + if (this_image() == di) then + var = 0 + do img = 1, num_images() + var = var + tmp[img] + end do + else + var = 0 + end if + + deallocate(tmp) + + return + end subroutine coarray_component_collect_I4B + + + module subroutine coarray_component_collect_I8B(var,dest_img) + !! author: David A. Minton + !! + !! Sums this component of a coarray derived type from all images and places the value in the destination image component. The default destination image is 1 + !! integer(I8B) version + implicit none + ! Arguments + integer(I8B), intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + ! Internals + integer(I8B), allocatable :: tmp[:] + integer(I4B) :: img, di + + if (present(dest_img)) then + di = dest_img + else + di = 1 + end if + + allocate(tmp[*], source=var) + + if (this_image() == di) then + var = 0 + do img = 1, num_images() + var = var + tmp[img] + end do + else + var = 0 + end if + + deallocate(tmp) + + return + end subroutine coarray_component_collect_I8B + + + module subroutine coarray_component_collect_I4B_arr1D(var,dest_img) + !! author: David A. Minton + !! + !! Collects components of a coarray derived type from all images and combines them into destination image component . The default destination image is 1 + !! integer(I4B) 1D allocatable array version + implicit none + ! Arguments + integer(I4B), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + ! Internals + integer(I4B), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: i,img, ti, di, istart, iend, nmax + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + integer(I4B), dimension(:), allocatable :: vari1 + + allocate(isalloc[*]) + allocate(n[*]) + + if (present(dest_img)) then + di = dest_img + else + di = 1 + end if + + isalloc = allocated(var) + if (isalloc) then + n = size(var) + else + n = 0 + end if + sync all + nmax = 0 + do img = 1, num_images() + if (n[img] > nmax) nmax = n[img] + end do + + allocate(tmp(nmax)[*]) + if (isalloc) tmp(1:n) = var(1:n) + + if (this_image() == di) then + do img = 1, num_images() + if (img /= di) then + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) + n = n + n[img] + end if + end do + sync images(*) + else + sync images(di) + if (allocated(var)) deallocate(var) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine coarray_component_collect_I4B_arr1D + + + module subroutine coarray_component_collect_lgt_arr1D(var,dest_img) + !! author: David A. Minton + !! + !! Collects components of a coarray derived type from all images and combines them into destination image component . The default destination image is 1 + !! logical 1D allocatable array version + implicit none + ! Arguments + logical, dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + ! Internals + logical, dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: i,img, ti, di, ntot, istart, iend, nmax + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + logical, dimension(:), allocatable :: vari1 + + allocate(isalloc[*]) + allocate(n[*]) + + if (present(dest_img)) then + di = dest_img + else + di = 1 + end if + + isalloc = allocated(var) + if (isalloc) then + n = size(var) + else + n = 0 + end if + sync all + nmax = 0 + do img = 1, num_images() + if (n[img] > nmax) nmax = n[img] + end do + + allocate(tmp(nmax)[*]) + if (isalloc) tmp(1:n) = var(1:n) + + if (this_image() == di) then + do img = 1, num_images() + if (img /= di) then + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) + n = n + n[img] + end if + end do + sync images(*) + else + sync images(di) + if (allocated(var)) deallocate(var) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine coarray_component_collect_lgt_arr1D + + + +end submodule s_coarray_collect \ No newline at end of file diff --git a/src/coarray/coarray_module.f90 b/src/coarray/coarray_module.f90 new file mode 100644 index 000000000..b034f8786 --- /dev/null +++ b/src/coarray/coarray_module.f90 @@ -0,0 +1,142 @@ +!! Copyright 2023 - David Minton +!! This file is part of Swiftest. +!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +!! You should have received a copy of the GNU General Public License along with Swiftest. +!! If not, see: https://www.gnu.org/licenses. + +module coarray + !! author: David A. Minton + !! + !! Utilities that are used for coarray test particles + !! + use globals + implicit none + public + + interface coclone + module subroutine coarray_component_clone_char(var,src_img) + implicit none + character(len=*), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_char + + module subroutine coarray_component_clone_DP(var,src_img) + implicit none + real(DP), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_DP + + module subroutine coarray_component_clone_DP_arr1D(var,src_img) + implicit none + real(DP), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_DP_arr1D + + module subroutine coarray_component_clone_DP_arr2D(var,src_img) + implicit none + real(DP), dimension(:,:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_DP_arr2D + + module subroutine coarray_component_clone_I4B(var,src_img) + implicit none + integer(I4B), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_I4B + + module subroutine coarray_component_clone_I4B_arr1D(var,src_img) + implicit none + integer(I4B), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_I4B_arr1D + + module subroutine coarray_component_clone_I8B(var,src_img) + implicit none + integer(I8B), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_I8B + + module subroutine coarray_component_clone_lgt(var,src_img) + implicit none + logical, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_lgt + + module subroutine coarray_component_clone_lgt_arr1D(var,src_img) + implicit none + logical, dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_lgt_arr1D + + module subroutine coarray_component_clone_QP(var,src_img) + implicit none + real(QP), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_QP + end interface + + + interface coclonevec + module subroutine coarray_component_clone_DP_vec1D(var,src_img) + implicit none + real(DP), dimension(:), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_DP_vec1D + + module subroutine coarray_component_clone_DP_vec2D(var,src_img) + implicit none + real(DP), dimension(:,:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine coarray_component_clone_DP_vec2D + end interface coclonevec + + + interface cocollect + module subroutine coarray_component_collect_DP_arr1D(var,dest_img) + implicit none + real(DP), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + end subroutine coarray_component_collect_DP_arr1D + + + module subroutine coarray_component_collect_DP_arr2D(var,dest_img) + implicit none + real(DP), dimension(:,:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + end subroutine coarray_component_collect_DP_arr2D + + + module subroutine coarray_component_collect_I4B(var,dest_img) + implicit none + integer(I4B), intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + end subroutine coarray_component_collect_I4B + + + module subroutine coarray_component_collect_I8B(var,dest_img) + implicit none + integer(I8B), intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + end subroutine coarray_component_collect_I8B + + + module subroutine coarray_component_collect_I4B_arr1D(var,dest_img) + implicit none + integer(I4B), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + end subroutine coarray_component_collect_I4B_arr1D + + + module subroutine coarray_component_collect_lgt_arr1D(var,dest_img) + implicit none + logical, dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + end subroutine coarray_component_collect_lgt_arr1D + end interface + + + +end module coarray \ No newline at end of file diff --git a/src/collision/collision_check.f90 b/src/collision/collision_check.f90 index 936963caa..ebb4a3671 100644 --- a/src/collision/collision_check.f90 +++ b/src/collision/collision_check.f90 @@ -77,7 +77,8 @@ module subroutine collision_check_plpl(self, nbody_system, param, t, dt, irec, l ! Internals logical, dimension(:), allocatable :: lcollision, lmask real(DP), dimension(NDIM) :: xr, vr - integer(I4B) :: i, j, k, nenc + integer(I4B) :: i, j + integer(I8B) :: k, nenc real(DP) :: rlim, Gmtot logical :: lany_closest @@ -101,7 +102,11 @@ module subroutine collision_check_plpl(self, nbody_system, param, t, dt, irec, l lcollision(:) = .false. self%lclosest(:) = .false. - do concurrent(k = 1:nenc, lmask(k)) +#ifdef DOCONLOC + do concurrent(k = 1_I8B:nenc, lmask(k)) shared(self,pl,lmask, dt, lcollision) local(i,j,xr,vr,rlim,Gmtot) +#else + do concurrent(k = 1_I8B:nenc, lmask(k)) +#endif i = self%index1(k) j = self%index2(k) xr(:) = pl%rh(:, i) - pl%rh(:, j) @@ -116,7 +121,7 @@ module subroutine collision_check_plpl(self, nbody_system, param, t, dt, irec, l if (lany_collision .or. lany_closest) then call pl%rh2rb(nbody_system%cb) ! Update the central body barycenteric position vector to get us out of DH and into bary - do k = 1, nenc + do k = 1_I8B, nenc if (.not.lcollision(k) .and. .not. self%lclosest(k)) cycle i = self%index1(k) j = self%index2(k) @@ -174,7 +179,8 @@ module subroutine collision_check_pltp(self, nbody_system, param, t, dt, irec, l ! Internals logical, dimension(:), allocatable :: lcollision, lmask real(DP), dimension(NDIM) :: xr, vr - integer(I4B) :: i, j, k, nenc + integer(I4B) :: i, j + integer(I8B) :: k, nenc logical :: lany_closest character(len=STRMAX) :: timestr, idstri, idstrj, message class(collision_list_pltp), allocatable :: tmp @@ -190,13 +196,13 @@ module subroutine collision_check_pltp(self, nbody_system, param, t, dt, irec, l nenc = self%nenc allocate(lmask(nenc)) - lmask(:) = (self%status(1:nenc) == ACTIVE) + lmask(:) = (self%status(1:nenc) == ACTIVE) select type(pl) class is (symba_pl) - select type(tp) - class is (symba_tp) - lmask(:) = lmask(:) .and. (tp%levelg(self%index2(1:nenc)) >= irec) - end select + select type(tp) + class is (symba_tp) + lmask(:) = lmask(:) .and. (tp%levelg(self%index2(1:nenc)) >= irec) + end select end select if (.not.any(lmask(:))) return @@ -204,8 +210,11 @@ module subroutine collision_check_pltp(self, nbody_system, param, t, dt, irec, l lcollision(:) = .false. self%lclosest(:) = .false. - - do concurrent(k = 1:nenc, lmask(k)) +#ifdef DOCONLOC + do concurrent(k = 1_I8B:nenc, lmask(k)) shared(self,pl,tp,lmask, dt, lcollision) local(i,j,xr,vr) +#else + do concurrent(k = 1_I8B:nenc, lmask(k)) +#endif i = self%index1(k) j = self%index2(k) xr(:) = pl%rh(:, i) - tp%rh(:, j) diff --git a/src/collision/collision_generate.f90 b/src/collision/collision_generate.f90 index f0fc6d9e7..7f529ba02 100644 --- a/src/collision/collision_generate.f90 +++ b/src/collision/collision_generate.f90 @@ -46,7 +46,6 @@ module subroutine collision_generate_bounce(self, nbody_system, param, t) real(DP), intent(in) :: t !! The time of the collision ! Internals integer(I4B) :: i,j,nimp - real(DP), dimension(NDIM) :: rcom, vcom, rnorm logical, dimension(:), allocatable :: lmask select type(nbody_system) @@ -171,7 +170,8 @@ module subroutine collision_generate_merge(self, nbody_system, param, t) class(base_parameters), intent(inout) :: param !! Current run configuration parameters real(DP), intent(in) :: t !! The time of the collision ! Internals - integer(I4B) :: i, j, k, ibiggest + integer(I4B) :: i, j, ibiggest + integer(I8B) :: k real(DP), dimension(NDIM) :: L_spin_new, L_residual real(DP) :: volume character(len=STRMAX) :: message @@ -232,7 +232,7 @@ module subroutine collision_generate_merge(self, nbody_system, param, t) call collision_util_velocity_torque(-L_residual(:), fragments%mass(1), fragments%rb(:,1), fragments%vb(:,1)) ! Update any encounter lists that have the removed bodies in them so that they instead point to the new body - do k = 1, nbody_system%plpl_encounter%nenc + do k = 1_I8B, nbody_system%plpl_encounter%nenc do j = 1, impactors%ncoll i = impactors%id(j) if (i == ibiggest) cycle diff --git a/src/collision/collision_io.f90 b/src/collision/collision_io.f90 index d0e8f30ae..cb4a544a0 100644 --- a/src/collision/collision_io.f90 +++ b/src/collision/collision_io.f90 @@ -365,7 +365,7 @@ module subroutine collision_io_netcdf_write_frame_snapshot(self, history, param) class(encounter_storage), intent(inout) :: history !! Collision history object class(base_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i, idslot, old_mode, npl, stage + integer(I4B) :: i, idslot, old_mode, npl, stage, tmp character(len=NAMELEN) :: charstring class(swiftest_pl), allocatable :: pl @@ -427,7 +427,7 @@ module subroutine collision_io_netcdf_write_frame_snapshot(self, history, param) call netcdf_io_check( nf90_put_var(nc%id, nc%L_spin_varid, collider%L_spin(:,:), start=[1, 1, eslot], count=[NDIM, 2, 1]), "collision_io_netcdf_write_frame_snapshot nf90_put_var L_spin_varid before" ) end if - call netcdf_io_check( nf90_set_fill(nc%id, old_mode, old_mode) ) + call netcdf_io_check( nf90_set_fill(nc%id, old_mode, tmp) ) end associate end select return diff --git a/src/collision/collision_module.f90 b/src/collision/collision_module.f90 index 042c67af7..a06d6d2c1 100644 --- a/src/collision/collision_module.f90 +++ b/src/collision/collision_module.f90 @@ -19,7 +19,11 @@ module collision public character(len=*), parameter :: COLLISION_OUTFILE = 'collisions.nc' !! Name of NetCDF output file for collision information +#ifdef COARRAY + character(len=STRMAX) :: COLLISION_LOG_OUT !! Name of log file for collision diagnostic information (each co-image gets its own) +#else character(len=*), parameter :: COLLISION_LOG_OUT = "collisions.log" !! Name of log file for collision diagnostic information +#endif !>Symbolic names for collisional outcomes from collresolve_resolve: integer(I4B), parameter :: COLLRESOLVE_REGIME_MERGE = 1 @@ -97,8 +101,10 @@ module collision !> Class definition for the variables that describe a collection of fragments in barycentric coordinates - type, extends(base_multibody) :: collision_fragments + type, extends(base_object) :: collision_fragments + integer(I4B) :: nbody = 0 !! Number of bodies real(DP) :: mtot !! Total mass of fragments + integer(I4B), dimension(:), allocatable :: id !! Identifier class(base_particle_info), dimension(:), allocatable :: info !! Particle metadata information integer(I4B), dimension(:), allocatable :: status !! An integrator-specific status indicator real(DP), dimension(:,:), allocatable :: rh !! Heliocentric position @@ -120,7 +126,7 @@ module collision real(DP), dimension(:), allocatable :: rmag !! Array of radial distance magnitudes of individual fragments in the collisional coordinate frame real(DP), dimension(:), allocatable :: vmag !! Array of radial distance magnitudes of individual fragments in the collisional coordinate frame real(DP), dimension(:), allocatable :: rotmag !! Array of rotation magnitudes of individual fragments - integer(I1B), dimension(:), allocatable :: origin_body !! Array of indices indicating which impactor body (1 or 2) the fragment originates from + integer(I4B), dimension(:), allocatable :: origin_body !! Array of indices indicating which impactor body (1 or 2) the fragment originates from real(DP), dimension(NDIM) :: L_orbit_tot !! Orbital angular momentum vector of all fragments real(DP), dimension(NDIM) :: L_spin_tot !! Spin angular momentum vector of all fragments real(DP), dimension(:,:), allocatable :: L_orbit !! Orbital angular momentum vector of each individual fragment diff --git a/src/collision/collision_regime.f90 b/src/collision/collision_regime.f90 index be9ec288f..0c81eca14 100644 --- a/src/collision/collision_regime.f90 +++ b/src/collision/collision_regime.f90 @@ -111,7 +111,11 @@ subroutine collision_regime_LS12(collider, nbody_system, param) if (impactors%regime == COLLRESOLVE_REGIME_MERGE) then volume = 4._DP / 3._DP * PI * sum(impactors%radius(:)**3) radius = (3._DP * volume / (4._DP * PI))**(THIRD) +#ifdef DOCONLOC + do concurrent(i = 1:NDIM) shared(impactors,Ip,L_spin) +#else do concurrent(i = 1:NDIM) +#endif Ip(i) = sum(impactors%mass(:) * impactors%Ip(i,:)) L_spin(i) = sum(impactors%L_orbit(i,:) + impactors%L_spin(i,:)) end do @@ -281,19 +285,12 @@ subroutine collision_regime_LS12_SI(Mcb, m1, m2, rad1, rad2, rh1, rh2, vb1, vb2, Mlr = max((1.0_DP - Qr / Qrd_pstar / 2.0_DP) * Mtot, min_mfrag) ! [kg] # LS12 eq (5) end if Mbig = max(m1,Mlr) - Msmall = Mtot - Mbig - if (Msmall < min_mfrag) then - regime = COLLRESOLVE_REGIME_MERGE - Mbig = Mtot - Mslr = 0.0_DP - Mslr_hitandrun = 0.0_DP + Msmall = mtot - Mbig + Mslr_hitandrun = max(calc_Qrd_rev(Msmall, Mbig, Mint, den1, den2, Vimp, c_star), min_mfrag) + if (regime == COLLRESOLVE_REGIME_HIT_AND_RUN ) then + Mslr = Mslr_hitandrun else - Mslr_hitandrun = max(calc_Qrd_rev(Msmall, Mbig, Mint, den1, den2, Vimp, c_star), min_mfrag) - if (regime == COLLRESOLVE_REGIME_HIT_AND_RUN ) then - Mslr = Mslr_hitandrun - else - Mslr = max(Mtot * (3.0_DP - BETA) * (1.0_DP - N1 * Mlr / Mtot) / (N2 * BETA), min_mfrag) !LS12 eq (37) - end if + Mslr = max(Mtot * (3.0_DP - BETA) * (1.0_DP - N1 * Mlr / Mtot) / (N2 * BETA), min_mfrag) !LS12 eq (37) end if Mresidual = Mtot - Mlr - Mslr diff --git a/src/collision/collision_resolve.f90 b/src/collision/collision_resolve.f90 index dadde1dfd..0166711ab 100644 --- a/src/collision/collision_resolve.f90 +++ b/src/collision/collision_resolve.f90 @@ -191,8 +191,9 @@ module subroutine collision_resolve_extract_plpl(self, nbody_system, param) logical, dimension(:), allocatable :: lplpl_collision logical, dimension(:), allocatable :: lplpl_unique_parent integer(I4B), dimension(:), pointer :: plparent - integer(I4B), dimension(:), allocatable :: collision_idx, unique_parent_idx - integer(I4B) :: i, index_coll, ncollisions, nunique_parent, nplplenc + integer(I4B) :: nunique_parent + integer(I8B) :: ncollisions, index_coll, k, nplplenc + integer(I8B), dimension(:), allocatable :: unique_parent_idx, collision_idx select type(nbody_system) class is (swiftest_nbody_system) @@ -201,14 +202,14 @@ module subroutine collision_resolve_extract_plpl(self, nbody_system, param) associate(idx1 => self%index1, idx2 => self%index2, plparent => pl%kin%parent) nplplenc = self%nenc allocate(lplpl_collision(nplplenc)) - lplpl_collision(:) = self%status(1:nplplenc) == COLLIDED + lplpl_collision(:) = self%status(1_I8B:nplplenc) == COLLIDED if (.not.any(lplpl_collision)) return ! Collisions have been detected in this step. So we need to determine which of them are between unique bodies. ! Get the subset of pl-pl encounters that lead to a collision ncollisions = count(lplpl_collision(:)) allocate(collision_idx(ncollisions)) - collision_idx = pack([(i, i=1, nplplenc)], lplpl_collision) + collision_idx = pack([(k, k=1_I8B, nplplenc)], lplpl_collision) ! Get the subset of collisions that involve a unique pair of parents allocate(lplpl_unique_parent(ncollisions)) @@ -223,7 +224,7 @@ module subroutine collision_resolve_extract_plpl(self, nbody_system, param) ! due to restructuring of parent/child relationships when there are large numbers of multi-body collisions in a single ! step lplpl_unique_parent(:) = .true. - do index_coll = 1, ncollisions + do index_coll = 1_I8B, ncollisions associate(ip1 => plparent(idx1(collision_idx(index_coll))), ip2 => plparent(idx2(collision_idx(index_coll)))) lplpl_unique_parent(:) = .not. ( any(plparent(idx1(unique_parent_idx(:))) == ip1) .or. & any(plparent(idx2(unique_parent_idx(:))) == ip1) .or. & @@ -350,7 +351,7 @@ module subroutine collision_resolve_mergeaddsub(nbody_system, param, t, status) class is (swiftest_nbody_system) select type(param) class is (swiftest_parameters) - associate(pl => nbody_system%pl, pl_discards => nbody_system%pl_discards, info => nbody_system%pl%info, pl_adds => nbody_system%pl_adds, cb => nbody_system%cb, npl => nbody_system%pl%nbody, & + associate(pl => nbody_system%pl, pl_discards => nbody_system%pl_discards, info => nbody_system%pl%info, pl_adds => nbody_system%pl_adds, cb => nbody_system%cb, & collider => nbody_system%collider, impactors => nbody_system%collider%impactors,fragments => nbody_system%collider%fragments) ! Add the impactors%id bodies to the subtraction list @@ -387,7 +388,11 @@ module subroutine collision_resolve_mergeaddsub(nbody_system, param, t, status) ! plnew%tlag = pl%tlag(ibiggest) ! end if +#ifdef DOCONLOC + do concurrent(i = 1:nfrag) shared(plnew,fragments) local(volume) +#else do concurrent(i = 1:nfrag) +#endif volume = 4.0_DP/3.0_DP * PI * plnew%radius(i)**3 plnew%density(i) = fragments%mass(i) / volume end do @@ -533,7 +538,8 @@ module subroutine collision_resolve_plpl(self, nbody_system, param, t, dt, irec) character(len=STRMAX) :: timestr, idstr integer(I4B), dimension(2) :: idx_parent !! Index of the two bodies considered the "parents" of the collision logical :: lgoodcollision - integer(I4B) :: i, j, nnew, loop, ncollisions + integer(I4B) :: i, j, nnew, loop + integer(I8B) :: k, ncollisions integer(I4B), dimension(:), allocatable :: idnew integer(I4B), parameter :: MAXCASCADE = 1000 @@ -572,9 +578,9 @@ module subroutine collision_resolve_plpl(self, nbody_system, param, t, dt, irec) call swiftest_io_log_one_message(COLLISION_LOG_OUT, "***********************************************************" // & "***********************************************************") - do i = 1, ncollisions - idx_parent(1) = pl%kin(idx1(i))%parent - idx_parent(2) = pl%kin(idx2(i))%parent + do k = 1_I8B, ncollisions + idx_parent(1) = pl%kin(idx1(k))%parent + idx_parent(2) = pl%kin(idx2(k))%parent call impactors%consolidate(nbody_system, param, idx_parent, lgoodcollision) if ((.not. lgoodcollision) .or. any(pl%status(idx_parent(:)) /= COLLIDED)) cycle @@ -595,7 +601,7 @@ module subroutine collision_resolve_plpl(self, nbody_system, param, t, dt, irec) call collision_history%take_snapshot(param,nbody_system, t, "after") - plpl_collision%status(i) = collider%status + plpl_collision%status(k) = collider%status call impactors%dealloc() end do diff --git a/src/collision/collision_util.f90 b/src/collision/collision_util.f90 index 19a688c8a..75c836b4c 100644 --- a/src/collision/collision_util.f90 +++ b/src/collision/collision_util.f90 @@ -21,21 +21,26 @@ module subroutine collision_util_add_fragments_to_collider(self, nbody_system, p class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object class(base_parameters), intent(in) :: param !! Current Swiftest run configuration parameters ! Internals - integer(I4B) :: i, npl_before, npl_after + integer(I4B) :: i, npl_before, npl_after, nfrag logical, dimension(:), allocatable :: lexclude select type(nbody_system) class is (swiftest_nbody_system) - associate(fragments => self%fragments, impactors => self%impactors, nfrag => self%fragments%nbody, pl => nbody_system%pl, cb => nbody_system%cb) + associate(fragments => self%fragments, impactors => self%impactors, pl => nbody_system%pl, cb => nbody_system%cb) npl_after = pl%nbody npl_before = npl_after - nfrag + nfrag = self%fragments%nbody allocate(lexclude(npl_after)) pl%status(npl_before+1:npl_after) = ACTIVE pl%mass(npl_before+1:npl_after) = fragments%mass(1:nfrag) pl%Gmass(npl_before+1:npl_after) = fragments%mass(1:nfrag) * param%GU pl%radius(npl_before+1:npl_after) = fragments%radius(1:nfrag) +#ifdef DOCONLOC + do concurrent (i = 1:nfrag) shared(cb,pl,fragments) +#else do concurrent (i = 1:nfrag) +#endif pl%rb(:,npl_before+i) = fragments%rb(:,i) pl%vb(:,npl_before+i) = fragments%vb(:,i) pl%rh(:,npl_before+i) = fragments%rb(:,i) - cb%rb(:) @@ -141,15 +146,17 @@ end subroutine collision_util_get_idvalues_snapshot module subroutine collision_util_get_energy_and_momentum(self, nbody_system, param, phase) !! Author: David A. Minton !! - !! Calculates total system energy in either the pre-collision outcome state (phase = "before") or the post-collision outcome state (lbefore = .false.) + !! Calculates total system energy in either the pre-collision outcome state (phase = "before") or the post-collision outcome + !! state (lbefore = .false.) implicit none ! Arguments class(collision_basic), intent(inout) :: self !! Encounter collision system object class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object class(base_parameters), intent(inout) :: param !! Current Swiftest run configuration parameters - character(len=*), intent(in) :: phase !! One of "before" or "after", indicating which phase of the calculation this needs to be done + character(len=*), intent(in) :: phase !! One of "before" or "after", indicating which phase of the + !! calculation this needs to be done ! Internals - integer(I4B) :: i, phase_val + integer(I4B) :: i, phase_val, nfrag select case(phase) case("before") @@ -165,13 +172,24 @@ module subroutine collision_util_get_energy_and_momentum(self, nbody_system, par class is (swiftest_nbody_system) select type(param) class is (swiftest_parameters) - associate(fragments => self%fragments, impactors => self%impactors, nfrag => self%fragments%nbody, pl => nbody_system%pl, cb => nbody_system%cb) + associate(fragments => self%fragments, impactors => self%impactors, pl => nbody_system%pl, cb => nbody_system%cb) + nfrag = self%fragments%nbody if (phase_val == 1) then +#ifdef DOCONLOC + do concurrent(i = 1:2) shared(impactors) +#else do concurrent(i = 1:2) +#endif impactors%ke_orbit(i) = 0.5_DP * impactors%mass(i) * dot_product(impactors%vc(:,i), impactors%vc(:,i)) - impactors%ke_spin(i) = 0.5_DP * impactors%mass(i) * impactors%radius(i)**2 * impactors%Ip(3,i) * dot_product(impactors%rot(:,i), impactors%rot(:,i)) + impactors%ke_spin(i) = 0.5_DP * impactors%mass(i) * impactors%radius(i)**2 * impactors%Ip(3,i) & + * dot_product(impactors%rot(:,i), impactors%rot(:,i)) impactors%be(i) = -3 * impactors%Gmass(i) * impactors%mass(i) / (5 * impactors%radius(i)) - impactors%L_orbit(:,i) = impactors%mass(i) * impactors%rc(:,i) .cross. impactors%vc(:,i) + impactors%L_orbit(1,i) = impactors%mass(i) * (impactors%rc(2,i) * impactors%vc(3,i) & + - impactors%rc(3,i) * impactors%vc(2,i)) + impactors%L_orbit(2,i) = impactors%mass(i) * (impactors%rc(3,i) * impactors%vc(1,i) & + - impactors%rc(1,i) * impactors%vc(3,i)) + impactors%L_orbit(3,i) = impactors%mass(i) * (impactors%rc(1,i) * impactors%vc(2,i) & + - impactors%rc(2,i) * impactors%vc(1,i)) impactors%L_spin(:,i) = impactors%mass(i) * impactors%radius(i)**2 * impactors%Ip(3,i) * impactors%rot(:,i) end do self%L_orbit(:,phase_val) = sum(impactors%L_orbit(:,1:2),dim=2) @@ -180,16 +198,28 @@ module subroutine collision_util_get_energy_and_momentum(self, nbody_system, par self%ke_orbit(phase_val) = sum(impactors%ke_orbit(1:2)) self%ke_spin(phase_val) = sum(impactors%ke_spin(1:2)) self%be(phase_val) = sum(impactors%be(1:2)) - call swiftest_util_get_potential_energy(2, [(.true., i = 1, 2)], 0.0_DP, impactors%Gmass, impactors%mass, impactors%rb, self%pe(phase_val)) + call swiftest_util_get_potential_energy(2, [(.true., i = 1, 2)], 0.0_DP, impactors%Gmass, impactors%mass, & + impactors%rb, self%pe(phase_val)) self%te(phase_val) = self%ke_orbit(phase_val) + self%ke_spin(phase_val) + self%be(phase_val) + self%pe(phase_val) else if (phase_val == 2) then +#ifdef DOCONLOC + do concurrent(i = 1:nfrag) shared(fragments) +#else do concurrent(i = 1:nfrag) +#endif fragments%ke_orbit(i) = 0.5_DP * fragments%mass(i) * dot_product(fragments%vc(:,i), fragments%vc(:,i)) - fragments%ke_spin(i) = 0.5_DP * fragments%mass(i) * fragments%radius(i)**2 * fragments%Ip(3,i) * dot_product(fragments%rot(:,i), fragments%rot(:,i)) - fragments%L_orbit(:,i) = fragments%mass(i) * fragments%rc(:,i) .cross. fragments%vc(:,i) + fragments%ke_spin(i) = 0.5_DP * fragments%mass(i) * fragments%radius(i)**2 * fragments%Ip(3,i) & + * dot_product(fragments%rot(:,i), fragments%rot(:,i)) + fragments%L_orbit(1,i) = fragments%mass(i) * (fragments%rc(2,i) * fragments%vc(3,i) - & + fragments%rc(3,i) * fragments%vc(2,i)) + fragments%L_orbit(2,i) = fragments%mass(i) * (fragments%rc(3,i) * fragments%vc(1,i) - & + fragments%rc(1,i) * fragments%vc(3,i)) + fragments%L_orbit(3,i) = fragments%mass(i) * (fragments%rc(1,i) * fragments%vc(2,i) - & + fragments%rc(2,i) * fragments%vc(1,i)) fragments%L_spin(:,i) = fragments%mass(i) * fragments%radius(i)**2 * fragments%Ip(3,i) * fragments%rot(:,i) end do - call swiftest_util_get_potential_energy(nfrag, [(.true., i = 1, nfrag)], 0.0_DP, fragments%Gmass, fragments%mass, fragments%rb, fragments%pe) + call swiftest_util_get_potential_energy(nfrag, [(.true., i = 1, nfrag)], 0.0_DP, fragments%Gmass, fragments%mass, & + fragments%rb, fragments%pe) fragments%be = sum(-3*fragments%Gmass(1:nfrag)*fragments%mass(1:nfrag)/(5*fragments%radius(1:nfrag))) fragments%L_orbit_tot(:) = sum(fragments%L_orbit(:,1:nfrag),dim=2) fragments%L_spin_tot(:) = sum(fragments%L_spin(:,1:nfrag),dim=2) @@ -227,7 +257,7 @@ module subroutine collision_util_index_map(self) call self%get_index_values(idvals, tvals) ! Consolidate ids to only unique values - call swiftest_util_unique(idvals,self%idvals,self%idmap) + call util_unique(idvals,self%idvals,self%idmap) self%nid = size(self%idvals) ! Don't consolidate time values (multiple collisions can happen in a single time step) @@ -299,6 +329,8 @@ module subroutine collision_util_dealloc_fragments(self) ! Arguments class(collision_fragments), intent(inout) :: self + self%nbody = 0 + if (allocated(self%id)) deallocate(self%id) if (allocated(self%info)) deallocate(self%info) if (allocated(self%status)) deallocate(self%status) if (allocated(self%rh)) deallocate(self%rh) @@ -525,14 +557,16 @@ end subroutine collision_util_setup_fragments module subroutine collision_util_set_coordinate_collider(self) - + !! author: David A. Minton + !! !! - !! Defines the collisional coordinate nbody_system, including the unit vectors of both the nbody_system and individual fragments. + !! Defines the collisional coordinate nbody_system, including the unit vectors of both the nbody_system and individual + !! fragments. implicit none ! Arguments class(collision_basic), intent(inout) :: self !! Collisional nbody_system - associate(fragments => self%fragments, impactors => self%impactors, nfrag => self%fragments%nbody) + associate(fragments => self%fragments, impactors => self%impactors) call impactors%set_coordinate_system() if (.not.allocated(self%fragments)) return @@ -548,7 +582,8 @@ end subroutine collision_util_set_coordinate_collider module subroutine collision_util_set_coordinate_fragments(self) !! author: David A. Minton !! - !! Defines the collisional coordinate nbody_system, including the unit vectors of both the nbody_system and individual fragments. + !! Defines the collisional coordinate nbody_system, including the unit vectors of both the nbody_system and individual + !! fragments. implicit none ! Arguments class(collision_fragments), intent(inout) :: self !! Collisional nbody_system @@ -574,7 +609,8 @@ end subroutine collision_util_set_coordinate_fragments module subroutine collision_util_set_coordinate_impactors(self) !! author: David A. Minton !! - !! Defines the collisional coordinate nbody_system, including the unit vectors of both the nbody_system and individual fragments. + !! Defines the collisional coordinate nbody_system, including the unit vectors of both the nbody_system and individual + !! fragments. implicit none ! Arguments class(collision_impactors), intent(inout) :: self !! Collisional nbody_system @@ -586,8 +622,8 @@ module subroutine collision_util_set_coordinate_impactors(self) delta_v(:) = impactors%vb(:, 2) - impactors%vb(:, 1) delta_r(:) = impactors%rb(:, 2) - impactors%rb(:, 1) - ! We will initialize fragments on a plane defined by the pre-impact nbody_system, with the z-axis aligned with the angular momentum vector - ! and the y-axis aligned with the pre-impact distance vector. + ! We will initialize fragments on a plane defined by the pre-impact nbody_system, with the z-axis aligned with the angular + ! momentum vector and the y-axis aligned with the pre-impact distance vector. ! y-axis is the separation distance impactors%y_unit(:) = .unit.delta_r(:) @@ -616,14 +652,16 @@ module subroutine collision_util_set_coordinate_impactors(self) impactors%vc(:,1) = impactors%vb(:,1) - impactors%vbcom(:) impactors%vc(:,2) = impactors%vb(:,2) - impactors%vbcom(:) - ! Find the point of impact between the two bodies, defined as the location (in the collisional coordinate system) at the surface of body 1 along the line connecting the two bodies. + ! Find the point of impact between the two bodies, defined as the location (in the collisional coordinate system) at the + ! surface of body 1 along the line connecting the two bodies. impactors%rcimp(:) = impactors%rb(:,1) + impactors%radius(1) * impactors%y_unit(:) - impactors%rbcom(:) ! Set the velocity direction as the "bounce" direction" for disruptions, and body 2's direction for hit and runs if (impactors%regime == COLLRESOLVE_REGIME_HIT_AND_RUN) then impactors%bounce_unit(:) = .unit. impactors%vc(:,2) else - impactors%bounce_unit(:) = .unit. (impactors%vc(:,2) - 2 * dot_product(impactors%vc(:,2),impactors%y_unit(:)) * impactors%y_unit(:)) + impactors%bounce_unit(:) = .unit. (impactors%vc(:,2) - 2 * dot_product(impactors%vc(:,2),impactors%y_unit(:)) & + * impactors%y_unit(:)) end if end associate @@ -726,7 +764,8 @@ module subroutine collision_util_snapshot(self, param, nbody_system, t, arg) class(base_parameters), intent(inout) :: param !! Current run configuration parameters class(base_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object to store real(DP), intent(in), optional :: t !! Time of snapshot if different from nbody_system time - character(*), intent(in), optional :: arg !! "before": takes a snapshot just before the collision. "after" takes the snapshot just after the collision. + character(*), intent(in), optional :: arg !! "before": takes a snapshot just before the collision. "after" + !! takes the snapshot just after the collision. ! Arguments class(collision_snapshot), allocatable, save :: snapshot character(len=:), allocatable :: stage @@ -800,8 +839,9 @@ module subroutine collision_util_snapshot(self, param, nbody_system, t, arg) write(message,*) trim(adjustl(plnew%info(i)%name)), " (", trim(adjustl(plnew%info(i)%particle_type)),")" call swiftest_io_log_one_message(COLLISION_LOG_OUT, message) end do - call swiftest_io_log_one_message(COLLISION_LOG_OUT, "***********************************************************" // & - "***********************************************************") + call swiftest_io_log_one_message(COLLISION_LOG_OUT, & + "***********************************************************" // & + "***********************************************************") allocate(after_snap%pl, source=plnew) end select deallocate(after_orig%pl) @@ -914,7 +954,11 @@ module subroutine collision_util_set_original_scale_factors(self) impactors%L_orbit = impactors%L_orbit * collider%Lscale impactors%ke_orbit = impactors%ke_orbit * collider%Escale impactors%ke_spin = impactors%ke_spin * collider%Escale +#ifdef DOCONLOC + do concurrent(i = 1:2) shared(impactors) +#else do concurrent(i = 1:2) +#endif impactors%rot(:,i) = impactors%L_spin(:,i) * (impactors%mass(i) * impactors%radius(i)**2 * impactors%Ip(3,i)) end do diff --git a/src/encounter/encounter_check.f90 b/src/encounter/encounter_check.f90 index c2013ce6b..deef9bdda 100644 --- a/src/encounter/encounter_check.f90 +++ b/src/encounter/encounter_check.f90 @@ -61,11 +61,6 @@ module subroutine encounter_check_all_plplm(param, nplm, nplt, rplm, vplm, rplt, integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! List of indices for body 2 in each encounter logical, dimension(:), allocatable, intent(out) :: lvdotr !! Logical flag indicating the sign of v .dot. x ! Internals - ! type(interaction_timer), save :: itimer - logical, save :: lfirst = .true. - logical, save :: skipit = .false. - integer(I8B) :: nplplm = 0_I8B - integer(I4B) :: npl logical, dimension(:), allocatable :: plmplt_lvdotr !! Logical flag indicating the sign of v .dot. x in the plm-plt group integer(I4B), dimension(:), allocatable :: plmplt_index1 !! List of indices for body 1 in each encounter in the plm-plt group integer(I4B), dimension(:), allocatable :: plmplt_index2 !! List of indices for body 2 in each encounter in the plm-lt group @@ -103,10 +98,10 @@ module subroutine encounter_check_all_plplm(param, nplm, nplt, rplm, vplm, rplt, call move_alloc(ltmp, lvdotr) nenc = nenc + plmplt_nenc - call swiftest_util_sort(index1, ind) - call swiftest_util_sort_rearrange(index1, ind, nenc) - call swiftest_util_sort_rearrange(index2, ind, nenc) - call swiftest_util_sort_rearrange(lvdotr, ind, nenc) + call util_sort(index1, ind) + call util_sort_rearrange(index1, ind, nenc) + call util_sort_rearrange(index2, ind, nenc) + call util_sort_rearrange(lvdotr, ind, nenc) end if @@ -179,8 +174,12 @@ subroutine encounter_check_all_sort_and_sweep_plpl(npl, r, v, renc, dt, nenc, in npl_last = npl end if +#ifdef DOCONLOC + do concurrent (i = 1:npl) shared(r,renc,rmin,rmax) local(rmag) +#else do concurrent (i = 1:npl) - rmag = .mag.r(:,i) +#endif + rmag = norm2(r(:,i)) rmax(i) = rmag + RSWEEP_FACTOR * renc(i) rmin(i) = rmag - RSWEEP_FACTOR * renc(i) end do @@ -232,13 +231,21 @@ subroutine encounter_check_all_sort_and_sweep_plplm(nplm, nplt, rplm, vplm, rplt ntot_last = ntot end if +#ifdef DOCONLOC + do concurrent (i = 1:nplm) shared(rmin,rmax,rplm,rencm) local(rmag) +#else do concurrent (i = 1:nplm) - rmag = .mag.rplm(:,i) +#endif + rmag = norm2(rplm(:,i)) rmax(i) = rmag + RSWEEP_FACTOR * rencm(i) rmin(i) = rmag - RSWEEP_FACTOR * rencm(i) end do +#ifdef DOCONLOC + do concurrent (i = 1:nplt) shared(rmin,rmax,rplt,renct) local(rmag) +#else do concurrent (i = 1:nplt) - rmag = .mag.rplt(:,i) +#endif + rmag = norm2(rplt(:,i)) rmax(nplm+i) = rmag + RSWEEP_FACTOR * renct(i) rmin(nplm+i) = rmag - RSWEEP_FACTOR * renct(i) end do @@ -292,13 +299,21 @@ subroutine encounter_check_all_sort_and_sweep_pltp(npl, ntp, rpl, vpl, rtp, vtp, renctp(:) = 0.0_DP +#ifdef DOCONLOC + do concurrent (i = 1:npl) shared(rmin,rmax,rpl,rencpl) local(rmag) +#else do concurrent (i = 1:npl) - rmag = .mag.rpl(:,i) +#endif + rmag = norm2(rpl(:,i)) rmax(i) = rmag + RSWEEP_FACTOR * rencpl(i) rmin(i) = rmag - RSWEEP_FACTOR * rencpl(i) end do - do concurrent (i = 1:ntp) - rmag = .mag.rtp(:,i) +#ifdef DOCONLOC + do concurrent (i = 1:ntp) shared(rmin,rmax,rtp,renctp) local(rmag) +#else + do concurrent (i = 1:ntp) +#endif + rmag = norm2(rtp(:,i)) rmax(npl+i) = rmag + RSWEEP_FACTOR * renctp(i) rmin(npl+i) = rmag - RSWEEP_FACTOR * renctp(i) end do @@ -340,7 +355,11 @@ pure subroutine encounter_check_all_sweep_one(i, n, xi, yi, zi, vxi, vyi, vzi, x logical, dimension(n) :: lencounteri, lvdotri lencounteri(:) = .false. +#ifdef DOCONLOC + do concurrent(j = 1:n, lgood(j)) shared(lgood,lencounteri,lvdotri,x,y,z,vx,vy,vz,renci,renc) local(xr,yr,zr,vxr,vyr,vzr,renc12) +#else do concurrent(j = 1:n, lgood(j)) +#endif xr = x(j) - xi yr = y(j) - yi zr = z(j) - zi @@ -387,7 +406,11 @@ subroutine encounter_check_all_triangular_one(i, n, xi, yi, zi, vxi, vyi, vzi, x real(DP) :: xr, yr, zr, vxr, vyr, vzr, renc12 logical, dimension(n) :: lencounteri, lvdotri +#ifdef DOCONLOC + do concurrent(j = i+1:n) shared(lencounteri, lvdotri, renci, renc) local(xr,yr,zr,vxr,vyr,vzr,renc12) +#else do concurrent(j = i+1:n) +#endif xr = x(j) - xi yr = y(j) - yi zr = z(j) - zi @@ -605,15 +628,15 @@ module subroutine encounter_check_collapse_ragged_list(ragged_list, n1, nenc, in implicit none ! Arguments class(encounter_list), dimension(:), intent(in) :: ragged_list !! The ragged encounter list - integer(I4B), intent(in) :: n1 !! Number of bodies 1 - integer(I8B), intent(out) :: nenc !! Total number of encountersj - integer(I4B), dimension(:), allocatable, intent(out) :: index1 !! Array of indices for body 1 - integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! Array of indices for body 1 - logical, dimension(:), allocatable, intent(out), optional :: lvdotr !! Array indicating which bodies are approaching + integer(I4B), intent(in) :: n1 !! Number of bodies 1 + integer(I8B), intent(out) :: nenc !! Total number of encountersj + integer(I4B), dimension(:), allocatable, intent(out) :: index1 !! Array of indices for body 1 + integer(I4B), dimension(:), allocatable, intent(out) :: index2 !! Array of indices for body 1 + logical, dimension(:), allocatable, intent(out), optional :: lvdotr !! Array indicating which bodies are approaching ! Internals integer(I4B) :: i integer(I8B) :: j1, j0, nenci - integer(I4B), dimension(n1) :: ibeg + integer(I8B), dimension(n1) :: ibeg associate(nenc_arr => ragged_list(:)%nenc) nenc = sum(nenc_arr(:)) @@ -677,10 +700,10 @@ subroutine encounter_check_remove_duplicates(n, nenc, index1, index2, lvdotr) return end if - call swiftest_util_sort(index1, ind) - call swiftest_util_sort_rearrange(index1, ind, nenc) - call swiftest_util_sort_rearrange(index2, ind, nenc) - call swiftest_util_sort_rearrange(lvdotr, ind, nenc) + call util_sort(index1, ind) + call util_sort_rearrange(index1, ind, nenc) + call util_sort_rearrange(index2, ind, nenc) + call util_sort_rearrange(lvdotr, ind, nenc) ! Get the bounds on the bodies in the first index ibeg(:) = n @@ -701,12 +724,16 @@ subroutine encounter_check_remove_duplicates(n, nenc, index1, index2, lvdotr) ! Sort on the second index and remove duplicates if (allocated(itmp)) deallocate(itmp) allocate(itmp, source=index2) +#ifdef DOCONLOC + do concurrent(i = 1:n, iend(i) - ibeg(i) > 0_I8B) shared(iend,ibeg,index2,lencounter,itmp) local(klo,khi,nenci,j) +#else do concurrent(i = 1:n, iend(i) - ibeg(i) > 0_I8B) +#endif klo = ibeg(i) khi = iend(i) nenci = khi - klo + 1_I8B if (allocated(ind)) deallocate(ind) - call swiftest_util_sort(index2(klo:khi), ind) + call util_sort(index2(klo:khi), ind) index2(klo:khi) = itmp(klo - 1_I8B + ind(:)) do j = klo + 1_I8B, khi if (index2(j) == index2(j - 1_I8B)) lencounter(j) = .false. @@ -746,9 +773,13 @@ pure module subroutine encounter_check_sort_aabb_1D(self, n, extent_arr) ! Internals integer(I8B) :: i, k - call swiftest_util_sort(extent_arr, self%ind) + call util_sort(extent_arr, self%ind) +#ifdef DOCONLOC + do concurrent(k = 1_I8B:2_I8B * n) shared(self,n) local(i) +#else do concurrent(k = 1_I8B:2_I8B * n) +#endif i = self%ind(k) if (i <= n) then self%ibeg(i) = k @@ -834,7 +865,7 @@ module subroutine encounter_check_sweep_aabb_double_list(self, n1, n2, r1, v1, r if (loverlap(i)) then ibeg = self%aabb%ibeg(i) + 1_I8B iend = self%aabb%iend(i) - 1_I8B - nbox = iend - ibeg + 1 + nbox = int(iend - ibeg, kind=I4B) + 1 call encounter_check_all_sweep_one(i, nbox, r1(1,i), r1(2,i), r1(3,i), v1(1,i), v1(2,i), v1(3,i), & xind(ibeg:iend), yind(ibeg:iend), zind(ibeg:iend),& vxind(ibeg:iend), vyind(ibeg:iend), vzind(ibeg:iend), & @@ -850,7 +881,7 @@ module subroutine encounter_check_sweep_aabb_double_list(self, n1, n2, r1, v1, r if (loverlap(i)) then ibeg = self%aabb%ibeg(i) + 1_I8B iend = self%aabb%iend(i) - 1_I8B - nbox = iend - ibeg + 1 + nbox = int(iend - ibeg, kind=I4B) + 1 ii = i - n1 call encounter_check_all_sweep_one(ii, nbox, r2(1,ii), r2(2,ii), r2(3,ii), v2(1,ii), v2(2,ii), v2(3,ii), & xind(ibeg:iend), yind(ibeg:iend), zind(ibeg:iend),& @@ -927,7 +958,7 @@ module subroutine encounter_check_sweep_aabb_single_list(self, n, r, v, renc, dt if (loverlap(i)) then ibeg = self%aabb%ibeg(i) + 1_I8B iend = self%aabb%iend(i) - 1_I8B - nbox = int(iend - ibeg + 1, kind=I4B) + nbox = int(iend - ibeg, kind=I4B) + 1 lencounteri(ibeg:iend) = .true. call encounter_check_all_sweep_one(i, nbox, r(1,i), r(2,i), r(3,i), v(1,i), v(2,i), v(3,i), & xind(ibeg:iend), yind(ibeg:iend), zind(ibeg:iend),& @@ -941,7 +972,11 @@ module subroutine encounter_check_sweep_aabb_single_list(self, n, r, v, renc, dt call encounter_check_collapse_ragged_list(lenc, n, nenc, index1, index2, lvdotr) ! By convention, we always assume that index1 < index2, and so we must swap any that are out of order +#ifdef DOCONLOC + do concurrent(k = 1_I8B:nenc, index1(k) > index2(k)) shared(index1,index2) local(itmp) +#else do concurrent(k = 1_I8B:nenc, index1(k) > index2(k)) +#endif itmp = index1(k) index1(k) = index2(k) index2(k) = itmp diff --git a/src/encounter/encounter_io.f90 b/src/encounter/encounter_io.f90 index ceb3194fe..fb5de048f 100644 --- a/src/encounter/encounter_io.f90 +++ b/src/encounter/encounter_io.f90 @@ -231,7 +231,7 @@ module subroutine encounter_io_netcdf_write_frame_snapshot(self, history, param) class(base_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i, idslot, old_mode, npl, ntp + integer(I4B) :: i, idslot, old_mode, npl, ntp, tmp character(len=STRMAX) :: charstring select type(param) @@ -284,7 +284,7 @@ module subroutine encounter_io_netcdf_write_frame_snapshot(self, history, param) call netcdf_io_check( nf90_put_var(nc%id, nc%ptype_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "encounter_io_netcdf_write_frame_snapshot nf90_put_var tp particle_type_varid" ) end do - call netcdf_io_check( nf90_set_fill(nc%id, old_mode, old_mode) ) + call netcdf_io_check( nf90_set_fill(nc%id, old_mode, tmp) ) end associate end select end select diff --git a/src/encounter/encounter_module.f90 b/src/encounter/encounter_module.f90 index f3c24c763..bcae2bd15 100644 --- a/src/encounter/encounter_module.f90 +++ b/src/encounter/encounter_module.f90 @@ -259,9 +259,9 @@ end subroutine encounter_util_setup_list module subroutine encounter_util_append_list(self, source, lsource_mask) implicit none - class(encounter_list), intent(inout) :: self !! Swiftest encounter list object - class(encounter_list), intent(in) :: source !! Source object to append - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to + class(encounter_list), intent(inout) :: self !! Swiftest encounter list object + class(encounter_list), intent(in) :: source !! Source object to append + logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to end subroutine encounter_util_append_list module subroutine encounter_util_copy_list(self, source) diff --git a/src/encounter/encounter_util.f90 b/src/encounter/encounter_util.f90 index 01848d571..7307eb9cb 100644 --- a/src/encounter/encounter_util.f90 +++ b/src/encounter/encounter_util.f90 @@ -18,28 +18,27 @@ module subroutine encounter_util_append_list(self, source, lsource_mask) !! This method will automatically resize the destination body if it is too small implicit none ! Arguments - class(encounter_list), intent(inout) :: self !! Swiftest encounter list object - class(encounter_list), intent(in) :: source !! Source object to append - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to + class(encounter_list), intent(inout) :: self !! Swiftest encounter list object + class(encounter_list), intent(in) :: source !! Source object to append + logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to ! Internals - integer(I4B) :: nold, nsrc + integer(I4B) :: nold nold = int(self%nenc, kind=I4B) - nsrc = int(source%nenc, kind=I4B) - call swiftest_util_append(self%tcollision, source%tcollision, nold, nsrc, lsource_mask) - call swiftest_util_append(self%lclosest, source%lclosest, nold, nsrc, lsource_mask) - call swiftest_util_append(self%lvdotr, source%lvdotr, nold, nsrc, lsource_mask) - call swiftest_util_append(self%status, source%status, nold, nsrc, lsource_mask) - call swiftest_util_append(self%index1, source%index1, nold, nsrc, lsource_mask) - call swiftest_util_append(self%index2, source%index2, nold, nsrc, lsource_mask) - call swiftest_util_append(self%id1, source%id1, nold, nsrc, lsource_mask) - call swiftest_util_append(self%id2, source%id2, nold, nsrc, lsource_mask) - call swiftest_util_append(self%r1, source%r1, nold, nsrc, lsource_mask) - call swiftest_util_append(self%r2, source%r2, nold, nsrc, lsource_mask) - call swiftest_util_append(self%v1, source%v1, nold, nsrc, lsource_mask) - call swiftest_util_append(self%v2, source%v2, nold, nsrc, lsource_mask) - call swiftest_util_append(self%level, source%level, nold, nsrc, lsource_mask) - self%nenc = nold + count(lsource_mask(1:nsrc)) + call util_append(self%tcollision, source%tcollision, nold, lsource_mask) + call util_append(self%lclosest, source%lclosest, nold, lsource_mask) + call util_append(self%lvdotr, source%lvdotr, nold, lsource_mask) + call util_append(self%status, source%status, nold, lsource_mask) + call util_append(self%index1, source%index1, nold, lsource_mask) + call util_append(self%index2, source%index2, nold, lsource_mask) + call util_append(self%id1, source%id1, nold, lsource_mask) + call util_append(self%id2, source%id2, nold, lsource_mask) + call util_append(self%r1, source%r1, nold, lsource_mask) + call util_append(self%r2, source%r2, nold, lsource_mask) + call util_append(self%v1, source%v1, nold, lsource_mask) + call util_append(self%v2, source%v2, nold, lsource_mask) + call util_append(self%level, source%level, nold, lsource_mask) + self%nenc = nold + count(lsource_mask(:)) return end subroutine encounter_util_append_list @@ -101,8 +100,6 @@ module subroutine encounter_util_dealloc_bounding_box(self) implicit none ! Arguments class(encounter_bounding_box), intent(inout) :: self !! Bounding box structure - ! Internals - integer(I4B) :: i call self%aabb%dealloc() @@ -283,11 +280,11 @@ module subroutine encounter_util_index_map(self) call encounter_util_get_vals_storage(self, idvals, tvals) ! Consolidate ids to only unique values - call swiftest_util_unique(idvals,self%idvals,self%idmap) + call util_unique(idvals,self%idvals,self%idmap) self%nid = size(self%idvals) ! Consolidate time values to only unique values - call swiftest_util_unique(tvals,self%tvals,self%tmap) + call util_unique(tvals,self%tvals,self%tmap) self%nt = size(self%tvals) return @@ -342,7 +339,7 @@ module subroutine encounter_util_setup_aabb(self, n, n_last) integer(I4B), intent(in) :: n !! Number of objects with bounding box extents integer(I4B), intent(in) :: n_last !! Number of objects with bounding box extents the previous time this was called ! Internals - integer(I4B) :: next, next_last, k, dim + integer(I4B) :: next, next_last, k integer(I4B), dimension(:), allocatable :: itmp next = 2 * n @@ -431,19 +428,19 @@ module subroutine encounter_util_spill_list(self, discards, lspill_list, ldestru integer(I8B) :: nenc_old associate(keeps => self) - call swiftest_util_spill(keeps%tcollision, discards%tcollision, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lvdotr, discards%lvdotr, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lclosest, discards%lclosest, lspill_list, ldestructive) - call swiftest_util_spill(keeps%status, discards%status, lspill_list, ldestructive) - call swiftest_util_spill(keeps%index1, discards%index1, lspill_list, ldestructive) - call swiftest_util_spill(keeps%index2, discards%index2, lspill_list, ldestructive) - call swiftest_util_spill(keeps%id1, discards%id1, lspill_list, ldestructive) - call swiftest_util_spill(keeps%id2, discards%id2, lspill_list, ldestructive) - call swiftest_util_spill(keeps%r1, discards%r1, lspill_list, ldestructive) - call swiftest_util_spill(keeps%r2, discards%r2, lspill_list, ldestructive) - call swiftest_util_spill(keeps%v1, discards%v1, lspill_list, ldestructive) - call swiftest_util_spill(keeps%v2, discards%v2, lspill_list, ldestructive) - call swiftest_util_spill(keeps%level, discards%level, lspill_list, ldestructive) + call util_spill(keeps%tcollision, discards%tcollision, lspill_list, ldestructive) + call util_spill(keeps%lvdotr, discards%lvdotr, lspill_list, ldestructive) + call util_spill(keeps%lclosest, discards%lclosest, lspill_list, ldestructive) + call util_spill(keeps%status, discards%status, lspill_list, ldestructive) + call util_spill(keeps%index1, discards%index1, lspill_list, ldestructive) + call util_spill(keeps%index2, discards%index2, lspill_list, ldestructive) + call util_spill(keeps%id1, discards%id1, lspill_list, ldestructive) + call util_spill(keeps%id2, discards%id2, lspill_list, ldestructive) + call util_spill(keeps%r1, discards%r1, lspill_list, ldestructive) + call util_spill(keeps%r2, discards%r2, lspill_list, ldestructive) + call util_spill(keeps%v1, discards%v1, lspill_list, ldestructive) + call util_spill(keeps%v2, discards%v2, lspill_list, ldestructive) + call util_spill(keeps%level, discards%level, lspill_list, ldestructive) nenc_old = keeps%nenc diff --git a/src/fraggle/fraggle_generate.f90 b/src/fraggle/fraggle_generate.f90 index 93b4c3431..cd1df7033 100644 --- a/src/fraggle/fraggle_generate.f90 +++ b/src/fraggle/fraggle_generate.f90 @@ -59,7 +59,8 @@ module subroutine fraggle_generate(self, nbody_system, param, t) call self%set_mass_dist(param) call self%disrupt(nbody_system, param, t, lfailure) if (lfailure) then - call swiftest_io_log_one_message(COLLISION_LOG_OUT, "Fraggle failed to find a solution to match energy contraint. Treating this as a merge.") + call swiftest_io_log_one_message(COLLISION_LOG_OUT, & + "Fraggle failed to find a solution to match energy contraint. Treating this as a merge.") call self%merge(nbody_system, param, t) ! Use the default collision model, which is merge return end if @@ -68,7 +69,11 @@ module subroutine fraggle_generate(self, nbody_system, param, t) ! Get the energy and momentum of the system before and after the collision call self%get_energy_and_momentum(nbody_system, param, phase="before") nfrag = fragments%nbody +#ifdef DOCONLOC + do concurrent(i = 1:2) shared(fragments,impactors) +#else do concurrent(i = 1:2) +#endif fragments%rc(:,i) = fragments%rb(:,i) - impactors%rbcom(:) fragments%vc(:,i) = fragments%vb(:,i) - impactors%vbcom(:) end do @@ -127,8 +132,9 @@ module subroutine fraggle_generate_disrupt(self, nbody_system, param, t, lfailur real(DP), parameter :: fail_scale_initial = 1.0003_DP integer(I4B) :: nfrag_start - ! The minimization and linear solvers can sometimes lead to floating point exceptions. Rather than halting the code entirely if this occurs, we - ! can simply fail the attempt and try again. So we need to turn off any floating point exception halting modes temporarily + ! The minimization and linear solvers can sometimes lead to floating point exceptions. Rather than halting the code entirely + ! if this occurs, we can simply fail the attempt and try again. So we need to turn off any floating point exception halting + ! modes temporarily call ieee_get_halting_mode(IEEE_ALL,fpe_halting_modes) ! Save the current halting modes so we can turn them off temporarily fpe_quiet_modes(:) = .false. call ieee_set_halting_mode(IEEE_ALL,fpe_quiet_modes) @@ -164,7 +170,8 @@ module subroutine fraggle_generate_disrupt(self, nbody_system, param, t, lfailur if (.not.lfailure) then if (self%fragments%nbody /= nfrag_start) then write(message,*) self%fragments%nbody - call swiftest_io_log_one_message(COLLISION_LOG_OUT, "Fraggle found a solution with " // trim(adjustl(message)) // " fragments" ) + call swiftest_io_log_one_message(COLLISION_LOG_OUT, "Fraggle found a solution with " // trim(adjustl(message)) & + // " fragments" ) end if call self%get_energy_and_momentum(nbody_system, param, phase="after") @@ -172,7 +179,8 @@ module subroutine fraggle_generate_disrupt(self, nbody_system, param, t, lfailur dE = self%te(2) - self%te(1) call swiftest_io_log_one_message(COLLISION_LOG_OUT, "All quantities in collision system natural units") - call swiftest_io_log_one_message(COLLISION_LOG_OUT, "* Conversion factors (collision system units / nbody system units):") + call swiftest_io_log_one_message(COLLISION_LOG_OUT, & + "* Conversion factors (collision system units / nbody system units):") write(message,*) "* Mass: ", self%mscale call swiftest_io_log_one_message(COLLISION_LOG_OUT, message) write(message,*) "* Distance: ", self%dscale @@ -196,7 +204,8 @@ module subroutine fraggle_generate_disrupt(self, nbody_system, param, t, lfailur end if call self%set_original_scale() - self%max_rot = MAX_ROT_SI * param%TU2S ! Re-compute the spin limit from scratch so it doesn't drift due to floating point errors every time we convert + self%max_rot = MAX_ROT_SI * param%TU2S ! Re-compute the spin limit from scratch so it doesn't drift due to floating point + ! errors every time we convert ! Restore the big array if (lk_plpl) call pl%flatten(param) @@ -244,7 +253,8 @@ module subroutine fraggle_generate_hitandrun(self, nbody_system, param, t) end if ! The Fraggle disruption model (and its extended types allow for non-pure hit and run. - if (impactors%mass_dist(2) > 0.9_DP * impactors%mass(jproj)) then ! Pure hit and run, so we'll just keep the two bodies untouched + if (impactors%mass_dist(2) > 0.9_DP * impactors%mass(jproj)) then ! Pure hit and run, so we'll just keep the two bodies + ! untouched call swiftest_io_log_one_message(COLLISION_LOG_OUT, "Pure hit and run. No new fragments generated.") call self%collision_basic%hitandrun(nbody_system, param, t) return @@ -299,7 +309,7 @@ module subroutine fraggle_generate_merge(self, nbody_system, param, t) real(DP), intent(in) :: t !! The time of the collision ! Internals - integer(I4B) :: i, j + integer(I4B) :: i real(DP), dimension(NDIM) :: L_spin_new, Ip, rot real(DP) :: rotmag, mass, volume, radius @@ -309,7 +319,11 @@ module subroutine fraggle_generate_merge(self, nbody_system, param, t) mass = sum(impactors%mass(:)) volume = 4._DP / 3._DP * PI * sum(impactors%radius(:)**3) radius = (3._DP * volume / (4._DP * PI))**(THIRD) +#ifdef DOCONLOC + do concurrent(i = 1:NDIM) shared(impactors, Ip, L_spin_new) +#else do concurrent(i = 1:NDIM) +#endif Ip(i) = sum(impactors%mass(:) * impactors%Ip(i,:)) L_spin_new(i) = sum(impactors%L_orbit(i,:) + impactors%L_spin(i,:)) end do @@ -319,7 +333,8 @@ module subroutine fraggle_generate_merge(self, nbody_system, param, t) if (rotmag < self%max_rot) then call self%collision_basic%merge(nbody_system, param, t) else - call swiftest_io_log_one_message(COLLISION_LOG_OUT, "Merger would break the spin barrier. Converting to pure hit and run" ) + call swiftest_io_log_one_message(COLLISION_LOG_OUT, & + "Merger would break the spin barrier. Converting to pure hit and run" ) impactors%mass_dist(1:2) = impactors%mass(1:2) call self%hitandrun(nbody_system, param, t) end if @@ -334,9 +349,9 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu !! Author: Jennifer L.L. Pouplin, Carlisle A. Wishard, and David A. Minton !! !! Initializes the position vectors of the fragments around the center of mass based on the collision style. - !! For hit and run with disruption, the fragments are generated in a random cloud around the smallest of the two colliders (body 2) - !! For disruptive collisions, the fragments are generated in a random cloud around the impact point. Bodies are checked for overlap and - !! regenerated if they overlap. + !! For hit and run with disruption, the fragments are generated in a random cloud around the smallest of the two colliders + !! (body 2). For disruptive collisions, the fragments are generated in a random cloud around the impact point. Bodies are + !! checked for overlap and regenerated if they overlap. implicit none ! Arguments class(collision_fraggle), intent(inout) :: collider !! Fraggle collision system object @@ -350,21 +365,22 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu real(DP), dimension(2) :: fragment_cloud_radius logical, dimension(collider%fragments%nbody) :: loverlap real(DP), dimension(collider%fragments%nbody) :: mass_rscale, phi, theta, u - integer(I4B) :: i, j, loop, istart + integer(I4B) :: i, j, loop, istart, nfrag, npl, ntp logical :: lsupercat, lhitandrun integer(I4B), parameter :: MAXLOOP = 10000 - real(DP), parameter :: cloud_size_scale_factor = 3.0_DP ! Scale factor to apply to the size of the cloud relative to the distance from the impact point. - ! A larger value puts more space between fragments initially real(DP), parameter :: rbuffer = 1.01_DP ! Body radii are inflated by this scale factor to prevent secondary collisions real(DP), parameter :: pack_density = 0.5236_DP ! packing density of loose spheres - associate(fragments => collider%fragments, impactors => collider%impactors, nfrag => collider%fragments%nbody, & - pl => nbody_system%pl, tp => nbody_system%tp, npl => nbody_system%pl%nbody, ntp => nbody_system%tp%nbody) + associate(fragments => collider%fragments, impactors => collider%impactors, pl => nbody_system%pl, tp => nbody_system%tp) + nfrag = collider%fragments%nbody + npl = nbody_system%pl%nbody + ntp = nbody_system%tp%nbody lsupercat = (impactors%regime == COLLRESOLVE_REGIME_SUPERCATASTROPHIC) lhitandrun = (impactors%regime == COLLRESOLVE_REGIME_HIT_AND_RUN) ! We will treat the first two fragments of the list as special cases. - ! Place the first two bodies at the centers of the two fragment clouds, but be sure they are sufficiently far apart to avoid overlap + ! Place the first two bodies at the centers of the two fragment clouds, but be sure they are sufficiently far apart to + ! avoid overlap if (lhitandrun) then rdistance = impactors%radius(2) istart = 2 @@ -377,11 +393,14 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu end if mass_rscale(1:istart-1) = 1.0_DP - ! Give the fragment positions a random value that is scaled with fragment mass so that the more massive bodies tend to be closer to the impact point - ! Later, velocities will be scaled such that the farther away a fragment is placed from the impact point, the higher will its velocity be. + ! Give the fragment positions a random value that is scaled with fragment mass so that the more massive bodies tend to be + ! closer to the impact point. Later, velocities will be scaled such that the farther away a fragment is placed from the + ! impact point, the higher will its velocity be. call random_number(mass_rscale(istart:nfrag)) mass_rscale(istart:nfrag) = (mass_rscale(istart:nfrag) + 1.0_DP) / 2 - mass_rscale(istart:nfrag) = mass_rscale(istart:nfrag) * (sum(fragments%mass(istart:nfrag)) / fragments%mass(istart:nfrag))**(0.125_DP) ! The power is arbitrary. It just gives the velocity a small mass dependence + ! The power of 0.125 in the scaling below is arbitrary. It just gives the velocity a small mass dependence + mass_rscale(istart:nfrag) = mass_rscale(istart:nfrag) * (sum(fragments%mass(istart:nfrag)) & + / fragments%mass(istart:nfrag))**(0.125_DP) mass_rscale(istart:nfrag) = mass_rscale(istart:nfrag) / minval(mass_rscale(istart:nfrag)) loverlap(:) = .true. @@ -394,8 +413,10 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu fragment_cloud_center(:,2) = impactors%rc(:,2) fragments%rc(:,1) = fragment_cloud_center(:,1) else ! Keep the first and second bodies at approximately their original location, but so as not to be overlapping - fragment_cloud_center(:,1) = impactors%rcimp(:) - rbuffer * max(fragments%radius(1),impactors%radius(1)) * impactors%y_unit(:) - fragment_cloud_center(:,2) = impactors%rcimp(:) + rbuffer * max(fragments%radius(2),impactors%radius(2)) * impactors%y_unit(:) + fragment_cloud_center(:,1) = impactors%rcimp(:) - rbuffer * max(fragments%radius(1),& + impactors%radius(1)) * impactors%y_unit(:) + fragment_cloud_center(:,2) = impactors%rcimp(:) + rbuffer * max(fragments%radius(2), & + impactors%radius(2)) * impactors%y_unit(:) fragment_cloud_radius(:) = rdistance / pack_density fragments%rc(:,1:2) = fragment_cloud_center(:,1:2) end if @@ -411,7 +432,12 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu end do ! Randomly place the n>2 fragments inside their cloud until none are overlapping +#ifdef DOCONLOC + do concurrent(i = istart:nfrag, loverlap(i)) shared(fragments, impactors, fragment_cloud_radius, fragment_cloud_center,& + loverlap, mass_rscale, u, phi, theta, lhitandrun) local(j, direction) +#else do concurrent(i = istart:nfrag, loverlap(i)) +#endif j = fragments%origin_body(i) ! Scale the cloud size @@ -430,13 +456,15 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu ! Stretch out the hit and run cloud along the flight trajectory if (lhitandrun) then - fragments%rc(:,i) = fragments%rc(:,i) * (1.0_DP + 2 * fragment_cloud_radius(j) * mass_rscale(i) * impactors%bounce_unit(:)) + fragments%rc(:,i) = fragments%rc(:,i) * (1.0_DP + 2 * fragment_cloud_radius(j) * mass_rscale(i) & + * impactors%bounce_unit(:)) end if fragments%rc(:,i) = fragments%rc(:,i) + fragment_cloud_center(:,j) if (lhitandrun) then - fragments%rc(:,i) = fragments%rc(:,i) + 2 * fragment_cloud_radius(j) * mass_rscale(i) * impactors%bounce_unit(:) ! Shift the stretched cloud downrange + ! Shift the stretched cloud downrange + fragments%rc(:,i) = fragments%rc(:,i) + 2 * fragment_cloud_radius(j) * mass_rscale(i) * impactors%bounce_unit(:) else ! Make sure that the fragments are positioned away from the impact point direction = dot_product(fragments%rc(:,i) - impactors%rcimp(:), fragment_cloud_center(:,j) - impactors%rcimp(:)) @@ -448,9 +476,14 @@ module subroutine fraggle_generate_pos_vec(collider, nbody_system, param, lfailu end do ! Because body 1 and 2 are initialized near the original impactor positions, then if these bodies are still overlapping - ! when the rest are not, we will randomly walk their position in space so as not to move them too far from their starting position + ! when the rest are not, we will randomly walk their position in space so as not to move them too far from their + ! starting position if (all(.not.loverlap(istart:nfrag)) .and. any(loverlap(1:istart-1))) then +#ifdef DOCONLOC + do concurrent(i = 1:istart-1,loverlap(i)) shared(fragments,loverlap, u, theta, i) local(rwalk, dis) +#else do concurrent(i = 1:istart-1,loverlap(i)) +#endif dis = 0.1_DP * fragments%radius(i) * u(i)**(THIRD) rwalk(1) = fragments%rmag(i) * sin(theta(i)) * cos(phi(i)) rwalk(2) = fragments%rmag(i) * sin(theta(i)) * sin(phi(i)) @@ -508,25 +541,29 @@ module subroutine fraggle_generate_rot_vec(collider, nbody_system, param) class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i - real(DP), parameter :: frag_rot_fac = 0.1_DP ! Fraction of projectile rotation magnitude to add as random noise to fragment rotation - real(DP), parameter :: hitandrun_momentum_transfer = 0.01_DP ! Fraction of projectile momentum transfered to target in a hit and run + integer(I4B) :: i, nfrag + real(DP), parameter :: FRAG_ROT_FAC = 0.1_DP ! Fraction of projectile rotation magnitude to add as random noise to fragment + ! rotation + real(DP), parameter :: hitandrun_momentum_transfer = 0.01_DP ! Fraction of projectile momentum transfered to target in a hit + ! and run real(DP) :: mass_fac real(DP), dimension(NDIM) :: drot, dL integer(I4B), parameter :: MAXLOOP = 10 logical :: lhitandrun - associate(fragments => collider%fragments, impactors => collider%impactors, nfrag => collider%fragments%nbody) + associate(fragments => collider%fragments, impactors => collider%impactors) + nfrag = collider%fragments%nbody lhitandrun = (impactors%regime == COLLRESOLVE_REGIME_HIT_AND_RUN) - ! Initialize fragment rotations and velocities to be pre-impact rotation for body 1, and randomized for bodies >1 and scaled to the original rotation. - ! This will get updated later when conserving angular momentum + ! Initialize fragment rotations and velocities to be pre-impact rotation for body 1, and randomized for bodies >1 and + ! scaled to the original rotation. This will get updated later when conserving angular momentum mass_fac = fragments%mass(1) / impactors%mass(1) fragments%rot(:,1) = mass_fac**(5.0_DP/3.0_DP) * impactors%rot(:,1) ! If mass was added, also add spin angular momentum if (mass_fac > 1.0_DP) then - dL(:) = (fragments%mass(1) - impactors%mass(1)) * (impactors%rc(:,2) - impactors%rc(:,1)) .cross. (impactors%vc(:,2) - impactors%vc(:,1)) + dL(:) = (fragments%mass(1) - impactors%mass(1)) * (impactors%rc(:,2) - impactors%rc(:,1)) & + .cross. (impactors%vc(:,2) - impactors%vc(:,1)) drot(:) = dL(:) / (fragments%mass(1) * fragments%radius(1)**2 * fragments%Ip(3,1)) ! Check to make sure we haven't broken the spin barrier. Reduce the rotation change if so do i = 1, MAXLOOP @@ -542,7 +579,8 @@ module subroutine fraggle_generate_rot_vec(collider, nbody_system, param) end if if (lhitandrun) then - dL(:) = hitandrun_momentum_transfer * impactors%mass(2) * (impactors%rc(:,2) - impactors%rc(:,1)) .cross. (impactors%vc(:,2) - impactors%vc(:,1)) + dL(:) = hitandrun_momentum_transfer * impactors%mass(2) * (impactors%rc(:,2) - impactors%rc(:,1)) & + .cross. (impactors%vc(:,2) - impactors%vc(:,1)) drot(:) = dL(:) / (fragments%mass(1) * fragments%radius(1)**2 * fragments%Ip(3,1)) do i = 1, MAXLOOP if (.mag.(fragments%rot(:,1) + drot(:)) < collider%max_rot) exit @@ -557,9 +595,14 @@ module subroutine fraggle_generate_rot_vec(collider, nbody_system, param) end if call random_number(fragments%rot(:,2:nfrag)) +#ifdef DOCONLOC + do concurrent (i = 2:nfrag) shared(fragments,impactors) local(mass_fac) +#else do concurrent (i = 2:nfrag) +#endif mass_fac = fragments%mass(i) / impactors%mass(2) - fragments%rot(:,i) = mass_fac**(5.0_DP/3.0_DP) * impactors%rot(:,2) + 2 * (fragments%rot(:,i) - 1.0_DP) * frag_rot_fac * .mag.impactors%rot(:,2) + fragments%rot(:,i) = mass_fac**(5.0_DP/3.0_DP) * impactors%rot(:,2) + 2 * (fragments%rot(:,i) - 1.0_DP) * & + FRAG_ROT_FAC * norm2(impactors%rot(:,2)) end do fragments%rotmag(:) = .mag.fragments%rot(:,:) @@ -582,17 +625,22 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters logical, intent(out) :: lfailure !! Did the velocity computation fail? ! Internals - real(DP), parameter :: ENERGY_SUCCESS_METRIC = 0.1_DP !! Relative energy error to accept as a success (success also must be energy-losing in addition to being within the metric amount) + real(DP), parameter :: ENERGY_SUCCESS_METRIC = 0.1_DP !! Relative energy error to accept as a success (success also must be + !! energy-losing in addition to being within the metric amount) real(DP), parameter :: ENERGY_CONVERGENCE_TOL = 1e-3_DP !! Relative change in error before giving up on energy convergence - real(DP) :: MOMENTUM_SUCCESS_METRIC = 10*epsilon(1.0_DP) !! Relative angular momentum error to accept as a success (should be *much* stricter than energy) + real(DP) :: MOMENTUM_SUCCESS_METRIC = 10*epsilon(1.0_DP) !! Relative angular momentum error to accept as a success + !! (should be *much* stricter than energy) integer(I4B) :: i, j, loop, try, istart, nfrag, nsteps, nsteps_best, posloop logical :: lhitandrun, lsupercat - real(DP), dimension(NDIM) :: vimp_unit, rimp, vrot, vdisp, L_residual, L_residual_unit, L_residual_best, dL, drot, rot_new, dL_metric - real(DP) :: vimp, vmag, vesc, dE, E_residual, E_residual_best, E_residual_last, ke_avail, ke_remove, dE_best, fscale, dE_metric, mfrag, rn, dL1_mag, dE_conv + real(DP), dimension(NDIM) :: vimp_unit, rimp, vrot, vdisp, L_residual, L_residual_unit, L_residual_best, dL, drot, rot_new + real(DP), dimension(NDIM) :: dL_metric + real(DP) :: vimp, vmag, vesc, dE, E_residual, E_residual_best, E_residual_last, ke_avail, ke_remove, dE_best, fscale + real(DP) :: dE_metric, mfrag, rn, dL1_mag, dE_conv, vumag integer(I4B), dimension(:), allocatable :: vsign real(DP), dimension(:), allocatable :: vscale real(DP), dimension(:), allocatable :: dLi_mag - ! For the initial "guess" of fragment velocities, this is the minimum and maximum velocity relative to escape velocity that the fragments will have + ! For the initial "guess" of fragment velocities, this is the minimum and maximum velocity relative to escape velocity that + ! the fragments will have real(DP), parameter :: hitandrun_vscale = 0.25_DP real(DP) :: vmin_guess real(DP) :: vmax_guess @@ -651,7 +699,11 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu ! Scale the magnitude of the velocity by the distance from the impact point ! This will reduce the chances of fragments colliding with each other immediately, and is more physically correct - do concurrent(i = 1:fragments%nbody) +#ifdef DOCONLOC + do concurrent(i = 1:fragments%nbody) shared(fragments,impactors,vscale) local(rimp) +#else + do concurrent(i = 1:fragments%nbody) +#endif rimp(:) = fragments%rc(:,i) - impactors%rcimp(:) vscale(i) = .mag. rimp(:) / sum(impactors%radius(1:2)) end do @@ -662,22 +714,35 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu ! Set the velocities of all fragments using all of the scale factors determined above if (istart > 1) fragments%vc(:,1) = impactors%vc(:,1) * impactors%mass(1) / fragments%mass(1) +#ifdef DOCONLOC + do concurrent(i = istart:fragments%nbody) shared(fragments,impactors,lhitandrun, vscale, vesc, vsign) & + local(j,vrot,vmag,vdisp,rimp,vimp_unit, vumag) +#else do concurrent(i = istart:fragments%nbody) +#endif j = fragments%origin_body(i) - vrot(:) = impactors%rot(:,j) .cross. (fragments%rc(:,i) - impactors%rc(:,j)) + vrot(1) = impactors%rot(2,j) * (fragments%rc(3,i) - impactors%rc(3,j)) & + - impactors%rot(3,j) * (fragments%rc(2,i) - impactors%rc(2,j)) + vrot(2) = impactors%rot(3,j) * (fragments%rc(1,i) - impactors%rc(1,j)) & + - impactors%rot(1,j) * (fragments%rc(3,i) - impactors%rc(3,j)) + vrot(3) = impactors%rot(1,j) * (fragments%rc(2,i) - impactors%rc(2,j)) & + - impactors%rot(2,j) * (fragments%rc(1,i) - impactors%rc(1,j)) if (lhitandrun) then - vdisp(:) = .unit.(fragments%rc(:,i) - impactors%rc(:,2)) * vesc + vumag = norm2(fragments%rc(:,i) - impactors%rc(:,2)) + vdisp(:) = (fragments%rc(:,i) - impactors%rc(:,2)) / vumag * vesc fragments%vc(:,i) = vsign(i) * impactors%bounce_unit(:) * vscale(i) + vrot(:) + vdisp(:) else vmag = vscale(i) rimp(:) = fragments%rc(:,i) - impactors%rcimp(:) - vimp_unit(:) = .unit. (rimp(:) + vsign(i) * impactors%bounce_unit(:)) + vumag = norm2(rimp(:) + vsign(i) * impactors%bounce_unit(:)) + vimp_unit(:) = (rimp(:) + vsign(i) * impactors%bounce_unit(:)) / vumag fragments%vc(:,i) = vmag * vimp_unit(:) + vrot(:) end if end do fragments%vmag(:) = .mag. fragments%vc(:,:) - ! Every time the collision-frame velocities are altered, we need to be sure to shift everything back to the center-of-mass frame + ! Every time the collision-frame velocities are altered, we need to be sure to shift everything back to the + ! center-of-mass frame call collision_util_shift_vector_to_origin(fragments%mass, fragments%vc) call fragments%set_coordinate_system() @@ -686,14 +751,19 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu nsteps = nsteps + 1 mfrag = sum(fragments%mass(istart:fragments%nbody)) - ! Try to put residual angular momentum into the spin, but if this would go past the spin barrier, then put it into velocity shear instead + ! Try to put residual angular momentum into the spin, but if this would go past the spin barrier, then put it into + ! velocity shear instead call collider_local%get_energy_and_momentum(nbody_system, param, phase="after") L_residual(:) = (collider_local%L_total(:,2) - collider_local%L_total(:,1)) L_residual_unit(:) = .unit. L_residual(:) if (nsteps == 1) L_residual_best(:) = L_residual(:) ! Use equipartition of spin kinetic energy to distribution spin angular momentum +#ifdef DOCONLOC + do concurrent(i = istart:fragments%nbody) shared(DLi_mag, fragments) +#else do concurrent(i = istart:fragments%nbody) +#endif dLi_mag(i) = ((fragments%mass(i) / fragments%mass(istart)) * & (fragments%radius(i) / fragments%radius(istart))**2 * & (fragments%Ip(3,i) / fragments%Ip(3,istart)))**(1.5_DP) @@ -707,7 +777,8 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu if (.mag.rot_new(:) < collider_local%max_rot) then fragments%rot(:,i) = rot_new(:) fragments%rotmag(i) = .mag.fragments%rot(:,i) - else ! We would break the spin barrier here. Add a random component of rotation that is less than what would break the limit. The rest will go in velocity shear + else ! We would break the spin barrier here. Add a random component of rotation that is less than what would + ! break the limit. The rest will go in velocity shear call random_number(drot) call random_number(rn) drot(:) = (rn * collider_local%max_rot - fragments%rotmag(i)) * 2 * (drot(:) - 0.5_DP) @@ -752,7 +823,8 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu ! Check if we've converged on our constraints if (all(dL_metric(:) <= 1.0_DP)) then - if ((abs(E_residual) < abs(E_residual_best)) .or. ((dE < 0.0_DP) .and. (dE_best >= 0.0_DP))) then ! This is our best case so far. Save it for posterity + if ((abs(E_residual) < abs(E_residual_best)) .or. ((dE < 0.0_DP) .and. (dE_best >= 0.0_DP))) then + ! This is our best case so far. Save it for posterity E_residual_best = E_residual L_residual_best(:) = L_residual(:) dE_best = dE @@ -766,7 +838,8 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu if (dE_conv < ENERGY_CONVERGENCE_TOL) exit inner end if - ! Remove a constant amount of velocity from the bodies so we don't shift the center of mass and screw up the momentum + ! Remove a constant amount of velocity from the bodies so we don't shift the center of mass and screw up the + ! momentum ke_avail = 0.0_DP do i = fragments%nbody, 1, -1 ke_avail = ke_avail + 0.5_DP * fragments%mass(i) * max(fragments%vmag(i) - vesc / try,0.0_DP)**2 @@ -797,15 +870,21 @@ module subroutine fraggle_generate_vel_vec(collider, nbody_system, param, lfailu write(message, *) nsteps if (lfailure) then - call swiftest_io_log_one_message(COLLISION_LOG_OUT, "Fraggle velocity calculation failed to converge after " // trim(adjustl(message)) // " steps. The best solution found had:") + call swiftest_io_log_one_message(COLLISION_LOG_OUT, "Fraggle velocity calculation failed to converge after " & + // trim(adjustl(message)) // " steps. The best solution found had:") else - call swiftest_io_log_one_message(COLLISION_LOG_OUT,"Fraggle velocity calculation converged after " // trim(adjustl(message)) // " steps.") + call swiftest_io_log_one_message(COLLISION_LOG_OUT,"Fraggle velocity calculation converged after " & + // trim(adjustl(message)) // " steps.") call collider%get_energy_and_momentum(nbody_system, param, phase="after") L_residual(:) = (collider%L_total(:,2) - collider%L_total(:,1)) call collision_util_velocity_torque(-L_residual(:), collider%fragments%mtot, impactors%rbcom, impactors%vbcom) - do concurrent(i = 1:collider%fragments%nbody) +#ifdef DOCONLOC + do concurrent(i = 1:nfrag) shared(collider, impactors) +#else + do concurrent(i = 1:nfrag) +#endif collider%fragments%vb(:,i) = collider%fragments%vc(:,i) + impactors%vbcom(:) end do diff --git a/src/fraggle/fraggle_util.f90 b/src/fraggle/fraggle_util.f90 index 14a3b69df..19752442c 100644 --- a/src/fraggle/fraggle_util.f90 +++ b/src/fraggle/fraggle_util.f90 @@ -44,7 +44,11 @@ module subroutine fraggle_util_restructure(self, nbody_system, param, lfailure) new_fragments%Gmass(1) =sum(old_fragments%Gmass(1:2)) new_fragments%density(1) = new_fragments%mass(1) / volume new_fragments%radius(1) = (3._DP * volume / (4._DP * PI))**(THIRD) +#ifdef DOCONLOC + do concurrent(i = 1:NDIM) shared(old_fragments, new_fragments) +#else do concurrent(i = 1:NDIM) +#endif new_fragments%Ip(i,1) = sum(old_fragments%mass(1:2) * old_fragments%Ip(i,1:2)) end do new_fragments%Ip(:,1) = new_fragments%Ip(:,1) / new_fragments%mass(1) @@ -55,7 +59,11 @@ module subroutine fraggle_util_restructure(self, nbody_system, param, lfailure) new_fragments%Gmass(2:nnew) = old_fragments%Gmass(3:nold) new_fragments%density(2:nnew) = old_fragments%density(3:nold) new_fragments%radius(2:nnew) = old_fragments%radius(3:nold) +#ifdef DOCONLOC + do concurrent(i = 1:NDIM) shared(old_fragments,new_fragments) +#else do concurrent(i = 1:NDIM) +#endif new_fragments%Ip(i,2:nnew) = old_fragments%Ip(i,3:nold) end do new_fragments%origin_body(2:nnew) = old_fragments%origin_body(3:nold) @@ -87,10 +95,10 @@ module subroutine fraggle_util_set_mass_dist(self, param) class(collision_fraggle), intent(inout) :: self !! Fraggle collision system object class(swiftest_parameters), intent(in) :: param !! Current Swiftest run configuration parameters ! Internals - integer(I4B) :: i, j, k, jproj, jtarg, nfrag, istart, nfragmax, nrem + integer(I4B) :: i, j, jproj, jtarg, nfrag, istart, nfragmax real(DP), dimension(2) :: volume real(DP), dimension(NDIM) :: Ip_avg - real(DP) :: mremaining, mtot, mcumul, G, mass_noise, Mslr, x0, x1, ymid, y0, y1, y, yp, eps, Mrat + real(DP) :: mremaining, mtot, mcumul, G, mass_noise, Mslr, Mrat real(DP), dimension(:), allocatable :: mass real(DP) :: beta integer(I4B), parameter :: MASS_NOISE_FACTOR = 5 !! The number of digits of random noise that get added to the minimum mass value to prevent identical masses from being generated in a single run @@ -100,7 +108,6 @@ module subroutine fraggle_util_set_mass_dist(self, param) integer(I4B), parameter :: iMrem = 3 integer(I4B), parameter :: NFRAGMIN = iMrem + 2 !! Minimum number of fragments that can be generated integer(I4B), dimension(:), allocatable :: ind - integer(I4B), parameter :: MAXLOOP = 20 logical :: flipper logical, dimension(size(IEEE_ALL)) :: fpe_halting_modes @@ -166,7 +173,7 @@ module subroutine fraggle_util_set_mass_dist(self, param) mass(2) = impactors%mass_dist(iMslr) ! Recompute the slope parameter beta so that we span the complete size range - if (Mslr == min_mfrag) Mslr = Mslr + impactors%mass_dist(iMrem) / nfrag + if (abs(Mslr - min_mfrag) < epsilon(min_mfrag) * min_mfrag) Mslr = Mslr + impactors%mass_dist(iMrem) / nfrag mremaining = impactors%mass_dist(iMrem) ! The mass will be distributed in a power law where N>M=(M/Mslr)**(-beta/3) @@ -188,8 +195,8 @@ module subroutine fraggle_util_set_mass_dist(self, param) end if ! Sort the distribution in descending order by mass so that the largest fragment is always the first - call swiftest_util_sort(-mass, ind) - call swiftest_util_sort_rearrange(mass, ind, nfrag) + call util_sort(-mass, ind) + call util_sort_rearrange(mass, ind, nfrag) call move_alloc(mass, fragments%mass) fragments%Gmass(:) = G * fragments%mass(:) @@ -207,14 +214,18 @@ module subroutine fraggle_util_set_mass_dist(self, param) fragments%density(istart:nfrag) = fragments%mtot / sum(volume(:)) fragments%radius(istart:nfrag) = (3 * fragments%mass(istart:nfrag) / (4 * PI * fragments%density(istart:nfrag)))**(1.0_DP / 3.0_DP) +#ifdef DOCONLOC + do concurrent(i = istart:nfrag) shared(fragments,Ip_avg) +#else do concurrent(i = istart:nfrag) +#endif fragments%Ip(:, i) = Ip_avg(:) end do ! For catastrophic impacts, we will assign each of the n>2 fragments to one of the two original bodies so that the fragment cloud occupies ! roughly the same space as both original bodies. For all other disruption cases, we use body 2 as the center of the cloud. - fragments%origin_body(1) = 1 - fragments%origin_body(2) = 2 + fragments%origin_body(1) = 1_I1B + fragments%origin_body(2) = 2_I1B if (impactors%regime == COLLRESOLVE_REGIME_SUPERCATASTROPHIC) then mcumul = fragments%mass(1) flipper = .true. diff --git a/src/globals/globals_module.f90 b/src/globals/globals_module.f90 index fa6b18582..dd58d6dae 100644 --- a/src/globals/globals_module.f90 +++ b/src/globals/globals_module.f90 @@ -37,9 +37,12 @@ module globals real(DP), parameter :: GC = 6.6743E-11_DP !! Universal gravitational constant in SI units real(DP), parameter :: einsteinC = 299792458.0_DP !! Speed of light in SI units - integer(I4B), parameter :: LOWERCASE_BEGIN = iachar('a') !! ASCII character set parameter for lower to upper conversion - start of lowercase - integer(I4B), parameter :: LOWERCASE_END = iachar('z') !! ASCII character set parameter for lower to upper conversion - end of lowercase - integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper conversion - offset between upper and lower + integer(I4B), parameter :: LOWERCASE_BEGIN = iachar('a') !! ASCII character set parameter for lower to upper conversion - start + !! of lowercase + integer(I4B), parameter :: LOWERCASE_END = iachar('z') !! ASCII character set parameter for lower to upper conversion - end of + !! lowercase + integer(I4B), parameter :: UPPERCASE_OFFSET = iachar('A') - iachar('a') !! ASCII character set parameter for lower to upper + !! conversion - offset between upper and lower real(SP), parameter :: VERSION_NUMBER = 1.0_SP !! Swiftest version @@ -102,7 +105,13 @@ module globals !> Standard file names integer(I4B), parameter :: NDUMPFILES = 2 character(*), parameter :: PARAM_RESTART_FILE = "param.restart.in" - character(*), parameter :: SWIFTEST_LOG_FILE = "swiftest.log" !! Name of file to use to log output when using "COMPACT" display style +#ifdef COARRAY + character(STRMAX) :: SWIFTEST_LOG_FILE !! Name of file to use to log output when using "COMPACT" or + !! "PROGRESS" display style (each co-image gets its own log file) +#else + character(*), parameter :: SWIFTEST_LOG_FILE = "swiftest.log" !! Name of file to use to log output when using "COMPACT" or + !! "PROGRESS" display style +#endif integer(I4B), parameter :: SWIFTEST_LOG_OUT = 33 !! File unit for log file when using "COMPACT" display style !> Default file names that can be changed by the user in the parameters file @@ -113,7 +122,8 @@ module globals character(*), parameter :: BIN_OUTFILE = 'data.nc' integer(I4B), parameter :: BINUNIT = 20 !! File unit number for the binary output file integer(I4B), parameter :: PARTICLEUNIT = 44 !! File unit number for the binary particle info output file - integer(I4B), parameter :: LUN = 42 !! File unit number for files that are opened and closed within a single subroutine call, and therefore should not collide + integer(I4B), parameter :: LUN = 42 !! File unit number for files that are opened and closed within a single + !! subroutine call, and therefore should not collide !> Miscellaneous constants: integer(I4B), parameter :: NDIM = 3 !! Number of dimensions in our reality diff --git a/src/helio/helio_gr.f90 b/src/helio/helio_gr.f90 index 2092fca6a..6b43714b7 100644 --- a/src/helio/helio_gr.f90 +++ b/src/helio/helio_gr.f90 @@ -71,13 +71,18 @@ pure module subroutine helio_gr_p4_pl(self, nbody_system, param, dt) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: dt !! Step size ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl if (self%nbody == 0) return - associate(pl => self, npl => self%nbody) - do concurrent(i = 1:npl, pl%lmask(i)) - call swiftest_gr_p4_pos_kick(param, pl%rh(:, i), pl%vb(:, i), dt) + associate(lmask => self%lmask, rh => self%rh, vb => self%vb, inv_c2 => param%inv_c2) + npl = self%nbody +#ifdef DOCONLOC + do concurrent(i = 1:npl, lmask(i)) shared(inv_c2, lmask, rh, vb, dt) +#else + do concurrent(i = 1:npl, lmask(i)) +#endif + call swiftest_gr_p4_pos_kick(inv_c2, rh(1,i), rh(2,i), rh(3,i), vb(1,i), vb(2,i), vb(3,i), dt) end do end associate @@ -99,13 +104,18 @@ pure module subroutine helio_gr_p4_tp(self, nbody_system, param, dt) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: dt !! Step size ! Internals - integer(I4B) :: i + integer(I4B) :: i, ntp if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody) - do concurrent(i = 1:ntp, tp%lmask(i)) - call swiftest_gr_p4_pos_kick(param, tp%rh(:, i), tp%vb(:, i), dt) + associate(rh => self%rh, vb => self%vb, lmask => self%lmask, inv_c2 => param%inv_c2) + ntp = self%nbody +#ifdef DOCONLOC + do concurrent(i = 1:ntp, lmask(i)) shared(inv_c2, lmask, rh, vb, dt) +#else + do concurrent(i = 1:ntp, lmask(i)) +#endif + call swiftest_gr_p4_pos_kick(inv_c2, rh(1,i), rh(2,i), rh(3,i), vb(1,i), vb(2,i), vb(3,i), dt) end do end associate diff --git a/src/helio/helio_kick.f90 b/src/helio/helio_kick.f90 index 6fb4fad43..755a385d9 100644 --- a/src/helio/helio_kick.f90 +++ b/src/helio/helio_kick.f90 @@ -104,11 +104,12 @@ module subroutine helio_kick_vb_pl(self, nbody_system, param, t, dt, lbeg) real(DP), intent(in) :: dt !! Stepsize logical, intent(in) :: lbeg !! Logical flag indicating whether this is the beginning of the half step or not. ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl if (self%nbody == 0) return - associate(pl => self, npl => self%nbody) + associate(pl => self) + npl = self%nbody pl%ah(:, 1:npl) = 0.0_DP call pl%accel(nbody_system, param, t, lbeg) if (lbeg) then @@ -116,7 +117,11 @@ module subroutine helio_kick_vb_pl(self, nbody_system, param, t, dt, lbeg) else call pl%set_beg_end(rend = pl%rh) end if +#ifdef DOCONLOC + do concurrent(i = 1:npl, pl%lmask(i)) shared(pl,dt) +#else do concurrent(i = 1:npl, pl%lmask(i)) +#endif pl%vb(1, i) = pl%vb(1, i) + pl%ah(1, i) * dt pl%vb(2, i) = pl%vb(2, i) + pl%ah(2, i) * dt pl%vb(3, i) = pl%vb(3, i) + pl%ah(3, i) * dt @@ -143,14 +148,19 @@ module subroutine helio_kick_vb_tp(self, nbody_system, param, t, dt, lbeg) real(DP), intent(in) :: dt !! Stepsize logical, intent(in) :: lbeg !! Logical flag indicating whether this is the beginning of the half step or not. ! Internals - integer(I4B) :: i + integer(I4B) :: i, ntp if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody) + associate(tp => self) + ntp = self%nbody tp%ah(:, 1:ntp) = 0.0_DP call tp%accel(nbody_system, param, t, lbeg) +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp,dt) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%vb(:, i) = tp%vb(:, i) + tp%ah(:, i) * dt end do end associate diff --git a/src/helio/helio_module.f90 b/src/helio/helio_module.f90 index cd5581837..182512e53 100644 --- a/src/helio/helio_module.f90 +++ b/src/helio/helio_module.f90 @@ -165,10 +165,11 @@ module subroutine helio_kick_vb_tp(self, nbody_system, param, t, dt, lbeg) logical, intent(in) :: lbeg !! Logical flag indicating whether this is the beginning of the half step or not. end subroutine helio_kick_vb_tp - module subroutine helio_util_setup_initialize_system(self, param) + module subroutine helio_util_setup_initialize_system(self, system_history, param) implicit none - class(helio_nbody_system), intent(inout) :: self !! Helio nbody system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(helio_nbody_system), intent(inout) :: self !! Helio nbody system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine helio_util_setup_initialize_system module subroutine helio_step_pl(self, nbody_system, param, t, dt) diff --git a/src/helio/helio_util.f90 b/src/helio/helio_util.f90 index 94b464502..bb032defb 100644 --- a/src/helio/helio_util.f90 +++ b/src/helio/helio_util.f90 @@ -11,17 +11,18 @@ use swiftest contains - module subroutine helio_util_setup_initialize_system(self, param) + module subroutine helio_util_setup_initialize_system(self, system_history, param) !! author: David A. Minton !! !! Initialize a Helio nbody system from files, converting all heliocentric quantities to barycentric. !! implicit none ! Arguments - class(helio_nbody_system), intent(inout) :: self !! Helio nbody system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(helio_nbody_system), intent(inout) :: self !! Helio nbody system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - call swiftest_util_setup_initialize_system(self, param) + call swiftest_util_setup_initialize_system(self, system_history, param) call self%pl%sort("mass", ascending=.false.) call self%pl%vh2vb(self%cb) call self%tp%h2b(self%cb) diff --git a/src/misc/solver_module.f90 b/src/misc/solver_module.f90 index 410116b2a..872db6428 100644 --- a/src/misc/solver_module.f90 +++ b/src/misc/solver_module.f90 @@ -16,7 +16,7 @@ module solver use lambda_function use, intrinsic :: ieee_exceptions private - public :: solve_linear_system, solve_rkf45, solve_roots + public :: solve_linear_system, solve_roots !, solve_rkf45 interface solve_linear_system module procedure solve_linear_system_dp @@ -424,22 +424,25 @@ end function f ! returns the minimum of two real numbers real(DP) Function Minimum(x1,x2) real(DP) x1,x2,resultat + if (x1 < x2) then - resultat = x1 + resultat = x1 else - resultat = x2 + resultat = x2 endif + Minimum = resultat end function Minimum ! TRUE if x1*x2 negative - integer Function RootBracketed(x1,x2) + logical Function RootBracketed(x1,x2) real(DP) x1,x2 - integer resultat + logical resultat + if ((x1 > 0.and.x2 > 0).or.(x1 < 0.and.x2 < 0)) then - resultat = 0 + resultat = .false. else - resultat = 1 + resultat = .true. endif RootBracketed = resultat end function RootBracketed diff --git a/src/netcdf_io/netcdf_io_implementations.f90 b/src/netcdf_io/netcdf_io_implementations.f90 index c59acd0fc..b4e7f0b12 100644 --- a/src/netcdf_io/netcdf_io_implementations.f90 +++ b/src/netcdf_io/netcdf_io_implementations.f90 @@ -37,9 +37,16 @@ module subroutine netcdf_io_close(self) implicit none ! Arguments class(netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset + character(namelen) :: message if (self%lfile_is_open) then - call netcdf_io_check( nf90_close(self%id), "netcdf_io_close" ) +#ifdef COARRAY + write(message,*) this_image() + message = "netcdf_io_close on image " // trim(adjustl(message)) +#else + message = "netcdf_io_close" +#endif + call netcdf_io_check( nf90_close(self%id), message) self%lfile_is_open = .false. end if @@ -52,6 +59,8 @@ module subroutine netcdf_io_find_tslot(self, t, tslot) !! !! Given an open NetCDF file and a value of time t, finds the index of the time value (aka the time slot) to place a new set of data. !! The returned value of tslot will correspond to the first index value where the value of t is greater than or equal to the saved time value. + use, intrinsic :: ieee_exceptions + use, intrinsic :: ieee_arithmetic implicit none ! Arguments class(netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset @@ -59,7 +68,11 @@ module subroutine netcdf_io_find_tslot(self, t, tslot) integer(I4B), intent(out) :: tslot !! The index of the time slot where this data belongs ! Internals real(DP), dimension(:), allocatable :: tvals + integer(I4B) :: i + logical, dimension(size(IEEE_ALL)) :: fpe_halting_modes + call ieee_get_halting_mode(IEEE_ALL,fpe_halting_modes) ! Save the current halting modes so we can turn them off temporarily + call ieee_set_halting_mode(IEEE_ALL,.false.) if (.not.self%lfile_is_open) return tslot = 0 @@ -68,16 +81,23 @@ module subroutine netcdf_io_find_tslot(self, t, tslot) if (self%max_tslot > 0) then allocate(tvals(self%max_tslot)) call netcdf_io_check( nf90_get_var(self%id, self%time_varid, tvals(:), start=[1]), "netcdf_io_find_tslot get_var" ) + where(.not.ieee_is_normal(tvals(:))) tvals(:) = huge(1.0_DP) else allocate(tvals(1)) - tvals(1) = -huge(1.0_DP) + tvals(1) = huge(1.0_DP) + self%max_tslot = 1 end if - tslot = findloc(tvals, t, dim=1) - if (tslot == 0) tslot = self%max_tslot + 1 + tslot = 1 + do i = 1, self%max_tslot + if (t <= tvals(tslot)) exit + tslot = tslot + 1 + end do self%max_tslot = max(self%max_tslot, tslot) self%tslot = tslot + call ieee_set_halting_mode(IEEE_ALL,fpe_halting_modes) + return end subroutine netcdf_io_find_tslot @@ -99,16 +119,16 @@ module subroutine netcdf_io_find_idslot(self, id, idslot) if (.not.allocated(self%idvals)) call self%get_idvals() self%max_idslot = size(self%idvals) - idslot = findloc(self%idvals, id, dim=1) - if (idslot == 0) then - self%max_idslot = self%max_idslot + 1 - idslot = self%max_idslot + idslot = id + 1 + if (idslot > self%max_idslot) then ! Update the idvals array allocate(idvals(idslot)) - idvals(1:idslot-1) = self%idvals(1:idslot-1) + idvals(:) = NF90_FILL_INT + idvals(1:self%max_idslot) = self%idvals(1:self%max_idslot) idvals(idslot) = id call move_alloc(idvals, self%idvals) + self%max_idslot = idslot end if self%idslot = idslot diff --git a/src/operator/operator_cross.f90 b/src/operator/operator_cross.f90 index f784a1c98..72c24a176 100644 --- a/src/operator/operator_cross.f90 +++ b/src/operator/operator_cross.f90 @@ -104,7 +104,7 @@ pure module function operator_cross_el_sp(A, B) result(C) n = size(A, 2) if (allocated(C)) deallocate(C) allocate(C, mold = A) - do concurrent (i = 1:n) + do i = 1,n C(:,i) = operator_cross_sp(A(:,i), B(:,i)) end do return @@ -118,7 +118,7 @@ pure module function operator_cross_el_dp(A, B) result(C) n = size(A, 2) if (allocated(C)) deallocate(C) allocate(C, mold = A) - do concurrent (i = 1:n) + do i = 1,n C(:,i) = operator_cross_dp(A(:,i), B(:,i)) end do return @@ -132,7 +132,7 @@ pure module function operator_cross_el_qp(A, B) result(C) n = size(A, 2) if (allocated(C)) deallocate(C) allocate(C, mold = A) - do concurrent (i = 1:n) + do i = 1,n C(:,i) = operator_cross_qp(A(:,i), B(:,i)) end do return @@ -146,7 +146,7 @@ pure module function operator_cross_el_i1b(A, B) result(C) n = size(A, 2) if (allocated(C)) deallocate(C) allocate(C, mold = A) - do concurrent (i = 1:n) + do i = 1,n C(:,i) = operator_cross_i1b(A(:,i), B(:,i)) end do return @@ -160,7 +160,7 @@ pure module function operator_cross_el_i2b(A, B) result(C) n = size(A, 2) if (allocated(C)) deallocate(C) allocate(C, mold = A) - do concurrent (i = 1:n) + do i = 1,n C(:,i) = operator_cross_i2b(A(:,i), B(:,i)) end do return @@ -174,7 +174,7 @@ pure module function operator_cross_el_i4b(A, B) result(C) n = size(A, 2) if (allocated(C)) deallocate(C) allocate(C, mold = A) - do concurrent (i = 1:n) + do i = 1,n C(:,i) = operator_cross_i4b(A(:,i), B(:,i)) end do return @@ -188,7 +188,7 @@ pure module function operator_cross_el_i8b(A, B) result(C) n = size(A, 2) if (allocated(C)) deallocate(C) allocate(C, mold = A) - do concurrent (i = 1:n) + do i = 1,n C(:,i) = operator_cross_i8b(A(:,i), B(:,i)) end do return diff --git a/src/operator/operator_mag.f90 b/src/operator/operator_mag.f90 index 8bf6bff5b..721e4a930 100644 --- a/src/operator/operator_mag.f90 +++ b/src/operator/operator_mag.f90 @@ -44,7 +44,7 @@ pure module function operator_mag_el_sp(A) result(B) if (allocated(B)) deallocate(B) allocate(B(n)) call ieee_set_halting_mode(ieee_underflow, .false.) - do concurrent (i=1:n) + do i = 1,n B(i) = norm2(A(:, i)) end do return @@ -59,7 +59,7 @@ pure module function operator_mag_el_dp(A) result(B) if (allocated(B)) deallocate(B) allocate(B(n)) call ieee_set_halting_mode(ieee_underflow, .false.) - do concurrent (i=1:n) + do i = 1,n B(i) = norm2(A(:, i)) end do return @@ -74,7 +74,7 @@ pure module function operator_mag_el_qp(A) result(B) if (allocated(B)) deallocate(B) allocate(B(n)) call ieee_set_halting_mode(ieee_underflow, .false.) - do concurrent (i=1:n) + do i = 1,n B(i) = norm2(A(:, i)) end do return diff --git a/src/operator/operator_unit.f90 b/src/operator/operator_unit.f90 index 39f3fce53..2a14f6645 100644 --- a/src/operator/operator_unit.f90 +++ b/src/operator/operator_unit.f90 @@ -89,7 +89,7 @@ pure module function operator_unit_el_sp(A) result(B) if (allocated(B)) deallocate(B) allocate(B(NDIM,n)) - do concurrent (i=1:n) + do i=1,n B(:,i) = operator_unit_sp(A(:,i)) end do @@ -109,7 +109,7 @@ pure module function operator_unit_el_dp(A) result(B) if (allocated(B)) deallocate(B) allocate(B(NDIM,n)) - do concurrent (i=1:n) + do i=1,n B(:,i) = operator_unit_dp(A(:,i)) end do @@ -128,7 +128,7 @@ pure module function operator_unit_el_qp(A) result(B) if (allocated(B)) deallocate(B) allocate(B(NDIM,n)) - do concurrent (i=1:n) + do i=1,n B(:,i) = operator_unit_qp(A(:,i)) end do diff --git a/src/rmvs/rmvs_coarray.f90 b/src/rmvs/rmvs_coarray.f90 new file mode 100644 index 000000000..3a7508159 --- /dev/null +++ b/src/rmvs/rmvs_coarray.f90 @@ -0,0 +1,169 @@ +!! Copyright 2023 - David Minton +!! This file is part of Swiftest. +!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +!! You should have received a copy of the GNU General Public License along with Swiftest. +!! If not, see: https://www.gnu.org/licenses. + +submodule (rmvs) s_rmvs_coarray +use coarray +use swiftest +use whm +contains + + module subroutine rmvs_coarray_coclone_cb(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(rmvs_cb),intent(inout),codimension[*] :: self !! RMVS pl object + + call coclone(self%outer) + call coclone(self%inner) + call coclone(self%lplanetocentric) + + call swiftest_coarray_coclone_cb(self) + + return + end subroutine rmvs_coarray_coclone_cb + + + module subroutine rmvs_coarray_coclone_interp(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(rmvs_interp),intent(inout),codimension[*] :: self !! RMVS pl object + + call coclone(self%x) + call coclone(self%v) + call coclone(self%aobl) + call coclone(self%atide) + + return + end subroutine rmvs_coarray_coclone_interp + + + module subroutine rmvs_coarray_coclone_pl(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(rmvs_pl),intent(inout),codimension[*] :: self !! RMVS pl object + + call coclone(self%nenc) + call coclone(self%tpenc1P) + call coclone(self%plind) + call coclone(self%outer) + call coclone(self%lplanetocentric) + + call whm_coarray_coclone_pl(self) + + return + end subroutine rmvs_coarray_coclone_pl + + + module subroutine rmvs_coarray_coclone_system(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(rmvs_nbody_system),intent(inout),codimension[*] :: self !! Swiftest body object + ! Internals + integer(I4B) :: i, img + + call coclone(self%lplanetocentric) + call coclone(self%rts) + call coclone(self%vbeg) + + call swiftest_coarray_coclone_system(self) + + return + end subroutine rmvs_coarray_coclone_system + + + module subroutine rmvs_coarray_coclone_tp(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(rmvs_tp),intent(inout),codimension[*] :: self !! RMVS pl object + + call coclone(self%lperi) + call coclone(self%plperP) + call coclone(self%plencP) + call coclone(self%index) + call coclone(self%ipleP) + call coclone(self%lplanetocentric) + + call swiftest_coarray_coclone_tp(self) + + return + end subroutine rmvs_coarray_coclone_tp + + + module subroutine rmvs_coarray_component_clone_interp_arr1D(var,src_img) + implicit none + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! swiftest_particle_info scalar version + ! Arguments + type(rmvs_interp), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + type(rmvs_interp), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: i,img, si + integer(I4B), save :: n[*] + logical, save :: isalloc[*] + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + sync all + isalloc = allocated(var) + if (isalloc) n = size(var) + sync all + if (.not. isalloc[si]) return + + allocate(tmp(n[si])[*]) + do i = 1, n[si] + call tmp(i)%coclone() + end do + if (this_image() /= si) then + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + + return + end subroutine rmvs_coarray_component_clone_interp_arr1D + + + module subroutine rmvs_coarray_cocollect_tp(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(rmvs_tp),intent(inout),codimension[*] :: self !! RMVS pl object + + call cocollect(self%lperi) + call cocollect(self%plperP) + call cocollect(self%plencP) + + call swiftest_coarray_cocollect_tp(self) + + return + end subroutine rmvs_coarray_cocollect_tp + +end submodule s_rmvs_coarray \ No newline at end of file diff --git a/src/rmvs/rmvs_discard.f90 b/src/rmvs/rmvs_discard.f90 index 7e0cb9905..bb6c3063e 100644 --- a/src/rmvs/rmvs_discard.f90 +++ b/src/rmvs/rmvs_discard.f90 @@ -54,6 +54,9 @@ module subroutine rmvs_discard_tp(self, nbody_system, param) call swiftest_discard_tp(tp, nbody_system, param) end associate + + return + end subroutine rmvs_discard_tp end submodule s_rmvs_discard \ No newline at end of file diff --git a/src/rmvs/rmvs_kick.f90 b/src/rmvs/rmvs_kick.f90 index 7d113f863..82d19463e 100644 --- a/src/rmvs/rmvs_kick.f90 +++ b/src/rmvs/rmvs_kick.f90 @@ -29,11 +29,13 @@ module subroutine rmvs_kick_getacch_tp(self, nbody_system, param, t, lbeg) class(swiftest_parameters), allocatable :: param_planetocen real(DP), dimension(:, :), allocatable :: rh_original real(DP) :: GMcb_original - integer(I4B) :: i + integer(I4B) :: i, ntp, inner_index if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody, ipleP => self%ipleP, inner_index => self%index) + associate(tp => self, ipleP => self%ipleP) + ntp = self%nbody + inner_index = self%index select type(nbody_system) class is (rmvs_nbody_system) if (nbody_system%lplanetocentric) then ! This is a close encounter step, so any accelerations requiring heliocentric position values @@ -59,17 +61,29 @@ module subroutine rmvs_kick_getacch_tp(self, nbody_system, param, t, lbeg) ! Now compute any heliocentric values of acceleration if (tp%lfirst) then +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%rheliocentric(:,i) = tp%rh(:,i) + cb%inner(inner_index - 1)%x(:,1) end do else +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%rheliocentric(:,i) = tp%rh(:,i) + cb%inner(inner_index )%x(:,1) end do end if ! Swap the planetocentric and heliocentric position vectors and central body masses +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%rh(:, i) = tp%rheliocentric(:, i) end do GMcb_original = cb%Gmass diff --git a/src/rmvs/rmvs_module.f90 b/src/rmvs/rmvs_module.f90 index 733a81e60..b219fd01b 100644 --- a/src/rmvs/rmvs_module.f90 +++ b/src/rmvs/rmvs_module.f90 @@ -35,6 +35,9 @@ module rmvs procedure :: dealloc => rmvs_util_dealloc_system !! Performs RMVS-specific deallocation procedure :: initialize => rmvs_util_setup_initialize_system !! Performs RMVS-specific initilization steps, including generating the close encounter planetocentric structures procedure :: step => rmvs_step_system !! Advance the RMVS nbody system forward in time by one step +#ifdef COARRAY + procedure :: coclone => rmvs_coarray_coclone_system !! Clones the image 1 body object to all other images in the coarray structure. +#endif end type rmvs_nbody_system type, private :: rmvs_interp @@ -45,6 +48,9 @@ module rmvs contains procedure :: dealloc => rmvs_util_dealloc_interp !! Deallocates all allocatable arrays final :: rmvs_final_interp !! Finalizes the RMVS interpolated nbody_system variables object - deallocates all allocatables +#ifdef COARRAY + procedure :: coclone => rmvs_coarray_coclone_interp +#endif end type rmvs_interp @@ -56,6 +62,9 @@ module rmvs contains procedure :: dealloc => rmvs_util_dealloc_cb !! Deallocates all allocatable arrays final :: rmvs_final_cb !! Finalizes the RMVS central body object - deallocates all allocatables +#ifdef COARRAY + procedure :: coclone => rmvs_coarray_coclone_cb !! Clones the image 1 body object to all other images in the coarray structure. +#endif end type rmvs_cb @@ -88,6 +97,10 @@ module rmvs procedure :: rearrange => rmvs_util_sort_rearrange_tp !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods procedure :: spill => rmvs_util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) final :: rmvs_final_tp !! Finalizes the RMVS test particle object - deallocates all allocatables +#ifdef COARRAY + procedure :: coclone => rmvs_coarray_coclone_tp !! Clones the image 1 body object to all other images in the coarray structure. + procedure :: cocollect => rmvs_coarray_cocollect_tp !! Clones the image 1 body object to all other images in the coarray structure. +#endif end type rmvs_tp @@ -101,7 +114,7 @@ module rmvs class(rmvs_nbody_system), dimension(:), allocatable :: planetocentric !! Planetocentric version of the massive body objects (one for each massive body) logical :: lplanetocentric = .false. !! Flag that indicates that the object is a planetocentric set of masive bodies used for close encounter calculations contains - procedure :: setup => rmvs_util_setup_pl !! Constructor method - Allocates space for the input number of bodiess + procedure :: setup => rmvs_util_setup_pl !! Constructor method - Allocates space for the input number of bodiess procedure :: append => rmvs_util_append_pl !! Appends elements from one structure to another procedure :: dealloc => rmvs_util_dealloc_pl !! Deallocates all allocatable arrays procedure :: fill => rmvs_util_fill_pl !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic) @@ -109,7 +122,10 @@ module rmvs procedure :: sort => rmvs_util_sort_pl !! Sorts body arrays by a sortable componen procedure :: rearrange => rmvs_util_sort_rearrange_pl !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods procedure :: spill => rmvs_util_spill_pl !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) - final :: rmvs_final_pl !! Finalizes the RMVS massive body object - deallocates all allocatables + final :: rmvs_final_pl !! Finalizes the RMVS massive body object - deallocates all allocatables +#ifdef COARRAY + procedure :: coclone => rmvs_coarray_coclone_pl !! Clones the image 1 body object to all other images in the coarray structure. +#endif end type rmvs_pl interface @@ -145,10 +161,11 @@ module subroutine rmvs_util_setup_pl(self, n, param) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine rmvs_util_setup_pl - module subroutine rmvs_util_setup_initialize_system(self, param) + module subroutine rmvs_util_setup_initialize_system(self, system_history, param) implicit none - class(rmvs_nbody_system), intent(inout) :: self !! RMVS system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(rmvs_nbody_system), intent(inout) :: self !! RMVS system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine rmvs_util_setup_initialize_system module subroutine rmvs_util_setup_tp(self, n, param) @@ -275,6 +292,51 @@ end subroutine rmvs_step_system end interface + +#ifdef COARRAY + interface coclone + module subroutine rmvs_coarray_component_clone_interp_arr1D(var,src_img) + implicit none + type(rmvs_interp), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine rmvs_coarray_component_clone_interp_arr1D + end interface + + interface cocollect + module subroutine rmvs_coarray_cocollect_tp(self) + implicit none + class(rmvs_tp),intent(inout),codimension[*] :: self !! RMVS pl object + end subroutine rmvs_coarray_cocollect_tp + end interface + + interface + module subroutine rmvs_coarray_coclone_cb(self) + implicit none + class(rmvs_cb),intent(inout),codimension[*] :: self !! RMVS tp object + end subroutine rmvs_coarray_coclone_cb + + module subroutine rmvs_coarray_coclone_interp(self) + implicit none + class(rmvs_interp),intent(inout),codimension[*] :: self !! RMVS tp object + end subroutine rmvs_coarray_coclone_interp + + module subroutine rmvs_coarray_coclone_pl(self) + implicit none + class(rmvs_pl),intent(inout),codimension[*] :: self !! RMVS pl object + end subroutine rmvs_coarray_coclone_pl + + module subroutine rmvs_coarray_coclone_system(self) + implicit none + class(rmvs_nbody_system),intent(inout),codimension[*] :: self !! RMVS nbody system object + end subroutine rmvs_coarray_coclone_system + + module subroutine rmvs_coarray_coclone_tp(self) + implicit none + class(rmvs_tp),intent(inout),codimension[*] :: self !! RMVS tp object + end subroutine rmvs_coarray_coclone_tp + end interface +#endif + contains subroutine rmvs_final_cb(self) diff --git a/src/rmvs/rmvs_step.f90 b/src/rmvs/rmvs_step.f90 index bcb38797a..4a5dcf3af 100644 --- a/src/rmvs/rmvs_step.f90 +++ b/src/rmvs/rmvs_step.f90 @@ -202,6 +202,10 @@ subroutine rmvs_step_out(cb, pl, tp, nbody_system, param, t, dt) call tp%step(nbody_system, param, outer_time, dto) tp%lfirst = lfirsttp else + if (param%loblatecb) then + call swiftest_obl_acc(npl, cb%Gmass, cb%j2rp2, cb%j4rp4, pl%rbeg, pl%lmask, pl%outer(outer_index-1)%aobl, pl%Gmass, cb%aoblbeg) + call swiftest_obl_acc(npl, cb%Gmass, cb%j2rp2, cb%j4rp4, pl%rend, pl%lmask, pl%outer(outer_index)%aobl, pl%Gmass, cb%aoblend) + end if call tp%step(nbody_system, param, outer_time, dto) end if do j = 1, npl @@ -537,9 +541,8 @@ subroutine rmvs_peri_tp(tp, pl, t, dt, lfirst, inner_index, ipleP, param) integer(I4B), intent(in) :: ipleP !! index of RMVS planet being closely encountered class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i, id1, id2 - real(DP) :: r2, mu, rhill2, vdotr, a, peri, capm, tperi, rpl - real(DP), dimension(NDIM) :: rh1, rh2, vh1, vh2 + integer(I4B) :: i + real(DP) :: r2, mu, rhill2, vdotr, a, peri, capm, tperi rhill2 = pl%rhill(ipleP)**2 mu = pl%Gmass(ipleP) diff --git a/src/rmvs/rmvs_util.f90 b/src/rmvs/rmvs_util.f90 index b9462840b..6b26bf12f 100644 --- a/src/rmvs/rmvs_util.f90 +++ b/src/rmvs/rmvs_util.f90 @@ -24,19 +24,17 @@ module subroutine rmvs_util_append_pl(self, source, lsource_mask) select type(source) class is (rmvs_pl) - associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%nenc, source%nenc, nold, nsrc, lsource_mask) - call swiftest_util_append(self%tpenc1P, source%tpenc1P, nold, nsrc, lsource_mask) - call swiftest_util_append(self%plind, source%plind, nold, nsrc, lsource_mask) + call util_append(self%nenc, source%nenc, lsource_mask=lsource_mask) + call util_append(self%tpenc1P, source%tpenc1P, lsource_mask=lsource_mask) + call util_append(self%plind, source%plind, lsource_mask=lsource_mask) - ! The following are not implemented as RMVS doesn't make use of fill operations on pl type - ! So they are here as a placeholder in case someone wants to extend the RMVS class for some reason - !call swiftest_util_append(self%outer, source%outer, nold, nsrc, lsource_mask) - !call swiftest_util_append(self%inner, source%inner, nold, nsrc, lsource_mask) - !call swiftest_util_append(self%planetocentric, source%planetocentric, nold, nsrc, lsource_mask) + ! The following are not implemented as RMVS doesn't make use of fill operations on pl type + ! So they are here as a placeholder in case someone wants to extend the RMVS class for some reason + !call util_append(self%outer, source%outer, lsource_mask=lsource_mask) + !call util_append(self%inner, source%inner, lsource_mask=lsource_mask) + !call util_append(self%planetocentric, source%planetocentric, lsource_mask) - call whm_util_append_pl(self, source, lsource_mask) - end associate + call whm_util_append_pl(self, source, lsource_mask) class default write(*,*) "Invalid object passed to the append method. Source must be of class rmvs_pl or its descendents!" call base_util_exit(FAILURE) @@ -59,13 +57,11 @@ module subroutine rmvs_util_append_tp(self, source, lsource_mask) select type(source) class is (rmvs_tp) - associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%lperi, source%lperi, nold, nsrc, lsource_mask) - call swiftest_util_append(self%plperP, source%plperP, nold, nsrc, lsource_mask) - call swiftest_util_append(self%plencP, source%plencP, nold, nsrc, lsource_mask) + call util_append(self%lperi, source%lperi, lsource_mask=lsource_mask) + call util_append(self%plperP, source%plperP, lsource_mask=lsource_mask) + call util_append(self%plencP, source%plencP, lsource_mask=lsource_mask) - call swiftest_util_append_tp(self, source, lsource_mask) ! Note: whm_tp does not have its own append method, so we skip back to the base class - end associate + call swiftest_util_append_tp(self, source, lsource_mask) ! Note: whm_tp does not have its own append method, so we skip back to the base class class default write(*,*) "Invalid object passed to the append method. Source must be of class rmvs_tp or its descendents!" call base_util_exit(FAILURE) @@ -177,15 +173,15 @@ module subroutine rmvs_util_fill_pl(self, inserts, lfill_list) associate(keeps => self) select type(inserts) class is (rmvs_pl) - call swiftest_util_fill(keeps%nenc, inserts%nenc, lfill_list) - call swiftest_util_fill(keeps%tpenc1P, inserts%tpenc1P, lfill_list) - call swiftest_util_fill(keeps%plind, inserts%plind, lfill_list) + call util_fill(keeps%nenc, inserts%nenc, lfill_list) + call util_fill(keeps%tpenc1P, inserts%tpenc1P, lfill_list) + call util_fill(keeps%plind, inserts%plind, lfill_list) ! The following are not implemented as RMVS doesn't make use of fill operations on pl type ! So they are here as a placeholder in case someone wants to extend the RMVS class for some reason - !call swiftest_util_fill(keeps%outer, inserts%outer, lfill_list) - !call swiftest_util_fill(keeps%inner, inserts%inner, lfill_list) - !call swiftest_util_fill(keeps%planetocentric, inserts%planetocentric, lfill_list) + !call util_fill(keeps%outer, inserts%outer, lfill_list) + !call util_fill(keeps%inner, inserts%inner, lfill_list) + !call util_fill(keeps%planetocentric, inserts%planetocentric, lfill_list) call whm_util_fill_pl(keeps, inserts, lfill_list) class default @@ -213,9 +209,9 @@ module subroutine rmvs_util_fill_tp(self, inserts, lfill_list) associate(keeps => self) select type(inserts) class is (rmvs_tp) - call swiftest_util_fill(keeps%lperi, inserts%lperi, lfill_list) - call swiftest_util_fill(keeps%plperP, inserts%plperP, lfill_list) - call swiftest_util_fill(keeps%plencP, inserts%plencP, lfill_list) + call util_fill(keeps%lperi, inserts%lperi, lfill_list) + call util_fill(keeps%plperP, inserts%plperP, lfill_list) + call util_fill(keeps%plencP, inserts%plencP, lfill_list) call swiftest_util_fill_tp(keeps, inserts, lfill_list) ! Note: whm_tp does not have its own fill method, so we skip back to the base class class default @@ -237,15 +233,15 @@ module subroutine rmvs_util_resize_pl(self, nnew) class(rmvs_pl), intent(inout) :: self !! RMVS massive body object integer(I4B), intent(in) :: nnew !! New size neded - call swiftest_util_resize(self%nenc, nnew) - call swiftest_util_resize(self%tpenc1P, nnew) - call swiftest_util_resize(self%plind, nnew) + call util_resize(self%nenc, nnew) + call util_resize(self%tpenc1P, nnew) + call util_resize(self%plind, nnew) ! The following are not implemented as RMVS doesn't make use of resize operations on pl type ! So they are here as a placeholder in case someone wants to extend the RMVS class for some reason - !call swiftest_util_resize(self%outer, nnew) - !call swiftest_util_resize(self%inner, nnew) - !call swiftest_util_resize(self%planetocentric, nnew) + !call util_resize(self%outer, nnew) + !call util_resize(self%inner, nnew) + !call util_resize(self%planetocentric, nnew) call whm_util_resize_pl(self, nnew) return @@ -261,10 +257,10 @@ module subroutine rmvs_util_resize_tp(self, nnew) class(rmvs_tp), intent(inout) :: self !! RMVS test particle object integer(I4B), intent(in) :: nnew !! New size neded - call swiftest_util_resize(self%lperi, nnew) - call swiftest_util_resize(self%plperP, nnew) - call swiftest_util_resize(self%plencP, nnew) - call swiftest_util_resize(self%rheliocentric, nnew) + call util_resize(self%lperi, nnew) + call util_resize(self%plperP, nnew) + call util_resize(self%plencP, nnew) + call util_resize(self%rheliocentric, nnew) call swiftest_util_resize_tp(self, nnew) @@ -302,13 +298,15 @@ module subroutine rmvs_util_setup_pl(self, n, param) allocate(pl%outer(i)%v(NDIM, n)) pl%outer(i)%x(:,:) = 0.0_DP pl%outer(i)%v(:,:) = 0.0_DP + allocate(pl%outer(i)%aobl(NDIM, n)) + pl%outer(i)%aobl(:,:) = 0.0_DP end do do i = 0, NTPHENC allocate(pl%inner(i)%x(NDIM, n)) allocate(pl%inner(i)%v(NDIM, n)) - allocate(pl%inner(i)%aobl(NDIM, n)) pl%inner(i)%x(:,:) = 0.0_DP pl%inner(i)%v(:,:) = 0.0_DP + allocate(pl%inner(i)%aobl(NDIM, n)) pl%inner(i)%aobl(:,:) = 0.0_DP end do ! if (param%ltides) then @@ -323,7 +321,7 @@ module subroutine rmvs_util_setup_pl(self, n, param) end subroutine rmvs_util_setup_pl - module subroutine rmvs_util_setup_initialize_system(self, param) + module subroutine rmvs_util_setup_initialize_system(self, system_history, param) !! author: David A. Minton !! !! Initialize an RMVS nbody system from files and sets up the planetocentric structures. @@ -335,13 +333,14 @@ module subroutine rmvs_util_setup_initialize_system(self, param) !! to use during close encounters. implicit none ! Arguments - class(rmvs_nbody_system), intent(inout) :: self !! RMVS system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(rmvs_nbody_system), intent(inout) :: self !! RMVS system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals integer(I4B) :: i, j ! Call parent method - call whm_util_setup_initialize_system(self, param) + call whm_util_setup_initialize_system(self, system_history, param) ! Set up the pl-tp planetocentric encounter structures for pl and cb. The planetocentric tp structures are ! generated as necessary during close encounter steps. @@ -413,11 +412,13 @@ module subroutine rmvs_util_setup_tp(self, n, param) call self%whm_tp%setup(n, param) if (n <= 0) return - allocate(self%lperi(n)) - allocate(self%plperP(n)) - allocate(self%plencP(n)) + if (allocated(self%lperi)) deallocate(self%lperi); allocate(self%lperi(n)) + if (allocated(self%plperP)) deallocate(self%plperP); allocate(self%plperP(n)) + if (allocated(self%plencP)) deallocate(self%plencP); allocate(self%plencP(n)) - if (self%lplanetocentric) allocate(self%rheliocentric(NDIM, n)) + if (self%lplanetocentric) then + if (allocated(self%rheliocentric)) deallocate(self%rheliocentric); allocate(self%rheliocentric(NDIM, n)) + end if self%lperi(:) = .false. @@ -450,11 +451,11 @@ module subroutine rmvs_util_sort_pl(self, sortby, ascending) associate(pl => self, npl => self%nbody) select case(sortby) case("nenc") - call swiftest_util_sort(direction * pl%nenc(1:npl), ind) + call util_sort(direction * pl%nenc(1:npl), ind) case("tpenc1P") - call swiftest_util_sort(direction * pl%tpenc1P(1:npl), ind) + call util_sort(direction * pl%tpenc1P(1:npl), ind) case("plind") - call swiftest_util_sort(direction * pl%plind(1:npl), ind) + call util_sort(direction * pl%plind(1:npl), ind) case("outer", "inner", "planetocentric", "lplanetocentric") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default ! Look for components in the parent class @@ -494,9 +495,9 @@ module subroutine rmvs_util_sort_tp(self, sortby, ascending) associate(tp => self, ntp => self%nbody) select case(sortby) case("plperP") - call swiftest_util_sort(direction * tp%plperP(1:ntp), ind) + call util_sort(direction * tp%plperP(1:ntp), ind) case("plencP") - call swiftest_util_sort(direction * tp%plencP(1:ntp), ind) + call util_sort(direction * tp%plencP(1:ntp), ind) case("lperi", "cb_heliocentric", "rheliocentric", "index", "ipleP", "lplanetocentric") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default ! Look for components in the parent class (*NOTE whm_tp does not need its own sort method, so we go straight to the swiftest_tp method) @@ -523,9 +524,9 @@ module subroutine rmvs_util_sort_rearrange_pl(self, ind) if (self%nbody == 0) return associate(pl => self, npl => self%nbody) - call swiftest_util_sort_rearrange(pl%nenc, ind, npl) - call swiftest_util_sort_rearrange(pl%tpenc1P, ind, npl) - call swiftest_util_sort_rearrange(pl%plind, ind, npl) + call util_sort_rearrange(pl%nenc, ind, npl) + call util_sort_rearrange(pl%tpenc1P, ind, npl) + call util_sort_rearrange(pl%plind, ind, npl) call swiftest_util_sort_rearrange_pl(pl,ind) end associate @@ -546,10 +547,10 @@ module subroutine rmvs_util_sort_rearrange_tp(self, ind) if (self%nbody == 0) return associate(tp => self, ntp => self%nbody) - call swiftest_util_sort_rearrange(tp%lperi, ind, ntp) - call swiftest_util_sort_rearrange(tp%plperP, ind, ntp) - call swiftest_util_sort_rearrange(tp%plencP, ind, ntp) - call swiftest_util_sort_rearrange(tp%rheliocentric, ind, ntp) + call util_sort_rearrange(tp%lperi, ind, ntp) + call util_sort_rearrange(tp%plperP, ind, ntp) + call util_sort_rearrange(tp%plencP, ind, ntp) + call util_sort_rearrange(tp%rheliocentric, ind, ntp) call swiftest_util_sort_rearrange_tp(tp,ind) end associate @@ -573,9 +574,9 @@ module subroutine rmvs_util_spill_pl(self, discards, lspill_list, ldestructive) associate(keeps => self) select type(discards) class is (rmvs_pl) - call swiftest_util_spill(keeps%nenc, discards%nenc, lspill_list, ldestructive) - call swiftest_util_spill(keeps%tpenc1P, discards%tpenc1P, lspill_list, ldestructive) - call swiftest_util_spill(keeps%plind, discards%plind, lspill_list, ldestructive) + call util_spill(keeps%nenc, discards%nenc, lspill_list, ldestructive) + call util_spill(keeps%tpenc1P, discards%tpenc1P, lspill_list, ldestructive) + call util_spill(keeps%plind, discards%plind, lspill_list, ldestructive) call whm_util_spill_pl(keeps, discards, lspill_list, ldestructive) class default @@ -604,9 +605,9 @@ module subroutine rmvs_util_spill_tp(self, discards, lspill_list, ldestructive) associate(keeps => self) select type(discards) class is (rmvs_tp) - call swiftest_util_spill(keeps%lperi, discards%lperi, lspill_list, ldestructive) - call swiftest_util_spill(keeps%plperP, discards%plperP, lspill_list, ldestructive) - call swiftest_util_spill(keeps%plencP, discards%plencP, lspill_list, ldestructive) + call util_spill(keeps%lperi, discards%lperi, lspill_list, ldestructive) + call util_spill(keeps%plperP, discards%plperP, lspill_list, ldestructive) + call util_spill(keeps%plencP, discards%plencP, lspill_list, ldestructive) call swiftest_util_spill_tp(keeps, discards, lspill_list, ldestructive) class default diff --git a/src/swiftest/swiftest_coarray.f90 b/src/swiftest/swiftest_coarray.f90 new file mode 100644 index 000000000..79b2de50e --- /dev/null +++ b/src/swiftest/swiftest_coarray.f90 @@ -0,0 +1,736 @@ +!! Copyright 2023 - David Minton +!! This file is part of Swiftest. +!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +!! You should have received a copy of the GNU General Public License along with Swiftest. +!! If not, see: https://www.gnu.org/licenses. + +submodule (swiftest) s_swiftest_coarray + use coarray +contains + + + module subroutine swiftest_coarray_balance_system(nbody_system, param) + !! author: David A. Minton + !! + !! Checks whether or not the system needs to be rebalance. Rebalancing occurs when the difference between the number of test particles between the + !! image with the smallest and largest number of test particles is larger than the number of images + implicit none + ! Arguments + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + ! Internals + integer(I4B), codimension[*], save :: ntp + integer(I4B) :: img,ntp_min, ntp_max + character(len=NAMELEN) :: min_str, max_str, diff_str, ni_str + + ntp = nbody_system%tp%nbody + sync all + write(param%display_unit,*) "Checking whether test particles need to be reblanced." + ntp_min = huge(1) + ntp_max = 0 + do img = 1, num_images() + if (ntp[img] < ntp_min) ntp_min = ntp[img] + if (ntp[img] > ntp_max) ntp_max = ntp[img] + end do + write(min_str,*) ntp_min + write(max_str,*) ntp_max + write(diff_str,*) ntp_max - ntp_min + write(ni_str,*) num_images() + write(param%display_unit,*) "ntp_min : " // trim(adjustl(min_str)) + write(param%display_unit,*) "ntp_max : " // trim(adjustl(max_str)) + write(param%display_unit,*) "difference: " // trim(adjustl(diff_str)) + flush(param%display_unit) + sync all + if (ntp_max - ntp_min >= num_images()) then + write(param%display_unit,*) trim(adjustl(diff_str)) // ">=" // trim(adjustl(ni_str)) // ": Rebalancing" + flush(param%display_unit) + call nbody_system%coarray_collect(param) + call nbody_system%coarray_distribute(param) + write(param%display_unit,*) "Rebalancing complete" + else + write(param%display_unit,*) trim(adjustl(diff_str)) // "<" // trim(adjustl(ni_str)) // ": No rebalancing needed" + end if + flush(param%display_unit) + return + end subroutine swiftest_coarray_balance_system + + + module subroutine swiftest_coarray_coclone_body(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(swiftest_body),intent(inout),codimension[*] :: self !! Swiftest body object + + call coclone(self%lfirst) + call coclone(self%nbody) + call coclone(self%id) + call coclone(self%info) + call coclone(self%lmask) + call coclone(self%status) + call coclone(self%ldiscard) + call coclone(self%lcollision) + call coclone(self%lencounter) + call coclone(self%mu) + call coclone(self%rh) + call coclone(self%vh) + call coclone(self%rb) + call coclone(self%vb) + call coclone(self%ah) + call coclone(self%aobl) + call coclone(self%agr) + call coclone(self%atide) + call coclone(self%ir3h) + call coclone(self%isperi) + call coclone(self%peri) + call coclone(self%atp) + call coclone(self%a) + call coclone(self%e) + call coclone(self%inc) + call coclone(self%capom) + call coclone(self%omega) + call coclone(self%capm) + + return + end subroutine swiftest_coarray_coclone_body + + module subroutine swiftest_coarray_coclone_kin(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(swiftest_kinship),intent(inout),codimension[*] :: self !! Swiftest kinship object + + call coclone(self%parent) + call coclone(self%nchild) + call coclone(self%child) + + return + end subroutine swiftest_coarray_coclone_kin + + module subroutine swiftest_coarray_coclone_nc(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(swiftest_netcdf_parameters),intent(inout),codimension[*] :: self !! Swiftest body object + + call coclone(self%file_name) + call coclone(self%lfile_is_open) + call coclone(self%out_type) + call coclone(self%id) + call coclone(self%tslot) + call coclone(self%max_tslot) + call coclone(self%idvals) + call coclone(self%idslot) + call coclone(self%max_idslot) + call coclone(self%str_dimname) + call coclone(self%str_dimid) + call coclone(self%time_dimname) + call coclone(self%time_dimid) + call coclone(self%time_varid) + call coclone(self%name_dimname) + call coclone(self%name_dimid) + call coclone(self%name_varid) + call coclone(self%space_dimname) + call coclone(self%space_dimid) + call coclone(self%space_varid) + call coclone(self%id_varname) + call coclone(self%id_varid) + call coclone(self%status_varname) + call coclone(self%status_varid) + call coclone(self%ptype_varname) + call coclone(self%ptype_varid) + call coclone(self%npl_varname) + call coclone(self%npl_varid) + call coclone(self%ntp_varname) + call coclone(self%ntp_varid) + call coclone(self%nplm_varname) + call coclone(self%nplm_varid) + call coclone(self%a_varname) + call coclone(self%a_varid) + call coclone(self%e_varname) + call coclone(self%e_varid) + call coclone(self%inc_varname) + call coclone(self%inc_varid) + call coclone(self%capom_varname) + call coclone(self%capom_varid) + call coclone(self%omega_varname) + call coclone(self%omega_varid) + call coclone(self%capm_varname) + call coclone(self%capm_varid) + call coclone(self%varpi_varname) + call coclone(self%varpi_varid) + call coclone(self%lam_varname) + call coclone(self%lam_varid) + call coclone(self%f_varname) + call coclone(self%f_varid) + call coclone(self%cape_varname) + call coclone(self%cape_varid) + call coclone(self%rh_varname) + call coclone(self%rh_varid) + call coclone(self%vh_varname) + call coclone(self%vh_varid) + call coclone(self%gr_pseudo_vh_varname) + call coclone(self%gr_pseudo_vh_varid) + call coclone(self%Gmass_varname) + call coclone(self%Gmass_varid) + call coclone(self%mass_varname) + call coclone(self%mass_varid) + call coclone(self%rhill_varname) + call coclone(self%rhill_varid) + call coclone(self%radius_varname) + call coclone(self%radius_varid) + call coclone(self%Ip_varname) + call coclone(self%Ip_varid) + call coclone(self%rot_varname) + call coclone(self%rot_varid) + call coclone(self%j2rp2_varname) + call coclone(self%j2rp2_varid) + call coclone(self%j4rp4_varname) + call coclone(self%j4rp4_varid) + call coclone(self%k2_varname) + call coclone(self%k2_varid) + call coclone(self%q_varname) + call coclone(self%Q_varid) + call coclone(self%ke_orb_varname) + call coclone(self%KE_orb_varid) + call coclone(self%ke_spin_varname) + call coclone(self%KE_spin_varid) + call coclone(self%pe_varname) + call coclone(self%PE_varid) + call coclone(self%be_varname) + call coclone(self%BE_varid) + call coclone(self%te_varname) + call coclone(self%TE_varid) + call coclone(self%L_orbit_varname) + call coclone(self%L_orbit_varid) + call coclone(self%L_spin_varname) + call coclone(self%L_spin_varid) + call coclone(self%L_escape_varname) + call coclone(self%L_escape_varid) + call coclone(self%E_collisions_varname) + call coclone(self%E_collisions_varid) + call coclone(self%E_untracked_varname) + call coclone(self%E_untracked_varid) + call coclone(self%GMescape_varname) + call coclone(self%GMescape_varid) + call coclone(self%origin_type_varname) + call coclone(self%origin_type_varid) + call coclone(self%origin_time_varname) + call coclone(self%origin_time_varid) + call coclone(self%collision_id_varname) + call coclone(self%collision_id_varid) + call coclone(self%origin_rh_varname) + call coclone(self%origin_rh_varid) + call coclone(self%origin_vh_varname) + call coclone(self%origin_vh_varid) + call coclone(self%discard_time_varname) + call coclone(self%discard_time_varid) + call coclone(self%discard_rh_varname) + call coclone(self%discard_rh_varid) + call coclone(self%discard_vh_varname) + call coclone(self%discard_vh_varid) + call coclone(self%discard_body_id_varname) + call coclone(self%lpseudo_vel_exists) + return + end subroutine swiftest_coarray_coclone_nc + + module subroutine swiftest_coarray_coclone_cb(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(swiftest_cb),intent(inout),codimension[*] :: self !! Swiftest body object + ! Internals + integer(I4B) :: i + + call coclone(self%info) + call coclone(self%id) + call coclone(self%mass) + call coclone(self%Gmass) + call coclone(self%radius) + call coclone(self%density) + call coclone(self%j2rp2) + call coclone(self%j4rp4) + call coclone(self%k2) + call coclone(self%Q) + call coclone(self%tlag) + call coclone(self%GM0) + call coclone(self%dGM) + call coclone(self%R0) + call coclone(self%dR) + + call coclonevec(self%aobl) + call coclonevec(self%atide) + call coclonevec(self%aoblbeg) + call coclonevec(self%aoblend) + call coclonevec(self%atidebeg) + call coclonevec(self%atideend) + call coclonevec(self%rb) + call coclonevec(self%vb) + call coclonevec(self%agr) + call coclonevec(self%Ip) + call coclonevec(self%rot) + call coclonevec(self%L0) + call coclonevec(self%dL) + + return + end subroutine swiftest_coarray_coclone_cb + + + module subroutine swiftest_coarray_coclone_pl(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(swiftest_pl),intent(inout),codimension[*] :: self !! Swiftest body object + + call coclone(self%mass) + call coclone(self%Gmass) + call coclone(self%rhill) + call coclone(self%renc) + call coclone(self%radius) + call coclone(self%density) + call coclone(self%rbeg) + call coclone(self%rend) + call coclone(self%vbeg) + call coclone(self%Ip) + call coclone(self%rot) + call coclone(self%k2) + call coclone(self%Q ) + call coclone(self%tlag) + call coclone(self%kin) + call coclone(self%lmtiny) + call coclone(self%nplm) + call coclone(self%nplplm) + call coclone(self%nplenc) + call coclone(self%ntpenc) + + call swiftest_coarray_coclone_body(self) + + return + end subroutine swiftest_coarray_coclone_pl + + + module subroutine swiftest_coarray_coclone_tp(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(swiftest_tp),intent(inout),codimension[*] :: self !! Swiftest body object + + call coclone(self%nplenc) + call swiftest_coarray_coclone_body(self) + + return + end subroutine swiftest_coarray_coclone_tp + + + module subroutine swiftest_coarray_coclone_system(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(swiftest_nbody_system),intent(inout),codimension[*] :: self !! Swiftest body object + ! Internals + integer(I4B) :: i + + call coclone(self%maxid) + call coclone(self%t) + call coclone(self%GMtot) + call coclone(self%ke_orbit) + call coclone(self%ke_spin) + call coclone(self%pe) + call coclone(self%be) + call coclone(self%te) + call coclone(self%oblpot) + do i = 1, NDIM + call coclone(self%L_orbit(i)) + call coclone(self%L_spin(i)) + call coclone(self%L_total(i)) + call coclone(self%L_total_orig(i)) + call coclone(self%L_orbit_orig(i)) + call coclone(self%L_spin_orig(i)) + call coclone(self%L_escape(i)) + end do + call coclone(self%ke_orbit_orig) + call coclone(self%ke_spin_orig) + call coclone(self%pe_orig) + call coclone(self%be_orig) + call coclone(self%te_orig) + call coclone(self%be_cb) + call coclone(self%E_orbit_orig) + call coclone(self%GMtot_orig) + call coclone(self%GMescape) + call coclone(self%E_collisions) + call coclone(self%E_untracked) + call coclone(self%ke_orbit_error) + call coclone(self%ke_spin_error) + call coclone(self%pe_error) + call coclone(self%be_error) + call coclone(self%E_orbit_error) + call coclone(self%Ecoll_error) + call coclone(self%E_untracked_error) + call coclone(self%te_error) + call coclone(self%L_orbit_error) + call coclone(self%L_spin_error) + call coclone(self%L_escape_error) + call coclone(self%L_total_error) + call coclone(self%Mtot_error) + call coclone(self%Mescape_error) + call coclone(self%lbeg) + + return + end subroutine swiftest_coarray_coclone_system + + + module subroutine swiftest_coarray_component_clone_info(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! swiftest_particle_info scalar version + implicit none + ! Arguments + type(swiftest_particle_info), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + type(swiftest_particle_info),allocatable :: tmp[:] + integer(I4B) :: img, si + + allocate(tmp[*]) + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + if (this_image() == si) then + do img = 1, num_images() + tmp[img] = var + end do + sync images(*) + else + sync images(si) + var = tmp[si] + end if + + deallocate(tmp) + + return + end subroutine swiftest_coarray_component_clone_info + + + module subroutine swiftest_coarray_component_clone_info_arr1D(var,src_img) + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! swiftest_particle_info 1D allocatable array version + implicit none + ! Arguments + type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + type(swiftest_particle_info), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: img, si + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + + allocate(isalloc[*]) + allocate(n[*]) + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + isalloc = allocated(var) + if (isalloc) n = size(var) + sync all + if (.not. isalloc[si]) return + + allocate(tmp(n[si])[*]) + if (this_image() == si) then + do img = 1, num_images() + tmp(:)[img] = var + end do + sync images(*) + else + sync images(si) + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine swiftest_coarray_component_clone_info_arr1D + + + module subroutine swiftest_coarray_component_clone_kin_arr1D(var,src_img) + implicit none + !! author: David A. Minton + !! + !! Copies a component of a coarray derived type from the specified source image to the current local one. The default source image is 1 + !! swiftest_kinship allocatable array version + ! Arguments + type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + ! Internals + type(swiftest_kinship), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: i, img, si + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + + if (present(src_img)) then + si = src_img + else + si = 1 + end if + + sync all + isalloc = allocated(var) + if (isalloc) n = size(var) + sync all + if (.not. isalloc[si]) return + + allocate(tmp(n[si])[*]) + do i = 1, n[si] + call tmp(i)%coclone() + end do + if (this_image() /= si) then + if (allocated(var)) deallocate(var) + allocate(var, source=tmp) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine swiftest_coarray_component_clone_kin_arr1D + + + module subroutine swiftest_coarray_component_collect_info_arr1D(var,dest_img) + !! author: David A. Minton + !! + !! Collects components of a coarray derived type from all images and combines them into destination image component . The default destination image is 1 + !! swiftest_particle_info 1D allocatable array version + implicit none + ! Arguments + type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + ! Internals + type(swiftest_particle_info), dimension(:), codimension[:], allocatable :: tmp + integer(I4B) :: i,img, ti, di, ntot, istart, iend, nmax + integer(I4B), allocatable :: n[:] + logical, allocatable :: isalloc[:] + type(swiftest_particle_info), dimension(:), allocatable :: vari1 + + allocate(isalloc[*]) + allocate(n[*]) + + if (present(dest_img)) then + di = dest_img + else + di = 1 + end if + + isalloc = allocated(var) + if (isalloc) then + n = size(var) + else + n = 0 + end if + sync all + nmax = 0 + do img = 1, num_images() + if (n[img] > nmax) nmax = n[img] + end do + + allocate(tmp(nmax)[*]) + if (isalloc) tmp(1:n) = var(1:n) + + if (this_image() == di) then + do img = 1, num_images() + if (img /= di) then + allocate(vari1, source=tmp(1:n[img])[img]) + call util_append(var, vari1) + n = n + n[img] + end if + end do + sync images(*) + else + sync images(di) + if (allocated(var)) deallocate(var) + end if + + deallocate(isalloc,n,tmp) + + return + end subroutine swiftest_coarray_component_collect_info_arr1D + + + module subroutine swiftest_coarray_cocollect_body(self) + !! author: David A. Minton + !! + !! Collects all body object array components from all images and combines them into the image 1 body object + implicit none + ! Arguments + class(swiftest_body),intent(inout), codimension[*] :: self !! Swiftest body object + integer(I4B) :: i + + call cocollect(self%nbody) + call cocollect(self%id) + call cocollect(self%info) + call cocollect(self%lmask) + call cocollect(self%status) + call cocollect(self%ldiscard) + call cocollect(self%lcollision) + call cocollect(self%lencounter) + call cocollect(self%mu) + call cocollect(self%rh) + call cocollect(self%vh) + call cocollect(self%rb) + call cocollect(self%vb) + call cocollect(self%ah) + call cocollect(self%aobl) + call cocollect(self%agr) + call cocollect(self%atide) + call cocollect(self%ir3h) + call cocollect(self%isperi) + call cocollect(self%peri) + call cocollect(self%atp) + call cocollect(self%a) + call cocollect(self%e) + call cocollect(self%inc) + call cocollect(self%capom) + call cocollect(self%omega) + call cocollect(self%capm) + + return + end subroutine swiftest_coarray_cocollect_body + + + module subroutine swiftest_coarray_cocollect_tp(self) + !! author: David A. Minton + !! + !! Collects all object array components from all images and combines them into the image 1 object + implicit none + ! Arguments + class(swiftest_tp),intent(inout),codimension[*] :: self !! Swiftest body object + + call cocollect(self%npltp) + call cocollect(self%nplenc) + call swiftest_coarray_cocollect_body(self) + + return + end subroutine swiftest_coarray_cocollect_tp + + + module subroutine swiftest_coarray_collect_system(nbody_system, param) + !! author: David A. Minton + !! + !! Collects all the test particles from other images into the image #1 test particle system + implicit none + ! Arguments + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + ! Internals + integer(I4B) :: i,j + class(swiftest_tp), allocatable, codimension[:] :: cotp + character(len=NAMELEN) :: image_num_char + + if (.not.param%lcoarray) return + + if (this_image() == 1 .or. param%log_output) then + write(image_num_char,*) num_images() + write(param%display_unit,*) " Collecting test particles from " // trim(adjustl(image_num_char)) // " images." + if (param%log_output) flush(param%display_unit) + end if + + allocate(cotp[*], source=nbody_system%tp) + call cotp%cocollect() + deallocate(nbody_system%tp) + allocate(nbody_system%tp, source=cotp) + + deallocate(cotp) + + return + end subroutine swiftest_coarray_collect_system + + + module subroutine swiftest_coarray_distribute_system(nbody_system, param) + !! author: David A. Minton + !! + !! Distributes test particles from image #1 out to all images. + implicit none + ! Arguments + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + ! Internals + integer(I4B) :: istart, iend, ntot, num_per_image, ncopy + logical, dimension(:), allocatable :: lspill_list + integer(I4B), codimension[:], allocatable :: ntp + character(len=NAMELEN) :: image_num_char, ntp_num_char + class(swiftest_tp), allocatable, codimension[:] :: cotp + class(swiftest_tp), allocatable :: tmp + + if (.not.param%lcoarray) return + + allocate(ntp[*]) + ntp = nbody_system%tp%nbody + sync all + ntot = ntp[1] + if (ntot == 0) return + + write(image_num_char,*) num_images() + + if (this_image() == 1 .or. param%log_output) then + write(ntp_num_char,*) ntot + write(param%display_unit,*) " Distributing " // trim(adjustl(ntp_num_char)) // " test particles across " // trim(adjustl(image_num_char)) // " images." + if (param%log_output) flush(param%display_unit) + end if + + allocate(lspill_list(ntot)) + num_per_image = ceiling(1.0_DP * ntot / num_images()) + istart = (this_image() - 1) * num_per_image + 1 + if (this_image() == num_images()) then + iend = ntot + else + iend = this_image() * num_per_image + end if + + lspill_list(:) = .true. + lspill_list(istart:iend) = .false. + + allocate(cotp[*], source=nbody_system%tp) + call cotp%coclone() + if (this_image() /= 1) then + deallocate(nbody_system%tp) + allocate(nbody_system%tp, source=cotp) + end if + allocate(tmp, mold=nbody_system%tp) + call nbody_system%tp%spill(tmp, lspill_list(:), ldestructive=.true.) + + write(image_num_char,*) this_image() + write(ntp_num_char,*) nbody_system%tp%nbody + write(param%display_unit,*) "Image " // trim(adjustl(image_num_char)) // " ntp: " // trim(adjustl(ntp_num_char)) + if (param%log_output) flush(param%display_unit) + + deallocate(ntp, lspill_list, tmp, cotp) + + return + end subroutine swiftest_coarray_distribute_system + + +end submodule s_swiftest_coarray diff --git a/src/swiftest/swiftest_discard.f90 b/src/swiftest/swiftest_discard.f90 index 6af0c9a8f..dd2f07eab 100644 --- a/src/swiftest/swiftest_discard.f90 +++ b/src/swiftest/swiftest_discard.f90 @@ -25,7 +25,7 @@ module subroutine swiftest_discard_system(self, param) lpl_check = allocated(self%pl_discards) ltp_check = allocated(self%tp_discards) - associate(nbody_system => self, tp => self%tp, pl => self%pl, tp_discards => self%tp_discards, pl_discards => self%pl_discards, nc => self%system_history%nc) + associate(nbody_system => self, tp => self%tp, pl => self%pl, tp_discards => self%tp_discards, pl_discards => self%pl_discards) lpl_discards = .false. ltp_discards = .false. if (lpl_check .and. pl%nbody > 0) then @@ -131,7 +131,7 @@ subroutine swiftest_discard_cb_tp(tp, nbody_system, param) ! Internals integer(I4B) :: i real(DP) :: energy, vb2, rb2, rh2, rmin2, rmax2, rmaxu2 - character(len=STRMAX) :: idstr, timestr + character(len=STRMAX) :: idstr, timestr, message associate(ntp => tp%nbody, cb => nbody_system%cb, Gmtot => nbody_system%Gmtot) rmin2 = max(param%rmin * param%rmin, cb%radius * cb%radius) @@ -144,8 +144,9 @@ subroutine swiftest_discard_cb_tp(tp, nbody_system, param) tp%status(i) = DISCARDED_RMAX write(idstr, *) tp%id(i) write(timestr, *) nbody_system%t - write(*, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // & + write(message, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // & " too far from the central body at t = " // trim(adjustl(timestr)) + call swiftest_io_log_one_message(COLLISION_LOG_OUT, message) tp%ldiscard(i) = .true. tp%lmask(i) = .false. call tp%info(i)%set_value(status="DISCARDED_RMAX", discard_time=nbody_system%t, discard_rh=tp%rh(:,i), & @@ -154,8 +155,9 @@ subroutine swiftest_discard_cb_tp(tp, nbody_system, param) tp%status(i) = DISCARDED_RMIN write(idstr, *) tp%id(i) write(timestr, *) nbody_system%t - write(*, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // & + write(message, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // & " too close to the central body at t = " // trim(adjustl(timestr)) + call swiftest_io_log_one_message(COLLISION_LOG_OUT, message) tp%ldiscard(i) = .true. tp%lmask(i) = .false. call tp%info(i)%set_value(status="DISCARDED_RMIN", discard_time=nbody_system%t, discard_rh=tp%rh(:,i), & @@ -168,8 +170,9 @@ subroutine swiftest_discard_cb_tp(tp, nbody_system, param) tp%status(i) = DISCARDED_RMAXU write(idstr, *) tp%id(i) write(timestr, *) nbody_system%t - write(*, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // & + write(message, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // & " is unbound and too far from barycenter at t = " // trim(adjustl(timestr)) + call swiftest_io_log_one_message(COLLISION_LOG_OUT, message) tp%ldiscard(i) = .true. tp%lmask(i) = .false. call tp%info(i)%set_value(status="DISCARDED_RMAXU", discard_time=nbody_system%t, discard_rh=tp%rh(:,i), & @@ -254,7 +257,7 @@ subroutine swiftest_discard_pl_tp(tp, nbody_system, param) integer(I4B) :: i, j, isp real(DP) :: r2min, radius real(DP), dimension(NDIM) :: dx, dv - character(len=STRMAX) :: idstri, idstrj, timestr + character(len=STRMAX) :: idstri, idstrj, timestr, message associate(ntp => tp%nbody, pl => nbody_system%pl, npl => nbody_system%pl%nbody, t => nbody_system%t, dt => param%dt) do i = 1, ntp @@ -271,9 +274,10 @@ subroutine swiftest_discard_pl_tp(tp, nbody_system, param) write(idstri, *) tp%id(i) write(idstrj, *) pl%id(j) write(timestr, *) nbody_system%t - write(*, *) "Test particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstri)) // ")" & + write(message, *) "Test particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstri)) // ")" & // " too close to massive body " // trim(adjustl(pl%info(j)%name)) // " (" // trim(adjustl(idstrj)) // ")" & // " at t = " // trim(adjustl(timestr)) + call swiftest_io_log_one_message(COLLISION_LOG_OUT, message) tp%ldiscard(i) = .true. call tp%info(i)%set_value(status="DISCARDED_PLR", discard_time=nbody_system%t, discard_rh=tp%rh(:,i), & discard_vh=tp%vh(:,i), discard_body_id=pl%id(j)) diff --git a/src/swiftest/swiftest_drift.f90 b/src/swiftest/swiftest_drift.f90 index b7811f88c..82239e452 100644 --- a/src/swiftest/swiftest_drift.f90 +++ b/src/swiftest/swiftest_drift.f90 @@ -1,10 +1,10 @@ -!! Copyright 2022 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh +!! Coryright 2022 - David Minton, Carlisle Wishard, Jennifer Pouplin, Jake Elliott, & Dana Singh !! This file is part of Swiftest. !! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License !! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. !! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty !! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -!! You should have received a copy of the GNU General Public License along with Swiftest. +!! You should have received a cory of the GNU General Public License along with Swiftest. !! If not, see: https://www.gnu.org/licenses. submodule (swiftest) s_swiftest_drift @@ -82,7 +82,11 @@ module subroutine swiftest_drift_all(mu, x, v, n, param, dt, lmask, iflag) allocate(dtp(n)) if (param%lgr) then +#ifdef DOCONLOC + do concurrent(i = 1:n, lmask(i)) shared(param,lmask,x,v,mu,dtp,dt) local(rmag,vmag2,energy) +#else do concurrent(i = 1:n, lmask(i)) +#endif rmag = norm2(x(:, i)) vmag2 = dot_product(v(:, i), v(:, i)) energy = 0.5_DP * vmag2 - mu(i) / rmag @@ -104,7 +108,7 @@ module subroutine swiftest_drift_all(mu, x, v, n, param, dt, lmask, iflag) end subroutine swiftest_drift_all - pure elemental module subroutine swiftest_drift_one(mu, px, py, pz, vx, vy, vz, dt, iflag) + pure elemental module subroutine swiftest_drift_one(mu, rx, ry, rz, vx, vy, vz, dt, iflag) !! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott !! !! Perform Danby drift for one body, redoing drift with smaller substeps if original accuracy is insufficient @@ -114,18 +118,18 @@ pure elemental module subroutine swiftest_drift_one(mu, px, py, pz, vx, vy, vz, implicit none ! Arguments real(DP), intent(in) :: mu !! G * (Mcb + m), G = gravitational constant, Mcb = mass of central body, m = mass of body to drift - real(DP), intent(inout) :: px, py, pz, vx, vy, vz !! Position and velocity of body to drift + real(DP), intent(inout) :: rx, ry, rz, vx, vy, vz !! Position and velocity of body to drift real(DP), intent(in) :: dt !! Step size integer(I4B), intent(out) :: iflag !! iflag : error status flag for Danby drift (0 = OK, nonzero = ERROR) ! Internals integer(I4B) :: i real(DP) :: dttmp - call swiftest_drift_dan(mu, px, py, pz, vx, vy, vz, dt, iflag) + call swiftest_drift_dan(mu, rx, ry, rz, vx, vy, vz, dt, iflag) if (iflag /= 0) then dttmp = 0.1_DP * dt do i = 1, 10 - call swiftest_drift_dan(mu, px, py, pz, vx, vy, vz, dttmp, iflag) + call swiftest_drift_dan(mu, rx, ry, rz, vx, vy, vz, dttmp, iflag) if (iflag /= 0) exit end do end if @@ -134,7 +138,7 @@ pure elemental module subroutine swiftest_drift_one(mu, px, py, pz, vx, vy, vz, end subroutine swiftest_drift_one - pure subroutine swiftest_drift_dan(mu, px0, py0, pz0, vx0, vy0, vz0, dt0, iflag) + pure subroutine swiftest_drift_dan(mu, rx0, ry0, rz0, vx0, vy0, vz0, dt0, iflag) !! author: David A. Minton !! !! Perform Kepler drift, solving Kepler's equation in appropriate variables @@ -144,23 +148,21 @@ pure subroutine swiftest_drift_dan(mu, px0, py0, pz0, vx0, vy0, vz0, dt0, iflag) implicit none ! Arguments real(DP), intent(in) :: mu !! G * (m1 + m2), G = gravitational constant, m1 = mass of central body, m2 = mass of body to drift - real(DP), intent(inout) :: px0, py0, pz0 !! position of body to drift + real(DP), intent(inout) :: rx0, ry0, rz0 !! position of body to drift real(DP), intent(inout) :: vx0, vy0, vz0 !! velocity of body to drift real(DP), intent(in) :: dt0 !! time step integer(I4B), intent(out) :: iflag !! error status flag for Kepler drift (0 = OK, nonzero = NO CONVERGENCE) ! Internals - real(DP) :: dt, f, g, fdot, gdot, c1, c2, c3, u, alpha, fp, r0 + real(DP) :: rx, ry, rz, vx, vy, vz, dt + real(DP) :: f, g, fdot, gdot, c1, c2, c3, u, alpha, fp, r0 real(DP) :: v0s, a, asq, en, dm, ec, es, esq, xkep, fchk, s, c - real(DP), dimension(NDIM) :: x, v, x0, v0 ! Executable code iflag = 0 dt = dt0 - x0 = [px0, py0, pz0] - v0 = [vx0, vy0, vz0] - r0 = sqrt(dot_product(x0(:), x0(:))) - v0s = dot_product(v0(:), v0(:)) - u = dot_product(x0(:), v0(:)) + r0 = sqrt(rx0*rx0 + ry0*ry0 + rz0*rz0) + v0s = vx0*vx0 + vy0*vy0 + vz0*vz0 + u = rx0*vx0 + ry0*vy0 + rz0*vz0 alpha = 2 * mu / r0 - v0s if (alpha > 0.0_DP) then a = mu / alpha @@ -186,10 +188,19 @@ pure subroutine swiftest_drift_dan(mu, px0, py0, pz0, vx0, vy0, vz0, dt0, iflag) g = dt + (s - xkep) / en fdot = -(a / (r0 * fp)) * en * s gdot = (c - 1.0_DP) / fp + 1.0_DP - x(:) = x0(:) * f + v0(:) * g - v(:) = x0(:) * fdot + v0(:) * gdot - px0 = x(1); py0 = x(2); pz0 = x(3) - vx0 = v(1); vy0 = v(2); vz0 = v(3) + rx = rx0 * f + vx0 * g + ry = ry0 * f + vy0 * g + rz = rz0 * f + vz0 * g + vx = rx0 * fdot + vx0 * gdot + vy = ry0 * fdot + vy0 * gdot + vz = rz0 * fdot + vz0 * gdot + + rx0 = rx + ry0 = ry + rz0 = rz + vx0 = vx + vy0 = vy + vz0 = vz iflag = 0 return end if @@ -201,10 +212,19 @@ pure subroutine swiftest_drift_dan(mu, px0, py0, pz0, vx0, vy0, vz0, dt0, iflag) g = dt - mu * c3 fdot = -mu / (fp * r0) * c1 gdot = 1.0_DP - mu / fp * c2 - x(:) = x0(:) * f + v0(:) * g - v(:) = x0(:) * fdot + v0(:) * gdot - px0 = x(1); py0 = x(2); pz0 = x(3) - vx0 = v(1); vy0 = v(2); vz0 = v(3) + rx = rx0 * f + vx0 * g + ry = ry0 * f + vy0 * g + rz = rz0 * f + vz0 * g + vx = rx0 * fdot + vx0 * gdot + vy = ry0 * fdot + vy0 * gdot + vz = rz0 * fdot + vz0 * gdot + + rx0 = rx + ry0 = ry + rz0 = rz + vx0 = vx + vy0 = vy + vz0 = vz end if return @@ -235,22 +255,22 @@ pure subroutine swiftest_drift_kepmd(dm, es, ec, x, s, c) ! executable code fac1 = 1.0_DP / (1.0_DP - ec) q = fac1 * dm - fac2 = es**2 * fac1 - ec / 3.0_DP + fac2 = es*es*fac1 - ec / 3.0_DP x = q * (1.0_DP - 0.5_DP * fac1 * q * (es - q * fac2)) - y = x**2 + y = x*x s = x * (a0 - y * (a1 - y * (a2 - y * (a3 - y * (a4 - y))))) / a0 - c = sqrt(1.0_DP - s**2) + c = sqrt(1.0_DP - s*s) f = x - ec * s + es * (1.0_DP - c) - dm fp = 1.0_DP - ec * c + es * s fpp = ec * s + es * c fppp = ec * c - es * s dx = -f / fp - dx = -f / (fp + dx * fpp * 0.5_DP) - dx = -f / (fp + dx * fpp * 0.5_DP + dx**2* fppp * SIXTH) + dx = -f / (fp + dx * fpp/2.0_DP) + dx = -f / (fp + dx * fpp/2.0_DP + dx*dx * fppp * SIXTH) x = x + dx - y = x**2 + y = x*x s = x * (a0 - y * (a1 - y * (a2 - y * (a3 - y * (a4 - y))))) / a0 - c = sqrt(1.0_DP - s**2) + c = sqrt(1.0_DP - s*s) return end subroutine swiftest_drift_kepmd @@ -336,18 +356,18 @@ pure subroutine swiftest_drift_kepu_guess(dt, r0, mu, alpha, u, s) if (alpha > 0.0_DP) then if (dt / r0 <= thresh) then - s = dt / r0 - (dt**2 * u) / (2 * r0**3) + s = dt/r0 - (dt*dt*u)/(2.0_DP*r0*r0*r0) else - a = mu / alpha - en = sqrt(mu / a**3) - ec = 1.0_DP - r0 / a - es = u / (en * a**2) - e = sqrt(ec**2 + es**2) - y = en * dt - es + a = mu/alpha + en = sqrt(mu/(a*a*a)) + ec = 1.0_DP - r0/a + es = u/(en*a*a) + e = sqrt(ec*ec + es*es) + y = en*dt - es call swiftest_orbel_scget(y, sy, cy) - sigma = sign(1.0_DP, es * cy + ec * sy) - x = y + sigma * danbyk * e - s = x / sqrt(alpha) + sigma = sign(1.0_DP, es*cy + ec*sy) + x = y + sigma*DANBYK*e + s = x/sqrt(alpha) end if else call swiftest_drift_kepu_p3solve(dt, r0, mu, alpha, u, s, iflag) @@ -392,16 +412,16 @@ pure subroutine swiftest_drift_kepu_lag(s, dt, r0, mu, alpha, u, fp, c1, c2, c3, do nc = 0, ncmax x = s * s * alpha call swiftest_drift_kepu_stumpff(x, c0, c1, c2, c3) - c1 = c1 * s - c2 = c2 * s**2 - c3 = c3 * s**3 + c1 = c1*s + c2 = c2*s*s + c3 = c3*s*s*s f = r0 * c1 + u * c2 + mu * c3 - dt fp = r0 * c0 + u * c1 + mu * c2 fpp = (-r0 * alpha + mu) * c1 + u * c0 - ds = -ln * f / (fp + sign(1.0_DP, fp) * sqrt(abs((ln - 1)**2 * fp**2 - (ln - 1) * ln * f * fpp))) + ds = -ln*f/(fp + sign(1.0_DP, fp)*sqrt(abs((ln - 1.0_DP)*(ln - 1.0_DP)*fp*fp - (ln - 1.0_DP)*ln*f*fpp))) s = s + ds fdt = f / dt - if (fdt**2 < DANBYB**2) then + if (fdt*fdt < DANBYB*DANBYB) then iflag = 0 return end if @@ -438,23 +458,23 @@ pure subroutine swiftest_drift_kepu_new(s, dt, r0, mu, alpha, u, fp, c1, c2, c3, real(DP) :: x, c0, ds, f, fpp, fppp, fdt do nc = 0, 6 - x = s**2 * alpha + x = s*s*alpha call swiftest_drift_kepu_stumpff(x, c0, c1, c2, c3) - c1 = c1 * s - c2 = c2 * s**2 - c3 = c3 * s**3 - f = r0 * c1 + u * c2 + mu * c3 - dt - fp = r0 * c0 + u * c1 + mu * c2 - fpp = (-r0 * alpha + mu) * c1 + u * c0 - fppp = (-r0 * alpha + mu) * c0 - u * alpha * c1 - ds = -f / fp - ds = -f / (fp + ds * fpp * 0.5_DP) - ds = -f / (fp + ds * fpp * 0.5_DP + ds**2 * fppp * SIXTH) + c1 = c1*s + c2 = c2*s*s + c3 = c3*s*s*s + f = r0*c1 + u*c2 + mu*c3 - dt + fp = r0*c0 + u*c1 + mu*c2 + fpp = (-r0*alpha + mu)*c1 + u*c0 + fppp = (-r0*alpha + mu)*c0 - u*alpha*c1 + ds = -f/fp + ds = -f/(fp + ds*fpp/2.0_DP) + ds = -f/(fp + ds*fpp/2.0_DP + ds*ds*fppp/6.0_DP) s = s + ds - fdt = f / dt - if (fdt**2 < DANBYB**2) then - iflag = 0 - return + fdt = f/dt + if (fdt*fdt < DANBYB*DANBYB) then + iflag = 0 + return end if end do iflag = 1 @@ -487,9 +507,9 @@ pure subroutine swiftest_drift_kepu_p3solve(dt, r0, mu, alpha, u, s, iflag) a2 = 0.5_DP * u / denom a1 = r0 / denom a0 = -dt / denom - q = (a1 - a2**2 * THIRD) * THIRD - r = (a1 * a2 - 3 * a0) * SIXTH - (a2 * THIRD)**3 - sq2 = q**3 + r**2 + q = (a1 - a2*a2 * THIRD) * THIRD + r = (a1*a2 - 3 * a0) * SIXTH - (a2*a2*a2)/27.0_DP + sq2 = q*q*q + r*r if (sq2 >= 0.0_DP) then sq = sqrt(sq2) if ((r + sq) <= 0.0_DP) then @@ -549,9 +569,9 @@ pure subroutine swiftest_drift_kepu_stumpff(x, c0, c1, c2, c3) if (n /= 0) then do i = n, 1, -1 c3 = (c2 + c0 * c3) / 4.0_DP - c2 = c1**2 / 2.0_DP + c2 = c1*c1 / 2.0_DP c1 = c0 * c1 - c0 = 2 * c0**2 - 1.0_DP + c0 = 2 * c0*c0 - 1.0_DP x = x * 4 end do end if diff --git a/src/swiftest/swiftest_driver.f90 b/src/swiftest/swiftest_driver.f90 index bfa950222..6cec24feb 100644 --- a/src/swiftest/swiftest_driver.f90 +++ b/src/swiftest/swiftest_driver.f90 @@ -20,30 +20,33 @@ program swiftest_driver implicit none class(swiftest_nbody_system), allocatable :: nbody_system !! Polymorphic object containing the nbody system to be integrated - class(swiftest_parameters), allocatable :: param !! Run configuration parameters + type(swiftest_parameters) :: param !! Run configuration parameters + class(swiftest_storage), allocatable :: system_history !! Stores the system history between output dumps character(len=:), allocatable :: integrator !! Integrator type code (see globals for symbolic names) character(len=:), allocatable :: param_file_name !! Name of the file containing user-defined parameters character(len=:), allocatable :: display_style !! Style of the output display {"STANDARD", "COMPACT", "PROGRESS"}). Default is "STANDARD" - integer(I8B) :: istart !! Starting index for loop counter - integer(I4B) :: iout !! Output cadence counter - integer(I4B) :: idump !! Dump cadence counter - integer(I4B) :: nout !! Current output step - integer(I4B) :: istep !! Current value of istep (used for time stretching) type(walltimer) :: integration_timer !! Object used for computing elapsed wall time call swiftest_io_get_args(integrator, param_file_name, display_style) !> Read in the user-defined parameters file and the initial conditions of the nbody_system - allocate(swiftest_parameters :: param) param%integrator = trim(adjustl(integrator)) param%display_style = trim(adjustl(display_style)) call param%read_in(param_file_name) +#ifdef COARRAY + if (.not.param%lcoarray .and. (this_image() /= 1)) stop ! Single image mode +#endif associate(t0 => param%t0, & tstart => param%tstart, & dt => param%dt, & tstop => param%tstop, & iloop => param%iloop, & + istart => param%istart, & + iout => param%iout, & + idump => param%idump, & + nout => param%nout, & + istep => param%istep, & nloops => param%nloops, & istep_out => param%istep_out, & fstep_out => param%fstep_out, & @@ -74,72 +77,115 @@ program swiftest_driver !> Define the maximum number of threads nthreads = 1 ! In the *serial* case !$ nthreads = omp_get_max_threads() ! In the *parallel* case - !$ write(param%display_unit,'(a)') ' OpenMP parameters:' - !$ write(param%display_unit,'(a)') ' ------------------' - !$ write(param%display_unit,'(a,i3,/)') ' Number of threads = ', nthreads - !$ if (param%log_output) write(*,'(a,i3)') ' OpenMP: Number of threads = ',nthreads - - call nbody_system%initialize(param) - - associate (system_history => nbody_system%system_history) - ! If this is a new run, compute energy initial conditions (if energy tracking is turned on) and write the initial conditions to file. - call nbody_system%display_run_information(param, integration_timer, phase="first") - if (param%lenergy) then - if (param%lrestart) then - call nbody_system%get_t0_values(param) - else - call nbody_system%conservation_report(param, lterminal=.false.) ! This will save the initial values of energy and momentum - end if - call nbody_system%conservation_report(param, lterminal=.true.) +#ifdef COARRAY + if (this_image() == 1 .or. param%log_output) then +#endif + !$ write(param%display_unit,'(a)') ' OpenMP parameters:' + !$ write(param%display_unit,'(a)') ' ------------------' + !$ write(param%display_unit,'(a,i3,/)') ' Number of threads = ', nthreads + !$ if (param%log_output) write(*,'(a,i3)') ' OpenMP: Number of threads = ',nthreads +#ifdef COARRAY + if (param%lcoarray) then + write(param%display_unit,*) ' Coarray parameters:' + write(param%display_unit,*) ' -------------------' + write(param%display_unit,*) ' Number of images = ', num_images() + if (param%log_output .and. this_image() == 1) write(*,'(a,i3)') ' Coarray: Number of images = ',num_images() + else + write(param%display_unit,*) ' Coarrays disabled.' + if (param%log_output) write(*,*) ' Coarrays disabled.' + end if + end if +#endif + if (param%log_output) flush(param%display_unit) + +#ifdef COARRAY + ! The following line lets us read in the input files one image at a time. Letting each image read the input in is faster than broadcasting all of the data + if (param%lcoarray .and. (this_image() /= 1)) sync images(this_image() - 1) +#endif + call nbody_system%initialize(system_history, param) +#ifdef COARRAY + if (param%lcoarray .and. (this_image() < num_images())) sync images(this_image() + 1) + + ! Distribute test particles to the various images + if (param%lcoarray) call nbody_system%coarray_distribute(param) +#endif + + ! If this is a new run, compute energy initial conditions (if energy tracking is turned on) and write the initial conditions to file. + call nbody_system%display_run_information(param, integration_timer, phase="first") + + if (param%lenergy) then + if (param%lrestart) then + call nbody_system%get_t0_values(system_history%nc, param) + else + call nbody_system%conservation_report(param, lterminal=.false.) ! This will save the initial values of energy and momentum end if - call system_history%take_snapshot(param,nbody_system) - call nbody_system%dump(param) - - do iloop = istart, nloops - !> Step the nbody_system forward in time - call integration_timer%start() - call nbody_system%step(param, nbody_system%t, dt) - call integration_timer%stop() - - nbody_system%t = t0 + iloop * dt - - !> Evaluate any discards or collisional outcomes - call nbody_system%discard(param) - - !> If the loop counter is at the output cadence value, append the data file with a single frame - if (istep_out > 0) then - iout = iout + 1 - if ((iout == istep) .or. (iloop == nloops)) then - iout = 0 - idump = idump + 1 - if (ltstretch) then - nout = nout + 1 - istep = floor(istep_out * fstep_out**nout, kind=I4B) - end if - - call system_history%take_snapshot(param,nbody_system) - - if (idump == dump_cadence) then - idump = 0 - call nbody_system%dump(param) - end if + call nbody_system%conservation_report(param, lterminal=.true.) + end if - call integration_timer%report(message="Integration steps:", unit=display_unit) - call nbody_system%display_run_information(param, integration_timer) - call integration_timer%reset() - if (param%lenergy) call nbody_system%conservation_report(param, lterminal=.true.) + call system_history%take_snapshot(param,nbody_system) + call nbody_system%dump(param, system_history) + + do iloop = istart, nloops + !> Step the nbody_system forward in time + call integration_timer%start() + call nbody_system%step(param, nbody_system%t, dt) + call integration_timer%stop() + + nbody_system%t = t0 + iloop * dt + + !> Evaluate any discards or collisional outcomes + call nbody_system%discard(param) + + !> If the loop counter is at the output cadence value, append the data file with a single frame + if (istep_out > 0) then + iout = iout + 1 + if ((iout == istep) .or. (iloop == nloops)) then + iout = 0 + idump = idump + 1 + if (ltstretch) then + nout = nout + 1 + istep = floor(istep_out * fstep_out**nout, kind=I4B) + end if + + call system_history%take_snapshot(param,nbody_system) + if (idump == dump_cadence) then + idump = 0 + call nbody_system%dump(param, system_history) +#ifdef COARRAY + if (param%lcoarray) call nbody_system%coarray_balance(param) +#endif end if +#ifdef COARRAY + if (this_image() == 1 .or. param%log_output) then +#endif + call integration_timer%report(message="Integration steps:", unit=display_unit) +#ifdef COARRAY + end if !(this_image() == 1) +#endif + call nbody_system%display_run_information(param, integration_timer) + call integration_timer%reset() +#ifdef COARRAY + if (this_image() == 1 .or. param%log_output) then +#endif + if (param%lenergy) call nbody_system%conservation_report(param, lterminal=.true.) +#ifdef COARRAY + end if ! (this_image() == 1) +#endif end if + end if - end do - ! Dump any remaining history if it exists - call nbody_system%dump(param) - call system_history%dump(param) - call nbody_system%display_run_information(param, integration_timer, phase="last") - - end associate + end do + ! Dump any remaining history if it exists + call nbody_system%dump(param, system_history) + call nbody_system%display_run_information(param, integration_timer, phase="last") end associate - call base_util_exit(SUCCESS) +#ifdef COARRAY + if (this_image() == 1) then +#endif + call base_util_exit(SUCCESS) +#ifdef COARRAY + end if ! (this_image() == 1) +#endif end program swiftest_driver diff --git a/src/swiftest/swiftest_gr.f90 b/src/swiftest/swiftest_gr.f90 index 1c37d3da4..083e5de1b 100644 --- a/src/swiftest/swiftest_gr.f90 +++ b/src/swiftest/swiftest_gr.f90 @@ -73,7 +73,11 @@ pure module subroutine swiftest_gr_kick_getacch(mu, x, lmask, n, inv_c2, agr) real(DP) :: beta, rjmag4 agr(:,:) = 0.0_DP +#ifdef DOCONLOC + do concurrent (i = 1:n, lmask(i)) shared(lmask,x,mu,agr,inv_c2) local(rjmag4,beta) +#else do concurrent (i = 1:n, lmask(i)) +#endif rjmag4 = (dot_product(x(:, i), x(:, i)))**2 beta = -mu(i)**2 * inv_c2 agr(:, i) = 2 * beta * x(:, i) / rjmag4 @@ -83,7 +87,7 @@ pure module subroutine swiftest_gr_kick_getacch(mu, x, lmask, n, inv_c2, agr) end subroutine swiftest_gr_kick_getacch - pure module subroutine swiftest_gr_p4_pos_kick(param, x, v, dt) + pure elemental module subroutine swiftest_gr_p4_pos_kick(inv_c2, rx, ry, rz, vx, vy, vz, dt) !! author: David A. Minton !! !! Position kick due to p**4 term in the post-Newtonian correction @@ -96,17 +100,21 @@ pure module subroutine swiftest_gr_p4_pos_kick(param, x, v, dt) !! Adapted from David A. Minton's Swifter routine gr_whm_p4.f90 implicit none ! Arguments - class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters - real(DP), dimension(:), intent(inout) :: x !! Position vector - real(DP), dimension(:), intent(in) :: v !! Velocity vector - real(DP), intent(in) :: dt !! Step size + real(DP), intent(in) :: inv_c2 !! One over speed of light squared (1/c**2) + real(DP), intent(inout) :: rx, ry, rz !! Position vector + real(DP), intent(in) :: vx, vy, vz !! Velocity vector + real(DP), intent(in) :: dt !! Step size ! Internals - real(DP), dimension(NDIM) :: dr - real(DP) :: vmag2 - - vmag2 = dot_product(v(:), v(:)) - dr(:) = -2 * param%inv_c2 * vmag2 * v(:) - x(:) = x(:) + dr(:) * dt + real(DP) :: drx, dry, drz + real(DP) :: vmag2 + + vmag2 = vx*vx + vy*vy + vz*vz + drx = -2 * inv_c2 * vmag2 * vx + dry = -2 * inv_c2 * vmag2 * vy + drz = -2 * inv_c2 * vmag2 * vz + rx = rx + drx * dt + ry = ry + dry * dt + rz = rz + drz * dt return end subroutine swiftest_gr_p4_pos_kick diff --git a/src/swiftest/swiftest_io.f90 b/src/swiftest/swiftest_io.f90 index 32f722a7b..70ddac5f7 100644 --- a/src/swiftest/swiftest_io.f90 +++ b/src/swiftest/swiftest_io.f90 @@ -123,11 +123,9 @@ module subroutine swiftest_io_conservation_report(self, param, lterminal) real(DP), dimension(NDIM) :: L_total_now, L_orbit_now, L_spin_now real(DP) :: ke_orbit_now, ke_spin_now, pe_now, E_orbit_now, be_now, be_cb_now, be_cb_orig, te_now real(DP) :: GMtot_now - character(len=STRMAX) :: errmsg - integer(I4B), parameter :: EGYIU = 72 character(len=*), parameter :: EGYTERMFMT = '(" DL/L0 = ", ES12.5, "; DE_orbit/|E0| = ", ES12.5, "; DE_total/|E0| = ", ES12.5, "; DM/M0 = ", ES12.5)' - associate(nbody_system => self, pl => self%pl, cb => self%cb, npl => self%pl%nbody, display_unit => param%display_unit, nc => self%system_history%nc) + associate(nbody_system => self, pl => self%pl, cb => self%cb, npl => self%pl%nbody, display_unit => param%display_unit) select type(self) class is (helio_nbody_system) ! Don't convert vh to vb for Helio-based integrators, because they are already have that calculated @@ -183,24 +181,27 @@ module subroutine swiftest_io_conservation_report(self, param, lterminal) nbody_system%L_total_error = norm2(L_total_now(:) - nbody_system%L_total_orig(:)) / norm2(nbody_system%L_total_orig(:)) nbody_system%Mescape_error = nbody_system%GMescape / nbody_system%GMtot_orig +#ifdef COARRAY + if (this_image() == 1 .or. param%log_output) then +#endif + if (lterminal) then + write(display_unit, EGYTERMFMT) nbody_system%L_total_error, nbody_system%E_orbit_error, nbody_system%te_error,nbody_system%Mtot_error + if (param%log_output) flush(display_unit) + end if - if (lterminal) write(display_unit, EGYTERMFMT) nbody_system%L_total_error, nbody_system%E_orbit_error, nbody_system%te_error,nbody_system%Mtot_error +#ifdef COARRAY + end if ! (this_image() == 1) then +#endif if (abs(nbody_system%Mtot_error) > 100 * epsilon(nbody_system%Mtot_error)) then write(*,*) "Severe error! Mass not conserved! Halting!" ! Save the frame of data to the bin file in the slot just after the present one for diagnostics - call self%write_frame(nc, param) - call nc%close() call base_util_exit(FAILURE) end if end if end associate return - - 667 continue - write(*,*) "Error writing energy and momentum tracking file: " // trim(adjustl(errmsg)) - call base_util_exit(FAILURE) end subroutine swiftest_io_conservation_report @@ -219,13 +220,21 @@ module subroutine swiftest_io_display_run_information(self, param, integration_t real(DP) :: tfrac !! Fraction of total simulation time completed type(progress_bar), save :: pbar !! Object used to print out a progress bar character(len=64) :: pbarmessage - character(*), parameter :: symbacompactfmt = '(";NPLM",ES22.15,$)' +#ifdef COARRAY + character(*), parameter :: co_statusfmt = '("Image: ",I4, "; Time = ", ES12.5, "; fraction done = ", F6.3, ' // & + '"; Number of active pl, tp = ", I6, ", ", I6)' + character(*), parameter :: co_symbastatfmt = '("Image: ",I4, "; Image: Time = ", ES12.5, "; fraction done = ", F6.3, ' // & + '"; Number of active pl, plm, tp = ", I6, ", ", I6, ", ", I6)' +#endif character(*), parameter :: statusfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, ' // & '"; Number of active pl, tp = ", I6, ", ", I6)' character(*), parameter :: symbastatfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, ' // & '"; Number of active pl, plm, tp = ", I6, ", ", I6, ", ", I6)' character(*), parameter :: pbarfmt = '("Time = ", ES12.5," of ",ES12.5)' +! The following will syncronize the images so that they report in order, and only write to file one at at ime + + phase_val = 1 if (present(phase)) then if (phase == "first") then @@ -237,36 +246,72 @@ module subroutine swiftest_io_display_run_information(self, param, integration_t tfrac = (self%t - param%t0) / (param%tstop - param%t0) - if (phase_val == 0) then - if (param%lrestart) then - write(param%display_unit, *) " *************** Swiftest restart " // param%integrator // " *************** " - else - write(param%display_unit, *) " *************** Swiftest start " // param%integrator // " *************** " - end if - if (param%display_style == "PROGRESS") then - call pbar%reset(param%nloops) - else if (param%display_style == "COMPACT") then - write(*,*) "SWIFTEST START " // param%integrator +#ifdef COARRAY + if (this_image() == 1 .or. param%log_output) then +#endif + if (phase_val == 0) then + if (param%lrestart) then + write(param%display_unit, *) " *************** Swiftest restart " // trim(adjustl(param%integrator)) // " *************** " + else + write(param%display_unit, *) " *************** Swiftest start " // trim(adjustl(param%integrator)) // " *************** " + end if + if (param%display_style == "PROGRESS") then + call pbar%reset(param%nloops) + else if (param%display_style == "COMPACT") then + write(*,*) "SWIFTEST START " // trim(adjustl(param%integrator)) + end if end if - end if +#ifdef COARRAY + end if !(this_image() == 1) +#endif if (param%display_style == "PROGRESS") then - write(pbarmessage,fmt=pbarfmt) self%t, param%tstop - call pbar%update(1_I8B,message=pbarmessage) +#ifdef COARRAY + if (this_image() == 1) then +#endif + write(pbarmessage,fmt=pbarfmt) self%t, param%tstop + call pbar%update(param%iloop,message=pbarmessage) +#ifdef COARRAY + end if !(this_image() == 1) +#endif else if (param%display_style == "COMPACT") then call self%compact_output(param,integration_timer) end if - if (self%pl%nplm > 0) then - write(param%display_unit, symbastatfmt) self%t, tfrac, self%pl%nbody, self%pl%nplm, self%tp%nbody + if (param%lmtiny_pl) then +#ifdef COARRAY + if (param%lcoarray) then + write(param%display_unit, co_symbastatfmt) this_image(),self%t, tfrac, self%pl%nbody, self%pl%nplm, self%tp%nbody + else +#endif + write(param%display_unit, symbastatfmt) self%t, tfrac, self%pl%nbody, self%pl%nplm, self%tp%nbody +#ifdef COARRAY + end if +#endif else - write(param%display_unit, statusfmt) self%t, tfrac, self%pl%nbody, self%tp%nbody +#ifdef COARRAY + if (param%lcoarray) then + write(param%display_unit, co_statusfmt) this_image(),self%t, tfrac, self%pl%nbody, self%tp%nbody + else +#endif + write(param%display_unit, statusfmt) self%t, tfrac, self%pl%nbody, self%tp%nbody +#ifdef COARRAY + end if +#endif end if - if (phase_val == -1) then - write(param%display_unit, *)" *************** Swiftest stop " // param%integrator // " *************** " - if (param%display_style == "COMPACT") write(*,*) "SWIFTEST STOP" // param%integrator - end if +#ifdef COARRAY + if (this_image() == num_images() .or. param%log_output) then +#endif + if (phase_val == -1) then + write(param%display_unit, *)" *************** Swiftest stop " // trim(adjustl(param%integrator)) // " *************** " + if (param%display_style == "COMPACT") write(*,*) "SWIFTEST STOP" // trim(adjustl(param%integrator)) + end if + +#ifdef COARRAY + end if ! this_image() == num_images() + if (param%log_output) flush(param%display_unit) +#endif return end subroutine swiftest_io_display_run_information @@ -303,7 +348,7 @@ module subroutine swiftest_io_dump_param(self, param_file_name) end subroutine swiftest_io_dump_param - module subroutine swiftest_io_dump_system(self, param) + module subroutine swiftest_io_dump_system(self, param, system_history) !! author: David A. Minton !! !! Dumps the state of the nbody_system to files in case the simulation is interrupted. @@ -313,6 +358,7 @@ module subroutine swiftest_io_dump_system(self, param) ! Arguments class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_storage), intent(inout) :: system_history !! Stores the system history between output dumps ! Internals class(swiftest_parameters), allocatable :: param_restart !! Local parameters variable used to parameters change input file names !! to dump file-specific values without changing the user-defined values @@ -324,21 +370,26 @@ module subroutine swiftest_io_dump_system(self, param) if (allocated(self%collision_history)) call self%collision_history%dump(param) ! Dump the nbody_system history to file - call self%system_history%dump(param) - - allocate(param_restart, source=param) - param_restart%in_form = "XV" - param_restart%out_stat = 'APPEND' - param_restart%in_type = "NETCDF_DOUBLE" - param_restart%nc_in = param%outfile - param_restart%lrestart = .true. - param_restart%tstart = self%t - param_file_name = trim(adjustl(PARAM_RESTART_FILE)) - call param_restart%dump(param_file_name) - write(time_text,'(I0.20)') param%iloop - param_file_name = "param." // trim(adjustl(time_text)) // ".in" - call param_restart%dump(param_file_name) - + call system_history%dump(param) + +#ifdef COARRAY + if (this_image() == 1) then +#endif + allocate(param_restart, source=param) + param_restart%in_form = "XV" + param_restart%out_stat = 'APPEND' + param_restart%in_type = "NETCDF_DOUBLE" + param_restart%nc_in = param%outfile + param_restart%lrestart = .true. + param_restart%tstart = self%t + param_file_name = trim(adjustl(PARAM_RESTART_FILE)) + call param_restart%dump(param_file_name) + write(time_text,'(I0.20)') param%iloop + param_file_name = "param." // trim(adjustl(time_text)) // ".in" + call param_restart%dump(param_file_name) +#ifdef COARRAY + end if ! (this_image() == 1) +#endif return end subroutine swiftest_io_dump_system @@ -353,26 +404,43 @@ module subroutine swiftest_io_dump_storage(self, param) implicit none ! Arguments class(swiftest_storage), intent(inout) :: self !! Swiftest simulation history storage object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals integer(I4B) :: i +#ifdef COARRAY + type(walltimer) :: iotimer +#endif if (self%iframe == 0) return call self%make_index_map() associate(nc => self%nc) +#ifdef COARRAY + sync all + write(param%display_unit,*) "File output started" + call iotimer%start() + critical +#endif call nc%open(param) - do i = 1, self%iframe + ! Writing files is more efficient if we write out the common frames from each image before going to the next frame if (allocated(self%frame(i)%item)) then select type(nbody_system => self%frame(i)%item) class is (swiftest_nbody_system) - call nbody_system%write_frame(param) + call nbody_system%write_frame(nc, param) end select deallocate(self%frame(i)%item) end if end do call nc%close() +#ifdef COARRAY + end critical + call iotimer%stop() + sync all + call iotimer%report(message="File output :", unit=param%display_unit) + flush(param%display_unit) +#endif end associate + call self%reset() return end subroutine swiftest_io_dump_storage @@ -391,7 +459,6 @@ module subroutine swiftest_io_get_args(integrator, param_file_name, display_styl character(len=STRMAX), dimension(:), allocatable :: arg integer(I4B), dimension(:), allocatable :: ierr integer :: i,narg - character(len=*),parameter :: linefmt = '(A)' narg = command_argument_count() if (narg > 0) then @@ -566,23 +633,25 @@ module subroutine swiftest_io_netcdf_flush(self, param) end subroutine swiftest_io_netcdf_flush - module subroutine swiftest_io_netcdf_get_t0_values_system(self, param) + module subroutine swiftest_io_netcdf_get_t0_values_system(self, nc, param) !! author: David A. Minton !! !! Gets the t0 values of various parameters such as energy and momentum !! implicit none ! Arguments - class(swiftest_nbody_system), intent(inout) :: self - class(swiftest_parameters), intent(inout) :: param + class(swiftest_nbody_system), intent(inout) :: self + class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset + class(swiftest_parameters), intent(inout) :: param ! Internals integer(I4B) :: itmax, idmax, tslot real(DP), dimension(:), allocatable :: vals + logical, dimension(:), allocatable :: plmask, tpmask real(DP), dimension(1) :: rtemp real(DP), dimension(NDIM) :: rot0, Ip0, L real(DP) :: mass0 - associate (nc => self%system_history%nc, cb => self%cb) + associate (cb => self%cb) call nc%open(param, readonly=.true.) call nc%find_tslot(param%t0, tslot) call netcdf_io_check( nf90_inquire_dimension(nc%id, nc%time_dimid, len=itmax), "netcdf_io_get_t0_values_system time_dimid" ) @@ -614,7 +683,8 @@ module subroutine swiftest_io_netcdf_get_t0_values_system(self, param) self%L_total_orig(:) = self%L_orbit_orig(:) + self%L_spin_orig(:) call netcdf_io_check( nf90_get_var(nc%id, nc%Gmass_varid, vals, start=[1,tslot], count=[idmax,1]), "netcdf_io_get_t0_values_system Gmass_varid" ) - self%GMtot_orig = vals(1) + sum(vals(2:idmax), vals(2:idmax) == vals(2:idmax)) + call nc%get_valid_masks(plmask,tpmask) + self%GMtot_orig = vals(1) + sum(vals(2:idmax), plmask(:)) cb%GM0 = vals(1) cb%dGM = cb%Gmass - cb%GM0 @@ -849,7 +919,6 @@ module subroutine swiftest_io_netcdf_open(self, param, readonly) end if associate(nc => self) - write(errmsg,*) "swiftest_io_netcdf_open nf90_open ",trim(adjustl(nc%file_name)) call netcdf_io_check( nf90_open(nc%file_name, mode, nc%id), errmsg) self%lfile_is_open = .true. @@ -911,7 +980,6 @@ module subroutine swiftest_io_netcdf_open(self, param, readonly) ! Optional variables The User Doesn't Need to Know About status = nf90_inq_varid(nc%id, nc%mass_varname, nc%mass_varid) status = nf90_inq_varid(nc%id, nc%rhill_varname, nc%rhill_varid) - param%lrhill_present = (status == NF90_NOERR) status = nf90_inq_varid(nc%id, nc%npl_varname, nc%npl_varid) status = nf90_inq_varid(nc%id, nc%status_varname, nc%status_varid) status = nf90_inq_varid(nc%id, nc%ntp_varname, nc%ntp_varid) @@ -957,22 +1025,30 @@ module subroutine swiftest_io_netcdf_open(self, param, readonly) end subroutine swiftest_io_netcdf_open - module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask) + module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask, plmmask, Gmtiny) !! author: David A. Minton !! !! Given an open NetCDF, returns logical masks indicating which bodies in the body arrays are active pl and tp type at the current time. !! Uses the value of tslot stored in the NetCDF parameter object as the definition of current time + use, intrinsic :: ieee_exceptions + use, intrinsic :: ieee_arithmetic implicit none ! Arguments - class(swiftest_netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset - logical, dimension(:), allocatable, intent(out) :: plmask !! Logical mask indicating which bodies are massive bodies - logical, dimension(:), allocatable, intent(out) :: tpmask !! Logical mask indicating which bodies are test particles + class(swiftest_netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset + logical, dimension(:), allocatable, intent(out) :: plmask !! Logical mask indicating which bodies are massive bodies + logical, dimension(:), allocatable, intent(out) :: tpmask !! Logical mask indicating which bodies are test particles + logical, dimension(:), allocatable, intent(out), optional :: plmmask !! Logical mask indicating which bodies are fully interacting massive bodies + real(DP), intent(in), optional :: Gmtiny !! The cutoff G*mass between semi-interacting and fully interacting massive bodies ! Internals real(DP), dimension(:), allocatable :: Gmass, a real(DP), dimension(:,:), allocatable :: rh integer(I4B), dimension(:), allocatable :: body_status logical, dimension(:), allocatable :: lvalid integer(I4B) :: idmax, status + logical, dimension(size(IEEE_ALL)) :: fpe_halting_modes + + call ieee_get_halting_mode(IEEE_ALL,fpe_halting_modes) ! Save the current halting modes so we can turn them off temporarily + call ieee_set_halting_mode(IEEE_ALL,.false.) call netcdf_io_check( nf90_inquire_dimension(self%id, self%name_dimid, len=idmax), "swiftest_io_netcdf_get_valid_masks nf90_inquire_dimension name_dimid" ) @@ -980,7 +1056,6 @@ module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask) allocate(tpmask(idmax)) allocate(plmask(idmax)) allocate(lvalid(idmax)) - associate(tslot => self%tslot) call netcdf_io_check( nf90_get_var(self%id, self%Gmass_varid, Gmass, start=[1,tslot], count=[idmax,1]), "swiftest_io_netcdf_get_valid_masks nf90_getvar Gmass_varid" ) @@ -989,26 +1064,27 @@ module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask) if (status == NF90_NOERR) then allocate(body_status(idmax)) call netcdf_io_check( nf90_get_var(self%id, self%status_varid, body_status, start=[1, tslot], count=[idmax,1]), "swiftest_io_netcdf_get_valid_masks nf90_getvar status_varid" ) - lvalid(:) = body_status /= INACTIVE + lvalid(:) = body_status(:) /= INACTIVE else status = nf90_inq_varid(self%id, self%rh_varname, self%rh_varid) if (status == NF90_NOERR) then allocate(rh(NDIM,idmax)) call netcdf_io_check( nf90_get_var(self%id, self%rh_varid, rh, start=[1, 1, tslot], count=[NDIM,idmax,1]), "swiftest_io_netcdf_get_valid_masks nf90_getvar rh_varid" ) - lvalid(:) = rh(1,:) == rh(1,:) + lvalid(:) = ieee_is_normal(rh(1,:)) else status = nf90_inq_varid(self%id, self%a_varname, self%a_varid) if (status == NF90_NOERR) then allocate(a(idmax)) call netcdf_io_check( nf90_get_var(self%id, self%a_varid, a, start=[1, tslot], count=[idmax,1]), "swiftest_io_netcdf_get_valid_masks nf90_getvar a_varid" ) - lvalid(:) = a(:) == a(:) + lvalid(:) = ieee_is_normal(a(:)) else lvalid(:) = .false. end if end if end if - plmask(:) = Gmass(:) == Gmass(:) + plmask(:) = ieee_is_normal(Gmass(:)) + where(plmask(:)) plmask(:) = Gmass(:) > 0.0_DP tpmask(:) = .not. plmask(:) plmask(1) = .false. ! This is the central body @@ -1016,6 +1092,15 @@ module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask) plmask(:) = plmask(:) .and. lvalid(:) tpmask(:) = tpmask(:) .and. lvalid(:) + if (present(plmmask) .and. present(Gmtiny)) then + allocate(plmmask, source=plmask) + where(plmask(:)) + plmmask = Gmass(:) > Gmtiny + endwhere + end if + + call ieee_set_halting_mode(IEEE_ALL,fpe_halting_modes) + end associate return @@ -1068,10 +1153,14 @@ module function swiftest_io_netcdf_read_frame_system(self, nc, param) result(ier if (npl_check /= npl) then write(*,*) "Error reading in NetCDF file: The recorded value of npl does not match the number of active massive bodies" + write(*,*) "Recorded: ",npl + write(*,*) "Active : ",npl_check end if if (ntp_check /= ntp) then write(*,*) "Error reading in NetCDF file: The recorded value of ntp does not match the number of active test particles" + write(*,*) "Recorded: ",ntp + write(*,*) "Active : ",ntp_check call base_util_exit(failure) end if @@ -1156,7 +1245,6 @@ module function swiftest_io_netcdf_read_frame_system(self, nc, param) result(ier status = nf90_get_var(nc%id, nc%rhill_varid, rtemp, start=[1, tslot], count=[idmax,1]) if (status == NF90_NOERR) then pl%rhill(:) = pack(rtemp, plmask) - param%lrhill_present = .true. end if end if @@ -1233,10 +1321,6 @@ module function swiftest_io_netcdf_read_frame_system(self, nc, param) result(ier ierr = 0 return - - 667 continue - write(*,*) "Error reading nbody_system frame in netcdf_io_read_frame_system" - end function swiftest_io_netcdf_read_frame_system @@ -1252,21 +1336,15 @@ module subroutine swiftest_io_netcdf_read_hdr_system(self, nc, param) class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to for reading a NetCDF dataset to file class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: status, idmax + integer(I4B) :: status logical, dimension(:), allocatable :: plmask, tpmask, plmmask - real(DP), dimension(:), allocatable :: Gmtemp associate(tslot => nc%tslot) call netcdf_io_check( nf90_get_var(nc%id, nc%time_varid, self%t, start=[tslot]), "netcdf_io_read_hdr_system nf90_getvar time_varid" ) - call nc%get_valid_masks(plmask, tpmask) - if (param%lmtiny_pl) then - idmax = size(plmask) - allocate(plmmask(idmax)) - allocate(Gmtemp(idmax)) - call netcdf_io_check( nf90_get_var(nc%id, nc%Gmass_varid, Gmtemp, start=[1,tslot], count=[idmax,1]), "netcdf_io_read_hdr_system nf90_getvar Gmass_varid" ) - where(Gmtemp(:) /= Gmtemp(:)) Gmtemp(:) = 0.0_DP - plmmask(:) = plmask(:) .and. Gmtemp(:) > param%GMTINY + call nc%get_valid_masks(plmask, tpmask, plmmask, param%GMTINY) + else + call nc%get_valid_masks(plmask, tpmask) end if status = nf90_inq_varid(nc%id, nc%npl_varname, nc%npl_varid) @@ -1541,10 +1619,14 @@ module subroutine swiftest_io_netcdf_write_frame_body(self, nc, param) class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to for writing a NetCDF dataset to file class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i, j, idslot, old_mode + integer(I4B) :: i, j, idslot, old_mode, tmp integer(I4B), dimension(:), allocatable :: ind real(DP), dimension(NDIM) :: vh !! Temporary variable to store heliocentric velocity values when converting from pseudovelocity in GR-enabled runs real(DP) :: a, e, inc, omega, capom, capm, varpi, lam, f, cape, capf +#ifdef COARRAY + integer(I4B) :: ntp + logical, dimension(:), allocatable :: tpmask, plmask +#endif call self%write_info(nc, param) @@ -1556,7 +1638,7 @@ module subroutine swiftest_io_netcdf_write_frame_body(self, nc, param) associate(n => self%nbody, tslot => nc%tslot) if (n == 0) return - call swiftest_util_sort(self%id(1:n), ind) + call util_sort(self%id(1:n), ind) do i = 1, n j = ind(i) @@ -1617,13 +1699,32 @@ module subroutine swiftest_io_netcdf_write_frame_body(self, nc, param) ! call netcdf_io_check( nf90_put_var(nc%id, nc%k2_varid, self%k2(j), start=[idslot, tslot]), "netcdf_io_write_frame_body nf90_put_var body k2_varid" ) ! call netcdf_io_check( nf90_put_var(nc%id, nc%Q_varid, self%Q(j), start=[idslot, tslot]), "netcdf_io_write_frame_body nf90_put_var body Q_varid" ) ! end if - + class is (swiftest_tp) + call netcdf_io_check( nf90_put_var(nc%id, nc%Gmass_varid, 0.0_DP, start=[idslot, tslot]), "netcdf_io_write_frame_body nf90_put_var body Gmass_varid" ) + call netcdf_io_check( nf90_put_var(nc%id, nc%mass_varid, 0.0_DP, start=[idslot, tslot]), "netcdf_io_write_frame_body nf90_put_var body mass_varid" ) + if (param%lrhill_present) then + call netcdf_io_check( nf90_put_var(nc%id, nc%rhill_varid, 0.0_DP, start=[idslot, tslot]), "netcdf_io_write_frame_body nf90_put_var body rhill_varid" ) + end if + if (param%lclose) call netcdf_io_check( nf90_put_var(nc%id, nc%radius_varid, 0.0_DP, start=[idslot, tslot]), "netcdf_io_write_frame_body nf90_put_var body radius_varid" ) + if (param%lrotation) then + call netcdf_io_check( nf90_put_var(nc%id, nc%Ip_varid, [0.0_DP,0.0_DP,0.0_DP], start=[1,idslot, tslot], count=[NDIM,1,1]), "netcdf_io_write_frame_body nf90_put_var body Ip_varid" ) + call netcdf_io_check( nf90_put_var(nc%id, nc%rot_varid, [0.0_DP,0.0_DP,0.0_DP], start=[1,idslot, tslot], count=[NDIM,1,1]), "netcdf_io_write_frame_body nf90_put_var body rotx_varid" ) + end if end select end do end associate end select end select - call netcdf_io_check( nf90_set_fill(nc%id, old_mode, old_mode), "netcdf_io_write_frame_body nf90_set_fill old_mode" ) +#ifdef COARRAY + select type(self) + class is (swiftest_tp) + call nc%get_valid_masks(plmask, tpmask) + ntp = count(tpmask(:)) + call netcdf_io_check( nf90_put_var(nc%id, nc%ntp_varid, ntp, start=[nc%tslot]), "netcdf_io_write_frame_body nf90_put_var ntp_varid" ) + end select +#endif + + call netcdf_io_check( nf90_set_fill(nc%id, old_mode, tmp), "netcdf_io_write_frame_body nf90_set_fill old_mode" ) return end subroutine swiftest_io_netcdf_write_frame_body @@ -1639,7 +1740,7 @@ module subroutine swiftest_io_netcdf_write_frame_cb(self, nc, param) class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to for writing a NetCDF dataset to file class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: idslot, old_mode + integer(I4B) :: idslot, old_mode, tmp associate(tslot => nc%tslot) call self%write_info(nc, param) @@ -1660,7 +1761,7 @@ module subroutine swiftest_io_netcdf_write_frame_cb(self, nc, param) call netcdf_io_check( nf90_put_var(nc%id, nc%rot_varid, self%rot(:) * RAD2DEG, start=[1, idslot, tslot], count=[NDIM,1,1]), "swiftest_io_netcdf_write_frame_cby nf90_put_var cb rot_varid" ) end if - call netcdf_io_check( nf90_set_fill(nc%id, old_mode, old_mode), "swiftest_io_netcdf_write_frame_cb nf90_set_fill old_mode" ) + call netcdf_io_check( nf90_set_fill(nc%id, old_mode, tmp), "swiftest_io_netcdf_write_frame_cb nf90_set_fill old_mode" ) end associate return @@ -1678,8 +1779,14 @@ module subroutine swiftest_io_netcdf_write_frame_system(self, nc, param) class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters call self%write_hdr(nc, param) - call self%cb%write_frame(nc, param) - call self%pl%write_frame(nc, param) +#ifdef COARRAY + if (this_image() == 1) then +#endif + call self%cb%write_frame(nc, param) + call self%pl%write_frame(nc, param) +#ifdef COARRAY + end if ! this_image() == 1 +#endif call self%tp%write_frame(nc, param) return @@ -1698,13 +1805,14 @@ module subroutine swiftest_io_netcdf_write_hdr_system(self, nc, param) class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to for writing a NetCDF dataset to file class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i,tslot, idmax - integer(I4B), dimension(:), allocatable :: body_status + integer(I4B) :: tslot call nc%find_tslot(self%t, tslot) call netcdf_io_check( nf90_put_var(nc%id, nc%time_varid, self%t, start=[tslot]), "netcdf_io_write_hdr_system nf90_put_var time_varid" ) call netcdf_io_check( nf90_put_var(nc%id, nc%npl_varid, self%pl%nbody, start=[tslot]), "netcdf_io_write_hdr_system nf90_put_var npl_varid" ) +#ifndef COARRAY call netcdf_io_check( nf90_put_var(nc%id, nc%ntp_varid, self%tp%nbody, start=[tslot]), "netcdf_io_write_hdr_system nf90_put_var ntp_varid" ) +#endif if (param%lmtiny_pl) call netcdf_io_check( nf90_put_var(nc%id, nc%nplm_varid, self%pl%nplm, start=[tslot]), "netcdf_io_write_hdr_system nf90_put_var nplm_varid" ) if (param%lenergy) then @@ -1721,10 +1829,6 @@ module subroutine swiftest_io_netcdf_write_hdr_system(self, nc, param) call netcdf_io_check( nf90_put_var(nc%id, nc%GMescape_varid, self%GMescape, start=[tslot]), "netcdf_io_write_hdr_system nf90_put_var GMescape_varid" ) end if - ! Set the status flag to INACTIVE by default - call netcdf_io_check( nf90_inquire_dimension(nc%id, nc%name_dimid, len=idmax), "netcdf_io_get_t0_values_system name_dimid" ) - call netcdf_io_check( nf90_put_var(nc%id, nc%status_varid, [(INACTIVE, i=1,idmax)], start=[1,tslot], count=[idmax,1]), "netcdf_io_write_info_body nf90_put_var status_varid" ) - return end subroutine swiftest_io_netcdf_write_hdr_system @@ -1739,7 +1843,7 @@ module subroutine swiftest_io_netcdf_write_info_body(self, nc, param) class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i, j, idslot, old_mode + integer(I4B) :: i, j, idslot, old_mode, tmp integer(I4B), dimension(:), allocatable :: ind character(len=NAMELEN) :: charstring character(len=NAMELEN), dimension(self%nbody) :: origin_type @@ -1750,7 +1854,7 @@ module subroutine swiftest_io_netcdf_write_info_body(self, nc, param) class is (swiftest_body) associate(n => self%nbody, tslot => nc%tslot) if (n == 0) return - call swiftest_util_sort(self%id(1:n), ind) + call util_sort(self%id(1:n), ind) call nc%get_idvals() do i = 1, n @@ -1783,7 +1887,7 @@ module subroutine swiftest_io_netcdf_write_info_body(self, nc, param) end associate end select - call netcdf_io_check( nf90_set_fill(nc%id, old_mode, old_mode) ) + call netcdf_io_check( nf90_set_fill(nc%id, old_mode, tmp) ) return end subroutine swiftest_io_netcdf_write_info_body @@ -1797,7 +1901,7 @@ module subroutine swiftest_io_netcdf_write_info_cb(self, nc, param) class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: idslot, old_mode + integer(I4B) :: idslot, old_mode, tmp character(len=NAMELEN) :: charstring ! This string of spaces of length NAMELEN is used to clear out any old data left behind inside the string variables @@ -1826,7 +1930,7 @@ module subroutine swiftest_io_netcdf_write_info_cb(self, nc, param) call netcdf_io_check( nf90_put_var(nc%id, nc%discard_rh_varid, self%info%discard_rh(:), start=[1, idslot], count=[NDIM,1]), "netcdf_io_write_info_body nf90_put_var cb discard_rh_varid" ) call netcdf_io_check( nf90_put_var(nc%id, nc%discard_vh_varid, self%info%discard_vh(:), start=[1, idslot], count=[NDIM,1]), "netcdf_io_write_info_body nf90_put_var cb discard_vh_varid" ) end if - call netcdf_io_check( nf90_set_fill(nc%id, old_mode, old_mode) ) + call netcdf_io_check( nf90_set_fill(nc%id, old_mode, tmp) ) return end subroutine swiftest_io_netcdf_write_info_cb @@ -1871,7 +1975,7 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i integer(I4B), intent(out) :: iostat !! IO status code character(len=*), intent(inout) :: iomsg !! Message to pass if iostat /= 0 ! Internals - logical :: tstart_set = .false. !! Is the final time set in the input file? + logical :: tstart_set = .false. !! Is the final time set in the input file? logical :: tstop_set = .false. !! Is the final time set in the input file? logical :: dt_set = .false. !! Is the step size set in the input file? integer(I4B) :: ilength, ifirst, ilast, i !! Variables used to parse input file @@ -1880,12 +1984,17 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i character(*),parameter :: linefmt = '(A)' !! Format code for simple text string integer(I4B) :: nseeds, nseeds_from_file logical :: seed_set = .false. !! Is the random seed set in the input file? - character(len=:), allocatable :: integrator real(DP) :: tratio, y - - - ! Parse the file line by line, extracting tokens then matching them up with known parameters if possible +#ifdef COARRAY + type(swiftest_parameters), codimension[*], save :: coparam + + if (this_image() == 1) then + coparam = self + associate(param => coparam) +#else associate(param => self) +#endif + ! Parse the file line by line, extracting tokens then matching them up with known parameters if possible call random_seed(size = nseeds) if (allocated(param%seed)) deallocate(param%seed) allocate(param%seed(nseeds)) @@ -2060,6 +2169,9 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i case ("ENCOUNTER_SAVE") call swiftest_io_toupper(param_value) read(param_value, *) param%encounter_save + case ("COARRAY") + call swiftest_io_toupper(param_value) + if (param_value == "YES" .or. param_value == 'T') param%lcoarray = .true. case("SEED") read(param_value, *) nseeds_from_file ! Because the number of seeds can vary between compilers/systems, we need to make sure we can handle cases in which the input file has a different @@ -2198,9 +2310,6 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i ! Calculate the G for the nbody_system units param%GU = GC / (param%DU2M**3 / (param%MU2KG * param%TU2S**2)) - ! A minimal log of collision outcomes is stored in the following log file - ! More complete data on collisions is stored in the NetCDF output files - call swiftest_io_log_start(param, COLLISION_LOG_OUT, "Collision logfile") if ((param%encounter_save /= "NONE") .and. & (param%encounter_save /= "TRAJECTORY") .and. & @@ -2306,14 +2415,57 @@ module subroutine swiftest_io_param_reader(self, unit, iotype, v_list, iostat, i param%lencounter_sas_pltp = .false. end select + + if (param%lcoarray) then +#ifdef COARRAY + if (num_images() == 1) then + write(iomsg, *) "Only one Coarray image detected. Coarrays will not be used." + param%lcoarray = .false. + end if + + select case(param%integrator) + case(INT_WHM, INT_RMVS, INT_HELIO) + case default + write(iomsg, *) "Coarray-based parallelization of test particles are not compatible with this integrator. This parameter will be ignored." + param%lcoarray = .false. + end select +#else + write(iomsg,*) "Coarray capability not detected. Swiftest must be compiled with Coarrays enabled. to use this feature." + param%lcoarray = .false. +#endif + end if + iostat = 0 + end associate + +#ifdef COARRAY + end if ! this_image() == 1 + call coparam%coclone() +#endif + select type(param => self) + type is (swiftest_parameters) +#ifdef COARRAY + param = coparam +#endif call param%set_display(param%display_style) - - ! Print the contents of the parameter file to standard output - if (.not.param%lrestart) call param%writer(unit = param%display_unit, iotype = "none", v_list = [0], iostat = iostat, iomsg = iomsg) - end associate + if (.not.param%lrestart) then +#ifdef COARRAY + if (this_image() == 1 .or. param%log_output) then +#endif + call param%writer(unit = param%display_unit, iotype = "none", v_list = [0], iostat = iostat, iomsg = iomsg) + if (param%log_output) flush(param%display_unit) +#ifdef COARRAY + end if !(this_image() == 1) + write(COLLISION_LOG_OUT,'("collision_coimage",I0.3,".log")') this_image() +#endif + ! A minimal log of collision outcomes is stored in the following log file + ! More complete data on collisions is stored in the NetCDF output files + call swiftest_io_log_start(param, COLLISION_LOG_OUT, "Collision logfile") + end if + ! Print the contents of the parameter file to standard output + end select return 667 continue @@ -2359,9 +2511,6 @@ module subroutine swiftest_io_param_writer(self, unit, iotype, v_list, iostat, i integer, intent(out) :: iostat !! IO status code character(len=*), intent(inout) :: iomsg !! Message to pass if iostat /= 0 ! Internals - character(*),parameter :: Ifmt = '(I0)' !! Format label for integer values - character(*),parameter :: Rfmt = '(ES25.17)' !! Format label for real values - character(*),parameter :: Lfmt = '(L1)' !! Format label for logical values integer(I4B) :: nseeds associate(param => self) @@ -2409,6 +2558,7 @@ module subroutine swiftest_io_param_writer(self, unit, iotype, v_list, iostat, i call io_param_writer_one("ENCOUNTER_CHECK_PLPL", param%encounter_check_plpl, unit) call io_param_writer_one("ENCOUNTER_CHECK_PLTP", param%encounter_check_pltp, unit) call io_param_writer_one("ENCOUNTER_SAVE", param%encounter_save, unit) + call io_param_writer_one("COARRAY", param%lcoarray, unit) if (param%lenergy) then call io_param_writer_one("FIRSTENERGY", param%lfirstenergy, unit) @@ -2429,7 +2579,6 @@ module subroutine swiftest_io_param_writer(self, unit, iotype, v_list, iostat, i iomsg = "UDIO not implemented" end associate - 667 continue return end subroutine swiftest_io_param_writer @@ -2734,14 +2883,15 @@ module subroutine swiftest_io_read_in_cb(self, param) end subroutine swiftest_io_read_in_cb - module subroutine swiftest_io_read_in_system(self, param) + module subroutine swiftest_io_read_in_system(self, nc, param) !! author: David A. Minton and Carlisle A. Wishard !! !! Reads in the nbody_system from input files implicit none ! Arguments - class(swiftest_nbody_system), intent(inout) :: self - class(swiftest_parameters), intent(inout) :: param + class(swiftest_nbody_system), intent(inout) :: self + class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset + class(swiftest_parameters), intent(inout) :: param ! Internals integer(I4B) :: ierr, i class(swiftest_parameters), allocatable :: tmp_param @@ -2764,21 +2914,30 @@ module subroutine swiftest_io_read_in_system(self, param) self%E_untracked = param%E_untracked else allocate(tmp_param, source=param) - self%system_history%nc%file_name = param%nc_in + nc%file_name = param%nc_in tmp_param%out_form = param%in_form if (.not. param%lrestart) then ! Turn off energy computation so we don't have to feed it into the initial conditions tmp_param%lenergy = .false. end if - ierr = self%read_frame(self%system_history%nc, tmp_param) + ierr = self%read_frame(nc, tmp_param) deallocate(tmp_param) if (ierr /=0) call base_util_exit(FAILURE) end if - param%loblatecb = ((self%cb%j2rp2 /= 0.0_DP) .or. (self%cb%j4rp4 /= 0.0_DP)) + param%loblatecb = ((abs(self%cb%j2rp2) > 0.0_DP) .or. (abs(self%cb%j4rp4) > 0.0_DP)) if (.not.param%loblatecb) then if (allocated(self%pl%aobl)) deallocate(self%pl%aobl) if (allocated(self%tp%aobl)) deallocate(self%tp%aobl) + else + if (self%pl%nbody > 0) then + if (.not. allocated(self%pl%aobl)) allocate(self%pl%aobl(NDIM,self%pl%nbody)) + self%pl%aobl(:,:) = 0.0_DP + end if + if (self%tp%nbody > 0) then + if (.not. allocated(self%tp%aobl)) allocate(self%tp%aobl(NDIM,self%tp%nbody)) + self%tp%aobl(:,:) = 0.0_DP + end if end if return @@ -2914,7 +3073,6 @@ module subroutine swiftest_io_read_in_param(self, param_file_name) call self%reader(LUN, iotype= "none", v_list=[""], iostat = ierr, iomsg = errmsg) if (ierr == 0) return - 667 continue write(self%display_unit,*) "Error reading parameter file: " // trim(adjustl(errmsg)) call base_util_exit(FAILURE) end subroutine swiftest_io_read_in_param @@ -2938,6 +3096,13 @@ module subroutine swiftest_io_set_display_param(self, display_style) self%display_unit = OUTPUT_UNIT !! stdout from iso_fortran_env self%log_output = .false. case ('COMPACT', 'PROGRESS') +#ifdef COARRAY + if (self%lcoarray) then + write(SWIFTEST_LOG_FILE,'("swiftest_coimage",I0.3,".log")') this_image() + else + write(SWIFTEST_LOG_FILE,'("swiftest.log")') + end if +#endif inquire(file=SWIFTEST_LOG_FILE, exist=fileExists) if (self%lrestart.and.fileExists) then open(unit=SWIFTEST_LOG_OUT, file=SWIFTEST_LOG_FILE, status="OLD", position="APPEND", err = 667, iomsg = errmsg) @@ -2986,7 +3151,7 @@ module subroutine swiftest_io_toupper(string) end subroutine swiftest_io_toupper - module subroutine swiftest_io_write_frame_system(self, param) + module subroutine swiftest_io_initialize_output_file_system(self, nc, param) !! author: The Purdue Swiftest Team - David A. Minton, Carlisle A. Wishard, Jennifer L.L. Pouplin, and Jacob R. Elliott !! !! Write a frame (header plus records for each massive body and active test particle) to output binary file @@ -2996,28 +3161,32 @@ module subroutine swiftest_io_write_frame_system(self, param) !! Adapted from Hal Levison's Swift routine io_write_frame.f implicit none ! Arguments - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object + class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals logical, save :: lfirst = .true. !! Flag to determine if this is the first call of this method - character(len=STRMAX) :: errmsg + character(len=2*STRMAX) :: errmsg logical :: fileExists - associate (nc => self%system_history%nc, pl => self%pl, tp => self%tp, npl => self%pl%nbody, ntp => self%tp%nbody) + associate (pl => self%pl, tp => self%tp, npl => self%pl%nbody, ntp => self%tp%nbody) nc%file_name = param%outfile if (lfirst) then inquire(file=param%outfile, exist=fileExists) +#ifdef COARRAY + if (this_image() /= 1) param%out_stat = 'APPEND' +#endif select case(param%out_stat) case('APPEND') if (.not.fileExists) then - errmsg = param%outfile // " not found! You must specify OUT_STAT = NEW, REPLACE, or UNKNOWN" + errmsg = trim(adjustl(param%outfile)) // " not found! You must specify OUT_STAT = NEW, REPLACE, or UNKNOWN" goto 667 end if call nc%open(param) case('NEW') if (fileExists) then - errmsg = param%outfile // " Alread Exists! You must specify OUT_STAT = APPEND, REPLACE, or UNKNOWN" + errmsg = trim(adjustl(param%outfile)) // " Alread Exists! You must specify OUT_STAT = APPEND, REPLACE, or UNKNOWN" goto 667 end if call nc%initialize(param) @@ -3028,7 +3197,6 @@ module subroutine swiftest_io_write_frame_system(self, param) lfirst = .false. end if - call self%write_frame(nc, param) end associate return @@ -3036,6 +3204,6 @@ module subroutine swiftest_io_write_frame_system(self, param) 667 continue write(*,*) "Error writing nbody_system frame: " // trim(adjustl(errmsg)) call base_util_exit(FAILURE) - end subroutine swiftest_io_write_frame_system + end subroutine swiftest_io_initialize_output_file_system end submodule s_swiftest_io diff --git a/src/swiftest/swiftest_kick.f90 b/src/swiftest/swiftest_kick.f90 index 54da2f82a..82cefd26c 100644 --- a/src/swiftest/swiftest_kick.f90 +++ b/src/swiftest/swiftest_kick.f90 @@ -21,8 +21,9 @@ module subroutine swiftest_kick_getacch_int_pl(self, param) class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_parameters), intent(inout) :: param !! Current swiftest run configuration parameters ! Internals - logical, save :: lfirst = .true. - +#ifdef PROFILE + type(walltimer), save :: timer +#endif if (param%lflatten_interactions) then if (param%lclose) then @@ -134,7 +135,7 @@ module subroutine swiftest_kick_getacch_int_all_flat_norad_pl(npl, nplpl, k_plpl integer(I8B) :: k real(DP), dimension(NDIM,npl) :: ahi, ahj integer(I4B) :: i, j - real(DP) :: rji2, rlim2 + real(DP) :: rji2 real(DP) :: rx, ry, rz ahi(:,:) = 0.0_DP @@ -195,7 +196,11 @@ module subroutine swiftest_kick_getacch_int_all_tri_rad_pl(npl, nplm, r, Gmass, !$omp reduction(+:ahi) & !$omp reduction(-:ahj) do i = 1, nplm +#ifdef DOCONLOC + do concurrent(j = i+1:npl) shared(i,r,radius,ahi,ahj,Gmass) local(rx,ry,rz,rji2,rlim2) +#else do concurrent(j = i+1:npl) +#endif rx = r(1, j) - r(1, i) ry = r(2, j) - r(2, i) rz = r(3, j) - r(3, i) @@ -206,14 +211,22 @@ module subroutine swiftest_kick_getacch_int_all_tri_rad_pl(npl, nplm, r, Gmass, end do end do !$omp end parallel do +#ifdef DOCONLOC + do concurrent(i = 1:npl) shared(acc,ahi,ahj) +#else do concurrent(i = 1:npl) +#endif acc(:,i) = acc(:,i) + ahi(:,i) + ahj(:,i) end do else !$omp parallel do default(private) schedule(static)& !$omp shared(npl, nplm, r, Gmass, radius, acc) do i = 1, nplm +#ifdef DOCONLOC + do concurrent(j = 1:npl, i/=j) shared(i,r,radius,Gmass,acc) local(rx,ry,rz,rji2,rlim2,fac) +#else do concurrent(j = 1:npl, i/=j) +#endif rx = r(1,j) - r(1,i) ry = r(2,j) - r(2,i) rz = r(3,j) - r(3,i) @@ -233,7 +246,11 @@ module subroutine swiftest_kick_getacch_int_all_tri_rad_pl(npl, nplm, r, Gmass, !$omp parallel do default(private) schedule(static)& !$omp shared(npl, nplm, r, Gmass, radius, acc) do i = nplm+1,npl +#ifdef DOCONLOC + do concurrent(j = 1:nplm) shared(i,r,radius,Gmass,acc) local(rx,ry,rz,rji2,rlim2,fac) +#else do concurrent(j = 1:nplm) +#endif rx = r(1,j) - r(1,i) ry = r(2,j) - r(2,i) rz = r(3,j) - r(3,i) @@ -273,7 +290,7 @@ module subroutine swiftest_kick_getacch_int_all_tri_norad_pl(npl, nplm, r, Gmass real(DP), dimension(:,:), intent(inout) :: acc !! Acceleration vector array ! Internals integer(I4B) :: i, j, nplt - real(DP) :: rji2, rlim2, fac, rx, ry, rz + real(DP) :: rji2, fac, rx, ry, rz real(DP), dimension(NDIM,npl) :: ahi, ahj logical :: lmtiny @@ -288,7 +305,11 @@ module subroutine swiftest_kick_getacch_int_all_tri_norad_pl(npl, nplm, r, Gmass !$omp reduction(+:ahi) & !$omp reduction(-:ahj) do i = 1, nplm +#ifdef DOCONLOC + do concurrent(j = i+1:npl) shared(i,r,Gmass,ahi,ahj) local(rx,ry,rz,rji2) +#else do concurrent(j = i+1:npl) +#endif rx = r(1, j) - r(1, i) ry = r(2, j) - r(2, i) rz = r(3, j) - r(3, i) @@ -298,14 +319,22 @@ module subroutine swiftest_kick_getacch_int_all_tri_norad_pl(npl, nplm, r, Gmass end do end do !$omp end parallel do +#ifdef DOCONLOC + do concurrent(i = 1:npl) shared(acc,ahi,ahj) +#else do concurrent(i = 1:npl) +#endif acc(:,i) = acc(:,i) + ahi(:,i) + ahj(:,i) end do else !$omp parallel do default(private) schedule(static)& !$omp shared(npl, nplm, r, Gmass, acc) do i = 1, nplm +#ifdef DOCONLOC + do concurrent(j = 1:npl, j/=i) shared(i,r,Gmass, acc) local(rx,ry,rz,rji2,fac) +#else do concurrent(j = 1:npl, j/=i) +#endif rx = r(1,j) - r(1,i) ry = r(2,j) - r(2,i) rz = r(3,j) - r(3,i) @@ -322,7 +351,11 @@ module subroutine swiftest_kick_getacch_int_all_tri_norad_pl(npl, nplm, r, Gmass !$omp parallel do default(private) schedule(static)& !$omp shared(npl, nplm, r, Gmass, acc) do i = nplm+1,npl +#ifdef DOCONLOC + do concurrent(j = 1:nplm) shared(i,r,Gmass,acc) local(rx,ry,rz,rji2,fac) +#else do concurrent(j = 1:nplm) +#endif rx = r(1,j) - r(1,i) ry = r(2,j) - r(2,i) rz = r(3,j) - r(3,i) @@ -367,7 +400,11 @@ module subroutine swiftest_kick_getacch_int_all_tp(ntp, npl, rtp, rpl, GMpl, lma !$omp reduction(-:acc) do i = 1, ntp if (lmask(i)) then +#ifdef DOCONLOC + do concurrent (j = 1:npl) shared(rtp,rpl,GMpl,acc) local(rx,ry,rz,rji2) +#else do concurrent (j = 1:npl) +#endif rx = rtp(1, i) - rpl(1, j) ry = rtp(2, i) - rpl(2, j) rz = rtp(3, i) - rpl(3, j) @@ -428,7 +465,7 @@ pure module subroutine swiftest_kick_getacch_int_one_tp(rji2, xr, yr, zr, GMpl, ! Internals real(DP) :: fac - fac = GMpl * sqrt(1.0_DP / (rji2*rji2*rji2)) + fac = GMpl / (rji2*sqrt(rji2)) ax = ax - fac * xr ay = ay - fac * yr az = az - fac * zr diff --git a/src/swiftest/swiftest_module.f90 b/src/swiftest/swiftest_module.f90 index 4ac6cb3c3..b7bbd109c 100644 --- a/src/swiftest/swiftest_module.f90 +++ b/src/swiftest/swiftest_module.f90 @@ -43,6 +43,9 @@ module swiftest use io_progress_bar use netcdf_io use solver +#ifdef COARRAY + use coarray +#endif !use advisor_annotate !$ use omp_lib implicit none @@ -54,6 +57,9 @@ module swiftest procedure :: get_valid_masks => swiftest_io_netcdf_get_valid_masks !! Gets logical masks indicating which bodies are valid pl and tp type at the current time procedure :: open => swiftest_io_netcdf_open !! Opens a NetCDF file and does the variable inquiries to activate variable ids procedure :: flush => swiftest_io_netcdf_flush !! Flushes a NetCDF file by closing it then opening it again +#ifdef COARRAY + procedure :: coclone => swiftest_coarray_coclone_nc +#endif end type swiftest_netcdf_parameters @@ -87,14 +93,38 @@ module swiftest integer(I4B), dimension(:), allocatable :: child !! Index of children particles contains procedure :: dealloc => swiftest_util_dealloc_kin !! Deallocates all allocatable arrays +#ifdef COARRAY + procedure :: coclone => swiftest_coarray_coclone_kin !! Clones the image 1 body object to all other images in the coarray structure. +#endif final :: swiftest_final_kin !! Finalizes the Swiftest kinship object - deallocates all allocatables end type swiftest_kinship + type, extends(base_particle_info) :: swiftest_particle_info + character(len=NAMELEN) :: name !! Non-unique name + character(len=NAMELEN) :: particle_type !! String containing a description of the particle type (e.g. Central Body, Massive Body, Test Particle) + character(len=NAMELEN) :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) + real(DP) :: origin_time !! The time of the particle's formation + integer(I4B) :: collision_id !! The ID of the collision that formed the particle + real(DP), dimension(NDIM) :: origin_rh !! The heliocentric distance vector at the time of the particle's formation + real(DP), dimension(NDIM) :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation + real(DP) :: discard_time !! The time of the particle's discard + character(len=NAMELEN) :: status !! Particle status description: Active, Merged, Fragmented, etc. + real(DP), dimension(NDIM) :: discard_rh !! The heliocentric distance vector at the time of the particle's discard + real(DP), dimension(NDIM) :: discard_vh !! The heliocentric velocity vector at the time of the particle's discard + integer(I4B) :: discard_body_id !! The id of the other body involved in the discard (0 if no other body involved) + contains + procedure :: copy => swiftest_util_copy_particle_info !! Copies one set of information object components into another, component-by-component + procedure :: set_value => swiftest_util_set_particle_info !! Sets one or more values of the particle information metadata object + end type swiftest_particle_info + + !> An abstract class for a generic collection of Swiftest bodies - type, abstract, extends(base_multibody) :: swiftest_body + type, abstract, extends(base_object) :: swiftest_body !! Superclass that defines the generic elements of a Swiftest particle logical :: lfirst = .true. !! Run the current step as a first + integer(I4B) :: nbody = 0 !! Number of bodies + integer(I4B), dimension(:), allocatable :: id !! Identifier type(swiftest_particle_info), dimension(:), allocatable :: info !! Particle metadata information logical, dimension(:), allocatable :: lmask !! Logical mask used to select a subset of bodies when performing certain operations (drift, kick, accel, etc.) integer(I4B), dimension(:), allocatable :: status !! An integrator-specific status indicator @@ -138,7 +168,6 @@ module swiftest procedure :: read_in => swiftest_io_read_in_body !! Read in body initial conditions from an ascii file procedure :: write_frame => swiftest_io_netcdf_write_frame_body !! I/O routine for writing out a single frame of time-series data for all bodies in the nbody_system in NetCDF format procedure :: write_info => swiftest_io_netcdf_write_info_body !! Dump contents of particle information metadata to file - procedure :: accel_obl => swiftest_obl_acc_body !! Compute the barycentric accelerations of bodies due to the oblateness of the central body procedure :: el2xv => swiftest_orbel_el2xv_vec !! Convert orbital elements to position and velocity vectors procedure :: xv2el => swiftest_orbel_xv2el_vec !! Convert position and velocity vectors to orbital elements procedure :: setup => swiftest_util_setup_body !! A constructor that sets the number of bodies and allocates all allocatable arrays @@ -148,34 +177,18 @@ module swiftest procedure :: fill => swiftest_util_fill_body !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic) procedure :: get_peri => swiftest_util_peri_body !! Determine nbody_system pericenter passages for test particles procedure :: resize => swiftest_util_resize_body !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small. - procedure :: set_ir3 => swiftest_util_set_ir3h !! Sets the inverse heliocentric radius term (1/rh**3) procedure :: sort => swiftest_util_sort_body !! Sorts body arrays by a sortable componen procedure :: rearrange => swiftest_util_sort_rearrange_body !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods procedure :: spill => swiftest_util_spill_body !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) generic :: read_frame => read_frame_bin !! Add the generic read frame for Fortran binary files +#ifdef COARRAY + procedure :: coclone => swiftest_coarray_coclone_body !! Clones the image 1 body object to all other images in the coarray structure. + procedure :: cocollect => swiftest_coarray_cocollect_body !! Collects all body object array components from all images and combines them into the image 1 body object +#endif end type swiftest_body - type, extends(base_particle_info) :: swiftest_particle_info - character(len=NAMELEN) :: name !! Non-unique name - character(len=NAMELEN) :: particle_type !! String containing a description of the particle type (e.g. Central Body, Massive Body, Test Particle) - character(len=NAMELEN) :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) - real(DP) :: origin_time !! The time of the particle's formation - integer(I4B) :: collision_id !! The ID of the collision that formed the particle - real(DP), dimension(NDIM) :: origin_rh !! The heliocentric distance vector at the time of the particle's formation - real(DP), dimension(NDIM) :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation - real(DP) :: discard_time !! The time of the particle's discard - character(len=NAMELEN) :: status !! Particle status description: Active, Merged, Fragmented, etc. - real(DP), dimension(NDIM) :: discard_rh !! The heliocentric distance vector at the time of the particle's discard - real(DP), dimension(NDIM) :: discard_vh !! The heliocentric velocity vector at the time of the particle's discard - integer(I4B) :: discard_body_id !! The id of the other body involved in the discard (0 if no other body involved) - contains - procedure :: copy => swiftest_util_copy_particle_info !! Copies one set of information object components into another, component-by-component - procedure :: set_value => swiftest_util_set_particle_info !! Sets one or more values of the particle information metadata object - end type swiftest_particle_info - - type, abstract, extends(base_object) :: swiftest_cb !> An abstract class for a generic central body in a Swiftest simulation class(swiftest_particle_info), allocatable :: info !! Particle metadata information @@ -211,6 +224,10 @@ module swiftest procedure :: read_in => swiftest_io_read_in_cb !! Read in central body initial conditions from an ASCII file procedure :: write_frame => swiftest_io_netcdf_write_frame_cb !! I/O routine for writing out a single frame of time-series data for all bodies in the system in NetCDF format procedure :: write_info => swiftest_io_netcdf_write_info_cb !! Dump contents of particle information metadata to file + +#ifdef COARRAY + procedure :: coclone => swiftest_coarray_coclone_cb !! Clones the image 1 body object to all other images in the coarray structure. +#endif end type swiftest_cb @@ -234,7 +251,7 @@ module swiftest integer(I8B) :: nplpl !! Number of body-body comparisons in the flattened upper triangular matrix type(swiftest_kinship), dimension(:), allocatable :: kin !! Array of merger relationship structures that can account for multiple pairwise mergers in a single step logical, dimension(:), allocatable :: lmtiny !! flag indicating whether this body is below the GMTINY cutoff value - integer(I4B) :: nplm !! number of bodies above the GMTINY limit + integer(I4B) :: nplm = 0 !! number of bodies above the GMTINY limit integer(I8B) :: nplplm !! Number of body (all massive)-body (only those above GMTINY) comparisons in the flattened upper triangular matrix integer(I4B), dimension(:), allocatable :: nplenc !! number of encounters with other planets this time step integer(I4B), dimension(:), allocatable :: ntpenc !! number of encounters with test particles this time step @@ -270,6 +287,9 @@ module swiftest procedure :: rearrange => swiftest_util_sort_rearrange_pl !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods procedure :: spill => swiftest_util_spill_pl !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) generic :: set_renc => set_renc_I4B, set_renc_DP +#ifdef COARRAY + procedure :: coclone => swiftest_coarray_coclone_pl !! Clones the image 1 body object to all other images in the coarray structure. +#endif end type swiftest_pl @@ -300,6 +320,10 @@ module swiftest procedure :: sort => swiftest_util_sort_tp !! Sorts body arrays by a sortable component procedure :: rearrange => swiftest_util_sort_rearrange_tp !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods procedure :: spill => swiftest_util_spill_tp !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) +#ifdef COARRAY + procedure :: coclone => swiftest_coarray_coclone_tp !! Clones the image 1 object to all other images in the coarray structure. + procedure :: cocollect => swiftest_coarray_cocollect_tp !! Collects all object array components from all images and combines them into the image 1 object +#endif end type swiftest_tp @@ -323,7 +347,6 @@ module swiftest class(collision_basic), allocatable :: collider !! Collision system object class(encounter_storage), allocatable :: encounter_history !! Stores encounter history for later retrieval and saving to file class(collision_storage), allocatable :: collision_history !! Stores encounter history for later retrieval and saving to file - class(swiftest_storage), allocatable :: system_history !! Stores the system history between output dumps integer(I4B) :: maxid = -1 !! The current maximum particle id number real(DP) :: t = -1.0_DP !! Integration current time @@ -384,23 +407,28 @@ module swiftest procedure :: dump => swiftest_io_dump_system !! Dump the state of the nbody_system to a file procedure :: get_t0_values => swiftest_io_netcdf_get_t0_values_system !! Validates the dump file to check whether the dump file initial conditions duplicate the last frame of the netcdf output. procedure :: read_frame => swiftest_io_netcdf_read_frame_system !! Read in a frame of input data from file - procedure :: write_frame_netcdf => swiftest_io_netcdf_write_frame_system !! Write a frame of input data from file procedure :: read_hdr => swiftest_io_netcdf_read_hdr_system !! Read a header for an output frame in NetCDF format procedure :: write_hdr => swiftest_io_netcdf_write_hdr_system !! Write a header for an output frame in NetCDF format procedure :: read_particle_info => swiftest_io_netcdf_read_particle_info_system !! Read in particle metadata from file procedure :: read_in => swiftest_io_read_in_system !! Reads the initial conditions for an nbody system - procedure :: write_frame_system => swiftest_io_write_frame_system !! Write a frame of input data from file + procedure :: write_frame => swiftest_io_netcdf_write_frame_system !! Write a frame of input data from file procedure :: obl_pot => swiftest_obl_pot_system !! Compute the contribution to the total gravitational potential due solely to the oblateness of the central body - procedure :: dealloc => swiftest_util_dealloc_system !! Deallocates all allocatables and resets all values to defaults. Acts as a base for a finalizer + procedure :: dealloc => swiftest_util_dealloc_system !! Deallocates all allocatables and resets all values to defaults. Acts as a base for a finalizer procedure :: get_energy_and_momentum => swiftest_util_get_energy_and_momentum_system !! Calculates the total nbody_system energy and momentum procedure :: get_idvals => swiftest_util_get_idvalues_system !! Returns an array of all id values in use in the nbody_system procedure :: rescale => swiftest_util_rescale_system !! Rescales the nbody_system into a new set of units + procedure :: initialize_output_file => swiftest_io_initialize_output_file_system !! Write a frame of input data from file procedure :: initialize => swiftest_util_setup_initialize_system !! Initialize the nbody_system from input files procedure :: init_particle_info => swiftest_util_setup_initialize_particle_info_system !! Initialize the nbody_system from input files ! procedure :: step_spin => tides_step_spin_system !! Steps the spins of the massive & central bodies due to tides. procedure :: set_msys => swiftest_util_set_msys !! Sets the value of msys from the masses of nbody_system bodies. procedure :: validate_ids => swiftest_util_valid_id_system !! Validate the numerical ids passed to the nbody_system and save the maximum value - generic :: write_frame => write_frame_system, write_frame_netcdf !! Generic method call for reading a frame of output data +#ifdef COARRAY + procedure :: coclone => swiftest_coarray_coclone_system !! Clones the image 1 body object to all other images in the coarray structure. + procedure :: coarray_collect => swiftest_coarray_collect_system !! Collects all the test particles from other images into the image #1 test particle system + procedure :: coarray_distribute => swiftest_coarray_distribute_system !! Distributes test particles from image #1 out to all images. + procedure :: coarray_balance => swiftest_coarray_balance_system !! Checks whether or not the test particle coarrays need to be rebalanced. +#endif end type swiftest_nbody_system @@ -442,11 +470,11 @@ end subroutine abstract_set_mu subroutine abstract_step_body(self, nbody_system, param, t, dt) import DP, swiftest_body, swiftest_nbody_system, swiftest_parameters implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest body object + class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - real(DP), intent(in) :: t !! Simulation time - real(DP), intent(in) :: dt !! Current stepsize + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + real(DP), intent(in) :: t !! Simulation time + real(DP), intent(in) :: dt !! Current stepsize end subroutine abstract_step_body subroutine abstract_step_system(self, param, t, dt) @@ -459,7 +487,6 @@ subroutine abstract_step_system(self, param, t, dt) end subroutine abstract_step_system end interface - interface module subroutine swiftest_discard_pl(self, nbody_system, param) implicit none @@ -500,11 +527,11 @@ module subroutine swiftest_drift_body(self, nbody_system, param, dt) real(DP), intent(in) :: dt !! Stepsize end subroutine swiftest_drift_body - pure elemental module subroutine swiftest_drift_one(mu, px, py, pz, vx, vy, vz, dt, iflag) + pure elemental module subroutine swiftest_drift_one(mu, rx, ry, rz, vx, vy, vz, dt, iflag) !$omp declare simd(swiftest_drift_one) implicit none real(DP), intent(in) :: mu !! G * (Mcb + m), G = gravitational constant, Mcb = mass of central body, m = mass of body to drift - real(DP), intent(inout) :: px, py, pz, vx, vy, vz !! Position and velocity of body to drift + real(DP), intent(inout) :: rx, ry, rz, vx, vy, vz !! Position and velocity of body to drift real(DP), intent(in) :: dt !! Step size integer(I4B), intent(out) :: iflag !! iflag : error status flag for Danby drift (0 = OK, nonzero = ERROR) end subroutine swiftest_drift_one @@ -526,12 +553,12 @@ pure module subroutine swiftest_gr_kick_getacch(mu, x, lmask, n, inv_c2, agr) real(DP), dimension(:,:), intent(out) :: agr !! Accelerations end subroutine swiftest_gr_kick_getacch - pure module subroutine swiftest_gr_p4_pos_kick(param, x, v, dt) + pure elemental module subroutine swiftest_gr_p4_pos_kick(inv_c2, rx, ry, rz, vx, vy, vz, dt) implicit none - class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters - real(DP), dimension(:), intent(inout) :: x !! Position vector - real(DP), dimension(:), intent(in) :: v !! Velocity vector - real(DP), intent(in) :: dt !! Step size + real(DP), intent(in) :: inv_c2 !! One over speed of light squared (1/c**2) + real(DP), intent(inout) :: rx, ry, rz !! Position vector + real(DP), intent(in) :: vx, vy, vz !! Velocity vector + real(DP), intent(in) :: dt !! Step size end subroutine swiftest_gr_p4_pos_kick pure module subroutine swiftest_gr_pseudovel2vel(param, mu, rh, pv, vh) @@ -592,10 +619,11 @@ module subroutine swiftest_io_dump_param(self, param_file_name) character(len=*), intent(in) :: param_file_name !! Parameter input file name (i.e. param.in) end subroutine swiftest_io_dump_param - module subroutine swiftest_io_dump_system(self, param) + module subroutine swiftest_io_dump_system(self, param, system_history) implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_storage), intent(inout) :: system_history !! Stores the system history between output dumps end subroutine swiftest_io_dump_system module subroutine swiftest_io_dump_storage(self, param) @@ -639,17 +667,20 @@ module subroutine swiftest_io_netcdf_flush(self, param) class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine swiftest_io_netcdf_flush - module subroutine swiftest_io_netcdf_get_t0_values_system(self, param) + module subroutine swiftest_io_netcdf_get_t0_values_system(self, nc, param) implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object + class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine swiftest_io_netcdf_get_t0_values_system - module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask) + module subroutine swiftest_io_netcdf_get_valid_masks(self, plmask, tpmask, plmmask, Gmtiny) implicit none - class(swiftest_netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset - logical, dimension(:), allocatable, intent(out) :: plmask !! Logical mask indicating which bodies are massive bodies - logical, dimension(:), allocatable, intent(out) :: tpmask !! Logical mask indicating which bodies are test particles + class(swiftest_netcdf_parameters), intent(inout) :: self !! Parameters used to identify a particular NetCDF dataset + logical, dimension(:), allocatable, intent(out) :: plmask !! Logical mask indicating which bodies are massive bodies + logical, dimension(:), allocatable, intent(out) :: tpmask !! Logical mask indicating which bodies are test particles + logical, dimension(:), allocatable, intent(out), optional :: plmmask !! Logical mask indicating which bodies are fully interacting massive bodies + real(DP), intent(in), optional :: Gmtiny !! The cutoff G*mass between semi-interacting and fully interacting massive bodies end subroutine swiftest_io_netcdf_get_valid_masks module subroutine swiftest_io_netcdf_initialize_output(self, param) @@ -837,9 +868,10 @@ module subroutine swiftest_io_read_in_param(self, param_file_name) character(len=*), intent(in) :: param_file_name !! Parameter input file name (i.e. param.in) end subroutine swiftest_io_read_in_param - module subroutine swiftest_io_read_in_system(self, param) + module subroutine swiftest_io_read_in_system(self, nc, param) implicit none - class(swiftest_nbody_system), intent(inout) :: self + class(swiftest_nbody_system), intent(inout) :: self + class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset class(swiftest_parameters), intent(inout) :: param end subroutine swiftest_io_read_in_system @@ -870,11 +902,12 @@ module subroutine swiftest_io_toupper(string) character(*), intent(inout) :: string !! String to make upper case end subroutine swiftest_io_toupper - module subroutine swiftest_io_write_frame_system(self, param) + module subroutine swiftest_io_initialize_output_file_system(self, nc, param) implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object + class(swiftest_netcdf_parameters), intent(inout) :: nc !! Parameters used to identify a particular NetCDF dataset class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - end subroutine swiftest_io_write_frame_system + end subroutine swiftest_io_initialize_output_file_system module subroutine swiftest_kick_getacch_int_pl(self, param) implicit none @@ -966,11 +999,18 @@ pure module subroutine swiftest_kick_getacch_int_one_tp(rji2, xr, yr, zr, Gmpl, real(DP), intent(inout) :: ax, ay, az !! Acceleration vector components of test particle end subroutine swiftest_kick_getacch_int_one_tp - module subroutine swiftest_obl_acc_body(self, nbody_system) + module subroutine swiftest_obl_acc(n, GMcb, j2rp2, j4rp4, rh, lmask, aobl, GMpl, aoblcb) implicit none - class(swiftest_body), intent(inout) :: self !! Swiftest body object - class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object - end subroutine swiftest_obl_acc_body + integer(I4B), intent(in) :: n !! Number of bodies + real(DP), intent(in) :: GMcb !! Central body G*Mass + real(DP), intent(in) :: j2rp2 !! J2 * R**2 for the central body + real(DP), intent(in) :: j4rp4 !! J4 * R**4 for the central body + real(DP), dimension(:,:), intent(in) :: rh !! Heliocentric positions of bodies + logical, dimension(:), intent(in) :: lmask !! Logical mask of bodies to compute aobl + real(DP), dimension(:,:), intent(out) :: aobl !! Barycentric acceleration of bodies due to central body oblateness + real(DP), dimension(:), intent(in), optional :: GMpl !! Masses of input bodies if they are not test particles + real(DP), dimension(:), intent(out), optional :: aoblcb !! Barycentric acceleration of central body (only needed if input bodies are massive) + end subroutine swiftest_obl_acc module subroutine swiftest_obl_acc_pl(self, nbody_system) implicit none @@ -1002,22 +1042,22 @@ pure module subroutine swiftest_orbel_scget(angle, sx, cx) real(DP), intent(out) :: sx, cx end subroutine swiftest_orbel_scget - pure elemental module subroutine swiftest_orbel_xv2aeq(mu, px, py, pz, vx, vy, vz, a, e, q) + pure elemental module subroutine swiftest_orbel_xv2aeq(mu, rx, ry, rz, vx, vy, vz, a, e, q) !$omp declare simd(swiftest_orbel_xv2aeq) implicit none real(DP), intent(in) :: mu !! Gravitational constant - real(DP), intent(in) :: px,py,pz !! Position vector + real(DP), intent(in) :: rx,ry,rz !! Position vector real(DP), intent(in) :: vx,vy,vz !! Velocity vector real(DP), intent(out) :: a !! semimajor axis real(DP), intent(out) :: e !! eccentricity real(DP), intent(out) :: q !! periapsis end subroutine swiftest_orbel_xv2aeq - pure module subroutine swiftest_orbel_xv2aqt(mu, px, py, pz, vx, vy, vz, a, q, capm, tperi) + pure module subroutine swiftest_orbel_xv2aqt(mu, rx, ry, rz, vx, vy, vz, a, q, capm, tperi) !$omp declare simd(swiftest_orbel_xv2aqt) implicit none real(DP), intent(in) :: mu !! Gravitational constant - real(DP), intent(in) :: px,py,pz !! Position vector + real(DP), intent(in) :: rx,ry,rz !! Position vector real(DP), intent(in) :: vx,vy,vz !! Velocity vector real(DP), intent(out) :: a !! semimajor axis real(DP), intent(out) :: q !! periapsis @@ -1025,10 +1065,10 @@ pure module subroutine swiftest_orbel_xv2aqt(mu, px, py, pz, vx, vy, vz, a, q, c real(DP), intent(out) :: tperi !! time of pericenter passage end subroutine swiftest_orbel_xv2aqt - pure module subroutine swiftest_orbel_xv2el(mu, px, py, pz, vx, vy, vz, a, e, inc, capom, omega, capm, varpi, lam, f, cape, capf) + pure module subroutine swiftest_orbel_xv2el(mu, rx, ry, rz, vx, vy, vz, a, e, inc, capom, omega, capm, varpi, lam, f, cape, capf) implicit none real(DP), intent(in) :: mu !! Gravitational constant - real(DP), intent(in) :: px,py,pz !! Position vector + real(DP), intent(in) :: rx,ry,rz !! Position vector real(DP), intent(in) :: vx,vy,vz !! Velocity vector real(DP), intent(out) :: a !! semimajor axis real(DP), intent(out) :: e !! eccentricity @@ -1059,7 +1099,7 @@ end subroutine swiftest_util_setup_body module subroutine swiftest_util_setup_construct_system(nbody_system, param) implicit none class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system !! Swiftest nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine swiftest_util_setup_construct_system module subroutine swiftest_util_setup_initialize_particle_info_system(self, param) @@ -1068,10 +1108,11 @@ module subroutine swiftest_util_setup_initialize_particle_info_system(self, para class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine swiftest_util_setup_initialize_particle_info_system - module subroutine swiftest_util_setup_initialize_system(self, param) + module subroutine swiftest_util_setup_initialize_system(self, system_history, param) implicit none - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine swiftest_util_setup_initialize_system module subroutine swiftest_util_setup_pl(self, n, param) @@ -1098,62 +1139,22 @@ module subroutine swiftest_user_kick_getacch_body(self, nbody_system, param, t, end subroutine swiftest_user_kick_getacch_body end interface - interface swiftest_util_append - module subroutine swiftest_util_append_arr_char_string(arr, source, nold, nsrc, lsource_mask) - implicit none - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Destination array - character(len=STRMAX), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - end subroutine swiftest_util_append_arr_char_string - - module subroutine swiftest_util_append_arr_DP(arr, source, nold, nsrc, lsource_mask) - implicit none - real(DP), dimension(:), allocatable, intent(inout) :: arr !! Destination array - real(DP), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - end subroutine swiftest_util_append_arr_DP - - module subroutine swiftest_util_append_arr_DPvec(arr, source, nold, nsrc, lsource_mask) + interface util_append + module subroutine swiftest_util_append_arr_info(arr, source, nold, lsource_mask) implicit none - real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Destination array - real(DP), dimension(:,:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - end subroutine swiftest_util_append_arr_DPvec - - module subroutine swiftest_util_append_arr_I4B(arr, source, nold, nsrc, lsource_mask) - implicit none - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - end subroutine swiftest_util_append_arr_I4B - - module subroutine swiftest_util_append_arr_info(arr, source, nold, nsrc, lsource_mask) - implicit none - type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array - type(swiftest_particle_info), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to + type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array + type(swiftest_particle_info), dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to end subroutine swiftest_util_append_arr_info - module subroutine swiftest_util_append_arr_kin(arr, source, nold, nsrc, lsource_mask) + module subroutine swiftest_util_append_arr_kin(arr, source, nold, lsource_mask) implicit none - type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Destination array - type(swiftest_kinship), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to + type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Destination array + type(swiftest_kinship), dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to end subroutine swiftest_util_append_arr_kin - - module subroutine swiftest_util_append_arr_logical(arr, source, nold, nsrc, lsource_mask) - implicit none - logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array - logical, dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - end subroutine swiftest_util_append_arr_logical end interface interface @@ -1308,40 +1309,12 @@ module subroutine swiftest_util_fill_tp(self, inserts, lfill_list) end subroutine swiftest_util_fill_tp end interface - interface swiftest_util_fill - module subroutine swiftest_util_fill_arr_char_string(keeps, inserts, lfill_list) - implicit none - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - character(len=STRMAX), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - end subroutine swiftest_util_fill_arr_char_string - - module subroutine swiftest_util_fill_arr_DP(keeps, inserts, lfill_list) - implicit none - real(DP), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - end subroutine swiftest_util_fill_arr_DP - - module subroutine swiftest_util_fill_arr_DPvec(keeps, inserts, lfill_list) - implicit none - real(DP), dimension(:,:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:,:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - end subroutine swiftest_util_fill_arr_DPvec - - module subroutine swiftest_util_fill_arr_I4B(keeps, inserts, lfill_list) - implicit none - integer(I4B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - integer(I4B), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - end subroutine swiftest_util_fill_arr_I4B - + interface util_fill module subroutine swiftest_util_fill_arr_info(keeps, inserts, lfill_list) implicit none type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep type(swiftest_particle_info), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps + logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps end subroutine swiftest_util_fill_arr_info module subroutine swiftest_util_fill_arr_kin(keeps, inserts, lfill_list) @@ -1350,13 +1323,6 @@ module subroutine swiftest_util_fill_arr_kin(keeps, inserts, lfill_list) type(swiftest_kinship), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps end subroutine swiftest_util_fill_arr_kin - - module subroutine swiftest_util_fill_arr_logical(keeps, inserts, lfill_list) - implicit none - logical, dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - logical, dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - end subroutine swiftest_util_fill_arr_logical end interface interface @@ -1501,31 +1467,7 @@ end subroutine swiftest_util_reset_kinship_pl end interface - interface swiftest_util_resize - module subroutine swiftest_util_resize_arr_char_string(arr, nnew) - implicit none - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - end subroutine swiftest_util_resize_arr_char_string - - module subroutine swiftest_util_resize_arr_DP(arr, nnew) - implicit none - real(DP), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - end subroutine swiftest_util_resize_arr_DP - - module subroutine swiftest_util_resize_arr_DPvec(arr, nnew) - implicit none - real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - end subroutine swiftest_util_resize_arr_DPvec - - module subroutine swiftest_util_resize_arr_I4B(arr, nnew) - implicit none - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - end subroutine swiftest_util_resize_arr_I4B - + interface util_resize module subroutine swiftest_util_resize_arr_info(arr, nnew) implicit none type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Array to resize @@ -1537,12 +1479,6 @@ module subroutine swiftest_util_resize_arr_kin(arr, nnew) type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Array to resize integer(I4B), intent(in) :: nnew !! New size end subroutine swiftest_util_resize_arr_kin - - module subroutine swiftest_util_resize_arr_logical(arr, nnew) - implicit none - logical, dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - end subroutine swiftest_util_resize_arr_logical end interface interface @@ -1653,98 +1589,16 @@ end subroutine swiftest_util_snapshot_save module subroutine swiftest_util_snapshot_system(self, param, nbody_system, t, arg) implicit none - class(swiftest_storage), intent(inout) :: self !! Swiftest storage object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object to store - real(DP), intent(in), optional :: t !! Time of snapshot if different from nbody_system time - character(*), intent(in), optional :: arg !! Optional argument (needed for extended storage type used in encounter snapshots) + class(swiftest_storage), intent(inout) :: self !! Swiftest storage object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object to store + real(DP), intent(in), optional :: t !! Time of snapshot if different from nbody_system time + character(*), intent(in), optional :: arg !! Optional argument (needed for extended storage type used in collision snapshots) end subroutine swiftest_util_snapshot_system end interface - interface swiftest_util_sort - pure module subroutine swiftest_util_sort_i4b(arr) - implicit none - integer(I4B), dimension(:), intent(inout) :: arr - end subroutine swiftest_util_sort_i4b - - pure module subroutine swiftest_util_sort_index_i4b(arr,ind) - implicit none - integer(I4B), dimension(:), intent(in) :: arr - integer(I4B), dimension(:), allocatable, intent(inout) :: ind - end subroutine swiftest_util_sort_index_i4b - - pure module subroutine swiftest_util_sort_index_I4B_I8Bind(arr,ind) - implicit none - integer(I4B), dimension(:), intent(in) :: arr - integer(I8B), dimension(:), allocatable, intent(inout) :: ind - end subroutine swiftest_util_sort_index_I4b_I8Bind - - pure module subroutine swiftest_util_sort_index_I8B_I8Bind(arr,ind) - implicit none - integer(I8B), dimension(:), intent(in) :: arr - integer(I8B), dimension(:), allocatable, intent(inout) :: ind - end subroutine swiftest_util_sort_index_I8B_I8Bind - - pure module subroutine swiftest_util_sort_sp(arr) - implicit none - real(SP), dimension(:), intent(inout) :: arr - end subroutine swiftest_util_sort_sp - - pure module subroutine swiftest_util_sort_index_sp(arr,ind) - implicit none - real(SP), dimension(:), intent(in) :: arr - integer(I4B), dimension(:), allocatable, intent(inout) :: ind - end subroutine swiftest_util_sort_index_sp - - pure module subroutine swiftest_util_sort_dp(arr) - implicit none - real(DP), dimension(:), intent(inout) :: arr - end subroutine swiftest_util_sort_dp - - pure module subroutine swiftest_util_sort_index_dp(arr,ind) - implicit none - real(DP), dimension(:), intent(in) :: arr - integer(I4B), dimension(:), allocatable, intent(inout) :: ind - end subroutine swiftest_util_sort_index_dp - end interface swiftest_util_sort - - interface swiftest_util_sort_rearrange - pure module subroutine swiftest_util_sort_rearrange_arr_char_string(arr, ind, n) - implicit none - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - end subroutine swiftest_util_sort_rearrange_arr_char_string - - pure module subroutine swiftest_util_sort_rearrange_arr_DP(arr, ind, n) - implicit none - real(DP), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - end subroutine swiftest_util_sort_rearrange_arr_DP - - pure module subroutine swiftest_util_sort_rearrange_arr_DPvec(arr, ind, n) - implicit none - real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - end subroutine swiftest_util_sort_rearrange_arr_DPvec - - pure module subroutine swiftest_util_sort_rearrange_arr_I4B(arr, ind, n) - implicit none - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - end subroutine swiftest_util_sort_rearrange_arr_I4B - - pure module subroutine swiftest_util_sort_rearrange_arr_I4B_I8Bind(arr, ind, n) - implicit none - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I8B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I8B), intent(in) :: n !! Number of elements in arr and ind to rearrange - end subroutine swiftest_util_sort_rearrange_arr_I4B_I8Bind - + interface util_sort_rearrange module subroutine swiftest_util_sort_rearrange_arr_info(arr, ind, n) implicit none type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array @@ -1759,20 +1613,7 @@ pure module subroutine swiftest_util_sort_rearrange_arr_kin(arr, ind, n) integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange end subroutine swiftest_util_sort_rearrange_arr_kin - pure module subroutine swiftest_util_sort_rearrange_arr_logical(arr, ind, n) - implicit none - logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - end subroutine swiftest_util_sort_rearrange_arr_logical - - pure module subroutine swiftest_util_sort_rearrange_arr_logical_I8Bind(arr, ind, n) - implicit none - logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I8B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I8B), intent(in) :: n !! Number of elements in arr and ind to rearrange - end subroutine swiftest_util_sort_rearrange_arr_logical_I8Bind - end interface swiftest_util_sort_rearrange + end interface util_sort_rearrange interface module subroutine swiftest_util_sort_rearrange_body(self, ind) @@ -1816,47 +1657,7 @@ end subroutine swiftest_util_sort_tp end interface - interface swiftest_util_spill - module subroutine swiftest_util_spill_arr_char_string(keeps, discards, lspill_list, ldestructive) - implicit none - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - end subroutine swiftest_util_spill_arr_char_string - - module subroutine swiftest_util_spill_arr_DP(keeps, discards, lspill_list, ldestructive) - implicit none - real(DP), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - end subroutine swiftest_util_spill_arr_DP - - module subroutine swiftest_util_spill_arr_DPvec(keeps, discards, lspill_list, ldestructive) - implicit none - real(DP), dimension(:,:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:,:), allocatable, intent(inout) :: discards !! Array discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - end subroutine swiftest_util_spill_arr_DPvec - - module subroutine swiftest_util_spill_arr_I4B(keeps, discards, lspill_list, ldestructive) - implicit none - integer(I4B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - integer(I4B), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - end subroutine swiftest_util_spill_arr_I4B - - module subroutine swiftest_util_spill_arr_I8B(keeps, discards, lspill_list, ldestructive) - implicit none - integer(I8B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - integer(I8B), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - end subroutine swiftest_util_spill_arr_I8B - + interface util_spill module subroutine swiftest_util_spill_arr_info(keeps, discards, lspill_list, ldestructive) implicit none type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep @@ -1872,14 +1673,6 @@ module subroutine swiftest_util_spill_arr_kin(keeps, discards, lspill_list, ldes logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not end subroutine swiftest_util_spill_arr_kin - - module subroutine swiftest_util_spill_arr_logical(keeps, discards, lspill_list, ldestructive) - implicit none - logical, dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - logical, dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - end subroutine swiftest_util_spill_arr_logical end interface interface @@ -1909,22 +1702,6 @@ end subroutine swiftest_util_spill_tp end interface - interface swiftest_util_unique - module subroutine swiftest_util_unique_DP(input_array, output_array, index_map) - implicit none - real(DP), dimension(:), intent(in) :: input_array !! Unsorted input array - real(DP), dimension(:), allocatable, intent(out) :: output_array !! Sorted array of unique values - integer(I4B), dimension(:), allocatable, intent(out) :: index_map !! An array of the same size as input_array that such that any for any index i, output_array(index_map(i)) = input_array(i) - end subroutine swiftest_util_unique_DP - - module subroutine swiftest_util_unique_I4B(input_array, output_array, index_map) - implicit none - integer(I4B), dimension(:), intent(in) :: input_array !! Unsorted input array - integer(I4B), dimension(:), allocatable, intent(out) :: output_array !! Sorted array of unique values - integer(I4B), dimension(:), allocatable, intent(out) :: index_map !! An array of the same size as input_array that such that any for any index i, output_array(index_map(i)) = input_array(i) - end subroutine swiftest_util_unique_I4B - end interface swiftest_util_unique - interface module subroutine swiftest_util_valid_id_system(self, param) implicit none @@ -1937,6 +1714,111 @@ module subroutine swiftest_util_version() end subroutine swiftest_util_version end interface +#ifdef COARRAY + interface + module subroutine swiftest_coarray_balance_system(nbody_system, param) + !! author: David A. Minton + !! + !! Checks whether or not the system needs to be rebalance. Rebalancing occurs when the image with the smallest number of test particles + !! has <90% of that of the image with the largest number of test particles. + implicit none + ! Arguments + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + end subroutine swiftest_coarray_balance_system + + module subroutine swiftest_coarray_collect_system(nbody_system, param) + implicit none + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + end subroutine swiftest_coarray_collect_system + + module subroutine swiftest_coarray_distribute_system(nbody_system, param) + implicit none + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + end subroutine swiftest_coarray_distribute_system + end interface + + interface coclone + module subroutine swiftest_coarray_component_clone_info(var,src_img) + implicit none + type(swiftest_particle_info), intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine swiftest_coarray_component_clone_info + + module subroutine swiftest_coarray_component_clone_info_arr1D(var,src_img) + implicit none + type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine swiftest_coarray_component_clone_info_arr1D + + module subroutine swiftest_coarray_component_clone_kin_arr1D(var,src_img) + implicit none + type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: src_img + end subroutine swiftest_coarray_component_clone_kin_arr1D + end interface + + interface cocollect + module subroutine swiftest_coarray_component_collect_info_arr1D(var,dest_img) + implicit none + type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: var + integer(I4B), intent(in),optional :: dest_img + end subroutine + end interface + + interface + module subroutine swiftest_coarray_coclone_body(self) + implicit none + class(swiftest_body),intent(inout),codimension[*] :: self !! Swiftest body object + end subroutine swiftest_coarray_coclone_body + + module subroutine swiftest_coarray_coclone_cb(self) + implicit none + class(swiftest_cb),intent(inout),codimension[*] :: self !! Swiftest cb object + end subroutine swiftest_coarray_coclone_cb + + module subroutine swiftest_coarray_coclone_kin(self) + implicit none + class(swiftest_kinship),intent(inout),codimension[*] :: self !! Swiftest kinship object + end subroutine swiftest_coarray_coclone_kin + + module subroutine swiftest_coarray_coclone_nc(self) + implicit none + class(swiftest_netcdf_parameters),intent(inout),codimension[*] :: self !! Swiftest body object + end subroutine swiftest_coarray_coclone_nc + + module subroutine swiftest_coarray_coclone_pl(self) + implicit none + class(swiftest_pl),intent(inout),codimension[*] :: self !! Swiftest pl object + end subroutine swiftest_coarray_coclone_pl + + module subroutine swiftest_coarray_coclone_tp(self) + implicit none + class(swiftest_tp),intent(inout),codimension[*] :: self !! Swiftest tp object + end subroutine swiftest_coarray_coclone_tp + + module subroutine swiftest_coarray_coclone_system(self) + implicit none + class(swiftest_nbody_system),intent(inout),codimension[*] :: self !! Swiftest nbody system object + end subroutine swiftest_coarray_coclone_system + + module subroutine swiftest_coarray_cocollect_body(self) + !! Collects all body object array components from all images and combines them into the image 1 body object + implicit none + class(swiftest_body),intent(inout), codimension[*] :: self !! Swiftest body object + end subroutine swiftest_coarray_cocollect_body + + module subroutine swiftest_coarray_cocollect_tp(self) + !! Collects all body object array components from all images and combines them into the image 1 body object + implicit none + class(swiftest_tp),intent(inout), codimension[*] :: self !! Swiftest tp object + end subroutine swiftest_coarray_cocollect_tp + end interface + +#endif + contains subroutine swiftest_final_kin(self) !! author: David A. Minton diff --git a/src/swiftest/swiftest_obl.f90 b/src/swiftest/swiftest_obl.f90 index 2b87b7264..21f4363ae 100644 --- a/src/swiftest/swiftest_obl.f90 +++ b/src/swiftest/swiftest_obl.f90 @@ -9,7 +9,7 @@ submodule (swiftest) s_swiftest_obl contains - module subroutine swiftest_obl_acc_body(self, nbody_system) + module subroutine swiftest_obl_acc(n, GMcb, j2rp2, j4rp4, rh, lmask, aobl, GMpl, aoblcb) !! author: David A. Minton !! !! Compute the barycentric accelerations of bodies due to the oblateness of the central body @@ -19,33 +19,50 @@ module subroutine swiftest_obl_acc_body(self, nbody_system) !! Adapted from Hal Levison's Swift routine obl_acc.f and obl_acc_tp.f implicit none ! Arguments - class(swiftest_body), intent(inout) :: self !! Swiftest body object - class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object + integer(I4B), intent(in) :: n !! Number of bodies + real(DP), intent(in) :: GMcb !! Central body G*Mass + real(DP), intent(in) :: j2rp2 !! J2 * R**2 for the central body + real(DP), intent(in) :: j4rp4 !! J4 * R**4 for the central body + real(DP), dimension(:,:), intent(in) :: rh !! Heliocentric positions of bodies + logical, dimension(:), intent(in) :: lmask !! Logical mask of bodies to compute aobl + real(DP), dimension(:,:), intent(out) :: aobl !! Barycentric acceleration of bodies due to central body oblateness + real(DP), dimension(:), intent(in), optional :: GMpl !! Masses of input bodies if they are not test particles + real(DP), dimension(:), intent(out), optional :: aoblcb !! Barycentric acceleration of central body (only needed if input bodies are massive) ! Internals integer(I4B) :: i real(DP) :: r2, irh, rinv2, t0, t1, t2, t3, fac1, fac2 - if (self%nbody == 0) return - - associate(n => self%nbody, cb => nbody_system%cb) - self%aobl(:,:) = 0.0_DP - do concurrent(i = 1:n, self%lmask(i)) - r2 = dot_product(self%rh(:, i), self%rh(:, i)) - irh = 1.0_DP / sqrt(r2) - rinv2 = irh**2 - t0 = -cb%Gmass * rinv2 * rinv2 * irh - t1 = 1.5_DP * cb%j2rp2 - t2 = self%rh(3, i) * self%rh(3, i) * rinv2 - t3 = 1.875_DP * cb%j4rp4 * rinv2 - fac1 = t0 * (t1 - t3 - (5 * t1 - (14.0_DP - 21.0_DP * t2) * t3) * t2) - fac2 = 2 * t0 * (t1 - (2.0_DP - (14.0_DP * t2 / 3.0_DP)) * t3) - self%aobl(:, i) = fac1 * self%rh(:, i) - self%aobl(3, i) = fac2 * self%rh(3, i) + self%aobl(3, i) + if (n == 0) return + + aobl(:,:) = 0.0_DP +#ifdef DOCONLOC + do concurrent(i = 1:n, lmask(i)) shared(lmask,rh,aobl) local(r2,irh,rinv2,t0,t1,t2,t3,fac1,fac2) +#else + do concurrent(i = 1:n, lmask(i)) +#endif + r2 = dot_product(rh(:, i), rh(:, i)) + irh = 1.0_DP / sqrt(r2) + rinv2 = irh**2 + t0 = -GMcb * rinv2 * rinv2 * irh + t1 = 1.5_DP * j2rp2 + t2 = rh(3, i) * rh(3, i) * rinv2 + t3 = 1.875_DP * j4rp4 * rinv2 + fac1 = t0 * (t1 - t3 - (5 * t1 - (14.0_DP - 21.0_DP * t2) * t3) * t2) + fac2 = 2 * t0 * (t1 - (2.0_DP - (14.0_DP * t2 / 3.0_DP)) * t3) + aobl(:, i) = fac1 * rh(:, i) + aobl(3, i) = fac2 * rh(3, i) + aobl(3, i) + end do + + if (present(GMpl) .and. present(aoblcb)) then + aoblcb(:) = 0.0_DP + do i = n, 1, -1 + if (lmask(i)) aoblcb(:) = aoblcb(:) - GMpl(i) * aobl(:, i) / GMcb end do - end associate + end if + return - end subroutine swiftest_obl_acc_body + end subroutine swiftest_obl_acc module subroutine swiftest_obl_acc_pl(self, nbody_system) @@ -60,18 +77,19 @@ module subroutine swiftest_obl_acc_pl(self, nbody_system) class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl if (self%nbody == 0) return - associate(pl => self, npl => self%nbody, cb => nbody_system%cb) - call swiftest_obl_acc_body(pl, nbody_system) - cb%aobl(:) = 0.0_DP - do i = npl, 1, -1 - if (pl%lmask(i)) cb%aobl(:) = cb%aobl(:) - pl%Gmass(i) * pl%aobl(:, i) / cb%Gmass - end do + associate(pl => self, cb => nbody_system%cb) + npl = self%nbody + call swiftest_obl_acc(npl, cb%Gmass, cb%j2rp2, cb%j4rp4, pl%rh, pl%lmask, pl%aobl, pl%Gmass, cb%aobl) +#ifdef DOCONLOC + do concurrent(i = 1:npl, pl%lmask(i)) shared(cb,pl) +#else do concurrent(i = 1:npl, pl%lmask(i)) +#endif pl%ah(:, i) = pl%ah(:, i) + pl%aobl(:, i) - cb%aobl(:) end do end associate @@ -94,19 +112,24 @@ module subroutine swiftest_obl_acc_tp(self, nbody_system) class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object ! Internals real(DP), dimension(NDIM) :: aoblcb - integer(I4B) :: i + integer(I4B) :: i, ntp if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody, cb => nbody_system%cb) - call swiftest_obl_acc_body(tp, nbody_system) + associate(tp => self, cb => nbody_system%cb) + ntp = self%nbody + call swiftest_obl_acc(ntp, cb%Gmass, cb%j2rp2, cb%j4rp4, tp%rh, tp%lmask, tp%aobl) if (nbody_system%lbeg) then aoblcb = cb%aoblbeg else aoblcb = cb%aoblend end if +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp,aoblcb) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%ah(:, i) = tp%ah(:, i) + tp%aobl(:, i) - aoblcb(:) end do @@ -130,12 +153,17 @@ module subroutine swiftest_obl_pot_system(self) ! Arguments class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl real(DP), dimension(self%pl%nbody) :: oblpot_arr - associate(nbody_system => self, pl => self%pl, npl => self%pl%nbody, cb => self%cb) + associate(nbody_system => self, pl => self%pl, cb => self%cb) + npl = self%pl%nbody if (.not. any(pl%lmask(1:npl))) return +#ifdef DOCONLOC + do concurrent (i = 1:npl, pl%lmask(i)) shared(cb,pl,oblpot_arr) +#else do concurrent (i = 1:npl, pl%lmask(i)) +#endif oblpot_arr(i) = swiftest_obl_pot_one(cb%Gmass, pl%Gmass(i), cb%j2rp2, cb%j4rp4, pl%rh(3,i), 1.0_DP / norm2(pl%rh(:,i))) end do nbody_system%oblpot = sum(oblpot_arr, pl%lmask(1:npl)) diff --git a/src/swiftest/swiftest_orbel.f90 b/src/swiftest/swiftest_orbel.f90 index 8e351e911..431d182ab 100644 --- a/src/swiftest/swiftest_orbel.f90 +++ b/src/swiftest/swiftest_orbel.f90 @@ -21,20 +21,28 @@ module subroutine swiftest_orbel_el2xv_vec(self, cb) class(swiftest_body), intent(inout) :: self !! Swiftest body object class(swiftest_cb), intent(inout) :: cb !! Swiftest central body objec ! Internals - integer(I4B) :: i + integer(I4B) :: i, n if (self%nbody == 0) return + n = self%nbody call self%set_mu(cb) - do concurrent (i = 1:self%nbody) - call swiftest_orbel_el2xv(self%mu(i), self%a(i), self%e(i), self%inc(i), self%capom(i), & - self%omega(i), self%capm(i), self%rh(:, i), self%vh(:, i)) - end do + associate(mu => self%mu, a => self%a, e => self%e, inc => self%inc, capom => self%capom, omega => self%omega, & + capm => self%capm, rh => self%rh, vh => self%vh) +#ifdef DOCONLOC + do concurrent (i = 1:n) shared(mu, a, e, inc, capom, omega, capm, rh, vh) +#else + do concurrent (i = 1:n) +#endif + call swiftest_orbel_el2xv(mu(i), a(i), e(i), inc(i), capom(i), omega(i), capm(i), & + rh(1,i), rh(2,i), rh(3,i), vh(1,i), vh(2,i), vh(3,i)) + end do + end associate return end subroutine swiftest_orbel_el2xv_vec - pure subroutine swiftest_orbel_el2xv(mu, a, ie, inc, capom, omega, capm, x, v) + pure elemental subroutine swiftest_orbel_el2xv(mu, a, ie, inc, capom, omega, capm, rx, ry, rz, vx, vy, vz) !! author: David A. Minton !! !! Compute osculating orbital elements from relative C)rtesian position and velocity @@ -52,7 +60,7 @@ pure subroutine swiftest_orbel_el2xv(mu, a, ie, inc, capom, omega, capm, x, v) implicit none real(DP), intent(in) :: mu real(DP), intent(in) :: a, ie, inc, capom, omega, capm - real(DP), dimension(:), intent(out) :: x, v + real(DP), intent(out) :: rx, ry, rz, vx, vy, vz integer(I4B) :: iorbit_type real(DP) :: e, cape, capf, zpara, em1 @@ -125,12 +133,12 @@ pure subroutine swiftest_orbel_el2xv(mu, a, ie, inc, capom, omega, capm, x, v) vfac2 = ri * sqgma endif !-- - x(1) = d11 * xfac1 + d21 * xfac2 - x(2) = d12 * xfac1 + d22 * xfac2 - x(3) = d13 * xfac1 + d23 * xfac2 - v(1) = d11 * vfac1 + d21 * vfac2 - v(2) = d12 * vfac1 + d22 * vfac2 - v(3) = d13 * vfac1 + d23 * vfac2 + rx = d11 * xfac1 + d21 * xfac2 + ry = d12 * xfac1 + d22 * xfac2 + rz = d13 * xfac1 + d23 * xfac2 + vx = d11 * vfac1 + d21 * vfac2 + vy = d12 * vfac1 + d22 * vfac2 + vz = d13 * vfac1 + d23 * vfac2 return end subroutine swiftest_orbel_el2xv @@ -232,7 +240,6 @@ real(DP) pure function swiftest_orbel_flon(e,icapn) real(DP), parameter :: a5 = 51891840._DP, a3 = 1037836800._DP real(DP), parameter :: b11 = 11 * a11, b9 = 9 * a9, b7 = 7 * a7 real(DP), parameter :: b5 = 5 * a5, b3 = 3 * a3 - real(DP), parameter :: THIRD = 1._DP / 3._DP ! Function to solve "Kepler's eqn" for F (here called ! x) for given e and CAPN. Only good for smallish CAPN @@ -690,7 +697,7 @@ real(DP) pure function swiftest_orbel_fhybrid(e,n) end function swiftest_orbel_fhybrid - pure elemental module subroutine swiftest_orbel_xv2aeq(mu, px, py, pz, vx, vy, vz, a, e, q) + pure elemental module subroutine swiftest_orbel_xv2aeq(mu, rx, ry, rz, vx, vy, vz, a, e, q) !! author: David A. Minton !! !! Compute semimajor axis, eccentricity, and pericentric distance from relative Cartesian position and velocity @@ -700,26 +707,28 @@ pure elemental module subroutine swiftest_orbel_xv2aeq(mu, px, py, pz, vx, vy, v implicit none !! Arguments real(DP), intent(in) :: mu !! Gravitational constant - real(DP), intent(in) :: px,py,pz !! Position vector + real(DP), intent(in) :: rx,ry,rz !! Position vector real(DP), intent(in) :: vx,vy,vz !! Velocity vector real(DP), intent(out) :: a !! semimajor axis real(DP), intent(out) :: e !! eccentricity real(DP), intent(out) :: q !! periapsis ! Internals integer(I4B) :: iorbit_type - real(DP) :: r, v2, h2, energy, fac - real(DP), dimension(NDIM) :: hvec, x, v + real(DP) :: hx, hy, hz, r, v2, h2, energy, fac a = 0.0_DP e = 0.0_DP q = 0.0_DP - x = [px, py, pz] - v = [vx, vy, vz] - r = .mag.x(:) - v2 = dot_product(v(:), v(:)) - hvec(:) = x(:) .cross. v(:) - h2 = dot_product(hvec(:), hvec(:)) - if (h2 == 0.0_DP) return + + r = sqrt(rx*rx + ry*ry + rz*rz) + v2 = vx*vx + vy*vy + vz*vz + + hx = ry*vz - rz*vy + hy = rz*vx - rx*vz + hz = rx*vy - ry*vx + h2 = hx*hx + hy*hy + hz*hz + + if (h2 < tiny(h2)) return energy = 0.5_DP * v2 - mu / r if (abs(energy * r / mu) < sqrt(TINYVALUE)) then iorbit_type = PARABOLA @@ -755,7 +764,7 @@ pure elemental module subroutine swiftest_orbel_xv2aeq(mu, px, py, pz, vx, vy, v end subroutine swiftest_orbel_xv2aeq - pure module subroutine swiftest_orbel_xv2aqt(mu, px, py, pz, vx, vy, vz, a, q, capm, tperi) + pure module subroutine swiftest_orbel_xv2aqt(mu, rx, ry, rz, vx, vy, vz, a, q, capm, tperi) !! author: David A. Minton !! !! Compute semimajor axis, pericentric distance, mean anomaly, and time to nearest pericenter passage from @@ -767,7 +776,7 @@ pure module subroutine swiftest_orbel_xv2aqt(mu, px, py, pz, vx, vy, vz, a, q, c implicit none ! Arguments real(DP), intent(in) :: mu !! Gravitational constant - real(DP), intent(in) :: px,py,pz !! Position vector + real(DP), intent(in) :: rx,ry,rz !! Position vector real(DP), intent(in) :: vx,vy,vz !! Velocity vector real(DP), intent(out) :: a !! semimajor axis real(DP), intent(out) :: q !! periapsis @@ -775,21 +784,21 @@ pure module subroutine swiftest_orbel_xv2aqt(mu, px, py, pz, vx, vy, vz, a, q, c real(DP), intent(out) :: tperi !! time of pericenter passage ! Internals integer(I4B) :: iorbit_type - real(DP) :: r, v2, h2, rdotv, energy, fac, w, face, cape, e, tmpf, capf, mm - real(DP), dimension(NDIM) :: hvec, x, v + real(DP) :: hx, hy, hz, r, v2, h2, rdotv, energy, fac, w, face, cape, e, tmpf, capf, mm a = 0.0_DP q = 0.0_DP capm = 0.0_DP tperi = 0.0_DP - x = [px, py, pz] - v = [vx, vy, vz] - r = sqrt(dot_product(x(:), x(:))) - v2 = dot_product(v(:), v(:)) - hvec(:) = x(:) .cross. v(:) - h2 = dot_product(hvec(:), hvec(:)) - if (h2 == 0.0_DP) return - rdotv = dot_product(x(:), v(:)) + hx = ry*vz - rz*vy + hy = rz*vx - rx*vz + hz = rx*vy - ry*vx + h2 = hx*hx + hy*hy + hz*hz + if (h2 < tiny(h2)) return + + r = sqrt(rx*rx + ry*ry + rz*rz) + v2 = vx*vx + vy*vy + vz*vz + rdotv = rx*vx + ry*vy + rz*vz energy = 0.5_DP * v2 - mu / r if (abs(energy * r / mu) < sqrt(TINYVALUE)) then iorbit_type = PARABOLA @@ -885,7 +894,11 @@ module subroutine swiftest_orbel_xv2el_vec(self, cb) if (allocated(self%capom)) deallocate(self%capom); allocate(self%capom(self%nbody)) if (allocated(self%omega)) deallocate(self%omega); allocate(self%omega(self%nbody)) if (allocated(self%capm)) deallocate(self%capm); allocate(self%capm(self%nbody)) +#ifdef DOCONLOC + do concurrent (i = 1:self%nbody) shared(self) local(varpi,lam,f,cape,capf) +#else do concurrent (i = 1:self%nbody) +#endif call swiftest_orbel_xv2el(self%mu(i), self%rh(1,i), self%rh(2,i), self%rh(3,i), & self%vh(1,i), self%vh(2,i), self%vh(3,i), & self%a(i), self%e(i), self%inc(i), & @@ -897,7 +910,7 @@ module subroutine swiftest_orbel_xv2el_vec(self, cb) end subroutine swiftest_orbel_xv2el_vec - pure module subroutine swiftest_orbel_xv2el(mu, px, py, pz, vx, vy, vz, a, e, inc, capom, omega, capm, varpi, lam, f, cape, capf) + pure module subroutine swiftest_orbel_xv2el(mu, rx, ry, rz, vx, vy, vz, a, e, inc, capom, omega, capm, varpi, lam, f, cape, capf) !! author: David A. Minton !! !! Compute osculating orbital elements from relative Cartesian position and velocity @@ -915,7 +928,7 @@ pure module subroutine swiftest_orbel_xv2el(mu, px, py, pz, vx, vy, vz, a, e, in implicit none ! Arguments real(DP), intent(in) :: mu !! Gravitational constant - real(DP), intent(in) :: px,py,pz !! Position vector + real(DP), intent(in) :: rx,ry,rz !! Position vector real(DP), intent(in) :: vx,vy,vz !! Velocity vector real(DP), intent(out) :: a !! semimajor axis real(DP), intent(out) :: e !! eccentricity @@ -930,8 +943,7 @@ pure module subroutine swiftest_orbel_xv2el(mu, px, py, pz, vx, vy, vz, a, e, in real(DP), intent(out) :: capf !! hyperbolic anomaly (hyperbolic orbits) ! Internals integer(I4B) :: iorbit_type - real(DP) :: r, v2, h2, h, rdotv, energy, fac, u, w, cw, sw, face, tmpf, sf, cf, rdot, h_over_r2 - real(DP), dimension(NDIM) :: hvec, x, v + real(DP) :: hx, hy, hz, r, v2, h2, h, rdotv, energy, fac, u, w, cw, sw, face, tmpf, sf, cf, rdot a = 0.0_DP e = 0.0_DP @@ -944,29 +956,37 @@ pure module subroutine swiftest_orbel_xv2el(mu, px, py, pz, vx, vy, vz, a, e, in f = 0.0_DP cape = 0.0_DP capf = 0.0_DP - x = [px, py, pz] - v = [vx, vy, vz] - r = .mag. x(:) - v2 = dot_product(v(:), v(:)) - hvec = x(:) .cross. v(:) - h2 = dot_product(hvec(:), hvec(:)) - h = .mag. hvec(:) + + hx = ry*vz - rz*vy + hy = rz*vx - rx*vz + hz = rx*vy - ry*vx + h2 = hx*hx + hy*hy +hz*hz + h = sqrt(h2) + if(hz>h) then ! Hal's fix + hz = h + hx = 0.0_DP + hy = 0.0_DP + endif if (h2 <= 10 * tiny(0.0_DP)) return - rdotv = dot_product(x(:), v(:)) + h = SQRT(h2) + + r = sqrt(rx*rx + ry*ry + rz*rz) + v2 = vx*vx + vy*vy + vz*vz + rdotv = rx*vx + ry*vy + rz*vz energy = 0.5_DP * v2 - mu / r - fac = hvec(3) / h + fac = hz / h if (fac < -1.0_DP) then inc = PI else if (fac < 1.0_DP) then inc = acos(fac) end if - fac = sqrt(hvec(1)**2 + hvec(2)**2) / h + fac = sqrt(hx**2 + hy**2) / h if (fac**2 < TINYVALUE) then - u = atan2(py, px) - if (hvec(3) < 0.0_DP) u = -u + u = atan2(ry, rx) + if (hz < 0.0_DP) u = -u else - capom = atan2(hvec(1), -hvec(2)) - u = atan2(pz / sin(inc), px * cos(capom) + py * sin(capom)) + capom = atan2(hx, -hy) + u = atan2(rz / sin(inc), rx * cos(capom) + ry * sin(capom)) end if if (capom < 0.0_DP) capom = capom + TWOPI if (u < 0.0_DP) u = u + TWOPI diff --git a/src/swiftest/swiftest_util.f90 b/src/swiftest/swiftest_util.f90 index fcf130f83..f3ce3082f 100644 --- a/src/swiftest/swiftest_util.f90 +++ b/src/swiftest/swiftest_util.f90 @@ -15,221 +15,99 @@ use fraggle contains - module subroutine swiftest_util_append_arr_char_string(arr, source, nold, nsrc, lsource_mask) - !! author: David A. Minton - !! - !! Append a single array of character string type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. - implicit none - ! Arguments - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Destination array - character(len=STRMAX), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - ! Internals - integer(I4B) :: nnew - - if (.not. allocated(source)) return - - nnew = count(lsource_mask(1:nsrc)) - if (nnew == 0) return - - if (.not.allocated(arr)) then - allocate(arr(nold+nnew)) - else - call swiftest_util_resize(arr, nold + nnew) - end if - - arr(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) - - return - end subroutine swiftest_util_append_arr_char_string - - - module subroutine swiftest_util_append_arr_DP(arr, source, nold, nsrc, lsource_mask) - !! author: David A. Minton - !! - !! Append a single array of double precision type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. - implicit none - ! Arguments - real(DP), dimension(:), allocatable, intent(inout) :: arr !! Destination array - real(DP), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - ! Internals - integer(I4B) :: nnew - - if (.not. allocated(source)) return - - nnew = count(lsource_mask(1:nsrc)) - if (nnew == 0) return - - if (.not.allocated(arr)) then - allocate(arr(nold+nnew)) - else - call swiftest_util_resize(arr, nold + nnew) - end if - - arr(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) - return - end subroutine swiftest_util_append_arr_DP - - - module subroutine swiftest_util_append_arr_DPvec(arr, source, nold, nsrc, lsource_mask) + module subroutine swiftest_util_append_arr_info(arr, source, nold, lsource_mask) !! author: David A. Minton !! - !! Append a single array of double precision vector type of size (NDIM, n) onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. + !! Append a single array of particle information type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. implicit none ! Arguments - real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Destination array - real(DP), dimension(:,:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to + type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array + type(swiftest_particle_info), dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to ! Internals - integer(I4B) :: nnew - - if (.not. allocated(source)) return + integer(I4B) :: nnew, nsrc, nend_orig, i + integer(I4B), dimension(:), allocatable :: idx - nnew = count(lsource_mask(1:nsrc)) - if (nnew == 0) return + if (.not.allocated(source)) return - if (.not.allocated(arr)) then - allocate(arr(NDIM,nold+nnew)) + if (present(lsource_mask)) then + nsrc = count(lsource_mask(:)) else - call swiftest_util_resize(arr, nold + nnew) + nsrc = size(source) end if - - arr(1, nold + 1:nold + nnew) = pack(source(1,1:nsrc), lsource_mask(1:nsrc)) - arr(2, nold + 1:nold + nnew) = pack(source(2,1:nsrc), lsource_mask(1:nsrc)) - arr(3, nold + 1:nold + nnew) = pack(source(3,1:nsrc), lsource_mask(1:nsrc)) - - return - end subroutine swiftest_util_append_arr_DPvec - - - module subroutine swiftest_util_append_arr_I4B(arr, source, nold, nsrc, lsource_mask) - !! author: David A. Minton - !! - !! Append a single array of integer(I4B) onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. - implicit none - ! Arguments - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - ! Internals - integer(I4B) :: nnew - - if (.not. allocated(source)) return - - nnew = count(lsource_mask(1:nsrc)) - if (nnew == 0) return + if (nsrc == 0) return if (.not.allocated(arr)) then - allocate(arr(nold+nnew)) + nend_orig = 0 + allocate(arr(nsrc)) else - call swiftest_util_resize(arr, nold + nnew) + if (present(nold)) then + nend_orig = nold + else + nend_orig = size(arr) + end if + call util_resize(arr, nend_orig + nsrc) end if + nnew = nend_orig + nsrc - arr(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) - - return - end subroutine swiftest_util_append_arr_I4B - - - module subroutine swiftest_util_append_arr_info(arr, source, nold, nsrc, lsource_mask) - !! author: David A. Minton - !! - !! Append a single array of particle information type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. - implicit none - ! Arguments - type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Destination array - type(swiftest_particle_info), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - ! Internals - integer(I4B) :: nnew, i - integer(I4B), dimension(:), allocatable :: idx - - if (.not. allocated(source)) return - - nnew = count(lsource_mask(1:nsrc)) - if (nnew == 0) return - - if (.not.allocated(arr)) then - allocate(arr(nold+nnew)) + allocate(idx(nsrc)) + if (present(lsource_mask)) then + idx = pack([(i, i = 1, size(lsource_mask))], lsource_mask(:)) else - call swiftest_util_resize(arr, nold + nnew) - end if - - allocate(idx(nnew)) + idx = [(i, i = 1,nsrc)] + end if - idx = pack([(i, i = 1, nsrc)], lsource_mask(1:nsrc)) - - call swiftest_util_copy_particle_info_arr(source(1:nsrc), arr(nold+1:nold+nnew), idx) + call swiftest_util_copy_particle_info_arr(source(:), arr(nend_orig+1:nnew), idx) return end subroutine swiftest_util_append_arr_info - module subroutine swiftest_util_append_arr_kin(arr, source, nold, nsrc, lsource_mask) + module subroutine swiftest_util_append_arr_kin(arr, source, nold, lsource_mask) !! author: David A. Minton !! !! Append a single array of kinship type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. implicit none ! Arguments - type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Destination array - type(swiftest_kinship), dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to + type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Destination array + type(swiftest_kinship), dimension(:), allocatable, intent(in) :: source !! Array to append + integer(I4B), intent(in), optional :: nold !! Extent of original array. If passed, the source array will begin at arr(nold+1). Otherwise, the size of arr will be used. + logical, dimension(:), intent(in), optional :: lsource_mask !! Logical mask indicating which elements to append to ! Internals - integer(I4B) :: nnew - - if (.not. allocated(source)) return + integer(I4B) :: nnew, nsrc, nend_orig - nnew = count(lsource_mask(1:nsrc)) - if (nnew == 0) return + if (.not.allocated(source)) return - if (.not.allocated(arr)) then - allocate(arr(nold+nnew)) + if (present(lsource_mask)) then + nsrc = count(lsource_mask(:)) else - call swiftest_util_resize(arr, nold + nnew) + nsrc = size(source) end if - - arr(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) - - return - end subroutine swiftest_util_append_arr_kin - - - module subroutine swiftest_util_append_arr_logical(arr, source, nold, nsrc, lsource_mask) - !! author: David A. Minton - !! - !! Append a single array of logical type onto another. If the destination array is not allocated, or is not big enough, this will allocate space for it. - implicit none - ! Arguments - logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array - logical, dimension(:), allocatable, intent(in) :: source !! Array to append - integer(I4B), intent(in) :: nold, nsrc !! Extend of the old array and the source array, respectively - logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to - ! Internals - integer(I4B) :: nnew - - if (.not. allocated(source)) return - - nnew = count(lsource_mask(1:nsrc)) - if (nnew == 0) return + if (nsrc == 0) return if (.not.allocated(arr)) then - allocate(arr(nold+nnew)) + nend_orig = 0 + allocate(arr(nsrc)) else - call swiftest_util_resize(arr, nold + nnew) + if (present(nold)) then + nend_orig = nold + else + nend_orig = size(arr) + end if + call util_resize(arr, nend_orig + nsrc) end if + nnew = nend_orig + nsrc - arr(nold + 1:nold + nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) + if (present(lsource_mask)) then + arr(nend_orig + 1:nnew) = pack(source(1:nsrc), lsource_mask(1:nsrc)) + else + arr(nend_orig + 1:nnew) = source(1:nsrc) + end if return - end subroutine swiftest_util_append_arr_logical + end subroutine swiftest_util_append_arr_kin module subroutine swiftest_util_append_body(self, source, lsource_mask) @@ -243,40 +121,36 @@ module subroutine swiftest_util_append_body(self, source, lsource_mask) class(swiftest_body), intent(in) :: source !! Source object to append logical, dimension(:), intent(in) :: lsource_mask !! Logical mask indicating which elements to append to ! Internals - integer(I4B) :: nold, nsrc, nnew - - nold = self%nbody - nsrc = source%nbody - nnew = count(lsource_mask(1:nsrc)) - - call swiftest_util_append(self%id, source%id, nold, nsrc, lsource_mask) - call swiftest_util_append(self%info, source%info, nold, nsrc, lsource_mask) - call swiftest_util_append(self%lmask, source%lmask, nold, nsrc, lsource_mask) - call swiftest_util_append(self%status, source%status, nold, nsrc, lsource_mask) - call swiftest_util_append(self%ldiscard, source%ldiscard, nold, nsrc, lsource_mask) - call swiftest_util_append(self%lencounter, source%lencounter, nold, nsrc, lsource_mask) - call swiftest_util_append(self%lcollision, source%lcollision, nold, nsrc, lsource_mask) - call swiftest_util_append(self%mu, source%mu, nold, nsrc, lsource_mask) - call swiftest_util_append(self%rh, source%rh, nold, nsrc, lsource_mask) - call swiftest_util_append(self%vh, source%vh, nold, nsrc, lsource_mask) - call swiftest_util_append(self%rb, source%rb, nold, nsrc, lsource_mask) - call swiftest_util_append(self%vb, source%vb, nold, nsrc, lsource_mask) - call swiftest_util_append(self%ah, source%ah, nold, nsrc, lsource_mask) - call swiftest_util_append(self%aobl, source%aobl, nold, nsrc, lsource_mask) - call swiftest_util_append(self%atide, source%atide, nold, nsrc, lsource_mask) - call swiftest_util_append(self%agr, source%agr, nold, nsrc, lsource_mask) - call swiftest_util_append(self%ir3h, source%ir3h, nold, nsrc, lsource_mask) - call swiftest_util_append(self%isperi, source%isperi, nold, nsrc, lsource_mask) - call swiftest_util_append(self%peri, source%peri, nold, nsrc, lsource_mask) - call swiftest_util_append(self%atp, source%atp, nold, nsrc, lsource_mask) - call swiftest_util_append(self%a, source%a, nold, nsrc, lsource_mask) - call swiftest_util_append(self%e, source%e, nold, nsrc, lsource_mask) - call swiftest_util_append(self%inc, source%inc, nold, nsrc, lsource_mask) - call swiftest_util_append(self%capom, source%capom, nold, nsrc, lsource_mask) - call swiftest_util_append(self%omega, source%omega, nold, nsrc, lsource_mask) - call swiftest_util_append(self%capm, source%capm, nold, nsrc, lsource_mask) - - self%nbody = nold + nnew + + + call util_append(self%id, source%id, lsource_mask=lsource_mask) + call util_append(self%info, source%info, lsource_mask=lsource_mask) + call util_append(self%lmask, source%lmask, lsource_mask=lsource_mask) + call util_append(self%status, source%status, lsource_mask=lsource_mask) + call util_append(self%ldiscard, source%ldiscard, lsource_mask=lsource_mask) + call util_append(self%lencounter, source%lencounter, lsource_mask=lsource_mask) + call util_append(self%lcollision, source%lcollision, lsource_mask=lsource_mask) + call util_append(self%mu, source%mu, lsource_mask=lsource_mask) + call util_append(self%rh, source%rh, lsource_mask=lsource_mask) + call util_append(self%vh, source%vh, lsource_mask=lsource_mask) + call util_append(self%rb, source%rb, lsource_mask=lsource_mask) + call util_append(self%vb, source%vb, lsource_mask=lsource_mask) + call util_append(self%ah, source%ah, lsource_mask=lsource_mask) + call util_append(self%aobl, source%aobl, lsource_mask=lsource_mask) + call util_append(self%atide, source%atide, lsource_mask=lsource_mask) + call util_append(self%agr, source%agr, lsource_mask=lsource_mask) + call util_append(self%ir3h, source%ir3h, lsource_mask=lsource_mask) + call util_append(self%isperi, source%isperi, lsource_mask=lsource_mask) + call util_append(self%peri, source%peri, lsource_mask=lsource_mask) + call util_append(self%atp, source%atp, lsource_mask=lsource_mask) + call util_append(self%a, source%a, lsource_mask=lsource_mask) + call util_append(self%e, source%e, lsource_mask=lsource_mask) + call util_append(self%inc, source%inc, lsource_mask=lsource_mask) + call util_append(self%capom, source%capom, lsource_mask=lsource_mask) + call util_append(self%omega, source%omega, lsource_mask=lsource_mask) + call util_append(self%capm, source%capm, lsource_mask=lsource_mask) + + self%nbody = self%nbody + count(lsource_mask(:)) return end subroutine swiftest_util_append_body @@ -295,30 +169,28 @@ module subroutine swiftest_util_append_pl(self, source, lsource_mask) select type(source) class is (swiftest_pl) - associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%mass, source%mass, nold, nsrc, lsource_mask) - call swiftest_util_append(self%Gmass, source%Gmass, nold, nsrc, lsource_mask) - call swiftest_util_append(self%rhill, source%rhill, nold, nsrc, lsource_mask) - call swiftest_util_append(self%renc, source%renc, nold, nsrc, lsource_mask) - call swiftest_util_append(self%radius, source%radius, nold, nsrc, lsource_mask) - call swiftest_util_append(self%density, source%density, nold, nsrc, lsource_mask) - call swiftest_util_append(self%rbeg, source%rbeg, nold, nsrc, lsource_mask) - call swiftest_util_append(self%rend, source%rend, nold, nsrc, lsource_mask) - call swiftest_util_append(self%vbeg, source%vbeg, nold, nsrc, lsource_mask) - call swiftest_util_append(self%Ip, source%Ip, nold, nsrc, lsource_mask) - call swiftest_util_append(self%rot, source%rot, nold, nsrc, lsource_mask) - call swiftest_util_append(self%k2, source%k2, nold, nsrc, lsource_mask) - call swiftest_util_append(self%Q, source%Q, nold, nsrc, lsource_mask) - call swiftest_util_append(self%tlag, source%tlag, nold, nsrc, lsource_mask) - call swiftest_util_append(self%kin, source%kin, nold, nsrc, lsource_mask) - call swiftest_util_append(self%lmtiny, source%lmtiny, nold, nsrc, lsource_mask) - call swiftest_util_append(self%nplenc, source%nplenc, nold, nsrc, lsource_mask) - call swiftest_util_append(self%ntpenc, source%ntpenc, nold, nsrc, lsource_mask) - - if (allocated(self%k_plpl)) deallocate(self%k_plpl) - - call swiftest_util_append_body(self, source, lsource_mask) - end associate + call util_append(self%mass, source%mass, lsource_mask=lsource_mask) + call util_append(self%Gmass, source%Gmass, lsource_mask=lsource_mask) + call util_append(self%rhill, source%rhill, lsource_mask=lsource_mask) + call util_append(self%renc, source%renc, lsource_mask=lsource_mask) + call util_append(self%radius, source%radius, lsource_mask=lsource_mask) + call util_append(self%density, source%density, lsource_mask=lsource_mask) + call util_append(self%rbeg, source%rbeg, lsource_mask=lsource_mask) + call util_append(self%rend, source%rend, lsource_mask=lsource_mask) + call util_append(self%vbeg, source%vbeg, lsource_mask=lsource_mask) + call util_append(self%Ip, source%Ip, lsource_mask=lsource_mask) + call util_append(self%rot, source%rot, lsource_mask=lsource_mask) + call util_append(self%k2, source%k2, lsource_mask=lsource_mask) + call util_append(self%Q, source%Q, lsource_mask=lsource_mask) + call util_append(self%tlag, source%tlag, lsource_mask=lsource_mask) + call util_append(self%kin, source%kin, lsource_mask=lsource_mask) + call util_append(self%lmtiny, source%lmtiny, lsource_mask=lsource_mask) + call util_append(self%nplenc, source%nplenc, lsource_mask=lsource_mask) + call util_append(self%ntpenc, source%ntpenc, lsource_mask=lsource_mask) + + if (allocated(self%k_plpl)) deallocate(self%k_plpl) + + call swiftest_util_append_body(self, source, lsource_mask) class default write(*,*) "Invalid object passed to the append method. Source must be of class swiftest_pl or its descendents" call base_util_exit(FAILURE) @@ -341,11 +213,9 @@ module subroutine swiftest_util_append_tp(self, source, lsource_mask) select type(source) class is (swiftest_tp) - associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%nplenc, source%nplenc, nold, nsrc, lsource_mask) + call util_append(self%nplenc, source%nplenc, lsource_mask=lsource_mask) - call swiftest_util_append_body(self, source, lsource_mask) - end associate + call swiftest_util_append_body(self, source, lsource_mask) class default write(*,*) "Invalid object passed to the append method. Source must be of class swiftest_tp or its descendents" call base_util_exit(FAILURE) @@ -407,11 +277,16 @@ module subroutine swiftest_util_coord_h2b_tp(self, cb) class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object class(swiftest_cb), intent(in) :: cb !! Swiftest central body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, ntp if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody) + associate(tp => self) + ntp = self%nbody +#ifdef DOCONLOC + do concurrent (i = 1:ntp, tp%status(i) /= INACTIVE) shared(cb,tp) +#else do concurrent (i = 1:ntp, tp%status(i) /= INACTIVE) +#endif tp%rb(:, i) = tp%rh(:, i) + cb%rb(:) tp%vb(:, i) = tp%vh(:, i) + cb%vb(:) end do @@ -433,12 +308,17 @@ module subroutine swiftest_util_coord_b2h_pl(self, cb) class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl if (self%nbody == 0) return - associate(pl => self, npl => self%nbody) + associate(pl => self) + npl = self%nbody +#ifdef DOCONLOC + do concurrent (i = 1:npl, pl%status(i) /= INACTIVE) shared(cb,pl) +#else do concurrent (i = 1:npl, pl%status(i) /= INACTIVE) +#endif pl%rh(:, i) = pl%rb(:, i) - cb%rb(:) pl%vh(:, i) = pl%vb(:, i) - cb%vb(:) end do @@ -460,12 +340,17 @@ module subroutine swiftest_util_coord_b2h_tp(self, cb) class(swiftest_tp), intent(inout) :: self !! Swiftest massive body object class(swiftest_cb), intent(in) :: cb !! Swiftest central body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, ntp if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody) + associate(tp => self) + ntp = self%nbody +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%status(i) /= INACTIVE) shared(cb,tp) +#else do concurrent(i = 1:ntp, tp%status(i) /= INACTIVE) +#endif tp%rh(:, i) = tp%rb(:, i) - cb%rb(:) tp%vh(:, i) = tp%vb(:, i) - cb%vb(:) end do @@ -487,16 +372,21 @@ module subroutine swiftest_util_coord_vb2vh_pl(self, cb) class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl if (self%nbody == 0) return - associate(pl => self, npl => self%nbody) + associate(pl => self) + npl = self%nbody cb%vb(:) = 0.0_DP do i = npl, 1, -1 if (pl%status(i) /= INACTIVE) cb%vb(:) = cb%vb(:) - pl%Gmass(i) * pl%vb(:, i) / cb%Gmass end do +#ifdef DOCONLOC + do concurrent(i = 1:npl) shared(cb,pl) +#else do concurrent(i = 1:npl) +#endif pl%vh(:, i) = pl%vb(:, i) - cb%vb(:) end do end associate @@ -543,19 +433,24 @@ module subroutine swiftest_util_coord_vh2vb_pl(self, cb) class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl real(DP) :: Gmtot if (self%nbody == 0) return - associate(pl => self, npl => self%nbody) + associate(pl => self) + npl = self%nbody Gmtot = cb%Gmass + sum(pl%Gmass(1:npl)) cb%vb(:) = 0.0_DP do i = 1, npl cb%vb(:) = cb%vb(:) - pl%Gmass(i) * pl%vh(:, i) end do cb%vb(:) = cb%vb(:) / Gmtot +#ifdef DOCONLOC + do concurrent(i = 1:npl) shared(cb,pl) +#else do concurrent(i = 1:npl) +#endif pl%vb(:, i) = pl%vh(:, i) + cb%vb(:) end do end associate @@ -638,11 +533,16 @@ module subroutine swiftest_util_coord_rh2rb_tp(self, cb) class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object class(swiftest_cb), intent(in) :: cb !! Swiftest central body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, ntp if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody) + associate(tp => self) + ntp = self%nbody +#ifdef DOCONLOC + do concurrent (i = 1:ntp, tp%status(i) /= INACTIVE) shared(cb,tp) +#else do concurrent (i = 1:ntp, tp%status(i) /= INACTIVE) +#endif tp%rb(:, i) = tp%rh(:, i) + cb%rb(:) end do end associate @@ -727,7 +627,8 @@ module subroutine swiftest_util_dealloc_body(self) class(swiftest_body), intent(inout) :: self self%lfirst = .true. - + self%nbody = 0 + if (allocated(self%id)) deallocate(self%id) if (allocated(self%info)) deallocate(self%info) if (allocated(self%status)) deallocate(self%status) if (allocated(self%lmask)) deallocate(self%lmask) @@ -754,8 +655,6 @@ module subroutine swiftest_util_dealloc_body(self) if (allocated(self%omega)) deallocate(self%omega) if (allocated(self%capm)) deallocate(self%capm) - call base_util_dealloc_multibody(self) - return end subroutine swiftest_util_dealloc_body @@ -897,7 +796,6 @@ module subroutine swiftest_util_dealloc_system(self) if (allocated(self%collider)) deallocate(self%collider) if (allocated(self%encounter_history)) deallocate(self%encounter_history) if (allocated(self%collision_history)) deallocate(self%collision_history) - if (allocated(self%system_history)) deallocate(self%system_history) self%t = -1.0_DP self%GMtot = 0.0_DP @@ -960,90 +858,6 @@ module subroutine swiftest_util_dealloc_tp(self) end subroutine swiftest_util_dealloc_tp - module subroutine swiftest_util_fill_arr_char_string(keeps, inserts, lfill_list) - !! author: David A. Minton - !! - !! Performs a fill operation on a single array of type character strings - !! This is the inverse of a spill operation - implicit none - ! Arguments - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - character(len=STRMAX), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - - if (.not.allocated(keeps) .or. .not.allocated(inserts)) return - - keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) - keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) - - return - end subroutine swiftest_util_fill_arr_char_string - - - module subroutine swiftest_util_fill_arr_DP(keeps, inserts, lfill_list) - !! author: David A. Minton - !! - !! Performs a fill operation on a single array of type DP - !! This is the inverse of a spill operation - implicit none - ! Arguments - real(DP), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - - if (.not.allocated(keeps) .or. .not.allocated(inserts)) return - - keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) - keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) - - return - end subroutine swiftest_util_fill_arr_DP - - - module subroutine swiftest_util_fill_arr_DPvec(keeps, inserts, lfill_list) - !! author: David A. Minton - !! - !! Performs a fill operation on a single array of DP vectors with shape (NDIM, n) - !! This is the inverse of a spill operation - implicit none - ! Arguments - real(DP), dimension(:,:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:,:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - ! Internals - integer(I4B) :: i - - if (.not.allocated(keeps) .or. .not.allocated(inserts)) return - - do i = 1, NDIM - keeps(i,:) = unpack(keeps(i,:), .not.lfill_list(:), keeps(i,:)) - keeps(i,:) = unpack(inserts(i,:), lfill_list(:), keeps(i,:)) - end do - - return - end subroutine swiftest_util_fill_arr_DPvec - - - module subroutine swiftest_util_fill_arr_I4B(keeps, inserts, lfill_list) - !! author: David A. Minton - !! - !! Performs a fill operation on a single array of type I4B - !! This is the inverse of a spill operation - implicit none - ! Arguments - integer(I4B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - integer(I4B), dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - - if (.not.allocated(keeps) .or. .not.allocated(inserts)) return - - keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) - keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) - - return - end subroutine swiftest_util_fill_arr_I4B - - module subroutine swiftest_util_fill_arr_info(keeps, inserts, lfill_list) !! author: David A. Minton !! @@ -1072,26 +886,6 @@ module subroutine swiftest_util_fill_arr_info(keeps, inserts, lfill_list) end subroutine swiftest_util_fill_arr_info - module subroutine swiftest_util_fill_arr_logical(keeps, inserts, lfill_list) - !! author: David A. Minton - !! - !! Performs a fill operation on a single array of logicals - !! This is the inverse of a spill operation - implicit none - ! Arguments - logical, dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - logical, dimension(:), allocatable, intent(in) :: inserts !! Array of values to insert into keep - logical, dimension(:), intent(in) :: lfill_list !! Logical array of bodies to merge into the keeps - - if (.not.allocated(keeps) .or. .not.allocated(inserts)) return - - keeps(:) = unpack(keeps(:), .not.lfill_list(:), keeps(:)) - keeps(:) = unpack(inserts(:), lfill_list(:), keeps(:)) - - return - end subroutine swiftest_util_fill_arr_logical - - module subroutine swiftest_util_fill_arr_kin(keeps, inserts, lfill_list) !! author: David A. Minton !! @@ -1126,32 +920,32 @@ module subroutine swiftest_util_fill_body(self, inserts, lfill_list) ! For each component, pack the discarded bodies into the discard object and do the inverse with the keeps !> Fill all the common components associate(keeps => self) - call swiftest_util_fill(keeps%id, inserts%id, lfill_list) - call swiftest_util_fill(keeps%info, inserts%info, lfill_list) - call swiftest_util_fill(keeps%lmask, inserts%lmask, lfill_list) - call swiftest_util_fill(keeps%status, inserts%status, lfill_list) - call swiftest_util_fill(keeps%ldiscard, inserts%ldiscard, lfill_list) - call swiftest_util_fill(keeps%lcollision, inserts%lcollision, lfill_list) - call swiftest_util_fill(keeps%lencounter, inserts%lencounter, lfill_list) - call swiftest_util_fill(keeps%mu, inserts%mu, lfill_list) - call swiftest_util_fill(keeps%rh, inserts%rh, lfill_list) - call swiftest_util_fill(keeps%vh, inserts%vh, lfill_list) - call swiftest_util_fill(keeps%rb, inserts%rb, lfill_list) - call swiftest_util_fill(keeps%vb, inserts%vb, lfill_list) - call swiftest_util_fill(keeps%ah, inserts%ah, lfill_list) - call swiftest_util_fill(keeps%aobl, inserts%aobl, lfill_list) - call swiftest_util_fill(keeps%agr, inserts%agr, lfill_list) - call swiftest_util_fill(keeps%atide, inserts%atide, lfill_list) - call swiftest_util_fill(keeps%ir3h, inserts%ir3h, lfill_list) - call swiftest_util_fill(keeps%isperi, inserts%isperi, lfill_list) - call swiftest_util_fill(keeps%peri, inserts%peri, lfill_list) - call swiftest_util_fill(keeps%atp, inserts%atp, lfill_list) - call swiftest_util_fill(keeps%a, inserts%a, lfill_list) - call swiftest_util_fill(keeps%e, inserts%e, lfill_list) - call swiftest_util_fill(keeps%inc, inserts%inc, lfill_list) - call swiftest_util_fill(keeps%capom, inserts%capom, lfill_list) - call swiftest_util_fill(keeps%omega, inserts%omega, lfill_list) - call swiftest_util_fill(keeps%capm, inserts%capm, lfill_list) + call util_fill(keeps%id, inserts%id, lfill_list) + call util_fill(keeps%info, inserts%info, lfill_list) + call util_fill(keeps%lmask, inserts%lmask, lfill_list) + call util_fill(keeps%status, inserts%status, lfill_list) + call util_fill(keeps%ldiscard, inserts%ldiscard, lfill_list) + call util_fill(keeps%lcollision, inserts%lcollision, lfill_list) + call util_fill(keeps%lencounter, inserts%lencounter, lfill_list) + call util_fill(keeps%mu, inserts%mu, lfill_list) + call util_fill(keeps%rh, inserts%rh, lfill_list) + call util_fill(keeps%vh, inserts%vh, lfill_list) + call util_fill(keeps%rb, inserts%rb, lfill_list) + call util_fill(keeps%vb, inserts%vb, lfill_list) + call util_fill(keeps%ah, inserts%ah, lfill_list) + call util_fill(keeps%aobl, inserts%aobl, lfill_list) + call util_fill(keeps%agr, inserts%agr, lfill_list) + call util_fill(keeps%atide, inserts%atide, lfill_list) + call util_fill(keeps%ir3h, inserts%ir3h, lfill_list) + call util_fill(keeps%isperi, inserts%isperi, lfill_list) + call util_fill(keeps%peri, inserts%peri, lfill_list) + call util_fill(keeps%atp, inserts%atp, lfill_list) + call util_fill(keeps%a, inserts%a, lfill_list) + call util_fill(keeps%e, inserts%e, lfill_list) + call util_fill(keeps%inc, inserts%inc, lfill_list) + call util_fill(keeps%capom, inserts%capom, lfill_list) + call util_fill(keeps%omega, inserts%omega, lfill_list) + call util_fill(keeps%capm, inserts%capm, lfill_list) ! This is the base class, so will be the last to be called in the cascade. keeps%nbody = size(keeps%id(:)) @@ -1177,23 +971,23 @@ module subroutine swiftest_util_fill_pl(self, inserts, lfill_list) select type (inserts) ! The standard requires us to select the type of both arguments in order to access all the components class is (swiftest_pl) !> Fill components specific to the massive body class - call swiftest_util_fill(keeps%mass, inserts%mass, lfill_list) - call swiftest_util_fill(keeps%Gmass, inserts%Gmass, lfill_list) - call swiftest_util_fill(keeps%rhill, inserts%rhill, lfill_list) - call swiftest_util_fill(keeps%renc, inserts%renc, lfill_list) - call swiftest_util_fill(keeps%radius, inserts%radius, lfill_list) - call swiftest_util_fill(keeps%density, inserts%density, lfill_list) - call swiftest_util_fill(keeps%rbeg, inserts%rbeg, lfill_list) - call swiftest_util_fill(keeps%rend, inserts%rend, lfill_list) - call swiftest_util_fill(keeps%vbeg, inserts%vbeg, lfill_list) - call swiftest_util_fill(keeps%Ip, inserts%Ip, lfill_list) - call swiftest_util_fill(keeps%rot, inserts%rot, lfill_list) - call swiftest_util_fill(keeps%k2, inserts%k2, lfill_list) - call swiftest_util_fill(keeps%Q, inserts%Q, lfill_list) - call swiftest_util_fill(keeps%tlag, inserts%tlag, lfill_list) - call swiftest_util_fill(keeps%kin, inserts%kin, lfill_list) - call swiftest_util_fill(keeps%nplenc, inserts%nplenc, lfill_list) - call swiftest_util_fill(keeps%ntpenc, inserts%ntpenc, lfill_list) + call util_fill(keeps%mass, inserts%mass, lfill_list) + call util_fill(keeps%Gmass, inserts%Gmass, lfill_list) + call util_fill(keeps%rhill, inserts%rhill, lfill_list) + call util_fill(keeps%renc, inserts%renc, lfill_list) + call util_fill(keeps%radius, inserts%radius, lfill_list) + call util_fill(keeps%density, inserts%density, lfill_list) + call util_fill(keeps%rbeg, inserts%rbeg, lfill_list) + call util_fill(keeps%rend, inserts%rend, lfill_list) + call util_fill(keeps%vbeg, inserts%vbeg, lfill_list) + call util_fill(keeps%Ip, inserts%Ip, lfill_list) + call util_fill(keeps%rot, inserts%rot, lfill_list) + call util_fill(keeps%k2, inserts%k2, lfill_list) + call util_fill(keeps%Q, inserts%Q, lfill_list) + call util_fill(keeps%tlag, inserts%tlag, lfill_list) + call util_fill(keeps%kin, inserts%kin, lfill_list) + call util_fill(keeps%nplenc, inserts%nplenc, lfill_list) + call util_fill(keeps%ntpenc, inserts%ntpenc, lfill_list) if (allocated(keeps%k_plpl)) deallocate(keeps%k_plpl) @@ -1222,7 +1016,7 @@ module subroutine swiftest_util_fill_tp(self, inserts, lfill_list) select type(inserts) class is (swiftest_tp) !> Spill components specific to the test particle class - call swiftest_util_fill(keeps%nplenc, inserts%nplenc, lfill_list) + call util_fill(keeps%nplenc, inserts%nplenc, lfill_list) call swiftest_util_fill_body(keeps, inserts, lfill_list) class default @@ -1307,20 +1101,25 @@ module subroutine swiftest_util_flatten_eucl_plpl(self, param) class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i, j, err - integer(I8B) :: k, npl + integer(I4B) :: err, i, j, npl + integer(I8B) :: k, npl8 - npl = int(self%nbody, kind=I8B) associate(nplpl => self%nplpl) - nplpl = npl * (npl - 1_I8B) / 2_I8B ! number of entries in a strict lower triangle, npl x npl + npl = self%nbody + npl8 = int(npl, kind=I8B) + nplpl = npl8 * (npl8 - 1_I8B) / 2_I8B ! number of entries in a strict lower triangle, npl x npl if (param%lflatten_interactions) then if (allocated(self%k_plpl)) deallocate(self%k_plpl) ! Reset the index array if it's been set previously allocate(self%k_plpl(2, nplpl), stat=err) if (err /=0) then ! An error occurred trying to allocate this big array. This probably means it's too big to fit in memory, and so we will force the run back into triangular mode param%lflatten_interactions = .false. else +#ifdef DOCONLOC + do concurrent (i=1:npl, j=1:npl, j>i) shared(self) local(k) +#else do concurrent (i=1:npl, j=1:npl, j>i) - call swiftest_util_flatten_eucl_ij_to_k(self%nbody, i, j, k) +#endif + call swiftest_util_flatten_eucl_ij_to_k(npl, i, j, k) self%k_plpl(1, k) = i self%k_plpl(2, k) = j end do @@ -1347,17 +1146,18 @@ module subroutine swiftest_util_flatten_eucl_pltp(self, pl, param) class(swiftest_pl), intent(in) :: pl !! Swiftest massive body object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I8B) :: i, j, counter, npl, ntp + integer(I4B) :: i, j + integer(I8B) :: counter, npl8, ntp8 - ntp = int(self%nbody, kind=I8B) - npl = int(pl%nbody, kind=I8B) - associate(npltp => self%npltp) - npltp = npl * ntp + associate(ntp => self%nbody, npl => pl%nbody, npltp => self%npltp) + npl8 = int(npl, kind=I8B) + ntp8 = int(ntp, kind=I8B) + npltp = npl8 * ntp8 if (allocated(self%k_pltp)) deallocate(self%k_pltp) ! Reset the index array if it's been set previously allocate(self%k_pltp(2, npltp)) - do i = 1_I8B, npl - counter = (i - 1_I8B) * npl + 1_I8B - do j = 1_I8B, ntp + counter = 1_I8B + do i = 1, npl + do j = 1, ntp self%k_pltp(1, counter) = i self%k_pltp(2, counter) = j counter = counter + 1_I8B @@ -1381,7 +1181,7 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param) class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody system object class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i,j + integer(I4B) :: i,j, npl real(DP) :: kecb, kespincb real(DP), dimension(self%pl%nbody) :: kepl, kespinpl real(DP), dimension(NDIM,self%pl%nbody) :: Lplorbit @@ -1389,7 +1189,8 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param) real(DP), dimension(NDIM) :: Lcborbit, Lcbspin real(DP), dimension(NDIM) :: h - associate(nbody_system => self, pl => self%pl, npl => self%pl%nbody, cb => self%cb) + associate(nbody_system => self, pl => self%pl, cb => self%cb) + npl = self%pl%nbody nbody_system%L_orbit(:) = 0.0_DP nbody_system%L_spin(:) = 0.0_DP nbody_system%L_total(:) = 0.0_DP @@ -1407,8 +1208,14 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param) nbody_system%be_cb = -3*cb%Gmass * cb%mass / (5 * cb%radius) Lcborbit(:) = cb%mass * (cb%rb(:) .cross. cb%vb(:)) +#ifdef DOCONLOC + do concurrent (i = 1:npl, pl%lmask(i)) shared(pl,Lplorbit,kepl) local(h) +#else do concurrent (i = 1:npl, pl%lmask(i)) - h(:) = pl%rb(:,i) .cross. pl%vb(:,i) +#endif + h(1) = pl%rb(2,i) * pl%vb(3,i) - pl%rb(3,i) * pl%vb(2,i) + h(2) = pl%rb(3,i) * pl%vb(1,i) - pl%rb(1,i) * pl%vb(3,i) + h(3) = pl%rb(1,i) * pl%vb(2,i) - pl%rb(2,i) * pl%vb(1,i) ! Angular momentum from orbit Lplorbit(:,i) = pl%mass(i) * h(:) @@ -1423,7 +1230,11 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param) ! For simplicity, we always assume that the rotation pole is the 3rd principal axis Lcbspin(:) = cb%Ip(3) * cb%mass * cb%radius**2 * cb%rot(:) +#ifdef DOCONLOC + do concurrent (i = 1:npl, pl%lmask(i)) shared(pl,Lplspin,kespinpl) +#else do concurrent (i = 1:npl, pl%lmask(i)) +#endif ! Currently we assume that the rotation pole is the 3rd principal axis ! Angular momentum from spin Lplspin(:,i) = pl%mass(i) * pl%Ip(3,i) * pl%radius(i)**2 * pl%rot(:,i) @@ -1434,7 +1245,11 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param) nbody_system%ke_spin = 0.5_DP * (kespincb + sum(kespinpl(1:npl), pl%lmask(1:npl))) +#ifdef DOCONLOC + do concurrent (j = 1:NDIM) shared(nbody_system,pl,Lplspin,Lcbspin) +#else do concurrent (j = 1:NDIM) +#endif nbody_system%L_spin(j) = Lcbspin(j) + sum(Lplspin(j,1:npl), pl%lmask(1:npl)) end do else @@ -1455,8 +1270,11 @@ module subroutine swiftest_util_get_energy_and_momentum_system(self, param) end if nbody_system%ke_orbit = 0.5_DP * (kecb + sum(kepl(1:npl), pl%lmask(1:npl))) - +#ifdef DOCONLOC + do concurrent (j = 1:NDIM) shared(nbody_system,pl,Lcborbit,Lplorbit,npl) +#else do concurrent (j = 1:NDIM) +#endif nbody_system%L_orbit(j) = Lcborbit(j) + sum(Lplorbit(j,1:npl), pl%lmask(1:npl)) end do @@ -1500,7 +1318,11 @@ module subroutine swiftest_util_get_potential_energy_flat(npl, nplpl, k_plpl, lm pecb(1:npl) = 0.0_DP end where +#ifdef DOCONLOC + do concurrent(i = 1:npl, lmask(i)) shared(lmask,pecb,GMcb,mass,rb) +#else do concurrent(i = 1:npl, lmask(i)) +#endif pecb(i) = -GMcb * mass(i) / norm2(rb(:,i)) end do @@ -1547,7 +1369,11 @@ module subroutine swiftest_util_get_potential_energy_triangular(npl, lmask, GMcb pecb(1:npl) = 0.0_DP end where +#ifdef DOCONLOC + do concurrent(i = 1:npl, lmask(i)) shared(lmask, pecb, GMcb, mass, rb, lmask) +#else do concurrent(i = 1:npl, lmask(i)) +#endif pecb(i) = -GMcb * mass(i) / norm2(rb(:,i)) end do @@ -1558,7 +1384,11 @@ module subroutine swiftest_util_get_potential_energy_triangular(npl, lmask, GMcb !$omp reduction(+:pe) do i = 1, npl if (lmask(i)) then +#ifdef DOCONLOC + do concurrent(j = i+1:npl, lmask(i) .and. lmask(j)) shared(lmask, pepl, rb, mass, Gmass, lmask) +#else do concurrent(j = i+1:npl, lmask(i) .and. lmask(j)) +#endif pepl(j) = - (Gmass(i) * mass(j)) / norm2(rb(:, i) - rb(:, j)) end do pe = pe + sum(pepl(i+1:npl), lmask(i+1:npl)) @@ -1708,10 +1538,10 @@ module subroutine swiftest_util_index_map_storage(self) call swiftest_util_get_vals_storage(self, idvals, tvals) - call swiftest_util_unique(idvals,self%idvals,self%idmap) + call util_unique(idvals,self%idvals,self%idmap) self%nid = size(self%idvals) - call swiftest_util_unique(tvals,self%tvals,self%tmap) + call util_unique(tvals,self%tvals,self%tmap) self%nt = size(self%tvals) return @@ -1753,7 +1583,7 @@ module subroutine swiftest_util_peri(n,m, r, v, atp, q, isperi) real(DP), dimension(n) :: e !! Temporary, just to make use of the xv2aeq subroutine real(DP) :: vdotr - do concurrent(i = 1:n) + do i = 1,n vdotr = dot_product(r(:,i),v(:,i)) if (isperi(i) == -1) then if (vdotr >= 0.0) then @@ -1817,7 +1647,8 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals class(swiftest_pl), allocatable :: tmp !! The discarded body list. - integer(I4B) :: i, k, npl, nadd, nencmin, nenc_old, idnew1, idnew2, idold1, idold2 + integer(I4B) :: i, npl, nadd, idnew1, idnew2, idold1, idold2 + integer(I8B) :: k, nenc_old, nencmin logical, dimension(:), allocatable :: lmask class(encounter_list), allocatable :: plplenc_old logical :: lencounter @@ -1850,7 +1681,10 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) npl = pl%nbody end if - if (npl == 0) return + if (npl == 0) then + if (param%lmtiny_pl) pl%nplm = 0 + return + end if ! Reset all of the status flags for this body pl%status(1:npl) = ACTIVE @@ -1868,6 +1702,7 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) elsewhere pl%info(1:npl)%particle_type = PL_TYPE_NAME end where + pl%nplm = count(.not.pl%lmtiny(1:npl)) end if ! Reindex the new list of bodies @@ -1882,7 +1717,7 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) if (allocated(nbody_system%plpl_encounter)) then ! Store the original plplenc list so we don't remove any of the original encounters nenc_old = nbody_system%plpl_encounter%nenc - if (nenc_old > 0) then + if (nenc_old > 0_I8B) then allocate(plplenc_old, source=nbody_system%plpl_encounter) call plplenc_old%copy(nbody_system%plpl_encounter) end if @@ -1904,10 +1739,10 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) end select ! Re-index the encounter list as the index values may have changed - if (nenc_old > 0) then + if (nenc_old > 0_I8B) then nencmin = min(nbody_system%plpl_encounter%nenc, plplenc_old%nenc) nbody_system%plpl_encounter%nenc = nencmin - do k = 1, nencmin + do k = 1_I8B, nencmin idnew1 = nbody_system%plpl_encounter%id1(k) idnew2 = nbody_system%plpl_encounter%id2(k) idold1 = plplenc_old%id1(k) @@ -1948,7 +1783,7 @@ module subroutine swiftest_util_rearray_pl(self, nbody_system, param) end if nencmin = count(lmask(:)) nbody_system%plpl_encounter%nenc = nencmin - if (nencmin > 0) then + if (nencmin > 0_I8B) then nbody_system%plpl_encounter%index1(1:nencmin) = pack(nbody_system%plpl_encounter%index1(1:nenc_old), lmask(1:nenc_old)) nbody_system%plpl_encounter%index2(1:nencmin) = pack(nbody_system%plpl_encounter%index2(1:nenc_old), lmask(1:nenc_old)) nbody_system%plpl_encounter%id1(1:nencmin) = pack(nbody_system%plpl_encounter%id1(1:nenc_old), lmask(1:nenc_old)) @@ -2046,16 +1881,16 @@ module subroutine swiftest_util_reset_kinship_pl(self, idx) end subroutine swiftest_util_reset_kinship_pl - module subroutine swiftest_util_resize_arr_char_string(arr, nnew) + module subroutine swiftest_util_resize_arr_info(arr, nnew) !! author: David A. Minton !! - !! Resizes an array component of type character string. nnew = 0 will deallocate. + !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. Passing nnew = 0 will deallocate. implicit none ! Arguments - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size + type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Array to resize + integer(I4B), intent(in) :: nnew !! New size ! Internals - character(len=STRMAX), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + type(swiftest_particle_info), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated integer(I4B) :: nold !! Old size if (nnew < 0) return @@ -2074,34 +1909,29 @@ module subroutine swiftest_util_resize_arr_char_string(arr, nnew) if (nnew == nold) return allocate(tmp(nnew)) - if (nold > 0) then - if (nnew > nold) then - tmp(1:nold) = arr(1:nold) - tmp(nold+1:nnew) = "" - else - tmp(1:nnew) = arr(1:nnew) - end if + if (nnew > nold) then + call swiftest_util_copy_particle_info_arr(arr(1:nold), tmp(1:nold)) else - tmp(1:nnew) = "" + call swiftest_util_copy_particle_info_arr(arr(1:nnew), tmp(1:nnew)) end if + call move_alloc(tmp, arr) return - end subroutine swiftest_util_resize_arr_char_string - + end subroutine swiftest_util_resize_arr_info - module subroutine swiftest_util_resize_arr_DP(arr, nnew) + + module subroutine swiftest_util_resize_arr_kin(arr, nnew) !! author: David A. Minton !! - !! Resizes an array component of double precision type. Passing nnew = 0 will deallocate. + !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. Passing nnew = 0 will deallocate. implicit none ! Arguments - real(DP), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size + type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Array to resize + integer(I4B), intent(in) :: nnew !! New size ! Internals - real(DP), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated + type(swiftest_kinship), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated integer(I4B) :: nold !! Old size - real(DP), parameter :: init_val = 0.0_DP if (nnew < 0) return @@ -2116,324 +1946,98 @@ module subroutine swiftest_util_resize_arr_DP(arr, nnew) nold = 0 end if - if (nnew == nold) return - allocate(tmp(nnew)) - if (nold > 0) then - if (nnew > nold) then - tmp(1:nold) = arr(1:nold) - tmp(nold+1:nnew) = init_val - else - tmp(1:nnew) = arr(1:nnew) - end if + if (nnew > nold) then + tmp(1:nold) = arr(1:nold) else - tmp(1:nnew) = init_val + tmp(1:nnew) = arr(1:nnew) end if call move_alloc(tmp, arr) return - end subroutine swiftest_util_resize_arr_DP + end subroutine swiftest_util_resize_arr_kin - module subroutine swiftest_util_resize_arr_DPvec(arr, nnew) + module subroutine swiftest_util_resize_body(self, nnew) !! author: David A. Minton !! - !! Resizes an array component of double precision vectors of size (NDIM, n). Passing nnew = 0 will deallocate. + !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small. implicit none ! Arguments - real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - ! Internals - real(DP), dimension(:,:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated - integer(I4B) :: nold !! Old size - real(DP), dimension(NDIM), parameter :: init_val = 0.0_DP - integer(I4B) :: i + class(swiftest_body), intent(inout) :: self !! Swiftest body object + integer(I4B), intent(in) :: nnew !! New size neded - if (nnew < 0) return + call util_resize(self%info, nnew) + call util_resize(self%id, nnew) + call util_resize(self%status, nnew) + call util_resize(self%lcollision, nnew) + call util_resize(self%lencounter, nnew) + call util_resize(self%ldiscard, nnew) + call util_resize(self%lmask, nnew) + call util_resize(self%mu, nnew) + call util_resize(self%rh, nnew) + call util_resize(self%vh, nnew) + call util_resize(self%rb, nnew) + call util_resize(self%vb, nnew) + call util_resize(self%ah, nnew) + call util_resize(self%aobl, nnew) + call util_resize(self%atide, nnew) + call util_resize(self%agr, nnew) + call util_resize(self%ir3h, nnew) + call util_resize(self%a, nnew) + call util_resize(self%e, nnew) + call util_resize(self%inc, nnew) + call util_resize(self%capom, nnew) + call util_resize(self%omega, nnew) + call util_resize(self%capm, nnew) + self%nbody = count(self%status(1:nnew) /= INACTIVE) - if (nnew == 0) then - if (allocated(arr)) deallocate(arr) - return - end if - - if (allocated(arr)) then - nold = size(arr, dim=2) - else - nold = 0 - end if + return + end subroutine swiftest_util_resize_body - if (nnew == nold) return - - allocate(tmp(NDIM, nnew)) - if (nold > 0) then - if (nnew > nold) then - tmp(:,1:nold) = arr(:,1:nold) - do i = nold+1, nnew - tmp(:,i) = init_val(:) - end do - else - tmp(:,1:nnew) = arr(:,1:nnew) - end if - else - do i = 1, nnew - tmp(:, i) = init_val(:) - end do - end if - call move_alloc(tmp, arr) - return + module subroutine swiftest_util_resize_pl(self, nnew) + !! author: David A. Minton + !! + !! Checks the current size of a Swiftest massive body against the requested size and resizes it if it is too small. + implicit none + ! Arguments + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + integer(I4B), intent(in) :: nnew !! New size neded + + call swiftest_util_resize_body(self, nnew) + + call util_resize(self%mass, nnew) + call util_resize(self%Gmass, nnew) + call util_resize(self%rhill, nnew) + call util_resize(self%renc, nnew) + call util_resize(self%radius, nnew) + call util_resize(self%rbeg, nnew) + call util_resize(self%rend, nnew) + call util_resize(self%vbeg, nnew) + call util_resize(self%density, nnew) + call util_resize(self%Ip, nnew) + call util_resize(self%rot, nnew) + call util_resize(self%k2, nnew) + call util_resize(self%Q, nnew) + call util_resize(self%tlag, nnew) + call util_resize(self%kin, nnew) + call util_resize(self%lmtiny, nnew) + call util_resize(self%nplenc, nnew) + call util_resize(self%ntpenc, nnew) + + + + if (allocated(self%k_plpl)) deallocate(self%k_plpl) return - end subroutine swiftest_util_resize_arr_DPvec + end subroutine swiftest_util_resize_pl - module subroutine swiftest_util_resize_arr_I4B(arr, nnew) + module subroutine swiftest_util_resize_tp(self, nnew) !! author: David A. Minton !! - !! Resizes an array component of integer type. Passing nnew = 0 will deallocate. - implicit none - ! Arguments - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - ! Internals - integer(I4B), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated - integer(I4B) :: nold !! Old size - integer(I4B), parameter :: init_val = -1 - - if (nnew < 0) return - - if (nnew == 0) then - if (allocated(arr)) deallocate(arr) - return - end if - - if (allocated(arr)) then - nold = size(arr) - else - nold = 0 - end if - - if (nnew == nold) return - - allocate(tmp(nnew)) - if (nold > 0) then - if (nnew > nold) then - tmp(1:nold) = arr(1:nold) - tmp(nold+1:nnew) = init_val - else - tmp(1:nnew) = arr(1:nnew) - end if - else - tmp(1:nnew) = init_val - end if - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_resize_arr_I4B - - - module subroutine swiftest_util_resize_arr_info(arr, nnew) - !! author: David A. Minton - !! - !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. Passing nnew = 0 will deallocate. - implicit none - ! Arguments - type(swiftest_particle_info), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - ! Internals - type(swiftest_particle_info), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated - integer(I4B) :: nold !! Old size - - if (nnew < 0) return - - if (nnew == 0) then - if (allocated(arr)) deallocate(arr) - return - end if - - if (allocated(arr)) then - nold = size(arr) - else - nold = 0 - end if - - if (nnew == nold) return - - allocate(tmp(nnew)) - if (nnew > nold) then - call swiftest_util_copy_particle_info_arr(arr(1:nold), tmp(1:nold)) - else - call swiftest_util_copy_particle_info_arr(arr(1:nnew), tmp(1:nnew)) - end if - - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_resize_arr_info - - - module subroutine swiftest_util_resize_arr_kin(arr, nnew) - !! author: David A. Minton - !! - !! Resizes an array component of type character string. Array will only be resized if has previously been allocated. Passing nnew = 0 will deallocate. - implicit none - ! Arguments - type(swiftest_kinship), dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - ! Internals - type(swiftest_kinship), dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated - integer(I4B) :: nold !! Old size - - if (nnew < 0) return - - if (nnew == 0) then - if (allocated(arr)) deallocate(arr) - return - end if - - if (allocated(arr)) then - nold = size(arr) - else - nold = 0 - end if - - allocate(tmp(nnew)) - if (nnew > nold) then - tmp(1:nold) = arr(1:nold) - else - tmp(1:nnew) = arr(1:nnew) - end if - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_resize_arr_kin - - - module subroutine swiftest_util_resize_arr_logical(arr, nnew) - !! author: David A. Minton - !! - !! Resizes an array component of logical type. Passing nnew = 0 will deallocate. - implicit none - ! Arguments - logical, dimension(:), allocatable, intent(inout) :: arr !! Array to resize - integer(I4B), intent(in) :: nnew !! New size - ! Internals - logical, dimension(:), allocatable :: tmp !! Temporary storage array in case the input array is already allocated - integer(I4B) :: nold !! Old size - logical, parameter :: init_val = .false. - - if (nnew < 0) return - - if (nnew == 0) then - if (allocated(arr)) deallocate(arr) - return - end if - - if (allocated(arr)) then - nold = size(arr) - else - nold = 0 - end if - - if (nnew == nold) return - - allocate(tmp(nnew)) - if (nold > 0) then - if (nnew > nold) then - tmp(1:nold) = arr(1:nold) - tmp(nold+1:nnew) = init_val - else - tmp(1:nnew) = arr(1:nnew) - end if - else - tmp(1:nnew) = init_val - end if - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_resize_arr_logical - - - module subroutine swiftest_util_resize_body(self, nnew) - !! author: David A. Minton - !! - !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small. - implicit none - ! Arguments - class(swiftest_body), intent(inout) :: self !! Swiftest body object - integer(I4B), intent(in) :: nnew !! New size neded - - call swiftest_util_resize(self%info, nnew) - call swiftest_util_resize(self%id, nnew) - call swiftest_util_resize(self%status, nnew) - call swiftest_util_resize(self%lcollision, nnew) - call swiftest_util_resize(self%lencounter, nnew) - call swiftest_util_resize(self%ldiscard, nnew) - call swiftest_util_resize(self%lmask, nnew) - call swiftest_util_resize(self%mu, nnew) - call swiftest_util_resize(self%rh, nnew) - call swiftest_util_resize(self%vh, nnew) - call swiftest_util_resize(self%rb, nnew) - call swiftest_util_resize(self%vb, nnew) - call swiftest_util_resize(self%ah, nnew) - call swiftest_util_resize(self%aobl, nnew) - call swiftest_util_resize(self%atide, nnew) - call swiftest_util_resize(self%agr, nnew) - call swiftest_util_resize(self%ir3h, nnew) - call swiftest_util_resize(self%a, nnew) - call swiftest_util_resize(self%e, nnew) - call swiftest_util_resize(self%inc, nnew) - call swiftest_util_resize(self%capom, nnew) - call swiftest_util_resize(self%omega, nnew) - call swiftest_util_resize(self%capm, nnew) - self%nbody = count(self%status(1:nnew) /= INACTIVE) - - return - end subroutine swiftest_util_resize_body - - - module subroutine swiftest_util_resize_pl(self, nnew) - !! author: David A. Minton - !! - !! Checks the current size of a Swiftest massive body against the requested size and resizes it if it is too small. - implicit none - ! Arguments - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - integer(I4B), intent(in) :: nnew !! New size neded - - call swiftest_util_resize_body(self, nnew) - - call swiftest_util_resize(self%mass, nnew) - call swiftest_util_resize(self%Gmass, nnew) - call swiftest_util_resize(self%rhill, nnew) - call swiftest_util_resize(self%renc, nnew) - call swiftest_util_resize(self%radius, nnew) - call swiftest_util_resize(self%rbeg, nnew) - call swiftest_util_resize(self%rend, nnew) - call swiftest_util_resize(self%vbeg, nnew) - call swiftest_util_resize(self%density, nnew) - call swiftest_util_resize(self%Ip, nnew) - call swiftest_util_resize(self%rot, nnew) - call swiftest_util_resize(self%k2, nnew) - call swiftest_util_resize(self%Q, nnew) - call swiftest_util_resize(self%tlag, nnew) - call swiftest_util_resize(self%kin, nnew) - call swiftest_util_resize(self%lmtiny, nnew) - call swiftest_util_resize(self%nplenc, nnew) - call swiftest_util_resize(self%ntpenc, nnew) - - - - if (allocated(self%k_plpl)) deallocate(self%k_plpl) - - return - end subroutine swiftest_util_resize_pl - - - module subroutine swiftest_util_resize_tp(self, nnew) - !! author: David A. Minton - !! - !! Checks the current size of a Swiftest test particle against the requested size and resizes it if it is too small. + !! Checks the current size of a Swiftest test particle against the requested size and resizes it if it is too small. implicit none ! Arguments class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object @@ -2441,10 +2045,10 @@ module subroutine swiftest_util_resize_tp(self, nnew) call swiftest_util_resize_body(self, nnew) - call swiftest_util_resize(self%nplenc, nnew) - call swiftest_util_resize(self%isperi, nnew) - call swiftest_util_resize(self%peri, nnew) - call swiftest_util_resize(self%atp, nnew) + call util_resize(self%nplenc, nnew) + call util_resize(self%isperi, nnew) + call util_resize(self%peri, nnew) + call util_resize(self%atp, nnew) return end subroutine swiftest_util_resize_tp @@ -2695,8 +2299,8 @@ module subroutine swiftest_util_set_rhill_approximate(self,cb) return end subroutine swiftest_util_set_rhill_approximate - module subroutine swiftest_util_setup_construct_system(nbody_system, param) + !! author: David A. Minton !! !! Constructor for a Swiftest nbody system. Creates the nbody system object based on the user-input integrator @@ -2704,13 +2308,11 @@ module subroutine swiftest_util_setup_construct_system(nbody_system, param) implicit none ! Arguments class(swiftest_nbody_system), allocatable, intent(inout) :: nbody_system !! Swiftest nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters select case(param%integrator) case (INT_BS) write(*,*) 'Bulirsch-Stoer integrator not yet enabled' - case (INT_HELIO) - allocate(helio_nbody_system :: nbody_system) + case (INT_HELIO) select type(nbody_system) class is (helio_nbody_system) allocate(helio_cb :: nbody_system%cb) @@ -2769,10 +2371,8 @@ module subroutine swiftest_util_setup_construct_system(nbody_system, param) allocate(swiftest_particle_info :: nbody_system%cb%info) - nbody_system%t = param%tstart - return end subroutine swiftest_util_setup_construct_system @@ -2810,26 +2410,28 @@ module subroutine swiftest_util_setup_initialize_particle_info_system(self, para end subroutine swiftest_util_setup_initialize_particle_info_system - module subroutine swiftest_util_setup_initialize_system(self, param) + module subroutine swiftest_util_setup_initialize_system(self, system_history, param) !! author: David A. Minton !! !! Wrapper method to initialize a basic Swiftest nbody system from files !! implicit none ! Arguments - class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: self !! Swiftest nbody_system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - if (allocated(self%system_history)) then - call self%system_history%dealloc() - deallocate(self%system_history) + ! Internals + if (allocated(system_history)) then + call system_history%dealloc() + deallocate(system_history) end if - allocate(swiftest_storage :: self%system_history) - call self%system_history%setup(param%dump_cadence) - allocate(swiftest_netcdf_parameters :: self%system_history%nc) + allocate(swiftest_storage :: system_history) + call system_history%setup(param%dump_cadence) + allocate(swiftest_netcdf_parameters :: system_history%nc) - associate(nbody_system => self, cb => self%cb, pl => self%pl, tp => self%tp, nc => self%system_history%nc) - call nbody_system%read_in(param) + associate(nbody_system => self, cb => self%cb, pl => self%pl, tp => self%tp, nc => system_history%nc) + call nbody_system%read_in(nc, param) call nbody_system%validate_ids(param) call nbody_system%set_msys() call pl%set_mu(cb) @@ -2849,7 +2451,7 @@ module subroutine swiftest_util_setup_initialize_system(self, param) ! Write initial conditions to file nc%file_name = param%outfile - call nbody_system%write_frame(param) + call nbody_system%initialize_output_file(nc, param) call nc%close() end associate @@ -2892,7 +2494,6 @@ module subroutine swiftest_util_setup_body(self, n, param) allocate(self%vb(NDIM, n)) allocate(self%ah(NDIM, n)) allocate(self%ir3h(n)) - allocate(self%aobl(NDIM, n)) allocate(self%isperi(n)) allocate(self%peri(n)) allocate(self%atp(n)) @@ -2931,11 +2532,14 @@ module subroutine swiftest_util_setup_body(self, n, param) self%vb(:,:) = 0.0_DP self%ah(:,:) = 0.0_DP self%ir3h(:) = 0.0_DP - self%aobl(:,:) = 0.0_DP self%isperi(:) = 1 self%peri(:) = 0.0_DP self%atp(:) = 0.0_DP + if (param%loblatecb) then + allocate(self%aobl(NDIM, n)) + self%aobl(:,:) = 0.0_DP + end if if (param%ltides) then allocate(self%atide(NDIM, n)) self%atide(:,:) = 0.0_DP @@ -3049,11 +2653,11 @@ module subroutine swiftest_util_snapshot_system(self, param, nbody_system, t, ar !! Takes a snapshot of the nbody_system for later file storage implicit none ! Arguments - class(swiftest_storage), intent(inout) :: self !! Swiftest storage object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object to store - real(DP), intent(in), optional :: t !! Time of snapshot if different from nbody_system time - character(*), intent(in), optional :: arg !! Optional argument (needed for extended storage type used in collision snapshots) + class(swiftest_storage), intent(inout) :: self !! Swiftest storage object + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(swiftest_nbody_system), intent(inout) :: nbody_system !! Swiftest nbody system object to store + real(DP), intent(in), optional :: t !! Time of snapshot if different from nbody_system time + character(*), intent(in), optional :: arg !! Optional argument (needed for extended storage type used in collision snapshots) ! Internals class(swiftest_nbody_system), allocatable :: snapshot @@ -3073,16 +2677,13 @@ module subroutine swiftest_util_snapshot_system(self, param, nbody_system, t, ar end select end select - call nbody_system%pl%set_rhill(nbody_system%cb) + if (.not.param%lrhill_present) call nbody_system%pl%set_rhill(nbody_system%cb) ! Take a minimal snapshot wihout all of the extra storage objects allocate(snapshot, mold=nbody_system) allocate(snapshot%cb, source=nbody_system%cb ) allocate(snapshot%pl, source=nbody_system%pl ) allocate(snapshot%tp, source=nbody_system%tp ) - allocate(snapshot%system_history) - allocate(snapshot%system_history%nc, source=nbody_system%system_history%nc) - snapshot%system_history%nc%lfile_is_open = .true. snapshot%t = nbody_system%t snapshot%GMtot = nbody_system%GMtot @@ -3161,25 +2762,25 @@ module subroutine swiftest_util_sort_body(self, sortby, ascending) associate(body => self, n => self%nbody) select case(sortby) case("id") - call swiftest_util_sort(direction * body%id(1:n), ind) + call util_sort(direction * body%id(1:n), ind) case("status") - call swiftest_util_sort(direction * body%status(1:n), ind) + call util_sort(direction * body%status(1:n), ind) case("ir3h") - call swiftest_util_sort(direction * body%ir3h(1:n), ind) + call util_sort(direction * body%ir3h(1:n), ind) case("a") - call swiftest_util_sort(direction * body%a(1:n), ind) + call util_sort(direction * body%a(1:n), ind) case("e") - call swiftest_util_sort(direction * body%e(1:n), ind) + call util_sort(direction * body%e(1:n), ind) case("inc") - call swiftest_util_sort(direction * body%inc(1:n), ind) + call util_sort(direction * body%inc(1:n), ind) case("capom") - call swiftest_util_sort(direction * body%capom(1:n), ind) + call util_sort(direction * body%capom(1:n), ind) case("mu") - call swiftest_util_sort(direction * body%mu(1:n), ind) + call util_sort(direction * body%mu(1:n), ind) case("peri") - call swiftest_util_sort(direction * body%peri(1:n), ind) + call util_sort(direction * body%peri(1:n), ind) case("atp") - call swiftest_util_sort(direction * body%atp(1:n), ind) + call util_sort(direction * body%atp(1:n), ind) case("info", "lfirst", "nbody", "ldiscard", "lcollision", "lencounter", "rh", "vh", "rb", "vb", "ah", "aobl", "atide", "agr","isperi") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default @@ -3195,664 +2796,80 @@ module subroutine swiftest_util_sort_body(self, sortby, ascending) end subroutine swiftest_util_sort_body - pure module subroutine swiftest_util_sort_dp(arr) - !! author: David A. Minton - !! - !! Sort input DP precision array in place into ascending numerical order using quicksort. - !! - implicit none - ! Arguments - real(DP), dimension(:), intent(inout) :: arr - - call swiftest_util_sort_qsort_DP(arr) - - return - end subroutine swiftest_util_sort_dp - - - pure module subroutine swiftest_util_sort_index_dp(arr, ind) + module subroutine swiftest_util_sort_pl(self, sortby, ascending) !! author: David A. Minton !! - !! Sort input DP precision array by index in ascending numerical order using quick sort. - !! This algorithm works well for partially sorted arrays (which is usually the case here). - !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously - !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. - !! + !! Sort a Swiftest massive body object in-place. + !! sortby is a string indicating which array component to sort. implicit none ! Arguments - real(DP), dimension(:), intent(in) :: arr - integer(I4B), dimension(:), allocatable, intent(inout) :: ind + class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object + character(*), intent(in) :: sortby !! Sorting attribute + logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or descending order ! Internals - integer(I4B) :: n, i - real(DP), dimension(:), allocatable :: tmparr + integer(I4B), dimension(:), allocatable :: ind + integer(I4B) :: direction + + if (self%nbody == 0) return - n = size(arr) - if (.not.allocated(ind)) then - allocate(ind(n)) - ind = [(i, i=1, n)] + if (ascending) then + direction = 1 + else + direction = -1 end if - allocate(tmparr, mold=arr) - tmparr(:) = arr(ind(:)) - call swiftest_util_sort_qsort_DP(tmparr, ind) - - return - end subroutine swiftest_util_sort_index_dp + associate(pl => self, npl => self%nbody) + select case(sortby) + case("Gmass","mass") + call util_sort(direction * pl%Gmass(1:npl), ind) + case("rhill") + call util_sort(direction * pl%rhill(1:npl), ind) + case("renc") + call util_sort(direction * pl%renc(1:npl), ind) + case("radius") + call util_sort(direction * pl%radius(1:npl), ind) + case("density") + call util_sort(direction * pl%density(1:npl), ind) + case("k2") + call util_sort(direction * pl%k2(1:npl), ind) + case("Q") + call util_sort(direction * pl%Q(1:npl), ind) + case("tlag") + call util_sort(direction * pl%tlag(1:npl), ind) + case("nplenc") + call util_sort(direction * pl%nplenc(1:npl), ind) + case("ntpenc") + call util_sort(direction * pl%ntpenc(1:npl), ind) + case("lmtiny", "nplm", "nplplm", "kin", "rbeg", "rend", "vbeg", "Ip", "rot", "k_plpl", "nplpl") + write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' + case default ! Look for components in the parent class + call swiftest_util_sort_body(pl, sortby, ascending) + return + end select + + call pl%rearrange(ind) - recursive pure subroutine swiftest_util_sort_qsort_DP(arr, ind) - !! author: David A. Minton - !! - !! Sort input DP precision array by index in ascending numerical order using quicksort sort. - !! - implicit none - ! Arguments - real(DP), dimension(:), intent(inout) :: arr - integer(I4B),dimension(:),intent(out), optional :: ind - !! Internals - integer :: iq - - if (size(arr) > 1) then - if (present(ind)) then - call swiftest_util_sort_partition_DP(arr, iq, ind) - call swiftest_util_sort_qsort_DP(arr(:iq-1),ind(:iq-1)) - call swiftest_util_sort_qsort_DP(arr(iq:), ind(iq:)) - else - call swiftest_util_sort_partition_DP(arr, iq) - call swiftest_util_sort_qsort_DP(arr(:iq-1)) - call swiftest_util_sort_qsort_DP(arr(iq:)) - end if - end if + end associate return - end subroutine swiftest_util_sort_qsort_DP + end subroutine swiftest_util_sort_pl - - pure subroutine swiftest_util_sort_partition_DP(arr, marker, ind) + + module subroutine swiftest_util_sort_tp(self, sortby, ascending) !! author: David A. Minton !! - !! Partition function for quicksort on DP type - !! + !! Sort a Swiftest test particle object in-place. + !! sortby is a string indicating which array component to sort. implicit none ! Arguments - real(DP), intent(inout), dimension(:) :: arr - integer(I4B), intent(inout), dimension(:), optional :: ind - integer(I4B), intent(out) :: marker + class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object + character(*), intent(in) :: sortby !! Sorting attribute + logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or descending order ! Internals - integer(I4B) :: i, j, itmp, narr, ipiv - real(DP) :: temp - real(DP) :: x ! pivot point + integer(I4B), dimension(:), allocatable :: ind + integer(I4B) :: direction - narr = size(arr) - - ! Get center as pivot, as this is likely partially sorted - ipiv = narr / 2 - x = arr(ipiv) - i = 0 - j = narr + 1 - - do - j = j - 1 - do - if (arr(j) <= x) exit - j = j - 1 - end do - i = i + 1 - do - if (arr(i) >= x) exit - i = i + 1 - end do - if (i < j) then - ! exchange A(i) and A(j) - temp = arr(i) - arr(i) = arr(j) - arr(j) = temp - if (present(ind)) then - itmp = ind(i) - ind(i) = ind(j) - ind(j) = itmp - end if - else if (i == j) then - marker = i + 1 - return - else - marker = i - return - endif - end do - - return - end subroutine swiftest_util_sort_partition_DP - - - pure module subroutine swiftest_util_sort_i4b(arr) - !! author: David A. Minton - !! - !! Sort input integer array in place into ascending numerical order using quick sort. - !! This algorithm works well for partially sorted arrays (which is usually the case here) - !! - implicit none - ! Arguments - integer(I4B), dimension(:), intent(inout) :: arr - - call swiftest_util_sort_qsort_I4B(arr) - - return - end subroutine swiftest_util_sort_i4b - - - pure module subroutine swiftest_util_sort_index_I4B(arr, ind) - !! author: David A. Minton - !! - !! Sort input integer array by index in ascending numerical order using quicksort. - !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously - !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. - !! - implicit none - ! Arguments - integer(I4B), dimension(:), intent(in) :: arr - integer(I4B), dimension(:), allocatable, intent(inout) :: ind - ! Internals - integer(I4B) :: n, i - integer(I4B), dimension(:), allocatable :: tmparr - - n = size(arr) - if (.not.allocated(ind)) then - allocate(ind(n)) - ind = [(i, i=1, n)] - end if - allocate(tmparr, mold=arr) - tmparr(:) = arr(ind(:)) - call swiftest_util_sort_qsort_I4B(tmparr, ind) - - return - end subroutine swiftest_util_sort_index_I4B - - - pure module subroutine swiftest_util_sort_index_I4B_I8Bind(arr, ind) - !! author: David A. Minton - !! - !! Sort input integer array by index in ascending numerical order using quicksort. - !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously - !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. - !! - implicit none - ! Arguments - integer(I4B), dimension(:), intent(in) :: arr - integer(I8B), dimension(:), allocatable, intent(inout) :: ind - ! Internals - integer(I8B) :: n, i - integer(I4B), dimension(:), allocatable :: tmparr - - n = size(arr) - if (.not.allocated(ind)) then - allocate(ind(n)) - ind = [(i, i=1_I8B, n)] - end if - allocate(tmparr, mold=arr) - tmparr(:) = arr(ind(:)) - call swiftest_util_sort_qsort_I4B_I8Bind(tmparr, ind) - - return - end subroutine swiftest_util_sort_index_I4B_I8Bind - - - recursive pure subroutine swiftest_util_sort_qsort_I4B(arr, ind) - !! author: David A. Minton - !! - !! Sort input I4B array by index in ascending numerical order using quicksort. - !! - implicit none - ! Arguments - integer(I4B), dimension(:), intent(inout) :: arr - integer(I4B), dimension(:), intent(out), optional :: ind - ! Internals - integer(I4B) :: iq - - if (size(arr) > 1) then - if (present(ind)) then - call swiftest_util_sort_partition_I4B(arr, iq, ind) - call swiftest_util_sort_qsort_I4B(arr(:iq-1),ind(:iq-1)) - call swiftest_util_sort_qsort_I4B(arr(iq:), ind(iq:)) - else - call swiftest_util_sort_partition_I4B(arr, iq) - call swiftest_util_sort_qsort_I4B(arr(:iq-1)) - call swiftest_util_sort_qsort_I4B(arr(iq:)) - end if - end if - - return - end subroutine swiftest_util_sort_qsort_I4B - - - recursive pure subroutine swiftest_util_sort_qsort_I4B_I8Bind(arr, ind) - !! author: David A. Minton - !! - !! Sort input I4B array by index in ascending numerical order using quicksort. - !! - implicit none - ! Arguments - integer(I4B), dimension(:), intent(inout) :: arr - integer(I8B), dimension(:), intent(out), optional :: ind - ! Internals - integer(I8B) :: iq - - if (size(arr) > 1_I8B) then - if (present(ind)) then - call swiftest_util_sort_partition_I4B_I8Bind(arr, iq, ind) - call swiftest_util_sort_qsort_I4B_I8Bind(arr(:iq-1_I8B),ind(:iq-1_I8B)) - call swiftest_util_sort_qsort_I4B_I8Bind(arr(iq:), ind(iq:)) - else - call swiftest_util_sort_partition_I4B_I8Bind(arr, iq) - call swiftest_util_sort_qsort_I4B_I8Bind(arr(:iq-1_I8B)) - call swiftest_util_sort_qsort_I4B_I8Bind(arr(iq:)) - end if - end if - - return - end subroutine swiftest_util_sort_qsort_I4B_I8Bind - - - recursive pure subroutine swiftest_util_sort_qsort_I8B_I8Bind(arr, ind) - !! author: David A. Minton - !! - !! Sort input I8B array by index in ascending numerical order using quicksort. - !! - implicit none - ! Arguments - integer(I8B), dimension(:), intent(inout) :: arr - integer(I8B), dimension(:), intent(out), optional :: ind - ! Internals - integer(I8B) :: iq - - if (size(arr) > 1_I8B) then - if (present(ind)) then - call swiftest_util_sort_partition_I8B_I8Bind(arr, iq, ind) - call swiftest_util_sort_qsort_I8B_I8Bind(arr(:iq-1_I8B),ind(:iq-1_I8B)) - call swiftest_util_sort_qsort_I8B_I8Bind(arr(iq:), ind(iq:)) - else - call swiftest_util_sort_partition_I8B_I8Bind(arr, iq) - call swiftest_util_sort_qsort_I8B_I8Bind(arr(:iq-1_I8B)) - call swiftest_util_sort_qsort_I8B_I8Bind(arr(iq:)) - end if - end if - - return - end subroutine swiftest_util_sort_qsort_I8B_I8Bind - - - pure subroutine swiftest_util_sort_partition_I4B(arr, marker, ind) - !! author: David A. Minton - !! - !! Partition function for quicksort on I4B type - !! - implicit none - ! Arguments - integer(I4B), intent(inout), dimension(:) :: arr - integer(I4B), intent(inout), dimension(:), optional :: ind - integer(I4B), intent(out) :: marker - ! Internals - integer(I4B) :: i, j, itmp, narr, ipiv - integer(I4B) :: temp - integer(I4B) :: x ! pivot point - - narr = size(arr) - - ! Get center as pivot, as this is likely partially sorted - ipiv = narr / 2 - x = arr(ipiv) - i = 0 - j = narr + 1 - - do - j = j - 1 - do - if (arr(j) <= x) exit - j = j - 1 - end do - i = i + 1 - do - if (arr(i) >= x) exit - i = i + 1 - end do - if (i < j) then - ! exchange A(i) and A(j) - temp = arr(i) - arr(i) = arr(j) - arr(j) = temp - if (present(ind)) then - itmp = ind(i) - ind(i) = ind(j) - ind(j) = itmp - end if - else if (i == j) then - marker = i + 1 - return - else - marker = i - return - endif - end do - - return - end subroutine swiftest_util_sort_partition_I4B - - - pure subroutine swiftest_util_sort_partition_I4B_I8Bind(arr, marker, ind) - !! author: David A. Minton - !! - !! Partition function for quicksort on I4B type - !! - implicit none - ! Arguments - integer(I4B), intent(inout), dimension(:) :: arr - integer(I8B), intent(inout), dimension(:), optional :: ind - integer(I8B), intent(out) :: marker - ! Internals - integer(I8B) :: i, j, itmp, narr, ipiv - integer(I4B) :: temp - integer(I8B) :: x ! pivot point - - narr = size(arr) - - ! Get center as pivot, as this is likely partially sorted - ipiv = narr / 2_I8B - x = arr(ipiv) - i = 0_I8B - j = narr + 1_I8B - - do - j = j - 1_I8B - do - if (arr(j) <= x) exit - j = j - 1_I8B - end do - i = i + 1_I8B - do - if (arr(i) >= x) exit - i = i + 1_I8B - end do - if (i < j) then - ! exchange A(i) and A(j) - temp = arr(i) - arr(i) = arr(j) - arr(j) = temp - if (present(ind)) then - itmp = ind(i) - ind(i) = ind(j) - ind(j) = itmp - end if - else if (i == j) then - marker = i + 1_I8B - return - else - marker = i - return - endif - end do - - return - end subroutine swiftest_util_sort_partition_I4B_I8Bind - - - pure subroutine swiftest_util_sort_partition_I8B_I8Bind(arr, marker, ind) - !! author: David A. Minton - !! - !! Partition function for quicksort on I8B type with I8B index - !! - implicit none - ! Arguments - integer(I8B), intent(inout), dimension(:) :: arr - integer(I8B), intent(inout), dimension(:), optional :: ind - integer(I8B), intent(out) :: marker - ! Internals - integer(I8B) :: i, j, itmp, narr, ipiv - integer(I8B) :: temp - integer(I8B) :: x ! pivot point - - narr = size(arr) - - ! Get center as pivot, as this is likely partially sorted - ipiv = narr / 2_I8B - x = arr(ipiv) - i = 0_I8B - j = narr + 1_I8B - - do - j = j - 1_I8B - do - if (arr(j) <= x) exit - j = j - 1_I8B - end do - i = i + 1_I8B - do - if (arr(i) >= x) exit - i = i + 1_I8B - end do - if (i < j) then - ! exchange A(i) and A(j) - temp = arr(i) - arr(i) = arr(j) - arr(j) = temp - if (present(ind)) then - itmp = ind(i) - ind(i) = ind(j) - ind(j) = itmp - end if - else if (i == j) then - marker = i + 1_I8B - return - else - marker = i - return - endif - end do - - return - end subroutine swiftest_util_sort_partition_I8B_I8Bind - - - pure module subroutine swiftest_util_sort_sp(arr) - !! author: David A. Minton - !! - !! Sort input DP precision array in place into ascending numerical order using quicksort. - !! - implicit none - ! Arguments - real(SP), dimension(:), intent(inout) :: arr - - call swiftest_util_sort_qsort_SP(arr) - - return - end subroutine swiftest_util_sort_sp - - - pure module subroutine swiftest_util_sort_index_sp(arr, ind) - !! author: David A. Minton - !! - !! Sort input DP precision array by index in ascending numerical order using quicksort. - !! If ind is supplied already allocated, we assume it is an existing index array (e.g. a previously - !! sorted array). If it is not allocated, this subroutine swiftest_allocates it. - !! - implicit none - ! Arguments - real(SP), dimension(:), intent(in) :: arr - integer(I4B), dimension(:), allocatable, intent(inout) :: ind - ! Internals - integer(I4B) :: n, i - real(SP), dimension(:), allocatable :: tmparr - - n = size(arr) - if (.not.allocated(ind)) then - allocate(ind(n)) - ind = [(i, i=1, n)] - end if - allocate(tmparr, mold=arr) - tmparr(:) = arr(ind(:)) - call swiftest_util_sort_qsort_SP(tmparr, ind) - - return - end subroutine swiftest_util_sort_index_sp - - - recursive pure subroutine swiftest_util_sort_qsort_SP(arr, ind) - !! author: David A. Minton - !! - !! Sort input DP precision array by index in ascending numerical order using quicksort. - !! - implicit none - ! Arguments - real(SP), dimension(:), intent(inout) :: arr - integer(I4B),dimension(:),intent(out), optional :: ind - !! Internals - integer :: iq - - if (size(arr) > 1) then - if (present(ind)) then - call swiftest_util_sort_partition_SP(arr, iq, ind) - call swiftest_util_sort_qsort_SP(arr(:iq-1),ind(:iq-1)) - call swiftest_util_sort_qsort_SP(arr(iq:), ind(iq:)) - else - call swiftest_util_sort_partition_SP(arr, iq) - call swiftest_util_sort_qsort_SP(arr(:iq-1)) - call swiftest_util_sort_qsort_SP(arr(iq:)) - end if - end if - - return - end subroutine swiftest_util_sort_qsort_SP - - - pure subroutine swiftest_util_sort_partition_SP(arr, marker, ind) - !! author: David A. Minton - !! - !! Partition function for quicksort on SP type - !! - implicit none - ! Arguments - real(SP), intent(inout), dimension(:) :: arr - integer(I4B), intent(inout), dimension(:), optional :: ind - integer(I4B), intent(out) :: marker - ! Internals - integer(I4B) :: i, j, itmp, narr, ipiv - real(SP) :: temp - real(SP) :: x ! pivot point - - narr = size(arr) - - ! Get center as pivot, as this is likely partially sorted - ipiv = narr / 2 - x = arr(ipiv) - i = 0 - j = narr + 1 - - do - j = j - 1 - do - if (arr(j) <= x) exit - j = j - 1 - end do - i = i + 1 - do - if (arr(i) >= x) exit - i = i + 1 - end do - if (i < j) then - ! exchange A(i) and A(j) - temp = arr(i) - arr(i) = arr(j) - arr(j) = temp - if (present(ind)) then - itmp = ind(i) - ind(i) = ind(j) - ind(j) = itmp - end if - else if (i == j) then - marker = i + 1 - return - else - marker = i - return - endif - end do - - return - end subroutine swiftest_util_sort_partition_SP - - - module subroutine swiftest_util_sort_pl(self, sortby, ascending) - !! author: David A. Minton - !! - !! Sort a Swiftest massive body object in-place. - !! sortby is a string indicating which array component to sort. - implicit none - ! Arguments - class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object - character(*), intent(in) :: sortby !! Sorting attribute - logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or descending order - ! Internals - integer(I4B), dimension(:), allocatable :: ind - integer(I4B) :: direction - - if (self%nbody == 0) return - - if (ascending) then - direction = 1 - else - direction = -1 - end if - - associate(pl => self, npl => self%nbody) - select case(sortby) - case("Gmass","mass") - call swiftest_util_sort(direction * pl%Gmass(1:npl), ind) - case("rhill") - call swiftest_util_sort(direction * pl%rhill(1:npl), ind) - case("renc") - call swiftest_util_sort(direction * pl%renc(1:npl), ind) - case("radius") - call swiftest_util_sort(direction * pl%radius(1:npl), ind) - case("density") - call swiftest_util_sort(direction * pl%density(1:npl), ind) - case("k2") - call swiftest_util_sort(direction * pl%k2(1:npl), ind) - case("Q") - call swiftest_util_sort(direction * pl%Q(1:npl), ind) - case("tlag") - call swiftest_util_sort(direction * pl%tlag(1:npl), ind) - case("nplenc") - call swiftest_util_sort(direction * pl%nplenc(1:npl), ind) - case("ntpenc") - call swiftest_util_sort(direction * pl%ntpenc(1:npl), ind) - case("lmtiny", "nplm", "nplplm", "kin", "rbeg", "rend", "vbeg", "Ip", "rot", "k_plpl", "nplpl") - write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' - case default ! Look for components in the parent class - call swiftest_util_sort_body(pl, sortby, ascending) - return - end select - - call pl%rearrange(ind) - - end associate - - return - end subroutine swiftest_util_sort_pl - - - module subroutine swiftest_util_sort_tp(self, sortby, ascending) - !! author: David A. Minton - !! - !! Sort a Swiftest test particle object in-place. - !! sortby is a string indicating which array component to sort. - implicit none - ! Arguments - class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object - character(*), intent(in) :: sortby !! Sorting attribute - logical, intent(in) :: ascending !! Logical flag indicating whether or not the sorting should be in ascending or descending order - ! Internals - integer(I4B), dimension(:), allocatable :: ind - integer(I4B) :: direction - - if (self%nbody == 0) return + if (self%nbody == 0) return if (ascending) then direction = 1 @@ -3863,7 +2880,7 @@ module subroutine swiftest_util_sort_tp(self, sortby, ascending) associate(tp => self, ntp => self%nbody) select case(sortby) case("nplenc") - call swiftest_util_sort(direction * tp%nplenc(1:ntp), ind) + call util_sort(direction * tp%nplenc(1:ntp), ind) case default ! Look for components in the parent class call swiftest_util_sort_body(tp, sortby, ascending) return @@ -3881,147 +2898,43 @@ module subroutine swiftest_util_sort_rearrange_body(self, ind) !! author: David A. Minton !! !! Rearrange Swiftest body structure in-place from an index list. - !! This is a helper utility used to make polymorphic sorting work on Swiftest structures. - implicit none - ! Arguments - class(swiftest_body), intent(inout) :: self !! Swiftest body object - integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) - - associate(n => self%nbody) - call swiftest_util_sort_rearrange(self%id, ind, n) - call swiftest_util_sort_rearrange(self%lmask, ind, n) - call swiftest_util_sort_rearrange(self%info, ind, n) - call swiftest_util_sort_rearrange(self%status, ind, n) - call swiftest_util_sort_rearrange(self%ldiscard, ind, n) - call swiftest_util_sort_rearrange(self%lcollision, ind, n) - call swiftest_util_sort_rearrange(self%lencounter, ind, n) - call swiftest_util_sort_rearrange(self%rh, ind, n) - call swiftest_util_sort_rearrange(self%vh, ind, n) - call swiftest_util_sort_rearrange(self%rb, ind, n) - call swiftest_util_sort_rearrange(self%vb, ind, n) - call swiftest_util_sort_rearrange(self%ah, ind, n) - call swiftest_util_sort_rearrange(self%aobl, ind, n) - call swiftest_util_sort_rearrange(self%agr, ind, n) - call swiftest_util_sort_rearrange(self%atide, ind, n) - call swiftest_util_sort_rearrange(self%ir3h, ind, n) - call swiftest_util_sort_rearrange(self%isperi, ind, n) - call swiftest_util_sort_rearrange(self%peri, ind, n) - call swiftest_util_sort_rearrange(self%atp, ind, n) - call swiftest_util_sort_rearrange(self%mu, ind, n) - call swiftest_util_sort_rearrange(self%a, ind, n) - call swiftest_util_sort_rearrange(self%e, ind, n) - call swiftest_util_sort_rearrange(self%inc, ind, n) - call swiftest_util_sort_rearrange(self%capom, ind, n) - call swiftest_util_sort_rearrange(self%omega, ind, n) - call swiftest_util_sort_rearrange(self%capm, ind, n) - end associate - - return - end subroutine swiftest_util_sort_rearrange_body - - - pure module subroutine swiftest_util_sort_rearrange_arr_char_string(arr, ind, n) - !! author: David A. Minton - !! - !! Rearrange a single array of character string in-place from an index list. - implicit none - ! Arguments - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - ! Internals - character(len=STRMAX), dimension(:), allocatable :: tmp !! Temporary copy of arry used during rearrange operation - - if (.not. allocated(arr) .or. n <= 0) return - allocate(tmp, mold=arr) - tmp(1:n) = arr(ind) - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_sort_rearrange_arr_char_string - - - pure module subroutine swiftest_util_sort_rearrange_arr_DP(arr, ind, n) - !! author: David A. Minton - !! - !! Rearrange a single array of DP type in-place from an index list. - implicit none - ! Arguments - real(DP), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - ! Internals - real(DP), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation - - if (.not. allocated(arr) .or. n <= 0) return - allocate(tmp, mold=arr) - tmp(1:n) = arr(ind) - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_sort_rearrange_arr_DP - - - pure module subroutine swiftest_util_sort_rearrange_arr_DPvec(arr, ind, n) - !! author: David A. Minton - !! - !! Rearrange a single array of (NDIM,n) DP-type vectors in-place from an index list. - implicit none - ! Arguments - real(DP), dimension(:,:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - ! Internals - real(DP), dimension(:,:), allocatable :: tmp !! Temporary copy of array used during rearrange operation - - if (.not. allocated(arr) .or. n <= 0) return - allocate(tmp, mold=arr) - tmp(:,1:n) = arr(:, ind) - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_sort_rearrange_arr_DPvec - - - pure module subroutine swiftest_util_sort_rearrange_arr_I4B(arr, ind, n) - !! author: David A. Minton - !! - !! Rearrange a single array of integers in-place from an index list. - implicit none - ! Arguments - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - ! Internals - integer(I4B), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation - - if (.not. allocated(arr) .or. n <= 0) return - allocate(tmp, mold=arr) - tmp(1:n) = arr(ind) - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_sort_rearrange_arr_I4B - - pure module subroutine swiftest_util_sort_rearrange_arr_I4B_I8Bind(arr, ind, n) - !! author: David A. Minton - !! - !! Rearrange a single array of integers in-place from an index list. + !! This is a helper utility used to make polymorphic sorting work on Swiftest structures. implicit none ! Arguments - integer(I4B), dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I8B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I8B), intent(in) :: n !! Number of elements in arr and ind to rearrange - ! Internals - integer(I4B), dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation + class(swiftest_body), intent(inout) :: self !! Swiftest body object + integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) - if (.not. allocated(arr) .or. n <= 0_I8B) return - allocate(tmp, mold=arr) - tmp(1:n) = arr(ind) - call move_alloc(tmp, arr) + associate(n => self%nbody) + call util_sort_rearrange(self%id, ind, n) + call util_sort_rearrange(self%lmask, ind, n) + call util_sort_rearrange(self%info, ind, n) + call util_sort_rearrange(self%status, ind, n) + call util_sort_rearrange(self%ldiscard, ind, n) + call util_sort_rearrange(self%lcollision, ind, n) + call util_sort_rearrange(self%lencounter, ind, n) + call util_sort_rearrange(self%rh, ind, n) + call util_sort_rearrange(self%vh, ind, n) + call util_sort_rearrange(self%rb, ind, n) + call util_sort_rearrange(self%vb, ind, n) + call util_sort_rearrange(self%ah, ind, n) + call util_sort_rearrange(self%aobl, ind, n) + call util_sort_rearrange(self%agr, ind, n) + call util_sort_rearrange(self%atide, ind, n) + call util_sort_rearrange(self%ir3h, ind, n) + call util_sort_rearrange(self%isperi, ind, n) + call util_sort_rearrange(self%peri, ind, n) + call util_sort_rearrange(self%atp, ind, n) + call util_sort_rearrange(self%mu, ind, n) + call util_sort_rearrange(self%a, ind, n) + call util_sort_rearrange(self%e, ind, n) + call util_sort_rearrange(self%inc, ind, n) + call util_sort_rearrange(self%capom, ind, n) + call util_sort_rearrange(self%omega, ind, n) + call util_sort_rearrange(self%capm, ind, n) + end associate return - end subroutine swiftest_util_sort_rearrange_arr_I4B_I8Bind + end subroutine swiftest_util_sort_rearrange_body module subroutine swiftest_util_sort_rearrange_arr_info(arr, ind, n) @@ -4044,7 +2957,7 @@ module subroutine swiftest_util_sort_rearrange_arr_info(arr, ind, n) return end subroutine swiftest_util_sort_rearrange_arr_info - + pure module subroutine swiftest_util_sort_rearrange_arr_kin(arr, ind, n) !! author: David A. Minton @@ -4074,48 +2987,6 @@ pure module subroutine swiftest_util_sort_rearrange_arr_kin(arr, ind, n) end subroutine swiftest_util_sort_rearrange_arr_kin - pure module subroutine swiftest_util_sort_rearrange_arr_logical(arr, ind, n) - !! author: David A. Minton - !! - !! Rearrange a single array of logicals in-place from an index list. - implicit none - ! Arguments - logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I4B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I4B), intent(in) :: n !! Number of elements in arr and ind to rearrange - ! Internals - logical, dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation - - if (.not. allocated(arr) .or. n <= 0) return - allocate(tmp, mold=arr) - tmp(1:n) = arr(ind) - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_sort_rearrange_arr_logical - - - pure module subroutine swiftest_util_sort_rearrange_arr_logical_I8Bind(arr, ind, n) - !! author: David A. Minton - !! - !! Rearrange a single array of logicals in-place from an index list. - implicit none - ! Arguments - logical, dimension(:), allocatable, intent(inout) :: arr !! Destination array - integer(I8B), dimension(:), intent(in) :: ind !! Index to rearrange against - integer(I8B), intent(in) :: n !! Number of elements in arr and ind to rearrange - ! Internals - logical, dimension(:), allocatable :: tmp !! Temporary copy of array used during rearrange operation - - if (.not. allocated(arr) .or. n <= 0) return - allocate(tmp, mold=arr) - tmp(1:n) = arr(ind) - call move_alloc(tmp, arr) - - return - end subroutine swiftest_util_sort_rearrange_arr_logical_I8Bind - - module subroutine swiftest_util_sort_rearrange_pl(self, ind) !! author: David A. Minton !! @@ -4126,23 +2997,23 @@ module subroutine swiftest_util_sort_rearrange_pl(self, ind) integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) associate(pl => self, npl => self%nbody) - call swiftest_util_sort_rearrange(pl%mass, ind, npl) - call swiftest_util_sort_rearrange(pl%Gmass, ind, npl) - call swiftest_util_sort_rearrange(pl%rhill, ind, npl) - call swiftest_util_sort_rearrange(pl%renc, ind, npl) - call swiftest_util_sort_rearrange(pl%radius, ind, npl) - call swiftest_util_sort_rearrange(pl%density, ind, npl) - call swiftest_util_sort_rearrange(pl%rbeg, ind, npl) - call swiftest_util_sort_rearrange(pl%vbeg, ind, npl) - call swiftest_util_sort_rearrange(pl%Ip, ind, npl) - call swiftest_util_sort_rearrange(pl%rot, ind, npl) - call swiftest_util_sort_rearrange(pl%k2, ind, npl) - call swiftest_util_sort_rearrange(pl%Q, ind, npl) - call swiftest_util_sort_rearrange(pl%tlag, ind, npl) - call swiftest_util_sort_rearrange(pl%kin, ind, npl) - call swiftest_util_sort_rearrange(pl%lmtiny, ind, npl) - call swiftest_util_sort_rearrange(pl%nplenc, ind, npl) - call swiftest_util_sort_rearrange(pl%ntpenc, ind, npl) + call util_sort_rearrange(pl%mass, ind, npl) + call util_sort_rearrange(pl%Gmass, ind, npl) + call util_sort_rearrange(pl%rhill, ind, npl) + call util_sort_rearrange(pl%renc, ind, npl) + call util_sort_rearrange(pl%radius, ind, npl) + call util_sort_rearrange(pl%density, ind, npl) + call util_sort_rearrange(pl%rbeg, ind, npl) + call util_sort_rearrange(pl%vbeg, ind, npl) + call util_sort_rearrange(pl%Ip, ind, npl) + call util_sort_rearrange(pl%rot, ind, npl) + call util_sort_rearrange(pl%k2, ind, npl) + call util_sort_rearrange(pl%Q, ind, npl) + call util_sort_rearrange(pl%tlag, ind, npl) + call util_sort_rearrange(pl%kin, ind, npl) + call util_sort_rearrange(pl%lmtiny, ind, npl) + call util_sort_rearrange(pl%nplenc, ind, npl) + call util_sort_rearrange(pl%ntpenc, ind, npl) if (allocated(pl%k_plpl)) deallocate(pl%k_plpl) @@ -4164,7 +3035,7 @@ module subroutine swiftest_util_sort_rearrange_tp(self, ind) integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) associate(tp => self, ntp => self%nbody) - call swiftest_util_sort_rearrange(tp%nplenc, ind, ntp) + call util_sort_rearrange(tp%nplenc, ind, ntp) if (allocated(tp%k_pltp)) deallocate(tp%k_pltp) @@ -4175,220 +3046,6 @@ module subroutine swiftest_util_sort_rearrange_tp(self, ind) end subroutine swiftest_util_sort_rearrange_tp - module subroutine swiftest_util_spill_arr_char_string(keeps, discards, lspill_list, ldestructive) - !! author: David A. Minton - !! - !! Performs a spill operation on a single array of type character strings - !! This is the inverse of a spill operation - implicit none - ! Arguments - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - character(len=STRMAX), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - ! Internals - integer(I4B) :: nspill, nkeep, nlist - character(len=STRMAX), dimension(:), allocatable :: tmp !! Array of values to keep - - nkeep = count(.not.lspill_list(:)) - nspill = count(lspill_list(:)) - nlist = size(lspill_list(:)) - - if (.not.allocated(keeps) .or. nspill == 0) return - if (.not.allocated(discards)) then - allocate(discards(nspill)) - else if (size(discards) /= nspill) then - deallocate(discards) - allocate(discards(nspill)) - end if - - discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) - if (ldestructive) then - if (nkeep > 0) then - allocate(tmp(nkeep)) - tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) - call move_alloc(tmp, keeps) - else - deallocate(keeps) - end if - end if - - return - end subroutine swiftest_util_spill_arr_char_string - - - module subroutine swiftest_util_spill_arr_DP(keeps, discards, lspill_list, ldestructive) - !! author: David A. Minton - !! - !! Performs a spill operation on a single array of type DP - !! This is the inverse of a spill operation - implicit none - ! Arguments - real(DP), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discardss - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - ! Internals - integer(I4B) :: nspill, nkeep, nlist - real(DP), dimension(:), allocatable :: tmp !! Array of values to keep - - nkeep = count(.not.lspill_list(:)) - nspill = count(lspill_list(:)) - nlist = size(lspill_list(:)) - - if (.not.allocated(keeps) .or. nspill == 0) return - if (.not.allocated(discards)) then - allocate(discards(nspill)) - else if (size(discards) /= nspill) then - deallocate(discards) - allocate(discards(nspill)) - end if - - discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) - if (ldestructive) then - if (nkeep > 0) then - allocate(tmp(nkeep)) - tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) - call move_alloc(tmp, keeps) - else - deallocate(keeps) - end if - end if - - return - end subroutine swiftest_util_spill_arr_DP - - - module subroutine swiftest_util_spill_arr_DPvec(keeps, discards, lspill_list, ldestructive) - !! author: David A. Minton - !! - !! Performs a spill operation on a single array of DP vectors with shape (NDIM, n) - !! This is the inverse of a spill operation - implicit none - ! Arguments - real(DP), dimension(:,:), allocatable, intent(inout) :: keeps !! Array of values to keep - real(DP), dimension(:,:), allocatable, intent(inout) :: discards !! Array discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - ! Internals - integer(I4B) :: i, nspill, nkeep, nlist - real(DP), dimension(:,:), allocatable :: tmp !! Array of values to keep - - nkeep = count(.not.lspill_list(:)) - nspill = count(lspill_list(:)) - nlist = size(lspill_list(:)) - - if (.not.allocated(keeps) .or. nspill == 0) return - if (.not.allocated(discards)) then - allocate(discards(NDIM, nspill)) - else if (size(discards, dim=2) /= nspill) then - deallocate(discards) - allocate(discards(NDIM, nspill)) - end if - - do i = 1, NDIM - discards(i,:) = pack(keeps(i,1:nlist), lspill_list(1:nlist)) - end do - if (ldestructive) then - if (nkeep > 0) then - allocate(tmp(NDIM, nkeep)) - do i = 1, NDIM - tmp(i, :) = pack(keeps(i, 1:nlist), .not. lspill_list(1:nlist)) - end do - call move_alloc(tmp, keeps) - else - deallocate(keeps) - end if - end if - - return - end subroutine swiftest_util_spill_arr_DPvec - - - module subroutine swiftest_util_spill_arr_I4B(keeps, discards, lspill_list, ldestructive) - !! author: David A. Minton - !! - !! Performs a spill operation on a single array of type I4B - !! This is the inverse of a spill operation - implicit none - ! Arguments - integer(I4B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - integer(I4B), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - ! Internals - integer(I4B) :: nspill, nkeep, nlist - integer(I4B), dimension(:), allocatable :: tmp !! Array of values to keep - - nkeep = count(.not.lspill_list(:)) - nspill = count(lspill_list(:)) - nlist = size(lspill_list(:)) - - if (.not.allocated(keeps) .or. nspill == 0) return - if (.not.allocated(discards)) then - allocate(discards(nspill)) - else if (size(discards) /= nspill) then - deallocate(discards) - allocate(discards(nspill)) - end if - - discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) - if (ldestructive) then - if (nkeep > 0) then - allocate(tmp(nkeep)) - tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) - call move_alloc(tmp, keeps) - else - deallocate(keeps) - end if - end if - - return - end subroutine swiftest_util_spill_arr_I4B - - - module subroutine swiftest_util_spill_arr_I8B(keeps, discards, lspill_list, ldestructive) - !! author: David A. Minton - !! - !! Performs a spill operation on a single array of type I4B - !! This is the inverse of a spill operation - implicit none - ! Arguments - integer(I8B), dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - integer(I8B), dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or not - ! Internals - integer(I4B) :: nspill, nkeep, nlist - integer(I8B), dimension(:), allocatable :: tmp !! Array of values to keep - - nkeep = count(.not.lspill_list(:)) - nspill = count(lspill_list(:)) - nlist = size(lspill_list(:)) - - if (.not.allocated(keeps) .or. nspill == 0) return - if (.not.allocated(discards)) then - allocate(discards(nspill)) - else if (size(discards) /= nspill) then - deallocate(discards) - allocate(discards(nspill)) - end if - - discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) - if (ldestructive) then - if (nkeep > 0) then - allocate(tmp(nkeep)) - tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) - call move_alloc(tmp, keeps) - else - deallocate(keeps) - end if - end if - - return - end subroutine swiftest_util_spill_arr_I8B - - module subroutine swiftest_util_spill_arr_info(keeps, discards, lspill_list, ldestructive) !! author: David A. Minton !! @@ -4410,6 +3067,7 @@ module subroutine swiftest_util_spill_arr_info(keeps, discards, lspill_list, lde nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then @@ -4457,6 +3115,7 @@ module subroutine swiftest_util_spill_arr_kin(keeps, discards, lspill_list, ldes nlist = size(lspill_list(:)) if (.not.allocated(keeps) .or. nspill == 0) return + if (size(keeps) < nkeep) return if (.not.allocated(discards)) then allocate(discards(nspill)) else if (size(discards) /= nspill) then @@ -4479,48 +3138,6 @@ module subroutine swiftest_util_spill_arr_kin(keeps, discards, lspill_list, ldes end subroutine swiftest_util_spill_arr_kin - module subroutine swiftest_util_spill_arr_logical(keeps, discards, lspill_list, ldestructive) - !! author: David A. Minton - !! - !! Performs a spill operation on a single array of logicals - !! This is the inverse of a spill operation - implicit none - ! Arguments - logical, dimension(:), allocatable, intent(inout) :: keeps !! Array of values to keep - logical, dimension(:), allocatable, intent(inout) :: discards !! Array of discards - logical, dimension(:), intent(in) :: lspill_list !! Logical array of bodies to spill into the discards - logical, intent(in) :: ldestructive !! Logical flag indicating whether or not this operation should alter the keeps array or no - ! Internals - integer(I4B) :: nspill, nkeep, nlist - logical, dimension(:), allocatable :: tmp !! Array of values to keep - - nkeep = count(.not.lspill_list(:)) - nspill = count(lspill_list(:)) - nlist = size(lspill_list(:)) - - if (.not.allocated(keeps) .or. nspill == 0) return - if (.not.allocated(discards)) then - allocate(discards(nspill)) - else if (size(discards) /= nspill) then - deallocate(discards) - allocate(discards(nspill)) - end if - - discards(:) = pack(keeps(1:nlist), lspill_list(1:nlist)) - if (ldestructive) then - if (nkeep > 0) then - allocate(tmp(nkeep)) - tmp(:) = pack(keeps(1:nlist), .not. lspill_list(1:nlist)) - call move_alloc(tmp, keeps) - else - deallocate(keeps) - end if - end if - - return - end subroutine swiftest_util_spill_arr_logical - - module subroutine swiftest_util_spill_body(self, discards, lspill_list, ldestructive) !! author: David A. Minton !! @@ -4539,32 +3156,32 @@ module subroutine swiftest_util_spill_body(self, discards, lspill_list, ldestruc !> Spill all the common components associate(keeps => self) - call swiftest_util_spill(keeps%id, discards%id, lspill_list, ldestructive) - call swiftest_util_spill(keeps%info, discards%info, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lmask, discards%lmask, lspill_list, ldestructive) - call swiftest_util_spill(keeps%status, discards%status, lspill_list, ldestructive) - call swiftest_util_spill(keeps%ldiscard, discards%ldiscard, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lcollision, discards%lcollision, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lencounter, discards%lencounter, lspill_list, ldestructive) - call swiftest_util_spill(keeps%mu, discards%mu, lspill_list, ldestructive) - call swiftest_util_spill(keeps%rh, discards%rh, lspill_list, ldestructive) - call swiftest_util_spill(keeps%vh, discards%vh, lspill_list, ldestructive) - call swiftest_util_spill(keeps%rb, discards%rb, lspill_list, ldestructive) - call swiftest_util_spill(keeps%vb, discards%vb, lspill_list, ldestructive) - call swiftest_util_spill(keeps%ah, discards%ah, lspill_list, ldestructive) - call swiftest_util_spill(keeps%aobl, discards%aobl, lspill_list, ldestructive) - call swiftest_util_spill(keeps%agr, discards%agr, lspill_list, ldestructive) - call swiftest_util_spill(keeps%atide, discards%atide, lspill_list, ldestructive) - call swiftest_util_spill(keeps%ir3h, discards%ir3h, lspill_list, ldestructive) - call swiftest_util_spill(keeps%isperi, discards%isperi, lspill_list, ldestructive) - call swiftest_util_spill(keeps%peri, discards%peri, lspill_list, ldestructive) - call swiftest_util_spill(keeps%atp, discards%atp, lspill_list, ldestructive) - call swiftest_util_spill(keeps%a, discards%a, lspill_list, ldestructive) - call swiftest_util_spill(keeps%e, discards%e, lspill_list, ldestructive) - call swiftest_util_spill(keeps%inc, discards%inc, lspill_list, ldestructive) - call swiftest_util_spill(keeps%capom, discards%capom, lspill_list, ldestructive) - call swiftest_util_spill(keeps%omega, discards%omega, lspill_list, ldestructive) - call swiftest_util_spill(keeps%capm, discards%capm, lspill_list, ldestructive) + call util_spill(keeps%id, discards%id, lspill_list, ldestructive) + call util_spill(keeps%info, discards%info, lspill_list, ldestructive) + call util_spill(keeps%lmask, discards%lmask, lspill_list, ldestructive) + call util_spill(keeps%status, discards%status, lspill_list, ldestructive) + call util_spill(keeps%ldiscard, discards%ldiscard, lspill_list, ldestructive) + call util_spill(keeps%lcollision, discards%lcollision, lspill_list, ldestructive) + call util_spill(keeps%lencounter, discards%lencounter, lspill_list, ldestructive) + call util_spill(keeps%mu, discards%mu, lspill_list, ldestructive) + call util_spill(keeps%rh, discards%rh, lspill_list, ldestructive) + call util_spill(keeps%vh, discards%vh, lspill_list, ldestructive) + call util_spill(keeps%rb, discards%rb, lspill_list, ldestructive) + call util_spill(keeps%vb, discards%vb, lspill_list, ldestructive) + call util_spill(keeps%ah, discards%ah, lspill_list, ldestructive) + call util_spill(keeps%aobl, discards%aobl, lspill_list, ldestructive) + call util_spill(keeps%agr, discards%agr, lspill_list, ldestructive) + call util_spill(keeps%atide, discards%atide, lspill_list, ldestructive) + call util_spill(keeps%ir3h, discards%ir3h, lspill_list, ldestructive) + call util_spill(keeps%isperi, discards%isperi, lspill_list, ldestructive) + call util_spill(keeps%peri, discards%peri, lspill_list, ldestructive) + call util_spill(keeps%atp, discards%atp, lspill_list, ldestructive) + call util_spill(keeps%a, discards%a, lspill_list, ldestructive) + call util_spill(keeps%e, discards%e, lspill_list, ldestructive) + call util_spill(keeps%inc, discards%inc, lspill_list, ldestructive) + call util_spill(keeps%capom, discards%capom, lspill_list, ldestructive) + call util_spill(keeps%omega, discards%omega, lspill_list, ldestructive) + call util_spill(keeps%capm, discards%capm, lspill_list, ldestructive) nbody_old = keeps%nbody @@ -4594,24 +3211,24 @@ module subroutine swiftest_util_spill_pl(self, discards, lspill_list, ldestructi select type (discards) ! The standard requires us to select the type of both arguments in order to access all the components class is (swiftest_pl) !> Spill components specific to the massive body class - call swiftest_util_spill(keeps%mass, discards%mass, lspill_list, ldestructive) - call swiftest_util_spill(keeps%Gmass, discards%Gmass, lspill_list, ldestructive) - call swiftest_util_spill(keeps%rhill, discards%rhill, lspill_list, ldestructive) - call swiftest_util_spill(keeps%renc, discards%renc, lspill_list, ldestructive) - call swiftest_util_spill(keeps%radius, discards%radius, lspill_list, ldestructive) - call swiftest_util_spill(keeps%density, discards%density, lspill_list, ldestructive) - call swiftest_util_spill(keeps%rbeg, discards%rbeg, lspill_list, ldestructive) - call swiftest_util_spill(keeps%rend, discards%rend, lspill_list, ldestructive) - call swiftest_util_spill(keeps%vbeg, discards%vbeg, lspill_list, ldestructive) - call swiftest_util_spill(keeps%Ip, discards%Ip, lspill_list, ldestructive) - call swiftest_util_spill(keeps%rot, discards%rot, lspill_list, ldestructive) - call swiftest_util_spill(keeps%k2, discards%k2, lspill_list, ldestructive) - call swiftest_util_spill(keeps%Q, discards%Q, lspill_list, ldestructive) - call swiftest_util_spill(keeps%tlag, discards%tlag, lspill_list, ldestructive) - call swiftest_util_spill(keeps%kin, discards%kin, lspill_list, ldestructive) - call swiftest_util_spill(keeps%lmtiny, discards%lmtiny, lspill_list, ldestructive) - call swiftest_util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive) - call swiftest_util_spill(keeps%ntpenc, discards%ntpenc, lspill_list, ldestructive) + call util_spill(keeps%mass, discards%mass, lspill_list, ldestructive) + call util_spill(keeps%Gmass, discards%Gmass, lspill_list, ldestructive) + call util_spill(keeps%rhill, discards%rhill, lspill_list, ldestructive) + call util_spill(keeps%renc, discards%renc, lspill_list, ldestructive) + call util_spill(keeps%radius, discards%radius, lspill_list, ldestructive) + call util_spill(keeps%density, discards%density, lspill_list, ldestructive) + call util_spill(keeps%rbeg, discards%rbeg, lspill_list, ldestructive) + call util_spill(keeps%rend, discards%rend, lspill_list, ldestructive) + call util_spill(keeps%vbeg, discards%vbeg, lspill_list, ldestructive) + call util_spill(keeps%Ip, discards%Ip, lspill_list, ldestructive) + call util_spill(keeps%rot, discards%rot, lspill_list, ldestructive) + call util_spill(keeps%k2, discards%k2, lspill_list, ldestructive) + call util_spill(keeps%Q, discards%Q, lspill_list, ldestructive) + call util_spill(keeps%tlag, discards%tlag, lspill_list, ldestructive) + call util_spill(keeps%kin, discards%kin, lspill_list, ldestructive) + call util_spill(keeps%lmtiny, discards%lmtiny, lspill_list, ldestructive) + call util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive) + call util_spill(keeps%ntpenc, discards%ntpenc, lspill_list, ldestructive) if (ldestructive .and. allocated(keeps%k_plpl)) deallocate(keeps%k_plpl) @@ -4641,7 +3258,7 @@ module subroutine swiftest_util_spill_tp(self, discards, lspill_list, ldestructi select type(discards) class is (swiftest_tp) !> Spill components specific to the test particle class - call swiftest_util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive) + call util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive) call swiftest_util_spill_body(keeps, discards, lspill_list, ldestructive) class default write(*,*) 'Error! spill method called for incompatible return type on swiftest_tp' @@ -4652,71 +3269,6 @@ module subroutine swiftest_util_spill_tp(self, discards, lspill_list, ldestructi end subroutine swiftest_util_spill_tp - module subroutine swiftest_util_unique_DP(input_array, output_array, index_map) - !! author: David A. Minton - !! - !! Takes an input unsorted integer array and returns a new array of sorted, unique values (DP version) - implicit none - ! Arguments - real(DP), dimension(:), intent(in) :: input_array !! Unsorted input array - real(DP), dimension(:), allocatable, intent(out) :: output_array !! Sorted array of unique values - integer(I4B), dimension(:), allocatable, intent(out) :: index_map !! An array of the same size as input_array that such that any for any index i, output_array(index_map(i)) = input_array(i) - ! Internals - real(DP), dimension(:), allocatable :: unique_array - integer(I4B) :: n - real(DP) :: lo, hi - - allocate(unique_array, mold=input_array) - allocate(index_map(size(input_array))) - lo = minval(input_array) - 1 - hi = maxval(input_array) - - n = 0 - do - n = n + 1 - lo = minval(input_array(:), mask=input_array(:) > lo) - unique_array(n) = lo - where(input_array(:) == lo) index_map(:) = n - if (lo >= hi) exit - enddo - allocate(output_array(n), source=unique_array(1:n)) - - return - end subroutine swiftest_util_unique_DP - - - module subroutine swiftest_util_unique_I4B(input_array, output_array, index_map) - !! author: David A. Minton - !! - !! Takes an input unsorted integer array and returns a new array of sorted, unique values (I4B version) - implicit none - ! Arguments - integer(I4B), dimension(:), intent(in) :: input_array !! Unsorted input array - integer(I4B), dimension(:), allocatable, intent(out) :: output_array !! Sorted array of unique values - integer(I4B), dimension(:), allocatable, intent(out) :: index_map !! An array of the same size as input_array that such that any for any index i, output_array(index_map(i)) = input_array(i) - ! Internals - integer(I4B), dimension(:), allocatable :: unique_array - integer(I4B) :: n, lo, hi - - allocate(unique_array, mold=input_array) - allocate(index_map, mold=input_array) - lo = minval(input_array) - 1 - hi = maxval(input_array) - - n = 0 - do - n = n + 1 - lo = minval(input_array(:), mask=input_array(:) > lo) - unique_array(n) = lo - where(input_array(:) == lo) index_map(:) = n - if (lo >= hi) exit - enddo - allocate(output_array(n), source=unique_array(1:n)) - - return - end subroutine swiftest_util_unique_I4B - - module subroutine swiftest_util_valid_id_system(self, param) !! author: David A. Minton !! @@ -4747,11 +3299,11 @@ module subroutine swiftest_util_valid_id_system(self, param) maxid = maxval(idarr) ! Check to see if the ids are unique - call swiftest_util_unique(idarr, unique_idarr, idmap) + call util_unique(idarr, unique_idarr, idmap) if (size(unique_idarr) == nid) return ! All id values are unique ! Fix any duplicate id values and update the maxid - call swiftest_util_sort(idmap) + call util_sort(idmap) do i = 2, size(idmap) if (idmap(i) == idmap(i-1)) then maxid = maxid + 1 @@ -4782,9 +3334,7 @@ module subroutine swiftest_util_version() "Authors:", //, & " The Purdue University Swiftest Development team ", /, & " Lead by David A. Minton ", /, & - " Single loop blocking by Jacob R. Elliott", /, & - " Fragmentation by Carlisle A. Wishard and", //, & - " Jennifer L. L. Poutplin ", //, & + " Carlisle Wishard, Jennifer Pouplin, Jacob Elliott, Dana Singh." & "Please address comments and questions to:", //, & " David A. Minton", /, & " Department Earth, Atmospheric, & Planetary Sciences ",/, & @@ -4798,22 +3348,6 @@ module subroutine swiftest_util_version() "************************************************", /) - 100 FORMAT(/, "************* SWIFTER: Version ", F3.1, " *************", //, & - "Authors:", //, & - " Martin Duncan: Queen's University", /, & - " Hal Levison : Southwest Research Institute", //, & - "Please address comments and questions to:", //, & - " Hal Levison or David Kaufmann", /, & - " Department of Space Studies", /, & - " Southwest Research Institute", /, & - " 1050 Walnut Street, Suite 400", /, & - " Boulder, Colorado 80302", /, & - " 303-546-0290 (HFL), 720-240-0119 (DEK)", /, & - " 303-546-9687 (fax)", /, & - " hal@gort.boulder.swri.edu (HFL)", /, & - " kaufmann@boulder.swri.edu (DEK)", //, & - "************************************************", /) - return end subroutine swiftest_util_version diff --git a/src/symba/symba_encounter_check.f90 b/src/symba/symba_encounter_check.f90 index 895a9f34d..e66791409 100644 --- a/src/symba/symba_encounter_check.f90 +++ b/src/symba/symba_encounter_check.f90 @@ -96,11 +96,12 @@ module function symba_encounter_check_list_plpl(self, param, nbody_system, dt, i integer(I4B), intent(in) :: irec !! Current recursion level logical :: lany_encounter !! Returns true if there is at least one close encounter ! Internals - integer(I4B) :: i, j, k, lidx, nenc_enc + integer(I4B) :: i, j, nenc_enc + integer(I8B) :: k, lidx real(DP), dimension(NDIM) :: xr, vr real(DP) :: rlim2, rji2, rcrit12 logical, dimension(:), allocatable :: lencmask, lencounter - integer(I4B), dimension(:), allocatable :: eidx + integer(I8B), dimension(:), allocatable :: eidx lany_encounter = .false. if (self%nenc == 0) return @@ -116,10 +117,14 @@ module function symba_encounter_check_list_plpl(self, param, nbody_system, dt, i allocate(eidx(nenc_enc)) allocate(lencounter(nenc_enc)) - eidx(:) = pack([(k, k = 1, self%nenc)], lencmask(:)) + eidx(:) = pack([(k, k = 1_I8B, self%nenc)], lencmask(:)) lencounter(:) = .false. - do concurrent(lidx = 1:nenc_enc) +#ifdef DOCONLOC + do concurrent(lidx = 1_I8B:nenc_enc) shared(self,pl,eidx,lencounter,dt) local(i,j,k,xr,vr,rcrit12,rlim2,rji2) +#else + do concurrent(lidx = 1_I8B:nenc_enc) +#endif k = eidx(lidx) i = self%index1(k) j = self%index2(k) @@ -137,8 +142,8 @@ module function symba_encounter_check_list_plpl(self, param, nbody_system, dt, i lany_encounter = any(lencounter(:)) if (lany_encounter) then nenc_enc = count(lencounter(:)) - eidx(1:nenc_enc) = pack(eidx(:), lencounter(:)) - do lidx = 1, nenc_enc + eidx(1_I8B:nenc_enc) = pack(eidx(:), lencounter(:)) + do lidx = 1_I8B, nenc_enc k = eidx(lidx) i = self%index1(k) j = self%index2(k) @@ -164,11 +169,12 @@ module function symba_encounter_check_list_pltp(self, param, nbody_system, dt, i integer(I4B), intent(in) :: irec !! Current recursion level logical :: lany_encounter !! Returns true if there is at least one close encounter ! Internals - integer(I4B) :: i, j, k, lidx, nenc_enc + integer(I4B) :: i, j, nenc_enc + integer(I8B) :: k, lidx real(DP), dimension(NDIM) :: xr, vr real(DP) :: rlim2, rji2 logical, dimension(:), allocatable :: lencmask, lencounter - integer(I4B), dimension(:), allocatable :: eidx + integer(I8B), dimension(:), allocatable :: eidx lany_encounter = .false. if (self%nenc == 0) return @@ -186,10 +192,13 @@ module function symba_encounter_check_list_pltp(self, param, nbody_system, dt, i allocate(eidx(nenc_enc)) allocate(lencounter(nenc_enc)) - eidx(:) = pack([(k, k = 1, self%nenc)], lencmask(:)) + eidx(:) = pack([(k, k = 1_I8B, self%nenc)], lencmask(:)) lencounter(:) = .false. - - do concurrent(lidx = 1:nenc_enc) +#ifdef DOCONLOC + do concurrent(lidx = 1_I8B:nenc_enc) shared(self,pl,tp,eidx,lencounter,dt) local(i,j,k,xr,vr,rlim2,rji2) +#else + do concurrent(lidx = 1_I8B:nenc_enc) +#endif k = eidx(lidx) i = self%index1(k) j = self%index2(k) @@ -207,8 +216,8 @@ module function symba_encounter_check_list_pltp(self, param, nbody_system, dt, i lany_encounter = any(lencounter(:)) if (lany_encounter) then nenc_enc = count(lencounter(:)) - eidx(1:nenc_enc) = pack(eidx(:), lencounter(:)) - do lidx = 1, nenc_enc + eidx(1_I8B:nenc_enc) = pack(eidx(:), lencounter(:)) + do lidx = 1_I8B, nenc_enc k = eidx(lidx) i = self%index1(k) j = self%index2(k) diff --git a/src/symba/symba_kick.f90 b/src/symba/symba_kick.f90 index 0c75e1054..2db14456c 100644 --- a/src/symba/symba_kick.f90 +++ b/src/symba/symba_kick.f90 @@ -91,7 +91,8 @@ module subroutine symba_kick_getacch_tp(self, nbody_system, param, t, lbeg) real(DP), intent(in) :: t !! Current time logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step ! Internals - integer(I4B) :: i, j, k + integer(I4B) :: i, j + integer(I8B) :: k real(DP) :: rjj, fac real(DP), dimension(NDIM) :: dx @@ -142,7 +143,7 @@ module subroutine symba_kick_list_plpl(self, nbody_system, dt, irec, sgn) real(DP) :: r, rr, ri, ris, rim1, r2, ir3, fac, faci, facj real(DP), dimension(NDIM) :: dx logical, dimension(:), allocatable :: lgoodlevel - integer(I4B), dimension(:), allocatable :: good_idx + integer(I8B), dimension(:), allocatable :: good_idx if (self%nenc == 0) return @@ -170,9 +171,13 @@ module subroutine symba_kick_list_plpl(self, nbody_system, dt, irec, sgn) ngood = count(lgoodlevel(:)) if (ngood > 0_I8B) then allocate(good_idx(ngood)) - good_idx(:) = pack([(i, i = 1, nenc)], lgoodlevel(:)) + good_idx(:) = pack([(k, k = 1_I8B, nenc)], lgoodlevel(:)) +#ifdef DOCONLOC + do concurrent (k = 1:ngood) shared(self,pl,good_idx) local(i,j) +#else do concurrent (k = 1:ngood) +#endif i = self%index1(good_idx(k)) j = self%index2(good_idx(k)) pl%ah(:,i) = 0.0_DP @@ -208,7 +213,7 @@ module subroutine symba_kick_list_plpl(self, nbody_system, dt, irec, sgn) end do ngood = count(lgoodlevel(:)) if (ngood == 0_I8B) return - good_idx(1:ngood) = pack([(i, i = 1, nenc)], lgoodlevel(:)) + good_idx(1:ngood) = pack([(k, k = 1_I8B, nenc)], lgoodlevel(:)) do k = 1, ngood i = self%index1(good_idx(k)) @@ -247,7 +252,7 @@ module subroutine symba_kick_list_pltp(self, nbody_system, dt, irec, sgn) real(DP) :: r, rr, ri, ris, rim1, r2, ir3, fac, faci real(DP), dimension(NDIM) :: dx logical, dimension(:), allocatable :: lgoodlevel - integer(I4B), dimension(:), allocatable :: good_idx + integer(I8B), dimension(:), allocatable :: good_idx if (self%nenc == 0) return @@ -280,10 +285,13 @@ module subroutine symba_kick_list_pltp(self, nbody_system, dt, irec, sgn) if (ngood > 0_I8B) then allocate(good_idx(ngood)) - good_idx(:) = pack([(i, i = 1, nenc)], lgoodlevel(:)) - + good_idx(:) = pack([(k, k = 1_I8B, nenc)], lgoodlevel(:)) +#ifdef DOCONLOC + do concurrent (k = 1_I8B:ngood) shared(self,tp,good_idx) local(j) +#else do concurrent (k = 1_I8B:ngood) +#endif j = self%index2(good_idx(k)) tp%ah(:,j) = 0.0_DP end do @@ -316,7 +324,7 @@ module subroutine symba_kick_list_pltp(self, nbody_system, dt, irec, sgn) end do ngood = count(lgoodlevel(:)) if (ngood == 0_I8B) return - good_idx(1:ngood) = pack([(i, i = 1, nenc)], lgoodlevel(:)) + good_idx(1:ngood) = pack([(k, k = 1_I8B, nenc)], lgoodlevel(:)) do k = 1, ngood j = self%index2(good_idx(k)) diff --git a/src/symba/symba_module.f90 b/src/symba/symba_module.f90 index efa8dda8f..85e5ca3bc 100644 --- a/src/symba/symba_module.f90 +++ b/src/symba/symba_module.f90 @@ -243,10 +243,12 @@ module subroutine symba_util_dealloc_system(self) class(symba_nbody_system), intent(inout) :: self end subroutine symba_util_dealloc_system - module subroutine symba_util_setup_initialize_system(self, param) + + module subroutine symba_util_setup_initialize_system(self, system_history, param) implicit none - class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody_system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine symba_util_setup_initialize_system module subroutine symba_util_setup_pl(self, n, param) diff --git a/src/symba/symba_step.f90 b/src/symba/symba_step.f90 index 6e72c3e95..22cdddeb6 100644 --- a/src/symba/symba_step.f90 +++ b/src/symba/symba_step.f90 @@ -27,7 +27,6 @@ module subroutine symba_step_system(self, param, t, dt) real(DP), intent(in) :: dt !! Current stepsize ! Internals logical :: lencounter - type(walltimer) :: timer1,timer2,timer3 !! Object used for computing elapsed wall time select type(pl => self%pl) class is (symba_pl) diff --git a/src/symba/symba_util.f90 b/src/symba/symba_util.f90 index a30c08bac..c7abd79f3 100644 --- a/src/symba/symba_util.f90 +++ b/src/symba/symba_util.f90 @@ -25,12 +25,10 @@ module subroutine symba_util_append_pl(self, source, lsource_mask) select type(source) class is (symba_pl) - associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%levelg, source%levelg, nold, nsrc, lsource_mask) - call swiftest_util_append(self%levelm, source%levelm, nold, nsrc, lsource_mask) + call util_append(self%levelg, source%levelg, lsource_mask=lsource_mask) + call util_append(self%levelm, source%levelm, lsource_mask=lsource_mask) - call swiftest_util_append_pl(self, source, lsource_mask) ! Note: helio_pl does not have its own append method, so we skip back to the base class - end associate + call swiftest_util_append_pl(self, source, lsource_mask) ! Note: helio_pl does not have its own append method, so we skip back to the base class class default write(*,*) "Invalid object passed to the append method. Source must be of class symba_pl or its descendents!" call base_util_exit(FAILURE) @@ -53,12 +51,10 @@ module subroutine symba_util_append_tp(self, source, lsource_mask) select type(source) class is (symba_tp) - associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%levelg, source%levelg, nold, nsrc, lsource_mask) - call swiftest_util_append(self%levelm, source%levelm, nold, nsrc, lsource_mask) + call util_append(self%levelg, source%levelg, lsource_mask=lsource_mask) + call util_append(self%levelm, source%levelm, lsource_mask=lsource_mask) - call swiftest_util_append_tp(self, source, lsource_mask) ! Note: helio_tp does not have its own append method, so we skip back to the base class - end associate + call swiftest_util_append_tp(self, source, lsource_mask) ! Note: helio_tp does not have its own append method, so we skip back to the base class class default write(*,*) "Invalid object passed to the append method. Source must be of class symba_tp or its descendents!" call base_util_exit(FAILURE) @@ -75,8 +71,6 @@ module subroutine symba_util_dealloc_pl(self) implicit none ! Arguments class(symba_pl), intent(inout) :: self !! SyMBA massive body object - ! Internals - integer(I4B) :: i if (allocated(self%levelg)) deallocate(self%levelg) if (allocated(self%levelm)) deallocate(self%levelm) @@ -134,8 +128,8 @@ module subroutine symba_util_fill_pl(self, inserts, lfill_list) associate(keeps => self) select type(inserts) class is (symba_pl) - call swiftest_util_fill(keeps%levelg, inserts%levelg, lfill_list) - call swiftest_util_fill(keeps%levelm, inserts%levelm, lfill_list) + call util_fill(keeps%levelg, inserts%levelg, lfill_list) + call util_fill(keeps%levelm, inserts%levelm, lfill_list) call swiftest_util_fill_pl(keeps, inserts, lfill_list) ! Note: helio_pl does not have its own fill method, so we skip back to the base class class default @@ -163,9 +157,9 @@ module subroutine symba_util_fill_tp(self, inserts, lfill_list) associate(keeps => self) select type(inserts) class is (symba_tp) - call swiftest_util_fill(keeps%nplenc, inserts%nplenc, lfill_list) - call swiftest_util_fill(keeps%levelg, inserts%levelg, lfill_list) - call swiftest_util_fill(keeps%levelm, inserts%levelm, lfill_list) + call util_fill(keeps%nplenc, inserts%nplenc, lfill_list) + call util_fill(keeps%levelg, inserts%levelg, lfill_list) + call util_fill(keeps%levelm, inserts%levelm, lfill_list) call swiftest_util_fill_tp(keeps, inserts, lfill_list) ! Note: helio_tp does not have its own fill method, so we skip back to the base class class default @@ -223,8 +217,8 @@ module subroutine symba_util_resize_pl(self, nnew) class(symba_pl), intent(inout) :: self !! SyMBA massive body object integer(I4B), intent(in) :: nnew !! New size neded - call swiftest_util_resize(self%levelg, nnew) - call swiftest_util_resize(self%levelm, nnew) + call util_resize(self%levelg, nnew) + call util_resize(self%levelm, nnew) call swiftest_util_resize_pl(self, nnew) @@ -240,8 +234,8 @@ module subroutine symba_util_resize_tp(self, nnew) class(symba_tp), intent(inout) :: self !! SyMBA test particle object integer(I4B), intent(in) :: nnew !! New size neded - call swiftest_util_resize(self%levelg, nnew) - call swiftest_util_resize(self%levelm, nnew) + call util_resize(self%levelg, nnew) + call util_resize(self%levelm, nnew) call swiftest_util_resize_tp(self, nnew) @@ -273,7 +267,7 @@ module subroutine symba_util_set_renc(self, scale) end subroutine symba_util_set_renc - module subroutine symba_util_setup_initialize_system(self, param) + module subroutine symba_util_setup_initialize_system(self, system_history, param) !! author: David A. Minton !! !! Initialize an SyMBA nbody system from files and sets up the planetocentric structures. @@ -281,8 +275,9 @@ module subroutine symba_util_setup_initialize_system(self, param) !! implicit none ! Arguments - class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody_system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody_system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals type(encounter_storage) :: encounter_history type(collision_storage) :: collision_history @@ -291,7 +286,7 @@ module subroutine symba_util_setup_initialize_system(self, param) call collision_history%setup(4096) ! Call parent method associate(nbody_system => self) - call helio_util_setup_initialize_system(nbody_system, param) + call helio_util_setup_initialize_system(nbody_system, system_history, param) call nbody_system%pltp_encounter%setup(0_I8B) call nbody_system%plpl_encounter%setup(0_I8B) call nbody_system%plpl_collision%setup(0_I8B) @@ -355,8 +350,6 @@ module subroutine symba_util_setup_pl(self, n, param) class(symba_pl), intent(inout) :: self !! SyMBA massive body object integer(I4B), intent(in) :: n !! Number of particles to allocate space for class(swiftest_parameters), intent(in) :: param !! Current run configuration parameter - ! Internals - integer(I4B) :: i !> Call allocation method for parent class. call self%helio_pl%setup(n, param) @@ -422,9 +415,9 @@ module subroutine symba_util_sort_pl(self, sortby, ascending) associate(pl => self, npl => self%nbody) select case(sortby) case("levelg") - call swiftest_util_sort(direction * pl%levelg(1:npl), ind) + call util_sort(direction * pl%levelg(1:npl), ind) case("levelm") - call swiftest_util_sort(direction * pl%levelm(1:npl), ind) + call util_sort(direction * pl%levelm(1:npl), ind) case default ! Look for components in the parent class call swiftest_util_sort_pl(pl, sortby, ascending) @@ -463,11 +456,11 @@ module subroutine symba_util_sort_tp(self, sortby, ascending) associate(tp => self, ntp => self%nbody) select case(sortby) case("nplenc") - call swiftest_util_sort(direction * tp%nplenc(1:ntp), ind) + call util_sort(direction * tp%nplenc(1:ntp), ind) case("levelg") - call swiftest_util_sort(direction * tp%levelg(1:ntp), ind) + call util_sort(direction * tp%levelg(1:ntp), ind) case("levelm") - call swiftest_util_sort(direction * tp%levelm(1:ntp), ind) + call util_sort(direction * tp%levelm(1:ntp), ind) case default ! Look for components in the parent class call swiftest_util_sort_tp(tp, sortby, ascending) return @@ -491,8 +484,8 @@ module subroutine symba_util_sort_rearrange_pl(self, ind) integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) associate(pl => self, npl => self%nbody) - call swiftest_util_sort_rearrange(pl%levelg, ind, npl) - call swiftest_util_sort_rearrange(pl%levelm, ind, npl) + call util_sort_rearrange(pl%levelg, ind, npl) + call util_sort_rearrange(pl%levelm, ind, npl) call swiftest_util_sort_rearrange_pl(pl,ind) end associate @@ -511,9 +504,9 @@ module subroutine symba_util_sort_rearrange_tp(self, ind) integer(I4B), dimension(:), intent(in) :: ind !! Index array used to restructure the body (should contain all 1:n index values in the desired order) associate(tp => self, ntp => self%nbody) - call swiftest_util_sort_rearrange(tp%nplenc, ind, ntp) - call swiftest_util_sort_rearrange(tp%levelg, ind, ntp) - call swiftest_util_sort_rearrange(tp%levelm, ind, ntp) + call util_sort_rearrange(tp%nplenc, ind, ntp) + call util_sort_rearrange(tp%levelg, ind, ntp) + call util_sort_rearrange(tp%levelm, ind, ntp) call swiftest_util_sort_rearrange_tp(tp,ind) end associate @@ -539,8 +532,8 @@ module subroutine symba_util_spill_pl(self, discards, lspill_list, ldestructive) associate(keeps => self) select type(discards) class is (symba_pl) - call swiftest_util_spill(keeps%levelg, discards%levelg, lspill_list, ldestructive) - call swiftest_util_spill(keeps%levelm, discards%levelm, lspill_list, ldestructive) + call util_spill(keeps%levelg, discards%levelg, lspill_list, ldestructive) + call util_spill(keeps%levelm, discards%levelm, lspill_list, ldestructive) call swiftest_util_spill_pl(keeps, discards, lspill_list, ldestructive) class default @@ -570,9 +563,9 @@ module subroutine symba_util_spill_tp(self, discards, lspill_list, ldestructive) associate(keeps => self) select type(discards) class is (symba_tp) - call swiftest_util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive) - call swiftest_util_spill(keeps%levelg, discards%levelg, lspill_list, ldestructive) - call swiftest_util_spill(keeps%levelm, discards%levelm, lspill_list, ldestructive) + call util_spill(keeps%nplenc, discards%nplenc, lspill_list, ldestructive) + call util_spill(keeps%levelg, discards%levelg, lspill_list, ldestructive) + call util_spill(keeps%levelm, discards%levelm, lspill_list, ldestructive) call swiftest_util_spill_tp(keeps, discards, lspill_list, ldestructive) class default diff --git a/src/whm/whm_coarray.f90 b/src/whm/whm_coarray.f90 new file mode 100644 index 000000000..5a8de4c32 --- /dev/null +++ b/src/whm/whm_coarray.f90 @@ -0,0 +1,34 @@ +!! Copyright 2023 - David Minton +!! This file is part of Swiftest. +!! Swiftest is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License +!! as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +!! Swiftest is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty +!! of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +!! You should have received a copy of the GNU General Public License along with Swiftest. +!! If not, see: https://www.gnu.org/licenses. + +submodule (whm) s_whm_coarray +use coarray +use swiftest +contains + + module subroutine whm_coarray_coclone_pl(self) + !! author: David A. Minton + !! + !! Broadcasts the image 1 object to all other images in a coarray + implicit none + ! Arguments + class(whm_pl),intent(inout),codimension[*] :: self !! WHM pl object + + call coclone(self%eta) + call coclone(self%xj) + call coclone(self%vj) + call coclone(self%muj) + call coclone(self%ir3j) + + call swiftest_coarray_coclone_pl(self) + + return + end subroutine whm_coarray_coclone_pl + +end submodule s_whm_coarray \ No newline at end of file diff --git a/src/whm/whm_gr.f90 b/src/whm/whm_gr.f90 index b0891f006..6e23ca21b 100644 --- a/src/whm/whm_gr.f90 +++ b/src/whm/whm_gr.f90 @@ -25,8 +25,6 @@ pure module subroutine whm_gr_kick_getacch_pl(self, param) ! Internals integer(I4B) :: i real(DP), dimension(NDIM) :: suma - real(DP), dimension(:, :), allocatable :: aj - real(DP) :: beta, rjmag4 if (self%nbody == 0) return @@ -56,8 +54,6 @@ pure module subroutine whm_gr_kick_getacch_tp(self, param) class(whm_tp), intent(inout) :: self !! WHM massive body particle data structure class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters ! Internals - integer(I4B) :: i - real(DP) :: rjmag4, beta if (self%nbody == 0) return @@ -84,12 +80,18 @@ pure module subroutine whm_gr_p4_pl(self, nbody_system, param, dt) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: dt !! Step size ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl + + if (self%nbody == 0) return - associate(pl => self, npl => self%nbody) - if (npl == 0) return - do concurrent(i = 1:npl, pl%lmask(i)) - call swiftest_gr_p4_pos_kick(param, pl%xj(:, i), pl%vj(:, i), dt) + associate(xj => self%xj, vj => self%vj, lmask => self%lmask, inv_c2 => param%inv_c2) + npl = self%nbody +#ifdef DOCONLOC + do concurrent(i = 1:npl, lmask(i)) shared(lmask, inv_c2, xj, vj,dt) +#else + do concurrent(i = 1:npl, lmask(i)) +#endif + call swiftest_gr_p4_pos_kick(inv_c2, xj(1,i), xj(2,i), xj(3,i), vj(1,i), vj(2,i), vj(3,i), dt) end do end associate @@ -111,12 +113,17 @@ pure module subroutine whm_gr_p4_tp(self, nbody_system, param, dt) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: dt !! Step size ! Internals - integer(I4B) :: i + integer(I4B) :: i, ntp - associate(tp => self, ntp => self%nbody) + associate(rh => self%rh, vh => self%vh, lmask => self%lmask, inv_c2 => param%inv_c2) + ntp = self%nbody if (ntp == 0) return - do concurrent(i = 1:ntp, tp%lmask(i)) - call swiftest_gr_p4_pos_kick(param, tp%rh(:, i), tp%vh(:, i), dt) +#ifdef DOCONLOC + do concurrent(i = 1:ntp, lmask(i)) shared(lmask, rh, vh, inv_c2, dt) +#else + do concurrent(i = 1:ntp, lmask(i)) +#endif + call swiftest_gr_p4_pos_kick(inv_c2, rh(1,i), rh(2,i), rh(3,i), vh(1,i), vh(2,i), vh(3,i), dt) end do end associate diff --git a/src/whm/whm_kick.f90 b/src/whm/whm_kick.f90 index 6469809e5..bcddf0de7 100644 --- a/src/whm/whm_kick.f90 +++ b/src/whm/whm_kick.f90 @@ -82,22 +82,32 @@ module subroutine whm_kick_getacch_tp(self, nbody_system, param, t, lbeg) real(DP), intent(in) :: t !! Current time logical, intent(in) :: lbeg !! Logical flag that determines whether or not this is the beginning or end of the step ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl, ntp real(DP), dimension(NDIM) :: ah0 - associate(tp => self, ntp => self%nbody, pl => nbody_system%pl, cb => nbody_system%cb, npl => nbody_system%pl%nbody) + associate(tp => self, pl => nbody_system%pl, cb => nbody_system%cb) + npl = nbody_system%pl%nbody + ntp = self%nbody if (ntp == 0 .or. npl == 0) return nbody_system%lbeg = lbeg if (lbeg) then ah0(:) = whm_kick_getacch_ah0(pl%Gmass(1:npl), pl%rbeg(:, 1:npl), npl) +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp,ah0) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%ah(:, i) = tp%ah(:, i) + ah0(:) end do call tp%accel_int(param, pl%Gmass(1:npl), pl%rbeg(:, 1:npl), npl) else ah0(:) = whm_kick_getacch_ah0(pl%Gmass(1:npl), pl%rend(:, 1:npl), npl) +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp,ah0) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%ah(:, i) = tp%ah(:, i) + ah0(:) end do call tp%accel_int(param, pl%Gmass(1:npl), pl%rend(:, 1:npl), npl) @@ -124,14 +134,13 @@ function whm_kick_getacch_ah0(mu, rhp, n) result(ah0) ! Result real(DP), dimension(NDIM) :: ah0 ! Internals - real(DP) :: fac, r2, ir3h, irh + real(DP) :: fac, r2, ir3h integer(I4B) :: i ah0(:) = 0.0_DP do i = 1, n r2 = dot_product(rhp(:, i), rhp(:, i)) - irh = 1.0_DP / sqrt(r2) - ir3h = irh / r2 + ir3h = 1.0_DP / (r2 * sqrt(r2)) fac = mu(i) * ir3h ah0(:) = ah0(:) - fac * rhp(:, i) end do @@ -152,16 +161,19 @@ pure subroutine whm_kick_getacch_ah1(cb, pl) class(swiftest_cb), intent(in) :: cb !! WHM central body object class(whm_pl), intent(inout) :: pl !! WHM massive body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl real(DP), dimension(NDIM) :: ah1h, ah1j - associate(npl => pl%nbody) - do concurrent (i = 2:npl, pl%lmask(i)) - ah1j(:) = pl%xj(:, i) * pl%ir3j(i) - ah1h(:) = pl%rh(:, i) * pl%ir3h(i) - pl%ah(:, i) = pl%ah(:, i) + cb%Gmass * (ah1j(:) - ah1h(:)) - end do - end associate + npl = pl%nbody +#ifdef DOCONLOC + do concurrent (i = 2:npl, pl%lmask(i)) shared(pl,cb) local(ah1j,ah1h) +#else + do concurrent (i = 2:npl, pl%lmask(i)) +#endif + ah1j(:) = pl%xj(:, i) * pl%ir3j(i) + ah1h(:) = pl%rh(:, i) * pl%ir3h(i) + pl%ah(:, i) = pl%ah(:, i) + cb%Gmass * (ah1j(:) - ah1h(:)) + end do return end subroutine whm_kick_getacch_ah1 @@ -179,22 +191,25 @@ pure subroutine whm_kick_getacch_ah2(cb, pl) class(swiftest_cb), intent(in) :: cb !! Swiftest central body object class(whm_pl), intent(inout) :: pl !! WHM massive body object ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl real(DP) :: etaj, fac real(DP), dimension(NDIM) :: ah2, ah2o - associate(npl => pl%nbody) - ah2(:) = 0.0_DP - ah2o(:) = 0.0_DP - etaj = cb%Gmass - do concurrent(i = 2:npl, pl%lmask(i)) - etaj = etaj + pl%Gmass(i - 1) - fac = pl%Gmass(i) * cb%Gmass * pl%ir3j(i) / etaj - ah2(:) = ah2o + fac * pl%xj(:, i) - pl%ah(:,i) = pl%ah(:, i) + ah2(:) - ah2o(:) = ah2(:) - end do - end associate + npl = pl%nbody + ah2(:) = 0.0_DP + ah2o(:) = 0.0_DP + etaj = cb%Gmass +#ifdef DOCONLOC + do concurrent(i = 2:npl, pl%lmask(i)) shared(pl,cb,ah2,ah2o) local(etaj,fac) +#else + do concurrent(i = 2:npl, pl%lmask(i)) +#endif + etaj = etaj + pl%Gmass(i - 1) + fac = pl%Gmass(i) * cb%Gmass * pl%ir3j(i) / etaj + ah2(:) = ah2o(:) + fac * pl%xj(:, i) + pl%ah(:,i) = pl%ah(:, i) + ah2(:) + ah2o(:) = ah2(:) + end do return end subroutine whm_kick_getacch_ah2 @@ -216,9 +231,10 @@ module subroutine whm_kick_vh_pl(self, nbody_system, param, t, dt, lbeg) real(DP), intent(in) :: dt !! Stepsize logical, intent(in) :: lbeg !! Logical flag indicating whether this is the beginning of the half step or not. ! Internals - integer(I4B) :: i + integer(I4B) :: i, npl - associate(pl => self, npl => self%nbody, cb => nbody_system%cb) + associate(pl => self, cb => nbody_system%cb) + npl = self%nbody if (npl == 0) return if (lbeg) then if (pl%lfirst) then @@ -233,7 +249,11 @@ module subroutine whm_kick_vh_pl(self, nbody_system, param, t, dt, lbeg) call pl%accel(nbody_system, param, t, lbeg) call pl%set_beg_end(rend = pl%rh) end if +#ifdef DOCONLOC + do concurrent(i = 1:npl, pl%lmask(i)) shared(pl,dt) +#else do concurrent(i = 1:npl, pl%lmask(i)) +#endif pl%vh(:, i) = pl%vh(:, i) + pl%ah(:, i) * dt end do end associate @@ -258,25 +278,38 @@ module subroutine whm_kick_vh_tp(self, nbody_system, param, t, dt, lbeg) real(DP), intent(in) :: dt !! Stepsize logical, intent(in) :: lbeg !! Logical flag indicating whether this is the beginning of the half step or not. ! Internals - integer(I4B) :: i + integer(I4B) :: i, ntp if (self%nbody == 0) return - associate(tp => self, ntp => self%nbody) + associate(tp => self) + ntp = self%nbody if (tp%lfirst) then +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%ah(:, i) = 0.0_DP end do call tp%accel(nbody_system, param, t, lbeg=.true.) tp%lfirst = .false. end if if (.not.lbeg) then +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%ah(:, i) = 0.0_DP end do call tp%accel(nbody_system, param, t, lbeg) end if +#ifdef DOCONLOC + do concurrent(i = 1:ntp, tp%lmask(i)) shared(tp) +#else do concurrent(i = 1:ntp, tp%lmask(i)) +#endif tp%vh(:, i) = tp%vh(:, i) + tp%ah(:, i) * dt end do end associate diff --git a/src/whm/whm_module.f90 b/src/whm/whm_module.f90 index d2d10f971..38e73f190 100644 --- a/src/whm/whm_module.f90 +++ b/src/whm/whm_module.f90 @@ -48,10 +48,13 @@ module whm procedure :: set_mu => whm_util_set_mu_eta_pl !! Sets the Jacobi mass value for all massive bodies. procedure :: sort => whm_util_sort_pl !! Sort a WHM massive body object in-place. procedure :: rearrange => whm_util_sort_rearrange_pl !! Rearranges the order of array elements of body based on an input index array. Used in sorting methods - procedure :: spill => whm_util_spill_pl !!"Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) - procedure :: setup => whm_util_setup_pl !! Constructor method - Allocates space for the input number of bodiess + procedure :: spill => whm_util_spill_pl !! "Spills" bodies from one object to another depending on the results of a mask (uses the PACK intrinsic) + procedure :: setup => whm_util_setup_pl !! Constructor method - Allocates space for the input number of bodiess procedure :: step => whm_step_pl !! Steps the body forward one stepsize - final :: whm_final_pl !! Finalizes the WHM massive body object - deallocates all allocatables + final :: whm_final_pl !! Finalizes the WHM massive body object - deallocates all allocatables +#ifdef COARRAY + procedure :: coclone => whm_coarray_coclone_pl !! Clones the image 1 body object to all other images in the coarray structure. +#endif end type whm_pl @@ -180,10 +183,11 @@ module subroutine whm_util_setup_pl(self, n, param) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine whm_util_setup_pl - module subroutine whm_util_setup_initialize_system(self, param) + module subroutine whm_util_setup_initialize_system(self, system_history, param) implicit none - class(whm_nbody_system), intent(inout) :: self !! WHM nbody system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(whm_nbody_system), intent(inout) :: self !! WHM nbody system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters end subroutine whm_util_setup_initialize_system module subroutine whm_step_pl(self, nbody_system, param, t, dt) @@ -270,6 +274,15 @@ module subroutine whm_util_sort_rearrange_pl(self, ind) end subroutine whm_util_sort_rearrange_pl end interface +#ifdef COARRAY + interface + module subroutine whm_coarray_coclone_pl(self) + implicit none + class(whm_pl),intent(inout),codimension[*] :: self !! WHM pl object + end subroutine whm_coarray_coclone_pl + end interface +#endif + contains subroutine whm_final_pl(self) diff --git a/src/whm/whm_util.f90 b/src/whm/whm_util.f90 index 751e97d2a..09fa59d76 100644 --- a/src/whm/whm_util.f90 +++ b/src/whm/whm_util.f90 @@ -24,15 +24,13 @@ module subroutine whm_util_append_pl(self, source, lsource_mask) select type(source) class is (whm_pl) - associate(nold => self%nbody, nsrc => source%nbody) - call swiftest_util_append(self%eta, source%eta, nold, nsrc, lsource_mask) - call swiftest_util_append(self%muj, source%muj, nold, nsrc, lsource_mask) - call swiftest_util_append(self%ir3j, source%ir3j, nold, nsrc, lsource_mask) - call swiftest_util_append(self%xj, source%xj, nold, nsrc, lsource_mask) - call swiftest_util_append(self%vj, source%vj, nold, nsrc, lsource_mask) - - call swiftest_util_append_pl(self, source, lsource_mask) - end associate + call util_append(self%eta, source%eta, lsource_mask=lsource_mask) + call util_append(self%muj, source%muj, lsource_mask=lsource_mask) + call util_append(self%ir3j, source%ir3j, lsource_mask=lsource_mask) + call util_append(self%xj, source%xj, lsource_mask=lsource_mask) + call util_append(self%vj, source%vj, lsource_mask=lsource_mask) + + call swiftest_util_append_pl(self, source, lsource_mask) class default write(*,*) "Invalid object passed to the append method. Source must be of class whm_pl or its descendents" call base_util_exit(FAILURE) @@ -78,11 +76,11 @@ module subroutine whm_util_fill_pl(self, inserts, lfill_list) associate(keeps => self) select type(inserts) class is (whm_pl) - call swiftest_util_fill(keeps%eta, inserts%eta, lfill_list) - call swiftest_util_fill(keeps%muj, inserts%muj, lfill_list) - call swiftest_util_fill(keeps%ir3j, inserts%ir3j, lfill_list) - call swiftest_util_fill(keeps%xj, inserts%xj, lfill_list) - call swiftest_util_fill(keeps%vj, inserts%vj, lfill_list) + call util_fill(keeps%eta, inserts%eta, lfill_list) + call util_fill(keeps%muj, inserts%muj, lfill_list) + call util_fill(keeps%ir3j, inserts%ir3j, lfill_list) + call util_fill(keeps%xj, inserts%xj, lfill_list) + call util_fill(keeps%vj, inserts%vj, lfill_list) call swiftest_util_fill_pl(keeps, inserts, lfill_list) class default @@ -104,11 +102,11 @@ module subroutine whm_util_resize_pl(self, nnew) class(whm_pl), intent(inout) :: self !! WHM massive body object integer(I4B), intent(in) :: nnew !! New size neded - call swiftest_util_resize(self%eta, nnew) - call swiftest_util_resize(self%xj, nnew) - call swiftest_util_resize(self%vj, nnew) - call swiftest_util_resize(self%muj, nnew) - call swiftest_util_resize(self%ir3j, nnew) + call util_resize(self%eta, nnew) + call util_resize(self%xj, nnew) + call util_resize(self%vj, nnew) + call util_resize(self%muj, nnew) + call util_resize(self%ir3j, nnew) call swiftest_util_resize_pl(self, nnew) @@ -200,17 +198,18 @@ module subroutine whm_util_set_mu_eta_pl(self, cb) end subroutine whm_util_set_mu_eta_pl - module subroutine whm_util_setup_initialize_system(self, param) + module subroutine whm_util_setup_initialize_system(self, system_history, param) !! author: David A. Minton !! !! Initialize a WHM nbody system from files !! implicit none ! Arguments - class(whm_nbody_system), intent(inout) :: self !! WHM nbody system object - class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters + class(whm_nbody_system), intent(inout) :: self !! WHM nbody system object + class(swiftest_storage), allocatable, intent(inout) :: system_history !! Stores the system history between output dumps + class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters - call swiftest_util_setup_initialize_system(self, param) + call swiftest_util_setup_initialize_system(self, system_history, param) ! First we need to make sure that the massive bodies are sorted by heliocentric distance before computing jacobies call swiftest_util_set_ir3h(self%pl) call self%pl%sort("ir3h", ascending=.false.) @@ -254,11 +253,11 @@ module subroutine whm_util_sort_pl(self, sortby, ascending) associate(pl => self, npl => self%nbody) select case(sortby) case("eta") - call swiftest_util_sort(direction * pl%eta(1:npl), ind) + call util_sort(direction * pl%eta(1:npl), ind) case("muj") - call swiftest_util_sort(direction * pl%muj(1:npl), ind) + call util_sort(direction * pl%muj(1:npl), ind) case("ir3j") - call swiftest_util_sort(direction * pl%ir3j(1:npl), ind) + call util_sort(direction * pl%ir3j(1:npl), ind) case("xj", "vj") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default @@ -286,11 +285,11 @@ module subroutine whm_util_sort_rearrange_pl(self, ind) if (self%nbody == 0) return associate(pl => self, npl => self%nbody) - call swiftest_util_sort_rearrange(pl%eta, ind, npl) - call swiftest_util_sort_rearrange(pl%xj, ind, npl) - call swiftest_util_sort_rearrange(pl%vj, ind, npl) - call swiftest_util_sort_rearrange(pl%muj, ind, npl) - call swiftest_util_sort_rearrange(pl%ir3j, ind, npl) + call util_sort_rearrange(pl%eta, ind, npl) + call util_sort_rearrange(pl%xj, ind, npl) + call util_sort_rearrange(pl%vj, ind, npl) + call util_sort_rearrange(pl%muj, ind, npl) + call util_sort_rearrange(pl%ir3j, ind, npl) call swiftest_util_sort_rearrange_pl(pl,ind) end associate @@ -315,11 +314,11 @@ module subroutine whm_util_spill_pl(self, discards, lspill_list, ldestructive) associate(keeps => self) select type(discards) class is (whm_pl) - call swiftest_util_spill(keeps%eta, discards%eta, lspill_list, ldestructive) - call swiftest_util_spill(keeps%muj, discards%muj, lspill_list, ldestructive) - call swiftest_util_spill(keeps%ir3j, discards%ir3j, lspill_list, ldestructive) - call swiftest_util_spill(keeps%xj, discards%xj, lspill_list, ldestructive) - call swiftest_util_spill(keeps%vj, discards%vj, lspill_list, ldestructive) + call util_spill(keeps%eta, discards%eta, lspill_list, ldestructive) + call util_spill(keeps%muj, discards%muj, lspill_list, ldestructive) + call util_spill(keeps%ir3j, discards%ir3j, lspill_list, ldestructive) + call util_spill(keeps%xj, discards%xj, lspill_list, ldestructive) + call util_spill(keeps%vj, discards%vj, lspill_list, ldestructive) call swiftest_util_spill_pl(keeps, discards, lspill_list, ldestructive) class default