plusFORT Automake and Qmerge

Automake and Qmerge

Minimal Re-Compilation for Fortran and C

If, after a series of edits, you have ever forgotten what you changed and what you left alone, then AUTOMAKE is for you. Invoke AUTOMAKE, typically by typing “AM”, and it updates your executable by compiling the minimum possible set of source files, and re-linking. In doing this, it takes account not only of changes or additions to source files, but also changes to INCLUDEd files and Fortran 90 modules. For example, if you change a file which is included in half a dozen source files, AUTOMAKE ensures that these files are re-compiled, even though they were not themselves changed.


Version 5.10 and above includes support for Fortran 90 modules

No make-file – just type “AM”.

AUTOMAKE can be regarded as a fully automatic alternative to the Linux style MAKE utility. Unlike MAKE, AUTOMAKE builds and maintains the dependency database (or “make-file”) itself. This removes a major source of error: users of a conventional MAKE may omit a dependency or specify it wrongly. If that happens (and anyone can make a mistake!), MAKE may appear to update a program correctly, while in fact building a corrupt hybrid of new and old code. The consequences may not be immediately apparent, and can be extremely hard to trace. This is precisely the sort of problem that MAKE is supposed to avoid.

AUTOMAKE users do not have that problem because dependency data is maintained automatically by AUTOMAKE. AUTOMAKE checks for new or deleted source files, and scans source code as necessary to update INCLUDE file dependencies.

To put it another way, AUTOMAKE handles the one dependency that conventional MAKE utilities choke on – that of the make-file on the source code.

Usually, the only data required from the user are the executable file name, and the compile and link commands; these are specified in a simple configuration file. Complex systems, perhaps involving different compilers, and source code spread across many directories can also be handled with minimal customisation effort.

AUTOMAKE is compatible with all common Fortran 77 and Fortran 90 compilers, including those from Intel, Salford, Absoft and Lahey, and with C++ compilers from Intel, Microsoft and Borland, as well as common compilers under Linux, Unix and VMS.



QMERGE – Version Selection

QMERGE is an unusual program, but it tackles a common problem – how to keep control of programs which exist in a number of different versions. A common application is programs which run on a variety of different machines, and require slight changes to the source code for each one. For example, there may be different file naming conventions, word length, or different ways of accessing the system.

QMERGE allows the user to keep all the code variants within the master version of the source code. It comments and un-comments sections of code, depending on the setting of user-defined logical flags. Unlike a macro pre-processor or a conditional compilation tool, QMERGE does not require that you deviate from ANSI standard FORTRAN, or that you pre-process code before compiling it – the master version is legal FORTRAN and can be compiled directly. QMERGE is needed only when you switch from one version to another.

The example shows how QMERGE could be used to switch between the VMS and UNIX versions of a code fragment: all the required conditions were entered on the command line. Thus



means that UNIX is true and VMS is false. If QMERGE needs to know the value of a condition which is not specified, it issues a prompt

Is IBM370 true? (Y or N) ==>

Other QMERGE facilities allow you to specify defaults, select from a list of alternatives, concatenate and nest conditions etc.


      PRINT *,'DEC VAX version 1.1'
      file = '[users.john]prog1.for'  
*-      PRINT *,'UNIX version 1.1'
*-      file = '/usr/john/prog1.f'
*-      PRINT *,'DEC VAX version 1.1' 
*-      file = '[users.john]prog1.for'  
      PRINT *,'UNIX version 1.1'
      file = '/usr/john/prog1.f'

Just Another Macro Pre-processor?

No! QMERGE is simpler – and in this context, that is a virtue. All too often complex, non-standard pre-processors are used to solve simple problems, perhaps in place of the standard Fortran PARAMETER statement.

The advantages of the QMERGE approach are:

  • There is no need to run the pre-processor before every compilation – just when the program is ported from one machine to another.
  • Users can see exactly how their source code will be presented to the compiler.
  • Negligible learning curve.
  • Less scope for “clever” but impenetrable programming.

The Next Steps