Hacky but awesome. Thank you a lot!! Sometimes it is much easier to transfer one file and compile it, or hand it to your coworker who is not familiar with Fortran tooling or cmake. Free intra-procedural optimizations are a bonus.
It needn’t be complicated if you have no “include” statements::
cat *.f *.f90 >onefile.f90
gfortran onefile.f90
I send Fortran source code to users with no Fortran, git or make expereince, and this is much easier for them (and for me). Adding “knowledge dependencies” will reduce adoption. It occurs to me that if you do have include statements, changing them to #include, and invoking the c preporcessor might work. I haven’t tried that.
I do miss pre-modules/explicit-interface simplicity of compilation order but the script above not only uses fpm to put them in the
right order, it will also include the source of dependencies. If you
know you have gfortran and fpm you can replace the “cat” with
and that will allow for #include statements as well. Unfortunately, -E does not expand Fortran INCLUDE statements so you would have to change them. Using gfortran instead of cat works well instead of a simple call to cpp because the -I options are easier to just pass to gfortran versus extracting them to add to the cpp command.
There are several commericial and open_source tools for changing fixed-format to free-format that could solve that. The latest versions of fpm default to assuming all code is free-format by default, as one example where files ending in .f might be free-format already as well.
I hadn’t thought about how something like this might be useful from a purely portable standpoint, i.e. sharing code!
I’ve implemented this feature in Simply Fortran’s development version now, and it should appear as an Export option in the next release. It handles dependency ordering and INCLUDE statements properly.