This file is indexed.

/usr/include/giza-fortran.F90 is in giza-dev 0.9.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
!-----------------------------------------------------------------------
!  giza - a scientific plotting library built on cairo
!
!  Copyright (c) 2010      James Wetter and Daniel Price
!  Copyright (c) 2010-2012 Daniel Price
!
!  This library is free software; and you are welcome to redistribute
!  it under the terms of the GNU General Public License
!  (GPL, see LICENSE file for details) and the provision that
!   this notice remains intact. If you modify this file, please
!  note section 2a) of the GPLv2 states that:
!
!   a) You must cause the modified files to carry prominent notices
!      stating that you changed the files and the date of any change.
!
!  This software is distributed "AS IS", with ABSOLUTELY NO WARRANTY.
!  See the GPL for specific language governing rights and limitations.
!
!  The Original code is the giza plotting library.
!
!  Contributor(s):
!       James Wetter <wetter.j@gmail.com>
!       Daniel Price <daniel.price@monash.edu> (main contact)
!
!-----------------------------------------------------------------------
!---------------------------------------------------------
!  This file contains the Fortran interface to giza
!  (using the Fortran 2003 iso_c_binding module)
!---------------------------------------------------------

module giza
 use, intrinsic :: iso_c_binding, only:c_double,c_float,c_char,c_int
 implicit none
 public  :: &
      giza_plot, &
      giza_arrow, &
      giza_set_arrow_style, &
      giza_get_arrow_style, &
      giza_annotate, &
      giza_band, &
      giza_box, &
      giza_box_time, &
      giza_begin_buffer, &
      giza_end_buffer, &
      giza_flush_buffer, &
      giza_circle, &
      giza_set_character_height, &
      giza_get_character_height, &
      giza_get_character_size, &
      giza_set_clipping, &
      giza_get_clipping, &
      giza_colour_bar, &
      giza_set_colour_index, &
      giza_get_colour_index, &
      giza_set_colour_index_range, &
      giza_get_colour_index_range, &
      giza_set_colour_palette, &
      giza_set_colour_representation, &
      giza_get_colour_representation, &
      giza_set_colour_representation_hls, &
      giza_set_colour_table, &
      giza_contour, &
      giza_get_current_point, &
      giza_rgb_from_table, &
      giza_print_device_list, &
      giza_open, &
      giza_open_device, &
      giza_open_device_size, &
      giza_get_device_id, &
      giza_select_device, &
      giza_flush_device, &
      giza_change_page, &
      giza_close_device, &
      giza_close, &
      giza_get_key_press, &
      giza_device_has_cursor, &
      giza_draw, &
      giza_draw_background, &
      giza_set_environment, &
      giza_error_bars, &
      giza_error_bars_x, &
      giza_error_bars_y, &
      giza_set_fill, &
      giza_get_fill, &
      giza_function_x, &
      giza_function_y, &
      giza_function_t, &
      giza_get_surface_size, &
      giza_set_hatching_style, &
      giza_get_hatching_style, &
      giza_histogram, &
      giza_histogram_binned, &
      giza_label, &
      giza_line, &
      giza_set_line_width, &
      giza_get_line_width, &
      giza_set_line_cap, &
      giza_get_line_cap, &
      giza_set_line_style, &
      giza_get_line_style, &
      giza_mark_line, &
      giza_mark_line_ordered, &
      giza_mark_points, &
      giza_mark_points_ordered, &
      giza_move, &
      giza_set_paper_size, &
      giza_get_paper_size, &
      giza_points, &
      giza_single_point, &
      giza_polygon, &
      giza_print_id, &
      giza_start_prompting, &
      giza_stop_prompting, &
      giza_set_text_background, &
      giza_get_text_background, &
      giza_text, &
      giza_ptext, &
      giza_qtext, &
      giza_qtextlen, &
      giza_rectangle, &
      giza_render, &
      giza_render_gray, &
      giza_render_transparent, &
      giza_draw_pixels, &
      giza_restore, &
      giza_round, &
      giza_save, &
      giza_set_font, &
      giza_set_font_bold, &
      giza_set_font_italic, &
      giza_set_font_bold_italic, &
      giza_subpanel, &
      giza_set_panel, &
      giza_get_panel, &
      giza_vector, &
      giza_set_viewport_default, &
      giza_set_viewport, &
      giza_get_viewport, &
      giza_set_viewport_inches, &
      giza_version, &
      giza_start_warnings, &
      giza_stop_warnings, &
      giza_set_window, &
      giza_set_window_equal_scale, &
      giza_get_window, &
      giza_format_number, &
      giza_query_device

#include "giza-shared.h"
  character(len=1),parameter, public :: giza_left_click_f = GIZA_LEFT_CLICK
  character(len=1),parameter, public :: giza_right_click_f = GIZA_RIGHT_CLICK
  character(len=1),parameter, public :: giza_middle_click_f = GIZA_MIDDLE_CLICK
  character(len=1),parameter, public :: giza_shift_click_f = achar(GIZA_SHIFT_CLICK)
  character(len=1),parameter, public :: giza_scroll_up_f = achar(GIZA_SCROLL_UP)
  character(len=1),parameter, public :: giza_scroll_down_f = achar(GIZA_SCROLL_DOWN)
  character(len=1),parameter, public :: giza_scroll_left_f = achar(GIZA_SCROLL_LEFT)
  character(len=1),parameter, public :: giza_scroll_right_f = achar(GIZA_SCROLL_RIGHT)
  character(len=*),parameter, public :: giza_version_string = GIZA_VERSION_STRING
  integer, parameter, public :: giza_version_major = GIZA_VERSION_MAJOR
  integer, parameter, public :: giza_version_minor = GIZA_VERSION_MINOR
  integer, parameter, public :: giza_version_micro = GIZA_VERSION_MICRO
!
!--the following can be generated automatically using the get-fortran-params.pl script
!
  integer, parameter, public :: giza_ls_solid = GIZA_LS_SOLID
  integer, parameter, public :: giza_ls_short_dash = GIZA_LS_SHORT_DASH
  integer, parameter, public :: giza_ls_long_dash = GIZA_LS_LONG_DASH
  integer, parameter, public :: giza_ls_dot = GIZA_LS_DOT
  integer, parameter, public :: giza_ls_dash_dot = GIZA_LS_DASH_DOT
  integer, parameter, public :: giza_ls_dash_dot_dot_dot = GIZA_LS_DASH_DOT_DOT_DOT
  integer, parameter, public :: giza_number_format_auto = GIZA_NUMBER_FORMAT_AUTO
  integer, parameter, public :: giza_number_format_dec = GIZA_NUMBER_FORMAT_DEC
  integer, parameter, public :: giza_number_format_exp = GIZA_NUMBER_FORMAT_EXP
  integer, parameter, public :: giza_units_normalized = GIZA_UNITS_NORMALIZED
  integer, parameter, public :: giza_units_inches = GIZA_UNITS_INCHES
  integer, parameter, public :: giza_units_mm = GIZA_UNITS_MM
  integer, parameter, public :: giza_units_pixels = GIZA_UNITS_PIXELS
  integer, parameter, public :: giza_units_world = GIZA_UNITS_WORLD
  integer, parameter, public :: giza_units_device = GIZA_UNITS_DEVICE
  integer, parameter, public :: giza_band_none = GIZA_BAND_NONE
  integer, parameter, public :: giza_band_line = GIZA_BAND_LINE
  integer, parameter, public :: giza_band_rectangle = GIZA_BAND_RECTANGLE
  integer, parameter, public :: giza_band_horzlines = GIZA_BAND_HORZLINES
  integer, parameter, public :: giza_band_vertlines = GIZA_BAND_VERTLINES
  integer, parameter, public :: giza_band_horzline = GIZA_BAND_HORZLINE
  integer, parameter, public :: giza_band_vertline = GIZA_BAND_VERTLINE
  integer, parameter, public :: giza_band_crosshair = GIZA_BAND_CROSSHAIR
  integer, parameter, public :: giza_band_circle = GIZA_BAND_CIRCLE
  integer, parameter, public :: giza_background_colour = GIZA_BACKGROUND_COLOUR
  integer, parameter, public :: giza_background_color = GIZA_BACKGROUND_COLOR
  integer, parameter, public :: giza_foreground_colour = GIZA_FOREGROUND_COLOUR
  integer, parameter, public :: giza_foreground_color = GIZA_FOREGROUND_COLOR
  integer, parameter, public :: giza_colour_index_min = GIZA_COLOUR_INDEX_MIN
  integer, parameter, public :: giza_colour_index_max = GIZA_COLOUR_INDEX_MAX
  integer, parameter, public :: giza_colour_palette_default = GIZA_COLOUR_PALETTE_DEFAULT
  integer, parameter, public :: giza_color_palette_default = GIZA_COLOR_PALETTE_DEFAULT
  integer, parameter, public :: giza_colour_palette_pgplot = GIZA_COLOUR_PALETTE_PGPLOT
  integer, parameter, public :: giza_color_palette_pgplot = GIZA_COLOR_PALETTE_PGPLOT
  integer, parameter, public :: giza_fill_solid = GIZA_FILL_SOLID
  integer, parameter, public :: giza_fill_hollow = GIZA_FILL_HOLLOW
  integer, parameter, public :: giza_fill_hatch = GIZA_FILL_HATCH
  integer, parameter, public :: giza_fill_crosshatch = GIZA_FILL_CROSSHATCH
  integer, parameter, public :: giza_max_fill_styles = GIZA_MAX_FILL_STYLES
  integer, parameter, public :: giza_extend_none = GIZA_EXTEND_NONE
  integer, parameter, public :: giza_extend_repeat = GIZA_EXTEND_REPEAT
  integer, parameter, public :: giza_extend_reflect = GIZA_EXTEND_REFLECT
  integer, parameter, public :: giza_extend_pad = GIZA_EXTEND_PAD

