next up previous contents index
Next: Named Constants Up: Specifying Data Type Previous: IMPLICIT Statement


There are two diametrically opposed schools of thought on type specification. The first holds that all names should have their types specified explicitly. This certainly helps programmers to avoid mistakes, because they have to think more carefully about each item. It also helps the compiler to diagnose errors more easily, especially if the it knows that all names are going to be declared in advance. Some Fortran compilers allow a statement of the form ``IMPLICIT NONE" which makes all names typeless by default and so requiring every name to be explicitly typed. Others have a compile-time switch with the same effect. If yours does not you may be able to produce a similar effect by using something like:
near the beginning of each program unit which is likely to cause an error for anything not explicitly typed. One disadvantage of the practice of declaring all names in advance is that the program may become so cluttered with specification statements that it may obscure its structure and algorithm.

The alternative way of working is to make maximum use of implicit types to reduce the number of statements. This means, of course, that the first letter of each name has to be chosen to suit the type, leaving no more than five to be chosen freely: this makes it harder than ever to devise meaningful symbolic names. As a result, Fortran programs often include names like RIMAGE or ISIZE or KOUNT. Clearly type statements are still needed for character type because it is usually necessary to use items of a number of different lengths.

Experience suggests that either system can be satisfactory provided it is used consistently. However the wholesale reassignment of initial letters with IMPLICIT statements usually increases the chance of making a mistake. IMPLICIT, if used at all, should only reassign one or two rarely-used letters to the less common data types, for example:

      COMPLEX (X)
It is also prudent to use an identical IMPLICIT statement in each program unit, otherwise type mismatches are more likely to be made in procedure calls.

next up previous contents index
Next: Named Constants Up: Specifying Data Type Previous: IMPLICIT Statement
Helen Rowlands