EGU General Assembly 2022
© Author(s) 2022. This work is distributed under
the Creative Commons Attribution 4.0 License.

CHarm: C library to work with spherical harmonics up to almost arbitrarily high degrees

Blazej Bucha
Blazej Bucha
  • Department of Theoretical Geodesy and Geoinformatics, Slovak University of Technology in Bratislava, Bratislava, Slovakia (

Spherical harmonic transforms aiming at degrees as high as a few tens of thousands are vital in geodesy to improve our knowledge of the Earth's gravity field.  A prominent example is spectral gravity forward modelling of topographic masses, which is able to approximate fine gravity field structures up to the sub-km-level and beyond (degree ~20,000 and higher).  Driven by these applications, we have developed CHarm, a C library to perform spherical harmonic transforms.  CHarm is centered around (but not limited to) high-degree expansions, say, well beyond degree 2700.  Its goal is to be numerically stable on the one hand, while achieving reasonable computational efficiency with minimized memory requirements on the other hand.  Supported are surface spherical harmonic analysis and solid (3D) synthesis, both with point and area-mean data values.  Standard quadratures due to Gauss--Legendre and Driscoll--Healy are implemented for exact harmonic analysis of point data values.  The library can be compiled in double precision or, in case higher numerical accuracy is sought, in quadruple precision.  For efficient FFT transforms along the latitude parallels, the state-of-the-art FFTW library is employed to boost the performance.  Unique to CHarm is a routine integrating solid spherical harmonic expansions on band-limited undulated surfaces.  It can deliver, for instance, area-mean potential values on planetary surfaces.  Available are also routines to compute Fourier coefficients of Legendre functions and integrals of a product of two spherical harmonics or of two Legendre functions over a restricted domain.  To utilize the power of multicore processors, CHarm can be compiled with enabled parallelization on shared-memory architectures (OpenMP).  A significant effort is put into the documentation of the library (HTML, PDF) to allow its easy use.

In this contribution, we discuss the motivation behind the development of CHarm, explain its main functionalities and demonstrate some usage case studies.  Within a high-degree closed-loop synthetic environment, we assess the numerical accuracy, the computational speed and the memory management of the library.  A discussion on the future work closes the contribution.  CHarm is available at

How to cite: Bucha, B.: CHarm: C library to work with spherical harmonics up to almost arbitrarily high degrees, EGU General Assembly 2022, Vienna, Austria, 23–27 May 2022, EGU22-11206,, 2022.


Display file