This is adapted from amrex-tutorials' SWFFT/Poisson to apply a given power spectrum in Fourier space (such as this one) to a 3D Gaussian random draw.
Aimed at amrex users wanting an efficient stochastic source with a given spectrum.
Current compilation settings are these of Cambridge's CSD3. Run e.g. with:
mpirun -n 8 ./main3d.intel-llvm.MPI.ex inputs