private

!---------------------------------------------------------
!  The following are pure interfaces to C
!  We make generic interfaces so that the Fortran can
!  be called with either single or double precision
!---------------------------------------------------------

 interface giza_arrow
    subroutine giza_arrow(x1,y1,x2,y2) bind(C)
      import
      real(kind=c_double),intent(in),value :: x1,y1,x2,y2
    end subroutine giza_arrow
    
    subroutine giza_arrow_float(x1,y1,x2,y2) bind(C)
      import
      real(kind=c_float),intent(in),value :: x1,y1,x2,y2
    end subroutine giza_arrow_float
 end interface

 interface giza_set_arrow_style
    subroutine giza_set_arrow_style(fillStyle,angle,cutback) bind(C)
      import
      integer(kind=c_int),intent(in),value :: fillStyle
      real(kind=c_double),intent(in),value :: angle,cutback
    end subroutine giza_set_arrow_style

    subroutine giza_set_arrow_style_float(fillStyle,angle,cutback) bind(C)
      import
      integer(kind=c_int),intent(in),value :: fillStyle
      real(kind=c_float) ,intent(in),value :: angle,cutback
    end subroutine giza_set_arrow_style_float
 end interface

 interface giza_get_arrow_style
    subroutine giza_get_arrow_style(fillStyle,angle,cutback) bind(C)
      import
      integer(kind=c_int),intent(out) :: fillStyle
      real(kind=c_double),intent(out) :: angle,cutback
    end subroutine giza_get_arrow_style

    subroutine giza_get_arrow_style_float(fillStyle,angle,cutback) bind(C)
      import
      integer(kind=c_int),intent(out) :: fillStyle
      real(kind=c_float) ,intent(out) :: angle,cutback
    end subroutine giza_get_arrow_style_float
 end interface

 interface giza_band
    function giza_band(mode,moveCurs,xanc,yanc,x,y,ch) bind(C)
      import
      integer(kind=c_int)                  :: giza_band
      integer(kind=c_int),intent(in),value :: mode,moveCurs
      real(kind=c_double),intent(in),value :: xanc,yanc
      real(kind=c_double),intent(inout)    :: x,y
      character(kind=c_char),intent(out)   :: ch
    end function giza_band

    function giza_band_float(mode,moveCurs,xanc,yanc,x,y,ch) bind(C)
      import
      integer(kind=c_int)                  :: giza_band_float
      integer(kind=c_int),intent(in),value :: mode,moveCurs
      real(kind=c_float),intent(in),value  :: xanc,yanc
      real(kind=c_float),intent(inout)     :: x,y
      character(kind=c_char),intent(out)   :: ch
    end function giza_band_float
 end interface

 interface giza_annotate
    module procedure giza_intern_annotate_f2c
 end interface
 
 interface giza_annotate_c
    subroutine giza_annotate_c (side,displacement,coord,justification,text) bind(C,name="giza_annotate")
      import
      character(kind=c_char),dimension(*),intent(in) :: side,text
      real(kind=c_double),intent(in),value    ::displacement,coord,justification
    end subroutine giza_annotate_c
    
    subroutine giza_annotate_float_c (side,displacement,coord,justification,text) bind(C,name="giza_annotate_float")
      import
      character(kind=c_char),dimension(*),intent(in) :: side,text
      real(kind=c_float),intent(in),value     ::displacement,coord,justification
    end subroutine giza_annotate_float_c
 end interface
 
 interface giza_box
    module procedure giza_intern_box_f2c
 end interface

 interface giza_box_time
    module procedure giza_intern_box_time_f2c
 end interface
 
 interface giza_box_c
    subroutine giza_box_float_c(xopt,xtick,nxsub,yopt,ytick,nysub) bind(C,name="giza_box_float")
      import
      character(kind=c_char),dimension(*), intent(in) :: xopt,yopt
      real(kind=c_float), value, intent(in)    :: xtick,ytick
      integer(kind=c_int), value, intent(in)   :: nxsub,nysub
    end subroutine giza_box_float_c
    
    subroutine giza_box_c(xopt,xtick,nxsub,yopt,ytick,nysub) bind(C,name="giza_box")
      import
      character(kind=c_char),dimension(*), intent(in) :: xopt,yopt
      real(kind=c_double), value, intent(in)   :: xtick,ytick
      integer(kind=c_int), value, intent(in)   :: nxsub,nysub
    end subroutine giza_box_c
 end interface

 interface giza_box_time_c
    subroutine giza_box_time_float_c(xopt,xtick,nxsub,yopt,ytick,nysub) bind(C,name="giza_box_time_float")
      import
      character(kind=c_char),dimension(*), intent(in) :: xopt,yopt
      real(kind=c_float), value, intent(in)    :: xtick,ytick
      integer(kind=c_int), value, intent(in)   :: nxsub,nysub
    end subroutine giza_box_time_float_c
    
    subroutine giza_box_time_c(xopt,xtick,nxsub,yopt,ytick,nysub) bind(C,name="giza_box_time")
      import
      character(kind=c_char),dimension(*), intent(in) :: xopt,yopt
      real(kind=c_double), value, intent(in)   :: xtick,ytick
      integer(kind=c_int), value, intent(in)   :: nxsub,nysub
    end subroutine giza_box_time_c
 end interface

 interface giza_begin_buffer
    subroutine giza_begin_buffer() bind(C)
    end subroutine giza_begin_buffer
 end interface

 interface giza_end_buffer
    subroutine giza_end_buffer() bind(C)
    end subroutine giza_end_buffer
 end interface

 interface giza_flush_buffer
    subroutine giza_flush_buffer() bind(C)
    end subroutine giza_flush_buffer
 end interface

 interface giza_circle
    subroutine giza_circle(x,y,r) bind(C)
      import
      real(kind=c_double),intent(in),value :: x,y,r
    end subroutine giza_circle

    subroutine giza_circle_float(x,y,r) bind(C)
      import
      real(kind=c_float),intent(in),value :: x,y,r
    end subroutine giza_circle_float
 end interface

 interface giza_set_character_height 
    subroutine giza_set_character_height(ch) bind(C)
      import
      real(kind=c_double),intent(in),value :: ch
    end subroutine giza_set_character_height
    
    subroutine giza_set_character_height_float(ch) bind(C)
      import
      real(kind=c_float),intent(in),value :: ch
    end subroutine giza_set_character_height_float
 end interface
 
 interface giza_get_character_height
    subroutine giza_get_character_height(ch) bind(C)
      import
      real(kind=c_double),intent(out) :: ch
    end subroutine giza_get_character_height
    
    subroutine giza_get_character_height_float(ch) bind(C)
      import
      real(kind=c_float),intent(out) :: ch
    end subroutine giza_get_character_height_float
 end interface

 interface giza_get_character_size
    subroutine giza_get_character_size(units,xch,ych) bind(C)
      import
      integer(kind=c_int),intent(in),value :: units
      real(kind=c_double),intent(out)      :: xch,ych
    end subroutine giza_get_character_size
    
    subroutine giza_get_character_size_float(units,xch,ych) bind(C)
      import
      integer(kind=c_int),intent(in),value :: units
      real(kind=c_float),intent(out)       :: xch,ych
    end subroutine giza_get_character_size_float
 end interface

 interface giza_set_clipping
    subroutine giza_set_clipping(clip) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: clip
    end subroutine giza_set_clipping
 end interface

 interface giza_get_clipping
    subroutine giza_get_clipping(clip) bind(C)
      import
      integer(kind=c_int),intent(out) :: clip
    end subroutine giza_get_clipping
 end interface

 interface giza_colour_bar
    module procedure giza_intern_colour_bar_f2c
 end interface

 interface giza_colour_bar_c
    subroutine giza_colour_bar_c(side,disp,width,valmin,valmax,label) bind(C,name="giza_colour_bar")
      import
      character(kind=c_char), dimension(*), intent(in) :: side, label
      real(kind=c_double), value, intent(in) :: disp,width,valmin,valmax
    end subroutine giza_colour_bar_c

    subroutine giza_colour_bar_float_c(side,disp,width,valmin,valmax,label) bind(C,name="giza_colour_bar_float")
      import
      character(kind=c_char), dimension(*), intent(in) :: side, label
      real(kind=c_float), value, intent(in) :: disp,width,valmin,valmax
    end subroutine giza_colour_bar_float_c
 end interface

 interface giza_set_colour_index
    subroutine giza_set_colour_index(ci) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: ci
    end subroutine giza_set_colour_index
 end interface

 interface giza_get_colour_index
    subroutine giza_get_colour_index(ci) bind(C)
      import
      integer(kind=c_int),intent(out) :: ci
    end subroutine giza_get_colour_index
 end interface

 interface giza_set_colour_palette
    subroutine giza_set_colour_palette(palette) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: palette
    end subroutine giza_set_colour_palette
 end interface

 interface giza_set_colour_index_range
    subroutine giza_set_colour_index_range(cimin,cimax) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: cimin,cimax
    end subroutine giza_set_colour_index_range
 end interface

 interface giza_get_colour_index_range
    subroutine giza_get_colour_index_range(cimin,cimax) bind(C)
      import
      integer(kind=c_int),intent(out) :: cimin,cimax
    end subroutine giza_get_colour_index_range
 end interface

 interface giza_set_colour_representation
    subroutine giza_set_colour_representation_float(ci,red,green,blue) bind(C)
      import
      integer(kind=c_int), value, intent(in)    :: ci
      real(kind=c_float), value, intent(in)     :: red,green,blue
    end subroutine giza_set_colour_representation_float
    
    subroutine giza_set_colour_representation(ci,red,green,blue) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: ci
      real(kind=c_double), value, intent(in) :: red,green,blue
    end subroutine giza_set_colour_representation

    subroutine giza_set_colour_representation_alpha_float(ci,red,green,blue,alpha) bind(C)
      import
      integer(kind=c_int), value, intent(in)    :: ci
      real(kind=c_float), value, intent(in)     :: red,green,blue,alpha
    end subroutine giza_set_colour_representation_alpha_float
    
    subroutine giza_set_colour_representation_alpha(ci,red,green,blue,alpha) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: ci
      real(kind=c_double), value, intent(in) :: red,green,blue,alpha
    end subroutine giza_set_colour_representation_alpha
 end interface

 interface giza_get_colour_representation
    subroutine giza_get_colour_representation(ci,red,green,blue) bind(C)
      import
      integer(kind=c_int),intent(in),value       :: ci
      real(kind=c_double),intent(out) :: red,green,blue
    end subroutine giza_get_colour_representation
   
    subroutine giza_get_colour_representation_float(ci,red,green,blue) bind(C)
      import
      integer(kind=c_int),intent(in),value       :: ci
      real(kind=c_float),intent(out) :: red,green,blue
    end subroutine giza_get_colour_representation_float

    subroutine giza_get_colour_representation_alpha(ci,red,green,blue,alpha) bind(C)
      import
      integer(kind=c_int),intent(in),value       :: ci
      real(kind=c_double),intent(out) :: red,green,blue,alpha
    end subroutine giza_get_colour_representation_alpha
   
    subroutine giza_get_colour_representation_alpha_float(ci,red,green,blue,alpha) bind(C)
      import
      integer(kind=c_int),intent(in),value       :: ci
      real(kind=c_float),intent(out) :: red,green,blue,alpha
    end subroutine giza_get_colour_representation_alpha_float
 end interface

 interface giza_set_colour_representation_hls
    subroutine giza_set_colour_representation_hls(ci,hue,light,sat) bind(C)
      import
      integer(kind=c_int),intent(in),value :: ci
      real(kind=c_double),intent(in),value :: hue,light,sat
    end subroutine giza_set_colour_representation_hls

    subroutine giza_set_colour_representation_hls_float(ci,hue,light,sat) bind(C)
      import
      integer(kind=c_int),intent(in),value :: ci
      real(kind=c_float),intent(in),value  :: hue,light,sat
    end subroutine giza_set_colour_representation_hls_float
 end interface

 interface giza_set_colour_table
    subroutine giza_set_colour_table(controlPoints,red,green,blue,n,cont,bright) bind(C)
      import
      integer(kind=c_int),intent(in),value        :: n
      real(kind=c_double),intent(in),dimension(n) :: controlPoints,red,green,blue
      real(kind=c_double),intent(in),value        :: cont,bright
    end subroutine giza_set_colour_table
    
    subroutine giza_set_colour_table_float(controlPoints,red,green,blue,n,cont,bright) bind(C)
      import
      integer(kind=c_int),intent(in),value       :: n
      real(kind=c_float),intent(in),dimension(n) :: controlPoints,red,green,blue
      real(kind=c_float),intent(in),value        :: cont,bright
    end subroutine giza_set_colour_table_float
 end interface

 interface giza_contour
    subroutine giza_contour(sizex,sizey,data,i1,i2,j1,j2,ncont,cont,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,ncont
      real(kind=c_double),intent(in) :: data(sizex,sizey)
      real(kind=c_double),intent(in) :: cont(ncont)
      real(kind=c_double),intent(in) :: affine(6)
    end subroutine giza_contour
    
    subroutine giza_contour_float(sizex,sizey,data,i1,i2,j1,j2,ncont,cont,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,ncont
      real(kind=c_float),intent(in) :: data(sizex,sizey)
      real(kind=c_float),intent(in) :: cont(ncont)
      real(kind=c_float),intent(in) :: affine(6)
    end subroutine giza_contour_float
 end interface

 interface giza_get_current_point
    subroutine giza_get_current_point(xpt,ypt) bind(C)
      import
      real(kind=c_double),intent(out) :: xpt,ypt
    end subroutine giza_get_current_point
    
    subroutine giza_get_current_point_float(xpt,ypt) bind(C)
      import
      real(kind=c_float),intent(out) :: xpt,ypt
    end subroutine giza_get_current_point_float
 end interface

 interface giza_rgb_from_table
    subroutine giza_rgb_from_table(pos,r,g,b) bind(C)
      import
      real(kind=c_double),intent(in),value :: pos
      real(kind=c_double),intent(out) :: r,g,b
    end subroutine giza_rgb_from_table

    subroutine giza_rgb_from_table_float(pos,r,g,b) bind(C)
      import
      real(kind=c_float),intent(in),value :: pos
      real(kind=c_float),intent(out) :: r,g,b
    end subroutine giza_rgb_from_table_float
 end interface

 interface giza_print_device_list
    subroutine giza_print_device_list() bind(C)
    end subroutine  giza_print_device_list
 end interface

 interface giza_open_device
    module procedure giza_intern_open_device
 end interface

 interface giza_open_device_c
    integer(kind=c_int) function giza_open_device_c (dev,prefix) bind(C,name="giza_open_device")
      import
      character(kind=c_char),dimension(*),intent(in) :: dev,prefix
    end function  giza_open_device_c
 end interface

!--open device: requires string conversion
 interface giza_open_device_size
    module procedure giza_intern_open_device_size
 end interface

 interface giza_open_device_size_c
    integer(kind=c_int) function giza_open_device_size_c (dev,prefix,width,height,units) &
                        bind(C,name="giza_open_device_size")
      import
      character(kind=c_char),dimension(*),intent(in) :: dev,prefix
      real(kind=c_double),intent(in),value    :: height,width
      integer(kind=c_int),intent(in),value    :: units
    end function giza_open_device_size_c

    integer(kind=c_int) function giza_open_device_size_float_c(dev,prefix,width,height,units) &
                        bind(C,name="giza_open_device_size_float")
      import
      character(kind=c_char),dimension(*),intent(in) :: dev,prefix
      real(kind=c_float),intent(in),value     :: height,width
      integer(kind=c_int),intent(in),value    :: units
    end function giza_open_device_size_float_c
 end interface
 
! device_has_cursor is logical in Fortran but int in c
! (cannot do a generic interface for int/logical), can call c version directly with _int version
 interface giza_device_has_cursor
    module procedure giza_intern_device_has_cursor
 end interface

 interface giza_device_has_cursor_int
    function giza_device_has_cursor_c() bind(C,name="giza_device_has_cursor")
     import
     implicit none
     integer(kind=c_int) :: giza_device_has_cursor_c
    end function giza_device_has_cursor_c
 end interface

 interface giza_select_device
    subroutine giza_select_device(devid) bind(C)
      import
      integer(kind=c_int),intent(in),value :: devid
    end subroutine giza_select_device
 end interface

 interface giza_get_device_id
    subroutine giza_get_device_id(devid) bind(C)
      import
      integer(kind=c_int),intent(out) :: devid
    end subroutine giza_get_device_id
 end interface

 interface giza_flush_device
    subroutine giza_flush_device() bind(C)
    end subroutine giza_flush_device
 end interface

 interface giza_change_page
    subroutine giza_change_page() bind(C)
    end subroutine giza_change_page
 end interface

 interface giza_close_device
    subroutine giza_close_device() bind(C)
    end subroutine giza_close_device
 end interface

 interface giza_get_key_press
    function giza_get_key_press(x,y,ch) bind(C)
      import
      integer(kind=c_int)                :: giza_get_key_press
      real(kind=c_double),intent(out)    :: x,y
      character(kind=c_char),intent(out) :: ch
    end function giza_get_key_press

    function giza_get_key_press_float(x,y,ch) bind(C)
      import
      integer(kind=c_int)                :: giza_get_key_press_float
      real(kind=c_float),intent(out)     :: x,y
      character(kind=c_char),intent(out) :: ch
    end function giza_get_key_press_float
 end interface

 interface giza_draw
    subroutine giza_draw(x,y) bind(C)
      import
      real(kind=c_double),intent(in),value :: x,y
    end subroutine giza_draw

    subroutine giza_draw_float(x,y) bind(C)
      import
      real(kind=c_float),intent(in),value :: x,y
    end subroutine giza_draw_float
 end interface

 interface giza_draw_background
    subroutine giza_draw_background() bind(C)
    end subroutine
 end interface

 interface giza_set_environment
    subroutine giza_set_environment(xmin,xmax,ymin,ymax,just,axis) bind(C)
      import
      real(kind=c_double),intent(in),value :: xmin,xmax,ymin,ymax
      integer(kind=c_int),intent(in),value :: just,axis
    end subroutine giza_set_environment

    subroutine giza_set_environment_float(xmin,xmax,ymin,ymax,just,axis) bind(C)
      import
      real(c_float),intent(in),value       :: xmin,xmax,ymin,ymax
      integer(kind=c_int),intent(in),value :: just,axis
    end subroutine giza_set_environment_float
 end interface

 interface giza_error_bars
    subroutine giza_error_bars(dir,n,xpts,ypts,error,term) bind(C)
      import
      integer(kind=c_int),intent(in),value :: dir,n
      real(kind=c_double),intent(in),value :: term
      real(kind=c_double),dimension(n),intent(in) :: xpts,ypts,error
    end subroutine giza_error_bars

    subroutine giza_error_bars_float(dir,n,xpts,ypts,error,term) bind(C)
      import
      integer(kind=c_int),intent(in),value :: dir,n
      real(kind=c_float),intent(in),value :: term
      real(kind=c_float),dimension(n),intent(in) :: xpts,ypts,error
    end subroutine giza_error_bars_float
 end interface

 interface giza_error_bars_x
    subroutine giza_error_bars_hori(n,xpts,ypts1,ypts2,term) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n
      real(kind=c_double),intent(in),value :: term
      real(kind=c_double),dimension(n),intent(in) :: xpts,ypts1,ypts2
    end subroutine giza_error_bars_hori

    subroutine giza_error_bars_hori_float(n,xpts,ypts1,ypts2,term) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n
      real(kind=c_float),intent(in),value :: term
      real(kind=c_float),dimension(n),intent(in) :: xpts,ypts1,ypts2
    end subroutine giza_error_bars_hori_float
 end interface

 interface giza_error_bars_y
    subroutine giza_error_bars_vert(n,xpts,ypts1,ypts2,term) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n
      real(kind=c_double),intent(in),value :: term
      real(kind=c_double),dimension(n),intent(in) :: xpts,ypts1,ypts2
    end subroutine giza_error_bars_vert

    subroutine giza_error_bars_vert_float(n,xpts,ypts1,ypts2,term) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n
      real(kind=c_float),intent(in),value :: term
      real(kind=c_float),dimension(n),intent(in) :: xpts,ypts1,ypts2
    end subroutine giza_error_bars_vert_float
 end interface

 interface giza_set_fill
    subroutine giza_set_fill(fs) bind(C)
      import
      integer(kind=c_int),intent(in),value :: fs
    end subroutine giza_set_fill
 end interface
 
 interface giza_get_fill
    subroutine giza_get_fill(fs) bind(C)
      import
      integer(kind=c_int),intent(out) :: fs
    end subroutine giza_get_fill
 end interface

 interface giza_function_x
    subroutine giza_function_x(func,n,xmin,xmax,flag) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n,flag
      real(kind=c_double),intent(in),value :: xmin,xmax
      abstract interface
       function func(x) bind(c)
         import
         real(c_double), intent(in) :: x
         real(c_double) :: func
       end function
      end interface
    end subroutine giza_function_x

    subroutine giza_function_x_float(func,n,xmin,xmax,flag) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n,flag
      real(kind=c_float), intent(in),value :: xmin,xmax
      abstract interface
       function func(x) bind(c)
         import
         real(c_float), intent(in) :: x
         real(c_float) :: func
       end function
      end interface
    end subroutine giza_function_x_float
 end interface

 interface giza_function_y
    subroutine giza_function_y(func,n,ymin,ymax,flag) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n,flag
      real(kind=c_double),intent(in),value :: ymin,ymax
      abstract interface
       function func(x) bind(c)
         import
         real(c_double), intent(in) :: x
         real(c_double) :: func
       end function
      end interface
    end subroutine giza_function_y

    subroutine giza_function_y_float(func,n,ymin,ymax,flag) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n,flag
      real(kind=c_float), intent(in),value :: ymin,ymax
      abstract interface
       function func(x) bind(c)
         import
         real(c_float), intent(in) :: x
         real(c_float) :: func
       end function
      end interface
    end subroutine giza_function_y_float
 end interface

 interface giza_function_t
    subroutine giza_function_t(funcx,funcy,n,tmin,tmax,flag) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n,flag
      real(kind=c_double),intent(in),value :: tmin,tmax
      abstract interface
       function funcx(x) bind(c)
         import
         real(c_double), intent(in) :: x
         real(c_double) :: funcx
       end function
       function funcy(x) bind(c)
         import
         real(c_double), intent(in) :: x
         real(c_double) :: funcy
       end function
      end interface
    end subroutine giza_function_t

    subroutine giza_function_t_float(funcx,funcy,n,tmin,tmax,flag) bind(C)
      import
      integer(kind=c_int),intent(in),value :: n,flag
      real(kind=c_float), intent(in),value :: tmin,tmax
!      real(kind=c_float),external :: funcx,funcy
      abstract interface
       function funcx(x) bind(c)
         import
         real(c_float), intent(in) :: x
         real(c_float) :: funcx
       end function
       function funcy(x) bind(c)
         import
         real(c_float), intent(in) :: x
         real(c_float) :: funcy
       end function
      end interface
    end subroutine giza_function_t_float
 end interface

 interface giza_get_surface_size
    subroutine giza_get_surface_size_float(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_float),intent(out) :: x1,x2,y1,y2
    end subroutine giza_get_surface_size_float

    subroutine giza_get_surface_size(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_double),intent(out) :: x1,x2,y1,y2
    end subroutine giza_get_surface_size
 end interface
 
 interface giza_set_hatching_style
    subroutine giza_set_hatching_style(angle,spacing,phase) bind(C)
      import
      real(kind=c_double),intent(in),value :: angle,spacing,phase
    end subroutine giza_set_hatching_style

    subroutine giza_set_hatching_style_float(angle,spacing,phase) bind(C)
      import
      real(kind=c_float),intent(in),value :: angle,spacing,phase
    end subroutine giza_set_hatching_style_float
 end interface giza_set_hatching_style

 interface giza_get_hatching_style
    subroutine giza_get_hatching_style(angle,spacing,phase) bind(C)
      import
      real(kind=c_double),intent(out) :: angle,spacing,phase
    end subroutine giza_get_hatching_style

    subroutine giza_get_hatching_style_float(angle,spacing,phase) bind(C)
      import
      real(kind=c_float),intent(out) :: angle,spacing,phase
    end subroutine giza_get_hatching_style_float
 end interface giza_get_hatching_style

 interface giza_histogram
    subroutine giza_histogram(n,dat,min,max,nbin,flag) bind(C)
      import
      integer(kind=c_int),intent(in), value :: n,nbin,flag
      real(kind=c_double),intent(in) :: dat(*)
      real(kind=c_double),intent(in), value :: min,max
    end subroutine giza_histogram

    subroutine giza_histogram_float(n,dat,min,max,nbin,flag) bind(C)
      import
      integer(kind=c_int),intent(in), value :: n,nbin,flag
      real(kind=c_float), intent(in) :: dat(*)
      real(kind=c_float), intent(in), value :: min,max
    end subroutine giza_histogram_float
 end interface

 interface giza_histogram_binned
    subroutine giza_histogram_binned(nbin,x,dat,centre) bind(C)
      import
      integer(kind=c_int),intent(in), value :: nbin,centre
      real(kind=c_double),intent(in) :: x(*),dat(*)
    end subroutine giza_histogram_binned

    subroutine giza_histogram_binned_float(nbin,x,dat,centre) bind(C)
      import
      integer(kind=c_int),intent(in), value :: nbin,centre
      real(kind=c_float), intent(in) :: x(*),dat(*)
    end subroutine giza_histogram_binned_float
 end interface

 interface giza_label
    module procedure giza_intern_label_f2c
 end interface
 
 interface giza_label_c
    subroutine giza_label_c (labelx,labely,title) bind(C,name="giza_label")
      import
      character(kind=c_char),dimension(*),intent(in) :: labelx,labely,title
    end subroutine giza_label_c
 end interface giza_label_c

 interface giza_line
    subroutine giza_line_float(n,xpts,ypts) bind(C)
      import
      integer(kind=c_int),value,intent(in)       :: n
      real(kind=c_float),intent(in),dimension(n) :: xpts,ypts
    end subroutine giza_line_float

    subroutine giza_line(n,xpts,ypts) bind(C)
      import
      integer(kind=c_int),value,intent(in)        :: n
      real(kind=c_double),intent(in),dimension(n) :: xpts,ypts
    end subroutine giza_line
 end interface
 
 interface giza_set_line_width
    subroutine giza_set_line_width(lw) bind(C)
      import
      real(kind=c_double),intent(in), value :: lw
    end subroutine giza_set_line_width
    
    subroutine giza_set_line_width_float(lw) bind(C)
      import
      real(kind=c_float),intent(in), value :: lw
    end subroutine giza_set_line_width_float
    
    module procedure giza_intern_set_line_width_int
 end interface
 
 interface giza_get_line_width
    subroutine giza_get_line_width(lw) bind(C)
      import
      real(kind=c_double),intent(out) :: lw
    end subroutine giza_get_line_width
    
    subroutine giza_get_line_width_float(lw) bind(C)
      import
      real(kind=c_float),intent(out) :: lw
    end subroutine giza_get_line_width_float
    
    module procedure giza_intern_get_line_width_int
 end interface

 interface giza_set_line_cap
    subroutine giza_set_line_cap(lc) bind(C)
      import
      integer(c_int),value,intent(in) :: lc
    end subroutine giza_set_line_cap
 end interface

 interface giza_get_line_cap
    subroutine giza_get_line_cap(lc) bind(C)
      import
      integer(c_int),intent(out) :: lc
    end subroutine giza_get_line_cap
 end interface

 interface giza_set_line_style
    subroutine giza_set_line_style(ls) bind(C)
      import
      integer(c_int),value,intent(in) :: ls
    end subroutine giza_set_line_style
 end interface

 interface giza_get_line_style
    subroutine giza_get_line_style(ls) bind(C)
      import
      integer(c_int),intent(out) :: ls
    end subroutine giza_get_line_style
 end interface
 
 interface giza_mark_line
    subroutine giza_mark_line(maxpts,npts,xpts,ypts) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_double), dimension(*), intent(inout) :: xpts
      real(kind=c_double), dimension(*), intent(inout) :: ypts
    end subroutine giza_mark_line
    
    subroutine giza_mark_line_float(maxpts,npts,xpts,ypts) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_float), dimension(*), intent(inout) :: xpts
      real(kind=c_float), dimension(*), intent(inout) :: ypts
    end subroutine giza_mark_line_float

    subroutine giza_mark_line_char(maxpts,npts,xpts,ypts,ch) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_double), dimension(*), intent(inout) :: xpts
      real(kind=c_double), dimension(*), intent(inout) :: ypts
      character(kind=c_char),intent(out)   :: ch
    end subroutine giza_mark_line_char
    
    subroutine giza_mark_line_char_float(maxpts,npts,xpts,ypts,ch) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_float), dimension(*), intent(inout) :: xpts
      real(kind=c_float), dimension(*), intent(inout) :: ypts
      character(kind=c_char),intent(out)   :: ch
    end subroutine giza_mark_line_char_float
 end interface

 interface giza_mark_line_ordered
    subroutine giza_mark_line_ordered(maxpts,npts,xpts,ypts) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_double), dimension(*), intent(inout) :: xpts
      real(kind=c_double), dimension(*), intent(inout) :: ypts
    end subroutine giza_mark_line_ordered
    
    subroutine giza_mark_line_ordered_float(maxpts,npts,xpts,ypts) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_float), dimension(*), intent(inout) :: xpts
      real(kind=c_float), dimension(*), intent(inout) :: ypts
    end subroutine giza_mark_line_ordered_float
 end interface

 interface giza_mark_points
    subroutine giza_mark_points(maxpts,npts,xpts,ypts,symbol) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_double), dimension(*), intent(inout) :: xpts
      real(kind=c_double), dimension(*), intent(inout) :: ypts
      integer(kind=c_int),intent(in),value :: symbol
    end subroutine giza_mark_points
    
    subroutine giza_mark_points_float(maxpts,npts,xpts,ypts,symbol) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_float), dimension(*), intent(inout) :: xpts
      real(kind=c_float), dimension(*), intent(inout) :: ypts
      integer(kind=c_int),intent(in),value :: symbol
    end subroutine giza_mark_points_float
 end interface

 interface giza_mark_points_ordered
    subroutine giza_mark_points_ordered(maxpts,npts,xpts,ypts,symbol) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_double), dimension(*), intent(inout) :: xpts
      real(kind=c_double), dimension(*), intent(inout) :: ypts
      integer(kind=c_int),intent(in),value :: symbol
    end subroutine giza_mark_points_ordered
    
    subroutine giza_mark_points_ordered_float(maxpts,npts,xpts,ypts,symbol) bind(C)
      import
      integer(kind=c_int),intent(in),value :: maxpts
      integer(kind=c_int),intent(inout) :: npts
      real(kind=c_float), dimension(*), intent(inout) :: xpts
      real(kind=c_float), dimension(*), intent(inout) :: ypts
      integer(kind=c_int),intent(in),value :: symbol
    end subroutine giza_mark_points_ordered_float
 end interface
 
 interface giza_move
    subroutine giza_move(x,y) bind(C)
      import
      real(kind=c_double),intent(in),value :: x,y
    end subroutine giza_move

    subroutine giza_move_float(x,y) bind(C)
      import
      real(kind=c_float),intent(in),value :: x,y
    end subroutine giza_move_float
 end interface

 interface giza_get_paper_size
    subroutine giza_get_paper_size(units,width,height) bind(C)
      import
      integer(kind=c_int), intent(in),value :: units
      real(kind=c_double),intent(out) :: width,height
    end subroutine giza_get_paper_size

    subroutine giza_get_paper_size_float(units,width,height) bind(C)
      import
      integer(kind=c_int), intent(in),value :: units
      real(kind=c_float),intent(out) :: width,height
    end subroutine giza_get_paper_size_float
 end interface

 interface giza_set_paper_size
    subroutine giza_set_paper_size(units,width,aspect) bind(C)
      import
      integer(kind=c_int), intent(in),value :: units
      real(kind=c_double), intent(in),value :: width,aspect
    end subroutine giza_set_paper_size

    subroutine giza_set_paper_size_float(units,width,aspect) bind(C)
      import
      integer(kind=c_int),intent(in),value :: units
      real(kind=c_float), intent(in),value :: width,aspect
    end subroutine giza_set_paper_size_float
 end interface

 interface giza_points
    subroutine giza_points(n,xpts,ypts,symbol) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: n, symbol
      real(kind=c_double), dimension(n), intent(in) :: xpts,ypts
    end subroutine giza_points

    subroutine giza_points_float(n,xpts,ypts,symbol) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: n, symbol
      real(kind=c_float), dimension(n), intent(in) :: xpts,ypts
    end subroutine giza_points_float
 end interface

 interface giza_single_point
    subroutine giza_single_point(x,y,symbol) bind(C)
      import
      real(kind=c_double), value, intent(in) :: x,y
      integer(kind=c_int), value, intent(in) :: symbol
    end subroutine giza_single_point

    subroutine giza_single_point_float(x,y,symbol) bind(C)
      import
      real(kind=c_float),  value, intent(in) :: x,y
      integer(kind=c_int), value, intent(in) :: symbol
    end subroutine giza_single_point_float
 end interface

 interface giza_polygon
    subroutine giza_polygon(n,xpts,ypts) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: n
      real(kind=c_double), dimension(n), intent(in) :: xpts,ypts
    end subroutine giza_polygon

    subroutine giza_polygon_float(n,xpts,ypts) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: n
      real(kind=c_float), dimension(n), intent(in) :: xpts,ypts
    end subroutine giza_polygon_float
 end interface

 interface giza_print_id
    subroutine giza_print_id() bind(C)
    end subroutine giza_print_id
 end interface

 interface giza_start_prompting
    subroutine giza_start_prompting() bind(C)
    end subroutine giza_start_prompting
 end interface

 interface giza_stop_prompting
    subroutine giza_stop_prompting() bind(C)
    end subroutine giza_stop_prompting
 end interface

 interface giza_text
    module procedure giza_intern_text_f2c    
    module procedure giza_intern_text_float_f2c
 end interface

 interface giza_set_text_background
    subroutine giza_set_text_background(ci) bind(C)
      import
      integer(kind=c_int), value, intent(in) :: ci
    end subroutine giza_set_text_background
 end interface

 interface giza_get_text_background
    subroutine giza_get_text_background(ci) bind(C)
      import
      integer(kind=c_int), intent(out) :: ci
    end subroutine giza_get_text_background
 end interface

 interface giza_text_c
    subroutine giza_text_c(x,y,text) bind(C,name="giza_text")
      import
      real(kind=c_double),value,intent(in)    :: x,y
      character(kind=c_char),dimension(*),intent(in) :: text
    end subroutine giza_text_c

    subroutine giza_text_float_c(x,y,text) bind(C,name="giza_text_float")
      import
      real(kind=c_float),value,intent(in)     :: x,y
      character(kind=c_char),dimension(*),intent(in) :: text
    end subroutine giza_text_float_c
 end interface

 interface giza_open
    module procedure giza_open_sub
 end interface giza_open

 interface giza_ptext
    module procedure giza_intern_ptext_f2c    
    module procedure giza_intern_ptext_float_f2c
 end interface

 interface giza_ptext_c
    subroutine giza_ptext_c(x,y,angle,just,text) bind(C,name="giza_ptext")
      import
      real(kind=c_double),value,intent(in)    :: x,y,angle,just
      character(kind=c_char),dimension(*),intent(in) :: text
    end subroutine giza_ptext_c

    subroutine giza_ptext_float_c(x,y,angle,just,text) bind(C,name="giza_ptext_float")
      import
      real(kind=c_float),value,intent(in)     :: x,y,angle,just
      character(kind=c_char),dimension(*),intent(in) :: text
    end subroutine giza_ptext_float_c
 end interface

 interface giza_qtext
    module procedure giza_intern_qtext_f2c   
    module procedure giza_intern_qtext_float_f2c
 end interface

 interface giza_qtext_c
    subroutine giza_qtext_c(x,y,angle,just,text,xbox,ybox) bind(C,name="giza_qtext")
      import
      real(kind=c_double),value,intent(in)    :: x,y,angle,just
      real(kind=c_double),intent(out)         :: xbox(4),ybox(4)
      character(kind=c_char),dimension(*),intent(in) :: text
    end subroutine giza_qtext_c

    subroutine giza_qtext_float_c(x,y,angle,just,text,xbox,ybox) bind(C,name="giza_qtext_float")
      import
      real(kind=c_float),value,intent(in)     :: x,y,angle,just
      real(kind=c_float),intent(out)          :: xbox(4),ybox(4)
      character(kind=c_char),dimension(*),intent(in) :: text
    end subroutine giza_qtext_float_c
 end interface

 interface giza_qtextlen
    module procedure giza_intern_qtextlen_f2c   
    module procedure giza_intern_qtextlen_float_f2c
 end interface

 interface giza_qtextlen_c
    subroutine giza_qtextlen_c(units,text,xlen,ylen) bind(C,name="giza_qtextlen")
      import
      integer(kind=c_int),value,intent(in)    :: units
      character(kind=c_char),dimension(*),intent(in) :: text
      real(kind=c_double),intent(out)         :: xlen,ylen
    end subroutine giza_qtextlen_c

    subroutine giza_qtextlen_float_c(units,text,xlen,ylen) bind(C,name="giza_qtextlen_float")
      import
      integer(kind=c_int),value,intent(in)    :: units
      character(kind=c_char),dimension(*),intent(in) :: text
      real(kind=c_float),intent(out)          :: xlen,ylen
    end subroutine giza_qtextlen_float_c
 end interface

 interface giza_render
    subroutine giza_render(sizex,sizey,data,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_double),intent(in) :: data(sizex,sizey)
      real(kind=c_double),intent(in),value :: valMin,valMax
      real(kind=c_double),intent(in) :: affine(6)
    end subroutine giza_render
    
    subroutine giza_render_float(sizex,sizey,data,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_float),intent(in) :: data(sizex,sizey)
      real(kind=c_float),intent(in),value :: valMin,valMax
      real(kind=c_float),intent(in) :: affine(6)
    end subroutine giza_render_float

    subroutine giza_render_alpha(sizex,sizey,data,alpha,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_double),intent(in) :: data(sizex,sizey), alpha(sizex,sizey)
      real(kind=c_double),intent(in),value :: valMin,valMax
      real(kind=c_double),intent(in) :: affine(6)
    end subroutine giza_render_alpha
    
    subroutine giza_render_alpha_float(sizex,sizey,data,alpha,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_float),intent(in) :: data(sizex,sizey), alpha(sizex,sizey)
      real(kind=c_float),intent(in),value :: valMin,valMax
      real(kind=c_float),intent(in) :: affine(6)
    end subroutine giza_render_alpha_float
 end interface

 interface giza_render_transparent
    subroutine giza_render_transparent(sizex,sizey,data,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_double),intent(in) :: data(sizex,sizey)
      real(kind=c_double),intent(in),value :: valMin,valMax
      real(kind=c_double),intent(in) :: affine(6)
    end subroutine giza_render_transparent
    
    subroutine giza_render_transparent_float(sizex,sizey,data,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_float),intent(in) :: data(sizex,sizey)
      real(kind=c_float),intent(in),value :: valMin,valMax
      real(kind=c_float),intent(in) :: affine(6)
    end subroutine giza_render_transparent_float
 end interface

 interface giza_render_gray
    subroutine giza_render_gray(sizex,sizey,data,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_double),intent(in) :: data(sizex,sizey)
      real(kind=c_double),intent(in),value :: valMin,valMax
      real(kind=c_double),intent(in) :: affine(6)
    end subroutine giza_render_gray
    
    subroutine giza_render_gray_float(sizex,sizey,data,i1,i2,j1,j2,valMin,valMax,extend,affine) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      real(kind=c_float),intent(in) :: data(sizex,sizey)
      real(kind=c_float),intent(in),value :: valMin,valMax
      real(kind=c_float),intent(in) :: affine(6)
    end subroutine giza_render_gray_float
 end interface

 interface giza_draw_pixels
    subroutine giza_draw_pixels(sizex,sizey,idata,i1,i2,j1,j2,xmin,xmax,ymin,ymax,extend) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      integer(kind=c_int),intent(in) :: idata(sizex,sizey)
      real(kind=c_double),intent(in),value :: xmin,xmax,ymin,ymax
    end subroutine giza_draw_pixels
    
    subroutine giza_draw_pixels_float(sizex,sizey,idata,i1,i2,j1,j2,xmin,xmax,ymin,ymax,extend) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,extend
      integer(kind=c_int),intent(in) :: idata(sizex,sizey)
      real(kind=c_float),intent(in),value :: xmin,xmax,ymin,ymax
    end subroutine giza_draw_pixels_float
 end interface

 interface giza_rectangle
    subroutine giza_rectangle(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_double),intent(in),value :: x1,x2,y1,y2
    end subroutine giza_rectangle

    subroutine giza_rectangle_float(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_float),intent(in),value :: x1,x2,y1,y2
    end subroutine giza_rectangle_float

    subroutine giza_rectangle_rounded(x1,x2,y1,y2,r) bind(C)
      import
      real(kind=c_double),intent(in),value :: x1,x2,y1,y2,r
    end subroutine giza_rectangle_rounded

    subroutine giza_rectangle_rounded_float(x1,x2,y1,y2,r) bind(C)
      import
      real(kind=c_float),intent(in),value :: x1,x2,y1,y2,r
    end subroutine giza_rectangle_rounded_float
 end interface giza_rectangle

 interface giza_restore
    subroutine giza_restore() bind(C)
    end subroutine giza_restore
 end interface

 interface giza_round
    function giza_round_db(x,nsub) bind(C,name="giza_round")
      import
      real(kind=c_double), intent(in) :: x
      integer(kind=c_int), intent(out) :: nsub
      real(kind=c_double) :: giza_round_db
    end function giza_round_db

    function giza_round_float(x,nsub) bind(C,name="giza_round_float")
      import
      real(kind=c_float), intent(in) :: x
      integer(kind=c_int), intent(out) :: nsub
      real(kind=c_float) :: giza_round_float
    end function giza_round_float
 end interface giza_round
 
 interface giza_save
    subroutine giza_save() bind(C)
    end subroutine giza_save
 end interface

 interface giza_set_font
    module procedure giza_intern_set_font_f2c
 end interface

 interface giza_set_font_bold
    module procedure giza_intern_set_font_bold_f2c
 end interface

 interface giza_set_font_italic
    module procedure giza_intern_set_font_italic_f2c
 end interface

 interface giza_set_font_bold_italic
    module procedure giza_intern_set_font_bold_italic_f2c
 end interface

 interface giza_set_font_c
    subroutine giza_set_font_c(font) bind(C,name="giza_set_font")
      import
      character(kind=c_char),dimension(*),intent(in) :: font
    end subroutine giza_set_font_c
 end interface
 interface giza_set_font_bold_c
    subroutine giza_set_font_bold_c(font) bind(C,name="giza_set_font_bold")
      import
      character(kind=c_char),dimension(*),intent(in) :: font
    end subroutine giza_set_font_bold_c
 end interface
 interface giza_set_font_italic_c
    subroutine giza_set_font_italic_c(font) bind(C,name="giza_set_font_italic")
      import
      character(kind=c_char),dimension(*),intent(in) :: font
    end subroutine giza_set_font_italic_c
 end interface
 interface giza_set_font_bold_italic_c
    subroutine giza_set_font_bold_italic_c(font) bind(C,name="giza_set_font_bold_italic")
      import
      character(kind=c_char),dimension(*),intent(in) :: font
    end subroutine giza_set_font_bold_italic_c
 end interface

 interface giza_subpanel
    subroutine giza_subpanel(nx,ny) bind(C)
      import
      integer(kind=c_int), intent(in),value :: nx,ny
    end subroutine giza_subpanel
 end interface
 
 interface giza_set_panel
    subroutine giza_set_panel(ix,iy) bind(C)
      import
      integer(kind=c_int), intent(in),value :: ix,iy
    end subroutine giza_set_panel
 end interface

 interface giza_get_panel
    subroutine giza_get_panel(ix,iy) bind(C)
      import
      integer(kind=c_int), intent(out) :: ix,iy
    end subroutine giza_get_panel
 end interface

 interface giza_vector
    subroutine giza_vector(sizex,sizey,horizontal,vertical,i1,i2,j1,j2,scale,position,affine,blank) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,position
      real(kind=c_double),intent(in) :: horizontal(sizex,sizey),vertical(sizex,sizey)
      real(kind=c_double),intent(in),value :: scale,blank
      real(kind=c_double),intent(in) :: affine(6)
    end subroutine giza_vector
    
    subroutine giza_vector_float(sizex,sizey,horizontal,vertical,i1,i2,j1,j2,scale,position,affine,blank) bind(C)
      import
      integer(kind=c_int),intent(in),value :: sizex,sizey,i1,i2,j1,j2,position
      real(kind=c_float),intent(in) :: horizontal(sizex,sizey),vertical(sizex,sizey)
      real(kind=c_float),intent(in),value :: scale,blank
      real(kind=c_float),intent(in) :: affine(6)
    end subroutine giza_vector_float
 end interface


 interface giza_set_viewport
    subroutine giza_set_viewport_float(xleft,xright,ybot,ytop) bind(C)
      import
      real(kind=c_float), value, intent(in) :: xleft,xright,ybot,ytop
    end subroutine giza_set_viewport_float

    subroutine giza_set_viewport(xleft,xright,ybot,ytop) bind(C)
      import
      real(kind=c_double), value, intent(in) :: xleft,xright,ybot,ytop
    end subroutine giza_set_viewport
 end interface

 interface giza_set_viewport_default
    subroutine giza_set_viewport_default() bind(C)
    end subroutine giza_set_viewport_default
 end interface

 interface giza_get_viewport
    subroutine giza_get_viewport(units,x1,x2,y1,y2) bind(C)
      import
      integer(kind=c_int), value, intent(in)  :: units
      real(kind=c_double),        intent(out) :: x1,x2,y1,y2
    end subroutine giza_get_viewport
    
    subroutine giza_get_viewport_float(units,x1,x2,y1,y2) bind(C)
      import
      integer(kind=c_int),value, intent(in)  :: units
      real(kind=c_float),        intent(out) :: x1,x2,y1,y2
    end subroutine giza_get_viewport_float
 end interface

 interface giza_set_viewport_inches
    subroutine giza_set_viewport_inches_float(xleft,xright,ybot,ytop) bind(C)
      import
      real(kind=c_float), value, intent(in) :: xleft,xright,ybot,ytop
    end subroutine giza_set_viewport_inches_float

    subroutine giza_set_viewport_inches(xleft,xright,ybot,ytop) bind(C)
      import
      real(kind=c_double), value, intent(in) :: xleft,xright,ybot,ytop
    end subroutine giza_set_viewport_inches
 end interface
 
 interface giza_version
    subroutine giza_version(major,minor,micro) bind(C)
     import
     integer(kind=c_int), intent(out) :: major,minor,micro
    end subroutine giza_version
 end interface

 interface giza_start_warnings
    subroutine giza_start_warnings() bind(C)
    end subroutine giza_start_warnings
 end interface

 interface giza_stop_warnings
    subroutine giza_stop_warnings() bind(C)
    end subroutine giza_stop_warnings
 end interface

 interface giza_set_window
    subroutine giza_set_window_float(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_float), value, intent(in) :: x1,x2,y1,y2
    end subroutine giza_set_window_float

    subroutine giza_set_window(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_double), value, intent(in) :: x1,x2,y1,y2
    end subroutine giza_set_window
 end interface

 interface giza_set_window_equal_scale
    subroutine giza_set_window_equal_scale(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_double), value, intent(in) :: x1,x2,y1,y2
    end subroutine giza_set_window_equal_scale

    subroutine giza_set_window_equal_scale_float(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_float), value, intent(in) :: x1,x2,y1,y2
    end subroutine giza_set_window_equal_scale_float
 end interface

 interface giza_get_window
    subroutine giza_get_window(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_double),intent(out) :: x1,x2,y1,y2
    end subroutine giza_get_window

    subroutine giza_get_window_float(x1,x2,y1,y2) bind(C)
      import
      real(kind=c_float),intent(out) :: x1,x2,y1,y2
    end subroutine giza_get_window_float
 end interface

 interface giza_format_number
    module procedure giza_format_number_f2c
 end interface

 !private :: giza_format_number_c
 interface giza_format_number_c
    subroutine giza_format_number_c(mantissa,power,iform,string) bind(C,name="giza_format_number")
      import
      integer(kind=c_int),value,intent(in)    :: mantissa,power,iform
      character(kind=c_char),dimension(*),intent(out) :: string
    end subroutine giza_format_number_c
 end interface

 interface giza_query_device
    module procedure giza_query_device_f2c
 end interface

 interface giza_query_device_c
    integer(kind=c_int) function giza_query_device_c(qtype,string) bind(C,name="giza_query_device")
      import
      character(kind=c_char),dimension(*),intent(in)  :: qtype
      character(kind=c_char),dimension(*),intent(out) :: string
    end function giza_query_device_c
 end interface
