SHTns 3.7
Using SHTns with Fortran

SHTns provides two interfaces to Fortran language (compatible with gfortran).

Basic Fortran 77 interface

First of all you need to initialize SHTns. There are two ways to do this :

  • calling one of the shtns_init_* subroutines,
  • or calling shtns_set_size followed by shtns_precompute or shtns_precompute_auto. This way lets you choose normalization and optimization.

Multi-threaded transforms can be enabled (if available, see Compiling and installing SHTns) by a call to shtns_use_threads before shtns_init or shtns_create.

Note that you can call initialization function(s) only once, which means that only one size and grid can be used with the Fortran interface (C and Python do not have this limitation). Then you must allocate some memory, and finaly you can perform some spherical harmonic transforms.

See also
See The full reference of the Fortran API.
See the Fortran example for a simple usage of SHTns from Fortran language.

When your program is ready, compile it adding these options to the compiler (gfortran) :

-L/path/to/lib/ -I/path/to/include/ -lshtns -lfftw3 -lm -lc

Fortran 2003 iso_c_binding

An iso_c_binding is provided in file shtns.f03 for a direct call to the C interface.

See also
See the Fortran 2003 example that uses these bindings.