	SUBROUTINE FINDEM(L,BLK,SUB,SABLK,BLKNUM,VAR,L2)
	INTEGER*2 DP(2048),E,ADD,STBLK,BLK,SABLK,SUB,BLKNUM
	COMMON DP
	LOGICAL VAR
C FIND SMALLEST EMPTY BLOCK LARGER THAN L
C BLK IS NUMBER OF BLOCKS IN THIS DIRECTORY
C SUB IS THE ENTRY NUMBER OF EMPTY FILE IN GIVEN BLOCK
C  L2 IS LENGTH OF EMPTY FILE FOUND
C SABLK IS STARTING BLOCK
C BLOCKNUM IS BLOCK WHICH CONTAINS EMPTY BLOCK
	VAR=.FALSE.
	IMAX=500	!UPPER LIMIT FOR TEST
	N=0
	LU=0
1	LU=LU+1
	E=-NUMB(DP(LU))		!NUMBER OF ENTIES IN BLOCK
	ADD=-NUMB(DP(LU+4))	!NUMBER OF ADDITIONAL WORDS
	STBLK=DP(LU+1)		!STARTING BLOCK OF FIRST FILE
	LU=LU+5
C NOW LU POINTS TO FIRST ENTRY
	DO 10 I=1,E
	IF(DP(LU).EQ.0)GOTO 20	!EMPTY FILE
	L9=-NUMB(DP(LU+ADD+4))	!LENGTH OF FILE
C  IF FILE IS NOT TENATIVE ADD ON LENGTH TO STARTING BLOCK
	IF(L9.LE.481)STBLK=STBLK+L9
	LU=LU+5+ADD
	GOTO 10
20	LP=-NUMB(DP(LU+1))	!LENGTH OF THIS EMPTY FILE
	IF(LP.LT.L)GOTO 30	!TO SMALL
	IF(LP.GE.IMAX)GOTO 30	!BIGGER THAN FILE WE HAVE GOT
	IMAX=LP			!RESET IMAX
	VAR=.TRUE.
	SABLK=STBLK		!SABLK IS START BLK OF THIS FILE
	L2=LP			!LENGTH OF EMPTY FILE
	BLKNUM=N+1
	SUB=I
30	LU=LU+2
	STBLK=STBLK+LP
10	CONTINUE
C NOW SEARCH NEXT BLOCK
	N=N+1
	LU=N*256
	IF(N.LT.BLK)GOTO 1
	RETURN
	END
