Change Eclipse configuration
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_f / c2g.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   c2g.f
23 c   Gaussian kernel correlation integral from c2
24 c   author T. Schreiber (1998)
25 c===========================================================================
26       parameter(meps=1000)
27       dimension e(meps), c(meps), lw(meps)
28       character*72 file, fout, aline
29       double precision g,gd,h,d,f,func,gg,ggd,err,dum1,dum2,a,b,dc,de
30       external func, funcd
31       common h,d,f
32       data iverb/1/
33
34       call whatido("Gaussian kernel correlation sum from c2",iverb)
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,"_g")
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       me=me+1
49       read(aline,*,err=999,end=999) ee, cc
50       if(cc.le.0.) goto 3
51       e(me)=log(ee)
52       c(me)=log(cc)
53       goto 2
54  3    write(iunit2,'(4h#m= ,i5)') m
55       call indexx(me,e,lw)
56       call index2sort(me,e,lw)
57       call index2sort(me,c,lw)
58       do 10 j=1,me
59          h=exp(e(j))
60          g=0
61          gd=0
62          do 20 k=1,me-1
63             f=exp((e(k+1)*c(k)-e(k)*c(k+1))/(e(k+1)-e(k)))
64             d=(c(k+1)-c(k))/(e(k+1)-e(k))
65             a=e(k)
66             b=e(k+1)
67             gg=0.
68             ggd=0.
69             if(b.ne.a) call dqk15(func,a,b,gg,err,dum1,dum2)
70             if(b.ne.a) call dqk15(funcd,a,b,ggd,err,dum1,dum2)
71             g=g+gg
72  20         gd=gd+ggd
73          dc=c(me)
74          de=e(me)
75          cgauss=g/(h**2)+exp(-exp(2*de)/(2*h**2))
76          cgd=gd/(h**4)+(2+exp(2*de)/h**2)*exp(-exp(2*de)/(2*h**2))
77  10      write(iunit2,*) h, cgauss, -2+cgd/cgauss
78       write(iunit2,'()') 
79       write(iunit2,'()') 
80       goto 4
81  999  stop
82       end
83
84       double precision function func(u)
85       double precision h,d,f,u
86       common h,d,f
87
88       func=f*exp((2+d)*u-exp(2*u)/(2*h**2))      
89       end
90
91       double precision function funcd(u)
92       double precision h,d,f,u
93       common h,d,f
94
95       funcd=f*exp((4+d)*u-exp(2*u)/(2*h**2))      
96       end
97
98       subroutine usage()
99 c usage message
100
101       call whatineed(
102      .   "[-o outfile -V# -h] file")
103       call pout("file_g")
104       call pall()
105       stop
106       end
107
108
109