Skip to content

Conversation

@rouson
Copy link
Collaborator

@rouson rouson commented Dec 7, 2025

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

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

Description

Change Log

  1. Add 1D divergence and Laplacian operators and related types:
    • Public operators: .div. and .laplacian.
    • Derived types: divergence_1D_t and laplacian_1D_t
  2. Add operator-matrix assembly generic bindings (assemble) for the gradient_operator_1D_t and divergence_operator_1D_t derived types along with corresponding private type-bound functions that produce the assembled matrices, including zeros.
  3. Add programs in the example subdirectory:
    • print-assembled-1D-operators prints the assembled 1D gradient and divergence matrices
    • div-grad-laplacian-1D prints
      • the result of applying .grad. to a scalar_1D_t object
      • the result of applying.div. to a vector_1D_t object
      • the result of applying .laplacian. to a scalar_1D_t object
      • usage information if -- --help is appended to the above fpm command
  4. Add a UML class diagram in doc/fortran-classes.md depicting
    • User-facing derived types: scalar_1D_t, vector_1D_t, divergence_1D_t, laplacian_1D_t
    • Important internal derived types: tensor_1D_t, mimetic_matrix_1D_t, gradient_operator_1D_t, divergence_operator_1D_t
  5. Add unit tests in the test subdirectory:
    • divergence_operator_1D_test_m tests the .div. result values and convergence rates
    • laplacian_operator_1D_test_m tests the .laplacian. result values and convergence rates
  6. Chores and workarounds:
    • Work around several gfortran compiler bugs or missing features
    • Use slightly larger tolerances with ifx in two tests
    • Restrict ifx runs to a single image because MOLE Fortran uses no multi-image features but ifx defaults to multi-image execution, resulting in redundant output for test failures. (Julienne avoids duplicative reporting for passing tests.)

Related Issues & Documents

N.A.

QA Instructions, Screenshots, Recordings

LLVM

Version 20 or later

fpm test --compiler flang-new --flag "-O3"
fpm run --example div-grad-laplacian-1D --compiler flang-new --flag "-O3" -- --help
fpm run --example div-grad-laplacian-1D --compiler flang-new --flag "-O3"
fpm run --example  print-assembled-1D-operators --compiler flang-new --flag "-O3"

Version 19

Add -mmlir -allow-assumed-rank inside the double quotes into the above commands with a space separating the new flags from -O3.

GCC

Version 14 or later

fpm test --compiler gfortran --profile release
fpm run --example div-grad-laplacian-1D --compiler gfortran --profile release -- --help
fpm run --example div-grad-laplacian-1D --compiler gfortran --profile release
fpm run --example  print-assembled-1D-operators --compiler gfortran --profile release

Version 13

Append --flag -ffree-line-length-0 to the above commands, except in the one with the trailing -- --help, in which case the added flag must precede -- --help.

Intel

fpm test --compiler ifx --profile release --flag -fpp
fpm run --example div-grad-laplacian-1D --compiler fix --profile release --flag -fpp -- --help
fpm run --example div-grad-laplacian-1D --compiler fix --profile release --flag -fpp
fpm run --example  print-assembled-1D-operators --compiler gfortran --profile release

NAG

This release drops support for the nagfor compiler unless and until blocking compiler bugs have been isolated, reported, and fixed.

Added/updated tests?

  • 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

Are there any post deployment tasks we need to perform?

No.

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

1D vector fileld

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.
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 added 25 commits December 3, 2025 14:41
This commit adds

1. generic `assemble` bindings to gradient_operator_t and
   divergence_operator_t that produce the complete operator
   matrix as a 2D array, including zero values.
2. example `print-assembled-1D-operators` demonstrating the
   use of `assemble` to print the assembled matrices.

For a gradient operator matrix, G, for example, the `assemble`
computs the matrix product GI = G, where is the idenity matrix.
This approach

a. works around the fact that the MOLE Fortran data structures
   store only the non-zero submatrix blocks.
b. supports the verification of both the non-zero values (which
   were already available via `to_file_t` type-bound functions)
   and the mimetic-matrix multiplication functions.
This commit reintroduces the execution of the Laplacian operator
convergence-rate tests with all tests passing.
Usage:
  fpm run \
  --example print-assembled-1D-operators \
  --compiler flang-new \
  --flag "-O3" \
  -- [--help|-h] | [--grad]  [--div] [--order <integer>]

where square brackets indicate optional arguments and angular
brackets indicate user input values.
This commit

1. Adjusts the Laplacian convergence rate tests to check
   for the nominal convergence rate at internal grid points and
   a rate one order lower near boundaries,
2. Combines the Laplacian convergence checks int one function
   that can be called for mimetic schmes of any order, and
4. Refactors the 2nd- and 4th-order mimetic Laplacian convergence
   tests so that each calls the new unified function.
@rouson rouson marked this pull request as draft December 7, 2025 03:33
@rouson rouson marked this pull request as ready for review December 7, 2025 03:57
@rouson
Copy link
Collaborator Author

rouson commented Dec 7, 2025

@joehellmers this PR is ready for review. I'm tagging you because I don't have the permissions to designate a reviewer. It's gargantuan so I recommend just running fpm commands in the QA Instructions with the compiler of your choice. If you want to do a detailed review, let's do that interactively so I can explain some motivations and subtleties. I can also show you where and how to add 6th-order schemes with corresponding unit tests and how to expand the example programs to include any new schemes you add.

My original submission was marked draft because I expected merge conflicts, but I'm happy to see that there are none. Additionally, all tests pass so this is safe to merge.

@joehellmersNOAA joehellmersNOAA self-assigned this Dec 12, 2025
@joehellmersNOAA joehellmersNOAA merged commit 1d51241 into csrc-sdsu:dev/fortran Dec 12, 2025
31 checks passed
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