I have inherited some FORTRAN code which makes calls to routines written in 'C' and I keep running into runtime errors where parameters are passed or interpreted incorrectly. I have tried using 'INTERFACE' in the FORTRAN code to ensure parameters are passed consistently but it appears that the INTERFACE needs to be declared in every FORTRAN subroutine that makes the calls to 'C'. If you forget to include it, the code compiles but crashes at run-time because it reverts to the default (by ref) calling convention. This is very hard with large programs and is prone to human error. Is there a way to ensure that all FORTRAN subroutines use the correct calling convention without having to search through and include the INTERFACE statements? Perhaps it is better NOT to do this and to ensure that the 'C' code expects parameters to be passed by reference? This seemed like a reasonable approach to me but the FORTRAN compiler appears to allow different size INTEGERS to be passed so the 'C' code might get a pointer to an INTEGER*2 or an INTERGER*4 and BOOM! more runtime errors.
Any advice on how to do this in a consitent and robust way would be greatly appreciated. Please note that I am a C/C++ programmer and know almost zero about FORTRAN (but willing to learn)