Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Announcement] Compilation Cascade

10 views
Skip to first unread message

Karsten Chmielewski

unread,
Nov 19, 2002, 9:08:25 AM11/19/02
to
Dear Fortran community,

after recurring discussions in this channel about what has become known
as the "compilation cascade" I decided to wrap a set of small tools and
my Makefile set-up into a small package which is available from

http://www.rvs.uni-hannover.de/people/chmielewski/fortran

I have been using this set-up with different compilers on various
architectures. The readme file is attached below.

With best regards,
Karsten Chmielewski
----

===================================================
Avoiding the Compilation Cascade in Fortran 90/95
===================================================

This package contains a Fortran sample project which demonstrates how
the compilation cascade can be minimized. That goal is achieved through
a combination of Perl-scripts and Makefile set-up. It is intended to be
used with the GNU-incarnation of `make'.

Usage
-----

The Perl-scripts reside within the directory `bin'. To mimic the
usage with a somewhat larger project where source files are distributed
among several directories the sources are contained in the `lib' and
`sample' directories. The sample project files depend on modules
defined in lib.

To build the project type `make -r' in the main directory. Note
that it might be necessary to change compiler-related settings like the
compiler name or the option for the module-file search path. Those
settings are maintained in a central Makefile in the directory
`makingof' which is included from all relevant Makefiles. It is
necessary to specify the option `-r' since by default GNU make
associates the extension `.mod' with Modula language files.

Description
-----------

Fortran compilers create module description files when compiling
source files with module definitions. Those module description files
are accessed when compiling other source files which "USE" the module.
The module description files contain the complete interface description
of the module as far as the compiler is concerned. Module description
files are created during compilation irrespective whether the actual
interface has changed or not. Since the make build-mechanism is based
on time stamps, this forces all source code files using such a module to
be recompiled as well, possibly triggering the compilation of further
source files. This phenomenon has become known as "compilation
cascade".

The following mechanism is used to circumvent this behavior: In a
first step a dependency file is created automatically from a
Perl-script. The dependency file is included from the relevant
Makefile. It lists all inter-file dependencies and defines variables
for the use with make. As its first goal it frees the user from
maintaining the dependency file by himself.

In the second step the rule to generate object files from Fortran
source files is changed in such a way that the old module description
file is backed-up and later on compared to the newly created module
description file. If they differ, according to the output of the `cmp'
command, the older file is deleted. Otherwise, the old file is moved
back and used as the valid module description file. Since its original
time stamp is kept further compilation is suppressed in this case.
(Note that this is possible since GNU-make allows empty commands;
thereby keeping the build chain complete.)

Remarks
-------

A problem arises with compilers which put time stamps in the,
possibly binary, module description file themselves. However, one can
often step around this. For example, some compilers with this behavior
put the time stamp at the beginning of the file: In this case one can
use the GNU version of the cmp which allows to ignore bytes at the file
start. (I recently made my own version for use with the IBM xlf
compiler which puts the time-stamp at the end of the module description
file.)

Dependency Script
-----------------

The list of inter source file dependencies is automatically created
with the Perl-script `makedep.pl' in the `bin' directory. It expects
all Fortran source files to be listed on the command line and writes to
standard output. (However, using the make mechanism described above the
script does not have to be invoked manually.) It has the following
features:

- The suffix of module description files to be specified via the
--modname command line option. Otherwise the default ".mod" is
used.

- Full path names can be produced with the option --fullpath.

- The case of the filename of the module description files can be
changed to upper case with the option --upcase (e.g., useful for
Cray).

- Multiple module definitions per source file are handled
correctly.

(c) 2002 Karsten Chmielewski

Please send any comments or suggestions to

my_las...@rrzn.uni-hannover.de

0 new messages