21 Building a monolith

The procedure used to create a monolith containing the ADDCONST and REPDIM2 programs is shown below. (Of course, monoliths usually comprise many more than two programs.) All the files described are in ADAM_EXAMPLES.

Firstly, a library is created to contain the object code of all the programs intended to comprise the monolith. In this example the library is called MIXLIB.OLB.16

  $ LIB/CREATE MIXLIB           ! Creates MIXLIB.OLB
  $ LIB MIXLIB ADDNEW,REPDIM2   ! Puts ADDNEW.OBJ & REPDIM2.OBJ into MIXLIB.OLB

A master program which calls the program corresponding to the command entered must now be written. MIXTURE.FOR below will call ADDNEW or REPDIM2 as appropriate.

        SUBROUTINE MIXTURE (NAME, STATUS)
        IMPLICIT NONE
        INCLUDE ’SAE_PAR’
        CHARACTER*(*) NAME
        INTEGER STATUS
        IF (STATUS.NE.SAI__OK) RETURN
        IF (NAME.EQ.’ADDNEW’) THEN
           CALL ADDNEW (STATUS)
        ELSEIF (NAME.EQ.’REPDIM2’) THEN
           CALL REPDIM2 (STATUS)
        ENDIF
        END

This program must now be compiled and linked. The special MLINK command is used to link monoliths. The object code library, MIXLIB, and anything else needed to link the constituent programs (e.g. graphics libraries) should also be included in the link.

  $ FOR MIXTURE
  $ MLINK MIXTURE,MIXLIB/LIB

A monolith interface file containing the interface files for each of the constituent programs must now be created. MIXTURE.IFL is shown below. Note that the file begins with the line “monolith monolith-name” and ends with “endmonolith”. All the necessary interface files are simply included in between.

  monolith mixture
    interface addconst
     ...
    interface repdim2
     ...
  endmonolith

MIXTURE.ICL, an ICL command file to define the commands in the monolith should now be written. Each command points to the monolith which contains the program i.e. MIXTURE.EXE.

  define addnew  mixture
  define repdim2 mixture

To try the monolith, simply enter ICL and load the procedure MIXTURE.ICL to define the commands. The first command which specifies a program in the monolith will cause the monolith to be loaded.

  $ ICL
  ICL> LOAD MIXTURE     ! Defines commands
  ICL> REPDIM2          ! Loads MIXTURE monolith

16Of course this step is not really necessary; you could simply list all the .OBJ files individually at the link stage.