Compiling and Linking 77 and Modern Fortran using FPM

Can somebody tell me how I can use Modern Fortran and 77 in the same project and get them to interoperate with one another? If you know of a manual somewhere, just tell me to go RTFM. Just need the link.

Try to set the fixed-form source code Manifest reference — Fortran Package Manager, although the default should allow you to mix .f with .f90 and infer the source form. Maybe you have some other problem, like you need different compiler options per file?

Assuming you created an fpm.toml manifest file with the “new” subcommand change the line

   source-form="free" 

to

    source-form="default"

The fpm(1) default was originally to depend on the compiler defaults. The de-facto standard compiler behavior is that a file suffix of .f is for fixed-format source and .f90 for free-format; and that capitalizing the
suffix indicates the files should be run through a pre-processor as well (typically cpp(1) or fpp(1)).

Now, to discourage the use of the restrictive old fixed-format style the default fpm.toml file generated by the “new” subcommand assumes all source files are free-format.

name = "showme"
version = "0.1.0"
license = "MIT"
author = "Jane Doe"
maintainer = "janedoe@mail.net"
copyright = "Copyright 2024, Jane Doe"
[build]
   auto-executables = true
   auto-tests = true
   auto-examples = true
   module-naming = false
[install]
   library = false
[fortran]
   implicit-typing = false
   implicit-external = false
   #########################  CHANGE "free" to "default"
   #source-form = "free"
   source-form = "default"
   #########################

From the manifest specification …

Source form

Allows to specifiy the source form to be used for all files in the
project. Possible choices are “free” to assume all files are free form
source, “fixed” to assume all files are fixed form source, and
“default” to let the compiler decide based on its own heuristics. The
default option is “free”.

Note this does not actually tell fpm(1) to allow mixed fixed and free format, it technically says to use the compiler default behavior.

Note some compilers even allow directives to be placed in the files to indicate if they are fixed or free format. This allows source to be cleanly combined and "INCLUDE"ed like in the past when all files were fixed-format but this is an extension.

For example:
https://cpe.ext.hpe.com/docs/guides/CCE/HPE_Cray_Fortran_Reference_Manual_17.0.1_S-3901.html#free-fixed

The Fortran standard itself says nothing about how to identify which sources are fixed and which are free-format so you would think the language would provide a standard directive for doing so, but it is mute on the subject even though storing source in text files is by far the most common method.

There are several tools for converting fixed-format to free-format. In the long run I would recommend switching rather than fighting it as the conversion to free-format often involves only changing line continuations and comment prefixes; and there are several products that make far more extensive modernizations of the code automatically.