You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A simple assertion utility taking advantage of the Fortran 2018 standard's introduction of variable stop codes and error termination inside pure procedures.
4
+
A simple assertion utility taking advantage of the Fortran 2018 standard's introduction of variable stop codes
5
+
and error termination inside pure procedures.
5
6
6
7
Motivations
7
8
-----------
@@ -10,22 +11,68 @@ Motivations
10
11
11
12
Overview
12
13
--------
13
-
This assertion utility contains just one public procedure: an `assert` subroutine that
14
+
This assertion utility contains one public procedure and one public abstract type: `assert` and `characterizable_t`, respectively.
15
+
The `assert` subroutine
14
16
15
17
1. error-terminates with a variable stop code when a user-defined logical assertion fails,
16
18
2. includes user-supplied diagnostic data in the output if provided by the calling procedure,
17
19
3. is callable inside `pure` procedures, and
18
-
4. can be eliminated by an optimizing compiler through the use of a preprocessor macro: `-DUSE_ASSERTIONS=.false.`.
20
+
4. can be eliminated during an optimizing compiler's dead-code removal phase based on a preprocessor macro: `-DUSE_ASSERTIONS=.false.`.
19
21
20
-
The intended uses cases are twofold: (1) enforcing programming contracts throughout a project
21
-
and (2) providing a convenient way to get temporarily produce output for debugging purposes.o
22
+
The `characterizable_t` abstract derived type provides a mechanism for obtaining diagnostic data from a user-defined derived type that implements the `characterizable_t`'s `as_character()` deferred binding.
22
23
23
-
Contracts enforce
24
+
Use Cases
25
+
---------
26
+
1.[Enforcing programming contracts] throughout a project via runtime checks.
27
+
2. Produce output in `pure` procedures for debugging purposes.
28
+
29
+
### Enforcing programming contracts
24
30
25
31
1. Preconditions (requirements): `logical` expressions that must evaluate to `.true.` when a procedure starts execution,
26
32
2. Postconditions (assurances): expressions that must evaluate to `.false.`
27
33
3. Invariants: universal pre- and postconditions that must always be true when all procedures in a class or package start or finish executing.
28
34
29
-
Examples
30
-
--------
31
-
See [./examples](./examples).
35
+
### Examples
36
+
See the [./example](./example) subdirectory.
37
+
38
+
Downloading, Building, and Running Examples
39
+
-------------------------------------------
40
+
Prerequisites:
41
+
1. A Fortran 2018 compiler (recent Cray, Intel, GNU, and NAG compiler versions suffice).
42
+
2. The [Fortran Package Manager](https://github.com/fortran-lang/fpm).
43
+
3._Optional_: [OpenCoarrays] for parallel execution with the GNU Fortran compiler.
](https://user-images.githubusercontent.com/13108868/130385757-6b79e5f1-5dec-440c-98f5-0f659c538754.png)
0 commit comments