SHTns  2.6.5
Loading and saving config (or plans)

SHTns provides a simple way to load/save a configuration from/to a file.

It allows:

All the calling program has to do is add SHT_LOAD_SAVE_CFG to the flags or layout parameter when calling shtns_set_grid / shtns_set_grid_auto (C) or shtns_precompute / shtns_precompute_auto (Fortran). SHTns will first look for the files shtns_cfg and shtns_cfg_fftw and use the data stored therein. If no configuration stored in the files correspond to the required one, SHTns will proceed as usual and then store the configuration (unless sht_quick_init mode is used).

Ensuring same config is used across MPI processes:

if (rank > 0) MPI_Barrier(); // all processes except 0 wait here until process 0 has initialized shtns.
shtns_set_grid_auto(... flags ...); // this will save the config to a file on process 0 and load from file on other processes.
if (rank == 0) MPI_Barrier(); // other processes now resume and load the config from file.