C	THIS PROGRAM READS FLOATING POINT DATA FILE SA10 AND SA11,
C	BOTH WERE PRODUCED BY SARRAY.F ON SUN3. SA10 CONTAINS 10
C	NUMBERS WHILE SA11 CONTAINS 12.
C	
C	THIS PROGRAM READS FROM THE INPUT FILES 8 BYTES EACH TIME
C	AND STORE THE 8 BYTES INTO ARRAYS SA10(5) AND SA11(6) 
C	RESPECTIVELY.
C	IT THEN CALLS SCUP32() TO UPPACK THE SUN FLOATING POINT
C	NUMBERS INTO CRAY FLOATING POINT NUMBERS AND STORES THOSE
C	NUMBERS INTO CA10(10) AND CA11(11) RESPECTIVELY.
C	CSPK32() IS THEN CALLED TO REPACK CA10(10) AND CA11(11)
C	INTO SUN FLOATING POINT ARRAYS, SB10(5) AND SB11(6).
C	COMPARE SB10(5) WITH SA10(5). THEY SHOULD BE THE SAME.
C	WHILE COMPARE SB11(6) WITH SA11(6), THE 6TH ENTRIES 
C	ARE DIFFERENT. IT IS BECAUSE THAT CA11(11) HAS ONLY 11
C	ENTRIES. THE HIGH 4 BYTES OF SB11(6) CORRESPOND TO CA11(11)
C	WHILE THE LOW 4 BYTES OF SB11(6) IS FILLED WITH 0'S.
C
C	THIS PROGRAM WAS WRITTEN TO TEST MODIFIED SCUP32.F AND CSPCK32.F
C
C	SHIMING XU, STG OF NCSA. OCT. 7, 1991
	



	integer size,sa10(5), sa11(6), ca10(10),ca11(11),i
	integer sb10(5),sb11(6)
        REAL FA(10)
	EQUIVALENCE (ca10,FA)

	OPEN(UNIT=20,FILE='sa10',FORM='UNFORMATTED',STATUS='OLD',
     *         ACCESS='DIRECT', RECL=8,ERR=999)

	DO 130 i=1,5
	    read(20,rec=i) sa10(i)
130	CONTINUE

	DO 135 I=1,5
	   WRITE(*,150) SA10(I)
150     FORMAT(O24, F20.11)
135	CONTINUE


	PRINT *

	CLOSE(20)

	CALL SCUP32(SA10,CA10,10,0)
C	DO 160 I=1,10
C	   WRITE(30,rec=I) CA10(I)
C 160	CONTINUE

	CALL CSPK32(CA10,sb10,10,0)
	do 170 i=1,5
	    write(*,150) sb10(i)
	    if (sb10(i) .NE. sa10(i)) then 
		write(*,*) 'NOT EQUAL',i
            end if
170	continue

	write(*,*)
	write(*,*) 'End of comparison of sa10 and sb10'
	write(*,*)

C	Now work on odd number of input data

	
	OPEN(UNIT=20,FILE='sa11',FORM='UNFORMATTED',STATUS='OLD',
     *         ACCESS='DIRECT', RECL=8,ERR=999)
	DO 230 i=1,6
	    read(20,rec=i) sa11(i)
230	CONTINUE

	DO 235 I=1,6
	   WRITE(*,250) SA11(I)
250     FORMAT(O24, F20.11)
235	CONTINUE


	PRINT *

	CLOSE(20)

	CALL SCUP32(SA11,CA11,11,0)
C	DO 260 I=1,11
C	   WRITE(30,rec=I) CA11(I)
C 260	CONTINUE

	CALL CSPK32(CA11,sb11,11,0)
	do 270 i=1,6
	    write(*,150) sb11(i)
	    if (sb11(i) .NE. sa11(i)) then 
		write(*,*) 'NOT EQUAL',i
            end if
270	continue

C	TEST ICHECK -- CHECKING FOR OVERFLOW AND UNDERFLOW
 
	OPEN(UNIT=20,FILE='sa10',FORM='UNFORMATTED',STATUS='OLD', 
     *         ACCESS='DIRECT', RECL=8,ERR=999) 
	DO 330 i=1,5 
	    read(20,rec=i) sa10(i)
330	CONTINUE

	DO 335 I=1,5
	   WRITE(*,350) SA10(I)
350     FORMAT(O24, F20.11)
335	CONTINUE


	PRINT *

	CLOSE(20)

	CALL SCUP32(SA10,CA10,10,0)
C	DO 160 I=1,10
C	   WRITE(30,rec=I) CA10(I)
C 160	CONTINUE

	CALL CSPK32(CA10,sb10,10,1)
	do 370 i=1,5
	    write(*,150) sb10(i)
	    if (sb10(i) .NE. sa10(i)) then 
		write(*,*) 'NOT EQUAL',i
            end if
370	continue

	write(*,*)
	write(*,*) 'End of comparison of sa10 and sb10'
	write(*,*)

C	Now work on odd number of input data

	
	OPEN(UNIT=20,FILE='sa11',FORM='UNFORMATTED',STATUS='OLD',
     *         ACCESS='DIRECT', RECL=8,ERR=999)
	DO 430 i=1,6
	    read(20,rec=i) sa11(i)
430	CONTINUE
	CLOSE(20)

	DO 435 I=1,6
	   WRITE(*,450) SA11(I)
450     FORMAT(O24, F20.11)
435	CONTINUE


	PRINT *

	CLOSE(20)

	CALL SCUP32(SA11,CA11,11,0)
C	DO 260 I=1,11
C	   WRITE(30,rec=I) CA11(I)
C 260	CONTINUE

	CALL CSPK32(CA11,sb11,11,1)
	do 470 i=1,6
	    write(*,150) sb11(i)
	    if (sb11(i) .NE. sa11(i)) then 
		write(*,*) 'NOT EQUAL',i
            end if
470	continue

999	write(*,*) 'test --finished'


	END

 
	
