Skip to content

swig-fortran/flibcpp

Repository files navigation

Flibcpp

This project uses SWIG-Fortran to expose useful functionality from the C++ standard library to Fortran 2003 application developers. It generates self-contained Fortran modules with native proxy classes and functions which wrap the C++ standard library.

Currently it's designed around the C++11 standard library, and it instantiates 32- and 64-bit integers as well as double-precision floats. All operations directly manipulate arrays of Fortran-owned data to minimize overhead.

Capabilities

Functionality includes:

  • Sorting, both canonical and with custom comparison function
  • Binary search for indices in a sorted array
  • Pseudo-random number generation, including a Gaussian/normal distribution

Getting started

Installation of Flibcpp is trivial, as it requires no external dependencies other than existing and compatible C++ and Fortran compilers, and a relatively recent version of CMake:

  1. Clone the repository with git clone https://github.com/swig-fortran/flibcpp or download a release
  2. Create a build directory and execute cmake $PATH_TO_SOURCE (requires CMake 3.8 or higher)
  3. Install using make install

More detailed installation instructions are available in the documentation. An example Fortran application that depends only on Flibcpp is available on Github.

Documentation

The latest documentation is hosted on readthedocs.io.

Contribute

Pull requests are welcome. Feature requests can be added as issues. If there is strong interest in adding an option for C++03 compatibility, it could be added. It would also be trivial to add support for single-precision floats, but since most scientific software uses double-precision, we only support those for now.

License

The source code for FlibCpp, including auto-generated code, is released under an MIT license. See the LICENSE file.

It must be linked against an existing C++ standard library implementation (e.g. libc++ or libstdc++), so those are not covered by this license.

SWIG is not required to use this project. SWIG-generated code does not inherit SWIG's GPL license.

The CgvFindVersion.cmake helper script used for determining the release info is released independently under an Apache-2.0 license.