!------------------ end of interfaces -----------------------

contains

!-------------------------------------------------------
! these are subroutines whose arguments need conversion
! before passing to c (mainly strings)       
!-------------------------------------------------------

  subroutine giza_intern_annotate_f2c(side,displacement,coord,justification,text)
    implicit none
    character(len=*),intent(in)    :: side,text
    real,intent(in)                :: displacement,coord,justification
    real(kind=c_double)            :: displacement_c,coord_c,justification_c

    displacement_c = displacement
    coord_c = coord
    justification_c = justification

    call giza_annotate_c(cstring(side),displacement_c,coord_c,justification_c,cstring(text))
  end subroutine giza_intern_annotate_f2c

  subroutine giza_intern_box_f2c(xopt,xtick,nxsub,yopt,ytick,nysub)
    implicit none
    character(len=*),intent(in) :: xopt,yopt
    real,intent(in)             :: xtick,ytick
    integer,intent(in)          :: nxsub,nysub
    real(kind=c_double)         :: xtick_c,ytick_c
    integer(kind=c_int)         :: nxsub_c,nysub_c

    xtick_c = xtick; ytick_c = ytick
    nxsub_c = nxsub; nysub_c = nysub

    call giza_box_c(cstring(xopt),xtick_c,nxsub_c,cstring(yopt),ytick_c,nysub_c)
  end subroutine giza_intern_box_f2c

  subroutine giza_intern_box_time_f2c(xopt,xtick,nxsub,yopt,ytick,nysub)
    implicit none
    character(len=*),intent(in) :: xopt,yopt
    real,intent(in)             :: xtick,ytick
    integer,intent(in)          :: nxsub,nysub
    real(kind=c_double)         :: xtick_c,ytick_c
    integer(kind=c_int)         :: nxsub_c,nysub_c

    xtick_c = xtick; ytick_c = ytick
    nxsub_c = nxsub; nysub_c = nysub

    call giza_box_time_c(cstring(xopt),xtick_c,nxsub_c,cstring(yopt),ytick_c,nysub_c)
  end subroutine giza_intern_box_time_f2c

  subroutine giza_intern_colour_bar_f2c(side,disp,width,valmin,valmax,label)
    implicit none
    character(len=*), intent(in) :: side,label
    real, intent(in) :: disp,width,valmin,valmax
    real(kind=c_double) :: disp_c,width_c,valmin_c,valmax_c
    
    disp_c = disp
    width_c = width
    valmin_c = valmin
    valmax_c = valmax
    
    call giza_colour_bar_c(cstring(side),disp_c,width_c,valmin_c,valmax_c,cstring(label))
    
  end subroutine giza_intern_colour_bar_f2c

  integer function  giza_intern_open_device(dev,prefix)
    implicit none
    character(len=*),intent(in) :: dev,prefix
    
    giza_intern_open_device = giza_open_device_c(cstring(dev),cstring(prefix))
  end function giza_intern_open_device

  subroutine giza_open_sub(dev,prefix,width,height,units,error)
    implicit none
    character(len=*),intent(in), optional  :: dev
    character(len=*), intent(in), optional :: prefix
    real,intent(in), optional     :: width,height
    integer, intent(in), optional :: units
    integer, intent(out), optional :: error
    integer :: giza_open
    
    character(len=40) :: fdev
    if (present(dev)) then
       fdev = dev
    else
       fdev = '?'
    endif
    
    if (present(units) .and. present(width) .and. present(height)) then    
       if (present(prefix)) then
          giza_open = giza_open_device_size_c(cstring(fdev),cstring(prefix),width,height,units)
       else
          giza_open = giza_open_device_size_c(cstring(fdev),cstring('giza'),width,height,units)
       endif
    else
       if (present(prefix)) then
          giza_open = giza_open_device_c(cstring(fdev),cstring(prefix))
       else
          giza_open = giza_open_device_c(cstring(fdev),cstring('giza'))
       endif
    endif
    if (present(error)) then
       error = giza_open
    endif
  
  end subroutine giza_open_sub
  
  subroutine giza_close
     call giza_close_device()
  end subroutine giza_close


  integer function giza_intern_open_device_size(dev,prefix,width,height,units)
    implicit none
    character(len=*),intent(in) :: dev,prefix
    real,intent(in)             :: width,height
    integer, intent(in)         :: units
    
    giza_intern_open_device_size = giza_open_device_size_c(cstring(dev),cstring(prefix),width,height,units)
  
  end function giza_intern_open_device_size

  ! So cursor functionality can be queried as logical 
  logical function giza_intern_device_has_cursor()
    implicit none

    giza_intern_device_has_cursor = (giza_device_has_cursor_c().eq.1)

  end function giza_intern_device_has_cursor

  subroutine giza_intern_label_f2c(labelx,labely,title)
    implicit none
    character(len=*),intent(in) :: labelx,labely,title
    
    call giza_label_c(cstring(labelx),cstring(labely),cstring(title))

  end subroutine giza_intern_label_f2c

  subroutine giza_intern_set_line_width_int(lw)
    implicit none
    integer(kind=c_int),value,intent(in) :: lw
    real(kind=c_double) :: reallw
    
    !--cairo line widths are best as .5, 1.5 etc
    reallw = dble(lw) + 0.5d0
    call giza_set_line_width(reallw)
  end subroutine giza_intern_set_line_width_int

  subroutine giza_intern_get_line_width_int(lw)
    implicit none
    integer(kind=c_int),intent(out) :: lw
    real(kind=c_double) :: reallw

    call giza_get_line_width(reallw)
    lw = nint(reallw - 0.5d0)
  end subroutine giza_intern_get_line_width_int

  subroutine giza_intern_text_f2c(x,y,text)
    implicit none
    real(kind=c_double),intent(in) :: x,y
    character(len=*),intent(in)    :: text

    call giza_text_c(x,y,cstring(text))
  end subroutine giza_intern_text_f2c

 subroutine giza_intern_text_float_f2c(x,y,text)
    implicit none
    real(kind=c_float),intent(in) :: x,y
    character(len=*),intent(in)    :: text
    
    call giza_text_float_c(x,y,cstring(text))
  end subroutine giza_intern_text_float_f2c

  subroutine giza_intern_ptext_f2c(x,y,angle,just,text)
    implicit none
    real(kind=c_double),intent(in) :: x,y,angle,just
    character(len=*),intent(in)    :: text

    call giza_ptext_c(x,y,angle,just,cstring(text))
  end subroutine giza_intern_ptext_f2c

 subroutine giza_intern_ptext_float_f2c(x,y,angle,just,text)
    implicit none
    real(kind=c_float),intent(in) :: x,y,angle,just
    character(len=*),intent(in)    :: text
    
    call giza_ptext_float_c(x,y,angle,just,cstring(text))
  end subroutine giza_intern_ptext_float_f2c

  subroutine giza_intern_qtext_f2c(x,y,angle,just,text,xbox,ybox)
    implicit none
    real(kind=c_double),intent(in) :: x,y,angle,just
    real(kind=c_double),intent(out):: xbox(4),ybox(4)
    character(len=*),intent(in)    :: text

    call giza_qtext_c(x,y,angle,just,cstring(text),xbox,ybox)
  end subroutine giza_intern_qtext_f2c

  subroutine giza_intern_qtext_float_f2c(x,y,angle,just,text,xbox,ybox)
    implicit none
    real(kind=c_float),intent(in) :: x,y,angle,just
    real(kind=c_float),intent(out):: xbox(4),ybox(4)
    character(len=*),intent(in)   :: text
    
    call giza_qtext_float_c(x,y,angle,just,cstring(text),xbox,ybox)
  end subroutine giza_intern_qtext_float_f2c

  subroutine giza_intern_qtextlen_f2c(units,text,xlen,ylen)
    implicit none
    integer(kind=c_int),intent(in) :: units
    character(len=*),intent(in)    :: text
    real(kind=c_double),intent(out):: xlen,ylen

    call giza_qtextlen_c(units,cstring(text),xlen,ylen)
  end subroutine giza_intern_qtextlen_f2c

  subroutine giza_intern_qtextlen_float_f2c(units,text,xlen,ylen)
    implicit none
    integer(kind=c_int),intent(in) :: units
    character(len=*),intent(in)    :: text
    real(kind=c_float),intent(out) :: xlen,ylen

    call giza_qtextlen_float_c(units,cstring(text),xlen,ylen)
  end subroutine giza_intern_qtextlen_float_f2c

  subroutine giza_intern_set_font_f2c(font)
    implicit none
    character(len=*),intent(in) :: font
  
    call giza_set_font_c(cstring(font))

  end subroutine giza_intern_set_font_f2c

  subroutine giza_intern_set_font_bold_f2c(font)
    implicit none
    character(len=*),intent(in) :: font
  
    call giza_set_font_bold_c(cstring(font))

  end subroutine giza_intern_set_font_bold_f2c

  subroutine giza_intern_set_font_italic_f2c(font)
    implicit none
    character(len=*),intent(in) :: font
  
    call giza_set_font_italic_c(cstring(font))

  end subroutine giza_intern_set_font_italic_f2c

  subroutine giza_intern_set_font_bold_italic_f2c(font)
    implicit none
    character(len=*),intent(in) :: font
  
    call giza_set_font_bold_italic_c(cstring(font))

  end subroutine giza_intern_set_font_bold_italic_f2c

  subroutine giza_format_number_f2c(mantissa,power,iform,string)
    implicit none
    integer(kind=c_int),intent(in) :: mantissa,power,iform
    character(len=*),  intent(out) :: string
    character(kind=c_char), dimension(len(string)+1) :: stringc
  
    call giza_format_number_c(mantissa,power,iform,stringc)
    string = fstring(stringc)

  end subroutine giza_format_number_f2c

  subroutine giza_query_device_f2c(qtype,string)
    implicit none
    character(len=*),intent(in)  :: qtype
    character(len=*),intent(out) :: string
    integer(kind=c_int) :: ierr
    character(kind=c_char), dimension(len(string)+1) :: stringc
    
    ierr = giza_query_device_c(cstring(qtype),stringc)
    string = fstring(stringc)
  
  end subroutine giza_query_device_f2c

  !---------------------------------------------------------------------------
  !
  ! function to safely convert a string to c format (ie. with a terminating
  ! ascii null character)
  !
  !---------------------------------------------------------------------------
  function cstring(string) result(array)
    implicit none
    character(len=*), intent(in) :: string
    character(kind=c_char), dimension(len(string)+1) :: array
    integer :: i, ilen

    ilen = len_trim(string) ! use the trimmed string length
    do i=1, ilen
      array(i)=string(i:i)
    end do
    array(ilen+1)=achar(0)

  end function cstring

  !---------------------------------------------------------------------------
  !
  ! function to safely convert a string from c format (ie. with a terminating
  ! ascii null character) back to a normal Fortran string
  !
  !---------------------------------------------------------------------------
   function fstring(array)
    implicit none
    character(kind=c_char), dimension(:), intent(in) :: array
    character(len=size(array)-1) :: fstring
    integer :: i

    fstring = ''
    do i=1,size(array)
       if (array(i).eq.achar(0)) exit
       fstring(i:i) = array(i)
    enddo

   end function fstring

