Debian Codegraph @

packages/seacas/applications/blot/grpend.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 SUBROUTINE GRPEND (MAYQUI, MAYTXT, NDONE, NTOTAL, GOBCK, *, *)
9 C=======================================================================
10
11 C --*** GRPEND *** (GRPLIB) End a plot by requesting quit, hardcopy (PLT)
12 C -- Written by Amy Gilkey - revised 01/22/88
13 C --
14 C --GRPEND is called at the end of a plot. It may prompt the user for
15 C --a response and take the appropriate alternate returns for special
16 C --responses.
17 C --
18 C --If a single hardcopy plot is requested, the hardcopy device is
19 C --selected and an internal flag is set and an alternate return is taken.
20 C --If the internal flag is set upon entry to the routine, the terminal
21 C --device is selected and the flag is reset. Be sure to call this
22 C --routine at the normal end of the each plot (even a single hardcopy plot).
23 C --The internal flag is reset whenever the terminal device is selected.
24 C --
25 C --If the plot may be annotated with text, be sure that the color of the
26 C --text to be displayed is set before this routine is called.
27 C --
28 C --If no response is possible and AUTO is set, the number of plots
29 C --completed is displayed.
30 C --
31 C --Parameters:
32 C -- MAYQUI - IN - true if QUIT is a possible alternative
33 C -- MAYTXT - IN - true if TEXT is a possible alternative
34 C -- NDONE - IN - the number of plots completed
35 C -- NTOTAL - IN - the total number of plots
36 C -- GOBCK - in/out - on entry, true if go back supported,
37 C -- - on output, true if go back selected
38 C -- * - the alternate return if hardcopy requested
39 C -- * - the alternate return if quit requested
40 C --
41 C --Common Variables:
42 C -- Sets and uses IHARD of /GRPCOM/
43 C -- Uses ICURDV, DEVOK, DEVCOD, AUTOPL of /GRPCOM/
44
45 C --Routines Called:
46 C -- FREFLD - (SUPES) Free-field reader
47 C -- SQZSTR - (STRLIB) Compress extra blanks
48 C -- PLTBEL - (PLT) Ring bell
49 C -- PLTFLU - (PLT) Flush buffer
50 C -- PLTMOV - (PLT) Move cursor
51 C -- PLTWAI - (PLT) Wait until key is pressed
52 C -- GRABRT - (GRPLIB) Check for plot set abort
53 C -- GRIKEY - (GRPLIB) Select cursor position
54 C -- GRSDEV - (GRPLIB) Select device
55 C -- GRSNAP - (GRPLIB) Handle device frame snapping
56
57 PARAMETER (MXTEXT = 80)
58
59 include 'grpcom.blk'
60
61 LOGICAL MAYQUI, MAYTXT, GOBCK
62
63 LOGICAL GRABRT
64 LOGICAL REQWAI, ASKQUI, ASKHRD, ASKTXT, REPEAT
65 CHARACTER*80 PROMPT
66 CHARACTER REPLY
67
68 LOGICAL LSTERR
69
70 INTEGER NTEXT
71 LOGICAL CTEXT(MXTEXT)
72 REAL XTEXT(MXTEXT), YTEXT(MXTEXT)
73 CHARACTER*80 TEXT(MXTEXT)
74 SAVE NTEXT, CTEXT, XTEXT, YTEXT, TEXT
75
76 C --If end of hardcopy plot, add any text
77
78 IF (ISHARD) THEN
79 DO 100 I = 1, NTEXT
80 IF (CTEXT(I)) THEN
81 CALL GRTEXC (XTEXT(I), YTEXT(I), TEXT(I))
82 ELSE
83 CALL GRTEXT (XTEXT(I), YTEXT(I), TEXT(I))
84 END IF
85 100 CONTINUE
86 END IF
87
88 C --End plot and snap frames
89
90 CALL GRSNAP ('STOP', 0)
91
92 C --Flush the buffer and ring bell and (on some devices) wait for key
93
94 IF (GRABRT ()) RETURN 2
95 CALL PLTMOV (0.0, 0.0)
96 CALL PLTFLU
97 CALL PLTBEL
98 CALL PLTFLU
99 REQWAI = (.NOT. AUTOPL(ICURDV)) .AND. (DEVCOD(ICURDV) .EQ. 'WAIT')
100 IF (REQWAI) THEN
101 CALL PLTWAI
102 CALL PLTFLU
103 END IF
104
105 C --If end of hardcopy plot, reselect terminal device and return
106
107 IF (ISHARD) THEN
108 CALL GRSDEV (0)
109 ISHARD = .FALSE.
110 RETURN
111 END IF
112
113 C --Reset the text lines
114 NTEXT = 0
115 DX = 1.0 / 2
116 DY = 0.75 / 2
117
118 C.. If a single plot, or the last plot in the set, don't prompt,
119 C return immediately to prompt.
120 ASKQUI = NDONE .LT. NTOTAL .AND. MAYQUI
121
122 ASKHRD = DEVOK(2) .AND. (ICURDV .NE. 2)
123 C.. Only ask for text if the hardcopy or multiple plot prompting enabled
124 ASKTXT = (ASKHRD .OR. ASKQUI) .AND. MAYTXT
125
126 IF ((.NOT. AUTOPL(ICURDV))
127 & .AND. (ASKQUI .OR. ASKHRD .OR. ASKTXT)) THEN
128
129 C --Check if user wants to quit or get hardcopy
130
131 LSTERR = .FALSE.
132
133 PROMPT = 'Enter'
134 LPR = LENSTR (PROMPT) + 1
135 IF (ASKQUI) THEN
136 PROMPT(LPR+1:) = '"Q" to quit,'
137 LPR = LENSTR (PROMPT) + 1
138 END IF
139 IF (gobck) THEN
140 gobck = .false.
141 if (ndone .gt. 1) then
142 PROMPT(LPR+1:) = '"P" for previous,'
143 LPR = LENSTR (PROMPT) + 1
144 end if
145 END IF
146 IF (ASKHRD) THEN
147 PROMPT(LPR+1:) = '"H" for hardcopy,'
148 LPR = LENSTR (PROMPT) + 1
149 END IF
150 IF (ASKTXT) THEN
151 PROMPT(LPR+1:) = '"T" for text,'
152 LPR = LENSTR (PROMPT) + 1
153 END IF
154 PROMPT(LPR+1:) = '" " to continue'
155 LPR = LENSTR (PROMPT) + 1
156
157 110 CONTINUE
158
159 C --Prompt for response, print trailing bell only if last response
160 C --was in error
161
162 IF (LSTERR) THEN
163 PROMPT(LPR+1:LPR+1) = CHAR(7)
164 LPR = LPR + 1
165 END IF
166 CALL FREFLD (0, 0, PROMPT(:LPR), 1,
167 & IOSTAT, NUMFLD, INTYP, REPLY, IDUM, RDUM)
168 IF (LSTERR) LPR = LPR - 1
169
170 LSTERR = .FALSE.
171 REPEAT = .FALSE.
172
173 IF (REPLY .EQ. 'Q') THEN
174 IF (ASKQUI) THEN
175 C --Quit
176 RETURN 2
177 END IF
178
179 ELSE IF (REPLY .EQ. 'H') THEN
180 IF (ASKHRD) THEN
181 C --Request hardcopy, select hardcopy, set flag, and return
182 CALL GRSDEV (2)
183 ISHARD = .TRUE.
184 RETURN 1
185 ELSE
186 REPEAT = .TRUE.
187 END IF
188
189 ELSE IF (REPLY .EQ. 'P') THEN
190 GOBCK = .TRUE.
191 RETURN
192
193 ELSE IF (REPLY .EQ. 'T') THEN
194 IF (ASKTXT .AND. (NTEXT .LT. MXTEXT)) THEN
195
196 C --Input position and text string
197
198 CALL GRIKEY (
199 & ' Select text position ("C" to center) ...',
200 & DX, DY, REPLY, *120)
201
202 C --Write line to correct problem with cursor input followed
203 C --by GETINP or FREFLD
204 WRITE (*, *)
205
206 IF (REPLY .EQ. 'C') THEN
207 CALL GETINP (0, 0, ' Text to center> ',
208 & TEXT(NTEXT+1), IOSTAT)
209 ELSE
210 CALL GETINP (0, 0, ' Text> ',
211 & TEXT(NTEXT+1), IOSTAT)
212 END IF
213 WRITE (*, *)
214
215 IF (TEXT(NTEXT+1) .NE. ' ') THEN
216 NTEXT = NTEXT + 1
217 CTEXT(NTEXT) = (REPLY .EQ. 'C')
218 XTEXT(NTEXT) = DX
219 YTEXT(NTEXT) = DY
220
221 C --Display text string on device
222
223 IF (CTEXT(NTEXT)) THEN
224 CALL GRTEXC (XTEXT(NTEXT), YTEXT(NTEXT),
225 & TEXT(NTEXT))
226 ELSE
227 CALL GRTEXT (XTEXT(NTEXT), YTEXT(NTEXT),
228 & TEXT(NTEXT))
229 END IF
230 CALL PLTFLU
231 END IF
232 END IF
233
234 REPEAT = .TRUE.
235
236 ELSE IF (REPLY .NE. ' ') THEN
237 LSTERR = .TRUE.
238 REPEAT = .TRUE.
239 END IF
240
241 IF (REPEAT) GOTO 110
242 ELSE
243 if (gobck) gobck = .false.
244 END IF
245
246 IF (AUTOPL(ICURDV) .AND. (NTOTAL .GT. 0)) THEN
247 WRITE (PROMPT, 10000, IOSTAT=IDUM) NDONE, NTOTAL
248 10000 FORMAT (4X, 'Plot ', I5, ' of ', I5)
249 CALL SQZSTR (PROMPT, LSTR)
250 WRITE (*, '(1X, A)') PROMPT(:LSTR)
251 END IF
252
253 RETURN
254 120 CONTINUE
255 return 2
256 END