Change Eclipse configuration
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_f / spikeauto.f
1 c===========================================================================
2 c
3 c   This file is part of TISEAN
4
5 c   Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber
6
7 c   TISEAN is free software; you can redistribute it and/or modify
8 c   it under the terms of the GNU General Public License as published by
9 c   the Free Software Foundation; either version 2 of the License, or
10 c   (at your option) any later version.
11 c
12 c   TISEAN is distributed in the hope that it will be useful,
13 c   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 c   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 c   GNU General Public License for more details.
16 c
17 c   You should have received a copy of the GNU General Public License
18 c   along with TISEAN; if not, write to the Free Software
19 c   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 c
21 c===========================================================================
22 c   spike train autocorrelation function
23 c   author T. Schreiber (1998) based on earlier versions
24 c===========================================================================
25       parameter(nx=1000000, nhist=100000)
26       dimension x(nx), lx(nx), ihist(nhist)
27       character*72 file, fout
28       data iverb/1/
29
30       call whatido("spike train autocorrelation function",iverb)
31       bin=fmust("d")
32       totbin=fmust("D")
33       nbin=int(totbin/bin)+1
34       nmaxx=ican("l",nx)
35       nexcl=ican("x",0)
36       jcol=ican("c",0)
37       inter=lopt("i",1)
38       isout=igetout(fout,iverb)
39
40       do 10 ifi=1,nstrings()
41          call nthstring(ifi,file)
42          nmax=nmaxx
43          call readfile(nmax,x,nexcl,jcol,file,iverb)
44          if(inter.eq.0) goto 1
45          do 20 n=2,nmax
46  20         x(n)=x(n)+x(n-1)
47  1       call sort(nmax,x,lx)
48          do 30 i=1,nbin
49  30         ihist(i)=0
50          do 40 n1=1,nmax
51             do 50 n2=n1+1,nmax
52                il=int((x(n2)-x(n1))/bin)+1
53                if(il.gt.nbin) goto 40
54  50            ihist(il)=ihist(il)+1
55  40         continue
56          if(file.eq."-") file="stdin"
57          if(isout.eq.1) call addsuff(fout,file,"_sco")
58          call outfile(fout,iunit,iverb)
59          do 60 i=1,nbin
60  60         write(iunit,*) (i-0.5)*bin, ihist(i)
61  10      if(iunit.ne.istdout()) close(iunit)
62       end
63
64       subroutine usage()
65 c usage message
66
67       call whatineed(
68      .   "-d# -D# [-i -o outfile -l# -x# -c# -V# -h] file(s)")
69       call popt("d","time span of one bin")
70       call popt("D","total time spanned")
71       call popt("i","expect intervals rather than times")
72       call popt("l","number of values to be read (all)")
73       call popt("x","number of values to be skipped (0)")
74       call popt("c","column to be read (1 or file,#)")
75       call pout("file_sco")
76       call pall()
77       stop
78       end
79
80
81