opencollab / arpack-ng

Collection of Fortran77 subroutines designed to solve large scale eigenvalue problems.
Other
277 stars 121 forks source link
arpack eigenvalue linear-algebra parpack

arpack-ng arpack-ng CI/CD

ARPACK-NG is a collection of Fortran77 subroutines designed to solve large scale eigenvalue problems. mandatory dependencies optional dependencies category
BLAS, LAPACK MPI, Eigen3, Boost.Python LinearAlgebra

About the project

This project started as a joint project between Debian, Octave and Scilab in order to provide a common and maintained version of arpack. This is now a community project maintained by a few volunteers. Indeed, no single release has been published by Rice university for the last few years and since many software (Octave, Scilab, R, Matlab...) forked it and implemented their own modifications, arpack-ng aims to tackle this by providing a common repository, maintained versions with a testsuite. arpack-ng is replacing arpack almost everywhere.

Important Features

Documentation

Within DOCUMENTS directory there are three files for templates on how to invoke the computational modes of ARPACK.

Also look in the README.MD file for explanations concerning the other documents.

ILP64 support

About ILP64 support:

Note for F77/F90 developers:

Note for C/C++ developers:

Example: to test arpack with sequential ILP64 MKL assuming you use gnu compilers

$ ./bootstrap
$ export FFLAGS='-DMKL_ILP64 -I/usr/include/mkl'
$ export FCFLAGS='-DMKL_ILP64 -I/usr/include/mkl'
$ export LIBS='-Wl,--no-as-needed -L/usr/lib/x86_64-linux-gnu -lmkl_sequential -lmkl_core -lpthread -lm -ldl'
$ export INTERFACE64=1
$ ./configure --with-blas=mkl_gf_ilp64 --with-lapack=mkl_gf_ilp64
$ make all check

ISO_C_BINDING support

About ISO_C_BINDING support:

ISO_C_BINDING is a feature of modern Fortran meant to handle safely interoperability between Fortran and C (in practice, no more need to use ugly tricks to link F77 functions to C code using "underscored" symbols). Basically, ISO_C_BINDING make sure all fortran variables are typed (which may not always be the case when using implicit keyword in fortran): this way, C compilers can link properly. For more informations on ISO_C_BINDING, you can checkout the following links:

Using ICB is seamless:

Example: to test arpack with ISO_C_BINDING

$ ./configure --enable-icb
$ cmake -D ICB=ON

Eigen support

arpack-ng provides C++ eigensolver based on both ISO_C_BINDING and eigen.

Check out ./EXAMPLES/MATRIX_MARKET/README for more details.

Example: to test arpack with eigen

$ mkdir build
$ cd build
$ cmake -D EXAMPLES=ON -D ICB=ON -D EIGEN=ON ..
$ make all check

Python support

pyarpack: python support based on Boost.Python.Numpy exposing C++ API. pyarpack exposes in python the arpack-ng C++ eigensolver (based on eigen).

Check out ./EXAMPLES/PYARPACK/README for more details.

Example: to test arpack with python3

$ mkdir build
$ cd build
$ cmake -D EXAMPLES=ON -D ICB=ON -D EIGEN=ON -D PYTHON3=ON ..
$ make all check

📁 Directory structure

Example programs for Parallel ARPACK may be found in the directory PARPACK/EXAMPLES. Look at the README file for further information.

Install 🚀

Getting arpack-ng

Unlike ARPACK, ARPACK-NG is providing autotools and cmake based build system. In addition, ARPACK-NG also provides ISO_C_BINDING support, which enables to call fortran subroutines natively from C or C++.

First, obtain the source code 📥 from github:

$ git clone https://github.com/opencollab/arpack-ng.git
$ cd ./arpack-ng

If you prefer the ssh to obtain the source code, then use:

$ git clone git@github.com:opencollab/arpack-ng.git
$ cd ./arpack-ng

Note, It is recommended to install arpack at standard location on your system by using your root privilege.

Using autotools

In the source directory, use the following commands to configure, build and install arpack-ng.

$ sh bootstrap
$ ./configure --enable-mpi
$ make
$ make check
$ sudo make install

