SHTns 3.7
|
The angular coordinates on a spherical shell are the co-latitude and the longitude .
The spatial discretization is defined by a call to shtns_init; or to shtns_set_grid or shtns_set_grid_auto after shtns_create.
A field A (or one of its component in case of a vector field) is discretized on an ordered grid, which consists of
There are constraints on the sizes NLAT and NPHI. The sampling theorem requires NPHI > 2*MMAX, with MMAX the highest Fourier mode to be resolved. Similarly NLAT > LMAX is required for a Gauss-Legendre quadrature, while on a regular grid NLAT > 2*LMAX is needed for the Féjer and Clenshaw-Curtis quadratures.
When dealing with non-linear equations, or more generally when analysing data that is not band-limited to LMAX and/or MMAX, anti-aliasing constraints exist. For a given non-linear order of the equation N (typically 2 for a quadratic non-linear term), the anti-aliasing conditions are :
Furthermore, the FFT is more efficient for certain values of NPHI and/or NLAT. If you do not require specific NLAT or NPHI, you can let SHTns choose them for you, by using shtns_set_grid_auto with nphi and/or nlat set to zero.
Identifying a grid point with its indices it
and ip
in latitudinal and longitudinal direction respectively (indices start at 0), one has :
acos(ct[it])
where ct
= shtns_info::ct is initialized by the call to shtns_initip
* 2 /(NPHI*MRES) and PHI_RAD and PHI_DEG can be used to get the phi angle corresponding to ip
.Currently, three data layouts are supported. Contiguous longitudes, Contiguous latitudes, and Native layout.
In this layout, increasing longitudes are stored next to each other for each latitude. That is = A
[it*NPHI + ip] in C or A(ip,it)
in Fortran. Use SHT_PHI_CONTIGUOUS to instruct shtns_init to use this spatial data layout :
will tell shtns to precompute everything for a gauss grid, and spatial data stored with longitude varying fastest.
In this layout, increasing latitude are stored next to each other for each longitude. That is = A
[ip*NLAT + it] in C or A(it,ip)
in Fortran. Use SHT_THETA_CONTIGUOUS to instruct shtns_init to use this spatial data layout.
Additionally, SHT_ALLOW_PADDING instructs shtns to optimize the layout to avoid cache bank conflicts. This can lead to significant performance boost (from 1% to 50% depending on the architecture). In that case, shtns_info::nlat_padded > shtns_info::nlat and shtns_info::nspat > shtns_info::nlat * shtns_info::nphi to reflect the data layout.
The "native" way of storing spatial field data will help you achieve the best performance with SHTns. On both CPU and GPU, it is the same as the Contiguous latitudes layout. Note that this may be subject to change and the data could be neither phi-contiguous nor theta-contiguous. For instance, in an earlier version (prior to v3.6), the GPU "native" layout was using the following access pattern: = A[ip*2 + (it%2) + (it/2)*(NPHI*2)] in C.
To instruct shtns_init that your spatial data has been set up using this layout, use SHT_NATIVE_LAYOUT.