@@ -19,7 +19,6 @@ This assertion utility contains four public entities:
19
19
20
20
The ` assert ` subroutine
21
21
* Error-terminates with a variable stop code when a caller-provided logical assertion fails,
22
- * Includes user-supplied diagnostic data in the output if provided by the calling procedure,
23
22
* Is callable inside ` pure ` procedures, and
24
23
* Can be eliminated at compile-time, as controlled by the ` ASSERTIONS ` preprocessor define.
25
24
@@ -42,10 +41,6 @@ If instead `fpm install` is used, then either the user must copy `include/assert
42
41
the user must invoke ` assert ` directly (via ` call assert(...) ` ).
43
42
In the latter approach when the assertions are disabled, the ` assert ` procedure will start and end with ` if (.false.) then ... end if ` , which might facilitate automatic removal of ` assert ` during the dead-code removal phase of optimizing compilers.
44
43
45
- The ` characterizable_t ` type defines an ` as_character() ` deferred binding that produces ` character ` strings for use as diagnostic output from a user-defined derived type that extends ` characterizable_t ` and implements the deferred binding.
46
-
47
- The ` intrinsic_array_t ` type that extends ` characterizable_t ` provides a convenient mechanism for producing diagnostic output from arrays of intrinsic type ` complex ` , ` integer ` , ` logical ` , or ` real ` .
48
-
49
44
Use Cases
50
45
---------
51
46
Two common use cases include
@@ -63,27 +58,49 @@ The requirements and assurances might be constraints of three kinds:
63
58
64
59
The [ example/README.md] file shows examples of writing constraints in notes on class diagrams using the formal syntax of the Object Constraint Language ([ OCL] ).
65
60
66
- Downloading, Building, and Running Examples
67
- -------------------------------------------
61
+ Running the Examples
62
+ --------------------
63
+ See the [ ./example] ( ./example ) subdirectory.
64
+
65
+ Building and Testing
66
+ --------------------
67
+
68
+ - [ Cray Compiler Environment (CCE) ` ftn ` ] ( #cray-compiler-environment-cce-ftn )
69
+ - [ GNU Compiler Collection (GCC) ` gfortran ` ] ( #gnu-compiler-collection-gcc-gfortran ) )
70
+ - [ Intel ` ifx ` ] ( #intel-ifx ) )
71
+ - [ LFortran ` lfortran ` ] ( #lfortran-lfortran )
72
+ - [ LLVM ` flang-new ` ] ( #llvm-flang-new )
73
+ - [ Numerical Algorithms Group (NAG) ` nagfor ` ] ( #numerical-algorithms-group-nag-nagfor )
74
+
75
+ ### Cray Compiler Environment (CCE) ` ftn `
76
+ Because ` fpm ` uses the compiler name to determine the compiler identity and because
77
+ CCE provides one compiler wrapper, ` ftn ` , for invoking all compilers, you will
78
+ need to invoke ` ftn ` in a shell script named to identify CCE compiler. For example,
79
+ place a script named ` crayftn.sh ` in your path with the following contents and with
80
+ executable privileges set appropriately:
81
+ ```
82
+ #!/bin/bash
68
83
69
- ### Downloading Assert
84
+ ftn $@
70
85
```
71
- git clone git@github.com:berkeleylab/assert
72
- cd assert
86
+ Then build and test Assert with the command
87
+ ```
88
+ fpm test --compiler crayftn.sh --profile release
73
89
```
74
90
75
- ### Building and testing with ` gfortran `
91
+ ### GNU Compiler Collection (GCC) ` gfortran `
92
+
76
93
#### Single-image (serial) execution
77
- The command below builds Assert and runs the full test suite in a single image.
78
- For ` gfortran ` 14 or later, use
94
+ With ` gfortran ` 14 or later, use
79
95
```
80
96
fpm test --profile release
81
97
```
82
- For ` gfortran ` 13 or earlier, use
98
+ With ` gfortran ` 13 or earlier, use
83
99
```
84
100
fpm test --profile release --flag "-ffree-line-length-0"
85
101
```
86
102
The above commands build the Assert library (with the default of assertion enforcement disabled) and runs the test suite.
103
+
87
104
#### Multi-image (parallel) execution
88
105
With ` gfortran ` 14 or later versions and OpenCoarrays installed, use
89
106
```
@@ -93,60 +110,56 @@ With `gfortran` 13 or earlier versions and OpenCoarrays installed,
93
110
```
94
111
fpm test --compiler caf --profile release --runner "cafrun -n 2" --flag "-ffree-line-length-0"
95
112
```
96
- To build and test with the Numerical Algorithms Group (NAG) Fortran compiler version
97
- 7.1 or later, use
98
- ```
99
- fpm test --compiler=nagfor --profile release --flag "-coarray=cosmp -fpp -f2018"
100
- ```
101
113
102
- ### Building and testing with the Intel ` ifx ` compiler
114
+ ### Intel ` ifx `
115
+
103
116
#### Single-image (serial) execution
104
117
```
105
118
fpm test --compiler ifx --profile release
106
119
```
120
+
107
121
#### Multi-image (parallel) execution
108
122
With Intel Fortran and Intel MPI installed,
109
123
```
110
124
fpm test --compiler ifx --profile release --flag "-coarray -DASSERT_MULTI_IMAGE"
111
125
```
112
126
113
- ### Building and testing with the LLVM ` flang-new ` compiler
114
- #### LLVM version 19
127
+ ### LLVM ` flang-new `
128
+
129
+ #### Single-image (serial) execution
130
+ With ` flang-new ` version 19, use
115
131
```
116
132
fpm test --compiler flang-new --flag "-mmlir -allow-assumed-rank -O3"
117
133
```
118
- #### LLVM version 20 or later
134
+ With ` flang-new ` version 20 or later, use
119
135
```
120
136
fpm test --compiler flang-new --flag "-O3"
121
137
```
122
138
123
- ### Building and testing with the Numerical Algorithms Group (NAG) compiler
139
+ ### LFortran ` lfortran `
140
+
141
+ #### Single-image (serial) execution
124
142
```
125
- fpm test --compiler nagfor --profile release --flag "-fpp -coarray=cosmp"
143
+ fpm test --compiler lfortran --profile release --flag --cpp
126
144
```
127
145
128
- ### Building and testing with the Cray Compiler Environment (CCE)
129
- Because ` fpm ` uses the compiler name to determine the compiler identity and because
130
- CCE provides one compiler wrapper, ` ftn ` , for invoking all compilers, you will
131
- need to invoke ` ftn ` in a shell script named to identify CCE compiler. For example,
132
- place a script named ` crayftn.sh ` in your path with the following contents and with
133
- executable privileges set appropriately:
146
+ ### Numerical Algorithms Group (NAG) ` nagfor `
147
+
148
+ #### Single-image (serial) execution
149
+ With ` nagfor ` version 7.1 or later, use
150
+ ```
151
+ fpm test --compiler nagfor --flag -fpp
134
152
```
135
- #!/bin/bash
136
153
137
- ftn $@
154
+ #### Multi-image execution
155
+ With ` nagfor ` 7.1, use
138
156
```
139
- Then build and test Assert with the command
157
+ fpm test --compiler nagfor --profile release --flag "-fpp -coarray=cosmp -f2018"
140
158
```
141
- fpm test --compiler crayftn.sh --profile release
159
+ With ` nagfor ` 7.2 or later, use
160
+ ```
161
+ fpm test --compiler nagfor --flag -fpp
142
162
```
143
-
144
-
145
- ### Building and testing with other compilers
146
- To use Assert with other compilers, please submit an issue or pull request.
147
-
148
- ### Running the examples
149
- See the [ ./example] ( ./example ) subdirectory.
150
163
151
164
Documentation
152
165
-------------
@@ -208,19 +221,19 @@ character for line-breaks in a macro invocation:
208
221
209
222
``` fortran
210
223
! OK for flang-new and gfortran
211
- call_assert_diagnose ( computed_checksum == expected_checksum, \
212
- "Checksum mismatch failure!", \
213
- expected_checksum )
224
+ call_assert_describe ( computed_checksum == expected_checksum, \
225
+ "Checksum mismatch failure!" \
226
+ )
214
227
```
215
228
216
229
Whereas Cray Fortran wants ` & ` line continuation characters, even inside
217
230
a macro invocation:
218
231
219
232
``` fortran
220
233
! OK for Cray Fortran
221
- call_assert_diagnose ( computed_checksum == expected_checksum, &
222
- "Checksum mismatch failure!", &
223
- expected_checksum )
234
+ call_assert_describe ( computed_checksum == expected_checksum, &
235
+ "Checksum mismatch failure!" &
236
+ )
224
237
```
225
238
226
239
There appears to be no syntax acceptable to all compilers, so when writing
@@ -237,29 +250,29 @@ after macro expansion (on gfortran and flang-new):
237
250
238
251
``` fortran
239
252
! INCORRECT: cannot use Fortran comments inside macro invocation
240
- call_assert_diagnose ( computed_checksum == expected_checksum, ! ensured since version 3.14
241
- "Checksum mismatch failure!", ! TODO: write a better message here
242
- computed_checksum )
253
+ call_assert_describe ( computed_checksum == expected_checksum, ! ensured since version 3.14
254
+ "Checksum mismatch failure!" ! TODO: write a better message here
255
+ )
243
256
```
244
257
245
258
Depending on your compiler it * might* be possible to use a C-style block
246
259
comment (because they are often removed by the preprocessor), for example with
247
260
gfortran one can instead write the following:
248
261
249
262
``` fortran
250
- call_assert_diagnose ( computed_checksum == expected_checksum, /* ensured since version 3.14 */ \
251
- "Checksum mismatch failure!", /* TODO: write a better message here */ \
252
- computed_checksum )
263
+ call_assert_describe ( computed_checksum == expected_checksum, /* ensured since version 3.14 */ \
264
+ "Checksum mismatch failure!" /* TODO: write a better message here */ \
265
+ )
253
266
```
254
267
255
268
However that capability might not be portable to other Fortran compilers.
256
269
When in doubt, one can always move the comment outside the macro invocation:
257
270
258
271
``` fortran
259
272
! assert a property ensured since version 3.14
260
- call_assert_diagnose ( computed_checksum == expected_checksum, \
261
- "Checksum mismatch failure!", \
262
- computed_checksum ) ! TODO: write a better message above
273
+ call_assert_describe ( computed_checksum == expected_checksum, \
274
+ "Checksum mismatch failure!" \
275
+ ) ! TODO: write a better message above
263
276
```
264
277
265
278
Legal Information
0 commit comments