!---------------------------------------------------------------------------
!---------------------------------------------------------------------------
!              HIGH LEVEL FORTRAN INTERFACE
!---------------------------------------------------------------------------
!---------------------------------------------------------------------------

subroutine giza_plot(y,x,img,dev,prefix,width,height,units,&
                     xmin,xmax,ymin,ymax,imgmin,imgmax,affine,&
                     vptxmin,vptxmax,vptymin,vptymax, &
                     xlabel,ylabel,title,font,&
                     ls,lw,ci,ch,symbol,just,axis,extend,printid)
 implicit none
 real, intent(in), dimension(:), optional :: y,x
 real, intent(in), dimension(:,:), optional :: img
 integer, intent(in), optional :: units
 real, intent(in), optional :: width,height
 character(len=*), intent(in), optional :: dev,prefix
 real, intent(in), optional :: xmin,xmax,ymin,ymax,imgmin,imgmax
 real, intent(in), optional :: vptxmin,vptxmax,vptymin,vptymax
 character(len=*), intent(in), optional :: xlabel,ylabel,title
 character(len=*), intent(in), optional :: font
 integer, intent(in), optional :: ls,ci,symbol,axis,just,extend
 real, intent(in), optional :: lw,ch
 real, dimension(6), intent(in), optional :: affine
 logical, intent(in), optional :: printid
 integer :: iunits,nx,ny,i,iaxis,ijust
 real(kind=c_double) :: xmini,xmaxi,ymini,ymaxi,valmin,valmax,dx,dy
 real(kind=c_double) :: vptxmini,vptxmaxi,vptymini,vptymaxi
 real(kind=c_double), dimension(6) :: affinei
 character(len=20) :: devi
 character(len=40) :: xlabeli,ylabeli,titlei
 real(kind=c_double), dimension(:), allocatable :: arrtmp
 
 real(kind=c_double)  :: lw_c, ch_c
 integer(kind=c_int)  :: n, nx_c, ny_c
 integer(kind=c_int)  :: symbol_c, iextend

