Fortran interfaces, classes and header extensions.
Explore the project »
fortiche (adjective and noun)
(informal) who is strong or smart
Fortiche is a collection of various preprocessor macros designed to extend the current features of the Fortran standard. It contains various experiments that have been collected over the years.
This repo should be seen as an experimentation and was develop to test the limits of preprocessing. Fortran and preprocessing is a long-standing love-hate relationship. While preprocessing has never been standardized, one may find numerous projects that heavily rely on preprocessor macros and use them for various reasons going from code reusability, ersatz of generics, reduced verbosity, etc.
To cite Stroustrup’s book The C++ Programming Language
The first rule about macros is: Don’t use them unless you have to. Almost every macro demonstrates a flaw in the programming language, in the program, or in the programmer.
So before you start having fun with macros just ask yourself if it increases the readability and the maintainability of your code. If yes, let's play!
Folder | Description |
---|---|
app | Introduces the console keyword to build command line applications. It contains a simple argument parser and provides a fine control on the exit sequence. It is much like the C counterpart int main(int argc, char *argv[]) . It also introduces the macros _COMPILER_NAME and _OS_NAME |
array | Introduces the keywords reallocate , reallocate_with , reallocate_as and resize for allocatable arrays. |
assertion | assertion.inc is a single-file, dependency-free, and simple micro-framework for unit testing in Fortran. The API is modeled after the one of googletest |
collections | Introduces list (aka dynamic arrays) to the language with new procedure to manipulate them as add , get , insert , clear , remove , and sizeof |
contract | Introduces the concept of multiple inheritance into Fortran. In addition, one can define a contract (aka abstract types without components) only containing clause (aka deferred procedures) |
export | Exports functions using !DEC extension |
logging | Introduces info , warn , debug , error and fatal to the Fortran language. This example is a very simple logging library. The logging level is controlled with the environment variable LOGGING_LEVEL |
logical | Introduces short-circuiting logic to the language. In other words, in the block if cond1() andalso cond2() then , cond2() is not evaluated when cond1() returns .false. |
loop | Introduces the foreach construct together with only(x) and exclude(x) filters |
namelist | Introduces serialize and deserialize macros for derived types that can be written to namelists (i.e. without allocatable components and pointers) |
optional | Introduces optionalize to deal with optional parameters and reduce slightly the verbosity |
To build that library you need
- a Fortran 2008 compliant compiler, or better, a Fortran 2018 compliant compiler. The following compilers are tested on the default branch of fortiche:
Name | Version | Platform | Architecture |
---|---|---|---|
GCC Fortran (MinGW) | 14 | Windows 10 | x86_64 |
Intel oneAPI classic | 2021.5 | Windows 10 | x86_64 |
- a preprocessor. fortiche uses quite some preprocessor macros. It is known to work both with intel
fpp
an gcccpp
.
git clone https://github.com/davidpfister/fortiche
cd fortiche
Each subfolder contains a fpm projects. It can be build using fpm For convenience, the folder also contains a response file that can be invoked as follows:
fpm @test
The project was originally developed on Windows with Visual Studio 2019. The repo contains the solution file (Fortiche.sln) to get you started with Visual Studio 2019.
For more examples, please refer to the test folders
A bug is a demonstrable problem caused by the code in this repository. Good bug reports are extremely valuable to us—thank you!
Before opening a bug report:
- Check if the issue has already been reported (issues).
- Check if it is still an issue or it has been fixed? Try to reproduce it with the latest version from the default branch.
- Isolate the problem and create a minimal test case.
A good bug report should include all information needed to reproduce the bug. Please be as detailed as possible:
- Which version of fortiche are you using? Please be specific.
- What are the steps to reproduce the issue?
- What is the expected outcome?
- What happens instead?
This information will help the developers diagnose the issue quickly and with minimal back-and-forth.
Distributed under the MIT License.