The callback solution of @jwmwalrus reminds me a bit of the Apple Accelerate Quadrature library. Many numerical quadrature libraries expect the user to provide a function which evaluates a scalar integrand_. This “cripples” the use of SIMD parallelism. But in Accelerate, the functions expects a “vector callback”.
The Apple documentation only shows the Swift API, but at least last time I checked there was also an (Objective-)C API, which can be combined with Fortran callbacks using C interop.
I’ve mentioned this idea on Discourse before: Iso_c_binding: pass an array from c to fortran (Edit: python interop content) - #26 by ivanpribec