# fortran-lang/stdlib: Fortran numerical and utility library guide

> fortran-lang/stdlib provides reusable Fortran code for linear algebra, statistics, random numbers, strings, containers, and other common tasks. It combines a specification with a reference implementation and supports CMake and fpm.

**fortran-lang/stdlib** — Fortran Standard Library

- Repository: https://github.com/fortran-lang/stdlib
- Website: https://stdlib.fortran-lang.org
- Stars: 1,361 · Forks: 233
- Language: Fortran
- License: MIT
- Published: 2026-10-16 · Updated: 2026-10-16 · Language: en
- Canonical page: https://hysenlabs.com/projects/fortran-lang-stdlib

## Why fortran-lang/stdlib exists

Fortran has a language standard published by ISO, but the README states that the standard itself has no Standard Library. fortran-lang/stdlib addresses that gap by providing a community-driven, agreed-upon de facto library. It is intended for Fortran programmers who repeatedly need functionality outside the language, including containers, strings, file and operating-system integration, unit testing, assertions, logging, searching, sorting, merging, linear algebra, sparse matrices, special functions, random numbers, statistics, differential equations, numerical integration, and optimization.

The project is both a specification and a reference implementation. That distinction matters when evaluating adoption. An implementation provides working modules, while a specification defines the intended API and behavior independently of a particular compiler or platform. The README also describes cooperation with the Fortran Standards Committee. It says a future standardization effort may draw on functionality already available in `stdlib`.

This is not a complete replacement for every package available through the Fortran package ecosystem. Its purpose is to provide a shared library layer for common Fortran work. The repository topics reflect that focus, including BLAS, LAPACK, linear algebra, probability distributions, quadrature, RNG, sorting, statistics, hashing, and strings. Applications that need only one specialized dependency may prefer a standalone package. Applications assembling a broader scientific-computing foundation are the clearest audience for this repository.

## How the repository is organized

Based on the repository layout, implementation source code is under `src/`, public interfaces are under `include/`, and tests are under `test/`. The `example/` directory contains examples grouped by topic, including `linalg/`, `random/`, `sorting/`, `stats/`, `quadrature/`, `hashmaps/`, `io/`, `logger/`, `math/`, `optval/`, `specialfunctions_gamma/`, and `stats_distribution_beta/`. This structure gives adopters a place to inspect usage before adding a module to an application.

The library uses fypp as a metaprogramming preprocessor. The README identifies fypp as a build requirement, so it is not an optional component in the documented build process. CMake handles configuration and generation. By default, it searches for external BLAS and LAPACK, which is relevant to the numerical functionality listed in the project scope. The `FIND_BLAS` option controls that dependency search.

A notable design choice is rank-procedure generation. The `CMAKE_MAXIMUM_RANK` setting controls the maximum array rank for generated procedures. Its default is 4, its stated minimum required value is also 4, and its maximum is 15 for Fortran 2003 compliant compilers. The README also states that rank 15 can require at least 4 GB of memory for sequential compilation and at least 16 GB for parallel compilation. The library therefore exchanges generated-procedure coverage for higher build requirements.

## Obtaining stdlib and preparing build tools

The README's first build step clones the repository and changes into its directory:

```sh
git clone https://github.com/fortran-lang/stdlib
cd stdlib
```

After this, the project directory contains the source, examples, tests, CMake configuration, and `fpm.toml`. The requirements section lists a Fortran 2008 compliant compiler or better, CMake version 3.14 or newer, a CMake backend such as Make or Ninja, and fypp. GCC Fortran and Intel Fortran compilers are identified as known to work.

If the system package manager does not provide the required build tools, the README gives this pip command:

```sh
pip install --user fypp cmake ninja
```

That command installs fypp, CMake, and Ninja for the current user. It does not install a Fortran compiler, so the compiler must already be available or be installed separately. The README also documents a conda-forge setup, including a named environment for the tools. Those steps are useful when a system package manager does not provide the required tools.

## Configuring stdlib with CMake

After the compiler, CMake, backend, and fypp are available, the README configures the build with:

```sh
cmake -B build
```

This creates the build directory and lets CMake select the default backend. The README identifies Ninja as recommended on Windows. It documents the generator option as `-G Ninja`, but the README does not show that option as a complete command or show the final compile and install commands. Those later commands must be obtained from the current repository documentation rather than inferred from configuration.

The default configuration enables the `stdlib` tests. A project that does not want them can disable testing with the documented CMake option `BUILD_TESTING=off`. Applications that need dynamic linkage can request shared libraries with `BUILD_SHARED_LIBS=on`.

The README describes `BUILD_SHARED_LIBS` as being off by default. Consequently, the default is static linkage unless the option is enabled. The choice affects how the resulting library is linked, so it should be selected as part of application packaging rather than changed casually during a first build.

## BLAS discovery and Fortran rank costs

CMake searches for external BLAS and LAPACK by default. Projects that need to disable that search can use the documented `FIND_BLAS` option with the value `off`.

Disabling the search should not be treated as harmless. The project scope includes linear algebra and sparse matrices, while the README identifies BLAS and LAPACK as external dependencies found by default. The README does not specify which numerical modules remain fully available when `FIND_BLAS=off`, so the relevant module documentation should be checked before selecting that setting.

