FTLINK COMMENTS
*-- Author : I.O. Skillicorn
      SUBROUTINE FTLINK
C     ORGANISE LINKING OF RADIAL MODULES                                                                      
C     AUTHOR   I.O.SKILLICORN                                                                                 
C     21/5/91  REDUCE SIZE                                                                                    
*   SUNDRY ARRAY DIMENSIONS...                                                                                
*KEEP,FRDIMS.                                                                                                 
*KEEP,FH1WORK.                                                                                                
*    Planar geometry                                                                                          
*                                                                                                             
*    Radial geometry                                                                                          
*                                                                                                             
*    Radial data...                                                                                           
*                                                                                                             
*    Planar Data                                                                                              
*                                                                                                             
*    Pointers into DIGI bank for IOS labelled hits                                                            
*                                                                                                             
*    Track segment data                                                                                       
*                                                                                                             
*    Fit data                                                                                                 
*                                                                                                             
*                                                                                                             
*KEND.                                                                                                        
*   VERTEX INFO...                                                                                            
*KEEP,FPTVTX.                                                                                                 
**the common/VERTEX/ becomes /VERTVV/ (in analogy to /VERTFF/) on the                                         
** 17/6/91, since it is in conflict with the VERTEX module (g.bernardi)                                       
** (note that all these common names should start by F in this deck...)                                       
*KEND.                                                                                                        
*                                                                                                             
*                                                                                                             
*     LOCAL ARRAYS...                                                                                         
*************************************************************                                                 
C      COMMON/FTWSEG/NIG,NNPTS(MAXTRK),NIRADG(36,MAXTRK),                                                     
C     1SDRADN(36,MAXTRK)                                                                                      
*************************************************************                                                 
C     DIMENSION IP12(36,MAXTRK),SD12(36,MAXTRK)                                                               
C     DIMENSION IP13(36,MAXTRK),SD13(36,MAXTRK)                                                               
C     DIMENSION IP23(36,MAXTRK),SD23(36,MAXTRK)                                                               
C     =1 FOR UNUSED SEGMENTS                                                                                  
C      NNPTS(J)=0                                                                                             
C      NIRADG(I,J)=0                                                                                          
C     JOIN  TRACK SEGMENTS                                                                                    
      CALL FTJN3(CF,IUSED,N123,LL123,RPC123,RPS123,PH123,
      CALL FTJN23(CF,IUSED,N23,LL23,RPC23,RPS23,PH23,
      CALL FTJN12(CF,IUSED,N12,LL12,RPC12,RPS12,PH12,
      CALL FTJN13(CF,IUSED,N13,LL13,RPC13,RPS13,PH13,
C     FILL BANK WITH TRACKS                                                                                   
C     STORE LINK POINTERS                                                                                     
C      WRITE(*,*)' 123 ',IG,RPCOSG(IG),RPSING(IG)                                                             
C     DO105 N=1,36                                                                                            
C     IF(IP123(N,I).GT.0)NPTS(IG)=NPTS(IG)+1                                                                  
C     IRADG(N,IG)=IP123(N,I)                                                                                  
C     SDRADG(N,IG)=SD123(N,I)                                                                                 
C105  CONTINUE                                                                                                
C     STORE LINK POINTERS                                                                                     
C      WRITE(*,*)'  23 ',IG,RPCOSG(IG),RPSING(IG)                                                             
C     DO115 N=1,36                                                                                            
C     IRADG(N,IG)=IP23(N,I)                                                                                   
C     IF(IP23(N,I).GT.0)NPTS(IG)=NPTS(IG)+1                                                                   
C     SDRADG(N,IG)=SD23(N,I)                                                                                  
C115  CONTINUE                                                                                                
C     STORE LINK POINTERS                                                                                     
C      WRITE(*,*)' 12  ',IG,RPCOSG(IG),RPSING(IG)                                                             
C     DO125 N=1,36                                                                                            
C     IRADG(N,IG)=IP12(N,I)                                                                                   
C     IF(IP12(N,I).GT.0)NPTS(IG)=NPTS(IG)+1                                                                   
C     SDRADG(N,IG)=SD12(N,I)                                                                                  
C125  CONTINUE                                                                                                
C     STORE LINK POINTERS                                                                                     
C      WRITE(*,*)' 1 3 ',IG,RPCOSG(IG),RPSING(IG)                                                             
C     DO135 N=1,36                                                                                            
C     IRADG(N,IG)=IP13(N,I)                                                                                   
C     IF(IP13(N,I).GT.0)NPTS(IG)=NPTS(IG)+1                                                                   
C     SDRADG(N,IG)=SD13(N,I)                                                                                  
C135  CONTINUE                                                                                                
C     PICK UP UNUSED TRACK SEGMENTS                                                                           
C      DO 210 I=1,NT                                                                                          
C      IF(IUSED(I,II).EQ.1)GOTO210                                                                            
C      NIG=NIG+1                                                                                              
C     IG=IG+1                                                                                                 
C**********************************************************************                                       
C     IF(NIG.GT.MAXTRK)THEN                                                                                   
C     NIG=MAXTRK                                                                                              
C     NNPTS(NIG)=0                                                                                            
C     ENDIF                                                                                                   
C     IF(IG.GT.MAXTRK)THEN                                                                                    
C     IG=MAXTRK                                                                                               
C     NNPTS(IG)=0                                                                                             
C     ENDIF                                                                                                   
C**************************************************12/10/87************                                       
C      RPCOSG(IG)=PCOSL(I,II)                                                                                 
C      RPSING(IG)=PSINL(I,II)                                                                                 
C      PHZG(IG)=PHZL(I,II)                                                                                    
C      ZIG(IG)=RZI(I,II)                                                                                      
C     DO 215 N=1,12                                                                                           
C     NN=NS+N                                                                                                 
C     NIRADG(NN,NIG)=IRPT(N,I,II)                                                                             
C     IF(IRPT(N,I,II).GT.0)NNPTS(NIG)=NNPTS(NIG)+1                                                            
C     SDRADN(NN,NIG)=SDRFT(N,I,II)                                                                            
C215  CONTINUE                                                                                                
C 210  CONTINUE                                                                                               
*-----Debug--------------------------------------                                                             
*     WRITE(6,'('' ***FTLINK>> '',I5, ''  tracks found'')')IG                                                 
*     DO 170 I=1,IG                                                                                           
*         PRINT 2330,I,(IRADG(J,I),J=1,36)                                                                    
*2330 FORMAT (' LINK ',1X,I3,1X,12I2,1X,12I2,1X,12I2,F6.2)                                                    
*170  CONTINUE                                                                                                
*GB   DO 175 I=1,NIG                                                                                          
*         PRINT 2330,I,(NIRADG(J,I),J=1,36)                                                                   
*175  CONTINUE                                                                                                
*------------------------------------------------                                                             
*