Skip to content

Conversation

@rouson
Copy link

@rouson rouson commented Oct 10, 2025

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Example
  • Documentation

Description

This PR adds 2nd- and 4th-order 1D gradient operators and associated unit tests.

Related Issues & Documents

N.A.

QA Instructions, Screenshots, Recordings

fpm test --compiler flang-new --flag -O3

or

fpm test --compiler gfortran --profile release

which currently works with GCC 15. I need to insert some workarounds to support GCC 13 and 14.

Either of the above commands should yield trailing output similar to the following:

A 1D mimetic gradient operator
   passes on computing 2nd- & 4th-order 1D gradients of a constant within tolerance 0.1000000000000E-13.
   passes on computing 2nd- & 4th-order 1D gradients of a line within tolerance 0.1000000000000E-11.
   passes on computing 2nd- & 4th-order 1D gradients of a parabola within tolerance 0.1000000000000E-11.
   passes on computing 2nd-order 1D gradients of a sinusoid with a convergence rate of 2 within tolerance 0.5000000000000E-01.
   passes on computing 4th-order 1D gradients of a sinusoid with a convergence rate of 4 within tolerance 0.5000000000000E-01.
 5 of 5 tests passed. 0 tests were skipped.

Test-suite run time:   1.40E-03 seconds
Number of images: 1

_____ 5 of 5 tests passed. 0 tests were skipped _____

Added/updated tests?

_We encourage you to test all code included with MOLE, including examples.

  • Yes
  • No, and this is why: please replace this line with details on why tests
    have not been included
  • I need help with writing tests

Read Contributing Guide and Code of Conduct

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

🥳

This commit enables the building of MOLE with the command
"fpm build".
This commit enables "fpm install" to install the MOLE library.
For example,

fpm install --prefix ~/.local

creates "~/.local/lib/libMOLE.a".
This commit adds
* A grad_op_{m,s} module and submodule in src/fortran
* A corresponding test suite in a new "test" subdirectory

The grad_op module & submodule define a grad_op_t derived type
and a stub constructor that can be invoked as grad_op_t(k,m,dx),
where k, m, and dx are the order of accuracy, number of cells,
and step size.  The test simply verifies that the constructor
executes.
This commit works around a missing Fortran 2008 feature that
was added to gfortran in version 14.3.
This commit
1. Switchese from git@ to https:// in URLs to support users who
   don't have SSH keys on GitHub.
2. Updates the Julienne version to 3.1.3 for better output
   formatting.
This commit updates the Julienne dependency to version 3.1.4, which
works around an issue in the NAG Fortran compiler version 7.2,
Build 7235.
This commit updates the Julienne dependency to version 3.1.5, which
works around an issue in the Intel ifx compiler version 2025.1.2,
Build 20250806.
This commit contains

* mimetic_matrix_t:
  - encapsulates the non-zero mimetic-discretization matrix coefficients
* face_values_t:
  - encapsulates face-centered values
* gradient_operator_t:
  - renamed from grad_op_t
  - contains a mimetic_matrix_t component
  - provides `.grad. face_values_t` via `mimetic_matrix_t .x. face_values_t`
* gradient_t:
  - result of .grad. face_values_t
* unit test edits reflecting the renamed gradient_operator_t
combine all types into one module family tree:

face_values_m module
|-- mimetic_matrix_s submodule
|-- gradient_operator_s submodule
|-- gradient_s submodule
This commit adds a passing test of computing the gradient of a
linear function using the 1D mimetic gradient operater defined in
Corbino & Castillo (2019).
This commit
1. Synchronizes a conditionally compiled
   gfortran workaround to match the updated alternative block.
2. Updates the unit test to work around a gfortran issue with
   `associate`.
This commit fixes issues with the matrix-vector multiplication
function "matvec" to ensure infers the loop limits and array
section bounds from the dimensions of the arrays accessed by the
loop or array section.
rouson added 19 commits October 8, 2025 10:46
This commit adds the ability to convert a mimetic matrix to a
Julienne file_t object so that the matrix elements can be printed
with code like the following

  type(mimetic_matrix_t) mimetic_matrix
  ! define matrix here
  associate(file => mimetic_matrix%to_file_t())
    call file%write_lines()
  end associate
Now all tests pass for computing 1D gradients of 0th, 1st, &
2nd-order polynomials, each with mimetic discretizations of
2nd- and 4th-order accuracy.
This commit adds tests of the ratio of the log of the maximum
absolute error for gradients of a sinusoidal function.  The tests
verify that 2nd- and 4th-order mimetic discretizations converge
to the expected gradient values at a rate proportional to dx raised
to the 2nd and 4th powers of the error within a tolerance of 5%.
To work around gfortran-14 not supporting `do concurrent` locality
specifiers, this commit removes specifiers conditionally via a new
macro: HAVE_LOCALITY_SPECIFIER_SUPPORT defined in
include/mole-language-support.F90.
@rouson rouson marked this pull request as ready for review October 12, 2025 18:55
@rouson
Copy link
Author

rouson commented Oct 12, 2025

@joehellmers I have removed the Draft status from this PR. It's now ready for review and merging. On my macOS laptop, all tests pass with

  • gfortran 13.4.0, 14.3.0, and 15.2.0
  • flang-new 22.0.0git

@rouson rouson force-pushed the gradient-operator branch from 6d3b83b to 1a1b502 Compare October 13, 2025 06:20
@rouson rouson force-pushed the gradient-operator branch from 1a1b502 to 3cc1e81 Compare October 13, 2025 06:21
@joehellmersNOAA
Copy link
Collaborator

@rouson I think we need to make dev/fortran the target branch for this PR.

@rouson
Copy link
Author

rouson commented Oct 15, 2025

@joehellmersNOAA oops! That was my intention. I'll close this and open a new one against dev/fortran.

@rouson rouson closed this Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants