charm_glob#
Module defining global CHarm variables.
The global variables are declared in charm_glob.h
and are initialized to safe values. Should you need to modify them for some reason, simply include charm_glob.h
(or charm.h
) in your code and set (without definition) the variables to whatever values you prefer. After that, whenever you call a CHarm routine that uses the global variables, the routine will use your own values instead of the default ones.
Warning
This module is for experienced users only. Most users should not interact with it.
Note
This documentation is written for double precision version of CHarm.
Thresholds used to compare floating point numbers

double charm_glob_threshold#
Threshold to judge whether two floating point numbers are equal,
100.0 * EPS
, whereEPS
is the machine epsilon of the floating point data type (float
,double
or__float128
). Experienced users may (under some very specific circumstances) need the possibility to tighten or relax the threshold.

double charm_glob_threshold2#
A more relaxed threshold to judge whether two floating point numbers are equal,
100000.0 * EPS
. It is used to check longitudes of custom userdefined grids for a constant longitudinal step (required by the FFTbased algorithms). To this end, we use double differences. For highresolution grids, the longitudinal step may be very small, so that two consecutive longitudes are very similar. Since double differences increase numerical errors, the threshold needs to be sufficiently large in such situations (yet narrow enough). The current value was found to be sufficient for quadrature grids associated with degrees as high as70,000
.
Parameters defining the polar optimization
CHarm can be told to skip the computation of all spherical harmonics during spherical harmonic synthesis/analysis for which
If the parameters a1
and a2
(see charm_glob_polar_optimization_a1
and charm_glob_polar_optimization_a2
) are tuned reasonably, the polar optimization can improve the computation speed while not deteriorating the output accuracy. This is because the inequality filters out spherical harmonics that are of such small magnitudes in the polar areas that they do not contribute to the result (within the numerical precision). However, if the parameters are set unwisely, the accuracy can be compromised.
If the second polar optimization parameter charm_glob_polar_optimization_a2
is negative (which is the default), no polar optimization is applied, that is, all spherical harmonics are evaluated, regardless of their smallness in magnitude. If it is nonnegative, the polar optimization is applied.
In double precision, the following values of the tuning parameters improve the computation speed and, in most cases, can safely be used without deteriorating the accuracy (Reinecke and Seljebotn, 2013):
charm_glob_polar_optimization_a1 = 100
andcharm_glob_polar_optimization_a2 = 0.01
.
In single and quadruple precision, different values of the tuning parameters are needed. Currently, we do not provide any recommendations, though.
References:
Reinecke, M., Seljebotn, D. S. (2013) Libsharp — spherical harmonic transforms revisited. Astronomy and Astrophysics 554, A112, doi: 10.1051/00046361/201321494.

unsigned long charm_glob_polar_optimization_a1#
Polar optimization parameter (default is
100
)

double charm_glob_polar_optimization_a2#
Polar optimization parameter (default is
1.0
, that is, no polar optimization)