DNAOAD (FPM Version)

September 15, 2025 ยท View on GitHub

Dual Numbers for Arbitrary Order Automatic Differentiation in Modern Fortran

This repository provides a Fortran Package Manager (fpm) compatible version of the dual number implementation for arbitrary-order automatic differentiation (DNAOAD).

โš ๏ธ Note: The core code is essentially the same as in the original repository fpenunuri/DNAOAD, with some changes for FPM compatibility. For more information, see the preprint: ๐Ÿ“„ arXiv:2501.04159


๐Ÿ“ Project Structure

  • src/ โ€” Fortran source modules
  • app/ โ€” Executable programs
  • docs/ โ€” Documentation of module functions
  • fpm.toml โ€” Project configuration file

๐Ÿ“ฆ Requirements

  • A Fortran compiler (e.g., gfortran, ifx)
  • A recent version of fpm

To install fpm, visit:
๐Ÿ‘‰ https://github.com/fortran-lang/fpm


๐Ÿ› ๏ธ Building with ifx (default: real64)

From the project root:

FPM_FC=ifx fpm build

โ–ถ๏ธ Running Examples

Example 1 (default real64, max order = 5)

FPM_FC=ifx fpm run ex1

Example 2 (requires higher order derivatives)

By default, MAX_ORDER_DUALZN = 5. The example ex2 requires at least 10:

FPM_FC=ifx fpm run --flag "-DMAX_ORDER_DUALZN=10" ex2

โš™๏ธ Using real128 Precision

To build and run using real128 precision:

FPM_FC=ifx fpm build --flag "-DUSE_REAL128"

Run ex2 with higher derivative order:

FPM_FC=ifx fpm run --flag "-DUSE_REAL128 -DMAX_ORDER_DUALZN=10" ex2