      PROGRAM UERSRC2T                                                          
C                                                                               
      INTEGER*4     LUN,SINF(2),SRR,ERR                                         
      LOGICAL       STATUS                                                      
      CHARACTER*80    TEXT                                                      
C                                                                               
C     TEST(1):CALL UERSRC WITH FINISH LESS THAN START                           
C     ***********************************************                           
C                                                                               
      CALL RITE(1)                                                              
      LUN=IGETLU()                                                              
      WRITE(7,100)LUN                                                           
      CALL UERSRC(LUN,2,5,3,TEXT,STATUS)                                        
      IF (STATUS) THEN                                                          
          WRITE(7,'(3X,A)')'CHECK TEST (1)'                                     
      ENDIF                                                                     
C                                                                               
C                                                                               
C     TEST (2):CALL UERSRC WITH INCORRECT FORMAT IN .ERR FILE.                  
C     ********************************************************                  
C                                                                               
      CALL RITE(2)                                                              
      STATUS=.TRUE.                                                             
      CALL UERFIL(LUN,'SCR2TEST',STATUS,SINF)                                   
      CALL UERSRC(LUN,1,8,13,TEXT,STATUS)                                       
      WRITE(7,200)STATUS                                                        
      CLOSE(UNIT=LUN)                                                           
C                                                                               
C                                                                               
C     TEST (3):CALL UERSRC WITH ITEM OUT OF RANGE.                              
C     ********************************************                              
C                                                                               
      CALL RITE(3)                                                              
      CALL UERFIL(LUN,'SCR3TEST',STATUS,SINF)                                   
      CALL UERSRC(LUN,6,7,11,TEXT,STATUS)                                       
      WRITE(7,200)STATUS                                                        
      CLOSE(UNIT=LUN)                                                           
C                                                                               
C                                                                               
C     TEST (4):CALL UERSRC WITH ITEM NOT IN FILE.                               
C     *******************************************                               
C                                                                               
      CALL RITE(4)                                                              
      CALL UERFIL(LUN,'SCR4TEST',STATUS,SINF)                                   
      CALL UERSRC(LUN,3,6,9,TEXT,STATUS)                                        
      WRITE(7,200)STATUS                                                        
      CLOSE(UNIT=LUN)                                                           
C                                                                               
C                                                                               
C     TEST (5):SEARCH FOR CORRECTLY SET UP FILE.                                
C     ******************************************                                
C                                                                               
      CALL RITE(5)                                                              
      CALL UERFIL(LUN,'SCR5TEST',STATUS,SINF)                                   
      WRITE(7,500)SINF(1),SINF(2)                                               
C                                                                               
      SRR=3                                                                     
      ERR=SINF(1)+2                                                             
C                                                                               
      DO 5000 I=1,5                                                             
          CALL RITE2(5,I)                                                       
          CALL UERSRC(LUN,I,SRR,ERR,TEXT,STATUS)                                
          IF (STATUS) THEN                                                      
              WRITE(7,510)I,TEXT                                                
          ELSE                                                                  
              WRITE(7,520)I                                                     
          ENDIF                                                                 
5000  CONTINUE                                                                  
C                                                                               
      SRR=SINF(1)+3                                                             
      ERR=SINF(1)+SINF(2)+2                                                     
      DO 5100 I=1,10,3                                                          
          CALL RITE2(5,I)                                                       
          CALL UERSRC(LUN,I,SRR,ERR,TEXT,STATUS)                                
          IF (STATUS) THEN                                                      
              WRITE(7,510)I,TEXT                                                
          ELSE                                                                  
              WRITE(7,520)I                                                     
          ENDIF                                                                 
5100  CONTINUE                                                                  
C                                                                               
C                                                                               
C     FORMAT STATEMENTS                                                         
C     *****************                                                         
C                                                                               
100   FORMAT(3X,'LUN=',I3)                                                      
200   FORMAT(3X,'STATUS=',L)                                                    
500   FORMAT(5X,'SINF(1)=',I3,10X,'SINF(2)=',I3)                                
510   FORMAT(3X,I,2X,A)                                                         
520   FORMAT(3X,'TEST FAIL ON RECORD=',I3)                                      
C                                                                               
      STOP                                                                      
      END                                                                       
C                                                                               
      SUBROUTINE RITE(J)                                                        
C                                                                               
      INTEGER*4  J                                                              
C                                                                               
      WRITE(6,100)                                                              
      WRITE(7,100)                                                              
      WRITE(6,200)J                                                             
      WRITE(7,200)J                                                             
      WRITE(6,300)                                                              
      WRITE(7,300)                                                              
C                                                                               
                                                                                
100   FORMAT(X,//)                                                              
200   FORMAT(3X,'TEST(',I,')')                                                  
300   FORMAT(X,/)                                                               
C                                                                               
      RETURN                                                                    
      END                                                                       
C                                                                               
      SUBROUTINE RITE2(K,L)                                                     
      INTEGER*4  K,L                                                            
C                                                                               
      WRITE(6,100)                                                              
      WRITE(7,100)                                                              
      WRITE(6,200)K,L                                                           
      WRITE(7,200)K,L                                                           
      WRITE(6,300)                                                              
      WRITE(7,300)                                                              
C                                                                               
100   FORMAT(X,//)                                                              
200   FORMAT(5X,'SUBTEST(',I,'.',I,')')                                         
300   FORMAT(X,/)                                                               
C                                                                               
      RETURN                                                                    
      END                                                                       
