10 Making your own software package

 10.1 Monoliths
 10.2 Example 13 – A monolith

10.1 Monoliths

Sometimes it can be useful to group several applications together into one package. The result is called a monolith. A monolith consists of a “top level” code which then calls the various applications as needed. The monolith also has its own interface file (whose structure is slightly different from those of applications). The following monolith brings together examples 8a, 8b, and 8c into a single package called newndf.

10.2 Example 13 – A monolith

Code:

         SUBROUTINE NEWNDF(STATUS)
  *
  * This monolith puts together all three create applications
  * into a single package.
  *
         INCLUDE ’SAE_PAR’
         INCLUDE ’PAR_PAR’
         INTEGER STATUS
         CHARACTER * (PAR__SZNAM) ACTION
  *
         IF (STATUS .NE. SAI__OK) RETURN
  *
  * Get the action name
  *
         CALL TASK_GET_NAME(ACTION,STATUS)
  *
  * Go through the commands
  *
         IF (ACTION .EQ. ’CREATE’) THEN
           CALL CREATE(STATUS)
         ELSEIF (ACTION .EQ. ’CREATE2’) THEN
           CALL CREATE2(STATUS)
         ELSEIF (ACTION .EQ. ’CREATE3’) THEN
           CALL CREATE3(STATUS)
         ELSE
           WRITE (*,*) ’Dunno!’
         ENDIF
         END

Note how the names of the three separate tasks are in CAPITAL LETTERS. Lower case will not work, even though the filenames of your applications usually are lower case. The corresponding interface file is:

  monolith NEWNDF
  
  interface CREATE
    parameter LBND
      position 1
      type _INTEGER
      prompt ’Lower bound’
    endparameter
    parameter UBND
      position 2
      type _INTEGER
      prompt ’Upper bound’
    endparameter
    parameter OUT
      position 3
      prompt ’Output NDF’
    endparameter
  endinterface
  
  interface CREATE2
    parameter LBND
      position 1
      type _INTEGER
      prompt ’Lower bound’
    endparameter
    parameter UBND
      position 2
      type _INTEGER
      prompt ’Upper bound’
    endparameter
    parameter OUT
      position 3
      prompt ’Output NDF’
    endparameter
    parameter TITLE
      position 4
      type ’Literal’
      prompt ’Title’
    endparameter
  endinterface
  
  interface CREATE3
    parameter LBND
      position 1
      type _INTEGER
      prompt ’Lower bound’
    endparameter
    parameter UBND
      position 2
      type _INTEGER
      prompt ’Upper bound’
    endparameter
    parameter OUT
      position 3
      prompt ’Output NDF’
    endparameter
    parameter TITLE
      position 4
      type ’Literal’
      prompt ’Title’
    endparameter
  endinterface
  
  endmonolith

To compile the code, alink is used thus:

  alink newndf.f create.f create2.f create3.f -L/star/lib ‘ndf_link_adam‘

but one further stage is still required to get the monolith to work. Soft links must be made from the monolithic executable to the names of the tasks it contains. In other words, to get the above example to work you must type:

  ln -s newndf create
  ln -s newndf create2
  ln -s newndf create3

Most Starlink packages also use a script to set up aliases to these soft links. For example, when Figaro is started, the user is really running a script called:

  /star/bin/figaro/figaro.csh