Fix core WST file
[jabaws.git] / binaries / src / disembl / Tisean_3.0.1 / source_f / xreadfile.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   multivariate i/o utilities for TISEAN f-sources
23 c   author T. Schreiber (1999)
24 c===========================================================================
25       subroutine xreadfile(nmax,mmax,nx,x,nexcl,icol,file,iverb)
26 c read columns as seperate time series
27       parameter(mline=1000)
28       dimension x(nx,mmax), icol(mmax), dum(mline)
29       character*(*) file
30
31       iv=iv_io(iverb)
32       if(iv.ne.0) write(istderr(),*) 
33      .   'reading from columns', (icol(i),i=1,mmax)
34       call infile(file,iunit,iverb)
35       mlast=0
36       do 10 i=1,mmax
37  10      mlast=max(mlast,icol(i))
38       if(mlast.gt.mline) stop "xreadfile: make mline larger."
39       lc=0
40       do 20 n=1,nexcl
41          lc=lc+1
42  20      read(iunit,*,end=999)
43       do 30 n=1,nmax
44  1       lc=lc+1
45          read(iunit,*,err=2,end=999)  (dum(i),i=1,mlast)
46          do 40 i=1,mmax
47  40         x(n,i)=dum(icol(i))
48          goto 30
49  2       if(iv.ne.0) write(istderr(),*) "data in line ", lc, " ignored"
50          goto 1
51  30      continue
52       if(iv.ne.0) write(istderr(),*) '*** readfile: warning:'//
53      .   ' maybe not the whole file has been used'
54  999  nmax=n-1
55       if(iunit.ne.istdin()) close(iunit)
56       if(iv.ne.0) call readreport(nmax,file)
57       end
58
59       subroutine xwritecfile(nmax,mmax,nx,x,file,iverb,comm)
60 c write comment and nmax points
61       dimension x(nx,mmax)
62       character*(*) file,comm
63
64       if(mmax.gt.1000) then
65          write(istderr(),*) "xwritecfile: "//
66      .      "cannot write more than 1000 columns"
67          stop
68       endif
69       call outfile(file,iunit,iverb)
70       if(comm.ne." ") write(iunit,'(a)') comm
71       do 10 n=1,nmax
72  10      write(iunit,'(1000g16.7)') (x(n,i),i=1,mmax)
73       if(iunit.eq.istdout()) then
74          write(iunit,*)
75          write(iunit,*)
76       else
77          close(iunit)
78       endif
79       if(iv_io(iverb).eq.1) call writereport(nmax,file)
80       end
81
82       subroutine xwritefile(nmax,mmax,nx,x,file,iverb)
83 c write nmax points
84       dimension x(nx,mmax)
85       character*(*) file
86
87       call xwritecfile(nmax,mmax,nx,x,file,iverb," ")
88       end
89
90       subroutine columns(mc,mmax,icol)
91       dimension icol(*)
92
93       call imcan("c",mmax,mc,icol)
94       icmax=0
95       do 10 m=1,mc
96  10      icmax=max(icmax,icol(m))
97       do 20 m=mc+1,mmax
98          icmax=icmax+1
99  20      icol(m)=icmax
100       end
101
102
103