SHTns  2.6.5
Functions
Initialization functions.

Functions

shtns_cfg shtns_create (int lmax, int mmax, int mres, enum shtns_norm norm)
 Defines the sizes of the spectral description. Use for advanced initialization. More...
 
shtns_cfg shtns_create_with_grid (shtns_cfg base, int mmax, int nofft)
 Copy a given config but allow a different (smaller) mmax and the possibility to enable/disable fft (beta). More...
 
void shtns_unset_grid (shtns_cfg shtns)
 release all resources allocated by a grid. More...
 
void shtns_destroy (shtns_cfg shtns)
 release all resources allocated by a given shtns_cfg. More...
 
void shtns_reset ()
 clear all allocated memory (hopefully) and go back to 0 state. More...
 
int shtns_set_grid_auto (shtns_cfg shtns, enum shtns_type flags, double eps, int nl_order, int *nlat, int *nphi)
 Precompute everything and choose the optimal nlat and nphi for a given non-linear order. More...
 
int shtns_set_grid (shtns_cfg shtns, enum shtns_type flags, double eps, int nlat, int nphi)
 Precompute everything for a given spatial grid. Use for advanced initialization, after shtns_create. More...
 
shtns_cfg shtns_init (enum shtns_type flags, int lmax, int mmax, int mres, int nlat, int nphi)
 Simple initialization of the spherical harmonic transforms of given size. Calls shtns_create and shtns_set_grid_auto. More...
 
int shtns_use_threads (int num_threads)
 Enables OpenMP parallel transforms, if available (see Compiling and installing SHTns). More...
 
int shtns_gauss_wts (shtns_cfg shtns, double *wts)
 fill the given array with Gauss weights. More...
 

Detailed Description

Function Documentation

shtns_cfg shtns_create ( int  lmax,
int  mmax,
int  mres,
enum shtns_norm  norm 
)

Defines the sizes of the spectral description. Use for advanced initialization.

This sets the description of spherical harmonic coefficients. It tells SHTns how to interpret spherical harmonic coefficient arrays, and it sets usefull arrays. Returns the configuration to be passed to subsequent transform functions, which is basicaly a pointer to a shtns_info struct.

Parameters
lmax: maximum SH degree that we want to describe.
mmax: number of azimutal wave numbers.
mres: 2.pi/mres is the azimutal periodicity. mmax*mres is the maximum SH order.
norm: define the normalization of the spherical harmonics (shtns_norm)

Condon-Shortley phase (-1)^m is used by default.

renormalization of m>0.

shtns_cfg shtns_create_with_grid ( shtns_cfg  base,
int  mmax,
int  nofft 
)

Copy a given config but allow a different (smaller) mmax and the possibility to enable/disable fft (beta).

Copy a given config but allow a different (smaller) mmax and the possibility to enable/disable fft.

void shtns_destroy ( shtns_cfg  shtns)

release all resources allocated by a given shtns_cfg.

free memory of given config, which cannot be used afterwards.

int shtns_gauss_wts ( shtns_cfg  shtns,
double *  wts 
)

fill the given array with Gauss weights.

fill the given array with Gauss weights. returns the number of weights written (0 if not a Gauss grid).

returns the number of weights written, which may be zero if the grid is not a Gauss grid.

shtns_cfg shtns_init ( enum shtns_type  flags,
int  lmax,
int  mmax,
int  mres,
int  nlat,
int  nphi 
)

Simple initialization of the spherical harmonic transforms of given size. Calls shtns_create and shtns_set_grid_auto.

Simple initialization of Spherical Harmonic transforms (backward and forward, vector and scalar, ...) of given size. This function sets all global variables by calling shtns_create followed by shtns_set_grid, with the default normalization and the default polar optimization (see sht_config.h). Returns the configuration to be passed to subsequent transform functions, which is basicaly a pointer to a shtns_info struct.

Parameters
lmax: maximum SH degree that we want to describe.
mmax: number of azimutal wave numbers.
mres: 2.pi/mres is the azimutal periodicity. mmax*mres is the maximum SH order.
nlat,nphi: respectively the number of latitudinal and longitudinal grid points.
flagsallows to choose the type of transform (see shtns_type) and the spatial data layout (see Spatial data layouts and grids used by SHTns)
void shtns_reset ( void  )

clear all allocated memory (hopefully) and go back to 0 state.

destroy all configs, free memory, and go back to initial state.

int shtns_set_grid ( shtns_cfg  shtns,
enum shtns_type  flags,
double  eps,
int  nlat,
int  nphi 
)

Precompute everything for a given spatial grid. Use for advanced initialization, after shtns_create.

Initialization of Spherical Harmonic transforms (backward and forward, vector and scalar, ...) of given size. This function must be called after shtns_create and before any SH transform. and sets all global variables. returns the required number of doubles to be allocated for a spatial field.

Parameters
shtnsis the config created by shtns_create for which the grid will be set.
flagsallows to choose the type of transform (see shtns_type) and the spatial data layout (see Spatial data layouts and grids used by SHTns)
epspolar optimization threshold : polar values of Legendre Polynomials below that threshold are neglected (for high m), leading to increased performance (a few percents)
nlat,nphirespectively the number of latitudinal and longitudinal grid points. 0 = no polar optimization; 1.e-14 = VERY safe; 1.e-10 = safe; 1.e-6 = aggresive, but still good accuracy.
int shtns_set_grid_auto ( shtns_cfg  shtns,
enum shtns_type  flags,
double  eps,
int  nl_order,
int *  nlat,
int *  nphi 
)

Precompute everything and choose the optimal nlat and nphi for a given non-linear order.

Initialization of Spherical Harmonic transforms (backward and forward, vector and scalar, ...) of given size. This function must be called after shtns_create and before any SH transform. and sets all global variables and internal data. returns the required number of doubles to be allocated for a spatial field.

Parameters
shtnsis the config created by shtns_create for which the grid will be set.
nlat,nphipointers to the number of latitudinal and longitudinal grid points respectively. If 0, they are set to optimal values.
nl_orderdefines the maximum SH degree to be resolved by analysis : lmax_analysis = lmax*nl_order. It is used to set an optimal and anti-aliasing nlat. If 0, the default SHT_DEFAULT_NL_ORDER is used.
flagsallows to choose the type of transform (see shtns_type) and the spatial data layout (see Spatial data layouts and grids used by SHTns)
epspolar optimization threshold : polar values of Legendre Polynomials below that threshold are neglected (for high m), leading to increased performance (a few percents) 0 = no polar optimization; 1.e-14 = VERY safe; 1.e-10 = safe; 1.e-6 = aggresive, but still good accuracy.
void shtns_unset_grid ( shtns_cfg  shtns)

release all resources allocated by a grid.

unset the grid.

int shtns_use_threads ( int  num_threads)

Enables OpenMP parallel transforms, if available (see Compiling and installing SHTns).

Enables multi-thread transform using OpenMP with num_threads (if available). Returns number of threads that will be used.

Call before any initialization of shtns to use mutliple threads. Returns the actual number of threads.

  • If num_threads > 0, specifies the maximum number of threads that should be used.
  • If num_threads <= 0, maximum number of threads is automatically set to the number of processors.
  • If num_threads == 1, openmp will be disabled.