The `CMAKE_MAXIMUM_RANK` option has a more visible build impact. The default is 4, and the README says the minimum required rank is also 4. A higher rank may generate more procedures and increase resource consumption. The documented upper bound is 15 for Fortran 2003 compliant compilers, while compilers that do not fully support Fortran 2003 have a maximum of 7. The README warns that compiling at rank 15 can be resource intensive. This is relevant on CI workers and developer machines with limited memory.

Build type selection can also affect compiler flags. The default is `RelWithDebInfo`, and the README warns that its flags override flags supplied through `FFLAGS`. Developers who need to control `FFLAGS` directly are directed to use `CMAKE_BUILD_TYPE=NoConfig` with those flags. This is a build-system constraint, not merely a convenience option.

## Supported compiler environments and maintenance

The README separates tested combinations from combinations that are only known to work. Tested configurations include GCC Fortran on Ubuntu and Apple silicon macOS, GCC Fortran on Windows Server 2022 through MSYS and MinGW, Intel oneAPI LLVM, Intel oneAPI classic, and Flang LLVM. Older MinGW GCC versions on Windows 10 are listed as known to work but are not tested in CI. GCC Fortran below 9, several NVIDIA HPC SDK versions, NAG 7.0 on RHEL, and older Intel Parallel Studio XE environments are listed as currently not working.

This support matrix matters for teams maintaining multiple build environments. A compiler that works for an application does not automatically qualify for this library. The documented list also does not say that every module behaves identically across every listed platform. The README asks for reports of successful and failing compiler, platform, and architecture combinations, which indicates that compatibility validation is an explicit part of the project workflow.

The repository is not archived, and the last push was on 2026-10-09. Recent releases include v0.8.1 on 2026-01-26 and v0.8.0 on 2026-01-23. That is recent repository activity, but it does not establish compatibility for a particular target. Upgrade planning should account for compiler requirements, BLAS and LAPACK availability, generated rank settings, and the repository changelog.

## A concrete alternative to broad stdlib adoption

The repository itself documents two build paths, CMake and fortran-lang/fpm. They provide different integration workflows for the same library rather than different implementations. CMake exposes controls such as `CMAKE_MAXIMUM_RANK`, `BUILD_TESTING`, `BUILD_SHARED_LIBS`, and `FIND_BLAS`. The fpm path fits applications already using the Fortran package workflow, but the README does not document the complete fpm command sequence or state how every CMake option maps to it.

Another practical alternative is maintaining separate in-house modules or dependencies for a small application. That can avoid the broad library's compiler matrix and build configuration, but it places duplication and maintenance responsibility on the application. The trade-off is straightforward. Choose fortran-lang/stdlib when the application needs several of its documented areas or values a shared reference implementation. Keep specialized dependencies when the application needs one narrow feature and has independent control over that dependency.

The examples provide a project-specific way to assess this decision. Directories such as `example/linalg/`, `example/random/`, `example/sorting/`, `example/stats/`, `example/quadrature/`, and `example/hashmaps/` show the kinds of features covered by the library. The README does not provide the contents of those examples or a run command for them, so a team should inspect the relevant directory before selecting a module.

## Conclusion

Fortran developers should consider fortran-lang/stdlib when an application needs reusable utility and numerical code rather than separate in-house modules. Projects using unsupported compilers, unusually strict memory limits, or unmanaged build settings may find it unsuitable. Before adoption, verify the target compiler, BLAS and LAPACK availability, and the generated array rank, then review documentation for the specific module being introduced.

## FAQ

### How do I install fortran-lang/stdlib?

Clone the repository with the documented `git clone` command, then install a Fortran compiler, CMake 3.14 or newer, a CMake backend, and fypp. The README documents configuration with `cmake -B build`, but does not include the final compile and installation commands.

### Which compilers does fortran-lang/stdlib support?

The README lists tested GCC, Intel, and Flang combinations on Ubuntu, macOS, and Windows Server 2022. Older MinGW GCC versions are known to work, while several older or less common compiler environments are listed as currently not working.

### Can fortran-lang/stdlib use BLAS and LAPACK?

CMake searches for external BLAS and LAPACK by default, and `FIND_BLAS` can be set to `off` when that dependency discovery is not wanted. The README does not document the exact module-level effect of disabling the search.

### How is fortran-lang/stdlib licensed?

The repository identifies its license as MIT. The exact license text is available in the repository's `LICENSE` file.

### Can I use fortran-lang/stdlib with fpm?

The repository includes `fpm.toml`, and the README has a build section for fortran-lang/fpm. The README does not include the complete fpm command sequence.

## Sources

- [fortran-lang/stdlib on GitHub](https://github.com/fortran-lang/stdlib)
- [License: MIT](https://github.com/fortran-lang/stdlib/blob/master/LICENSE)
- [Project website](https://stdlib.fortran-lang.org)
- [README](https://github.com/fortran-lang/stdlib/blob/master/README.md)
- [Releases](https://github.com/fortran-lang/stdlib/releases)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/fortran-lang-stdlib