Congratulations 🎉, you have installed arpack lib using autotools (caution: you need sudo to install in your system).

The above-mentioned process will build everything including the examples and parallel support using MPI.

Using cmake

You can install ARPACK-NG by using cmake. If you do not have cmake, then please download the binary from pip using:

$ python3 -m pip install cmake
$ which cmake && cmake --version

After installing cmake, follow the instruction given below.

Caution: Make sure you are in source directory of ARPACK-NG.

$ mkdir build
$ cd build
$ cmake -D EXAMPLES=ON -D MPI=ON -D BUILD_SHARED_LIBS=ON ..
$ make
$ sudo make install

✨ Congratulations, you have installed arpack lib using cmake (caution: you need sudo to install in your system).

The above-mentioned process will build everything including the examples and parallel support using MPI.

Customize build / install

You can also customize the installation of arpack using the autotools.

To customize the install directories:

$ LIBSUFFIX="64" ./configure
$ make all install

To enable ILP64 support:

$ INTERFACE64="1" ITF64SUFFIX="ILP64" ./configure
$ make all install

To enable ISO_C_BINDING support:

$ ./configure --enable-icb

You can customize the build by declaring the cmake options during configuration.

To customize the install directories:

$ cmake -D LIBSUFFIX="64" ..
$ make all install

To enable ILP64 support:

$ cmake -D INTERFACE64=ON -D ITF64SUFFIX="ILP64" ..
$ make all install

To enable ISO_C_BINDING support:

$ cmake -D ICB=ON

Supported Operating Systems:

Linux support

arpack-ng runs on debian-based distros.

Mac OS support

On mac OS, with GNU compilers, you may need to customize options:

$ LIBS="-framework Accelerate" FFLAGS="-ff2c -fno-second-underscore" FCFLAGS="-ff2c -fno-second-underscore" ./configure

Windows support

arpack-ng can be installed on Windows as a MinGW-w64 package via various distribution, for example through MSYS2 with pacman -S mingw-w64-x86_64-arpack. It can also be built and installed through vcpkg with vcpkg install arpack-ng.

Using arpack-ng from your own codebase

The *.pc and *.cmake files provided by arpack-ng are only pointing to arpack libraries. If you need other libraries (like MPI), you must add them alongside arpack (see CMake example below).

Typically, if you need

Examples are provided in tstCMakeInstall.sh and tstAutotoolsInstall.sh generated after running cmake/configure.

With autotools

First, set PKG_CONFIG_PATH to the location in the installation directory where arpack.pc lies.

Then, insert the following lines in your configure.ac:

PKG_CHECK_MODULES([ARPACK], [arpack])
AC_SUBST([ARPACK_CFLAGS])
AC_SUBST([ARPACK_LIBS])

Note: make sure you have installed pkg-config.

With CMake

You can use arpack in your CMake builds by using ARPACK::ARPACK target. For example,

FIND_PACKAGE(arpackng)
ADD_EXECUTABLE(main main.f)
TARGET_INCLUDE_DIRECTORIES(main PUBLIC ARPACK::ARPACK)
TARGET_LINK_LIBRARIES(main ARPACK::ARPACK)

To use PARPACK in your Cmake builds, use PARPACK::PARPACK target:

FIND_PACKAGE(arpackng)
FIND_PACKAGE(MPI REQUIRED COMPONENTS Fortran)
ADD_EXECUTABLE(main main.f)
TARGET_INCLUDE_DIRECTORIES(main PUBLIC PARPACK::PARPACK)
TARGET_LINK_LIBRARIES(main PARPACK::PARPACK)
TARGET_INCLUDE_DIRECTORIES(main PUBLIC MPI::MPI_Fortran)
TARGET_LINK_LIBRARIES(main MPI::MPI_Fortran)

Note: Make sure to update CMAKE_MODULE_PATH env variable (otheriwse, find_package won't find arpack-ng cmake file).

FAQ

Using MKL (also known as Intel oneAPI or oneMKL) instead of BLAS / LAPACK

How to use arpack-ng with Intel MKL:

Good luck and enjoy 🎊