aboutsummaryrefslogtreecommitdiff
path: root/sys/gio/ncarutil/autograph/agsrch.f
blob: 366c46cc13d5c35165a7a42cfd4d451b7a77ab2e (plain) (blame)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
C
C                                                                               
C +-----------------------------------------------------------------+           
C |                                                                 |           
C |                Copyright (C) 1986 by UCAR                       |           
C |        University Corporation for Atmospheric Research          |           
C |                    All Rights Reserved                          |           
C |                                                                 |           
C |                 NCARGRAPHICS  Version 1.00                      |           
C |                                                                 |           
C +-----------------------------------------------------------------+           
C                                                                               
C                                                                               
C ---------------------------------------------------------------------
C
      SUBROUTINE AGSRCH (TPID,IPID,IKWL,TKWL)
C
      CHARACTER*(*) TPID,TKWL
C
C The routine AGSRCH is used by AGSCAN to search a parameter identifier
C for the next keyword and return the index of that keyword in a list of
C keywords.  It has the following arguments.
C
C -- TPID is the parameter identifier, a character string.
C
C -- IPID is the index of the last character examined in TPID.  It is
C    updated by AGSRCH to point to the first slash or period following
C    the next keyword.
C
C -- IKWL is returned containing the index (in the keyword list) of the
C    next keyword in the parameter identifier (list length, plus one,
C    if the keyword is not found in the list).
C
C -- TKWL is the keyword list - 4*LKWL characters in all.
C
C ICHR is used to hold up to four characters of a keyword.
C
      CHARACTER*4 ICHR
C
C LPID is the assumed maximum length of a parameter identifier.
C
      DATA LPID / 100 /
C
C Compute the number of 4-character keywords in the keyword list.
C
      LKWL=LEN(TKWL)/4
C
C Find the next non-blank in the parameter identifier.
C
  101 IPID=IPID+1
      IF (IPID.GT.LPID) GO TO 107
      IF (TPID(IPID:IPID).EQ.' ') GO TO 101
C
C Pick up at most four characters of the keyword, stopping on the first
C blank, slash, or period encountered.
C
      NCHR=0
C
  102 IF (TPID(IPID:IPID).EQ.' '.OR.
     +    TPID(IPID:IPID).EQ.'/'.OR.
     +    TPID(IPID:IPID).EQ.'.') GO TO 103
C
      NCHR=NCHR+1
      ICHR(NCHR:NCHR)=TPID(IPID:IPID)
C
      IPID=IPID+1
C
      IF (NCHR.LT.4) GO TO 102
C
C If the keyword found has zero length, error.
C
  103 IF (NCHR.EQ.0) GO TO 107
C
C Scan ahead for the next slash or period.
C
  104 IF (TPID(IPID:IPID).EQ.'/'.OR.TPID(IPID:IPID).EQ.'.') GO TO 105
C
      IPID=IPID+1
      IF (IPID.GT.LPID) GO TO 107
      GO TO 104
C
C Search the keyword list for the keyword found.
C
  105 DO 106 I=1,LKWL
        IKWL=I
        ISTR=(I-1)*4+1
        IEND=(I-1)*4+NCHR
        IF (ICHR(1:NCHR).EQ.TKWL(ISTR:IEND)) RETURN
  106 CONTINUE
C
C Keyword not found - set IKWL to impossible value and return.
C
  107 IKWL=LKWL+1
      RETURN
C
      END