-
Notifications
You must be signed in to change notification settings - Fork 0
/
libgks1.f
3714 lines (3714 loc) · 122 KB
/
libgks1.f
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
c general 1d gks graphics library
c written by viktor k. decyk, ucla
c copyright 1994, regents of the university of california
c update: april 30, 2013
subroutine GROPEN
c this subroutine opens gks and activates standard workstation
c colors and maximum size of display surface are also set
c if a string (keyboard) device is available, it is initialized
c if a locator (mouse) device is available, it is initialized
call GROPEN0(0)
end
subroutine GROPEN0(iecho)
c this subroutine opens gks and activates workstation
c colors and maximum size of display surface are also set
c if a string (keyboard) device is available, it is initialized
c if a locator (mouse) device is available, it is initialized
c iecho = (0,1) = echo area is in (lower right, lower left)
c idwk = workstation identifier
c ncols = number of foreground colors available for line plotting
c rx, ry = ndc coordinates of upper-right corner of workstation window
c iplot = plot location on page, 0 <= iplot < nplot
c nplot = number of plots per page
c iclr = (-1,0,1) = (no,default,yes) erase plot (default=when iplot=0)
c iupd = (-1,0,1) = (no,default,yes) end plot
c (default=when iplot=nplot-1)
c idstr = string device number, 0 if no string device available
c idloc = locator device number, 0 if no locator device available
c nclsp = number of foreground colors supported on device
c ifrg = index of foreground color
c isx, isy = display width, height, in raster units
common /plotcm/ idwk,ncols,rx,ry,iplot,nplot,iclr,iupd,idstr,idloc
1,nclsp,ifrg,isx,isy,kprime(8)
c ndi = increment between frames
common /pextra/ ndi
c scratch strings and arrays needed for initializing input devices
character*80 datar
character*8 str
dimension earea(4)
save /plotcm/, /pextra/
c nerrfl = error file unit number, 6 for terminal
c meml = storage limit for one segment, in bytes
data nerrfl,meml /6,0/
data zero /0./
c set default plot values
iplot = 0
nplot = 1
iclr = 0
iupd = 0
ndi = 1
c open gks
call gopks(nerrfl,meml)
c get workstation parameters
c idcon = connection identifier, iwtype = workstation type
call gitwks(idcon,iwtype)
idwk = 1
c open workstation
call gopwk(idwk,idcon,iwtype)
c activate workstation
call gacwk(idwk)
c ncoli = number of colors available
c iscol = color availability indicator, 0 = monochrmome, 1 = color
c npci = number of predefined color indices
c inquire color facilities
call gqcf(iwtype,ierr,ncoli,iscol,npci)
c if metafile, set maximum number of colors to 256
if (ierr.gt.0) then
ncoli = 256
iscol = 1
endif
c set number of foreground colors, 0 < ncols < 8
if (iscol.eq.1) then
c special case for IBM graPHIGS gks and DEC gks
c ncoli = npci
nclsp = ncoli - 1
ncols = min0(ncoli,8) - 1
else
nclsp = 1
ncols = 1
endif
c set colors
call grcols
c idcun = device coordinate units, 0 = meters
c dcx, dcy = display width, height in device coordinate units
c isx, isy = display width, height, in raster units
c inquire maximum display surface size
call gqdsp(iwtype,ierr,idcun,dcx,dcy,isx,isy)
c if metafile, set square display
if (ierr.gt.0) then
dcx = 1.0
dcy = 1.0
isx = 1
isy = 1
endif
if (isx.gt.isy) then
rx = 1.0
ry = dcy/dcx
else
rx = dcx/dcy
ry = 1.0
endif
c set workstation window
call gswkwn(idwk,zero,rx,zero,ry)
c set workstation viewport
call gswkvp(idwk,zero,dcx,zero,dcy)
idstr = 1
c inquire string device state
call gqsts(idwk,idstr,1,ierr,mode,iesw,lstr,str,ipet,earea,lenb,ip
1os,ldr,datar)
if (ierr.eq.0) then
c echo area is in lower right or lower left hand corner
ecx = .9*dcx
if (iecho.eq.1) ecx = .05*dcx
ecy = .05*dcy
c initialize string device
call ginst(idwk,idstr,lstr,str,ipet,ecx,dcx,zero,ecy,lenb,ipos,
1ldr,datar)
else
idstr = 0
endif
idloc = 1
c inquire locator device state
call gqlcs(idwk,idloc,0,1,ierr,mode,iesw,nrt,px,py,ipet,earea,ldr,
1datar)
if (ierr.eq.0) then
c initialize locator device
call ginlc(idwk,idloc,nrt,px,py,ipet,zero,dcx,zero,dcy,ldr,data
1r)
else
idloc = 0
endif
return
end
subroutine grcols
c if possible, this subroutine sets the color indices as follows:
c 0 = background, 1 = foreground, 2 = blue, 3 = red
c 4 = yellow, 5 = cyan, 6 = magenta, 7 = green
c the rgb values of these colors are stored in the arrays
c reds, greens, and blues, respectively
c idwk = workstation identifier
c ncols = number of foreground colors available for line plotting
c ifrg = index of foreground color
c kprime = table of color indices for prime colors
common /plotcm/ idwk,ncols,rx,ry,iplot,nplot,iclr,iupd,idstr,idloc
1,nclsp,ifrg,isx,isy,kprime(8)
dimension reds(8), greens(8), blues(8)
c background = black, foreground = white
data reds /0.,1.,0.,1.,1.,0.,1.,0./
data greens /0.,1.,0.,0.,1.,1.,0.,1./
data blues /0.,1.,1.,0.,0.,1.,1.,0./
c background = white, foreground = black
c data reds /1.,0.,0.,1.,1.,0.,1.,0./
c data greens /1.,0.,0.,0.,1.,1.,0.,1./
c data blues /1.,0.,1.,0.,0.,1.,1.,0./
c data reds /1.,0.,0.,1.,0.,0.,1.,1./
c data greens /1.,0.,0.,0.,1.,1.,0.,1./
c data blues /1.,0.,1.,0.,0.,1.,1.,0./
c set background color index
kprime(1) = 0
c set color representation
call gscr(idwk,0,reds(1),greens(1),blues(1))
c set foreground color index
ifrg = 1
c set color representation
call gscr(idwk,1,reds(2),greens(2),blues(2))
do 10 j = 2, 8
kprime(j) = ifrg
10 continue
c define allowed color indices
do 20 j = 2, ncols
icol = j + 1
c set color representation
call gscr(idwk,j,reds(icol),greens(icol),blues(icol))
c store index
kprime(icol) = j
20 continue
return
end
subroutine grspal(nbit,pal,npal,ipmx,lpald)
c this subroutine sets palette of color indices for nbit color.
c if npal = 0, a default palette is set, if possible, as follows:
c for nbit = 1, 0 = background, 1 = foreground
c for nbit = 2, 0 = background, 1 = cyan, 2 = red, 3 = foreground
c for nbit = 3, 0 = background, 1 = blue, 2 = green, 3 = cyan, 4 = red,
c 5 = magenta, 6 = yellow, 7 = foreground
c for nbit = 4, 0 = background, 1 = dark grey, 2 = blue, 3 = light blue,
c 4 = green, 5 = light green, 6 = cyan, 7 = light cyan, 8 = red,
c 9 = light red, 10 = magenta, 11 = light magenta, 12 = yellow,
c 13 = light yellow, 14 = white, 15 = intense white
c the rgb values of these colors are stored in the arrays
c reds, greens, and blues, respectively
c if npal > 0, then a specified palette array pal is used, if possible.
c if enough colors are not available, then a default palette with enough
c colors is used, with an integer pixel lookup table to interpolate
c from given palette pal to 7 bit color. scheme used is as follows:
c for a given palette entry i, ipal(i) = 4*ir + 2*ig + ib, where
c ir = 64*irh+8*irm+irl, ig = 64*igh+8*igm+igl, ib = 64*ibh+8*ibm+ibl
c irh = 0, when the red value for the ith entry is < .5*max(red)
c igh = 0, when the green value for the ith entry is < .5*max(green)
c ibh = 0, when the blue value for the ith entry is < .5*max(blue)
c otherwise, irh, igh, and ibh are 1.
c irm = 0, when the red value - .5*irh*max(red) < .25*max(red)
c igm = 0, when the green value - .5*igh*max(green) < .25*max(green)
c irm = 0, when the blue value - .5*ibh*max(blue) < .25*max(blue)
c otherwise, irm, igm, and ibm are 1.
c irl = 0, when the red value - (.5*irh+.25*irm)*max(red)
c < .125*max(red)
c igl = 0, when the green value - (.5*igh+.25*igm)*max(green)
c < .125*max(green)
c irl = 0, when the blue value - (.5*ibh+.25*ibm)*max(blue)
c < .125*max(blue)
c otherwise, irl, igl, and ibl are 1.
c ipal is then divided by 512/ntc.
c nbit = the number of colors, pixel depth
c pal = palette array, with rgb values in successive bytes
c npal = (0,n) = (default,n) palette entries
c ipmx = maximum color value in the palette
c lpald = size of palette array
c npald = number of palette entries
parameter(npald=256)
c lxm, lym = maximum number of pixels in x, y
parameter(lxm=720,lym=540)
character*1 pal(lpald)
c ipal = integer pixel lookup table
dimension ipal(npald)
c img8 = integer image array
dimension img8(lxm*lym)
c idwk = workstation identifier
c nclsp = number of foreground colors supported on device
c ifrg = index of foreground color
common /plotcm/ idwk,ncols,rx,ry,iplot,nplot,iclr,iupd,idstr,idloc
1,nclsp,ifrg,isx,isy,kprime(8)
c lupt = (0,1) = (no,yes) pixel lookup table needed
common /movicm/ lupt,ipal,img8
dimension redp(8), greenp(8), bluep(8)
dimension reds(254), greens(254), blues(254)
dimension redx(256), greenx(256), bluex(256)
save /movicm/
c prime colors, background = black, foreground = white
data redp /0.,1.,0.,1.,1.,0.,1.,0./
data greenp /0.,1.,0.,0.,1.,1.,0.,1./
data bluep /0.,1.,1.,0.,0.,1.,1.,0./
c prime colors, background = black, foreground = white
c data redp /1.,0.,0.,1.,1.,0.,1.,0./
c data greenp /1.,0.,0.,0.,1.,1.,0.,1./
c data bluep /1.,0.,1.,0.,0.,1.,1.,0./
c data redp /1.,0.,0.,1.,0.,0.,1.,1./
c data greenp /1.,0.,0.,0.,1.,1.,0.,1./
c data bluep /1.,0.,1.,0.,0.,1.,1.,0./
data reds /0.,1.,0.,0.,1.,1.,0.,0.,0.,0.,1.,1.,1.,1.,0.,.33,0.,.33
1,0.,.33,0.,.33,.67,1.,.67,1.,.67,1.,.67,1.,0.,0.,.33,.33,0.,0.,.33
2,.33,0.,0.,.33,.33,0.,0.,.33,.33,.67,.67,1.,1.,.67,.67,1.,1.,.67,.
367,1.,1.,.67,.67,1.,1.,0.,0.,0.,0.,.33,.33,.33,.33,0.,0.,0.,0.,.33
4,.33,.33,.33,0.,0.,0.,0.,.33,.33,.33,.33,0.,0.,0.,0.,.33,.33,.33,.
533,.67,.67,.67,.67,1.,1.,1.,1.,.67,.67,.67,.67,1.,1.,1.,1.,.67,.67
6,.67,.67,1.,1.,1.,1.,.67,.67,.67,.67,1.,1.,1.,1.,0.,.14,0.,.14,0.,
7.14,0.,.14,.29,.43,.29,.43,.29,.43,.29,.43,0.,.14,0.,.14,0.,.14,0.
8,.14,.29,.43,.29,.43,.29,.43,.29,.43,0.,.14,0.,.14,0.,.14,0.,.14,.
929,.43,.29,.43,.29,.43,.29,.43,0.,.14,0.,.14,0.,.14,0.,.14,.29,.43
a,.29,.43,.29,.43,.29,.43,.57,.71,.57,.71,.57,.71,.57,.71,.86,1.,.8
b6,1.,.86,1.,.86,1.,.57,.71,.57,.71,.57,.71,.57,.71,.86,1.,.86,1.,.
c86,1.,.86,1.,.57,.71,.57,.71,.57,.71,.57,.71,.86,1.,.86,1.,.86,1.,
d.86,1.,.57,.71,.57,.71,.57,.71,.57,.71,.86,1.,.86,1.,.86,1.,.86,1.
e/
data greens /0.,1.,0.,1.,0.,1.,0.,0.,1.,1.,0.,0.,1.,1.,0.,.33,0.,.
133,.67,1.,.67,1.,0.,.33,0.,.33,.67,1.,.67,1.,0.,.33,0.,.33,0.,.33,
20.,.33,.67,1.,.67,1.,.67,1.,.67,1.,0.,.33,0.,.33,0.,.33,0.,.33,.67
3,1.,.67,1.,.67,1.,.67,1.,0.,0.,.33,.33,0.,0.,.33,.33,0.,0.,.33,.33
4,0.,0.,.33,.33,.67,.67,1.,1.,.67,.67,1.,1.,.67,.67,1.,1.,.67,.67,1
5.,1.,0.,0.,.33,.33,0.,0.,.33,.33,0.,0.,.33,.33,0.,0.,.33,.33,.67,.
667,1.,1.,.67,.67,1.,1.,.67,.67,1.,1.,.67,.67,1.,1.,0.,.14,0.,.14,.
729,.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43
8,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,.57,.71,.57,.71,.86,1.,.86,
91.,.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1.,.57
a,.71,.57,.71,.86,1.,.86,1.,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.
b,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.
c29,.43,.29,.43,.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1
d.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,
e1./
data blues /0.,1.,0.,1.,0.,1.,0.,1.,0.,1.,0.,1.,0.,1.,0.,.33,.67,1
1.,0.,.33,.67,1.,0.,.33,.67,1.,0.,.33,.67,1.,0.,.33,0.,.33,.67,1.,.
267,1.,0.,.33,0.,.33,.67,1.,.67,1.,0.,.33,0.,.33,.67,1.,.67,1.,0.,.
333,0.,.33,.67,1.,.67,1.,0.,.33,0.,.33,0.,.33,0.,.33,.67,1.,.67,1.,
4.67,1.,.67,1.,0.,.33,0.,.33,0.,.33,0.,.33,.67,1.,.67,1.,.67,1.,.67
5,1.,0.,.33,0.,.33,0.,.33,0.,.33,.67,1.,.67,1.,.67,1.,.67,1.,0.,.33
6,0.,.33,0.,.33,0.,.33,.67,1.,.67,1.,.67,1.,.67,1.,0.,.14,.29,.43,0
7.,.14,.29,.43,0.,.14,.29,.43,0.,.14,.29,.43,.57,.71,.86,1.,.57,.71
8,.86,1.,.57,.71,.86,1.,.57,.71,.86,1.,0.,.14,.29,.43,0.,.14,.29,.4
93,0.,.14,.29,.43,0.,.14,.29,.43,.57,.71,.86,1.,.57,.71,.86,1.,.57,
a.71,.86,1.,.57,.71,.86,1.,0.,.14,.29,.43,0.,.14,.29,.43,0.,.14,.29
b,.43,0.,.14,.29,.43,.57,.71,.86,1.,.57,.71,.86,1.,.57,.71,.86,1.,.
c57,.71,.86,1.,0.,.14,.29,.43,0.,.14,.29,.43,0.,.14,.29,.43,0.,.14,
d.29,.43,.57,.71,.86,1.,.57,.71,.86,1.,.57,.71,.86,1.,.57,.71,.86,1
e./
data redx /0.,0.,.14,.14,0.,0.,.14,.14,0.,0.,.14,.14,0.,0.,.14,.14
1,.29,.29,.43,.43,.29,.29,.43,.43,.29,.29,.43,.43,.29,.29,.43,.43,0
2.,0.,.14,.14,0.,0.,.14,.14,0.,0.,.14,.14,0.,0.,.14,.14,.29,.29,.43
3,.43,.29,.29,.43,.43,.29,.29,.43,.43,.29,.29,.43,.43,0.,0.,.14,.14
4,0.,0.,.14,.14,0.,0.,.14,.14,0.,0.,.14,.14,.29,.29,.43,.43,.29,.29
5,.43,.43,.29,.29,.43,.43,.29,.29,.43,.43,0.,0.,.14,.14,0.,0.,.14,.
614,0.,0.,.14,.14,0.,0.,.14,.14,.29,.29,.43,.43,.29,.29,.43,.43,.29
7,.29,.43,.43,.29,.29,.43,.43,.57,.57,.71,.71,.57,.57,.71,.71,.57,.
857,.71,.71,.57,.57,.71,.71,.86,.86,1.,1.,.86,.86,1.,1.,.86,.86,1.,
91.,.86,.86,1.,1.,.57,.57,.71,.71,.57,.57,.71,.71,.57,.57,.71,.71,.
a57,.57,.71,.71,.86,.86,1.,1.,.86,.86,1.,1.,.86,.86,1.,1.,.86,.86,1
b.,1.,.57,.57,.71,.71,.57,.57,.71,.71,.57,.57,.71,.71,.57,.57,.71,.
c71,.86,.86,1.,1.,.86,.86,1.,1.,.86,.86,1.,1.,.86,.86,1.,1.,.57,.57
d,.71,.71,.57,.57,.71,.71,.57,.57,.71,.71,.57,.57,.71,.71,.86,.86,1
e.,1.,.86,.86,1.,1.,.86,.86,1.,1.,.86,.86,1.,1./
data greenx /0.,.14,0.,.14,0.,.14,0.,.14,.29,.43,.29,.43,.29,.43,.
129,.43,0.,.14,0.,.14,0.,.14,0.,.14,.29,.43,.29,.43,.29,.43,.29,.43
2,0.,.14,0.,.14,0.,.14,0.,.14,.29,.43,.29,.43,.29,.43,.29,.43,0.,.1
34,0.,.14,0.,.14,0.,.14,.29,.43,.29,.43,.29,.43,.29,.43,.57,.71,.57
4,.71,.57,.71,.57,.71,.86,1.,.86,1.,.86,1.,.86,1.,.57,.71,.57,.71,.
557,.71,.57,.71,.86,1.,.86,1.,.86,1.,.86,1.,.57,.71,.57,.71,.57,.71
6,.57,.71,.86,1.,.86,1.,.86,1.,.86,1.,.57,.71,.57,.71,.57,.71,.57,.
771,.86,1.,.86,1.,.86,1.,.86,1.,0.,.14,0.,.14,0.,.14,0.,.14,.29,.43
8,.29,.43,.29,.43,.29,.43,0.,.14,0.,.14,0.,.14,0.,.14,.29,.43,.29,.
943,.29,.43,.29,.43,0.,.14,0.,.14,0.,.14,0.,.14,.29,.43,.29,.43,.29
a,.43,.29,.43,0.,.14,0.,.14,0.,.14,0.,.14,.29,.43,.29,.43,.29,.43,.
b29,.43,.57,.71,.57,.71,.57,.71,.57,.71,.86,1.,.86,1.,.86,1.,.86,1.
c,.57,.71,.57,.71,.57,.71,.57,.71,.86,1.,.86,1.,.86,1.,.86,1.,.57,.
d71,.57,.71,.57,.71,.57,.71,.86,1.,.86,1.,.86,1.,.86,1.,.57,.71,.57
e,.71,.57,.71,.57,.71,.86,1.,.86,1.,.86,1.,.86,1./
data bluex /0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43,.2
19,.43,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,
2.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1.,.57,.7
31,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1.,0.,.14,0.,.1
44,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,
5.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,.57,.71,.57,.71,.86,1.,.
686,1.,.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1.,
7.57,.71,.57,.71,.86,1.,.86,1.,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14
8,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.1
94,.29,.43,.29,.43,.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.8
a6,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.
b86,1.,0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,
c0.,.14,0.,.14,.29,.43,.29,.43,0.,.14,0.,.14,.29,.43,.29,.43,.57,.7
d1,.57,.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1.,.57,.71,.57,
e.71,.86,1.,.86,1.,.57,.71,.57,.71,.86,1.,.86,1./
c clear pixel lookup table flag
lupt = 0
c ntc = number of colors requested
ntc = 2**nbit
c for default palette, only 256 colors allowed
if ((npal.eq.0).and.(ntc.gt.256)) ntc = 256
c do not use more colors than specified in palette
if ((npal.gt.0).and.(ntc.gt.npal)) ntc = npal
c save number of colors requested
ncr = ntc
c do not use more colors than workstation supports
ncoli = nclsp + 1
if (ntc.gt.ncoli) then
c set pixel lookup table flag
lupt = 1
c determine how many colors are possible
if (npal.gt.0) ntc = 128
if (ntc.gt.ncoli) ntc = 64
if (ntc.gt.ncoli) ntc = 32
if (ntc.gt.ncoli) ntc = 16
if (ntc.gt.ncoli) ntc = 8
if (ntc.gt.ncoli) ntc = 4
if (ntc.gt.ncoli) ntc = 2
write (6,*) 'too many colors requested: ncr,ncoli = ',ncr,ncoli
write (6,*) 'only ',ntc,' will be used'
endif
c set default palette
if ((npal.eq.0).or.(lupt.eq.1)) then
do 10 j = 1, ntc
jc = j - 1
c 128 or fewer colors
if (ntc.le.128) then
icol = j + ntc - 2
c set color representation
call gscr(idwk,jc,reds(icol),greens(icol),blues(icol))
c 256 colors
else
c set color representation
call gscr(idwk,jc,redx(j),greenx(j),bluex(j))
endif
10 continue
c set specified palette
else
apmx = 1./real(ipmx - 1)
do 20 j = 1, ntc
jc = j - 1
j1 = 3*(j - 1)
red = real(ichar(pal(j1+1)))*apmx
green = real(ichar(pal(j1+2)))*apmx
blue = real(ichar(pal(j1+3)))*apmx
c set color representation
call gscr(idwk,jc,red,green,blue)
20 continue
endif
c find which indices correspond to prime colors
apmx = 1./real(ipmx - 1)
do 40 i = 1, 8
jmin = 0
cdm = 3.0
do 30 j = 1, ntc
jc = j - 1
c default palette
if ((npal.eq.0).or.(lupt.eq.1)) then
c 128 or fewer colors
if (ntc.le.128) then
icol = j + ntc - 2
cd = (reds(icol) - redp(i))**2 + (greens(icol) - greenp(i))*
1*2 + (blues(icol) - bluep(i))**2
c 256 colors
else
cd = (redx(j) - redp(i))**2 + (greenx(j) - greenp(i))**2 +
1(bluex(j) - bluep(i))**2
endif
c specified palette
else
j1 = 3*(j - 1)
cd = (real(ichar(pal(j1+1)))*apmx - redp(i))**2 + (real(ichar(p
1al(j1+2)))*apmx - greenp(i))**2 + (real(ichar(pal(j1+3)))*apmx -
2bluep(i))**2
endif
if (cd.le.cdm) then
jmin = jc
cdm = cd
endif
30 continue
kprime(i) = jmin
40 continue
c swap colors for index 0 and background
if (kprime(1).ne.0) then
jc = kprime(1)
if ((npal.eq.0).or.(lupt.eq.1)) then
c 128 or fewer colors
if (ntc.le.128) then
icol = ntc - 1
r0 = reds(icol)
g0 = greens(icol)
b0 = blues(icol)
icol = icol + jc
c set color representation
call gscr(idwk,0,reds(icol),greens(icol),blues(icol))
call gscr(idwk,jc,r0,g0,b0)
c 256 colors
else
r0 = redx(1)
g0 = greenx(1)
b0 = bluex(1)
icol = jc + 1
c set color representation
call gscr(idwk,0,redx(icol),greenx(icol),bluex(icol))
call gscr(idwk,jc,r0,g0,b0)
endif
c specified palette
else
apmx = 1./real(ipmx - 1)
r0 = real(ichar(pal(1)))*apmx
g0 = real(ichar(pal(2)))*apmx
b0 = real(ichar(pal(3)))*apmx
j1 = 3*jc
red = real(ichar(pal(j1+1)))*apmx
green = real(ichar(pal(j1+2)))*apmx
blue = real(ichar(pal(j1+3)))*apmx
c set color representation
call gscr(idwk,0,red,green,blue)
call gscr(idwk,jc,r0,g0,b0)
endif
if (kprime(2).eq.0) kprime(2) = jc
c set foreground color index
endif
ifrg = kprime(2)
c ifrg = ntc - 1
c pixel lookup table not needed
if (lupt.eq.0) return
c create pixel lookup table
itc = 512/ntc
c mapping from default 128 colors to fewer
if (npal.eq.0) then
aptq = 8.
do 50 j = 1, ncr
icol = j + ncr - 2
ip = reds(icol)*aptq
if (ip.gt.7) ip = 7
it = 48*(ip/4) + 6*(ip/2) + ip
ip = greens(icol)*aptq
if (ip.gt.3) ip = 3
it = 2*it + (48*(ip/4) + 6*(ip/2) + ip)
ip = blues(icol)*aptq
if (ip.gt.3) ip = 3
it = 2*it + (48*(ip/4) + 6*(ip/2) + ip)
ipal(j) = it/itc
50 continue
c mapping from 256 specified colors to 128 or fewer colors
else
len = npal
if (len.gt.npald) len = npald
iptq = ipmx/8
do 70 j = 1, len
j1 = 3*(j - 1)
it = 0
do 60 i = 1, 3
ip = ichar(pal(j1+i))/iptq
it = 2*it + (48*(ip/4) + 6*(ip/2) + ip)
60 continue
ipal(j) = it/itc
70 continue
endif
return
end
subroutine GRCLOSE
c this subroutine deactivates workstation and closes gks
c idwk = workstation identifier
common /plotcm/ idwk,ncols,rx,ry,iplot,nplot,iclr,iupd,idstr,idloc
1,nclsp,ifrg,isx,isy,kprime(8)
c pause if plots are still pending
if (((iplot.ne.0).and.(iupd.eq.0)).or.(iupd.eq.1)) then
c update workstation, perform
call guwk(idwk,1)
c read code from input device, if present
call readrc(irc)
endif
c deactivate workstation
call gdawk(idwk)
c close workstation
call gclwk(idwk)
c close gks
call gclks
return
end
subroutine SETNPLT (nplt,irc)
c this subroutine resets the maximum number of plots per page
c if requested number is negative, it is set to default (=1)
c the current plot location is also reset to the next available location
c if next available location is iplot = 0 and the old location was not
c 0, then the workstation is updated and a return code can be generated.
c iplot = plot location on page, 0 <= iplot < nplot
c nplot = number of plots per page
common /plotcm/ idwk,ncols,rx,ry,iplot,nplot,iclr,iupd,idstr,idloc
1,nclsp,ifrg,isx,isy,kprime(8)
c set return code to normal
irc = 0
c suppress plots (nplt = 0)
if (nplt.eq.0) then
iplot = 0
nplot = 0
return
endif
c calculate old screen partition
npl1 = sqrt(real(nplot-1)) + 0.0001
npl = npl1 + 1
apl = 1./real(npl)
c find location of previous plot
iplt = iplot - 1
if (iplt.lt.0) iplt = iplt + nplot
c find coordinates of previous plot
iy = iplt/npl
ix = iplt - iy*npl + 1
iy = npl1 - iy
c reset maximum number of plots per page
if (nplt.ge.0) then
nplot = nplt
else
nplot = 1
endif
c calculate new screen partition
npl1 = sqrt(real(nplot-1)) + 0.0001
npl = npl1 + 1
c find plot coordinates of previous plot in new screen partition
px = apl*real(ix) - 0.0001
py = apl*real(iy) + 0.0001
ix = abs(px)*real(npl)
iy = abs(1. - py)*real(npl)
c find new plot location
iplt = 1 + (ix + iy*npl)
if (iplt.ge.nplot) then
c pause if plots are still pending
if (((iplot.ne.0).and.(iupd.eq.0)).or.(iupd.eq.1)) then
c update workstation, perform
call guwk(idwk,1)
c read code from input device, if present
call readrc(irc)
endif
iplot = 0
else
iplot = iplt
endif
return
end
subroutine DISPR (f,label,xmin,xmax,isc,ist,mks,nx,nxv,ngs,chr,chr
1s,irc)
c this subroutine plots ngs subarrays of the array f, on a common graph,
c each plot with nx points, versus a linear function in x,
c where xmin < x < xmax.
c depending on the number of colors in the display device, each subarray
c is plotted with a different color, given in order by:
c blue, red, yellow, cyan, magenta, green, and foreground.
c after all the colors are cycled through, then different line styles
c are cycled through if mks=0, in order: solid, dash, dot, dash-dot,
c or different marker types if mks>0: dot, plus, star, circle, cross.
c multiple plots per page can be displayed by dividing the screen into
c n x n subregions, where n*n is the next largest integer >= nplot
c the location (ix,iy) of a plot in the subregions is determined by
c the parameter iplot = ix + iy*n
c f = array containing subarrays to be plotted
c label = long character string label for plot
c xmin/xmax = range of x values in plot
c isc = power of 2 scale of y coordinate for plot
c ist = flag for choosing positive and/or negative values
c the plots have a common scale in y given by ymax and ymin.
c if ist = 0, then ymax = 2**isc and ymin = -2**isc.
c if ist = 1, then ymax = 2**isc and ymin = 0.
c if ist = -1, then ymax = 0 and ymin = -2**isc.
c if ist = 2, then ymin = fmin, ymax = fmin + 2**ir,
c where fmin/fmax are the function minimum/maximum,
c and ir = power of 2 scale for (fmax - fmin)
c if abs(isc) < 116, then the isc value passed is used for scale.
c if abs(isc) > 116, then the program finds the minimum value of isc
c which will contain the plots, determined by the absolute value of f
c mks = flag to determine whether lines or markers are used,
c mks=0 means cycle through lines styles, mks > 0 means cycle through
c marker styles, using the value of mks as the initial marker,
c mks < 0 means draw the first subarray with a line, then subsequent
c subarrays with markers, using the value of abs(mks) as the initial
c marker.
c nx = number of points plotted in each subarray
c nxv = first dimension of array f, nxv >= nx
c ngs = second dimension of array f, number of subarrays to be plotted
c chr = additional long character string comment for plot
c chrs = array of ngs short character labels used by subroutine tickd
c to label individual line or marker samples
c irc = return code (0 = normal return)
c nxbs = length of scratch variable for plotting
parameter(nxbs=65)
character*(*) label, chr
character*(*) chrs(ngs)
c idwk = workstation identifier
c ncols = number of foreground colors available for line plotting
c rx, ry = ndc coordinates of upper-right corner of workstation window
c iplot = plot location on page, 0 <= iplot < nplot
c nplot = number of plots per page
c iclr = (-1,0,1) = (no,default,yes) erase plot (default=when iplot=0)
c iupd = (-1,0,1) = (no,default,yes) end plot
c (default=when iplot=nplot-1)
c kprime = table of color indices for prime colors
common /plotcm/ idwk,ncols,rx,ry,iplot,nplot,iclr,iupd,idstr,idloc
1,nclsp,ifrg,isx,isy,kprime(8)
dimension f(nxv,ngs)
c x,y = scratch arrays for plotting
dimension x(nxbs), y(nxbs)
c dv = scale will be set in powers of this parameter
data dv /2.0/
c smin/smax = range of x values of plotting window
c tmin/tmax = range of y values of plotting window
data smin,tmin,smax,tmax /.25,.14,.975,.975/
c nlts = number of line types available
c nmks = number of markers available
c ntx/nty = number of ticks in grid in x/y direction
data nlts,nmks,ntx,nty /4,5,11,9/
c csize = vertical size of characters
data csize /0.034/
c set return code to normal
irc = 0
c exit if plots are suppressed (nplot = 0)
if (nplot.lt.1) return
algdvi = 1./alog(dv)
c find scales for plot
is = isc
if (abs(is).gt.116) then
fmax = f(1,1)
fmin = fmax
do 20 k = 1, ngs
do 10 j = 1, nx
fmax = amax1(fmax,f(j,k))
fmin = amin1(fmin,f(j,k))
10 continue
20 continue
if (fmax.eq.0.) fmax = 1.0e-35
rmax = fmax - fmin
if (rmax.eq.0.) rmax = 1.0e-35
rmin = fmin
ymax = abs(fmax)
is = alog(ymax)*algdvi
if (ymax.ge.1.) is = is + 1
if (ymax.le.dv**(is-1)) is = is - 1
ymin = abs(fmin)
if (ymin.gt.0.) then
it = alog(ymin)*algdvi
if (ymin.ge.1.) it = it + 1
if (ymin.le.dv**(it-1)) it = it - 1
endif
if (fmax.gt.0.) then
if (fmin.gt.0.) then
fmin = dv**(it - 1)
else if (fmin.lt.0.) then
fmin = -dv**it
endif
fmax = dv**is
else
fmax = -dv**(is - 1)
fmin = -dv**it
endif
if (ist.eq.0) then
if (ymin.gt.ymax) then
fmax = dv**it
else
fmin = -dv**is
endif
else if (ist.eq.2) then
ir = alog(rmax)*algdvi
if (rmax.ge.1.) ir = ir + 1
if (rmax.le.dv**(ir-1)) ir = ir - 1
fmin = rmin
fmax = rmin + dv**ir
if (fmax.eq.fmin) fmax = fmin + 1.0
endif
else
fmax = dv**is
fmin = -fmax
endif
ymax = fmax
ymin = fmin
if (ist.eq.1) then
ymin = 0.
else if (ist.eq.(-1)) then
ymax = 0.
endif
c parameters for plots
dx = xmax - xmin
if (nx.gt.1) dx = dx/real(nx - 1)
nxs = nxbs - 1
c find location for plot
npl1 = sqrt(real(nplot-1)) + 0.0001
npl = npl1 + 1
apl = 1./real(npl)
iy = iplot/npl
ix = iplot - iy*npl
aplx = apl*rx
aply = apl*ry
orx = aplx*real(ix)
ory = aply*real(npl1 - iy)
smn = orx + aplx*smin
smx = orx + aplx*smax
tmn = ory + aply*tmin
tmx = ory + aply*tmax
chh = aply*csize
c initiate plot
if (((iplot.eq.0).and.(iclr.eq.0)).or.(iclr.eq.1)) then
c clear workstation, always
call gclrwk(idwk,1)
endif
c draw grid and labels, call identity transformation
call tickd(xmin,xmax,ymin,ymax,orx,ory,smn,smx,tmn,tmx,ntx,nty,lab
1el,chr,chh)
c display sample lines or markers
call dsmpln(orx,smn,tmn,tmx,ngs,nlts,nmks,mks,chrs,chh)
c define transformation number 2
nrt = 1
c set window
call gswn(nrt,xmin,xmax,ymin,ymax)
c set viewport
call gsvp(nrt,smn,smx,tmn,tmx)
c select normalization transformation
call gselnt(nrt)
c set linewidth scale factor, 1.0 = nominal
call gslwsc(1.0)
mkr = abs(mks)
c use markers
if (mkr.ne.0) then
c set marker size scale factor, 1.0 = nominal
call gsmksc(1.0)
endif
c set clipping indicator, 1 = on
call gsclip(1)
c plot curves, first cycle through colors, then line or marker types
do 70 k = 1, ngs
icol = k + 1 - ncols*(k/ncols)
icol = kprime(icol+1)
c use line types
if ((mks.eq.0).or.((mks.lt.0).and.(k.eq.1))) then
c blocking parameters for plots
nxb = (nx - 2)/nxs + 1
npts = nxbs
c length of last block
nptl = nx - nxs*(nxb - 1)
c set polyline color index
c 1=foreground, 2=blue, 3=red, 4=yellow, 5=cyan, 6=magenta, 7=green
call gsplci(icol)
ltype = 1 + (k - 1)/ncols - nlts*((k - 1)/(nlts*ncols))
c set linetype, 1 = solid, 2 = dash, 3 = dot, 4 = dash-dot
call gsln(ltype)
c plot curve
npt = npts
c loop over number of blocks
do 40 j = 1, nxb
js = nxs*(j - 1)
if (j.eq.nxb) npt = nptl
c calculate x,y axes for block
do 30 i = 1, npt
x(i) = xmin + dx*real(i + js - 1)
y(i) = f(i+js,k)
30 continue
c draw polyline
call gpl(npt,x,y)
40 continue
c use markers
else
c blocking parameters for plots
nxb = (nx - 1)/nxs + 1
npts = nxs
c length of last block
nptl = nx - nxs*(nxb - 1)
c set polymarker color index
c 1=foreground, 2=blue, 3=red, 4=yellow, 5=cyan, 6=magenta, 7=green
call gspmci(icol)
mtype = mkr + (k - 1)/ncols - nmks*((mkr - 1 + (k - 1)/ncols)/n
1mks)
c set marker type, 1 = dot, 2 = plus, 3 = star, 4 = circle, 5 = cross
call gsmk(mtype)
c plot polymarkers
npt = npts
c loop over number of blocks
do 60 j = 1, nxb
js = nxs*(j - 1)
if (j.eq.nxb) npt = nptl
c calculate x,y axes for block
do 50 i = 1, npt
x(i) = xmin + dx*real(i + js - 1)
y(i) = f(i+js,k)
50 continue
c dots
if (mtype.eq.1) then
c treat dots by drawing a line to itself
call spdots(x,y,npt,icol,nxbs)
else
c draw polymarker
call gpm(npt,x,y)
endif
60 continue
endif
70 continue
c update plot number
iplot = iplot + 1
if (iplot.eq.nplot) iplot = 0
if (((iplot.eq.0).and.(iupd.eq.0)).or.(iupd.eq.1)) then
c update workstation, perform
call guwk(idwk,1)
c read code from input device, if present
call readrc(irc)
endif
c reset defaults
iclr = 0
iupd = 0
return
end
subroutine DISPC (f,g,label,zsc,zst,mks,nx,nxv,ngs,chr,chrs,irc)
c this subroutine plots ngs subarrays of the array f, on a common graph,
c each plot with nx points, versus the corresponding subarray of the
c array g.
c depending on the number of colors in the display device, each subarray
c is plotted with a different color, given in order by:
c blue, red, yellow, cyan, magenta, green, and foreground
c after all the colors are cycled through, then different lines styles
c are cycled through if mks=0, in order: solid, dash, dot, dash-dot,
c or different marker types if mks>0: dot, plus, star, circle, cross.
c multiple plots per page can be displayed by dividing the screen into
c n x n subregions, where n*n is the next largest integer >= nplot
c the location (ix,iy) of a plot in the subregions is determined by
c the parameter iplot = ix + iy*n
c f, g = arrays containing subarrays to be plotted
c label = long character string label for plot
c real(zsc)/aimag(zsc) = power of 2 scale of x/y coordinate for plot
c real(zst)/aimag(zst) = flag for positive and/or negative x/y values.
c the plots have a common scale in y given by ymax and ymin,
c where isc = int(aimag(zsc)) and ist = int(aimag(zst)), as follows:
c if ist = 0, then ymax = 2**isc and ymin = -2**isc.
c if ist = 1, then ymax = 2**isc and ymin = 0.
c if ist = -1, then ymax = 0 and ymin = -2**isc.
c if ist = 2, then ymin = fmin, ymax = fmin + 2**ir,
c where fmin/fmax are the function minimum/maximum,
c and ir = power of 2 scale for (fmax - fmin)
c if abs(isc) < 116, then the isc value passed is used for scale.
c if abs(isc) > 116, then the program finds the minimum value of isc
c which will contain the plots, determined by the absolute value of f
c the plots have a common scale in x given by xmax and xmin,
c where isc = int(real(zsc)) and ist = int(real(zst)), as follows:
c if ist = 0, then xmax = 2**isc and xmin = -2**isc.
c if ist = 1, then xmax = 2**isc and xmin = 0.
c if ist = -1, then xmax = 0 and xmin = -2**isc.
c if ist = 2, then xmin = gmin, xmax = gmin + 2**ir,
c where gmin/gmax are the function minimum/maximum,
c and ir = power of 2 scale for (gmax - gmin)
c if abs(isc) < 116, then the isc value passed is used for scale.
c if abs(isc) > 116, then the program finds the minimum value of isc
c which will contain the plots, determined by the absolute value of g
c mks = flag to determine whether lines or markers are used,
c mks=0 means cycle through lines styles, mks > 0 means cycle through
c marker styles, using the value of mks as the initial marker,
c mks < 0 means draw the first subarray with a line, then subsequent
c subarrays with markers, using the value of abs(mks) as the initial
c marker.
c nx = number of points plotted in each subarray
c nxv = first dimension of array f, nxv >= nx
c ngs = second dimension of array f, number of subarrays to be plotted
c chr = additional character string comment for plot
c chrs = array of ngs short character labels used by subroutine tickd
c to label individual line or marker samples
c irc = return code (0 = normal return)
character*(*) label, chr
character*(*) chrs(ngs)
complex zsc, zst
c idwk = workstation identifier
c ncols = number of foreground colors available for line plotting
c rx, ry = ndc coordinates of upper-right corner of workstation window
c iplot = plot location on page, 0 <= iplot < nplot
c nplot = number of plots per page
c iclr = (-1,0,1) = (no,default,yes) erase plot (default=when iplot=0)
c iupd = (-1,0,1) = (no,default,yes) end plot
c (default=when iplot=nplot-1)
c kprime = table of color indices for prime colors
common /plotcm/ idwk,ncols,rx,ry,iplot,nplot,iclr,iupd,idstr,idloc
1,nclsp,ifrg,isx,isy,kprime(8)
dimension f(nxv,ngs), g(nxv,ngs)
c dv = scale will be set in powers of this parameter
data dv /2.0/
c smin/smax = range of x values of plotting window
c tmin/tmax = range of y values of plotting window
data smin,tmin,smax,tmax /.25,.14,.975,.975/
c nlts = number of line types available
c nmks = number of markers available
c ntx/nty = number of ticks in grid in x/y direction
data nlts,nmks,ntx,nty /4,5,9,9/
c csize = vertical size of characters
data csize /0.034/
c set return code to normal
irc = 0
c exit if plots are suppressed (nplot = 0)
if (nplot.lt.1) return
algdvi = 1./alog(dv)
c find y scales for plot
is = aimag(zsc)
ist = aimag(zst)
if (abs(is).gt.116) then
fmax = f(1,1)
fmin = fmax
do 20 k = 1, ngs
do 10 j = 1, nx
fmax = amax1(fmax,f(j,k))
fmin = amin1(fmin,f(j,k))
10 continue
20 continue
if (fmax.eq.0.) fmax = 1.0e-35
rmax = fmax - fmin
if (rmax.eq.0.) rmax = 1.0e-35
rmin = fmin
ymax = abs(fmax)
is = alog(ymax)*algdvi
if (ymax.ge.1.) is = is + 1
if (ymax.le.dv**(is-1)) is = is - 1
ymin = abs(fmin)
if (ymin.gt.0.) then
it = alog(ymin)*algdvi
if (ymin.ge.1.) it = it + 1
if (ymin.le.dv**(it-1)) it = it - 1
endif
if (fmax.gt.0.) then
if (fmin.gt.0.) then
fmin = dv**(it - 1)
else if (fmin.lt.0.) then
fmin = -dv**it
endif
fmax = dv**is
else
fmax = -dv**(is - 1)
fmin = -dv**it
endif
if (ist.eq.0) then
if (ymin.gt.ymax) then
fmax = dv**it
else
fmin = -dv**is
endif
else if (ist.eq.2) then
ir = alog(rmax)*algdvi
if (rmax.ge.1.) ir = ir + 1
if (rmax.le.dv**(ir-1)) ir = ir - 1
fmin = rmin
fmax = rmin + dv**ir
endif
else
fmax = dv**is
fmin = -fmax
endif
ymax = fmax
ymin = fmin
if (ist.eq.1) then
ymin = 0.
else if (ist.eq.(-1)) then
ymax = 0.
endif
c find x scales for plot
is = real(zsc)
ist = real(zst)
if (abs(is).gt.116) then
gmax = g(1,1)