Assertion module for gfortran, It is a simple module which adds an assertion function, It works by enabling -cpp
the c preprocesor directives in the fortran compiler, many fotrans compilers have this functionality.
If you have yay installed, just run this command.
yay -S assert-fortran-git
This is the link of the repo in AUR, then with git you can install the module, just run these two commands.
git clone https://aur.archlinux.org/assert-fortran-git.git
cd assert-fortran-git
makepkg -si
Before installing make sure that you have these dependencies to be able to compile the project:
You can download the latest realese of the project, then you can build a linux pacakge with souce code locally, by running:
make pkg
Then the library is packaged and ready to be install, depending on your distro of linux and your pacakge manager you maybe will need to execute another commands but in arch:
sudo pacamn -U assert-fortran-git-.x.y.z-a.x86_64.pkg.tar.zst
As I said before this module works by enabling -cpp
the c preprocesor directives,
then inside of the module where you want to make assertions, you only need to include the header file assertf.h
, thats why you need the flag -cpp
.
#include <assertf.h>
Then to compile the modules or the program, you need to set these flags.
gfortran -cpp your-program.f90 -I/usr/include -lassert
The -lassert
refers to the .a
library and the -I/usr/include
is needed to be able to include the assert
module and assertf.h
header.
This is an example of a failed assertion.