Skip to content

Commit 8a788db

Browse files
authored
Merge pull request #65 from rouson/update-readme
doc(README): rm ford, update intro
2 parents 8940bc6 + b6f4e1f commit 8a788db

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Overview
1212
--------
1313
This assertion utility contains four public entities:
1414

15-
1. An `assert` subroutine,
16-
2. A `characterizable_t` abstract type supporting `assert`, and
17-
3. An `intrinsic_array_t` non-abstract type extending `characterizable_t`.
18-
4. An `assert_macros.h` header file containing C-preprocessor macros.
15+
* An `assert_macros.h` file defining the recommended preprocessor macros for writing assertions:
16+
- `call_assert(assertion)`
17+
- `call_assert_describe(assertion, description)`
18+
* An `assert` subroutine
1919

2020
The `assert` subroutine
2121
* Error-terminates with a variable stop code when a caller-provided logical assertion fails,
2222
* Is callable inside `pure` procedures, and
23-
* Can be eliminated at compile-time, as controlled by the `ASSERTIONS` preprocessor define.
23+
* Can be eliminated by not defining the `ASSERTIONS` preprocessor macro.
2424

2525
Assertion enforcement is controlled via the `ASSERTIONS` preprocessor macro,
2626
which can be defined to non-zero or zero at compilation time to
@@ -164,9 +164,7 @@ fpm test --compiler nagfor --flag -fpp
164164
Documentation
165165
-------------
166166

167-
See [Assert's GitHub Pages site] for HTML documentation generated with [`ford`].
168-
169-
For further documentation, please see [example/README.md] and the [tests]. Also, the code in [src] has comments formatted for generating HTML documentation using [FORD].
167+
Please see [example/README.md] and the [tests] for examples of how to use Assert.
170168

171169
### Potential pitfalls of `call_assert` macros:
172170

@@ -178,7 +176,7 @@ of aggressively asserting invariants throughout their code, without needing to
178176
balance any potential performance cost associated with such assertions when the
179177
code runs in production.
180178

181-
Unfortunately, C-preprocessor macros do not integrate cleanly with some aspects
179+
Unfortunately, preprocessor macros do not integrate cleanly with some aspects
182180
of the Fortran language. As such, you might encounter one or more of the
183181
following pitfalls when using these macros.
184182

@@ -212,7 +210,7 @@ In the case of gfortran, this appears to have been resolved by default starting
212210
#### Line breaks in macro invocations
213211

214212
The preprocessor is not currently specified by any Fortran standard, and
215-
as of 2024 its operation differs in subtle ways between compilers.
213+
as of 2025 its operation differs in subtle ways between compilers.
216214
One way in which compilers differ is how macro invocations can safely be broken
217215
across multiple lines.
218216

@@ -286,9 +284,6 @@ See the [LICENSE](LICENSE) file for copyright and licensing information.
286284
[example/README.md]: ./example/README.md
287285
[tests]: ./tests
288286
[src]: ./src
289-
[FORD]: https://github.com/Fortran-FOSS-Programmers/ford
290287
[Fortran Package Manager]: https://github.com/fortran-lang/fpm
291288
[OCL]: https://en.wikipedia.org/wiki/Object_Constraint_Language
292-
[Assert's GitHub Pages site]: https://berkeleylab.github.io/assert/
293-
[`ford`]: https://github.com/Fortran-FOSS-Programmers/ford
294289
[example/invoke-via-macro.F90]: ./example/invoke-via-macro.F90

example/README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
Examples
22
========
33

4-
This directory contains two example programs.
4+
This directory contains several example programs.
5+
6+
Example of recommended use
7+
--------------------------
8+
The [invoke-via-macro.F90] example demonstrates the recommended ways
9+
to write assertions in code. These leverage the function-like macros
10+
`call_assert` and `call_assert_describe`. The primary advantage of
11+
using these macros is that they are completely eliminated when a file
12+
is compiled with the `ASSERTIONS` macro undefined or defined as `0`.
13+
To run this example with assertions off, use the command
14+
```
15+
fpm run --example invoke-via-macro
16+
```
17+
To run the example with assertions on, use either of the following
18+
commands:
19+
```
20+
fpm run --example invoke-via-macro --flag "-DASSERTIONS"
21+
```
522

623
Simple examples
724
---------------
@@ -39,6 +56,7 @@ or more images providing stop codes analogous to those quoted in the [Single-ima
3956
[Enforcing programming contracts]: #enforcing-programming-contracts
4057
[Single-image execution]: #single-image-execution
4158
[simple_assertions.f90]: ./simple_assertions.f90
59+
[invoke-via-macro.F90]: ./invoke-via-macro.F90
4260
[UML]: https://en.wikipedia.org/wiki/Unified_Modeling_Language
4361
[OCL]: https://en.wikipedia.org/wiki/Object_Constraint_Language
4462
[Atom]: https://atom.io

0 commit comments

Comments
 (0)