We have a new Fortran 2003 code which calls and is linked to a Fortran 77 library (in an external package). Is there any way to write declarations for the F77 functions and subroutines in the external library in F2003, to ensure an error message is given if functions are called with the wrong argument types? One way would be to write wrappers for each function, but this seems a lot of work.
(Incidentally, the F77 code is actually wrappers for calling C code. Ideally it would be better to rewrite the C wrappers in F2003, but that's also a lot of work).
The intel compiler, ifort, has the option -gen-interfaces. I think that this option does exactly what you need. Unlike the gfortran compiler (which unfortunately does not have this feature), ifort costs money, Perhaps you can get someone to run ifort -gen-interfaces once for your really old fortran77stuff? I assume that the fortran77 code no longer changes, so the generated *__genmod.f90 can be used and do not have to be generated time and again.
An alternative is to make a module:
MODULE NOSTALGIA77
CONTAINS
include 'file1.f'
...
include 'fileN.f'
END MODULE NOSTALGIA77
Now when you compile the module and not the separate files, you can use the functions and subroutines after adding USE NOSTALGIA77 to your Fortran2003-code, and the compiler will check the correctness of your calls.
Note: the example assumes that the fortran77 code contains only subroutines. If it contains other stuff as well (BLOCK DATA and other things we don't want to remember), the module may be a little more difficult to make because some stuff will come before the CONTAINS and some after. But it can still be done (and not in too much time).
Good luck!
Edit:
Perhaps https://shroud.readthedocs.io/en/latest/ can help you. I did a few small tests (see https://shroud.readthedocs.io/en/latest/appendix-A.html). What seemed to work is to put a few lines of your header files in a yaml file clibrary.yaml, each line preceded by '-decl':
declarations:
- decl: void NoReturnNoArguments()
- decl: double PassByValue(double arg1, int arg2)
I suppose this yaml file can easily be constructed from your header files using sed, awk, python or whatever scripting language you like. Next, all you run is shroud clibrary.yaml, and out comes a fortran module libray_mod, which you can include and then all your functions are available, and their usage is tested.