# Fortran Arrays in C++

**URL:** <https://fortran-lang.discourse.group/t/fortran-arrays-in-c/8856>\
**Category:** Announcements\
**Created:** [November 19, 2024, 5:21pm UTC](https://fortran-lang.discourse.group/t/fortran-arrays-in-c/8856 "2024-11-19T17:21:41Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![ivanpribec](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/ivanpribec/32/3290_2.png) [@ivanpribec](https://fortran-lang.discourse.group/u/ivanpribec)\
**Post date:** [November 21, 2024, 12:31pm UTC](https://fortran-lang.discourse.group/t/fortran-arrays-in-c/8856/13 "2024-11-21T12:31:06Z")

</div>

> [@Brady](#):
>
> Our library is not as good as Fortran. While the core “I just want to use arrays” is fairly elegant, there are a lot of rather ugly edges, particularly around elemental functions and component selection, that are forced on us by C++’s different idiom.

The lack of _standard_ multi-dimensional arrays has been a long-standing problem for C and C++ programmers, forcing them to invent dozens of array and tensor containers. I assembled a list at some point:

C:

- [WNLIB](http://www.willnaylor.com/wnlib.html)
- [Meschach](http://homepage.divms.uiowa.edu/~dstewart/meschach/)
- [GSL](https://www.gnu.org/software/gsl/doc/html/index.html)
- [CBLAS](https://netlib.org/blas/)
- [BLIS](https://github.com/flame/blis)

C++:

- [Armadillo](https://arma.sourceforge.net/)
- [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page)
- [Blaze](https://bitbucket.org/blaze-lib/blaze/src/master/)
- [Blitz++](https://github.com/blitzpp/blitz)
- [FLENS](https://github.com/michael-lehn/FLENS)
- [MTL4](https://github.com/simunova/mtl4)
- [GMM++](https://getfem.org/gmm.html)
- [TNT](https://math.nist.gov/tnt/overview.html)
- [POOMA](https://www.nongnu.org/freepooma/tutorial/introduction.html)
- [Boost.uBLAS](https://www.boost.org/doc/libs/1_65_1/libs/numeric/ublas/doc/index.html)
- [nt2](https://github.com/jtlap/nt2)
- [xtensor](https://github.com/xtensor-stack/xtensor) + [xtensor-blas](https://github.com/xtensor-stack/xtensor-blas)
- [Kokkos](https://github.com/kokkos/kokkos) + [Kokkos-Kernels](https://github.com/kokkos/kokkos-kernels)
- [BLAS++](https://icl.bitbucket.io/blaspp/)
- STL ([std::mdspan](https://github.com/kokkos/mdspan) + [std::experimental::linalg](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1673r11.html))

Each library caters to different use cases. Some are just array containers some offer extensive linear algebra (BLAS/LAPACK wrappers) and some even offer nice tensor syntax. There are downsides compared to built-in arrays:

- you need to install and configure the library
- if you write an algorithm tied to one array container, it ain’t directly reusable from other libraries (most libraries have a way to wrap an existing pointer)
- some libraries make extensive use of template meta-programming, which can be hard to develop and leads to long compilation times

I think having a Fortran-inspired library like FAR is good place for Fortran programmers to start with modern C++ when they have reasons to do so.

It should also be easy to interoperate with existing Fortran code in case needed using the advanced interoperability features in Fortran 2018. I did an example of Eigen++ wrappers before: [Weather and climate modeling codes from Fortran to C++ - #41 by ivanpribec](https://fortran-lang.discourse.group/t/weather-and-climate-modeling-codes-from-fortran-to-c/1531/41)

---

_[View the full topic](https://fortran-lang.discourse.group/t/fortran-arrays-in-c/8856)._
