Mac binaries
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_f / commandline.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   commandline.f
23 c   get command line options
24 c   author T. Schreiber (1998)
25 c===========================================================================
26
27       function iopt(c,ith,ierr)
28 c get ith occurence of switch -c as integer
29       character*72 argv
30       character c
31
32       iopt=0
33       ifound=0
34       do 10 i=1,iargc()
35          call getarg(i,argv)
36          if(argv(1:2).eq.'-'//c) then
37             ifound=ifound+1
38             if(ifound.eq.ith) then
39                call argdel(i)
40                if(argv(3:72).ne.' ') then
41                   iopt=i_s(argv(3:72),ierr)
42                else if(i+1.le.iargc()) then
43                   call getarg(i+1,argv)
44                   iopt=i_s(argv,ierr)
45                   if(ierr.eq.0) call argdel(i+1)
46                else
47                   ierr=1
48                endif
49                return
50             endif
51          endif
52  10      continue
53       ierr=1
54       end
55
56       function fopt(c,ith,ierr)
57 c get ith occurence of switch -c as real
58       character*72 argv
59       character c
60
61       fopt=0
62       ifound=0
63       do 10 i=1,iargc()
64          call getarg(i,argv)
65          if(argv(1:2).eq.'-'//c) then
66             ifound=ifound+1
67             if(ifound.eq.ith) then
68                call argdel(i)
69                if(argv(3:72).ne.' ') then
70                   fopt=f_s(argv(3:72),ierr)
71                else if(i+1.le.iargc()) then
72                   call getarg(i+1,argv)
73                   fopt=f_s(argv,ierr)
74                   if(ierr.eq.0) call argdel(i+1)
75                else
76                   ierr=1
77                endif
78                return
79             endif
80          endif
81  10      continue
82       ierr=1
83       end
84
85       subroutine sopt(c,ith,string,ierr)
86 c get ith occurence of switch -c as string
87       character*(*) string
88       character c
89
90       ifound=0
91       do 10 i=1,iargc()
92          call getarg(i,string)
93          if(string(1:2).eq.'-'//c) then
94             ifound=ifound+1
95             if(ifound.eq.ith) then
96                call argdel(i)
97                if(string(3:).ne.' ') then
98                   string=string(3:)
99                   ierr=0
100                else if(i+1.le.iargc()) then
101                   call getarg(i+1,string)
102                   if(string(1:1).eq."-") then
103                      ierr=1
104                      return
105                   endif
106                   call argdel(i+1)
107                   ierr=0
108                else
109                   ierr=1
110                endif
111                return
112             endif
113          endif
114  10      continue
115       ierr=1
116       end
117
118       function lopt(c,ith)
119 c test if ith occurence of switch -c is present
120       character*72 argv
121       character c
122
123       lopt=0
124       ifound=0
125       do 10 i=1,iargc()
126          call getarg(i,argv)
127          if(argv(1:2).eq.'-'//c) then
128             ifound=ifound+1
129             if(ifound.eq.ith) then
130                lopt=1
131                call argdel(i)
132                return
133             endif
134          endif
135  10      continue
136       end
137
138       function iget(inum)
139 c get inum'th argument as integer
140       character*72 argv
141       
142       iget=0
143       call getarg(inum,argv)
144       if(argv.eq.' ') 
145      .write(istderr(),'(a,i10)') "iget: missing integer argument",inum
146       iget=i_s(argv,ierr)
147       if(ierr.ne.0) 
148      .write(istderr(),'(a,i10)') "iget: integer argument expected:",inum
149       end
150
151       function fget(inum)
152 c get inum'th argument as real
153       character*72 argv
154       
155       fget=0
156       call getarg(inum,argv)
157       if(argv.eq.' ') 
158      .   write(istderr(),'(a)') "fget: missing real argument",inum
159       fget=f_s(argv,ierr)
160       if(ierr.ne.0) 
161      .   write(istderr(),'(a)') "fget: real argument expected:;",inum
162       end