        program compare                         !Disk Compare Utility
c
c                       Specifications Section
c
        include 'dccom.inc'

        integer*4 str$compare
        integer cli$present
        character*256 outfile
c
c                       Code Section
c
        page_line = 100                 !force page break
	printed = .false.
	dirsave(1) = '***'
	dirsave(2) = '***'

	call bld_ttab(table2,'0123456789 '//char(9),
     +   char(2)//char(2)//char(2)//char(2)//char(2)//
     +   char(2)//char(2)//char(2)//char(2)//char(2)//
     +   char(1)//char(1))
c
c               Get Command Arguments
c
        call cli$get_value('STREAM1',wspec(s1))
        indirect(1)=cli$present('DIRECTORY')
        call cli$get_value('STREAM2',wspec(s2))
        indirect(2)=cli$present('DIRECTORY')
        check_cre = cli$present('CREATION_DATE')
        check_rev = cli$present('REVISION_DATE')
        check_vers = cli$present('VERSION')
        check_size = cli$present('SIZE')
        if (cli$present('OUTPUT')) then
	    out_file = .true.
            call cli$get_value('OUTPUT',outfile)
            open(6,file=outfile,status='new')
	else
	    out_file = .false.
        endif
c
        call sys$asctim(,curdate,,)
c
        call open_stream(s1,wspec(s1))
        call open_stream(s2,wspec(s2))
c
        call get_file(s1)
        if (eos(s1)) then
            write(6,1100) wspec(s1)(1:index(wspec(s1),' ')-1)
            call exit
        endif
        call get_file(s2)
        if (eos(s2)) then
            write(6,1100) wspec(s2)(1:index(wspec(s2),' ')-1)
            call exit
        endif
c
        call check_div
d 	print *,'Check_div called and returned:'
d	print *,'cstart(1) = ',cstart(1)
d	print *,'cendt(1) = ',cend(1)
d	print *,'cstart(2) = ',cstart(2)
d	print *,'cendt(2) = ',cend(2)
c
        do while (.not. (eos(s1) .and. eos(s2)))
d	    print *,'cstart(1) = ',cstart(1)
d	    print *,'cendt(1) = ',cend(1)
d	    print *,'cstart(2) = ',cstart(2)
d	    print *,'cendt(2) = ',cend(2)
d	    print *,'Filespecs are: ',fspec(s1),' and ',fspec(s2)
d	    print *,'Comparing ',
d    +       fspec(s1)(cstart(s1):cend(s1)),' with ',
d    +       fspec(s2)(cstart(s2):cend(s2))
            isw = str$compare(
     +       fspec(s1)(cstart(s1):cend(s1)),
     +       fspec(s2)(cstart(s2):cend(s2)))
            if (isw .lt. 0) then
                call put_file(left,s1)
                total_added(s1) = total_added(s1) + 1
                call get_file(s1)
            else if (isw .eq. 0) then
                call process_match(s1, s2)
                call get_file(s1)
                call get_file(s2)
            else
                call put_file(right,s2)
                total_added(s2) = total_added(s2) + 1
                call get_file(s2)
            endif
        enddo
        page_line = page_line + 14
        call page_check
        write (6,1010), total_files, total_checked, total_added,
     +   total_diff
1010    format('0',//t60,'S U M M A R Y'//,
     +   ' There were:',//,
     +   i10,' Files in Master',/,
     +   i10,' Files in Copy',/,
     +   i10,' Files Checked (Type not DIR, LIS, OBJ, HDR, MAP)',
     +       ' in Master',/,
     +   i10,' Files Checked (Type not DIR, LIS, OBJ, HDR, MAP)',
     +       ' in Copy',/,
     +   i10,' Files found in Master, but not in Copy',/
     +   i10,' Files found in Copy, but not in Master',/,
     +   i10,' Files with same name and type, but differing in ',
     +       'external',/,
     +   10x,' version, size, creation date, or revision date')
1100    format(' ***Specification error: "',a,
     +   '" has no checkable files.')
        end
