	SUBROUTINE PSTOR
	COMMON IB(10,10),IA(8,2),IC(8,2),NA,IS1,IS2,CHAR,CLEAR
	LOGICAL*1 CLEAR(6),IB
	DIMENSION ID(8,2)
	CALL ASSIGN(1,'DL2:[200,6]BBOXFILES.DAT',24)
	IPAT=-1  ! NUMBER OF PATTERNS FOUND IN FILE
1	IPAT=IPAT+1 ! FIRST LINE IN FILE IS A DUMMY.
	READ(1,2,END=15,ERR=15) NPAT,NSTARS,ID
2	FORMAT(2I3,16I2)
	IF(NSTARS.NE.NA) GOTO 1  ! WRONG # STARS IN PATTERN
C	HAVE PATTERN WITH SAME # STARS, NOW CHECK IF IT'S
C	THE SAME AS THE ONE WE ARE SAVING.  PATTERN MUST BE
C	CHECK FOR 8 POSSIBLE ORIENTAIONS:
C	 ------   ------   ------   ------
C	|+    #| |     +| |*     | |#    *|
C	|      | |      | |      | |      |
C	|     *| |*    #| |#    +| |+     |
C	 ------   ------   ------   ------
C 
C	 ------   ------   ------   ------
C	|     *| |*    #| |#    +| |+     |
C	|      | |      | |      | |      |
C	|+    #| |     +| |*     | |#    *|
C	 ------   ------   ------   ------
C	USE IC TO STORE "ROTATED" IA
C	IF(IA(I,1).GT.9.OR.IA(I,1).LT.2) GOTO 20
	IOUT=0 ! 1 IF SAME PATTERN FOUND
	IR=0  ! PATTERN NOT YET ROTATED
5	DO 3 J=1,4  ! ROTATE 4 TIMES
	DO 7 I=1,NA
	ITEMP=ID(I,2)
	ID(I,2)=ID(I,1)
	ID(I,2)=11-ITEMP
7	CONTINUE
	CALL PCHECK(IA,ID,IOUT,NA)
	IF(IOUT.NE.0) GOTO 10
3	CONTINUE
C	NOW "INVERT" PATTERN (TRANSPOSE...):
	IF(IR.EQ.1) GOTO 1
	DO 4 I=1,NA
	ITEMP=IA(I,1)
	IA(I,1)=IA(I,2)
	IA(I,2)=ITEMP
4	CONTINUE
	IR=1
	GOTO 5  ! ROTATE AND CHECK
C 
C	SIMILAR PATTERN FOUND:
10	WRITE(5,11) NPAT
11	FORMAT(' PATTERN',I4,' HAS THE SAME'/' STAR RELATIONSHIPS AS'/
     C' YOUR PATTERN.'/' [PATTERN NOT STORED]')
12	CALL CLOSE(1)
	RETURN
C 
C	NEW PATTERN:
15	WRITE(5,16)
16	FORMAT(' NO SIMILAR PATTERN EXISTS'/' IN DATA FILE.'/
     C' [PATTERN STORED]')
C	REINVERT PATTERN:
	DO 25 I=1,NA
	ITEMP=IA(I,1)
	IA(I,1)=IA(I,2)
	IA(I,2)=ITEMP
25	CONTINUE
	WRITE(1,2) IPAT,NA,IA
	GOTO 12
20	WRITE(5,21)
21	FORMAT(' YOU CANNOT SAVE A'/' PATTERN THAT'/' DOESN`T EXIST !')
	GOTO 12
	END
