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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
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 AGSTCH (CHST,LNCS,IDCS)
C
CHARACTER*(*) CHST
C
C This routine stores strings of characters for later retrieval and/or
C modification by the routines AGGTCH, AGRPCH, and AGDLCH. It has the
C following arguments:
C
C -- CHST is the character string to be stored.
C
C -- LNCS is the length of the character string in CHST. LNCS must be
C less than or equal to the value of the FORTRAN function LEN(CHST).
C
C -- IDCS is an identifying integer, returned to the caller by AGSTCH
C for later use in calls to AGGTCH, AGRPCH, and AGDLCH. If CHST is
C more than one character long, it is stashed in the array CHRA, and
C the value returned in IDCS is a negative number between -LNIC and
C -1, inclusive, the absolute value of which is the index of an entry
C in the array INCH describing where in the array CHRA the string was
C stored. If CHST is only one character long, IDCS is returned as
C the value of the FORTRAN expression -(LNIC+1+ICHAR(CHST(1:1))).
C
C The following common blocks contain variables which are required for
C the character-storage-and-retrieval scheme of AUTOGRAPH.
C
COMMON /AGCHR1/ LNIC,INCH(2,50),LNCA,INCA
C
COMMON /AGCHR2/ CHRA(2000)
C
CHARACTER*1 CHRA
C
C If the string is short enough, just embed it in a negative integer
C and return that value to the caller as the identifier of the string.
C
IF (LNCS.LE.1) THEN
IDCS=-(LNIC+1+ICHAR(CHST(1:1)))
RETURN
END IF
C
C Otherwise, the string must be stashed in CHRA and the negative of the
C index, in INCH, of its descriptor returned to the caller. Loop, on I,
C through the index of character strings.
C
DO 104 I=1,LNIC
C
C If the next entry in the index is zeroed, use it for the new string.
C
IF (INCH(1,I).EQ.0) THEN
C
C Zeroed entry found. Return the negative of its index to the user.
C
IDCS=-I
C
C If there isn't enough room for the character string at the end of the
C character-storage array, do some garbage-collecting, eliminating all
C strings of all-zero characters.
C
IF (LNCS.GT.LNCA-INCA) THEN
J=0
K=0
DO 102 L=1,INCA
IF (CHRA(L).EQ.CHAR(0)) THEN
IF (J.EQ.0) J=L
ELSE
IF (J.NE.0) THEN
DO 101 M=1,LNIC
IF (INCH(1,M).GT.K) INCH(1,M)=INCH(1,M)+J-L
101 CONTINUE
J=0
END IF
K=K+1
CHRA(K)=CHRA(L)
END IF
102 CONTINUE
INCA=K
END IF
C
C If there still isn't enough room for the character string at the end
C of the character-storage array, take an error exit. Otherwise, stash
C it and return. All-zero characters are changed to blanks.
C
IF (LNCS.GT.LNCA-INCA) GO TO 901
INCH(1,I)=INCA+1
INCH(2,I)=LNCS
DO 103 J=1,LNCS
INCA=INCA+1
CHRA(INCA)=CHST(J:J)
IF (ICHAR(CHRA(INCA)).EQ.0) CHRA(INCA)=' '
103 CONTINUE
RETURN
C
END IF
C
104 CONTINUE
C
C If no zeroed entry was found in the index of character strings, jump
C to log an error and quit.
C
GO TO 902
C
C Error exits.
C
901 CALL SETER ('AGSTCH - CHARACTER-STRING BUFFER OVERFLOW - SEE CONSU
+LTANT',18,2)
C
902 CALL SETER ('AGSTCH - CHARACTER-STRING INDEX OVERFLOW - SEE CONSUL
+TANT',19,2)
C
END
|