Compute Canada

How do I maintain multiple program versions using the HWT?

Please note: The FAQ pages at the HPCVL website are continuously being revised. Some pages might pertain to an older configuration of the system. Please let us know if you encounter problems or inaccuracies, and we will correct the entries.

The HWT's first function is to process source code. It is often desirable to produce several versions of a program, and quite frequently these versions have a large degree of overlap, ie, parts of the code are used by several of them. The HWT allows the user to keep code for multiple versions in a single "original" source code file, which is then used to generate code corresponding to each version separately.

This is done by means of so-called pre-processor constructs. These commonly have the following form:

    (...Code A...) 
#ifdef KEYWORD1
(...Code Block 1...)
(...Code Block 2...)
(...Code B...)

The directives #ifdef, #else, and #endif are not used by a standard compiler, but by a pre-compiler such a cpp for C and C++, or fpp for Fortran. The HWT uses such pre-compilers to generate multiple versions of the code. In the above example, Code A and Code B would appear in all code versions. In contrast, Code Block 1 would only appear in code for which KEYWORD1 is defined, and Code Block 2 only in code for which it is not. The definitions for which KEYWORDs are associated with which version of the code is left to the user.

The user is asked to specify this and other details in a file called control. A template of such a file will be placed into the working directory the first time the HWT is executed. After the user has edited the control file and inserted the necessary pre-processor contructs, the HWT performs the following tasks when executed (by typing call.hwt):

  1. It detects all source code in the current working directory on the basis of file extensions.
  2. It pre-processes the code using cpp or fpp to generate the source code corresponding to different versions.
  3. It places the different version codes into separate directories and creates a makefile for each of them.
  4. It compiles the versions to create object files, modules, and executables.

Most of these actions are performed automatically. Details are specified in thecontrol file. For a detailed description of these features, please consult the manual.

Note that the HWT installation on HPCVL Sun SPARC machines was compiled with the Sun Studio compilers, which are the native compilers on these systems. This installation will only work properly with the Sun Studio compilers. If you are using other versions, please consider migrating, as there will be incompatibilities in the HT modules.