Change Eclipse configuration
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_f / c2d.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   c2d.f
23 c   local slopes from c2
24 c   author T. Schreiber (1998)
25 c===========================================================================
26
27       parameter(meps=1000)
28       dimension e(meps), c(meps)
29       character*72 file, fout, aline
30       data iav/1/
31       data iverb/1/
32
33       call whatido("local slopes from c1/c2 correlation sum data",iverb)
34       iav=ican('a',iav)
35       isout=igetout(fout,iverb)
36       if(nstrings().eq.0) call usage()
37       call nthstring(1,file)
38       call infile(file,iunit,iverb)
39       if(isout.eq.1) call addsuff(fout,file,"_d")
40       call outfile(fout,iunit2,iverb)
41  1    read(iunit,'(a)',end=999) aline
42  4    if(aline(1:1).ne."#") goto 1
43       if(aline(1:1).eq."#") 
44      .   read(aline(index(aline,"m=")+2:72),'(i20)',err=1) m
45       me=0
46  2    read(iunit,'(a)') aline
47       if(aline(1:72).eq." ") goto 3
48       read(aline,*,err=999,end=999) ee, cc
49       if(cc.le.0.) goto 3
50       me=me+1
51       e(me)=log(ee)
52       c(me)=log(cc)
53       goto 2
54  3    write(iunit2,'(4h#m= ,i5)') m
55       do 30 j=iav+1,me-iav
56          call slope(e(j-iav),c(j-iav),2*iav+1,s)
57  30      if(s.gt.0.) write(iunit2,*) exp(0.5*(e(j+iav)+e(j-iav))),  s
58       write(iunit2,'()') 
59       write(iunit2,'()') 
60       goto 4
61  999  stop
62       end
63
64       subroutine slope(x,y,n,a)
65       dimension x(n),y(n)
66
67       sx=0.
68       sa=0
69       a=0.
70       do 10 i=1,n
71  10      sx=sx+x(i)
72       do 20 i=1,n
73          sa=sa+(x(i)-sx/n)**2
74  20      a=a+y(i)*(x(i)-sx/n)
75       a=a/sa
76       end
77
78
79       subroutine usage()
80 c usage message
81
82       call whatineed(
83      .   "[-a# -o outfile -V# -h] file")
84       call popt("a","average using -#,...,+# [1]")
85       call pout("file_d")
86       call pall()
87       stop
88       end
89
90