function [nbefore,nafter,notfilled,nflag]=goodpts(igap,npts,nmaxbr,ngaps,nfirstbad,nlastbad,lgap,notfilled,infofid);

% c	Subroutine to look at the length of a data gap and number of 
% c	good points before and after a data gap to be filled spectrally.  
% c	Previously-filled gaps are not good points unless you take a
% c	second trip through the program.
% c	Subroutine writes message and sets nflag to 1 if it refuses to
% c	fill the gap because gap is too long, or to 10 if the lengths of
% c	the good points on either end of the gap is too short.
% c
% c	IMPORTS:
% c	  i: gap number
% c	npts: number of points in series
% c	nmaxbr: max # points to bridge
% c	nfirstbad,nlastbad,lgap: arrays of 1st & last points and lengths of gaps
% c	maxgaps: the nmaxgaps from the parameter statement (dimension)
% c	ngaps: the number of gaps in the file
% c	IMPORTS/EXPORTS
% c	notfilled: the # gaps program refuses to fill
% c	EXPORTS:
% c	nflag: a don't-fill flag: 0=fill 1=gap too long 10=too few good points

nflag=0;
if lgap(igap)>nmaxbr
	nflag=1;
	notfilled=notfilled+1;
	nbefore=-999;
	nafter=-999;
	fprintf('Gap #%d is too long to bridge: %d points.\n',igap,lgap(igap));
	fprintf(infofid,'Gap #%d is too long to bridge: %d points.\n',igap,lgap(igap));
	return;
end;

if igap==1
	nbefore=nfirstbad(igap)-1;
else
	nbefore=nfirstbad(igap)-nlastbad(igap-1)-1;
end;
if igap==ngaps
	nafter=npts-nlastbad(igap)-1;
else
	nafter=nfirstbad(igap+1)-nlastbad(igap)-1;
end;
if nbefore<100 & nbefore<2*lgap(igap)
	nflag=10;
	notfilled=notfilled+1;
	fprintf('Gap #%d is not bridged: too few points before gap.\n',igap);
	fprintf(infofid,'Gap #%d is not bridged: too few points before gap.\n',igap);
	return;
end;
if nafter<100 & nafter<2*lgap(igap)
	nflag=10;
	notfilled=notfilled+1;
	fprintf('Gap #%d is not bridged: too few points after gap.\n',igap);
	fprintf(infofid,'Gap #%d is not bridged: too few points after gap.\n',igap);
	return;
end;

return;
