7 Linking with the library

At a Starlink node the library is available as an archive of object modules. Since it is intended primarily for Starlink application packages, the link command used is most probably ‘alink’. In that case link as follows:

     % alink a-task.o -L/star/lib ‘pda_link_adam‘

The library can equally well be used by ordinary programs:

     % f77 program.f -L/star/lib ‘pda_link‘

The pda_link and pda_link_adam scripts results in your program being linked with the Starlink Error Message Service (EMS). When an error report is to be made, the library will call EMS_SETC and EMS_REP, and you have to link your program against a version of these routines.

If you do not want to link against EMS, then you can provide your own replacements for the two EMS routines. Use the following code:

  *  File name might be mymsg.f
  
        SUBROUTINE EMS_SETC( MESSG )
        CHARACTER * ( * ) MESSG
        WRITE( *, * ) MESSG
        END
  
        SUBROUTINE EMS_REP( MNAME, MESSG, STATUS )
        CHARACTER * ( * ) MNAME, MESSG
        INTEGER STATUS
        END

Then link:

     % f77 program.f mymsg.f -L/star/lib -lpda

Finally, if your site is not a Starlink site, you can customise the library as such to make EMS obsolete. For this you have to replace the error handling routine PDA_XERMSG in the library. The new code should be

  *  File name would be pda_xermsg.f
  
        SUBROUTINE PDA_XERMSG( LIBRAR, SUBROU, MESSG, NERR, LEVEL, STATUS )
  
        CHARACTER * ( * ) LIBRAR, SUBROU, MESSG
        INTEGER NERR, LEVEL
        INTEGER STATUS
  
        WRITE( *, * ) LIBRAR // ’/’ // SUBROU // ’: ’ // MESSG
        STATUS = 1
  
        END

You might also modify the link script pda_link so that it does not refer to ems_link any more and does not execute any awk command:

  
  #  N.B. the previous line should be blank.
        echo -lpda