diff --git a/.github/workflows/Documenter.yml b/.github/workflows/Documenter.yml index 808fc553..6f831f92 100644 --- a/.github/workflows/Documenter.yml +++ b/.github/workflows/Documenter.yml @@ -71,6 +71,9 @@ jobs: cd docs/doxygen doxygen - name: Deploy doxygen docs + if: >- + github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name == github.repository uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96694d49..98586575 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -359,3 +359,103 @@ jobs: if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled && always() }} uses: mxschmitt/action-tmate@v3 timeout-minutes: 15 + + macos-smoke: + name: macos-latest - smoke - Julia 1.11 - ${{ github.event_name }} + runs-on: macos-latest + env: + JULIA_DEPOT_PATH: ~/.julia + T8CODE_VERSION: '3.0.1' + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Enable Julia cache + uses: julia-actions/cache@v3 + + - name: Enable t8code cache + id: cache-t8code + uses: actions/cache@v5 + with: + path: ./t8code-local + key: ${{ runner.os }}-t8code-${{ env.T8CODE_VERSION }} + + - name: Install Julia + uses: julia-actions/setup-julia@v3 + with: + version: '1.11' + + - name: Install dependencies available with Homebrew + run: | + brew install cmake gcc open-mpi hdf5 + # Point Open MPI at Homebrew GCC's Fortran compiler + GFORTRAN="$(command -v gfortran || true)" + if [ -z "$GFORTRAN" ]; then + GFORTRAN="$(find "$(brew --prefix gcc)/bin" -name 'gfortran-*' | head -n 1)" + fi + if [ -z "$GFORTRAN" ]; then + echo "gfortran not found" >&2 + exit 1 + fi + echo "FC=$GFORTRAN" >> "$GITHUB_ENV" + echo "OMPI_FC=$GFORTRAN" >> "$GITHUB_ENV" + + - name: Install t8code + if: steps.cache-t8code.outputs.cache-hit != 'true' + run: | + mkdir t8code-local + cd t8code-local + T8CODE_SOURCE=T8CODE-${T8CODE_VERSION}-Source + T8CODE_URL=https://github.com/DLR-AMR/t8code/releases/download + curl -L -O "$T8CODE_URL/v${T8CODE_VERSION}/$T8CODE_SOURCE.tar.gz" + tar xf "$T8CODE_SOURCE.tar.gz" + cmake -S "$T8CODE_SOURCE" -B build \ + -DCMAKE_C_COMPILER=mpicc \ + -DCMAKE_CXX_COMPILER=mpicxx \ + -DCMAKE_Fortran_COMPILER=mpifort \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX="$PWD/prefix" \ + -DT8CODE_BUILD_TESTS=OFF \ + -DT8CODE_BUILD_TUTORIALS=OFF \ + -DT8CODE_BUILD_EXAMPLES=OFF \ + -DT8CODE_BUILD_BENCHMARKS=OFF \ + -DT8CODE_ENABLE_MPI=ON \ + -DT8CODE_BUILD_FORTRAN_INTERFACE=ON + cmake --build build --parallel 2 + cmake --install build + + - name: Build + run: | + cmake -S . -B build \ + -DCMAKE_INSTALL_PREFIX="$PWD/install" \ + -DCMAKE_BUILD_TYPE=Release \ + -DT8CODE_ROOT="$PWD/t8code-local/prefix" + cmake --build build --parallel 2 + cmake --install build + + - name: Run examples + run: | + mkdir libtrixi-julia + cd libtrixi-julia + EXAMPLES_DIR=../install/share/libtrixi/LibTrixi.jl/examples + cp "$EXAMPLES_DIR/libelixir_t8code2d_euler_tracer_amr.jl" . + HDF5_PREFIX="$(brew --prefix hdf5)" + MPI_PREFIX="$(brew --prefix open-mpi)" + ../install/bin/libtrixi-init-julia .. \ + --hdf5-library "$HDF5_PREFIX/lib/libhdf5.dylib" \ + --mpi-library "$MPI_PREFIX/lib/libmpi.dylib" \ + --t8code-library ../t8code-local/prefix/lib/libt8.dylib \ + --julia-depot ~/.julia \ + --skip-precompile \ + --force + mkdir run-c run-f + PROJECT_DIR="$PWD" + LIBELIXIR_PATH="$PROJECT_DIR/libelixir_t8code2d_euler_tracer_amr.jl" + cd run-c + ../../build/examples/trixi_controller_t8code_c \ + "$PROJECT_DIR" "$LIBELIXIR_PATH" + cd ../run-f + ../../build/examples/trixi_controller_t8code_f \ + "$PROJECT_DIR" "$LIBELIXIR_PATH" + env: + LIBTRIXI_DEBUG: all diff --git a/README.md b/README.md index 771d1ae0..cc57ae01 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ### Prerequisites -Currently, libtrixi is only developed and tested for Linux. Furthermore, the following +Currently, libtrixi is developed and tested for Linux and (experimentally) for macOS. Furthermore, the following software packages need to be made available locally before installing libtrixi: * [Julia](https://julialang.org/downloads/platform/) v1.8+ * C compiler with support for C11 or later (e.g., [gcc](https://gcc.gnu.org/) or [clang](https://clang.llvm.org/)) diff --git a/docs/src/index.md b/docs/src/index.md index 62f1714c..5ad8376b 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -16,7 +16,7 @@ ### Prerequisites -Currently, libtrixi is only developed and tested for Linux. Furthermore, the following +Currently, libtrixi is developed and tested for Linux and (experimentally) for macOS. Furthermore, the following software packages need to be made available locally before installing libtrixi: * [Julia](https://julialang.org/downloads/platform/) v1.8+ * C compiler with support for C11 or later (e.g., [gcc](https://gcc.gnu.org/) or [clang](https://clang.llvm.org/)) diff --git a/examples/trixi_controller_t8code.c b/examples/trixi_controller_t8code.c index cebaaf30..af2d1981 100644 --- a/examples/trixi_controller_t8code.c +++ b/examples/trixi_controller_t8code.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -22,7 +23,10 @@ void t8_print_forest_information (t8_forest_t forest) global_num_elements = t8_forest_get_global_num_elements (forest); printf ("\n*** T8code *** Local number of elements:\t%i\n", local_num_elements); - printf ("*** T8code *** Global number of elements:\t%li\n", global_num_elements); + + // Using PRId64 to print t8_gloidx_t portably across platforms + printf ("*** T8code *** Global number of elements:\t%" PRId64 "\n", + global_num_elements); } diff --git a/utils/libtrixi-init-julia b/utils/libtrixi-init-julia index a7e0be6f..e1d77aa0 100755 --- a/utils/libtrixi-init-julia +++ b/utils/libtrixi-init-julia @@ -53,30 +53,30 @@ optional arguments: --hdf5-library HDF5_LIBRARY Path to the HDF5 shared library, i.e., something like - 'path/to/libhdf5.so'. If empty, Julia will try to figure out the path - automatically. (default: '') + 'path/to/libhdf5.so' or 'path/to/libhdf5.dylib'. If empty, Julia + will try to figure out the path automatically. (default: '') --mpi-library MPI_LIBRARY Path to the MPI C shared library, i.e., something like - 'path/to/libmpi.so'. If empty, Julia will try to figure out the path - automatically. (default: '') + 'path/to/libmpi.so' or 'path/to/libmpi.dylib'. If empty, Julia will + try to figure out the path automatically. (default: '') --t8code-library T8CODE_LIBRARY Path to the t8code shared library, i.e., something like - 'path/to/libt8.so'. If empty, Julia will try to figure out the path - automatically. (default: '') + 'path/to/libt8.so' or 'path/to/libt8.dylib'. If empty, Julia will + try to figure out the path automatically. (default: '') --p4est-library P4EST_LIBRARY Path to the p4est shared library, i.e., something like - 'path/to/libp4est.so'. If omitted, it will be assumed to be located - next to the t8code library. (default: '\$(dirname \$T8CODE_LIBRARY)/ - libp4est.so') + 'path/to/libp4est.so' or 'path/to/libp4est.dylib'. If omitted, it + will be assumed to be located next to the t8code library. + (default: '\$(dirname \$T8CODE_LIBRARY)/libp4est.') --sc-library SC_LIBRARY Path to the sc shared library, i.e., something like - 'path/to/libsc.so'. If omitted, it will be assumed to be located next - to the t8code library. (default: '\$(dirname \$T8CODE_LIBRARY)/ - libsc.so') + 'path/to/libsc.so' or 'path/to/libsc.dylib'. If omitted, it will be + assumed to be located next to the t8code library. + (default: '\$(dirname \$T8CODE_LIBRARY)/libsc.') EOF } @@ -171,7 +171,20 @@ julia_exec="$LIBTRIXI_JULIA_EXEC" # Save Julia depot path julia_depot="$LIBTRIXI_JULIA_DEPOT" -# Check if libhdf5.so was given by the user or try to find it using Julia +# Determine platform shared library suffix +case "$(uname -s)" in + Linux) + shared_library_suffix=so + ;; + Darwin) + shared_library_suffix=dylib + ;; + *) + shared_library_suffix=so + ;; +esac + +# Check if libhdf5 was given by the user or try to find it using Julia if [ -z "$LIBTRIXI_HDF5_LIBRARY" ]; then hdf5_libdir="$($julia_exec -e 'using Libdl; find_library("libhdf5") |> dlpath |> dirname |> println')" if [ -z "$hdf5_libdir" ]; then @@ -180,11 +193,11 @@ if [ -z "$LIBTRIXI_HDF5_LIBRARY" ]; then else hdf5_libdir="$(dirname $LIBTRIXI_HDF5_LIBRARY)" fi -hdf5_library="$hdf5_libdir/libhdf5.so" +hdf5_library="$hdf5_libdir/libhdf5.$shared_library_suffix" if [ ! -f "$hdf5_library" ]; then die "hdf5 library '$hdf5_library' not found" 2 fi -hdf5_hl_library="$hdf5_libdir/libhdf5_hl.so" +hdf5_hl_library="$hdf5_libdir/libhdf5_hl.$shared_library_suffix" if [ ! -f "$hdf5_hl_library" ]; then die "hdf5 library '$hdf5_hl_library' not found" 2 fi @@ -202,7 +215,7 @@ if [ ! -f "$mpi_library" ]; then die "MPI library '$mpi_library' not found" 2 fi -# Check if libt8.so was given by the user or try to find it using Julia +# Check if libt8 was given by the user or try to find it using Julia if [ -z "$LIBTRIXI_T8CODE_LIBRARY" ]; then t8code_libdir="$($julia_exec -e 'using Libdl; find_library("libt8") |> dlpath |> dirname |> println')" if [ -z "$t8code_libdir" ]; then @@ -212,31 +225,31 @@ else t8code_libdir="$(dirname $LIBTRIXI_T8CODE_LIBRARY)" fi t8code_libdir_abs="$(cd $t8code_libdir && pwd)" -t8code_library="$t8code_libdir_abs/libt8.so" +t8code_library="$t8code_libdir_abs/libt8.$shared_library_suffix" if [ ! -f "$t8code_library" ]; then die "t8code library '$t8code_library' not found" 2 fi -# Check if libp4est.so was given by the user or else assume it is next to libt8.so +# Check if libp4est was given by the user or else assume it is next to libt8 if [ -z "$LIBTRIXI_P4EST_LIBRARY" ]; then p4est_libdir="$t8code_libdir" else p4est_libdir="$(dirname $LIBTRIXI_P4EST_LIBRARY)" fi p4est_libdir_abs="$(cd $p4est_libdir && pwd)" -p4est_library="$p4est_libdir_abs/libp4est.so" +p4est_library="$p4est_libdir_abs/libp4est.$shared_library_suffix" if [ ! -f "$p4est_library" ]; then die "p4est library '$p4est_library' not found" 2 fi -# Check if libsc.so was given by the user or else assume it is next to libt8.so +# Check if libsc was given by the user or else assume it is next to libt8 if [ -z "$LIBTRIXI_SC_LIBRARY" ]; then sc_libdir="$t8code_libdir" else sc_libdir="$(dirname $LIBTRIXI_SC_LIBRARY)" fi sc_libdir_abs="$(cd $sc_libdir && pwd)" -sc_library="$sc_libdir_abs/libsc.so" +sc_library="$sc_libdir_abs/libsc.$shared_library_suffix" if [ ! -f "$sc_library" ]; then die "sc library '$sc_library' not found" 2 fi