function formatted_build_config() result(output)
use, intrinsic :: iso_fortran_env, only: compiler_version, compiler_options
character(len=:), allocatable :: output
character(len=*), parameter :: nl = new_line('a')
allocate(character(len=max_build_config_len)::output)
write(output, '(a, a)') "Built with ", compiler_version()
write(output, '(a, a)') trim(output) // nl // "Build flags: ", compiler_options()
write(output, '(a)') trim(output) // nl // nl // "Current build configuration: "
write(output, '(a, a)') trim(output) // nl // "GS2_GK_SYSTEM: ", gs2_gk_system
write(output, '(a, a)') trim(output) // nl // "GS2_BUILD_TAG: ", gs2_build_tag
write(output, '(a, l1)') trim(output) // nl // "MPI: ", gs2_has_mpi
write(output, '(a, l1)') trim(output) // nl // "MPI3: ", gs2_has_mpi3
write(output, '(a, l1)') trim(output) // nl // "OPENMP: ", gs2_has_openmp
write(output, '(a, l1)') trim(output) // nl // "FFTW: ", gs2_has_fft
write(output, '(a, l1)') trim(output) // nl // "New diagnostics: ", gs2_has_new_diag
write(output, '(a, l1)') trim(output) // nl // "GENQUAD: ", gs2_has_genquad
write(output, '(a, l1)') trim(output) // nl // "NetCDF: ", gs2_has_netcdf
write(output, '(a, l1)') trim(output) // nl // "NetCDF Parallel: ", gs2_has_netcdf_parallel
write(output, '(a, l1)') trim(output) // nl // "LAPACK: ", gs2_has_lapack
write(output, '(a, l1)') trim(output) // nl // "Eigensolver: ", gs2_has_with_eig
write(output, '(a, l1)') trim(output) // nl // "Field eigensolver: ", gs2_has_fields_eig
write(output, '(a, l1)') trim(output) // nl // "Single precision: ", gs2_is_single_precision
write(output, '(a, l1)') trim(output) // nl // "Quad precision: ", gs2_has_quad
output = trim(output)
end function formatted_build_config