summaryrefslogtreecommitdiff
path: root/src/mt/crfind.f
blob: f996ac480fd1a653a2bab84c8f0946a14bd87271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c
c HTCd - Copyright (C) 1998-2006 Henrik Rydberg
c
c This program is free software; you can redistribute it and/or modify
c it under the terms of the GNU General Public License as published by
c the Free Software Foundation; either version 2 of the License, or
c (at your option) any later version.
c
c This program is distributed in the hope that it will be useful,
c but WITHOUT ANY WARRANTY; without even the implied warranty of
c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c GNU General Public License for more details.
c
c You should have received a copy of the GNU General Public License
c along with this program; if not, write to the Free Software
c Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
c

      integer function crfind(s,n,c)
      character s(0:1),c
      integer i,m,n
      m=mod(n,16)
      do 10 i=n-16,m,-16
         if(s(i+15).eq.c)go to 115
         if(s(i+14).eq.c)go to 114
         if(s(i+13).eq.c)go to 113
         if(s(i+12).eq.c)go to 112
         if(s(i+11).eq.c)go to 111
         if(s(i+10).eq.c)go to 110
         if(s(i+9).eq.c)go to 109
         if(s(i+8).eq.c)go to 108
         if(s(i+7).eq.c)go to 107
         if(s(i+6).eq.c)go to 106
         if(s(i+5).eq.c)go to 105
         if(s(i+4).eq.c)go to 104
         if(s(i+3).eq.c)go to 103
         if(s(i+2).eq.c)go to 102
         if(s(i+1).eq.c)go to 101
         if(s(i).eq.c)go to 100
 10   continue
      do 20 i=m-1,0,-1
         if(s(i).eq.c)go to 100
 20   continue
      crfind=-1
      return
 100  crfind=i
      return
 101  crfind=i+1
      return
 102  crfind=i+2
      return
 103  crfind=i+3
      return
 104  crfind=i+4
      return
 105  crfind=i+5
      return
 106  crfind=i+6
      return
 107  crfind=i+7
      return
 108  crfind=i+8
      return
 109  crfind=i+9
      return
 110  crfind=i+10
      return
 111  crfind=i+11
      return
 112  crfind=i+12
      return
 113  crfind=i+13
      return
 114  crfind=i+14
      return
 115  crfind=i+15
      return
      end