	SUBROUTINE RANGE2 (NX,X,XMIN,XMAX,ngood)
        common/check/nchk,xbad
	DIMENSION X(NX)
	ngood=0
	IF(NX.LT.1) RETURN
	xmin=1.e35
	xmax=-xmin
	DO 100 I=1,NX
	if(x(i).eq.xbad) go to 100
	IF (X(I).LT.XMIN) XMIN=X(I)
	IF (X(I).GT.XMAX) XMAX=X(I)
	ngood=ngood+1
100	continue
	RETURN
	END
