Introduction

Rapid changes in computer technology, and an increasing diversity of computer languages, are adding to the problems of developing large-scale computer software that is both portable and efficient. This is especially true for large systems that are to be implemented by inexperienced users. The challenge of achieving 'portability with efficiency' increases as machine-types and options proliferate, and software development costs often exceed the cost of computer hardware. It is now apparent that as the rate of computer-obsolescence increases, the need for software mobility has become an essential consideration for computer-intensive disciplines.

A crucial factor in achieving software portability is the choice of a suitable language. Compilers must be universally available and conform to strict syntactical standards. For number-crunching software the language must also be efficient. If at all possible the compiler should 'match' the local computer environment. Only three languages approach these requirements. They are Fortran77, Pascal and C. However, all suffer from version incompatibilities, and a lack of portability for certain machine-specific operations (e.g bit-packing or graphics). We thus return to the dilemma that confronts the software developer: 'How can the apparently mutually-exclusive properties of portability and machine-specificity be accomodated in a single language?'.

One solution is to use a preprocessor. Source code written in preprocessor language is translated into a locally available language (such as Fortran77, Pascal or C). The obvious advantage of this approach is that the preprocessor language can be made extremely portable, and can be adapted to the local compiler. The preprocessor language ratfor (Kernighan & Plauger, 1976) translates into Fortran77. Ratmac is an improved form of ratfor coupled with a powerful inline macro facility (Munn et al., 1980).

Ratmac is arguably the most adaptable language currently available for large-scale applications. It achieves portability through a macro facility which enables all machine-specific code to be isolated from the program source. In effect macros provide inline substitution and the global editing of a program during the preprocessing stage. Macro definitions are grouped at the front of a program and contain all information which is machine-specific. All references to word size, character size, bytes, bit-packing, device numbers, device buffer lengths (input, output and files) are handled via macros. These are defined once for the system as macro 'primitives' and all constructs that use machine-specific information use this type of macro. A hierarchy of sophisticated macros can be built from the primitive macros through the application of macro-arithmetic.

With careful planning, only a few macro definitions need be changed when transporting a ratmac program to a new machine. The Xtal System contains over 200,000 lines of ratmac code. Of the 125 macro definitions only 25 are machine-specific primitives. The macros for all machines are contained within this macro library. Macro definitions for the target machine are automatically extracted during the preprocessing of the Xtal source.

These macros provide the tools essential for developing portable code. What about efficiency? This is again where the macro facility is so important. If all machine-specific parameters are embedded in macro definitions, programs can be easily tailored to a given machine. In this way special software and hardware features can be invoked via the macros without changing one line of 'active' code.

What about the other desirable properties such as ease-of-use and flexibility? Ratmac provides structured commands that enable 'top-down' programming. It permits inline commenting and multi-line statements. It looks like Fortran but without cumbersome statement numbers, and has much better control instructions (e.g. FOR, REPEAT, WHILE, NEXT, BREAK). There is in fact no limit to the control instructions in ratmac. Since the syntax of the language is under the control of the program developer, additional commands can be added to the preprocessor repertoire provided the syntactical construct can be translated into Fortran.

A concomitant advantage of ratmac is that the programmer, and the user, are largely isolated from changes to the Fortran standard. This is an important consideration. Further changes to Fortran standards will occur and when they do, only the preprocessor need be adjusted in order to convert existing ratmac code into the new version. This level of adaptability is only possible because the ratmac preprocessor is non-proprietory. It may be adapted and modified, without the constraints of copyright, to suit the needs of the program developer. It may also be distributed with the software package at little or no cost to the user. And, since the ratmac preprocessor is itself written in ratmac, it may be used (via its own macro set) to generate a Fortran version for another machine.

Finally, this new version of the ratmac-to-Fortran preprocessor is one of a continuing series of developments associated with this language. In the future other versions of the preprocessor will enable ratmac software to be converted for other compilers. A ratmac-to-C preprocessor is being designed for application in Unix environments.

The appropriate references are:

Kernighan, B.W. and Plauger, P.J. 1976. Software Tools . Addison-Wesley: Massachusetts.

Munn, R.J., Stewart, J.M., Norden, A.P. and Pagoaga, M.K. 1980. Ratmac Primer Technical Report LBL-11847 / TR-804. N.R.C.C./ University of Maryland, Joint Publication.

Favas, M.C. & Hall, S.R. 1989. Qchem1.0 System Manual. University of Western Australia.