Installation
Prerequisites
A Fortran 2008+ compliant compiler is required. The CI tests GNU gfortran 16.2 (tests, coverage, documentation examples), 14.2 (doctests, UTF-8 harness) and 14 on macOS, and Intel ifx.
gfortran 14.3 or newer for reading strings
gfortran 13.3 and 14.2 (the versions tested) end a list-directed read into a string with an error: read *, first, second on the input "two words" three stops with End of file. gfortran 14.3 and 16.2 read it. The bug is in the compiler; StringiFor does not work around it. Ubuntu 24.04 ships gfortran 13.3 as gfortran and 14.2 as gfortran-14: use a newer compiler to read strings this way.
One-line install
curl -fsSL https://github.com/szaghi/StringiFor/releases/latest/download/install.sh | bashIt installs the latest release into ~/.local with the build system you choose among those StringiFor ships (--build fobis|fpm|cmake|make: a menu asks when you do not say), the compiler you name (--fc, --gnu, --intel), one install per compiler (lib/stringifor/<compiler>-<version>/, include/stringifor/<compiler>-<version>/), and makes it usable through pkg-config (pkg-config --cflags --libs stringifor, with PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig). The release carries StringiFor's dependencies (BeFoR64, FACE, PENF), so CMake and make need no network. Pass options after bash -s --, e.g. ... | bash -s -- --build cmake --prefix /opt/stringifor; --help lists them all, --uninstall removes the install. The installer is FoBiS's (One-line installer).
Download
Clone the repository:
git clone https://github.com/szaghi/StringiFor
cd StringiForDependencies are declared in the fobos file and fetched automatically by FoBiS into src/third_party/:
fobis fetch # fetch and build all dependencies
fobis fetch --update # re-fetch and rebuildThird-Party Dependencies
Dependencies are fetched into src/third_party/:
| Library | Purpose |
|---|---|
| PENF | Portable numeric kind parameters (I1P–I8P, R4P–R16P) and number-to-string conversion |
| FACE | ANSI terminal color/style support (used by string%colorize) |
| BeFoR64 | Base64 encode/decode (used by string%encode/string%decode) |
Build with fpm (recommended for new projects)
Fortran Package Manager resolves dependencies automatically. Add to your project's fpm.toml:
[dependencies]
StringiFor.git = "https://github.com/szaghi/StringiFor"To build StringiFor itself:
fpm buildINFO
The test suite is not wired into fpm: run it with FoBiS, as described below.
Build with FoBiS (primary development tool)
FoBiS is the officially supported build system for development.
pip install FoBiS.pyBuild all tests
fobis buildCompiled test executables are placed in ./exe/.
Build the library
# Static library (GNU gfortran)
fobis build --mode stringifor-static-gnu
# Shared library (GNU gfortran)
fobis build --mode stringifor-shared-gnu
# Static library (Intel Fortran)
fobis build --mode stringifor-static-intel
# Shared library (Intel Fortran)
fobis build --mode stringifor-shared-intelThe library is placed in ./lib/ (libstringifor.a or libstringifor.so).
Debug builds
fobis build --mode tests-gnu-debug
fobis build --mode tests-intel-debugList all modes
fobis build --lmodesInstall in one command
FoBiS can clone, build and install the library without a manual checkout:
fobis install szaghi/StringiFor --mode stringifor-static-gnu
fobis install szaghi/StringiFor --mode stringifor-static-gnu --prefix /path/to/prefixUse as a dependency of your FoBiS project
Declare StringiFor in the fobos file of your project and run fobis fetch:
[dependencies]
deps_dir = src/third_party
StringiFor = https://github.com/szaghi/StringiForBuild with CMake
cmake -B build
cmake --build buildWhen StringiFor is the top-level project the tests are built too; disable them with -DBUILD_TESTING=OFF.
Build with GNU Make
A makefile is provided for static library builds:
# Build static library with GNU gfortran (./lib/libstringifor.a)
make
# Build the tests suite
make TESTS=yes
# Use Intel Fortran instead
make COMPILER=intel
make COMPILER=intel TESTS=yesRunning the Test Suite
After a FoBiS or Make build that includes tests:
bash scripts/run_tests.shEach executable in ./exe/ is run and its output checked for pass/fail.