1 c===========================================================================
3 c This file is part of TISEAN
5 c Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber
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.
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.
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
21 c===========================================================================
22 c Force x to have spectrum a (routine needed by surrogates.f)
23 C author Thomas Schreiber (1999)
24 c===========================================================================
25 function totospec(nmax,a,x)
27 dimension x(nmax), a(nmax), w(nx), w1(nx), w2(nx), iw(15)
30 if(nmax.gt.nx) stop "totospec: make nx larger."
33 call rffti1(nmax,w2,iw)
34 call rfftf1(nmax,x,w1,w2,iw)
36 20 x(n)=x(n)/real(nmax)
39 ab=a(2*n-2)/(x(2*n-2)**2+x(2*n-1)**2)
40 x(2*n-2)=x(2*n-2)*sqrt(ab)
41 30 x(2*n-1)=x(2*n-1)*sqrt(ab)
42 if(mod(nmax,2).eq.0) x(nmax)=sqrt(a(nmax))
43 call rfftb1(nmax,x,w1,w2,iw)
46 40 totospec=totospec+(x(n)-w(n))**2
47 totospec=sqrt(totospec/nmax)