12 Writing TSP programs

Programs to access TSP data files should be written to make use of the TSP subroutine library (TSPSUBS) rather than making direct use of the HDS DAT_ routines. The TSPSUBS routines are described in Appendices C and D. They allow the building of new TSP structures, the reading and writing of items from the structures, and the mapping of data arrays (data arrays are always accessed by mapping in TSP programs. The only DAT_ routines that are used in TSP programs are those associated with the ADAM parameter system such as DAT_CREAT and DAT_ASSOC, and also DAT_ANNUL. Below is an example of an ADAM A-task that makes a copy of a TSP data structure using the routine TSP_COPY

  
  
        SUBROUTINE COPY(STATUS)
  *
  *  Copy a TSP structure
  *
        IMPLICIT NONE
        INTEGER STATUS
        INCLUDE ’SAE_PAR’
        CHARACTER*(DAT__SZLOC) LOC,LOC2
  
  
        CALL DAT_ASSOC(’INPUT’,’READ’,LOC,STATUS)
        CALL DAT_CREAT(’OUTPUT’,’NDF’,0,0,STATUS)
        CALL DAT_ASSOC(’OUTPUT’,’WRITE’,LOC2,STATUS)
        CALL TSP_COPY(LOC,LOC2,STATUS)
        CALL DAT_ANNUL(LOC,STATUS)
        CALL DAT_ANNUL(LOC2,STATUS)
  
        END
  

Such a program could be linked with the command

  
    alink copy ‘tsp_link_adam‘

on UNIX systems, and

  
   $ ALINK COPY,TSP_DIR:TSPSUBS
  

on VAX/VMS systems.