C******************************************************************             
C*                                                                              
C* FILENAME : GETSIG                                                            
C*                                                                              
C* AUTHOR   : A.MCKINNA                                                         
C*                                                                              
C* COMPANY  : CAP SCIENTIFIC                                                    
C*                                                                              
C* LAST MODIFIED : 09/11/81                                                     
C*                                                                              
C* DESCRIPTION   : XXXX                                                         
C*                                                                              
C* CALLS         : XXXXXXXXXX  :  XXXXXXXXXX                                    
C*                                                                              
C* COMMON        : XXXXXXXXXX R/W XXXXXXXXX                                     
C*                                                                              
C* PARAMETERS    : XXXXXXXXXX R/W XXXXXXXXX                                     
C*                                                                              
C* LOCALS        : XXXXXXXXXX R/W XXXXXXXXXX                                    
C*                                                                              
C*********************************************************************          
C                                                                               
C                                                                               
      SUBROUTINE GETSIG(TR,TI,LENGTH,KNAME,IERR)                                
C                                                                               
      INTEGER LENGTH,IERR                                                       
      INTEGER INCH,OUCH,DTCH                                                    
      CHARACTER*1 KNAME*8                                                       
C                                                                               
      INTEGER TR(LENGTH),TI(LENGTH)                                             
C                                                                               
C                                                                               
      INTEGER IST                                                               
      INTEGER FLEN                                                              
      COMMON/CHANNEL/INCH,OUCH,DTCH                                             
C                                                                               
C                                                                               
C                                                                               
      OPEN(UNIT=DTCH,IOSTAT=IST,ERR=9999,FILE=KNAME,SHARE="SRO")                
C                                                                               
      READ(DTCH,"(I4)")FLEN                                                     
C                                                                               
      IF(LENGTH.GT.FLEN)THEN                                                    
C         *REQUIRED DATA LENGTH EXCEEDS FILE LENGTH ; TAKE ALL FILE             
C         *DATA AND ZERO THE REST OF THE ARRAY.                                 
          CALL GSIG2(TR,FLEN)                                                   
          IREST=LENGTH-FLEN                                                     
          CALL ZERO(TR(FLEN+1),IREST)                                           
      ELSE                                                                      
C         *FILE LENGTH GREATER THAN REQUIRED DATA LENGTH - READ ALL             
          CALL GSIG2(TR,LENGTH)                                                 
      ENDIF                                                                     
C                                                                               
C                                                                               
 9999 CONTINUE                                                                  
      IERR=IST                                                                  
      RETURN                                                                    
      END                                                                       
C                                                                               
C                                                                               
C***************************************************************                
C                                                                               
C                                                                               
      SUBROUTINE GSIG2(TR,LENGTH)                                               
C                                                                               
      REAL TR(LENGTH)                                                           
      INTEGER LENGTH                                                            
C                                                                               
      INTEGER INCH,OUCH,DTCH                                                    
C                                                                               
      COMMON/CHANNEL/INCH,OUCH,DTCH                                             
C                                                                               
C                                                                               
      DO 200 I=1,LENGTH                                                         
      READ(DTCH,"(F15.6)")TR(I)                                                 
  200 CONTINUE                                                                  
C                                                                               
      RETURN                                                                    
      END                                                                       
