Skip to content

Commit 71c30d9

Browse files
authored
Merge pull request #67 from rouson/update-readme
Documentation: Describe use case & cite Julienne
2 parents aa8dbf2 + 12e6fce commit 71c30d9

File tree

1 file changed

+33
-8
lines changed

1 file changed

+33
-8
lines changed

README.md

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ When the `ASSERTIONS` preprocessor macro is not defined to any value,
3030
the default is that assertions are *disabled* and will not check the condition.
3131

3232
To enable assertion enforcement (e.g., for a debug build), define the
33-
preprocessor ASSERTIONS to non-zero, eg:
33+
preprocessor ASSERTIONS to non-zero, e.g.,
3434
```
3535
fpm build --flag "-DASSERTIONS"
3636
```
@@ -45,8 +45,22 @@ Use Cases
4545
---------
4646
Two common use cases include
4747

48-
1. [Enforcing programming contracts] throughout a project via runtime checks.
49-
2. Producing output in `pure` procedures for debugging purposes.
48+
1. [Supporting output in pure procedures] for debugging purposes.
49+
2. [Enforcing programming contracts] throughout a project via runtime checks.
50+
51+
### Supporting output in pure procedures
52+
Writing pure procedures communicates useful information to a compiler or a developer.
53+
Specifically, the pure attribute conveys compliance with several constraints that clarify data dependencies and preclude most side effects.
54+
For a compiler, these constraints support optimizations, including automatic parallelization on a central processing unit (CPU) or offloading to a graphics processing unit (GPU).
55+
For a developer, the constraints support refactoring tasks such as code movement.
56+
57+
The Fortran standard prohibits input or output in pure procedures, which precludes a common debugging mechanism.
58+
A developer seeking output inside a procedure presumably has an expectation regarding what ranges of output values represent correct program execution.
59+
A developer can state such expectations in an assertion such as `call_assert(i>0 .and. j<0)`.
60+
Enforce the assertion by defining the `ASSERTIONS` macro when compiling.
61+
If the expectation is not met, the program error terminates and prints a stop code showing the assertion's file and line location and a description.
62+
By default, the description is the literal text of what was asserted: `i>0 .and. j<0` in the aforementioned example.
63+
Alternatively, the user can provide a custom description.
5064

5165
### Enforcing programming contracts
5266
Programming can be thought of as requirements for correct execution of a procedure and assurances for the result of correct execution.
@@ -193,17 +207,17 @@ limit. This can result in compile-time errors like the following from gfortran:
193207
Error: Line truncated at (1) [-Werror=line-truncation]
194208
```
195209

196-
Some compilers offer a command-line argument that can be used to workaround this legacy limit, eg:
210+
Some compilers offer a command-line argument that can be used to workaround this legacy limit, e.g.,
197211

198-
* `gfortran -ffree-line-length-0` aka `gfortran -ffree-line-length-none`
212+
* `gfortran -ffree-line-length-0` or equivalently `gfortran -ffree-line-length-none`
199213

200-
When using `fpm`, one can pass such a flag to the compiler using the `fpm --flag` option, eg:
214+
When using `fpm`, one can pass such a flag to the compiler using the `fpm --flag` option, e.g.,
201215

202216
```shell
203217
$ fpm test --profile release --flag -ffree-line-length-0
204218
```
205219

206-
Thankfully Fortran 2023 raised this obscolecent line limit to 10,000
220+
Thankfully, Fortran 2023 raised this obsolescent line limit to 10,000
207221
characters, so by using newer compilers you might never encounter this problem.
208222
In the case of gfortran, this appears to have been resolved by default starting in release 14.1.0.
209223

@@ -273,6 +287,16 @@ call_assert_describe( computed_checksum == expected_checksum, \
273287
) ! TODO: write a better message above
274288
```
275289

290+
Clients of Assert
291+
-----------------
292+
293+
A few packages that use Assert include
294+
295+
* The [Julienne](https://go.lbl.gov/julienne) correctness-checking framework wraps Assert and defines idioms that automatically generate diagnostic messages containing program data.
296+
* The [Caffeine](https://go.lbl.gov/caffeine) multi-image Fortran compiler runtime library uses Assert for internal sanity checks and interface validation.
297+
* The [Fiats](https://go.lbl.gov/fiats) deep learning library uses Assert and Julienne.
298+
* The [Matcha](https://go.lbl.gov/matcha) T-cell motility simulator also uses Assert and Julienne.
299+
276300
Legal Information
277301
-----------------
278302
See the [LICENSE](LICENSE) file for copyright and licensing information.
@@ -283,7 +307,8 @@ See the [LICENSE](LICENSE) file for copyright and licensing information.
283307
[Single-image execution]: #single-image-execution
284308
[example/README.md]: ./example/README.md
285309
[tests]: ./tests
286-
[src]: ./src
287310
[Fortran Package Manager]: https://github.com/fortran-lang/fpm
288311
[OCL]: https://en.wikipedia.org/wiki/Object_Constraint_Language
289312
[example/invoke-via-macro.F90]: ./example/invoke-via-macro.F90
313+
[Producing output in pure procedures]: #producing-output-in-pure-procedures
314+
[Julienne]: https://go.lbl.gov/julienne

0 commit comments

Comments
 (0)