@@ -10,50 +10,102 @@ ___________ .__
1010Formal: Fortran mimetic abstraction language
1111============================================
1212
13- _ Towards a formally verifiable, tensor-calculus langauge embedded in Fortran 2028 ._
13+ _ Towards an embedded domain-specific language (DSL) for tensor calculus and formal verification ._
1414
15- ## Examples
15+ Introduction
16+ ------------
17+ Formal supports research on mimetic software abstractions for tensor calculus by providing
18+
19+ - Derived types that mimic tensor fields and
20+ - Differential and integral operators for writing tensor expressions.
21+
22+ Formal's types and operators implement the discrete calculus of [ Castillo & Corbino (2020)] :
23+ mimetic discretizations satisfying discrete versions of tensor calculus theorems.
24+
25+ Like the underlying numerical methods, Formal's software abstractios mimic their tensor calculus counterparts.
26+ For example, given scalar and vector fields $f$ and $\vec{v}$ defined over a unit volume $V = [ 0,1] ^3$ bounded
27+ by a surface area $A$, the program [ ` example/extended-gauss-divergence.F90 ` ] demonstrates satisfaction of the
28+ extended Gauss divergence theorem:
29+
30+ $$ \iiint_V (\vec{v} \cdot \nabla f) dV + \iiint_V (f \nabla \cdot \vec{v}) dV = \iint_A f \vec{v} \cdot d\vec{A} $$
31+
32+ Running the program as follows
33+ ``` fortran
34+ fpm run --example extended-gauss-divergence --compiler flang-new --flag -O3
35+ ```
36+ produces output that includes actual program syntax:
37+ ``` fortran
38+ f = (x**2)/2 ! <-- scalar function
39+ v = x ! <-- vector function
40+ .SSS. (v .dot. .grad. f) * dV = .3333333330205934
41+ .SSS. ( f * .div. v) * dV = .16666666739857125
42+ -.SS. (f .x. (v .dot. dA)) = -.5000000004191649
43+ ----------------------------------------------------
44+ sum = -.2220446049250313E-15 (residual)
45+ ```
46+ where the small residual of approximately $-.222 \times 10^{-15}$ evidences a highly accurate approximation.
47+
48+ ** Future work:** Formal lays a foundation for defining a DSL embedded in Fortran via template requirements,
49+ a feature of the forthcoming standard known informally as Fortran 202Y.
50+
51+ Examples
52+ --------
1653See this repository's [ example] ( ./example ) subdirectory for demonstrations of how
17- to use Formal. For usage information for each example, execute something like:
54+ to use Formal. For usage information for each example, execute something like
1855``` bash
1956fpm run --example < base-name> -- --help
2057```
21- where ` base-name ` is the portion of an example file name preceding the ` .F90 ` or
22- ` .f90 ` extension. To save typing in a terminal window, set the ` example `
23- directory as your present working directory before issuing the above ` fpm run `
24- command. Then use tab completion to enter enter the base name and delete the
25- file extension before pressing ` return ` .
26-
27- ## Prerequisites
58+ replacing ` <base-name> ` with the portion of an example file name preceding the ` .F90 ` or
59+ ` .f90 ` extension. To save typing in a terminal window, set the ` example ` directory as
60+ your present working directory before typing ` fpm run ` above. Then use tab completion to
61+ enter a file name and delete the file extension before pressing ` return ` or ` enter ` .
2862
63+ Prerequisite
64+ ------------
2965Building and testing Formal requires the Fortran Package Manager ([ ` fpm ` ] ),
3066which can be obtained via a package manager (e.g., ` brew install fpm ` on macOS)
3167or by compiling the single-file concatenation of the ` fpm ` source that is
3268included among the release assets. For the ` fpm ` 0.12.0 release, for example,
3369compiling [ fpm-0.12.0.F90] and placing the resulting executable file in your
3470` PATH ` suffices.
3571
36- ## Building and testing
72+ Building and testing
73+ --------------------
74+ Vendor | Compiler | Version(s) Tested | Build/Test Command
75+ --------|-------------|-------------------|-------------------
76+ GCC | ` gfortran ` | 14-15 | fpm test --compiler gfortran --profile release
77+ GCC | ` gfortran ` | 13 | fpm test --compiler gfortran --profile release --flag "-ffree-line-length-none"
78+ Intel | ` ifx ` | 2025.1.2 | FOR_COARRAY_NUM_IMAGES=1 fpm test --compiler ifx --flag "-fpp -O3 -coarray" --profile release
79+ LLVM | ` flang-new ` | 20-21 | fpm test --compiler flang-new --flag "-O3"
80+ LLVM | ` flang-new ` | 19 | fpm test --compiler flang-new --flag "-O3 -mmlir -allow-assumed-rank"
81+ NAG | ` nagfor ` | 7.2 Build 7242 | fpm test --compiler nagfor --flag "-O3 -fpp"
3782
38- | Vendor | Compiler | Version(s) | Build/Test Command |
39- | --------| -------------| ------------| -------------------------------------------------------|
40- | GCC | ` gfortran ` | 14-15 | fpm test --compiler gfortran --profile release |
41- | GCC | ` gfortran ` | 13 | fpm test --compiler gfortran --profile release --flag "-ffree-line-length-none"|
42- | Intel | ` ifx ` | 2025.1.2 | FOR_COARRAY_NUM_IMAGES=1 fpm test --compiler ifx --flag "-fpp -O3 -coarray" --profile release |
43- | LLVM | ` flang-new ` | 20-21 | fpm test --compiler flang-new --flag "-O3" |
44- | LLVM | ` flang-new ` | 19 | fpm test --compiler flang-new --flag "-O3 -mmlir -allow-assumed-rank" |
45- | NAG | ` nagfor ` | 7.2 | fpm test --compiler nagfor --flag "-O3 -fpp" |
83+ With ` fpm ` versions _ after_ 0.12.0, ` flang-new ` can be shortened to ` flang ` in the above ` fpm ` commands.
4684
47- ** Known Issues**
48- 1 . With ` fpm ` versions _ after_ 0.12.0, ` flang-new ` can be shortened to ` flang ` .
49- 2 . With NAG 7.2, Build 7235 or later is recommended, but earlier builds might work.
50-
51- ## Documentation
85+ Documentation
86+ -------------
5287The [ ` doc/uml/class-diagram.md ` ] file contains a Mermaid script that generates a
5388Unified Modeling Language (UML) class diagram depicting many Formal derived
5489types and their interrelationships. GitHub's web servers render the diagram
5590graphically when viewed in a web browser.
5691
92+ Support and Licensing
93+ ---------------------
94+ Please see [ LICENSE.txt] for the copyright and license under which Formal is distributed.
95+ To report any difficulty with building, testing, or using Formal, please submit an [ issue] .
96+ To contribute code, please submit a [ pull request] from a fork of Formal.
97+
98+ Funding Acknowledgment
99+ ----------------------
100+ Formal is a software artifact of research funded by the Competitive Portfolios for Advanced
101+ Scientific Computing Research Program of the U.S. Department of Energy, Office of Science,
102+ Office of Advanced Scientific Computing Research under contract DE-AC02-05CH11231.
103+
57104[ `fpm` ] : https://github.com/fortran-lang/fpm
58105[ fpm-0.12.0.F90 ] : https://github.com/fortran-lang/fpm/releases/download/v0.12.0/fpm-0.12.0.F90
59106[ `doc/uml/class-diagram.md` ] : ./doc/uml/class-diagram.md
107+ [ Castillo & Corbino (2020)] : https://doi.org/10.1016/j.cam.2019.06.042
108+ [ `example/extended-gauss-divergence.F90` ] : ./example/extended-gauss-divergence.F90
109+ [ issue ] : https://github.com/berkeleylab/formal/issues
110+ [ pull request ] : https://github.com/berkeleylab/formal/pulls
111+ [ LICENSE.txt ] : ./LICENSE.txt
0 commit comments