README.md
May 5, 2026 · View on GitHub
ForDebug: A Fortran library designed for debugging Fortran code, especially within pure procedures.
fpm dependency
If you want to use ForDebug as a dependency in your own fpm project,
you can easily include it by adding the following line to your fpm.toml file:
[dependencies]
fordebug = {git="https://github.com/gha3mi/fordebug.git"}
Usage
Error / Warning / Info Control
use fordebug, only: debug
type(debug) :: err
call err%set(&
severity = 1, &
code = 100, &
category = "math", &
message = "division by zero", &
location = my_module.f90:11, &
suggestion = "Check denominator for zero." )
call err%print()
call err%reset()
Notes
- Define
FOR_DEBUGpreprocessor directive to enable error/warning/info control.
Printing or Writing within Pure Procedures
To enable printing or writing within a pure procedure in Fortran, use the fordebug module.
use fordebug, only: pwrite
! within pure procedures
call pwrite(message='hello!')
call pwrite(R0i32=n)
call pwrite(message='x = ', R0r32=10.0, format='(a,f7.3)', file='example/demo.txt', access='append')
Notes
- All arguments of
pwriteare optional. - Data types are represented using the following conventions:
R0i32,R0i64,R0r32,R0r64,R0c32,R0c64for Rank 0 integer, real, and complex types.R1i32,R1i64,R1r32,R1r64,R1c32,R1c64for Rank 1 integer, real, and complex types.R2i32,R2i64,R2r32,R2r64,R2c32,R2c64for Rank 2 integer, real, and complex types.R0chfor Rank 0 character.
Measuring Elapsed Time within Pure Procedures
ForDebug uses ForTmie as dependency. For measuring elapsed time within a pure procedure, utilize the fordebug module with time derived type.
use fordebug, only: timer, ptimer_start, ptimer_stop
type(timer) :: t
call ptimer_start(t)
! Perform your operations here
call ptimer_stop(t) ! Output: Elapsed time: 0.000 [s]
How to run examples
Clone the repository:
Clone the ForDebug repository from GitHub using the following command:
git clone https://github.com/gha3mi/fordebug.git
Navigate to the cloned directory:
cd fordebug
Running examples
To run all examples, execute the following command:
fpm run --example --all --flag "-DFOR_DEBUG"
Status
| OS | Compiler | Version | fpm | cmake |
|---|---|---|---|---|
| ubuntu 24.04 | flang-new | 22.1.4 | 0.13.0 ✅ | 4.3.2 ✅ |
| ubuntu 24.04 | gfortran | 15.2.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| ubuntu 24.04 | ifx | 2026.0.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| ubuntu 24.04 | nvfortran | 26.3 | 0.13.0 ✅ | 4.3.2 ✅ |
| macos 15 | gfortran | 15.2.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| windows 2025 | flang-new | 22.1.4 | 0.13.0 ✅ | 4.3.2 ❌ |
| windows 2025 | gfortran | 15.2.0 | 0.13.0 ✅ | 4.3.2 ✅ |
| windows 2025 | ifx | 2026.0.0 | 0.12.0 ✅ | 4.3.2 ❌ |
API documentation
The most up-to-date API documentation for the master branch is available
here.
To generate the API documentation for ForDebug using
ford run the following
command:
ford README.yml
Contributing
Contributions to ForDebug are welcome!
If you find any issues or would like to suggest improvements, please open an issue.