From 84f2cf9c9fc53ecf6bda2c7faec554bbeb8e6e8e Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Mon, 19 Jan 2026 20:55:18 -0800 Subject: [PATCH 1/7] feat(Formal): add submodule in src/fortran This commit adds a git submodule containing the initial Formal (https://github.com/berkeleylab/formal) Fortran implementations of mimetic discretizations. --- .gitmodules | 3 +++ src/fortran | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 src/fortran diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..a83192c3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/fortran"] + path = src/fortran + url = https://github.com/berkeleylab/formal diff --git a/src/fortran b/src/fortran new file mode 160000 index 00000000..c776f815 --- /dev/null +++ b/src/fortran @@ -0,0 +1 @@ +Subproject commit c776f815211616fc6bdb00ae8ea27f4c877f6803 From f5694127e571cc6b7ccd036c94db3a1047d97bfb Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Fri, 23 Jan 2026 18:54:33 -0800 Subject: [PATCH 2/7] chore(.gitmodules): rename submodule This commit differentiates the submodule name from the path. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index a83192c3..81a6b73a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "src/fortran"] +[submodule "fortran"] path = src/fortran url = https://github.com/berkeleylab/formal From cb914b391d96cf412c185cbdada3c4cfd7ce65c7 Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Sat, 24 Jan 2026 11:22:53 -0800 Subject: [PATCH 3/7] build(fpm): add fpm manifest This commit adds an "fpm.toml" file in the root source directory, which enables the following command to build MOLE's C++ and Fortran libraries, including their prerequisites: fpm install --profile release --flag "-I./src/fortran/include" where it is assumed that the "formal" git submodule has been cloned into "src/fortran" by, for example, executing git submodule update --init --recursive --- fpm.toml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 fpm.toml diff --git a/fpm.toml b/fpm.toml new file mode 100644 index 00000000..546eec33 --- /dev/null +++ b/fpm.toml @@ -0,0 +1,8 @@ +name = "mole" + +[dependencies] +armadillo-code = {git = "https://gitlab.com/rouson/armadillo-code.git", tag = "fpm"} +julienne = {git = "https://github.com/berkeleylab/julienne.git", tag = "3.6.0"} + +[install] +library = true From 9bbead7bd0f7c77281a4e601f0e24eb31f37dc6d Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Sat, 24 Jan 2026 11:30:54 -0800 Subject: [PATCH 4/7] doc(README): add fortran implementation info --- README.md | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2a5e70d4..b685fdce 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,13 @@ ## Description -MOLE is a high-quality (C++ & MATLAB/Octave) library that implements +MOLE is a high-quality (C++, MATLAB/Octave, or Fortran) library that implements high-order mimetic operators to solve partial differential equations. It provides discrete analogs of the most common vector calculus operators: Gradient, Divergence, Laplacian, Bilaplacian, and Curl. These operators (highly sparse matrices) act on staggered grids (uniform, non-uniform, curvilinear) and satisfy local and -global conservation laws. +global conservation laws. Fortran programs invoke mimetic operators via +defined operations: `.div. v`, `.grad. f`, and `.laplacian. f`, for exmaple. Mathematics is based on the work of [Corbino and Castillo](https://doi.org/10.1016/j.cam.2019.06.042). However, the user may find helpful previous publications, such as [Castillo and Grone](https://doi.org/10.1137/S0895479801398025), @@ -22,6 +23,7 @@ in which similar operators were derived using a matrix analysis approach. ## Installation ### Platform and Compiler Compatibility +#### C++ Refer to the table below for compiler support across different operating systems when building MOLE. | OS / Compiler | GCC 13.2.0 | AppleClang | IntelLLVM (icpx) | @@ -29,9 +31,13 @@ Refer to the table below for compiler support across different operating systems | Linux | Yes | No | Yes | | macOS | No | Yes | Yes | -### Prerequisites +#### Fortran +The Fortran implementation supports recent versions of the GCC (`gfortran`), Intel (`ifx`), +LLVM (`flang`), and NAG (`nagfor`) compilers on macOS and Ubuntu Linux. -To install the MOLE library, you'll need the following packages: +### Prerequisites +#### C++ +To install MOLE's C++ library, you'll need the following packages: - CMake (Minimum version 3.10) - OpenBLAS (Minimum version 0.3.10) @@ -41,8 +47,27 @@ To install the MOLE library, you'll need the following packages: For documentation build requirements, please refer to the [Documentation Guide](https://github.com/csrc-sdsu/mole/blob/main/doc/sphinx/README.md). +#### Fortran +To install MOLE's Fortran library, you'll need the Fortran Package Manager ([`fpm`](https://github.com/fortran-lang/fpm)), +which will automatically download and build all prerequisites. + ### Package Installation by OS +#### Fortran +On macOS, Linux, or Windows with `git` and `fpm` installed, +``` +git clone https://github.com/csrc-sdsu/mole +cd mole +git submodule update --init --recursive +fpm install --profile release --flag "-I./src/fortran/include" +``` +which builds with the compiler specified by the `FPM_FC` environment variable +of with `gfortran` if `FPM_FC` is empty. For `fpm` commands to use with other +supported compilers, please consult `src/fortran/README.md` _after_ running +the above `git submodule` command to ensure `src/fortran` exists. + +#### C++ + #### Ubuntu/Debian Systems ```bash @@ -110,9 +135,8 @@ sudo yum install cmake openblas-devel eigen3-devel lapack ## Testing -Run from the `build` directory: - ### C++ +Run from the `build` directory: A suite of four automatic tests that verify MOLE's installation and dependencies. These tests run automatically during the C++ library construction. @@ -121,11 +145,17 @@ make run_tests ``` ### MATLAB/Octave +Run from the `build` directory: MATLAB/Octave equivalent of the C++ test suite. We recommend running these tests before using MOLE to ensure proper setup. ```matlab make run_matlab_octave_tests + +### Fortran +Run from the `src/fortran` directory: +``` +fpm test ``` ## Examples From d81c3701ff1495353a233dd8d11a62f9b08120f1 Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Sat, 24 Jan 2026 11:51:03 -0800 Subject: [PATCH 5/7] doc(README): info on running Fortran examples --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b685fdce..db6003a4 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,15 @@ brew install gnuplot ``` and on Windows downlaoding and running the file from [here](https://sourceforge.net/projects/gnuplot/files/gnuplot/6.0.2/gp602-win64-mingw.exe/download) +### Fortran +With your present working directory set to anywhere inside the `src/fortran` directory, run +``` +fpm run --example [] +``` +where square brackets desginate an optional argument, angular brackets indicate user input, +and `` is the string preceding the `.F90` extension in the name of any file in +the `src/fortran/example` directory. + ### C++ Four self-contained, well-documented examples demonstrating typical PDE solutions. These are automatically built with `make` and serve as an excellent starting point for C++ users. From fa74eb3ad486dda15d89dcfeb9067006b507ce25 Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Sat, 24 Jan 2026 12:45:47 -0800 Subject: [PATCH 6/7] build(fpm): simplify workflow Now `fpm install` works without additional arguments. --- README.md | 6 +++--- fpm.toml | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index db6003a4..8a1e80de 100644 --- a/README.md +++ b/README.md @@ -59,12 +59,12 @@ On macOS, Linux, or Windows with `git` and `fpm` installed, git clone https://github.com/csrc-sdsu/mole cd mole git submodule update --init --recursive -fpm install --profile release --flag "-I./src/fortran/include" +fpm install ``` which builds with the compiler specified by the `FPM_FC` environment variable -of with `gfortran` if `FPM_FC` is empty. For `fpm` commands to use with other +or with `gfortran` if `FPM_FC` is empty. For `fpm` commands to use with other supported compilers, please consult `src/fortran/README.md` _after_ running -the above `git submodule` command to ensure `src/fortran` exists. +the above `git submodule` command to populate the contents of `src/fortran`. #### C++ diff --git a/fpm.toml b/fpm.toml index 546eec33..75e48ae7 100644 --- a/fpm.toml +++ b/fpm.toml @@ -6,3 +6,7 @@ julienne = {git = "https://github.com/berkeleylab/julienne.git", tag = "3.6.0"} [install] library = true + +[library] +source-dir = "src/fortran" +include-dir = "src/fortran/include" From bc4fa2c22988cc9c9c336147682070e71ccb83e8 Mon Sep 17 00:00:00 2001 From: Damian Rouson Date: Sat, 24 Jan 2026 13:29:50 -0800 Subject: [PATCH 7/7] test(fortran): enable/document `fpm test` --- README.md | 2 +- fpm.toml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a1e80de..214884e9 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ MATLAB/Octave equivalent of the C++ test suite. We recommend running these tests make run_matlab_octave_tests ### Fortran -Run from the `src/fortran` directory: +Run from anywhwere in the MOLE source tree: ``` fpm test ``` diff --git a/fpm.toml b/fpm.toml index 75e48ae7..c984b353 100644 --- a/fpm.toml +++ b/fpm.toml @@ -10,3 +10,8 @@ library = true [library] source-dir = "src/fortran" include-dir = "src/fortran/include" + +[[test]] +name = "test_suite_driver" +source-dir = "src/fortran/test" +main = "driver.f90"