!
!--open giza device
!
 if (present(dev)) then
    devi = dev
 else
    devi = '?'
 endif
 if (present(width) .and. present(height)) then
    if (present(units)) then
       iunits = units
    else
       iunits = giza_units_pixels
    endif
    if (present(prefix)) then
       call giza_open(dev=devi,prefix=prefix,width=width,height=height,units=iunits)
    else
       call giza_open(dev=devi,width=width,height=height,units=iunits)
    endif
 else
    if (present(prefix)) then
       call giza_open(dev=devi,prefix=prefix)    
    else
       call giza_open(dev=devi)
    endif
 endif

!
!--max/min limits for plot window
!
 if (present(xmin)) then
    xmini = xmin
 else
    if (present(x)) then
       xmini = minval(x)
    else
       xmini = 0.
    endif
 endif
 if (present(xmax)) then    
    xmaxi = xmax
 else
    if (present(x)) then
       xmaxi = maxval(x)
    else
       xmaxi = 1.
    endif
 endif
 if (present(ymin)) then
    ymini = ymin
 else
    if (present(y)) then
       ymini = minval(y)
    else
       ymini = 0.
    endif
 endif
 if (present(ymax)) then
    ymaxi = ymax
 else
    if (present(y)) then
       ymaxi = maxval(y)
    else
       ymaxi = 1.
    endif
 endif
 !--plot labels
 if (present(title)) then
    titlei = title
 else
    titlei = ''
 endif
 if (present(xlabel)) then
    xlabeli = xlabel
 else
    xlabeli = ''
 endif
 if (present(ylabel)) then
    ylabeli = ylabel
 else
    ylabeli = ''
 endif
 if (present(font)) then
    call giza_set_font(font)
 endif
 if (present(ch)) then
    ch_c = ch
    call giza_set_character_height(ch_c)
 endif
 if (present(just)) then
    ijust = just
 else
    ijust = 0
 endif
 if (present(axis)) then
    iaxis = axis
 else
    iaxis = 0
 endif

 if (present(vptxmin) .or. present(vptxmax) .or. present(vptymin) .or. present(vptymax)) then
    call giza_set_viewport_default()
    call giza_get_viewport(giza_units_normalized,vptxmini,vptxmaxi,vptymini,vptymaxi)

    if (present(vptxmin)) vptxmini = vptxmin
    if (present(vptxmax)) vptxmaxi = vptxmax
    if (present(vptymin)) vptymini = vptymin
    if (present(vptymax)) vptymaxi = vptymax

    call giza_set_viewport(vptxmini,vptxmaxi,vptymini,vptymaxi)
    if (ijust.eq.1) then
       call giza_set_window(xmini,xmaxi,ymini,ymaxi)
    else
       call giza_set_window_equal_scale(xmini,xmaxi,ymini,ymaxi)
    endif
    call giza_box("BCTSN",0.,0,"BCTSN",0.,0)
    call giza_label(xlabeli,ylabeli,titlei)
 else
    call giza_set_environment(xmini,xmaxi,ymini,ymaxi,ijust,iaxis)
    call giza_label(xlabeli,ylabeli,titlei)
 endif
 if (present(printid)) then
    if (printid) call giza_print_id()
 endif

 if (present(ls)) then
    call giza_set_line_style(ls)
 endif
 if (present(lw)) then
    lw_c = lw
    call giza_set_line_width(lw_c)
 endif
 if (present(ci)) then
    call giza_set_colour_index(ci)
 endif
 
 if (present(x) .and. present(y)) then
    n = min(size(x),size(y))
    if (present(symbol)) then
       symbol_c = symbol
       call giza_points(n,real(x,kind=c_double),real(y,kind=c_double),symbol_c)    
    else
       call giza_line(n,real(x,kind=c_double),real(y,kind=c_double))
    endif
 elseif (present(x) .and. size(x).gt.1) then
    n = size(x)
    allocate(arrtmp(n))
    do i=1,n
       arrtmp(i) = (i-1)/(real(n-1))
    enddo
    if (present(symbol)) then
       symbol_c = symbol
       call giza_points(n,real(x,kind=c_double),arrtmp,symbol_c)
    else
       call giza_line(n,real(x,kind=c_double),arrtmp)
    endif
    deallocate(arrtmp)
 elseif (present(y) .and. size(y).gt.1) then
    n = size(y)
    allocate(arrtmp(n))
    do i=1,n
       arrtmp(i) = (i-1)/(real(n-1))
    enddo
    if (present(symbol)) then
       symbol_c = symbol
       call giza_points(n,arrtmp,real(y,kind=c_double),symbol_c)
    else
       call giza_line(n,arrtmp,real(y,kind=c_double))
    endif
    deallocate(arrtmp)
 endif
 
 if (present(img)) then
    nx = size(img(:,1))
    ny = size(img(1,:))
    if (present(imgmin)) then
       valmin = imgmin
    else
       valmin = minval(img)
    endif
    if (present(imgmax)) then
       valmax = imgmax
    else
       valmax = maxval(img)
    endif
    if (present(affine)) then
       affinei = affine
    else
       dx = real((xmaxi - xmini)/real(nx))
       dy = real((ymaxi - ymini)/real(ny))
       affinei = (/dx,0.d0,0.d0,dy,xmini,ymini/)
    endif
    if (present(extend)) then
       iextend = extend
    else
       iextend = giza_extend_none
    endif
    nx_c = nx; ny_c = ny
    call giza_render(nx_c,ny_c,real(img,kind=c_double),int(1,kind=c_int),&
                     nx_c,int(1,kind=c_int),ny_c,valmin,valmax,iextend,affinei)
 endif
 
 call giza_close()
 
end subroutine giza_plot

end module giza