From fc8f836a22b7a5cc87b741712b77f52613b5837f Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Sat, 6 Jun 2026 17:57:32 -0400 Subject: [PATCH 01/24] add basic macos support --- .github/workflows/ci.yml | 89 ++++++++++++++++++++++++++++++ README.md | 2 +- cmake/FindJulia.cmake | 6 +- docs/src/index.md | 2 +- examples/trixi_controller_t8code.c | 6 +- utils/libtrixi-init-julia | 80 +++++++++++++++++---------- 6 files changed, 150 insertions(+), 35 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96694d49..8e61bf87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -359,3 +359,92 @@ 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 + + - 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..4e29cdd1 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 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/cmake/FindJulia.cmake b/cmake/FindJulia.cmake index 2fd2c20f..b33e8a1d 100644 --- a/cmake/FindJulia.cmake +++ b/cmake/FindJulia.cmake @@ -45,19 +45,19 @@ endif() # Get flags # execute_process( - COMMAND ${JULIA_SHARE}/julia-config.jl --cflags + COMMAND ${JULIA_EXECUTABLE} ${JULIA_SHARE}/julia-config.jl --cflags OUTPUT_VARIABLE JULIA_CFLAGS RESULT_VARIABLE RESULT ) execute_process( - COMMAND ${JULIA_SHARE}/julia-config.jl --ldflags + COMMAND ${JULIA_EXECUTABLE} ${JULIA_SHARE}/julia-config.jl --ldflags OUTPUT_VARIABLE JULIA_LDFLAGS RESULT_VARIABLE RESULT ) execute_process( - COMMAND ${JULIA_SHARE}/julia-config.jl --ldlibs + COMMAND ${JULIA_EXECUTABLE} ${JULIA_SHARE}/julia-config.jl --ldlibs OUTPUT_VARIABLE JULIA_LDLIBS RESULT_VARIABLE RESULT ) diff --git a/docs/src/index.md b/docs/src/index.md index 62f1714c..e4c8a5f4 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 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..e8d6cc1a 100755 --- a/utils/libtrixi-init-julia +++ b/utils/libtrixi-init-julia @@ -53,30 +53,28 @@ 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. --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. EOF } @@ -171,29 +169,50 @@ 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 the HDF5 library 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 - die "location of hdf5 library could not be determined automatically (use '--hdf5-library' instead)" + hdf5_library="$($julia_exec -e ' +using Libdl +path = find_library("libhdf5") +isempty(path) || println(dlpath(path))')" + if [ -z "$hdf5_library" ]; then + die "location of hdf5 library could not be determined; use --hdf5-library" fi else - hdf5_libdir="$(dirname $LIBTRIXI_HDF5_LIBRARY)" + hdf5_library="$LIBTRIXI_HDF5_LIBRARY" fi -hdf5_library="$hdf5_libdir/libhdf5.so" if [ ! -f "$hdf5_library" ]; then die "hdf5 library '$hdf5_library' not found" 2 fi -hdf5_hl_library="$hdf5_libdir/libhdf5_hl.so" +hdf5_libdir="$(dirname $hdf5_library)" +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 # Check if MPI library was given by the user or try to find it using Julia if [ -z "$LIBTRIXI_MPI_LIBRARY" ]; then - mpi_library="$($julia_exec -e 'using Libdl; find_library(["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpi_cray", "libmpitrampoline"]) |> dlpath |> println')" + mpi_library="$($julia_exec -e ' +using Libdl +libraries = ["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpi_cray", + "libmpitrampoline"] +path = find_library(libraries) +isempty(path) || println(dlpath(path))')" if [ -z "$mpi_library" ]; then - die "location of MPI library could not be determined automatically (use '--mpi-library' instead)" + die "location of MPI library could not be determined; use --mpi-library" fi else mpi_library="$LIBTRIXI_MPI_LIBRARY" @@ -202,41 +221,44 @@ 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')" + t8code_libdir="$($julia_exec -e ' +using Libdl +path = find_library("libt8") +isempty(path) || println(dirname(dlpath(path)))')" if [ -z "$t8code_libdir" ]; then - die "location of t8code library could not be determined automatically (use '--t8code-library' instead)" + die "location of t8code library could not be determined; use --t8code-library" fi 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 From 2e480fb4b08d88664778d805bfd43be82c84a1b6 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Sat, 6 Jun 2026 18:09:03 -0400 Subject: [PATCH 02/24] find fortran compiler in ci --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e61bf87..98586575 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -388,6 +388,17 @@ jobs: - 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' From 2e32c9354d4c879304a18f1d23264f9479afeab2 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Sat, 6 Jun 2026 18:28:57 -0400 Subject: [PATCH 03/24] avoid doc deploy from fork PRs --- .github/workflows/Documenter.yml | 3 +++ 1 file changed, 3 insertions(+) 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 }} From 555949c675100819679d160db2e2723805a2d2b0 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Mon, 15 Jun 2026 14:33:45 -0600 Subject: [PATCH 04/24] revert unnecessary diff --- utils/libtrixi-init-julia | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/utils/libtrixi-init-julia b/utils/libtrixi-init-julia index e8d6cc1a..e1d77aa0 100755 --- a/utils/libtrixi-init-julia +++ b/utils/libtrixi-init-julia @@ -70,11 +70,13 @@ optional arguments: Path to the p4est shared library, i.e., something like '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' 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 } @@ -182,22 +184,19 @@ case "$(uname -s)" in ;; esac -# Check if the HDF5 library was given by the user or try to find it using Julia +# Check if libhdf5 was given by the user or try to find it using Julia if [ -z "$LIBTRIXI_HDF5_LIBRARY" ]; then - hdf5_library="$($julia_exec -e ' -using Libdl -path = find_library("libhdf5") -isempty(path) || println(dlpath(path))')" - if [ -z "$hdf5_library" ]; then - die "location of hdf5 library could not be determined; use --hdf5-library" + hdf5_libdir="$($julia_exec -e 'using Libdl; find_library("libhdf5") |> dlpath |> dirname |> println')" + if [ -z "$hdf5_libdir" ]; then + die "location of hdf5 library could not be determined automatically (use '--hdf5-library' instead)" fi else - hdf5_library="$LIBTRIXI_HDF5_LIBRARY" + hdf5_libdir="$(dirname $LIBTRIXI_HDF5_LIBRARY)" fi +hdf5_library="$hdf5_libdir/libhdf5.$shared_library_suffix" if [ ! -f "$hdf5_library" ]; then die "hdf5 library '$hdf5_library' not found" 2 fi -hdf5_libdir="$(dirname $hdf5_library)" 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 @@ -205,14 +204,9 @@ fi # Check if MPI library was given by the user or try to find it using Julia if [ -z "$LIBTRIXI_MPI_LIBRARY" ]; then - mpi_library="$($julia_exec -e ' -using Libdl -libraries = ["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpi_cray", - "libmpitrampoline"] -path = find_library(libraries) -isempty(path) || println(dlpath(path))')" + mpi_library="$($julia_exec -e 'using Libdl; find_library(["libmpi", "libmpi_ibm", "msmpi", "libmpich", "libmpi_cray", "libmpitrampoline"]) |> dlpath |> println')" if [ -z "$mpi_library" ]; then - die "location of MPI library could not be determined; use --mpi-library" + die "location of MPI library could not be determined automatically (use '--mpi-library' instead)" fi else mpi_library="$LIBTRIXI_MPI_LIBRARY" @@ -223,12 +217,9 @@ fi # 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 -path = find_library("libt8") -isempty(path) || println(dirname(dlpath(path)))')" + t8code_libdir="$($julia_exec -e 'using Libdl; find_library("libt8") |> dlpath |> dirname |> println')" if [ -z "$t8code_libdir" ]; then - die "location of t8code library could not be determined; use --t8code-library" + die "location of t8code library could not be determined automatically (use '--t8code-library' instead)" fi else t8code_libdir="$(dirname $LIBTRIXI_T8CODE_LIBRARY)" From bc09f6b63957caf4b91a3ae8f5fbf867f2ab1101 Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Mon, 15 Jun 2026 14:39:50 -0600 Subject: [PATCH 05/24] fix mistakes --- README.md | 2 +- docs/src/index.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4e29cdd1..cc57ae01 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ### Prerequisites -Currently, libtrixi is developed and tested for Linux and macOS. 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 e4c8a5f4..5ad8376b 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -16,7 +16,7 @@ ### Prerequisites -Currently, libtrixi is developed and tested for Linux and macOS. 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/)) From 63bb35a14368e1bd770b90983493bdb845cc0b6b Mon Sep 17 00:00:00 2001 From: Tristan Montoya Date: Mon, 15 Jun 2026 14:47:40 -0600 Subject: [PATCH 06/24] revert other unnecessary diff --- cmake/FindJulia.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/FindJulia.cmake b/cmake/FindJulia.cmake index b33e8a1d..2fd2c20f 100644 --- a/cmake/FindJulia.cmake +++ b/cmake/FindJulia.cmake @@ -45,19 +45,19 @@ endif() # Get flags # execute_process( - COMMAND ${JULIA_EXECUTABLE} ${JULIA_SHARE}/julia-config.jl --cflags + COMMAND ${JULIA_SHARE}/julia-config.jl --cflags OUTPUT_VARIABLE JULIA_CFLAGS RESULT_VARIABLE RESULT ) execute_process( - COMMAND ${JULIA_EXECUTABLE} ${JULIA_SHARE}/julia-config.jl --ldflags + COMMAND ${JULIA_SHARE}/julia-config.jl --ldflags OUTPUT_VARIABLE JULIA_LDFLAGS RESULT_VARIABLE RESULT ) execute_process( - COMMAND ${JULIA_EXECUTABLE} ${JULIA_SHARE}/julia-config.jl --ldlibs + COMMAND ${JULIA_SHARE}/julia-config.jl --ldlibs OUTPUT_VARIABLE JULIA_LDLIBS RESULT_VARIABLE RESULT ) From 59b33326fb2cec1812a2e38c242884a9dfc74b1f Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Fri, 3 Jul 2026 23:31:56 +0200 Subject: [PATCH 07/24] check without GFORTRAN --- .github/workflows/ci.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98586575..b0c476b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -388,17 +388,6 @@ jobs: - 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' @@ -433,7 +422,7 @@ jobs: cmake --build build --parallel 2 cmake --install build - - name: Run examples + - name: Initialize project directory (test_type == 'package-compiler') run: | mkdir libtrixi-julia cd libtrixi-julia @@ -448,6 +437,9 @@ jobs: --julia-depot ~/.julia \ --skip-precompile \ --force + + - name: Run examples + run: | mkdir run-c run-f PROJECT_DIR="$PWD" LIBELIXIR_PATH="$PROJECT_DIR/libelixir_t8code2d_euler_tracer_amr.jl" From ee20cb291b288dd70746f8e98bf922b2a218e97f Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Fri, 3 Jul 2026 23:42:06 +0200 Subject: [PATCH 08/24] fix --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b0c476b3..b1dc38a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -422,7 +422,7 @@ jobs: cmake --build build --parallel 2 cmake --install build - - name: Initialize project directory (test_type == 'package-compiler') + - name: Initialize project directory run: | mkdir libtrixi-julia cd libtrixi-julia @@ -440,6 +440,7 @@ jobs: - name: Run examples run: | + cd libtrixi-julia mkdir run-c run-f PROJECT_DIR="$PWD" LIBELIXIR_PATH="$PROJECT_DIR/libelixir_t8code2d_euler_tracer_amr.jl" From be539aaa2955776571a5c70fccf9c3fdfbc56c39 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 11:42:57 +0200 Subject: [PATCH 09/24] try to integrate macos --- .github/workflows/ci.yml | 115 ++++++--------------------------------- 1 file changed, 17 insertions(+), 98 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b47d7832..f63988ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,11 @@ jobs: arch: x64 julia_version: '1.11' t8code_version: '4.0.0-26.07' + - os: macos-latest + test_type: smoke + arch: default + julia_version: '1.11' + t8code_version: '4.0.0-26.07' env: # Necessary for HDF5 to play nice with Julia LD_PRELOAD: /lib/x86_64-linux-gnu/libcurl.so.4 @@ -74,9 +79,11 @@ jobs: run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)' - name: Update `apt-get` + if: ${{ matrix.os == 'ubuntu-latest' }} run: sudo apt-get update - name: Install dependencies available with `apt-get` + if: ${{ matrix.os == 'ubuntu-latest' }} # - MPI # - HDF5 # - Google Test @@ -87,6 +94,11 @@ jobs: libgtest-dev \ lcov + - name: Install dependencies available with Homebrew + if: ${{ matrix.os == 'macos-latest' }} + run: | + brew install cmake gcc open-mpi hdf5 + - name: Install t8code if: steps.cache-t8code.outputs.cache-hit != 'true' run: | @@ -120,7 +132,7 @@ jobs: mv ../prefix/PRIVATE_HEADER/* ../prefix/include/ - name: Configure (test_type == 'regular') - if: ${{ matrix.test_type == 'regular' }} + if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'smoke'}} run: | mkdir build cd build @@ -144,13 +156,13 @@ jobs: -DENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia - name: Build - if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }} + if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' || matrix.test_type == 'smoke' }} run: | cd build make -j 2 - name: Install - if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }} + if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' || matrix.test_type == 'smoke' }} run: | cd build make install @@ -162,7 +174,7 @@ jobs: make -f MakefileExternal LIBTRIXI_PREFIX=$PWD/../install - name: Initialize project directory - if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }} + if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' || matrix.test_type == 'smoke' }} # Note that we set the Julia depot to `~/.julia` *ONLY* to make use of the # julia-actions/cache above (which unfortunately hardcoded the `~/.julia` # directory). For this reason, we also need to use `--force` @@ -266,7 +278,7 @@ jobs: LIBTRIXI_DEBUG: all - name: Run examples (test_type == 'package-compiler') - if: ${{ matrix.test_type == 'package-compiler' }} + if: ${{ matrix.test_type == 'package-compiler' || matrix.test_type == 'smoke'}} run: | cd build/examples mpirun -n 2 trixi_controller_simple_c \ @@ -366,96 +378,3 @@ 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 - - - 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: Initialize project directory - 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 - - - name: Run examples - run: | - cd libtrixi-julia - 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 From 85e95687db837e743aa95a60a571667a5a271c17 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 13:37:21 +0200 Subject: [PATCH 10/24] check if mpifort works --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f63988ff..f6043f84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,6 +113,7 @@ jobs: cmake \ -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 \ From a887f4734c07044130ed70d59a97f10450dea099 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 13:37:39 +0200 Subject: [PATCH 11/24] add comments --- .github/workflows/Documenter.yml | 1 + examples/trixi_controller_t8code.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Documenter.yml b/.github/workflows/Documenter.yml index 5f01e13b..9a9a1c1b 100644 --- a/.github/workflows/Documenter.yml +++ b/.github/workflows/Documenter.yml @@ -71,6 +71,7 @@ jobs: cd docs/doxygen doxygen - name: Deploy doxygen docs + # Only deploy on merge to `main` if: >- github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository diff --git a/examples/trixi_controller_t8code.c b/examples/trixi_controller_t8code.c index ea2a243b..32c8bed7 100644 --- a/examples/trixi_controller_t8code.c +++ b/examples/trixi_controller_t8code.c @@ -24,7 +24,7 @@ void t8_print_forest_information (t8_forest_t forest) printf ("\n*** T8code *** Local number of elements:\t%i\n", local_num_elements); - // Using PRId64 to print t8_gloidx_t portably across platforms + // Using special format specifier PRId64 to print t8_gloidx_t portably across platforms printf ("*** T8code *** Global number of elements:\t%" PRId64 "\n", global_num_elements); } From 2e65e47e23c23f582596f6be95e5608e54c4a24b Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 13:42:24 +0200 Subject: [PATCH 12/24] install gtest --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6043f84..563ffac0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -97,7 +97,7 @@ jobs: - name: Install dependencies available with Homebrew if: ${{ matrix.os == 'macos-latest' }} run: | - brew install cmake gcc open-mpi hdf5 + brew install cmake gcc open-mpi hdf5 googletest - name: Install t8code if: steps.cache-t8code.outputs.cache-hit != 'true' From fbb005029dffc25de13b26b495bc964efd314baf Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 14:21:40 +0200 Subject: [PATCH 13/24] conditionally adapt HDF5 prefix --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 563ffac0..029a1060 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -182,12 +182,17 @@ jobs: # Still create subfolder `julia-depot`, which reflects the typical default # and is tested below run: | + if [ "${{ matrix.os }}" = "macos-latest" ]; then + HDF5_LIBRARY=$(brew --prefix hdf5)/lib/libhdf5.dylib + else + HDF5_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5.so + fi mkdir libtrixi-julia cd libtrixi-julia cp ../install/share/libtrixi/LibTrixi.jl/examples/libelixir_* . mkdir julia-depot ../install/bin/libtrixi-init-julia .. \ - --hdf5-library /usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5.so \ + --hdf5-library "$HDF5_LIBRARY" \ --t8code-library ../t8code-local/prefix/lib/libt8.so \ --julia-depot ~/.julia \ --force From 453289b9501c696f37a79f3d9562d5e82c4fed6b Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 14:53:18 +0200 Subject: [PATCH 14/24] add MPI path for macos --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 029a1060..29ec2040 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -184,6 +184,7 @@ jobs: run: | if [ "${{ matrix.os }}" = "macos-latest" ]; then HDF5_LIBRARY=$(brew --prefix hdf5)/lib/libhdf5.dylib + MPI_SWITCH="--mpi-library $(brew --prefix open-mpi)/lib/libmpi.dylib" else HDF5_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5.so fi @@ -193,6 +194,7 @@ jobs: mkdir julia-depot ../install/bin/libtrixi-init-julia .. \ --hdf5-library "$HDF5_LIBRARY" \ + "$MPI_SWITCH" \ --t8code-library ../t8code-local/prefix/lib/libt8.so \ --julia-depot ~/.julia \ --force From 12e3c64c4c584c5bf29b210c839859655597fb6a Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 15:15:40 +0200 Subject: [PATCH 15/24] use bash array instead --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 29ec2040..7d703c68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -184,9 +184,10 @@ jobs: run: | if [ "${{ matrix.os }}" = "macos-latest" ]; then HDF5_LIBRARY=$(brew --prefix hdf5)/lib/libhdf5.dylib - MPI_SWITCH="--mpi-library $(brew --prefix open-mpi)/lib/libmpi.dylib" + MPI_SWITCH=(--mpi-library "$(brew --prefix open-mpi)/lib/libmpi.dylib") else HDF5_LIBRARY=/usr/lib/x86_64-linux-gnu/hdf5/openmpi/libhdf5.so + MPI_SWITCH=() fi mkdir libtrixi-julia cd libtrixi-julia @@ -194,7 +195,7 @@ jobs: mkdir julia-depot ../install/bin/libtrixi-init-julia .. \ --hdf5-library "$HDF5_LIBRARY" \ - "$MPI_SWITCH" \ + "${MPI_SWITCH[@]}" \ --t8code-library ../t8code-local/prefix/lib/libt8.so \ --julia-depot ~/.julia \ --force From d0aae80deba9e05a079b3575bc43d1290a6ee1f9 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 15:53:47 +0200 Subject: [PATCH 16/24] add a Fortran example --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d703c68..e0923d87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -264,7 +264,7 @@ jobs: LIBTRIXI_DEBUG: all LD_PRELOAD: "" # Disable preloading libcurl.so since it does not work with the JLL-provided libhdf5.so - - name: Run examples + - name: Run examples (all) if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }} run: | cd libtrixi-julia @@ -286,13 +286,16 @@ jobs: env: LIBTRIXI_DEBUG: all - - name: Run examples (test_type == 'package-compiler') + - name: Run examples (some) if: ${{ matrix.test_type == 'package-compiler' || matrix.test_type == 'smoke'}} run: | cd build/examples mpirun -n 2 trixi_controller_simple_c \ ../../libtrixi-julia \ ../../LibTrixi.jl/examples/libelixir_p4est2d_euler_sedov.jl + mpirun -n 2 trixi_controller_t8code_f \ + ../../libtrixi-julia \ + ../../LibTrixi.jl/examples/libelixir_t8code2d_euler_tracer_amr.jl env: LIBTRIXI_DEBUG: all From a93b6dc69b2f66cbd59ed6b7fff4b0138ab363fe Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Mon, 28 Sep 2026 16:43:05 +0200 Subject: [PATCH 17/24] Does PC work with t8code? --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0923d87..2e586d98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -226,6 +226,7 @@ jobs: cd build cmake .. -DCMAKE_INSTALL_PREFIX=../install \ -DCMAKE_BUILD_TYPE=Debug \ + -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ -DUSE_PACKAGE_COMPILER=ON \ -DJULIA_PROJECT_PATH=$PWD/../libtrixi-julia From 7904222a441cd6958b48f73f2dc28ae02e686cc1 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 29 Sep 2026 11:16:07 +0200 Subject: [PATCH 18/24] add option disabling fortran build --- CMakeLists.txt | 73 +++++++++++++++++++++++++++-------------- README.md | 4 ++- docs/src/developers.md | 2 +- docs/src/index.md | 4 ++- examples/CMakeLists.txt | 11 +++++-- 5 files changed, 65 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5376e94d..94631762 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,8 +23,18 @@ file(WRITE "${CMAKE_BINARY_DIR}/LIBTRIXI_VERSION" "${LIBTRIXI_VERSION}\n") project ( trixi VERSION ${LIBTRIXI_VERSION_MAJOR}.${LIBTRIXI_VERSION_MINOR}.${LIBTRIXI_VERSION_PATCH} DESCRIPTION "Interface library for using Trixi.jl from C/C++/Fortran" ) -# Enable C and Fortran -enable_language(C Fortran) +# Additional configuration options +option( LIBTRIXI_BUILD_FORTRAN_API "Enable the build of the Fortran interface" ON ) +option( LIBTRIXI_ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" OFF ) +option( LIBTRIXI_USE_PACKAGE_COMPILER "Build standalone libtrixi.so using PackageCompiler.jl" ) + +# Enable C always +enable_language( C ) + +# Optionally enable Fortran +if( LIBTRIXI_BUILD_FORTRAN_API ) + enable_language( Fortran ) +endif() # Enabling setting rpath for installation SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -47,8 +57,7 @@ endif() find_package( MPI REQUIRED ) # Find Google Test and test-drive on demand -option( ENABLE_TESTING "Build tests using Google Test (C) and test-drive (Fortran)" ) -if( ENABLE_TESTING ) +if( LIBTRIXI_ENABLE_TESTING ) if ( NOT DEFINED JULIA_PROJECT_PATH ) message( FATAL_ERROR "JULIA_PROJECT_PATH not set, tests will not work.") endif() @@ -57,22 +66,23 @@ if( ENABLE_TESTING ) find_package( GTest REQUIRED ) - set ( TEST_DRIVE_FIND_METHOD fetch ) - # Option TEST_DRIVE_BUILD_TESTING is hard-coded to ON, could be spared - find_package( test-drive REQUIRED ) + if( LIBTRIXI_BUILD_FORTRAN_API ) + set ( TEST_DRIVE_FIND_METHOD fetch ) + # Option TEST_DRIVE_BUILD_TESTING is hard-coded to ON, could be spared + find_package( test-drive REQUIRED ) + endif() endif() -# Optionally use PackageCompiler.jl to build standalone libtrixi.so -option( USE_PACKAGE_COMPILER "Build standalone libtrixi.so using PackageCompiler.jl" ) - -# Fortran mod file location -set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}) +if( LIBTRIXI_BUILD_FORTRAN_API ) + # Fortran mod file location + set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}) +endif() -if( USE_PACKAGE_COMPILER ) +if( LIBTRIXI_USE_PACKAGE_COMPILER ) if ( NOT DEFINED JULIA_PROJECT_PATH ) message( FATAL_ERROR "JULIA_PROJECT_PATH needs to be set for PackageCompiler.jl.") endif() - if ( ENABLE_TESTING ) + if ( LIBTRIXI_ENABLE_TESTING ) message( NOTICE "Testing is not supported when PackageCompiler is used.") endif() @@ -89,10 +99,12 @@ if( USE_PACKAGE_COMPILER ) COMMAND ${CMAKE_COMMAND} -E copy ${PC_INIT_SOURCE} ${PC_INIT_BUILD} DEPENDS ${PC_INIT_SOURCE} ) - # Add a library target (libtrixi), only for Fortran module - add_library( ${PROJECT_NAME} OBJECT - src/api.f90 - ) + if( LIBTRIXI_BUILD_FORTRAN_API ) + # Add a library target (libtrixi), only for Fortran module + add_library( ${PROJECT_NAME} OBJECT + src/api.f90 + ) + endif() # Custom command to run PackageCompiler.jl to produce libtrixi.so add_custom_command( OUTPUT ${PC_LIBTRIXI_SO} @@ -123,12 +135,18 @@ else() # Library target add_library ( ${PROJECT_NAME} SHARED src/api.c - src/api.f90 src/auxiliary.h src/auxiliary.c src/trixi.h ) + # Build Fortran library target on demand + if( LIBTRIXI_BUILD_FORTRAN_API ) + target_sources (${PROJECT_NAME} PRIVATE + src/api.f90 + ) + endif() + # Include directories, private target_include_directories ( ${PROJECT_NAME} PRIVATE src ) @@ -141,7 +159,10 @@ else() # Include directories - target_include_directories( ${PROJECT_NAME} PRIVATE src ${JULIA_INCLUDE_DIRS} ) + # PRIVATE: Do not include internal directory in projects building against libtrixi + # SYSTEM: Disable warnings/error from upstream libraries + target_include_directories( ${PROJECT_NAME} PRIVATE src ) + target_include_directories( ${PROJECT_NAME} SYSTEM PRIVATE ${JULIA_INCLUDE_DIRS} ) # Libraries to link target_link_libraries( ${PROJECT_NAME} PRIVATE ${JULIA_LIBRARY} ) @@ -160,13 +181,15 @@ else() add_library ( ${PROJECT_NAME}_tls OBJECT src/tls.c ) - target_include_directories( ${PROJECT_NAME}_tls PRIVATE ${JULIA_INCLUDE_DIRS} ) + target_include_directories( ${PROJECT_NAME}_tls SYSTEM ${JULIA_INCLUDE_DIRS} ) # Add test on demand - if( ENABLE_TESTING ) + if( LIBTRIXI_ENABLE_TESTING ) enable_testing() add_subdirectory( test/c ) - add_subdirectory( test/fortran ) + if( LIBTRIXI_BUILD_FORTRAN_API ) + add_subdirectory( test/fortran ) + endif() endif() @@ -183,7 +206,9 @@ set_target_properties ( ${PROJECT_NAME} PROPERTIES PUBLIC_HEADER src/trixi.h ) # Common install configuration install( TARGETS ${PROJECT_NAME} ) install( DIRECTORY LibTrixi.jl DESTINATION share/libtrixi PATTERN "lib" EXCLUDE ) -install( FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/libtrixi.mod TYPE INCLUDE) +if( LIBTRIXI_BUILD_FORTRAN_API ) + install( FILES ${CMAKE_Fortran_MODULE_DIRECTORY}/libtrixi.mod TYPE INCLUDE) +endif() install( PROGRAMS utils/libtrixi-init-julia TYPE BIN ) # Add examples diff --git a/README.md b/README.md index cc57ae01..117acb1f 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ For building, `cmake` and its typical workflow is used. - Specifying the directory `install_directory` for later installation is optional. - Optional specification of build type sets some default compiler options for optimized or debug code. + - By default the Fortran-Interface is built; it may be excluded with + `-DLIBTRIXI_BUILD_FORTRAN_API=OFF`. - Building with t8code support is optional. It requires to pass `-DT8CODE_ROOT=`. @@ -302,7 +304,7 @@ To try this out, perform the following steps: *using cmake* - Add ``` - -DUSE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH= + -DLIBTRIXI_USE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH= ``` to your cmake call (see above) 3. From inside the `examples` folder you should be able to run the example (in parallel) diff --git a/docs/src/developers.md b/docs/src/developers.md index 0f6834c3..5ddd05f0 100644 --- a/docs/src/developers.md +++ b/docs/src/developers.md @@ -50,7 +50,7 @@ For testing the C interface of libtrixi we rely on [GoogleTest](https://google.g The tests are contained in `cpp`-files located under `test/c`. They are processed by `cmake` and made available via `ctest`, provided the options ``` --DENABLE_TESTING=ON -DJULIA_PROJECT_PATH= +-DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH= ``` are passed to `cmake` during configuration. The executables can then be found under `/test/c` (they will not be installed). To run them, execute diff --git a/docs/src/index.md b/docs/src/index.md index 5ad8376b..48baaa86 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -56,6 +56,8 @@ For building, `cmake` and its typical workflow is used. - Specifying the directory `install_directory` for later installation is optional. - Optional specification of build type sets some default compiler options for optimized or debug code. + - By default the Fortran-Interface is built; it may be excluded with + `-DLIBTRIXI_BUILD_FORTRAN_API=OFF`. - Building with t8code support is optional. It requires to pass `-DT8CODE_ROOT=`. @@ -306,7 +308,7 @@ To try this out, perform the following steps: *using cmake* - Add ``` - -DUSE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH= + -DLIBTRIXI_USE_PACKAGE_COMPILER=ON -DJULIA_PROJECT_PATH= ``` to your cmake call (see above) 3. From inside the `examples` folder you should be able to run the example (in parallel) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 508fb4bf..be992e3c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,6 +17,11 @@ if ( NOT T8CODE_FOUND ) list( FILTER EXAMPLES EXCLUDE REGEX "trixi_controller_baroclinic.*" ) endif() +if (NOT LIBTRIXI_BUILD_FORTRAN_API) + # Remove Fortran files if the the Fortran API is not build + list( FILTER EXAMPLES EXCLUDE REGEX ".*\.f90" ) +endif() + foreach ( EXAMPLE ${EXAMPLES} ) get_filename_component ( EXAMPLE_EXT ${EXAMPLE} EXT ) @@ -41,7 +46,7 @@ foreach ( EXAMPLE ${EXAMPLES} ) ${TARGET_NAME} PRIVATE MPI::MPI_${EXAMPLE_LANG} ${PROJECT_NAME} ) - if ( NOT USE_PACKAGE_COMPILER ) + if ( NOT LIBTRIXI_USE_PACKAGE_COMPILER ) target_link_libraries( ${TARGET_NAME} PRIVATE ${PROJECT_NAME}_tls ) endif() if ( T8CODE_FOUND ) @@ -53,7 +58,9 @@ foreach ( EXAMPLE ${EXAMPLES} ) ${TARGET_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src ) - if ( T8CODE_FOUND ) + + if ( LIBTRIXI_BUILD_FORTRAN_API AND T8CODE_FOUND ) + # Add the t8code include directory of the Fortran module file target_include_directories( ${TARGET_NAME} PRIVATE ${T8CODE_ROOT}/include/t8_fortran_interface/ ) endif() From 13e3ed15af1dca14b17253cc2e2cbb265efd6ea3 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 29 Sep 2026 11:16:35 +0200 Subject: [PATCH 19/24] add a test with Fortran disabled --- .github/workflows/ci.yml | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e586d98..416c1472 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,7 +140,17 @@ jobs: cmake .. -DCMAKE_INSTALL_PREFIX=../install \ -DCMAKE_BUILD_TYPE=Release \ -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ - -DENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia + -DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia + + - name: Configure without Fortran (test_type == 'regular') + if: ${{ matrix.test_type == 'regular' }} + run: | + mkdir build-nofortran + cd build-nofortran + cmake .. -DCMAKE_INSTALL_PREFIX=../install-nofortran \ + -DCMAKE_BUILD_TYPE=Release \ + -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ + -LIBTRIXI_BUILD_FORTRAN_API=OFF - name: Configure (test_type == 'coverage') if: ${{ matrix.test_type == 'coverage' }} @@ -154,13 +164,15 @@ jobs: -DCMAKE_Fortran_FLAGS="-cpp --coverage -O0" \ -DCMAKE_EXE_LINKER_FLAGS="--coverage" \ -DCMAKE_SHARED_LINKER_FLAGS="--coverage" \ - -DENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia + -DLIBTRIXI_ENABLE_TESTING=ON -DJULIA_PROJECT_PATH=../libtrixi-julia - name: Build if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' || matrix.test_type == 'smoke' }} run: | cd build make -j 2 + cd ../build-nofortran + make -j 2 - name: Install if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' || matrix.test_type == 'smoke' }} @@ -227,7 +239,7 @@ jobs: cmake .. -DCMAKE_INSTALL_PREFIX=../install \ -DCMAKE_BUILD_TYPE=Debug \ -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ - -DUSE_PACKAGE_COMPILER=ON \ + -DLIBTRIXI_USE_PACKAGE_COMPILER=ON \ -DJULIA_PROJECT_PATH=$PWD/../libtrixi-julia - name: Build (test_type == 'package-compiler') @@ -300,6 +312,16 @@ jobs: env: LIBTRIXI_DEBUG: all + - name: Run C example (Fortran API disabled) + if: ${{ matrix.test_type == 'regular'}} + run: | + cd build-nofortran + mpirun -n 2 trixi_controller_simple_c \ + ../../libtrixi-julia \ + ../../LibTrixi.jl/examples/libelixir_p4est2d_euler_sedov.jl + env: + LIBTRIXI_DEBUG: all + - name: Check error handling of examples if: ${{ matrix.test_type == 'regular' || matrix.test_type == 'coverage' }} run: | From 6be7ef255633188277fb7f317e6fd14c069917bd Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 29 Sep 2026 11:17:48 +0200 Subject: [PATCH 20/24] temporarily switch to Julia 1.12 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 416c1472..4fa1fe33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: - x64 julia_version: - '1.10' - - '1.11' + - '1.12' t8code_version: - '4.0.0-26.07' include: From 448fca646bbdcdab5fe7b88d36e6023e5df24e08 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 29 Sep 2026 11:25:35 +0200 Subject: [PATCH 21/24] update minimum version --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94631762..5ee8a13b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ # Specify the minimum version # 3.9 required for regex submatches # 3.12 required for policy CMP0074 (using *_ROOT variables) -cmake_minimum_required ( VERSION 3.12 ) +# 3.13 required for policy CMP0076 (target_sources() command converts relative paths to absolute) +cmake_minimum_required ( VERSION 3.13 ) # Reconfigure if Project.toml has changed set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/LibTrixi.jl/Project.toml") From fed382510f85350112c912bc045630396b5d8446 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 29 Sep 2026 11:25:50 +0200 Subject: [PATCH 22/24] SYSTEM PRIVATE? --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ee8a13b..2e55aec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,7 +182,7 @@ else() add_library ( ${PROJECT_NAME}_tls OBJECT src/tls.c ) - target_include_directories( ${PROJECT_NAME}_tls SYSTEM ${JULIA_INCLUDE_DIRS} ) + target_include_directories( ${PROJECT_NAME}_tls SYSTEM PRIVATE ${JULIA_INCLUDE_DIRS} ) # Add test on demand if( LIBTRIXI_ENABLE_TESTING ) From 3eb3d369a10b7e37645dbfa06483e205acf19029 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 29 Sep 2026 11:27:47 +0200 Subject: [PATCH 23/24] fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4fa1fe33..03064040 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,7 @@ jobs: cmake .. -DCMAKE_INSTALL_PREFIX=../install-nofortran \ -DCMAKE_BUILD_TYPE=Release \ -DT8CODE_ROOT=$PWD/../t8code-local/prefix \ - -LIBTRIXI_BUILD_FORTRAN_API=OFF + -DLIBTRIXI_BUILD_FORTRAN_API=OFF - name: Configure (test_type == 'coverage') if: ${{ matrix.test_type == 'coverage' }} From e809d472a8d07f0577c2118249a253d1b5a403f3 Mon Sep 17 00:00:00 2001 From: Benedict Geihe Date: Tue, 29 Sep 2026 12:42:27 +0200 Subject: [PATCH 24/24] fix --- .github/workflows/ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03064040..efad5e87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: - x64 julia_version: - '1.10' - - '1.12' + - '1.11' t8code_version: - '4.0.0-26.07' include: @@ -171,7 +171,11 @@ jobs: run: | cd build make -j 2 - cd ../build-nofortran + + - name: Build without Fortran + if: ${{ matrix.test_type == 'regular' }} + run: | + cd build-nofortran make -j 2 - name: Install @@ -315,7 +319,7 @@ jobs: - name: Run C example (Fortran API disabled) if: ${{ matrix.test_type == 'regular'}} run: | - cd build-nofortran + cd build-nofortran/examples mpirun -n 2 trixi_controller_simple_c \ ../../libtrixi-julia \ ../../LibTrixi.jl/examples/libelixir_p4est2d_euler_sedov.jl