@@ -19,7 +19,6 @@ This assertion utility contains four public entities:
1919
2020The ` assert ` subroutine
2121* 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,
2322* Is callable inside ` pure ` procedures, and
2423* Can be eliminated at compile-time, as controlled by the ` ASSERTIONS ` preprocessor define.
2524
@@ -42,10 +41,6 @@ If instead `fpm install` is used, then either the user must copy `include/assert
4241the user must invoke ` assert ` directly (via ` call assert(...) ` ).
4342In 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.
4443
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-
4944Use Cases
5045---------
5146Two common use cases include
@@ -63,27 +58,49 @@ The requirements and assurances might be constraints of three kinds:
6358
6459The [ example/README.md] file shows examples of writing constraints in notes on class diagrams using the formal syntax of the Object Constraint Language ([ OCL] ).
6560
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
6883
69- ### Downloading Assert
84+ ftn $@
7085```
71- git clone [email protected] :berkeleylab/assert 72- cd assert
86+ Then build and test Assert with the command
87+ ```
88+ fpm test --compiler crayftn.sh --profile release
7389```
7490
75- ### Building and testing with ` gfortran `
91+ ### GNU Compiler Collection (GCC) ` gfortran `
92+
7693#### 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
7995```
8096fpm test --profile release
8197```
82- For ` gfortran ` 13 or earlier, use
98+ With ` gfortran ` 13 or earlier, use
8399```
84100fpm test --profile release --flag "-ffree-line-length-0"
85101```
86102The above commands build the Assert library (with the default of assertion enforcement disabled) and runs the test suite.
103+
87104#### Multi-image (parallel) execution
88105With ` gfortran ` 14 or later versions and OpenCoarrays installed, use
89106```
@@ -93,60 +110,56 @@ With `gfortran` 13 or earlier versions and OpenCoarrays installed,
93110```
94111fpm test --compiler caf --profile release --runner "cafrun -n 2" --flag "-ffree-line-length-0"
95112```
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- ```
101113
102- ### Building and testing with the Intel ` ifx ` compiler
114+ ### Intel ` ifx `
115+
103116#### Single-image (serial) execution
104117```
105118fpm test --compiler ifx --profile release
106119```
120+
107121#### Multi-image (parallel) execution
108122With Intel Fortran and Intel MPI installed,
109123```
110124fpm test --compiler ifx --profile release --flag "-coarray -DASSERT_MULTI_IMAGE"
111125```
112126
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
115131```
116132fpm test --compiler flang-new --flag "-mmlir -allow-assumed-rank -O3"
117133```
118- #### LLVM version 20 or later
134+ With ` flang-new ` version 20 or later, use
119135```
120136fpm test --compiler flang-new --flag "-O3"
121137```
122138
123- ### Building and testing with the Numerical Algorithms Group (NAG) compiler
139+ ### LFortran ` lfortran `
140+
141+ #### Single-image (serial) execution
124142```
125- fpm test --compiler nagfor --profile release --flag "-fpp -coarray=cosmp"
143+ fpm test --compiler lfortran --profile release --flag --cpp
126144```
127145
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
134152```
135- #!/bin/bash
136153
137- ftn $@
154+ #### Multi-image execution
155+ With ` nagfor ` 7.1, use
138156```
139- Then build and test Assert with the command
157+ fpm test --compiler nagfor --profile release --flag "-fpp -coarray=cosmp -f2018"
140158```
141- fpm test --compiler crayftn.sh --profile release
159+ With ` nagfor ` 7.2 or later, use
160+ ```
161+ fpm test --compiler nagfor --flag -fpp
142162```
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.
150163
151164Documentation
152165-------------
@@ -208,19 +221,19 @@ character for line-breaks in a macro invocation:
208221
209222``` fortran
210223! 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+ )
214227```
215228
216229Whereas Cray Fortran wants ` & ` line continuation characters, even inside
217230a macro invocation:
218231
219232``` fortran
220233! 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+ )
224237```
225238
226239There appears to be no syntax acceptable to all compilers, so when writing
@@ -237,29 +250,29 @@ after macro expansion (on gfortran and flang-new):
237250
238251``` fortran
239252! 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+ )
243256```
244257
245258Depending on your compiler it * might* be possible to use a C-style block
246259comment (because they are often removed by the preprocessor), for example with
247260gfortran one can instead write the following:
248261
249262``` 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+ )
253266```
254267
255268However that capability might not be portable to other Fortran compilers.
256269When in doubt, one can always move the comment outside the macro invocation:
257270
258271``` fortran
259272! 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
263276```
264277
265278Legal Information
0 commit comments