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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
|
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
FUNCTION CFUX (RX)
C
C Given an x coordinate RX in the fractional system, CFUX(RX) is an x
C coordinate in the user system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=1
IF (MI.GE.3) I=2
CFUX=WD(I)+(RX-VP(1))/(VP(2)-VP(1))*(WD(3-I)-WD(I))
IF (LL.GE.3) CFUX=10.**CFUX
RETURN
END
FUNCTION CFUY (RY)
C
C Given a y coordinate RY in the fractional system, CFUY(RY) is a y
C coordinate in the user system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=3
IF (MI.EQ.2.OR.MI.GE.4) I=4
CFUY=WD(I)+(RY-VP(3))/(VP(4)-VP(3))*(WD(7-I)-WD(I))
IF (LL.EQ.2.OR.LL.GE.4) CFUY=10.**CFUY
RETURN
END
FUNCTION CMFX (IX)
C
C Given an x coordinate IX in the metacode system, CMFX(IX) is an x
C coordinate in the fractional system.
C
CMFX=FLOAT(IX)/32767.
RETURN
END
FUNCTION CMFY (IY)
C
C Given a y coordinate IY in the metacode system, CMFY(IY) is a y
C coordinate in the fractional system.
C
CMFY=FLOAT(IY)/32767.
RETURN
END
FUNCTION CMUX (IX)
C
C Given an x coordinate IX in the metacode system, CMUX(IX) is an x
C coordinate in the user system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=1
IF (MI.GE.3) I=2
CMUX=WD(I)+(FLOAT(IX)/32767.-VP(1))/(VP(2)-VP(1))*(WD(3-I)-WD(I))
IF (LL.GE.3) CMUX=10.**CMUX
RETURN
END
FUNCTION CMUY (IY)
C
C Given a y coordinate IY in the metacode system, CMUY(IY) is a y
C coordinate in the user system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=3
IF (MI.EQ.2.OR.MI.GE.4) I=4
CMUY=WD(I)+(FLOAT(IY)/32767.-VP(3))/(VP(4)-VP(3))*(WD(7-I)-WD(I))
IF (LL.EQ.2.OR.LL.GE.4) CMUY=10.**CMUY
RETURN
END
FUNCTION CPFX (IX)
C
C Given an x coordinate IX in the plotter system, CPFX(IX) is an x
C coordinate in the fractional system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
CPFX=FLOAT(IX-1)/(2.**MX-1.)
RETURN
END
FUNCTION CPFY (IY)
C
C Given a y coordinate IY in the plotter system, CPFY(IY) is a y
C coordinate in the fractional system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
CPFY=FLOAT(IY-1)/(2.**MY-1.)
RETURN
END
FUNCTION CPUX (IX)
C
C Given an x coordinate IX in the plotter system, CPUX(IX) is an x
C coordinate in the user system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=1
IF (MI.GE.3) I=2
CPUX=WD(I)+(FLOAT(IX-1)/(2.**MX-1.)-VP(1))/(VP(2)-VP(1))*
+ (WD(3-I)-WD(I))
IF (LL.GE.3) CPUX=10.**CPUX
RETURN
END
FUNCTION CPUY (IY)
C
C Given a y coordinate IY in the plotter system, CPUY(IY) is a y
C coordinate in the user system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=3
IF (MI.EQ.2.OR.MI.GE.4) I=4
CPUY=WD(I)+(FLOAT(IY-1)/(2.**MY-1.)-VP(3))/(VP(4)-VP(3))*
+ (WD(7-I)-WD(I))
IF (LL.EQ.2.OR.LL.GE.4) CPUY=10.**CPUY
RETURN
END
FUNCTION CUFX (RX)
C
C Given an x coordinate RX in the user system, CUFX(RX) is an x
C coordinate in the fractional system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=1
IF (MI.GE.3) I=2
IF (LL.LE.2) THEN
CUFX=(RX-WD(I))/(WD(3-I)-WD(I))*(VP(2)-VP(1))+VP(1)
ELSE
CUFX=(ALOG10(RX)-WD(I))/(WD(3-I)-WD(I))*(VP(2)-VP(1))+VP(1)
ENDIF
RETURN
END
FUNCTION CUFY (RY)
C
C Given a y coordinate RY in the user system, CUFY(RY) is a y
C coordinate in the fractional system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=3
IF (MI.EQ.2.OR.MI.GE.4) I=4
IF (LL.LE.1.OR.LL.EQ.3) THEN
CUFY=(RY-WD(I))/(WD(7-I)-WD(I))*(VP(4)-VP(3))+VP(3)
ELSE
CUFY=(ALOG10(RY)-WD(I))/(WD(7-I)-WD(I))*(VP(4)-VP(3))+VP(3)
ENDIF
RETURN
END
FUNCTION KFMX (RX)
C
C Given an x coordinate RX in the fractional system, KFMX(RX) is an x
C coordinate in the metacode system.
C
KFMX=IFIX(RX*32767.)
RETURN
END
FUNCTION KFMY (RY)
C
C Given a y coordinate RY in the fractional system, KFMY(RY) is a y
C coordinate in the metacode system.
C
KFMY=IFIX(RY*32767.)
RETURN
END
FUNCTION KFPX (RX)
C
C Given an x coordinate RX in the fractional system, KFPX(RX) is an x
C coordinate in the plotter system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
KFPX=1+IFIX(RX*(2.**MX-1.))
RETURN
END
FUNCTION KFPY (RY)
C
C Given a y coordinate RY in the fractional system, KFPY(RY) is a y
C coordinate in the plotter system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
KFPY=1+IFIX(RY*(2.**MX-1.))
RETURN
END
FUNCTION KMPX (IX)
C
C Given an x coordinate IX in the metacode system, KMPX(IX) is an x
C coordinate in the plotter system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
KMPX=1+IFIX((2.**MX-1.)*FLOAT(IX)/32767.)
RETURN
END
FUNCTION KMPY (IY)
C
C Given a y coordinate IY in the metacode system, KMPY(IY) is a y
C coordinate in the plotter system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
KMPY=1+IFIX((2.**MY-1.)*FLOAT(IY)/32767.)
RETURN
END
FUNCTION KPMX (IX)
C
C Given an x coordinate IX in the plotter system, KPMX(IX) is an x
C coordinate in the metacode system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
KPMX=IFIX(32767.*FLOAT(IX-1)/(2.**MX-1.))
RETURN
END
FUNCTION KPMY (IY)
C
C Given a y coordinate IY in the plotter system, KPMY(IY) is a y
C coordinate in the metacode system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
KPMY=IFIX(32767.*FLOAT(IY-1)/(2.**MY-1.))
RETURN
END
FUNCTION KUMX (RX)
C
C Given an x coordinate RX in the user system, KUMX(RX) is an x
C coordinate in the metacode system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=1
IF (MI.GE.3) I=2
IF (LL.LE.2) THEN
KUMX=IFIX(((RX-WD(I))/(WD(3-I)-WD(I))*(VP(2)-VP(1))+VP(1))*
+ 32767.)
ELSE
KUMX=IFIX(((ALOG10(RX)-WD(I))/(WD(3-I)-WD(I))*(VP(2)-VP(1))+
+ VP(1))*32767.)
ENDIF
RETURN
END
FUNCTION KUMY (RY)
C
C Given a y coordinate RY in the user system, KUMY(RY) is a y
C coordinate in the metacode system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=3
IF (MI.EQ.2.OR.MI.GE.4) I=4
IF (LL.LE.1.OR.LL.EQ.3) THEN
KUMY=IFIX(((RY-WD(I))/(WD(7-I)-WD(I))*(VP(4)-VP(3))+VP(3))*
+ 32767.)
ELSE
KUMY=IFIX(((ALOG10(RY)-WD(I))/(WD(7-I)-WD(I))*(VP(4)-VP(3))+
+ VP(3))*32767.)
ENDIF
RETURN
END
FUNCTION KUPX (RX)
C
C Given an x coordinate RX in the user system, KUPX(RX) is an x
C coordinate in the plotter system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=1
IF (MI.GE.3) I=2
IF (LL.LE.2) THEN
KUPX=1+IFIX(((RX-WD(I))/(WD(3-I)-WD(I))*(VP(2)-VP(1))+VP(1))*
+ (2.**MX-1.))
ELSE
KUPX=1+IFIX(((ALOG10(RX)-WD(I))/(WD(3-I)-WD(I))*(VP(2)-VP(1))+
+ VP(1))*(2.**MX-1.))
ENDIF
RETURN
END
FUNCTION KUPY (RY)
C
C Given a y coordinate RY in the user system, KUPY(RY) is a y
C coordinate in the plotter system.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
DIMENSION WD(4),VP(4)
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
I=3
IF (MI.EQ.2.OR.MI.GE.4) I=4
IF (LL.LE.1.OR.LL.EQ.3) THEN
KUPY=1+IFIX(((RY-WD(I))/(WD(7-I)-WD(I))*(VP(4)-VP(3))+VP(3))*
+ (2.**MY-1.))
ELSE
KUPY=1+IFIX(((ALOG10(RY)-WD(I))/(WD(7-I)-WD(I))*(VP(4)-VP(3))+
+ VP(3))*(2.**MY-1.))
ENDIF
RETURN
END
SUBROUTINE CLSGKS
C
C IU(6), in IUTLCM, is the current metacode unit number.
C
COMMON /IUTLCM/ IU(100)
C
C Deactivate the metacode workstation, close the workstation, and
C close GKS.
C
CALL GDAWK (IU(6))
CALL GCLWK (IU(6))
CALL GCLKS
C
RETURN
C
END
SUBROUTINE CURVE (PX,PY,NP)
C
DIMENSION PX(NP),PY(NP)
C
C CURVE draws the curve defined by the points (PX(I),PY(I)), for I = 1
C to NP. All coordinates are stated in the user coordinate system.
C
C Define arrays to hold converted point coordinates when it becomes
C necessary to draw the curve piecewise.
C
DIMENSION QX(10),QY(10)
C
C If NP is less than or equal to zero, there's nothing to do.
C
IF (NP.LE.0) RETURN
C
C If NP is exactly equal to 1, just draw a point.
C
IF (NP.EQ.1) THEN
CALL POINT (PX(1),PY(1))
C
C Otherwise, draw the curve.
C
ELSE
C
C Flush the pen-move buffer.
C
CALL PLOTIF (0.,0.,2)
C
C Save the current SET parameters.
C
CALL GETSET (F1,F2,F3,F4,F5,F6,F7,F8,LL)
C
C If the mapping defined by the last SET call was non-reversed and
C linear in both x and y, a single polyline will suffice.
C
IF (F5.LT.F6.AND.F7.LT.F8.AND.LL.EQ.1) THEN
CALL GPL (NP,PX,PY)
C
C Otherwise, piece the line together out of smaller chunks, converting
C the coordinates for each chunk as directed by the last SET call.
C
ELSE
DO 102 IP=1,NP,9
NQ=MIN0(10,NP-IP+1)
IF (NQ.GE.2) THEN
DO 101 IQ=1,NQ
QX(IQ)=CUFX(PX(IP+IQ-1))
QY(IQ)=CUFY(PY(IP+IQ-1))
101 CONTINUE
CALL SET (F1,F2,F3,F4,F1,F2,F3,F4,1)
CALL GPL (NQ,QX,QY)
CALL SET (F1,F2,F3,F4,F5,F6,F7,F8,LL)
END IF
102 CONTINUE
END IF
C
C Update the pen position.
C
CALL FRSTPT (PX(NP),PY(NP))
C
END IF
C
C Done.
C
RETURN
C
END
SUBROUTINE FL2INT (PX,PY,IX,IY)
C
C Given the user coordinates PX and PY of a point, FL2INT returns the
C metacode coordinates IX and IY of that point.
C
C Declare the common block containing the user state variables LL, MI,
C MX, and MY.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
C
C Declare arrays in which to retrieve the variables defining the current
C window and viewport.
C
DIMENSION WD(4),VP(4)
C
C Get the variables defining the current window and viewport.
C
CALL GQCNTN (IE,NT)
CALL GQNT (NT,IE,WD,VP)
C
C Compute IX.
C
I=1
IF (MI.GE.3) I=2
IF (LL.LE.2) THEN
IX=IFIX(((PX-WD(I))/(WD(3-I)-WD(I))*(VP(2)-VP(1))+VP(1))*32767.)
ELSE
IX=IFIX(((ALOG10(PX)-WD(I))/(WD(3-I)-WD(I))*
+ (VP(2)-VP(1))+VP(1))*32767.)
ENDIF
C
C Compute IY.
C
I=3
IF (MI.EQ.2.OR.MI.GE.4) I=4
IF (LL.LE.1.OR.LL.EQ.3) THEN
IY=IFIX(((PY-WD(I))/(WD(7-I)-WD(I))*(VP(4)-VP(3))+VP(3))*32767.)
ELSE
IY=IFIX(((ALOG10(PY)-WD(I))/(WD(7-I)-WD(I))*
+ (VP(4)-VP(3))+VP(3))*32767.)
ENDIF
C
C Done.
C
RETURN
C
END
C
C +NOAO - name conflict
C
C SUBROUTINE FLUSH
subroutine mcflsh
C
C - NOAO
C
C FLUSH currently does nothing except flush the pen-move buffer.
C
CALL PLOTIF (0.,0.,2)
C
C Done.
C
RETURN
C
END
SUBROUTINE FRAME
C
C FRAME is intended to advance to a new frame. The GKS version clears
C all open workstations.
C
C First, flush the pen-move buffer.
C
CALL PLOTIF (0.,0.,2)
C
C +NOAO - Initialize utilbd 'first' flag for next plot
call initut
C
C - NOAO
C Get the number of open workstations. If there are none, we're done.
C
CALL GQOPWK (0,IE,NO,ID)
IF (NO.EQ.0) RETURN
C
C Otherwise, clear the open workstations.
C
DO 101 I=1,NO
CALL GQOPWK (I,IE,NO,ID)
CALL GCLRWK (ID,1)
101 CONTINUE
C
C Done.
C
RETURN
C
END
SUBROUTINE FRSTPT (PX,PY)
C
C Given the user coordinates PX and PY of a point, FRSTPT generates a
C pen-up move to that point.
C
CALL PLOTIF (CUFX(PX),CUFY(PY),0)
C
C Done.
C
RETURN
C
END
SUBROUTINE GETSET (VL,VR,VB,VT,WL,WR,WB,WT,LF)
C
C GETSET returns to its caller the current values of the parameters
C defining the mapping from the user system to the fractional system
C (in GKS terminology, the mapping from world coordinates to normalized
C device coordinates).
C
C VL, VR, VB, and VT define the viewport (in the fractional system), WL,
C WR, WB, and WT the window (in the user system), and LF the nature of
C the mapping, according to the following table:
C
C 1 - x linear, y linear
C 2 - x linear, y logarithmic
C 3 - x logarithmic, y linear
C 4 - x logarithmic, y logarithmic
C
C Declare the common block containing the linear-log and mirror-imaging
C flags.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
C
C Define variables to receive the GKS viewport and window.
C
DIMENSION VP(4),WD(4)
C
C Retrieve the number of the current GKS normalization transformation.
C
CALL GQCNTN (IE,NT)
C
C Retrieve the definition of that normalization transformation.
C
CALL GQNT (NT,IE,WD,VP)
C
C Pass the viewport definition to the caller.
C
VL=VP(1)
VR=VP(2)
VB=VP(3)
VT=VP(4)
C
C Pass the linear/log flag and a (possibly modified) window definition
C to the caller.
C
LF=LL
C
IF (LL.EQ.1.OR.LL.EQ.2) THEN
WL=WD(1)
WR=WD(2)
ELSE
WL=10.**WD(1)
WR=10.**WD(2)
END IF
C
IF (MI.GE.3) THEN
WW=WL
WL=WR
WR=WW
END IF
C
IF (LL.EQ.1.OR.LL.EQ.3) THEN
WB=WD(3)
WT=WD(4)
ELSE
WB=10.**WD(3)
WT=10.**WD(4)
END IF
C
IF (MI.EQ.2.OR.MI.GE.4) THEN
WW=WB
WB=WT
WT=WW
END IF
C
RETURN
C
END
SUBROUTINE GETSI (IX,IY)
C
C Return to the user the parameters which determine the assumed size of
C the target plotter and therefore determine how user coordinates are
C to be mapped into plotter coordinates.
C
C Declare the common block containing the scaling information.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
C
C Set the user variables.
IX=MX
IY=MY
C
RETURN
C
END
SUBROUTINE GETUSV (VN,IV)
CHARACTER*(*) VN
C
C This subroutine retrieves the current values of the utility state
C variables. VN is the character name of the variable and IV is
C its value.
C
C The labelled common block IUTLCM contains all of the utility state
C variables.
C
COMMON /IUTLCM/IU(100)
C
C Check for the linear-log scaling variable.
C
IF (VN(1:2).EQ.'LS') THEN
IV=IU(1)
C
C Check for the variable specifying the mirror-imaging of the axes.
C
ELSE IF (VN(1:2).EQ.'MI') THEN
IV=IU(2)
C
C Check for the variable specifying the resolution of the plotter in x.
C
ELSE IF (VN(1:2).EQ.'XF') THEN
IV=IU(3)
C
C Check for the variable specifying the resolution of the plotter in x.
C
ELSE IF (VN(1:2).EQ.'YF') THEN
IV=IU(4)
C
C Check for the variable specifying the size of the pen-move buffer.
C
ELSE IF (VN(1:2).EQ.'PB') THEN
IV=IU(5)
C
C Check for the variable specifying the metacode unit.
C
ELSE IF (VN(1:2).EQ.'MU') THEN
IV=IU(6)
C
C Check for one of the variables specifying color and intensity.
C
ELSE IF (VN(1:2).EQ.'IR') THEN
IV=IU(7)
C
ELSE IF (VN(1:2).EQ.'IG') THEN
IV=IU(8)
C
ELSE IF (VN(1:2).EQ.'IB') THEN
IV=IU(9)
C
ELSE IF (VN(1:2).EQ.'IN') THEN
IV=IU(10)
C
C Check for the variable specifying the current color index.
C
ELSE IF (VN(1:2).EQ.'II') THEN
IV=IU(11)
C
C Check for the variable specifying the maximum color index.
C
ELSE IF (VN(1:2).EQ.'IM') THEN
IV=IU(12)
C
C Check for the variable specifying the line width scale factor.
C
ELSE IF (VN(1:2).EQ.'LW') THEN
IV=IU(13)
C
C Check for the variable specifying the marker size scale factor.
C
ELSE IF (VN(1:2).EQ.'MS') THEN
IV=IU(14)
C
C Otherwise, the variable name is unknown.
C
ELSE
CALL SETER ('GETUSV - UNKNOWN VARIABLE NAME IN CALL',1,2)
C
ENDIF
C
RETURN
C
END
SUBROUTINE LINE (X1,Y1,X2,Y2)
C
C Draw a line connecting the point (X1,Y1) to the point (X2,Y2), in the
C user coordinate system.
C
CALL PLOTIF (CUFX(X1),CUFY(Y1),0)
CALL PLOTIF (CUFX(X2),CUFY(Y2),1)
RETURN
END
SUBROUTINE MXMY (IX,IY)
C
C Return to the user the coordinates of the current pen position, in the
C plotter coordinate system.
C
C In the common block PLTCM are recorded the coordinates of the last
C pen position, in the metacode coordinate system.
C
COMMON /PLTCM/ JX,JY
C
C Declare the common block containing the user state variables LL, MI,
C MX, and MY.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
C
C Return to the user the plotter-system equivalents of the values in
C the metacode system.
C
IX=1+IFIX((2.**MX-1.)*FLOAT(JX)/32767.)
IY=1+IFIX((2.**MY-1.)*FLOAT(JY)/32767.)
C
C Done.
C
RETURN
C
END
C
C + NOAO - Following subroutine
C SUBROUTINE OPNGKS
C
C IU(6), in IUTLCM, is the current metacode unit number.
C
C COMMON /IUTLCM/ IU(100)
C
C Force all required BLOCKDATA's to load.
C
C EXTERNAL GKSBD,G01BKD,UERRBD,UTILBD
C
C GKS buffer size (a dummy for NCAR GKS.)
C
C DATA ISZ /0/
C
C Open GKS, define a workstation, and activate the workstation.
C
C CALL GOPKS (6,ISZ)
C CALL GOPWK (IU(6),2,1)
C CALL GACWK (IU(6))
C
C RETURN
C
C + NOAO
C
C END
SUBROUTINE PLOTIF (FX,FY,IP)
C
C Move the pen to the point (FX,FY), in the fractional cooordinate
C system. If IP is zero, do a pen-up move. If IP is one, do a pen-down
C move. If IP is two, flush the buffer.
C
C The variable IU(5), in the labelled common block IUTLCM, specifies
C the size of the pen-move buffer (between 2 and 50).
C
COMMON /IUTLCM/ IU(100)
C
C The common block VCTSEQ contains variables implementing the buffering
C of pen moves.
C
COMMON /VCTSEQ/ NQ,QX(50),QY(50),NF,IF(25)
C
C In the common block PLTCM are recorded the coordinates of the last
C pen position, in the metacode coordinate system, for MXMY.
C
COMMON /PLTCM/ JX,JY
C
C Force loading of the block data routine which initializes the contents
C of the common blocks.
C
C EXTERNAL UTILBD
C
C VP and WD hold viewport and window parameters obtained, when needed,
C from GKS.
C
DIMENSION VP(4),WD(4)
C
C + NOAO - block data utilbd has been rewritten as a run time initialization
C
call utilbd
C
C - NOAO
C Check for out-of-range values of the pen parameter.
C
IF (IP.LT.0.OR.IP.GT.2) THEN
CALL SETER ('PLOTIF - ILLEGAL VALUE FOR IPEN',1,2)
END IF
C
C If a buffer flush is requested, jump.
C
IF (IP.EQ.2) GO TO 101
C
C Limit the given coordinates to the legal fractional range.
C
GX=AMAX1(0.,AMIN1(1.,FX))
GY=AMAX1(0.,AMIN1(1.,FY))
C
C Set JX and JY for a possible call to MXMY.
C
JX=KFMX(GX)
JY=KFMY(GY)
C
C If the current move is a pen-down move, or if the last one was, bump
C the pointer into the coordinate arrays and, if the current move is
C a pen-up move, make a new entry in the array IF, which records the
C positions of the pen-up moves. Note that we never get two pen-up
C moves in a row, which means that IF need be dimensioned only half as
C large as QX and QY.
C
IF (IP.NE.0.OR.IF(NF).NE.NQ) THEN
NQ=NQ+1
IF (IP.EQ.0) THEN
NF=NF+1
IF(NF)=NQ
END IF
END IF
C
C Save the coordinates of the point, in the fractional coordinate
C system.
C
QX(NQ)=GX
QY(NQ)=GY
C
C If the point-coordinate buffer is full, dump the buffers; otherwise,
C return.
C
IF (NQ.LT.IU(5)) RETURN
C
C Dump the buffers. If NQ is one, there's nothing to dump. All that's
C there is a single pen-up move.
C
101 IF (NQ.LE.1) RETURN
C
C Get NT, the number of the current transformation, and, if it is not
C zero, modify the current transformation so that we can use fractional
C coordinates (normalized device coordinates, in GKS terms).
C
CALL GQCNTN (IE,NT)
IF (NT.NE.0) THEN
CALL GQNT (NT,IE,WD,VP)
CALL GSWN (NT,VP(1),VP(2),VP(3),VP(4))
END IF
C
C Dump out a series of polylines, each one defined by a pen-up move and
C a series of pen-down moves.
C
DO 102 I=1,NF-1
CALL GPL (IF(I+1)-IF(I),QX(IF(I)),QY(IF(I)))
102 CONTINUE
IF (IF(NF).NE.NQ) CALL GPL (NQ-IF(NF)+1,QX(IF(I)),QY(IF(I)))
C
C Put the current transformation back the way it was.
C
IF (NT.NE.0) THEN
CALL GSWN (NT,WD(1),WD(2),WD(3),WD(4))
END IF
C
C Move the last pen position to the beginning of the buffer and pretend
C there was a pen-up move to that position.
C
QX(1)=QX(NQ)
QY(1)=QY(NQ)
NQ=1
IF(1)=1
NF=1
C
C Done.
C
RETURN
C
END
SUBROUTINE PLOTIT (IX,IY,IP)
C
C Move the pen to the point (IX,IY), in the metacode coordinate system.
C If IP is zero, do a pen-up move. If IP is one, do a pen-down move.
C If IP is two, flush the buffer. (For the sake of efficiency, the
C moves are buffered; "CALL PLOTIT (0,0,0)" will also flush the buffer.)
C
C The variable IU(5), in the labelled common block IUTLCM, specifies
C the size of the pen-move buffer (between 2 and 50).
C
COMMON /IUTLCM/ IU(100)
C
C The common block VCTSEQ contains variables implementing the buffering
C of pen moves.
C
COMMON /VCTSEQ/ NQ,QX(50),QY(50),NF,IF(25)
C
C In the common block PLTCM are recorded the coordinates of the last
C pen position, in the metacode coordinate system, for MXMY.
C
COMMON /PLTCM/ JX,JY
C
C Force loading of the block data routine which initializes the contents
C of the common blocks.
C
C EXTERNAL UTILBD
C
C VP and WD hold viewport and window parameters obtained, when needed,
C from GKS.
C
DIMENSION VP(4),WD(4)
C
C + NOAO - Blockdata utilbd has been rewritten as a run time initialization
C
call utilbd
C
C - NOAO
C Check for out-of-range values of the pen parameter.
C
IF (IP.LT.0.OR.IP.GT.2) THEN
CALL SETER ('PLOTIT - ILLEGAL VALUE FOR IPEN',1,2)
END IF
C
C If a buffer flush is requested, jump.
C
IF (IP.EQ.2) GO TO 101
C
C Limit the given coordinates to the legal metacode range.
C
JX=MAX0(0,MIN0(32767,IX))
JY=MAX0(0,MIN0(32767,IY))
C
C If the current move is a pen-down move, or if the last one was, bump
C the pointer into the coordinate arrays and, if the current move is
C a pen-up move, make a new entry in the array IF, which records the
C positions of the pen-up moves. Note that we never get two pen-up
C moves in a row, which means that IF need be dimensioned only half as
C large as QX and QY.
C
IF (IP.NE.0.OR.IF(NF).NE.NQ) THEN
NQ=NQ+1
IF (IP.EQ.0) THEN
NF=NF+1
IF(NF)=NQ
END IF
END IF
C
C Save the coordinates of the point, in the fractional coordinate
C system.
C
QX(NQ)=FLOAT(JX)/32767.
QY(NQ)=FLOAT(JY)/32767.
C
C If all three arguments were zero, or if the point-coordinate buffer
C is full, dump the buffers; otherwise, return.
C
IF (IX.EQ.0.AND.IY.EQ.0.AND.IP.EQ.0) GO TO 101
IF (NQ.LT.IU(5)) RETURN
C
C Dump the buffers. If NQ is one, there's nothing to dump. All that's
C there is a single pen-up move.
C
101 IF (NQ.LE.1) RETURN
C
C Get NT, the number of the current transformation, and, if it is not
C zero, modify the current transformation so that we can use fractional
C coordinates (normalized device coordinates, in GKS terms).
C
CALL GQCNTN (IE,NT)
IF (NT.NE.0) THEN
CALL GQNT (NT,IE,WD,VP)
CALL GSWN (NT,VP(1),VP(2),VP(3),VP(4))
END IF
C
C Dump out a series of polylines, each one defined by a pen-up move and
C a series of pen-down moves.
C
DO 102 I=1,NF-1
CALL GPL (IF(I+1)-IF(I),QX(IF(I)),QY(IF(I)))
102 CONTINUE
IF (IF(NF).NE.NQ) CALL GPL (NQ-IF(NF)+1,QX(IF(I)),QY(IF(I)))
C
C Put the current transformation back the way it was.
C
IF (NT.NE.0) THEN
CALL GSWN (NT,WD(1),WD(2),WD(3),WD(4))
END IF
C
C Move the last pen position to the beginning of the buffer and pretend
C there was a pen-up move to that position.
C
QX(1)=QX(NQ)
QY(1)=QY(NQ)
NQ=1
IF(1)=1
NF=1
C
C Done.
C
RETURN
C
END
SUBROUTINE POINT (PX,PY)
C
C Draws a point at (PX,PY), defined in the user coordinate system.
C
CALL PLOTIF (CUFX(PX),CUFY(PY),0)
CALL PLOTIF (CUFX(PX),CUFY(PY),1)
RETURN
END
SUBROUTINE POINTS (PX,PY,NP,IC,IL)
DIMENSION PX(NP),PY(NP)
C
C Marks the points at positions in the user coordinate system defined
C by ((PX(I),PY(I)),I=1,NP). If IC is zero, each point is marked with
C a simple point. If IC is positive, each point is marked with the
C single character defined by the FORTRAN-77 function CHAR(IC). If IC
C is negative, each point is marked with a GKS polymarker of type -IC.
C If IL is non-zero, a curve is also drawn, connecting the points.
C
C Define arrays to hold converted point coordinates when it becomes
C necessary to mark the points a few at a time.
C
DIMENSION QX(10),QY(10)
C
C Define an array to hold the aspect source flags which may need to be
C retrieved from GKS.
C
DIMENSION LA(13)
CHARACTER*1 CHRTMP
C
C If the number of points is zero or negative, there's nothing to do.
C
IF (NP.LE.0) RETURN
C
C Otherwise, flush the pen-move buffer.
C
CALL PLOTIF (0.,0.,2)
C
C Retrieve the parameters from the last SET call.
C
CALL GETSET (F1,F2,F3,F4,F5,F6,F7,F8,LL)
C
C If a linear-linear, non-mirror-imaged, mapping is being done and the
C GKS polymarkers can be used, all the points can be marked with a
C single polymarker call and joined, if requested, by a single polyline
C call.
C
IF (F5.LT.F6.AND.F7.LT.F8.AND.LL.EQ.1.AND.IC.LE.0) THEN
CALL GQASF (IE,LA)
IF (LA(4).EQ.0) THEN
CALL GQPMI (IE,IN)
CALL GSPMI (MAX0(-IC,1))
CALL GPM (NP,PX,PY)
CALL GSPMI (IN)
ELSE
CALL GQMK (IE,IN)
CALL GSMK (MAX0(-IC,1))
CALL GPM (NP,PX,PY)
CALL GSMK (IN)
END IF
IF (IL.NE.0.AND.NP.GE.2) CALL GPL (NP,PX,PY)
C
C Otherwise, things get complicated. We have to do batches of nine
C points at a time. (Actually, we convert ten coordinates at a time,
C so that the curve joining the points, if any, won't have gaps in it.)
C
ELSE
C
C Initially, we have to reset either the polymarker index or the text
C alignment, depending on how we're marking the points.
C
IF (IC.LE.0) THEN
CALL GQASF (IE,LA)
IF (LA(4).EQ.0) THEN
CALL GQPMI (IE,IN)
CALL GSPMI (MAX0(-IC,1))
ELSE
CALL GQMK (IE,IN)
CALL GSMK (MAX0(-IC,1))
END IF
ELSE
CALL GQTXAL (IE,IH,IV)
CALL GSTXAL (2,3)
END IF
C
C Loop through the points by nines.
C
DO 104 IP=1,NP,9
C
C Fill the little point coordinate arrays with up to ten values,
C converting them from the user system to the fractional system.
C
NQ=MIN0(10,NP-IP+1)
MQ=MIN0(9,NQ)
DO 102 IQ=1,NQ
QX(IQ)=CUFX(PX(IP+IQ-1))
QY(IQ)=CUFY(PY(IP+IQ-1))
102 CONTINUE
C
C Change the SET call to allow the use of fractional coordinates.
C
CALL SET (F1,F2,F3,F4,F1,F2,F3,F4,1)
C
C Crank out either a polymarker or a set of characters.
C
IF (IC.LE.0) THEN
CALL GPM (MQ,QX,QY)
ELSE
DO 103 IQ=1,MQ
CHRTMP = CHAR(IC)
CALL GTX (QX(IQ),QY(IQ),CHRTMP)
103 CONTINUE
END IF
IF (IL.NE.0.AND.NQ.GE.2) CALL GPL (NQ,QX,QY)
C
C Put the SET parameters back the way they were.
C
CALL SET (F1,F2,F3,F4,F5,F6,F7,F8,LL)
C
104 CONTINUE
C
C Finally, we put either the polymarker index or the text alignment
C back the way it was.
C
IF (IC.LE.0) THEN
IF (LA(4).EQ.0) THEN
CALL GSPMI (IN)
ELSE
CALL GSMK (IN)
END IF
ELSE
CALL GSTXAL (IH,IV)
END IF
C
END IF
C
C Update the pen position.
C
CALL FRSTPT (PX(NP),PY(NP))
C
C Done.
C
RETURN
C
END
SUBROUTINE PWRIT (PX,PY,CH,NC,IS,IO,IC)
CHARACTER*(*) CH
C
C PWRIT is called to draw a character string in a specified position.
C It is just like WTSTR, but has one extra argument. NC is the number
C of characters to be written from the string CH.
C
CALL WTSTR (PX,PY,CH(1:NC),IS,IO,IC)
C
C Done.
C
RETURN
C
END
SUBROUTINE SET (VL,VR,VB,VT,WL,WR,WB,WT,LF)
C
C SET allows the user to change the current values of the parameters
C defining the mapping from the user system to the fractional system
C (in GKS terminology, the mapping from world coordinates to normalized
C device coordinates).
C
C VL, VR, VB, and VT define the viewport (in the fractional system), WL,
C WR, WB, and WT the window (in the user system), and LF the nature of
C the mapping, according to the following table:
C
C 1 - x linear, y linear
C 2 - x linear, y logarithmic
C 3 - x logarithmic, y linear
C 4 - x logarithmic, y logarithmic
C
C Declare the common block containing the linear-log and mirror-imaging
C flags.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
C
C Flush the pen-move buffer.
C
CALL PLOTIF (0.,0.,2)
C
C Set the GKS viewport for transformation 1.
C
CALL GSVP (1,VL,VR,VB,VT)
C
C Set the utility state variable controlling linear-log mapping.
C
LL=MAX0(1,MIN0(4,LF))
C
C Set the GKS window for transformation 1.
C
IF (WL.LT.WR) THEN
MI=1
QL=WL
QR=WR
ELSE
MI=3
QL=WR
QR=WL
END IF
C
IF (WB.LT.WT) THEN
QB=WB
QT=WT
ELSE
MI=MI+1
QB=WT
QT=WB
END IF
C
IF (LL.EQ.1) THEN
CALL GSWN (1,QL,QR,QB,QT)
ELSE IF (LL.EQ.2) THEN
CALL GSWN (1,QL,QR,ALOG10(QB),ALOG10(QT))
ELSE IF (LL.EQ.3) THEN
CALL GSWN (1,ALOG10(QL),ALOG10(QR),QB,QT)
ELSE
CALL GSWN (1,ALOG10(QL),ALOG10(QR),ALOG10(QB),ALOG10(QT))
END IF
C
C Select transformation 1 as the current one.
C
CALL GSELNT (1)
C
RETURN
C
END
SUBROUTINE SETI (IX,IY)
C
C Allows the user to set the parameters which determine the assumed size
C of the target plotter and therefore determine how user coordinates are
C to be mapped into plotter coordinates.
C
C Declare the common block containing the scaling information.
C
COMMON /IUTLCM/ LL,MI,MX,MY,IU(96)
C
C Transfer the user's values into the common block.
C
MX=MAX0(1,MIN0(15,IX))
MY=MAX0(1,MIN0(15,IY))
C
RETURN
C
END
SUBROUTINE SETUSV (VN,IV)
CHARACTER*(*) VN
C
C This subroutine sets the values of various utility state variables.
C VN is the name of the variable and IV is its value.
C
C The labelled common block IUTLCM contains all of the utility state
C variables.
C
COMMON /IUTLCM/ IU(100)
C
C Define an array in which to get the GKS aspect source flags.
C
DIMENSION LF(13)
C
C Check for the linear-log scaling variable, which can take on these
C values:
C
C 1 = X linear, Y linear
C 2 = X linear, Y log
C 3 = X log , Y linear
C 4 = X log , Y log
C
IF (VN(1:2).EQ.'LS') THEN
IF (IV.LT.1.OR.IV.GT.4) THEN
CALL SETER ('SETUSV - LOG SCALE VALUE OUT OF RANGE',2,2)
END IF
IU(1)=IV
C
C Check for the mirror-imaging variable, which can take on these
C values:
C
C 1 = X normal , Y normal
C 2 = X normal , Y reversed
C 3 = X reversed, Y normal
C 4 = X reversed, Y reversed
C
ELSE IF (VN(1:2).EQ.'MI') THEN
IF (IV.LT.1.OR.IV.GT.4) THEN
CALL SETER ('SETUSV - MIRROR-IMAGING VALUE OUT OF RANGE',3,2)
END IF
IU(2)=IV
C
C Check for the scale factor setting the resolution of the plotter in
C the x direction.
C
ELSE IF (VN(1:2).EQ.'XF') THEN
IF (IV.LT.1.OR.IV.GT.15) THEN
CALL SETER ('SETUSV - X RESOLUTION OUT OF RANGE',4,2)
END IF
IU(3)=IV
C
C Check for the scale factor setting the resolution of the plotter in
C the y direction.
C
ELSE IF (VN(1:2).EQ.'YF') THEN
IF (IV.LT.1.OR.IV.GT.15) THEN
CALL SETER ('SETUSV - Y RESOLUTION OUT OF RANGE',5,2)
END IF
IU(4)=IV
C
C Check for the variable specifying the size of the pen-move buffer.
C
ELSE IF (VN(1:2).EQ.'PB') THEN
IF (IV.LT.2.OR.IV.GT.50) THEN
CALL SETER ('SETUSV - PEN-MOVE BUFFER SIZE OUT OF RANGE',6,2)
END IF
CALL PLOTIF (0.,0.,2)
IU(5)=IV
C
C Check for a metacode unit number.
C
ELSE IF (VN(1:2).EQ.'MU') THEN
IF (IV.LE.0) THEN
CALL SETER ('SETUSV - METACODE UNIT NUMBER ILLEGAL',7,2)
END IF
C
C For the moment (1/11/85), we have to deactivate and close the old
C workstation and open and activate a new one. This does allow the
C user to break up his metacode output. It does not necessarily allow
C for the resumption of output to a previously-written metacode file.
C
CALL GDAWK (IU(6))
CALL GCLWK (IU(6))
IU(6)=IV
CALL GOPWK (IU(6),2,1)
CALL GACWK (IU(6))
C
C If, in the future, it becomes possible to have more than one metacode
C workstation open at once, the following code can be used instead.
C
C CALL GDAWK (IU(6))
C IU(6)=IV
C CALL GQOPWK (0,IE,NO,ID)
C IF (NO.NE.0) THEN
C DO 101 I=1,NO
C CALL GQOPWK (I,IE,NO,ID)
C IF (ID.EQ.IU(6)) GO TO 102
C 101 CONTINUE
C END IF
C CALL GOPWK (IU(6),2,1)
C 102 CALL GAWK (IU(6))
C
C Check for one of the variables setting color and intensity.
C
ELSE IF (VN(1:2).EQ.'IR') THEN
IF (IV.LT.0) THEN
CALL SETER ('SETUSV - ILLEGAL VALUE OF RED INTENSITY',8,2)
END IF
IU(7)=IV
C
ELSE IF (VN(1:2).EQ.'IG') THEN
IF (IV.LT.0) THEN
CALL SETER ('SETUSV - ILLEGAL VALUE OF GREEN INTENSITY',9,2)
END IF
IU(8)=IV
C
ELSE IF (VN(1:2).EQ.'IB') THEN
IF (IV.LT.0) THEN
CALL SETER ('SETUSV - ILLEGAL VALUE OF BLUE INTENSITY',10,2)
END IF
IU(9)=IV
C
ELSE IF (VN(1:2).EQ.'IN') THEN
IF (IV.LT.0.OR.IV.GT.10000) THEN
CALL SETER ('SETUSV - ILLEGAL VALUE OF INTENSITY',11,2)
END IF
IU(10)=IV
C
C Assign the intensity-controlling variables to local variables with
C simple, meaningful names.
C
IR=IU(7)
IG=IU(8)
IB=IU(9)
IN=IU(10)
II=IU(11)
IM=IU(12)
C
C Compute the floating-point red, green, and blue intensities.
C
FR=FLOAT(IR)/FLOAT(MAX0(IR,IG,IB,1))*FLOAT(IN)/10000.
FG=FLOAT(IG)/FLOAT(MAX0(IR,IG,IB,1))*FLOAT(IN)/10000.
FB=FLOAT(IB)/FLOAT(MAX0(IR,IG,IB,1))*FLOAT(IN)/10000.
C
C Dump the pen-move buffer before changing anything.
C
CALL PLOTIF (0.,0.,2)
C
C Set the aspect source flags for all the color indices to "individual".
C
CALL GQASF (IE,LF)
LF( 3)=1
LF( 6)=1
LF(10)=1
LF(13)=1
CALL GSASF (LF)
C
C Pick a new color index and use it for polylines, polymarkers, text,
C and areas.
C
II=MOD(II,IM)+1
IU(11)=II
CALL GSPLCI (II)
CALL GSPMCI (II)
CALL GSTXCI (II)
CALL GSFACI (II)
C
C Now, redefine the color for that color index on each open workstation.
C
CALL GQOPWK (0,IE,NO,ID)
C
DO 103 I=1,NO
CALL GQOPWK (I,IE,NO,ID)
CALL GSCR (ID,II,FR,FG,FB)
103 CONTINUE
C
C Check for variable resetting the color index.
C
ELSE IF (VN(1:2).EQ.'II') THEN
IF (IV.LT.1.OR.IV.GT.IU(12)) THEN
CALL SETER ('SETUSV - ILLEGAL COLOR INDEX',12,2)
END IF
IU(11)=IV
C
CALL PLOTIF (0.,0.,2)
C
CALL GQASF (IE,LF)
LF( 3)=1
LF( 6)=1
LF(10)=1
LF(13)=1
CALL GSASF (LF)
C
CALL GSPLCI (IV)
CALL GSPMCI (IV)
CALL GSTXCI (IV)
CALL GSFACI (IV)
C
C Check for the variable limiting the values of color index used.
C
ELSE IF (VN(1:2).EQ.'IM') THEN
IF (IV.LT.1) THEN
CALL SETER ('SETUSV - ILLEGAL MAXIMUM COLOR INDEX',13,2)
END IF
IU(12)=IV
C
C Check for the variable setting the current line width scale factor.
C
ELSE IF (VN(1:2).EQ.'LW') THEN
IF (IV.LT.0) THEN
CALL SETER ('SETUSV - ILLEGAL LINE WIDTH SCALE FACTOR',14,2)
END IF
IU(13)=IV
C
C Dump the pen-move buffer before changing anything.
C
CALL PLOTIF (0.,0.,2)
C
C Set the aspect source flag for linewidth scale factor to "individual".
C
CALL GQASF (IE,LF)
LF(2)=1
CALL GSASF (LF)
C
C Redefine the line width scale factor.
C
CALL GSLWSC (FLOAT(IV)/1000.)
C
C Check for the variable setting the current marker size scale factor.
C
ELSE IF (VN(1:2).EQ.'MS') THEN
IF (IV.LT.0) THEN
CALL SETER ('SETUSV - ILLEGAL MARKER SIZE SCALE FACTOR',15,2)
END IF
IU(14)=IV
C
C Set aspect source flag for marker size scale factor to "individual".
C
CALL GQASF (IE,LF)
LF(5)=1
CALL GSASF (LF)
C
C Redefine the marker size scale factor.
C
CALL GSMKSC (FLOAT(IV)/1000.)
C
C Otherwise, the variable name is unknown.
C
ELSE
CALL SETER ('SETUSV - UNKNOWN VARIABLE NAME IN CALL',1,2)
C
ENDIF
RETURN
END
SUBROUTINE VECTOR (PX,PY)
C
C Draw a vector (line segment) from the current pen position to the new
C pen position (PX,PY), in the user coordinate system, and then make
C (PX,PY) the current pen position.
C
CALL PLOTIF (CUFX(PX),CUFY(PY),1)
RETURN
END
SUBROUTINE WTSTR (PX,PY,CH,IS,IO,IC)
C
C WTSTR is called to draw a character string in a specified position.
C
C PX and PY specify, in user coordinates, the position of a point
C relative to which a character string is to be positioned.
C
C CH is the character string to be written.
C
C IS is the desired size of the characters to be used, stated as a
C character width in the plotter coordinate system. The values 0, 1,
C 2, and 3 mean 8, 12, 16, and 24, respectively.
C
C IO is the desired orientation angle, in degrees counterclockwise from
C a horizontal vector pointing to the right.
C
C IC specifies the desired type of centering. A negative value puts
C (PX,PY) in the center of the left end of the character string, a zero
C puts (PX,PY) in the center of the whole string, and a positive value
C puts (PX,PY) in the center of the right end of the character string.
C
CHARACTER*(*) CH
C
C Define arrays in which to save the current viewport and window.
C
DIMENSION VP(4),WD(4)
C
C Flush the pen-move buffer.
C
CALL PLOTIF (0.,0.,2)
C
C Compute the coordinates of (PX,PY) in the fractional coordinate
C system (normalized device coordinates).
C
XN=CUFX(PX)
YN=CUFY(PY)
C
C Save the current window and, if necessary, redefine it so that we can
C use normalized device coordinates.
C
CALL GQCNTN (IE,NT)
IF (NT.NE.0) THEN
CALL GQNT (NT,IE,WD,VP)
CALL GSWN (NT,VP(1),VP(2),VP(3),VP(4))
END IF
C
C Save current character height, text path, character up vector, and
C text alignment.
C
CALL GQCHH (IE,OS)
CALL GQTXP (IE,IP)
CALL GQCHUP (IE,UX,UY)
CALL GQTXAL (IE,IX,IY)
C
C Define the character height. (The final scale factor is derived from
C the default font.)
C
CALL GETUSV ('YF',MY)
YS=FLOAT(2**MY)
IF (IS.GE.0.AND.IS.LE.3) THEN
CS=FLOAT(8+4*IS+4*(IS/3))/YS
ELSE
CS=AMIN1(FLOAT(IS),YS)/YS
ENDIF
C
CS=CS*25.5/27.
C
C + NOAO - make character size readable with IRAF font
cs = cs * 2.0
C
C - NOAO
CALL GSCHH(CS)
C
C Define the text path.
C
CALL GSTXP (0)
C
C Define the character up vector.
C
JO=MOD(IO,360)
IF (JO.EQ.0) THEN
CALL GSCHUP (0.,1.)
ELSE IF (JO.EQ.90) THEN
CALL GSCHUP (-1.,0.)
ELSE IF (JO.EQ.180) THEN
CALL GSCHUP (0.,-1.)
ELSE IF (JO.EQ.270) THEN
CALL GSCHUP (1.,0.)
ELSE IF (JO.GT.0.AND.JO.LT.180) THEN
CALL GSCHUP (-1.,1./TAN(FLOAT(JO)*3.1415926/180.))
ELSE
CALL GSCHUP (1.,-1./TAN(FLOAT(JO)*3.1415926/180.))
ENDIF
C
C Define the text alignment.
C
CALL GSTXAL (IC+2,3)
C
C Plot the characters.
C
CALL GTX (XN,YN,CH)
C
C Restore the original text attributes.
C
CALL GSCHH (OS)
CALL GSTXP (IP)
CALL GSCHUP (UX,UY)
CALL GSTXAL (IX,IY)
C
C Restore the window definition.
C
IF (NT.NE.0) THEN
CALL GSWN (NT,WD(1),WD(2),WD(3),WD(4))
END IF
C
C Update the pen position.
C
CALL FRSTPT (PX,PY)
C
C Done.
C
RETURN
C
END
c + NOAO - blockdata utilbd changed to run time initialization
subroutine utilbd
c BLOCKDATA UTILBD
C
logical first
C The common block IUTLCM contains integer utility variables which are
C user-settable by the routine SETUSV and user-retrievable by the
C routine GETUSV.
C
COMMON /IUTLCM/ IU(100)
C
C The common block VCTSEQ contains variables realizing the buffering
C scheme used by PLOTIT/F for pen moves. The dimension of QX and QY must
C be an even number greater than or equal to the value of IU(5). The
C dimension of IF must be half that of QX and QY.
C
COMMON /VCTSEQ/ NQ,QX(50),QY(50),NF,IF(25)
C
C In the common block PLTCM are recorded the coordinates of the last
C point to which a pen move was requested by a call to PLOTIT/F.
C
COMMON /PLTCM/ JX,JY
C
C IU(1) contains the log scaling parameter, which may take on the
C following possible values:
C
C 1 = linear-linear
C 2 = log-linear
C 3 = linear-log
C 4 = log-log
C
c DATA IU(1) / 1 /
IU(1) = 1
C
C IU(2) specifies the mirror-imaging of the x and y axes, as follows:
C
C 1 = x normal, y normal
C 2 = x normal, y reversed
C 3 = x reversed, y normal
C 4 = x reversed, y reversed
C
c +NOAO - logical parameter first inserted to avoid clobbering initialization
data first /.true./
if (.not. first) return
first = .false.
c -NOAO
c DATA IU(2) / 1 /
IU(2) = 1
C
C IU(3) specifies the assumed resolution of the plotter in the x
C direction. Plotter x coordinates are assumed to lie between 1 and
C 2**IU(3), inclusive.
C
c DATA IU(3) / 10 /
IU(3) = 10
C
C IU(4) specifies the assumed resolution of the plotter in the y
C direction. Plotter y coordinates are assumed to lie between 1 and
C 2**IU(4), inclusive.
C
c DATA IU(4) / 10 /
IU(4) = 10
C
C IU(5) specifies the size of the buffers used by PLOTIT/F. Its value
C must be greater than or equal to 2 and not greater than the dimension
C of the variables QX and QY. Using the value 2 effectively turns off
C the buffering.
C
c DATA IU(5) / 50 /
IU(5) = 50
C
C IU(6) specifies the current metacode unit, which is machine-dependent.
C At NCAR, the value "1" currently (1/11/85) causes metacode to be
C written on the file "GMETA". Eventually, it will cause output to be
C written on unit number 1. At that point, the value, on the Cray at
C least, should be changed to "4H$PLT", so that output will come out on
C the old familiar dataset.
C
c DATA IU(6) / 1 /
IU(6) = 1
C
C IU(7), IU(8), IU(9), and IU(10) specify color and intensity, in the
C following way (letting IR=IU(7), IG=IU(8), IB=IU(9), and IN=IU(10)):
C
C The red intensity is IR/(IR+IG+IB)*IN/10000.
C The green intensity is IG/(IR+IG+IB)*IN/10000.
C The blue intensity is IB/(IR+IG+IB)*IN/10000.
C
C The GKS calls to set these intensities are executed in response to a
C "CALL SETUSV ('IN',IN)", using the existing values of IR, IG, and IB.
C Thus, to completely determine the color and the intensity, the user
C must execute four calls, as follows:
C
C CALL SETUSV ('IR',IR)
C CALL SETUSV ('IG',IG)
C CALL SETUSV ('IB',IB)
C CALL SETUSV ('IN',IN)
C
C The default values create a white line at .8 x maximum intensity.
C
c DATA IU(7) / 1 /
c DATA IU(8) / 1 /
c DATA IU(9) / 1 /
IU(7) = 1
IU(8) = 1
IU(9) = 1
C
c DATA IU(10) / 8000 /
IU(10) = 8000
C
C IU(11) and IU(12) specify, respectively, the last color index used
C and the maximum number of color indices it is permissible to use.
C
c DATA IU(11) / 0 /
c DATA IU(12) / 1 /
IU(11) = 0
IU(12) = 1
C
C IU(13)/1000 specifies the current line width scale factor.
C
c DATA IU(13) / 1000 /
IU(13) = 1000
C
C IU(14)/1000 specifies the current marker size scale factor.
C
c DATA IU(14) / 1000 /
IU(14) = 1000
C
C IU(15) through IU(100) are currently undefined.
C
C Initialization for the routine PLOTIT/F: For values of I between 1 and
C NQ, (QX(I),QY(I)) is a point to which a pen move has been requested
C by a past call to PLOTIT/F. The coordinates are stated in the fractional
C coordinate system. For values of I between 1 and NF, IF(I) is the
C index, in QX and QY, of the coordinates of a point to which a pen-up
C move was requested. NQ and NF are never allowed to be less than one.
C
c DATA NQ,QX(1),QY(1),NF,IF(1) / 1 , 0. , 0. , 1 , 1 /
NQ = 1
QX(1) = 0.
QY(1) = 0.
NF = 1
IF(1) = 1
C
C JX and JY are the coordinates, in the metacode system, of the last
C point to which a pen move was requested by a call to PLOTIT/F.
C
c DATA JX,JY / 0 , 0 /
JX = 0
JY = 0
C
c -NOAO
return
c
entry initut
first = .true.
END
|