File: NUDriver

package info (click to toggle)
pgplot5 5.2-13
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 6,280 kB
  • ctags: 5,903
  • sloc: fortran: 37,938; ansic: 18,809; sh: 1,147; objc: 532; makefile: 363; perl: 234; pascal: 233; tcl: 178; awk: 51; csh: 25
file content (379 lines) | stat: -rw-r--r-- 11,458 bytes parent folder | download | duplicates (15)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
C*NUDRIV -- PGPLOT Null device driver
C+
      SUBROUTINE NUDRIV (IFUNC, RBUF, NBUF, CHR, LCHR)
      INTEGER IFUNC, NBUF, LCHR
      REAL    RBUF(*)
      CHARACTER*(*) CHR
C
C PGPLOT driver for Null device (no graphical output)
C
C Version 1.0  - 1987 May 26 - T. J. Pearson.
C Version 1.1  - 1988 Mar 23 - add rectangle fill.
C Version 1.2  - 1992 Sep  3 - add line-of-pixels.
C Version 1.3  - 1992 Sep 21 - add markers.
C Version 1.4  - 1993 Apr 22 - add optional debugging.
C Version 1.5  - 1994 Aug 31 - use image primitives.
C Version 2.0  - 1996 Jan 22 - allow multiple active devices;
C                              add QCR primitive.
C
C Supported device: The ``null'' device can be used to suppress
C all graphic output from a program.  If environment variable
C PGPLOT_DEBUG is defined, some debugging information is
C reported on standard output.
C
C Device type code: /NULL.
C
C Default device name: None (the device name, if specified, is 
C ignored).
C
C Default view surface dimensions: Undefined (The device pretends to
C be a hardcopy device with 1000 pixels/inch and a view surface 8in 
C high by 10.5in wide.)
C
C Resolution: Undefined.
C
C Color capability: Color indices 0--255 are accepted.
C
C Input capability: None.
C
C File format: None.
C
C Obtaining hardcopy: Not possible.
C-----------------------------------------------------------------------
C Notes:
C  Up to MAXDEV "devices" may be open at once. ACTIVE is the number
C  of the currently selected device, or 0 if no devices are open.
C  STATE(i) is 0 if device i is not open, 1 if it is open but with
C  no current picture, or 2 if it is open with a current picture.
C
C  When debugging is enabled, open/close device and begin/end picture
C  calls are reported on stdout, and a cumulative count of all
C  driver calls is kept.
C-----------------------------------------------------------------------
      CHARACTER*(*) DEVICE
      PARAMETER (DEVICE='NULL  (Null device, no output)')
      INTEGER MAXDEV
      PARAMETER (MAXDEV=8)
      INTEGER NOPCOD
      PARAMETER (NOPCOD=29)
      CHARACTER*10 MSG
      CHARACTER*32 TEXT
      CHARACTER*8  LAB(NOPCOD)
      INTEGER COUNT(NOPCOD), I, STATE(0:MAXDEV), L, NPIC(MAXDEV)
      INTEGER ACTIVE
      LOGICAL DEBUG
      INTEGER CTABLE(3,0:255), CDEFLT(3,0:15)
      SAVE COUNT, STATE, NPIC, DEBUG, CTABLE, CDEFLT, ACTIVE
C
      DATA ACTIVE/-1/
      DATA COUNT/NOPCOD*0/
      DATA DEBUG/.FALSE./
      DATA LAB  /'qdev    ', 'qmaxsize', 'qscale  ', 'qcapab  ',
     1           'qdefnam ', 'qdefsize', 'qmisc   ', 'select  ',
     2           'open    ', 'close   ', 'beginpic', 'line    ',
     3           'dot     ', 'endpic  ', 'set CI  ', 'flush   ',
     4           'cursor  ', 'eralpha ', 'set LS  ', 'polygon ',
     5           'set CR  ', 'set LW  ', 'escape  ', 'rectangl',
     6           'set patt', 'pix/imag', 'scaling ', 'marker  ',
     7           'query CR'/
      DATA CDEFLT /000,000,000, 255,255,255, 255,000,000, 000,255,000,
     1             000,000,255, 000,255,255, 255,000,255, 255,255,000,
     2             255,128,000, 128,255,000, 000,255,128, 000,128,255,
     3             128,000,255, 255,000,128, 085,085,085, 170,170,170/
C-----------------------------------------------------------------------
C
      IF (ACTIVE.EQ.-1) THEN
           CALL GRGENV('DEBUG', TEXT, L)
           DEBUG = L.GT.0
           ACTIVE = 0
           STATE(ACTIVE) = 0
      END IF
