1subroutine blanker(iwave,nz,ndropmax,npct,c_bigfft)
2
3  integer*2 iwave(nz)
4  complex c_bigfft(0:nz/2)
5  integer hist(0:32768)
6  real fblank                     !Fraction of points to be blanked
7
8  fblank=0.01*npct
9  hist=0
10  do i=1,nz
11! ### NB: if iwave(i)=-32768, abs(iwave(i))=-32768 ###
12     if(iwave(i).eq.-32768) iwave(i)=-32767
13     n=abs(iwave(i))
14     hist(n)=hist(n)+1
15  enddo
16  n=0
17  do i=32768,0,-1
18     n=n+hist(i)
19     if(n.ge.nint(nz*fblank/ndropmax)) exit
20  enddo
21  nthresh=i
22  ndrop=0
23  ndropped=0
24
25  xx=0.
26  do i=1,nz
27     i0=iwave(i)
28     if(ndrop.gt.0) then
29        i0=0
30        ndropped=ndropped+1
31        ndrop=ndrop-1
32     endif
33
34! Start to apply blanking
35     if(abs(i0).gt.nthresh) then
36        i0=0
37        ndropped=ndropped+1
38        ndrop=ndropmax
39     endif
40
41! Now copy the data into c_bigfft
42     if(iand(i,1).eq.1) then
43        xx=i0
44     else
45        yy=i0
46        j=i/2 - 1
47        c_bigfft(j)=cmplx(xx,yy)
48     endif
49  enddo
50
51  return
52end subroutine blanker
53