SHTns
2.6.5
|
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.
When dealing with non-linear equation, 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), the anti-aliasing conditions are :
Furthermore, 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.
The native way of storing spatial field data (which will help you achieve the best performance with SHTns) is the same as the Contiguous latitudes layout, except that it requires you to allocate slightly more memory for a field than the NLAT*NPHI double values. Namely NLAT*(NPHI/2+1)*2 doubles are required (instead of NLAT*NPHI) to be able tu use the in-place FFT of FFTW.
In Fortran this means you will allocate data as if the phi direction had (NPHI/2+1)*2 points instead fo NPHI. The additional space, is located at the end of the useful data, and you don't need to worry about it.
To instruct shtns_init that your spatial data has been set up using this layout, use SHT_NATIVE_LAYOUT.
double
is NSPAT_ALLOC = NLAT*(NPHI/2+1)*2. The first NLAT*NPHI values are the spatial data.fftw_malloc
function, for example using :