C
      IF (IFUNC.LT.1 .OR. IFUNC.GT.NOPCOD) GOTO 900
      COUNT(IFUNC) = COUNT(IFUNC) + 1
      GOTO( 10, 20, 30, 40, 50, 60, 70, 80, 90,100,
     1     110,120,130,140,150,160,170,180,190,200,
     2     210,220,230,240,250,260,270,280,290), IFUNC
  900 WRITE (MSG, '(I10)') IFUNC
      CALL GRWARN('Unimplemented function in NULL device driver: '//MSG)
      NBUF = -1
      RETURN
C
C--- IFUNC = 1, Return device name.-------------------------------------
C
   10 CHR = DEVICE
      LCHR = LEN(DEVICE)
      RETURN
C
C--- IFUNC = 2, Return physical min and max for plot device, and range
C               of color indices.---------------------------------------
C
   20 RBUF(1) = 0
      RBUF(2) = 65535
      RBUF(3) = 0
      RBUF(4) = 65535
      RBUF(5) = 0
      RBUF(6) = 255
      NBUF = 6
      RETURN
C
C--- IFUNC = 3, Return device resolution. ------------------------------
C
   30 RBUF(1) = 1000.0
      RBUF(2) = 1000.0
      RBUF(3) = 1
      NBUF = 3
      RETURN
C
C--- IFUNC = 4, Return misc device info. -------------------------------
C    (This device is Hardcopy, No cursor, Dashed lines, Area fill, Thick
C    lines, Rectangle fill, Images, , , Markers, query color rep)
C
   40 CHR = 'HNDATRQNYM'
      LCHR = 10
      RETURN
C
C--- IFUNC = 5, Return default file name. ------------------------------
C
   50 CHR = 'NL:'
      LCHR = 3
      RETURN
C
C--- IFUNC = 6, Return default physical size of plot. ------------------
C
   60 RBUF(1) = 0
      RBUF(2) = 10499
      RBUF(3) = 0
      RBUF(4) = 7999
      NBUF = 4
      RETURN
C
C--- IFUNC = 7, Return misc defaults. ----------------------------------
C
   70 RBUF(1) = 1
      NBUF = 1
      RETURN
C
C--- IFUNC = 8, Select plot. -------------------------------------------
C
   80 CONTINUE
      I = RBUF(2) - 67890
      IF (I.LT.1 .OR. I.GT.MAXDEV) THEN
         CALL GRWARN('internal error: NULL opcode 8')
      ELSE IF (STATE(I).GT.0) THEN
         ACTIVE = I
      ELSE
         CALL GRNU00(IFUNC,0)
      END IF
      RETURN
C
C--- IFUNC = 9, Open workstation. --------------------------------------
C
   90 CONTINUE
C     -- Find an inactive device, and select it
      DO 91 I=1,MAXDEV
         IF (STATE(I).EQ.0) THEN
            ACTIVE = I
            STATE(ACTIVE) = 1
            GOTO 92
         END IF
 91   CONTINUE
      IF (DEBUG) CALL GRWARN ('09 Open workstation')
      CALL GRWARN('maximum number of devices of type NULL exceeded')
      RBUF(1) = 0
      RBUF(2) = 0 
      NBUF = 2
      RETURN
C     -- Initialize the new device
 92   CONTINUE
      RBUF(1) = ACTIVE + 67890
      RBUF(2) = 1
      NBUF = 2
      NPIC(ACTIVE) = 0
C     -- Initialize color table
      DO 95 I=0,15
         CTABLE(1,I) = CDEFLT(1,I)
         CTABLE(2,I) = CDEFLT(2,I)
         CTABLE(3,I) = CDEFLT(3,I)
 95   CONTINUE
      DO 96 I=16,255
         CTABLE(1,I) = 128
         CTABLE(2,I) = 128
         CTABLE(3,I) = 128
 96   CONTINUE
      IF (DEBUG) THEN
         CALL GRFAO('09 Open workstation: device #',
     :        L, TEXT, ACTIVE, 0, 0, 0)
         CALL GRWARN(TEXT(1:L))
      END IF
      RETURN
C
C--- IFUNC=10, Close workstation. --------------------------------------
C
  100 CONTINUE
      IF (STATE(ACTIVE).NE.1) CALL GRNU00(IFUNC,STATE(ACTIVE))
      STATE(ACTIVE) = 0
      IF (DEBUG) THEN
         CALL GRFAO('10 Close workstation: device #',
     :        L, TEXT, ACTIVE, 0, 0, 0)
         CALL GRWARN(TEXT(1:L))
         CALL GRWARN('Device driver calls:')
         DO 101 I=1,NOPCOD
            IF (COUNT(I).GT.0) THEN
               WRITE (TEXT,'(3X,I2,1X,A8,I10)') I, LAB(I), COUNT(I)
               CALL GRWARN(TEXT)
            END IF
 101     CONTINUE
      END IF
      RETURN
C
C--- IFUNC=11, Begin picture. ------------------------------------------
C
  110 CONTINUE
      IF (STATE(ACTIVE).NE.1) CALL GRNU00(IFUNC,STATE(ACTIVE))
      STATE(ACTIVE) = 2
      NPIC(ACTIVE) = NPIC(ACTIVE)+1
      IF (DEBUG) THEN
         CALL GRFAO('11   Begin picture # on device #',
     :        L, TEXT, NPIC(ACTIVE), ACTIVE, 0,0)
         CALL GRWARN(TEXT(:L))
      END IF
      RETURN
C
C--- IFUNC=12, Draw line. ----------------------------------------------
C
  120 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=13, Draw dot. -----------------------------------------------
C
  130 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=14, End picture. --------------------------------------------
C
  140 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      STATE(ACTIVE) = 1
      IF (DEBUG) THEN
         CALL GRFAO('14   End picture   # on device #',
     :        L, TEXT, NPIC(ACTIVE), ACTIVE, 0,0)
         CALL GRWARN(TEXT(:L))
      END IF
      RETURN
C
C--- IFUNC=15, Select color index. -------------------------------------
C
  150 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=16, Flush buffer. -------------------------------------------
C
  160 CONTINUE
      IF (STATE(ACTIVE).LT.1) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=17, Read cursor. --------------------------------------------
C    (Not implemented: should not be called.)
C
  170 GOTO 900
C
C--- IFUNC=18, Erase alpha screen. -------------------------------------
C
  180 CONTINUE
      IF (STATE(ACTIVE).LT.1) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=19, Set line style. -----------------------------------------
C
  190 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=20, Polygon fill. -------------------------------------------
C
  200 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=21, Set color representation. -------------------------------
C
  210 CONTINUE
      IF (STATE(ACTIVE).LT.1) CALL GRNU00(IFUNC,STATE(ACTIVE))
      I = RBUF(1)
      CTABLE(1, I) = NINT(RBUF(2)*255)
      CTABLE(2, I) = NINT(RBUF(3)*255)
      CTABLE(3, I) = NINT(RBUF(4)*255)
      RETURN
C
C--- IFUNC=22, Set line width. -----------------------------------------
C
  220 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=23, Escape. -------------------------------------------------
C
  230 CONTINUE
      RETURN
C
C--- IFUNC=24, Rectangle fill. -----------------------------------------
C
  240 CONTINUE
      IF (DEBUG.AND.STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=25, Not implemented -----------------------------------------
C
  250 CONTINUE
      RETURN
C
C--- IFUNC=26, Line of pixels ------------------------------------------
C
  260 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=27, Scaling info -- -----------------------------------------
C
  270 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
      RETURN
C
C--- IFUNC=28, Draw marker ---------------------------------------------
C
  280 CONTINUE
      IF (STATE(ACTIVE).NE.2) CALL GRNU00(IFUNC,STATE(ACTIVE))
C     WRITE (*,'(1X,A,I4,1X,3F10.1)') 'MARKER', NINT(RBUF(1)), RBUF(2),
C    1      RBUF(3), RBUF(4)
      RETURN
C
C--- IFUNC=29, Query color representation. -----------------------------
C
  290 CONTINUE
      IF (STATE(ACTIVE).LT.1) CALL GRNU00(IFUNC,STATE(ACTIVE))
      I = RBUF(1)
      RBUF(2) = CTABLE(1,I)/255.0
      RBUF(3) = CTABLE(2,I)/255.0
      RBUF(4) = CTABLE(3,I)/255.0
      NBUF = 4
      RETURN
C-----------------------------------------------------------------------
      END

      SUBROUTINE GRNU00(IFUNC, STATE)
      INTEGER IFUNC, STATE
C
C PGPLOT NULL device driver: report error
C-----------------------------------------------------------------------
      INTEGER L
      CHARACTER*80 MSG
C
      CALL GRFAO('++ internal error: driver in state # for opcode #',
     :           L, MSG, STATE, IFUNC, 0, 0)
      CALL GRWARN(MSG(1:L))
      RETURN
      END