Appearance
Installation
Requirements
- A Fortran 2018 compiler. FLAP is tested on every push with gfortran 13, 14 and 15 (and the gfortran 16 trunk), with FoBiS, fpm, CMake and make. It also builds and passes its tests with nvfortran 26.5 and Intel ifx 2025.3 (except one processor-dependent case: ifx reports a directory as not existing, see path checks). gfortran 12 compiles the library (not tested); gfortran 11 and older do not (
stop code, quiet=is Fortran 2018). - Two small libraries by the same author, fetched automatically by every build system: PENF (portable numeric kinds) and FACE (ANSI colours).
fpm
Add FLAP as a dependency in your project's fpm.toml:
toml
[dependencies]
FLAP = { git = "https://github.com/szaghi/FLAP", branch = "master" }This follows master, which always has the features of this documentation. For a fixed version, use tag = "vX.Y.Z" with a release.
fpm build fetches FLAP, PENF and FACE. To build and test FLAP itself:
bash
git clone https://github.com/szaghi/FLAP && cd FLAP
fpm testFoBiS
FoBiS (3.8+) is the reference build system of FLAP.
As a dependency of a FoBiS project, declare FLAP in your fobos and fetch it:
ini
[dependencies]
deps_dir = src/third_party
FLAP = https://github.com/szaghi/FLAPbash
fobis fetch # fetch FLAP (and its dependencies)
fobis fetch --update # update themStandalone:
bash
git clone https://github.com/szaghi/FLAP && cd FLAP
fobis fetch # PENF and FACE into src/third_party (pinned by fobos.lock)
fobis build --mode static-gnu # static/libflap.a, modules in static/mod
fobis build --mode shared-gnu # shared/libflap.so
fobis build --mode tests-gnu # every test program into exe/
bash scripts/run_tests.sh # run them
fobis build --lmodes # every mode (GNU, Intel, NVIDIA; debug variants; quad precision)CMake
bash
git clone https://github.com/szaghi/FLAP && cd FLAP
fobis fetch # PENF and FACE (or place them in src/third_party yourself)
cmake -B build
cmake --build build
ctest --test-dir build # the tests are built by default in a standalone buildAs a subproject (add_subdirectory), the tests are off unless BUILD_TESTING_FLAP=ON.
GNU Make
bash
git clone https://github.com/szaghi/FLAP && cd FLAP
fobis fetch
make # the library and some tests, into exe/
make STATIC=yes # the static library only: exe/libflap.aInstall script
Every release ships an install.sh, which downloads FLAP and builds it with one of the tools above:
bash
./install.sh --download git --build fobis
./install.sh --download wget --build cmake --tag v2.5.0Compiler notes
- nvfortran: FLAP builds as is (since v2.2.0
-Mbackslashis no longer needed; passing it is harmless). nvfortran 26.5 miscompiles a variable passed toget(or anyclass(*)argument) from more than one call site of the same scope, including an internal procedure using it by host association: a call executed before the first one in the source may leave the variable unassigned, or crash. In code built with nvfortran, give eachgetcall its own variable (a local in each helper procedure). - Quad precision:
getintoreal(R16P)needs FLAP and PENF compiled with-DPENF_R16P(FoBiS modetests-gnu-r16p); otherwiseR16Pis the same kind asR8P.
Quick start
f90
program minimal
!< A minimal FLAP program: one required option.
use flap
implicit none
type(command_line_interface) :: cli
character(99) :: string
integer :: error
call cli%init(description='minimal FLAP example')
call cli%add(switch='--string', switch_ab='-s', help='a string', required=.true., act='store', error=error)
if (error /= 0) stop 1, quiet=.true.
call cli%parse(error=error)
if (error /= 0) stop 1, quiet=.true.
call cli%get(switch='-s', val=string, error=error)
if (error /= 0) stop 1, quiet=.true.
print '(A)', 'String = '//trim(string)
endprogram minimalBuild it against the library (here the FoBiS static build) and run it:
bash
gfortran -I static/mod minimal.f90 static/libflap.a -o minimal$ minimal --string "hello world"
String = hello worldWithout its required option, it prints the error, the help and a hint, and ends with exit status 1:
$ minimal
minimal: error: named option "--string" is required!
usage: minimal --string value [--help] [--markdown] [--version]
minimal FLAP example
Required switches:
--string value, -s value
a string
Optional switches:
--help, -h
Print this help message
--markdown, -md
Save this help message in a Markdown file
--version, -v
Print version
Try 'minimal --help' for help.
[exit status 1]