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
|
<center><a href="https://gitlab.com/petsc/petsc/-/blob/966382dc56242773704ef5f5cee7aa2db3ebc577/include/petscerror.h">Actual source code: petscerror.h</a></center><br>
<html>
<head>
<title></title>
<meta name="generator" content="c2html 0.9.6">
<meta name="date" content="2025-04-30T18:14:50+00:00">
</head>
<body bgcolor="#FFFFFF">
<pre width=80>
<a name="line1"> 1: </a><font color="#B22222">/*</font>
<a name="line2"> 2: </a><font color="#B22222"> Contains all error handling interfaces for PETSc.</font>
<a name="line3"> 3: </a><font color="#B22222">*/</font>
<a name="line4"> 4: </a><font color="#A020F0">#pragma once</font>
<a name="line5"> 5: </a><font color="#B22222">// IWYU pragma: private, include "petscsys.h"</font>
<a name="line7"> 7: </a>#include <A href="../include/petscmacros.h.html"><petscmacros.h></A>
<a name="line8"> 8: </a>#include <A href="../include/petscsystypes.h.html"><petscsystypes.h></A>
<a name="line10"> 10: </a><font color="#A020F0">#if defined(__cplusplus)</font>
<a name="line11"> 11: </a><font color="#A020F0"> #include <exception> // std::exception</font>
<a name="line12"> 12: </a><font color="#A020F0">#endif</font>
<a name="line14"> 14: </a><font color="#B22222">/* SUBMANSEC = Sys */</font>
<a name="line16"> 16: </a><strong><font color="#228B22">#define SETERRQ1(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line17"> 17: </a><strong><font color="#228B22">#define SETERRQ2(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line18"> 18: </a><strong><font color="#228B22">#define SETERRQ3(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line19"> 19: </a><strong><font color="#228B22">#define SETERRQ4(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line20"> 20: </a><strong><font color="#228B22">#define SETERRQ5(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line21"> 21: </a><strong><font color="#228B22">#define SETERRQ6(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line22"> 22: </a><strong><font color="#228B22">#define SETERRQ7(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line23"> 23: </a><strong><font color="#228B22">#define SETERRQ8(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line24"> 24: </a><strong><font color="#228B22">#define SETERRQ9(...) PETSC_DEPRECATED_MACRO(3, 17, 0, </font><font color="#666666">"<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>"</font><font color="#228B22">, ) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(__VA_ARGS__)</font></strong>
<a name="line26"> 26: </a><font color="#B22222">/*MC</font>
<a name="line27"> 27: </a><font color="#B22222"> <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a> - Macro to be called when an error has been detected,</font>
<a name="line29"> 29: </a><font color="#B22222"> Synopsis:</font>
<a name="line30"> 30: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line31"> 31: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, char *message, ...)</font>
<a name="line33"> 33: </a><font color="#B22222"> Collective</font>
<a name="line35"> 35: </a><font color="#B22222"> Input Parameters:</font>
<a name="line36"> 36: </a><font color="#B22222">+ comm - An MPI communicator, use `<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>` unless you know all ranks of another communicator will detect the error</font>
<a name="line37"> 37: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line38"> 38: </a><font color="#B22222">- message - error message</font>
<a name="line40"> 40: </a><font color="#B22222"> Level: beginner</font>
<a name="line42"> 42: </a><font color="#B22222"> Notes:</font>
<a name="line43"> 43: </a><font color="#B22222"> This is rarely needed, one should use `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()` and `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` and friends to automatically handle error conditions.</font>
<a name="line44"> 44: </a><font color="#B22222"> Once the error handler is called the calling function is then returned from with the given error code.</font>
<a name="line46"> 46: </a><font color="#B22222"> Experienced users can set the error handler with `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`.</font>
<a name="line48"> 48: </a><font color="#B22222"> Fortran Note:</font>
<a name="line49"> 49: </a><font color="#B22222"> `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()` may be called from Fortran subroutines but `<a href="../manualpages/Sys/SETERRA.html">SETERRA</a>()` must be called from the</font>
<a name="line50"> 50: </a><font color="#B22222"> Fortran main program.</font>
<a name="line52"> 52: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`,</font>
<a name="line53"> 53: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line54"> 54: </a><font color="#B22222">M*/</font>
<a name="line55"> 55: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(comm, ierr, ...) \</font></strong>
<a name="line56"> 56: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line57"> 57: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_seterrq_petsc_ = <a href="../manualpages/Sys/PetscError.html">PetscError</a>(comm, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_INITIAL</a>, __VA_ARGS__); \</font></strong>
<a name="line58"> 58: </a><strong><font color="#228B22"> return ierr_seterrq_petsc_ ? ierr_seterrq_petsc_ : <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_RETURN</a>; \</font></strong>
<a name="line59"> 59: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line61"> 61: </a><strong><font color="#228B22">#define SETERRQNULL(comm, ierr, ...) \</font></strong>
<a name="line62"> 62: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line63"> 63: </a><strong><font color="#228B22"> (void)<a href="../manualpages/Sys/PetscError.html">PetscError</a>(comm, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_INITIAL</a>, __VA_ARGS__); \</font></strong>
<a name="line64"> 64: </a><strong><font color="#228B22"> return NULL; \</font></strong>
<a name="line65"> 65: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line67"> 67: </a><font color="#B22222">/*</font>
<a name="line68"> 68: </a><font color="#B22222"> Returned from PETSc functions that are called from MPI, such as related to attributes</font>
<a name="line69"> 69: </a><font color="#B22222"> Do not confuse PETSC_MPI_ERROR_CODE and <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_MPI</a>, the first is registered with MPI and returned to MPI as</font>
<a name="line70"> 70: </a><font color="#B22222"> an error code, the latter is a regular PETSc error code passed within PETSc code indicating an error was detected in an MPI call.</font>
<a name="line71"> 71: </a><font color="#B22222">*/</font>
<a name="line72"> 72: </a>PETSC_EXTERN <a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a> PETSC_MPI_ERROR_CLASS;
<a name="line73"> 73: </a>PETSC_EXTERN <a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a> PETSC_MPI_ERROR_CODE;
<a name="line75"> 75: </a><font color="#B22222">/*MC</font>
<a name="line76"> 76: </a><font color="#B22222"> <a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a> - Macro to be called when an error has been detected within an MPI callback function</font>
<a name="line78"> 78: </a><font color="#B22222"> No Fortran Support</font>
<a name="line80"> 80: </a><font color="#B22222"> Synopsis:</font>
<a name="line81"> 81: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line82"> 82: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, char *message, ...)</font>
<a name="line84"> 84: </a><font color="#B22222"> Collective</font>
<a name="line86"> 86: </a><font color="#B22222"> Input Parameters:</font>
<a name="line87"> 87: </a><font color="#B22222">+ comm - An MPI communicator, use `<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>` unless you know all ranks of another communicator will detect the error</font>
<a name="line88"> 88: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line89"> 89: </a><font color="#B22222">- message - error message</font>
<a name="line91"> 91: </a><font color="#B22222"> Level: developer</font>
<a name="line93"> 93: </a><font color="#B22222"> Note:</font>
<a name="line94"> 94: </a><font color="#B22222"> This macro is FOR USE IN MPI CALLBACK FUNCTIONS ONLY, such as those passed to `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Comm_create_keyval.html#MPI_Comm_create_keyval">MPI_Comm_create_keyval</a>()`. It always returns the error code `PETSC_MPI_ERROR_CODE`</font>
<a name="line95"> 95: </a><font color="#B22222"> which is registered with `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Add_error_code.html#MPI_Add_error_code">MPI_Add_error_code</a>()` when PETSc is initialized.</font>
<a name="line97"> 97: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line98"> 98: </a><font color="#B22222">M*/</font>
<a name="line99"> 99: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a>(comm, ierr, ...) return ((void)<a href="../manualpages/Sys/PetscError.html">PetscError</a>(comm, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_INITIAL</a>, __VA_ARGS__), PETSC_MPI_ERROR_CODE)</font></strong>
<a name="line101">101: </a><font color="#B22222">/*MC</font>
<a name="line102">102: </a><font color="#B22222"> <a href="../manualpages/Sys/SETERRA.html">SETERRA</a> - Fortran-only macro that can be called when an error has been detected from the main program</font>
<a name="line104">104: </a><font color="#B22222"> Synopsis:</font>
<a name="line105">105: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line106">106: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/SETERRA.html">SETERRA</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, char *message)</font>
<a name="line108">108: </a><font color="#B22222"> Collective</font>
<a name="line110">110: </a><font color="#B22222"> Input Parameters:</font>
<a name="line111">111: </a><font color="#B22222">+ comm - An MPI communicator, so that the error can be collective</font>
<a name="line112">112: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line113">113: </a><font color="#B22222">- message - error message in the `printf()` format</font>
<a name="line115">115: </a><font color="#B22222"> Level: beginner</font>
<a name="line117">117: </a><font color="#B22222"> Notes:</font>
<a name="line118">118: </a><font color="#B22222"> This should only be used with Fortran. With C/C++, use `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`.</font>
<a name="line120">120: </a><font color="#B22222"> `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()` may be called from Fortran subroutines but `<a href="../manualpages/Sys/SETERRA.html">SETERRA</a>()` must be called from the</font>
<a name="line121">121: </a><font color="#B22222"> Fortran main program.</font>
<a name="line123">123: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line124">124: </a><font color="#B22222">M*/</font>
<a name="line126">126: </a><font color="#B22222">/*MC</font>
<a name="line127">127: </a><font color="#B22222"> <a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a> - Macro that can be called when an error has been detected,</font>
<a name="line129">129: </a><font color="#B22222"> Synopsis:</font>
<a name="line130">130: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line131">131: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, char *message, ...)</font>
<a name="line133">133: </a><font color="#B22222"> Collective</font>
<a name="line135">135: </a><font color="#B22222"> Input Parameters:</font>
<a name="line136">136: </a><font color="#B22222">+ comm - An MPI communicator, so that the error can be collective</font>
<a name="line137">137: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line138">138: </a><font color="#B22222">- message - error message in the `printf()` format</font>
<a name="line140">140: </a><font color="#B22222"> Level: beginner</font>
<a name="line142">142: </a><font color="#B22222"> Notes:</font>
<a name="line143">143: </a><font color="#B22222"> This function just calls `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()`.</font>
<a name="line145">145: </a><font color="#B22222"> This should only be called in routines that cannot return an error code, such as in C++ constructors.</font>
<a name="line147">147: </a><font color="#B22222"> Fortran Note:</font>
<a name="line148">148: </a><font color="#B22222"> Use `<a href="../manualpages/Sys/SETERRA.html">SETERRA</a>()` in Fortran main program and `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()` in Fortran subroutines</font>
<a name="line150">150: </a><font color="#B22222"> Developer Note:</font>
<a name="line151">151: </a><font color="#B22222"> In Fortran `<a href="../manualpages/Sys/SETERRA.html">SETERRA</a>()` could be called `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()` since they serve the same purpose</font>
<a name="line153">153: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line154">154: </a><font color="#B22222">M*/</font>
<a name="line155">155: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>(comm, ierr, ...) \</font></strong>
<a name="line156">156: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line157">157: </a><strong><font color="#228B22"> (void)<a href="../manualpages/Sys/PetscError.html">PetscError</a>(comm, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_INITIAL</a>, __VA_ARGS__); \</font></strong>
<a name="line158">158: </a><strong><font color="#228B22"> (void)<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>(comm, ierr); \</font></strong>
<a name="line159">159: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line161">161: </a><font color="#B22222">/*MC</font>
<a name="line162">162: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a> - Checks that a particular condition is true; if not true, then returns the provided error code</font>
<a name="line164">164: </a><font color="#B22222"> Synopsis:</font>
<a name="line165">165: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line166">166: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>(bool cond, <a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, const char *message, ...)</font>
<a name="line168">168: </a><font color="#B22222"> Collective; No Fortran Support</font>
<a name="line170">170: </a><font color="#B22222"> Input Parameters:</font>
<a name="line171">171: </a><font color="#B22222">+ cond - The boolean condition</font>
<a name="line172">172: </a><font color="#B22222">. comm - The communicator on which the check can be collective on</font>
<a name="line173">173: </a><font color="#B22222">. ierr - A nonzero error code, see include/petscerror.h for the complete list</font>
<a name="line174">174: </a><font color="#B22222">- message - Error message in the `printf()` format</font>
<a name="line176">176: </a><font color="#B22222"> Level: beginner</font>
<a name="line178">178: </a><font color="#B22222"> Notes:</font>
<a name="line179">179: </a><font color="#B22222"> Enabled in both optimized and debug builds.</font>
<a name="line181">181: </a><font color="#B22222"> As a general rule, `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()` is used to check "usage error" (for example, passing an incorrect value as a function argument),</font>
<a name="line182">182: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()` is used to "check for bugs in PETSc" (for example, is a value in a PETSc data structure nonsensical).</font>
<a name="line183">183: </a><font color="#B22222"> However, for functions that are called in a "hot spot", for example, thousands of times in a loop, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()` should be used instead</font>
<a name="line184">184: </a><font color="#B22222"> of `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()` since the former is compiled out in PETSc's optimization code.</font>
<a name="line186">186: </a><font color="#B22222"> Calls `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()` if the assertion fails, so can only be called from functions returning a</font>
<a name="line187">187: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` (or equivalent type after conversion).</font>
<a name="line189">189: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/PetscCheckReturnMPI.html">PetscCheckReturnMPI</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line190">190: </a><font color="#B22222">M*/</font>
<a name="line191">191: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>(cond, comm, ierr, ...) \</font></strong>
<a name="line192">192: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line193">193: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(!(cond))) <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>(comm, ierr, __VA_ARGS__); \</font></strong>
<a name="line194">194: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line196">196: </a><font color="#B22222">/*MC</font>
<a name="line197">197: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCheckReturnMPI.html">PetscCheckReturnMPI</a> - Checks that a particular condition is true; if not true, then returns an MPI error code.</font>
<a name="line198">198: </a><font color="#B22222"> To check for errors in PETSc-provided MPI callbacks.</font>
<a name="line200">200: </a><font color="#B22222"> Synopsis:</font>
<a name="line201">201: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line202">202: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCheckReturnMPI.html">PetscCheckReturnMPI</a>(bool cond, <a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, const char *message, ...)</font>
<a name="line204">204: </a><font color="#B22222"> Collective; No Fortran Support</font>
<a name="line206">206: </a><font color="#B22222"> Input Parameters:</font>
<a name="line207">207: </a><font color="#B22222">+ cond - The boolean condition</font>
<a name="line208">208: </a><font color="#B22222">. comm - The communicator on which the check can be collective on</font>
<a name="line209">209: </a><font color="#B22222">. ierr - A nonzero error code, see include/petscerror.h for the complete list</font>
<a name="line210">210: </a><font color="#B22222">- message - Error message in the `printf()` format</font>
<a name="line212">212: </a><font color="#B22222"> Level: beginner</font>
<a name="line214">214: </a><font color="#B22222"> Note:</font>
<a name="line215">215: </a><font color="#B22222"> Enabled in both optimized and debug builds.</font>
<a name="line217">217: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line218">218: </a><font color="#B22222">M*/</font>
<a name="line219">219: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/PetscCheckReturnMPI.html">PetscCheckReturnMPI</a>(cond, comm, ierr, ...) \</font></strong>
<a name="line220">220: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line221">221: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(!(cond))) <a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a>(comm, ierr, __VA_ARGS__); \</font></strong>
<a name="line222">222: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line224">224: </a><font color="#B22222">/*MC</font>
<a name="line225">225: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a> - Check that a particular condition is true, otherwise prints error and aborts</font>
<a name="line227">227: </a><font color="#B22222"> Synopsis:</font>
<a name="line228">228: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line229">229: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>(bool cond, <a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, const char *message, ...)</font>
<a name="line231">231: </a><font color="#B22222"> Collective; No Fortran Support</font>
<a name="line233">233: </a><font color="#B22222"> Input Parameters:</font>
<a name="line234">234: </a><font color="#B22222">+ cond - The boolean condition</font>
<a name="line235">235: </a><font color="#B22222">. comm - The communicator on which the check can be collective on</font>
<a name="line236">236: </a><font color="#B22222">. ierr - A nonzero error code, see include/petscerror.h for the complete list</font>
<a name="line237">237: </a><font color="#B22222">- message - Error message in the `printf()` format</font>
<a name="line239">239: </a><font color="#B22222"> Level: developer</font>
<a name="line241">241: </a><font color="#B22222"> Notes:</font>
<a name="line242">242: </a><font color="#B22222"> Enabled in both optimized and debug builds.</font>
<a name="line244">244: </a><font color="#B22222"> Calls `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()` if the assertion fails, can be called from a function that does not return an</font>
<a name="line245">245: </a><font color="#B22222"> error code, such as a C++ constructor. usually `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()` should be used.</font>
<a name="line247">247: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAssertAbort.html">PetscAssertAbort</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line248">248: </a><font color="#B22222">M*/</font>
<a name="line249">249: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>(cond, comm, ierr, ...) \</font></strong>
<a name="line250">250: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line251">251: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(!(cond))) <a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>(comm, ierr, __VA_ARGS__); \</font></strong>
<a name="line252">252: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line254">254: </a><font color="#B22222">/*MC</font>
<a name="line255">255: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a> - Assert that a particular condition is true</font>
<a name="line257">257: </a><font color="#B22222"> Synopsis:</font>
<a name="line258">258: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line259">259: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>(bool cond, <a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, const char *message, ...)</font>
<a name="line261">261: </a><font color="#B22222"> Collective; No Fortran Support</font>
<a name="line263">263: </a><font color="#B22222"> Input Parameters:</font>
<a name="line264">264: </a><font color="#B22222">+ cond - The boolean condition</font>
<a name="line265">265: </a><font color="#B22222">. comm - The communicator on which the check can be collective on</font>
<a name="line266">266: </a><font color="#B22222">. ierr - A nonzero error code, see include/petscerror.h for the complete list</font>
<a name="line267">267: </a><font color="#B22222">- message - Error message in `printf()` format</font>
<a name="line269">269: </a><font color="#B22222"> Level: beginner</font>
<a name="line271">271: </a><font color="#B22222"> Notes:</font>
<a name="line272">272: </a><font color="#B22222"> Equivalent to `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()` if debugging is enabled, and `<a href="../manualpages/Sys/PetscAssume.html">PetscAssume</a>(cond)` otherwise.</font>
<a name="line274">274: </a><font color="#B22222"> See `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()` for usage and behaviour.</font>
<a name="line276">276: </a><font color="#B22222"> This is needed instead of simply using `assert()` because this correctly handles the collective nature of errors under MPI</font>
<a name="line278">278: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/PetscAssertAbort.html">PetscAssertAbort</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line279">279: </a><font color="#B22222">M*/</font>
<a name="line280">280: </a><font color="#A020F0">#if <a href="../manualpages/Sys/PetscDefined.html">PetscDefined</a>(USE_DEBUG)</font>
<a name="line281">281: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>(cond, comm, ierr, ...) <a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>(cond, comm, ierr, __VA_ARGS__)</font></strong>
<a name="line282">282: </a><font color="#A020F0">#else</font>
<a name="line283">283: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>(cond, ...) <a href="../manualpages/Sys/PetscAssume.html">PetscAssume</a>(cond)</font></strong>
<a name="line284">284: </a><font color="#A020F0">#endif</font>
<a name="line286">286: </a><font color="#B22222">/*MC</font>
<a name="line287">287: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscAssertAbort.html">PetscAssertAbort</a> - Assert that a particular condition is true, otherwise prints error and aborts</font>
<a name="line289">289: </a><font color="#B22222"> Synopsis:</font>
<a name="line290">290: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line291">291: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscAssertAbort.html">PetscAssertAbort</a>(bool cond, <a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr, const char *message, ...)</font>
<a name="line293">293: </a><font color="#B22222"> Collective; No Fortran Support</font>
<a name="line295">295: </a><font color="#B22222"> Input Parameters:</font>
<a name="line296">296: </a><font color="#B22222">+ cond - The boolean condition</font>
<a name="line297">297: </a><font color="#B22222">. comm - The communicator on which the check can be collective on</font>
<a name="line298">298: </a><font color="#B22222">. ierr - A nonzero error code, see include/petscerror.h for the complete list</font>
<a name="line299">299: </a><font color="#B22222">- message - Error message in the `printf()` format</font>
<a name="line301">301: </a><font color="#B22222"> Level: beginner</font>
<a name="line303">303: </a><font color="#B22222"> Note:</font>
<a name="line304">304: </a><font color="#B22222"> Enabled only in debug builds. See `<a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>()` for usage.</font>
<a name="line306">306: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`</font>
<a name="line307">307: </a><font color="#B22222">M*/</font>
<a name="line308">308: </a><font color="#A020F0">#if <a href="../manualpages/Sys/PetscDefined.html">PetscDefined</a>(USE_DEBUG)</font>
<a name="line309">309: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscAssertAbort.html">PetscAssertAbort</a>(cond, comm, ierr, ...) <a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>(cond, comm, ierr, __VA_ARGS__)</font></strong>
<a name="line310">310: </a><font color="#A020F0">#else</font>
<a name="line311">311: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscAssertAbort.html">PetscAssertAbort</a>(cond, comm, ierr, ...) <a href="../manualpages/Sys/PetscAssume.html">PetscAssume</a>(cond)</font></strong>
<a name="line312">312: </a><font color="#A020F0">#endif</font>
<a name="line314">314: </a><font color="#B22222">/*MC</font>
<a name="line315">315: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCall.html">PetscCall</a> - Calls a PETSc function and then checks the resulting error code, if it is</font>
<a name="line316">316: </a><font color="#B22222"> non-zero it calls the error handler and returns from the current function with the error</font>
<a name="line317">317: </a><font color="#B22222"> code.</font>
<a name="line319">319: </a><font color="#B22222"> Synopsis:</font>
<a name="line320">320: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line321">321: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(PetscFunction(args))</font>
<a name="line323">323: </a><font color="#B22222"> Not Collective</font>
<a name="line325">325: </a><font color="#B22222"> Input Parameter:</font>
<a name="line326">326: </a><font color="#B22222">. PetscFunction - any PETSc function that returns an error code</font>
<a name="line328">328: </a><font color="#B22222"> Level: beginner</font>
<a name="line330">330: </a><font color="#B22222"> Notes:</font>
<a name="line331">331: </a><font color="#B22222"> Once the error handler is called the calling function is then returned from with the given</font>
<a name="line332">332: </a><font color="#B22222"> error code. Experienced users can set the error handler with `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`.</font>
<a name="line334">334: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` cannot be used in functions returning a datatype not convertible to</font>
<a name="line335">335: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`. For example, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` may not be used in functions returning `void`, use</font>
<a name="line336">336: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()` or `<a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>()` in this case.</font>
<a name="line338">338: </a><font color="#B22222"> Example Usage:</font>
<a name="line339">339: </a><font color="#B22222">.vb</font>
<a name="line340">340: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(PetscInitiailize(...)); // OK to call even when PETSc is not yet initialized!</font>
<a name="line342">342: </a><font color="#B22222"> struct my_struct</font>
<a name="line343">343: </a><font color="#B22222"> {</font>
<a name="line344">344: </a><font color="#B22222"> void *data;</font>
<a name="line345">345: </a><font color="#B22222"> } my_complex_type;</font>
<a name="line347">347: </a><font color="#B22222"> struct my_struct bar(void)</font>
<a name="line348">348: </a><font color="#B22222"> {</font>
<a name="line349">349: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(foo(15)); // ERROR <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> not convertible to struct my_struct!</font>
<a name="line350">350: </a><font color="#B22222"> }</font>
<a name="line352">352: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(bar()) // ERROR input not convertible to <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a></font>
<a name="line353">353: </a><font color="#B22222">.ve</font>
<a name="line355">355: </a><font color="#B22222"> It is also possible to call this directly on a `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` variable</font>
<a name="line356">356: </a><font color="#B22222">.vb</font>
<a name="line357">357: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(ierr); // check if ierr is nonzero</font>
<a name="line358">358: </a><font color="#B22222">.ve</font>
<a name="line360">360: </a><font color="#B22222"> Should not be used to call callback functions provided by users, `<a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>()` should be used in that situation.</font>
<a name="line362">362: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscUseTypeMethod.html">PetscUseTypeMethod</a>()` or `<a href="../manualpages/Sys/PetscTryTypeMethod.html">PetscTryTypeMethod</a>()` should be used when calling functions pointers contained in a PETSc object's `ops` array</font>
<a name="line364">364: </a><font color="#B22222"> Fortran Notes:</font>
<a name="line365">365: </a><font color="#B22222"> The Fortran function in which this is used must declare a `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` variable necessarily named `ierr`, and `ierr` must be</font>
<a name="line366">366: </a><font color="#B22222"> the final argument to the PETSc function being called.</font>
<a name="line368">368: </a><font color="#B22222"> In the main program and in Fortran subroutines that do not have `ierr` as the final return parameter, one</font>
<a name="line369">369: </a><font color="#B22222"> should use `<a href="../manualpages/Sys/PetscCallA.html">PetscCallA</a>()`</font>
<a name="line371">371: </a><font color="#B22222"> Example Fortran Usage:</font>
<a name="line372">372: </a><font color="#B22222">.vb</font>
<a name="line373">373: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr</font>
<a name="line374">374: </a><font color="#B22222"> <a href="../manualpages/Vec/Vec.html">Vec</a> v</font>
<a name="line376">376: </a><font color="#B22222"> ...</font>
<a name="line377">377: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(<a href="../manualpages/Vec/VecShift.html">VecShift</a>(v, 1.0, ierr))</font>
<a name="line378">378: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallA.html">PetscCallA</a>(<a href="../manualpages/Vec/VecShift.html">VecShift</a>(v, 1.0, ierr))</font>
<a name="line379">379: </a><font color="#B22222">.ve</font>
<a name="line381">381: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`,</font>
<a name="line382">382: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>()`,</font>
<a name="line383">383: </a><font color="#B22222"> `<a href="../manualpages/Sys/CHKERRMPI.html">CHKERRMPI</a>()`, `<a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>()`, `<a href="../manualpages/Sys/PetscCallNull.html">PetscCallNull</a>()`</font>
<a name="line384">384: </a><font color="#B22222">M*/</font>
<a name="line386">386: </a><font color="#B22222">/*MC</font>
<a name="line387">387: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallNull.html">PetscCallNull</a> - Calls a PETSc function and then checks the resulting error code, if it is</font>
<a name="line388">388: </a><font color="#B22222"> non-zero it calls the error handler and returns a `NULL`</font>
<a name="line390">390: </a><font color="#B22222"> Synopsis:</font>
<a name="line391">391: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line392">392: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallNull.html">PetscCallNull</a>(PetscFunction(args))</font>
<a name="line394">394: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line396">396: </a><font color="#B22222"> Input Parameter:</font>
<a name="line397">397: </a><font color="#B22222">. PetscFunction - any PETSc function that returns something that can be returned as a `NULL`</font>
<a name="line399">399: </a><font color="#B22222"> Level: developer</font>
<a name="line401">401: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`,</font>
<a name="line402">402: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>()`,</font>
<a name="line403">403: </a><font color="#B22222"> `<a href="../manualpages/Sys/CHKERRMPI.html">CHKERRMPI</a>()`, `<a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`</font>
<a name="line404">404: </a><font color="#B22222">M*/</font>
<a name="line406">406: </a><font color="#B22222">/*MC</font>
<a name="line407">407: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallA.html">PetscCallA</a> - Fortran-only macro that should be used in the main program and subroutines that do not have `ierr` as the final return parameter, to call PETSc functions instead of using</font>
<a name="line408">408: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` which should be used in other Fortran subroutines</font>
<a name="line410">410: </a><font color="#B22222"> Synopsis:</font>
<a name="line411">411: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line412">412: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscCallA.html">PetscCallA</a>(PetscFunction(arguments, ierr))</font>
<a name="line414">414: </a><font color="#B22222"> Collective</font>
<a name="line416">416: </a><font color="#B22222"> Input Parameter:</font>
<a name="line417">417: </a><font color="#B22222">. PetscFunction(arguments,ierr) - the call to the function</font>
<a name="line419">419: </a><font color="#B22222"> Level: beginner</font>
<a name="line421">421: </a><font color="#B22222"> Notes:</font>
<a name="line422">422: </a><font color="#B22222"> This should only be used with Fortran. With C/C++, use `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` always.</font>
<a name="line424">424: </a><font color="#B22222"> The Fortran function in which this is used must declare a `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` variable necessarily named `ierr`</font>
<a name="line425">425: </a><font color="#B22222"> Use `<a href="../manualpages/Sys/SETERRA.html">SETERRA</a>()` to set an error in a Fortran main program and `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()` in Fortran subroutines</font>
<a name="line427">427: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/SETERRA.html">SETERRA</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`</font>
<a name="line428">428: </a><font color="#B22222">M*/</font>
<a name="line430">430: </a><font color="#B22222">/*MC</font>
<a name="line431">431: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a> - Calls a user provided PETSc callback function and then checks the resulting error code, if it is non-zero it calls the error</font>
<a name="line432">432: </a><font color="#B22222"> handler and returns from the current function with the error code.</font>
<a name="line434">434: </a><font color="#B22222"> Synopsis:</font>
<a name="line435">435: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line436">436: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>(const char *functionname, PetscFunction(args))</font>
<a name="line438">438: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line440">440: </a><font color="#B22222"> Input Parameters:</font>
<a name="line441">441: </a><font color="#B22222">+ functionname - the name of the function being called, this can be a string with spaces that describes the meaning of the callback</font>
<a name="line442">442: </a><font color="#B22222">- PetscFunction - user provided callback function that returns an error code</font>
<a name="line444">444: </a><font color="#B22222"> Example Usage:</font>
<a name="line445">445: </a><font color="#B22222">.vb</font>
<a name="line446">446: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>("XXX callback to do something", a->callback(...));</font>
<a name="line447">447: </a><font color="#B22222">.ve</font>
<a name="line449">449: </a><font color="#B22222"> Level: developer</font>
<a name="line451">451: </a><font color="#B22222"> Notes:</font>
<a name="line452">452: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscUseTypeMethod.html">PetscUseTypeMethod</a>()` and ` <a href="../manualpages/Sys/PetscTryTypeMethod.html">PetscTryTypeMethod</a>()` are the preferred API for this functionality. But when the callback functions are associated with a</font>
<a name="line453">453: </a><font color="#B22222"> `<a href="../manualpages/SNES/DMSNES.html">DMSNES</a>` or `<a href="../manualpages/TS/DMTS.html">DMTS</a>` this API must be used.</font>
<a name="line455">455: </a><font color="#B22222"> Once the error handler is called the calling function is then returned from with the given</font>
<a name="line456">456: </a><font color="#B22222"> error code. Experienced users can set the error handler with `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`.</font>
<a name="line458">458: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>()` should only be called in PETSc when a call is being made to a user provided call-back routine.</font>
<a name="line460">460: </a><font color="#B22222"> Developer Note:</font>
<a name="line461">461: </a><font color="#B22222"> It would be good to provide a new API for when the callbacks are associated with `<a href="../manualpages/SNES/DMSNES.html">DMSNES</a>` or `<a href="../manualpages/TS/DMTS.html">DMTS</a>` so this routine could be used less</font>
<a name="line463">463: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`</font>
<a name="line464">464: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>()`, `<a href="../manualpages/Sys/CHKERRMPI.html">CHKERRMPI</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscUseTypeMethod.html">PetscUseTypeMethod</a>()`, `<a href="../manualpages/Sys/PetscTryTypeMethod.html">PetscTryTypeMethod</a>()`</font>
<a name="line465">465: </a><font color="#B22222">M*/</font>
<a name="line467">467: </a><font color="#B22222">/*MC</font>
<a name="line468">468: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a> - Like `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` but for use in functions that return `void`</font>
<a name="line470">470: </a><font color="#B22222"> Synopsis:</font>
<a name="line471">471: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line472">472: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>(PetscFunction(args))</font>
<a name="line474">474: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line476">476: </a><font color="#B22222"> Input Parameter:</font>
<a name="line477">477: </a><font color="#B22222">. PetscFunction - any PETSc function that returns an error code</font>
<a name="line479">479: </a><font color="#B22222"> Example Usage:</font>
<a name="line480">480: </a><font color="#B22222">.vb</font>
<a name="line481">481: </a><font color="#B22222"> void foo()</font>
<a name="line482">482: </a><font color="#B22222"> {</font>
<a name="line483">483: </a><font color="#B22222"> <a href="../manualpages/KSP/KSP.html">KSP</a> ksp;</font>
<a name="line485">485: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>;</font>
<a name="line486">486: </a><font color="#B22222"> // OK, properly handles PETSc error codes</font>
<a name="line487">487: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>(<a href="../manualpages/KSP/KSPCreate.html">KSPCreate</a>(<a href="../manualpages/Sys/PETSC_COMM_WORLD.html">PETSC_COMM_WORLD</a>, &ksp));</font>
<a name="line488">488: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>();</font>
<a name="line489">489: </a><font color="#B22222"> }</font>
<a name="line491">491: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> bar()</font>
<a name="line492">492: </a><font color="#B22222"> {</font>
<a name="line493">493: </a><font color="#B22222"> <a href="../manualpages/KSP/KSP.html">KSP</a> ksp;</font>
<a name="line495">495: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>;</font>
<a name="line496">496: </a><font color="#B22222"> // ERROR, Non-void function 'bar' should return a value</font>
<a name="line497">497: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>(<a href="../manualpages/KSP/KSPCreate.html">KSPCreate</a>(<a href="../manualpages/Sys/PETSC_COMM_WORLD.html">PETSC_COMM_WORLD</a>, &ksp));</font>
<a name="line498">498: </a><font color="#B22222"> // OK, returning <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a></font>
<a name="line499">499: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(<a href="../manualpages/KSP/KSPCreate.html">KSPCreate</a>(<a href="../manualpages/Sys/PETSC_COMM_WORLD.html">PETSC_COMM_WORLD</a>, &ksp));</font>
<a name="line500">500: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>);</font>
<a name="line501">501: </a><font color="#B22222"> }</font>
<a name="line502">502: </a><font color="#B22222">.ve</font>
<a name="line504">504: </a><font color="#B22222"> Level: beginner</font>
<a name="line506">506: </a><font color="#B22222"> Notes:</font>
<a name="line507">507: </a><font color="#B22222"> Has identical usage to `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, except that it returns `void` on error instead of a</font>
<a name="line508">508: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`. See `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` for more detailed discussion.</font>
<a name="line510">510: </a><font color="#B22222"> Note that users should prefer `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()` to this routine. While this routine does</font>
<a name="line511">511: </a><font color="#B22222"> "handle" errors by returning from the enclosing function, it effectively gobbles the</font>
<a name="line512">512: </a><font color="#B22222"> error. Since the enclosing function itself returns `void`, its callers have no way of knowing</font>
<a name="line513">513: </a><font color="#B22222"> that the routine returned early due to an error. `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()` at least ensures that the</font>
<a name="line514">514: </a><font color="#B22222"> program crashes gracefully.</font>
<a name="line516">516: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscCallNull.html">PetscCallNull</a>()`</font>
<a name="line517">517: </a><font color="#B22222">M*/</font>
<a name="line519">519: </a><font color="#B22222">/*MC</font>
<a name="line520">520: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallReturnMPI.html">PetscCallReturnMPI</a> - Calls a PETSc function and then checks the resulting error code, if it is</font>
<a name="line521">521: </a><font color="#B22222"> non-zero it calls the error handler and returns from the current function with an MPI error code.</font>
<a name="line522">522: </a><font color="#B22222"> To check for errors in PETSc provided MPI callbacks.</font>
<a name="line524">524: </a><font color="#B22222"> Synopsis:</font>
<a name="line525">525: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line526">526: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallReturnMPI.html">PetscCallReturnMPI</a>(PetscFunction(args))</font>
<a name="line528">528: </a><font color="#B22222"> Not Collective</font>
<a name="line530">530: </a><font color="#B22222"> Input Parameter:</font>
<a name="line531">531: </a><font color="#B22222">. PetscFunction - any PETSc function that returns an error code</font>
<a name="line533">533: </a><font color="#B22222"> Level: advanced</font>
<a name="line535">535: </a><font color="#B22222"> Notes:</font>
<a name="line536">536: </a><font color="#B22222"> Note to be confused with `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`.</font>
<a name="line538">538: </a><font color="#B22222"> This is be used in a PETSc-provided MPI callback function, such as `MPI_Comm_delete_attr_function function()`.</font>
<a name="line540">540: </a><font color="#B22222"> Currently, it always returns `MPI_ERR_OTHER` on failure</font>
<a name="line542">542: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>()`, `<a href="../manualpages/Sys/PetscAssert.html">PetscAssert</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`,</font>
<a name="line543">543: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>()`,</font>
<a name="line544">544: </a><font color="#B22222"> `<a href="../manualpages/Sys/CHKERRMPI.html">CHKERRMPI</a>()`, `<a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>()`, `<a href="../manualpages/Sys/PetscCallNull.html">PetscCallNull</a>()`</font>
<a name="line545">545: </a><font color="#B22222">M*/</font>
<a name="line547">547: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER)</font>
<a name="line548">548: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line549">549: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>(const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line550">550: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line551">551: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallNull.html">PetscCallNull</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line552">552: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallReturnMPI.html">PetscCallReturnMPI</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line553">553: </a><font color="#A020F0">#else</font>
<a name="line554">554: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(...) \</font></strong>
<a name="line555">555: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line556">556: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_q_; \</font></strong>
<a name="line557">557: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line558">558: </a><strong><font color="#228B22"> ierr_petsc_call_q_ = __VA_ARGS__; \</font></strong>
<a name="line559">559: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_q_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) return <a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_call_q_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line560">560: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line561">561: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallNull.html">PetscCallNull</a>(...) \</font></strong>
<a name="line562">562: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line563">563: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_q_; \</font></strong>
<a name="line564">564: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line565">565: </a><strong><font color="#228B22"> ierr_petsc_call_q_ = __VA_ARGS__; \</font></strong>
<a name="line566">566: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_q_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) { \</font></strong>
<a name="line567">567: </a><strong><font color="#228B22"> (void)<a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_PLIB</a>, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_INITIAL</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line568">568: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(NULL); \</font></strong>
<a name="line569">569: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line570">570: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line571">571: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>(function, ...) \</font></strong>
<a name="line572">572: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line573">573: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_q_; \</font></strong>
<a name="line574">574: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line575">575: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>(function); \</font></strong>
<a name="line576">576: </a><strong><font color="#228B22"> ierr_petsc_call_q_ = __VA_ARGS__; \</font></strong>
<a name="line577">577: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>; \</font></strong>
<a name="line578">578: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_q_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) return <a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_call_q_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line579">579: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line580">580: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>(...) \</font></strong>
<a name="line581">581: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line582">582: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_void_; \</font></strong>
<a name="line583">583: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line584">584: </a><strong><font color="#228B22"> ierr_petsc_call_void_ = __VA_ARGS__; \</font></strong>
<a name="line585">585: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_void_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) { \</font></strong>
<a name="line586">586: </a><strong><font color="#228B22"> (void)<a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_call_void_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line587">587: </a><strong><font color="#228B22"> return; \</font></strong>
<a name="line588">588: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line589">589: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line590">590: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallReturnMPI.html">PetscCallReturnMPI</a>(...) \</font></strong>
<a name="line591">591: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line592">592: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_q_; \</font></strong>
<a name="line593">593: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line594">594: </a><strong><font color="#228B22"> ierr_petsc_call_q_ = __VA_ARGS__; \</font></strong>
<a name="line595">595: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_q_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) { \</font></strong>
<a name="line596">596: </a><strong><font color="#228B22"> (void)<a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_call_q_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line597">597: </a><strong><font color="#228B22"> return MPI_ERR_OTHER; \</font></strong>
<a name="line598">598: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line599">599: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line600">600: </a><font color="#A020F0">#endif</font>
<a name="line602">602: </a><font color="#B22222">/*MC</font>
<a name="line603">603: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKERRQ.html">CHKERRQ</a> - Checks error code returned from PETSc function</font>
<a name="line605">605: </a><font color="#B22222"> Synopsis:</font>
<a name="line606">606: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line607">607: </a><font color="#B22222"> void <a href="../manualpages/Sys/CHKERRQ.html">CHKERRQ</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line609">609: </a><font color="#B22222"> Not Collective</font>
<a name="line611">611: </a><font color="#B22222"> Input Parameter:</font>
<a name="line612">612: </a><font color="#B22222">. ierr - nonzero error code</font>
<a name="line614">614: </a><font color="#B22222"> Level: deprecated</font>
<a name="line616">616: </a><font color="#B22222"> Note:</font>
<a name="line617">617: </a><font color="#B22222"> Deprecated in favor of `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`. This routine behaves identically to it.</font>
<a name="line619">619: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`</font>
<a name="line620">620: </a><font color="#B22222">M*/</font>
<a name="line621">621: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/CHKERRQ.html">CHKERRQ</a>(...) <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>(__VA_ARGS__)</font></strong>
<a name="line622">622: </a><strong><font color="#228B22">#define CHKERRV(...) <a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>(__VA_ARGS__)</font></strong>
<a name="line624">624: </a><strong><font color="#4169E1">PETSC_EXTERN void <a href="../manualpages/Sys/PetscMPIErrorString.html">PetscMPIErrorString</a>(<a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a>, size_t, char *)</font></strong>;
<a name="line626">626: </a><font color="#B22222">/*MC</font>
<a name="line627">627: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a> - Checks error code returned from MPI calls, if non-zero it calls the error</font>
<a name="line628">628: </a><font color="#B22222"> handler and then returns a `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line630">630: </a><font color="#B22222"> Synopsis:</font>
<a name="line631">631: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line632">632: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(MPI_Function(args))</font>
<a name="line634">634: </a><font color="#B22222"> Not Collective</font>
<a name="line636">636: </a><font color="#B22222"> Input Parameter:</font>
<a name="line637">637: </a><font color="#B22222">. MPI_Function - an MPI function that returns an MPI error code</font>
<a name="line639">639: </a><font color="#B22222"> Level: beginner</font>
<a name="line641">641: </a><font color="#B22222"> Notes:</font>
<a name="line642">642: </a><font color="#B22222"> Always returns the error code `<a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_MPI</a>`; the MPI error code and string are embedded in</font>
<a name="line643">643: </a><font color="#B22222"> the string error message. Do not use this to call any other routines (for example PETSc</font>
<a name="line644">644: </a><font color="#B22222"> routines), it should only be used for direct MPI calls. The user may configure PETSc with the</font>
<a name="line645">645: </a><font color="#B22222"> `--with-strict-petscerrorcode` option to check this at compile-time, otherwise they must</font>
<a name="line646">646: </a><font color="#B22222"> check this themselves.</font>
<a name="line648">648: </a><font color="#B22222"> This routine can only be used in functions returning `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` themselves. If the</font>
<a name="line649">649: </a><font color="#B22222"> calling function returns a different type, use `<a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>()` instead.</font>
<a name="line651">651: </a><font color="#B22222"> Example Usage:</font>
<a name="line652">652: </a><font color="#B22222">.vb</font>
<a name="line653">653: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Comm_size.html#MPI_Comm_size">MPI_Comm_size</a>(...)); // OK, calling MPI function</font>
<a name="line655">655: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(PetscFunction(...)); // ERROR, use <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>() instead!</font>
<a name="line656">656: </a><font color="#B22222">.ve</font>
<a name="line658">658: </a><font color="#B22222"> Fortran Notes:</font>
<a name="line659">659: </a><font color="#B22222"> The Fortran function from which this is used must declare a variable `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` ierr and ierr must be</font>
<a name="line660">660: </a><font color="#B22222"> the final argument to the MPI function being called.</font>
<a name="line662">662: </a><font color="#B22222"> In the main program and in Fortran subroutines that do not have ierr as the final return parameter one</font>
<a name="line663">663: </a><font color="#B22222"> should use `PetscCallMPIA()`</font>
<a name="line665">665: </a><font color="#B22222"> Fortran Usage:</font>
<a name="line666">666: </a><font color="#B22222">.vb</font>
<a name="line667">667: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr or integer ierr</font>
<a name="line668">668: </a><font color="#B22222"> ...</font>
<a name="line669">669: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Comm_size.html#MPI_Comm_size">MPI_Comm_size</a>(...,ierr))</font>
<a name="line670">670: </a><font color="#B22222"> PetscCallMPIA(<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Comm_size.html#MPI_Comm_size">MPI_Comm_size</a>(...,ierr)) ! Will abort after calling error handler</font>
<a name="line672">672: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Comm_size.html#MPI_Comm_size">MPI_Comm_size</a>(...,eflag)) ! ERROR, final argument must be ierr</font>
<a name="line673">673: </a><font color="#B22222">.ve</font>
<a name="line675">675: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCallReturnMPI.html">PetscCallReturnMPI</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`,</font>
<a name="line676">676: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`,</font>
<a name="line677">677: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/PetscCallMPINull.html">PetscCallMPINull</a>()`</font>
<a name="line678">678: </a><font color="#B22222">M*/</font>
<a name="line680">680: </a><font color="#B22222">/*MC</font>
<a name="line681">681: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPIReturnMPI.html">PetscCallMPIReturnMPI</a> - Checks error code returned from MPI calls, if non-zero it calls the error</font>
<a name="line682">682: </a><font color="#B22222"> handler and then returns an MPI error code. To check for errors in PETSc-provided MPI callbacks.</font>
<a name="line684">684: </a><font color="#B22222"> Synopsis:</font>
<a name="line685">685: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line686">686: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallMPIReturnMPI.html">PetscCallMPIReturnMPI</a>(MPI_Function(args))</font>
<a name="line688">688: </a><font color="#B22222"> Not Collective</font>
<a name="line690">690: </a><font color="#B22222"> Input Parameter:</font>
<a name="line691">691: </a><font color="#B22222">. MPI_Function - an MPI function that returns an MPI error code</font>
<a name="line693">693: </a><font color="#B22222"> Level: advanced</font>
<a name="line695">695: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`, `<a href="../manualpages/Sys/PetscCallReturnMPI.html">PetscCallReturnMPI</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`,</font>
<a name="line696">696: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`,</font>
<a name="line697">697: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/PetscCallMPINull.html">PetscCallMPINull</a>()`</font>
<a name="line698">698: </a><font color="#B22222">M*/</font>
<a name="line700">700: </a><font color="#B22222">/*MC</font>
<a name="line701">701: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPINull.html">PetscCallMPINull</a> - Checks error code returned from MPI calls, if non-zero it calls the error</font>
<a name="line702">702: </a><font color="#B22222"> handler and then returns a `NULL`</font>
<a name="line704">704: </a><font color="#B22222"> Synopsis:</font>
<a name="line705">705: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line706">706: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallMPINull.html">PetscCallMPINull</a>(MPI_Function(args))</font>
<a name="line708">708: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line710">710: </a><font color="#B22222"> Input Parameter:</font>
<a name="line711">711: </a><font color="#B22222">. MPI_Function - an MPI function that returns an MPI error code</font>
<a name="line713">713: </a><font color="#B22222"> Level: beginner</font>
<a name="line715">715: </a><font color="#B22222"> Notes:</font>
<a name="line716">716: </a><font color="#B22222"> Always passes the error code `<a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_MPI</a>` to the error handler `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`; the MPI error code and string are embedded in</font>
<a name="line717">717: </a><font color="#B22222"> the string error message. Do not use this to call any other routines (for example PETSc</font>
<a name="line718">718: </a><font color="#B22222"> routines), it should only be used for direct MPI calls.</font>
<a name="line720">720: </a><font color="#B22222"> This routine can only be used in functions returning anything that can be returned as a `NULL` themselves. If the</font>
<a name="line721">721: </a><font color="#B22222"> calling function returns a different type, use `<a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>()` instead.</font>
<a name="line723">723: </a><font color="#B22222"> Example Usage:</font>
<a name="line724">724: </a><font color="#B22222">.vb</font>
<a name="line725">725: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPINull.html">PetscCallMPINull</a>(<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Comm_size.html#MPI_Comm_size">MPI_Comm_size</a>(...)); // OK, calling MPI function</font>
<a name="line727">727: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(PetscFunction(...)); // ERROR, use <a href="../manualpages/Sys/PetscCall.html">PetscCall</a>() instead!</font>
<a name="line728">728: </a><font color="#B22222">.ve</font>
<a name="line730">730: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`,</font>
<a name="line731">731: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`,</font>
<a name="line732">732: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`</font>
<a name="line733">733: </a><font color="#B22222">M*/</font>
<a name="line735">735: </a><font color="#B22222">/*MC</font>
<a name="line736">736: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a> - Like `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()` but calls `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` on error</font>
<a name="line738">738: </a><font color="#B22222"> Synopsis:</font>
<a name="line739">739: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line740">740: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, MPI_Function(args))</font>
<a name="line742">742: </a><font color="#B22222"> Not Collective</font>
<a name="line744">744: </a><font color="#B22222"> Input Parameters:</font>
<a name="line745">745: </a><font color="#B22222">+ comm - the MPI communicator to abort on</font>
<a name="line746">746: </a><font color="#B22222">- MPI_Function - an MPI function that returns an MPI error code</font>
<a name="line748">748: </a><font color="#B22222"> Level: beginner</font>
<a name="line750">750: </a><font color="#B22222"> Notes:</font>
<a name="line751">751: </a><font color="#B22222"> Usage is identical to `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`. See `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()` for detailed discussion.</font>
<a name="line753">753: </a><font color="#B22222"> This routine may be used in functions returning `void` or other non-`<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` types.</font>
<a name="line755">755: </a><font color="#B22222"> Fortran Note:</font>
<a name="line756">756: </a><font color="#B22222"> In Fortran this is called `PetscCallMPIA()` and is intended to be used in the main program while `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()` is</font>
<a name="line757">757: </a><font color="#B22222"> used in Fortran subroutines.</font>
<a name="line759">759: </a><font color="#B22222"> Developer Note:</font>
<a name="line760">760: </a><font color="#B22222"> This should have the same name in Fortran.</font>
<a name="line762">762: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`</font>
<a name="line763">763: </a><font color="#B22222">M*/</font>
<a name="line764">764: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER)</font>
<a name="line765">765: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(<a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a>)</font></strong>;
<a name="line766">766: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, <a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a>)</font></strong>;
<a name="line767">767: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallMPINull.html">PetscCallMPINull</a>(<a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a>)</font></strong>;
<a name="line768">768: </a><font color="#A020F0">#else</font>
<a name="line769">769: </a><strong><font color="#228B22"> #define PetscCallMPI_Private(__PETSC_STACK_POP_FUNC__, __SETERR_FUNC__, __COMM__, ...) \</font></strong>
<a name="line770">770: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line771">771: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a> ierr_petsc_call_mpi_; \</font></strong>
<a name="line772">772: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line773">773: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>(</font><font color="#666666">"MPI function"</font><font color="#228B22">); \</font></strong>
<a name="line774">774: </a><strong><font color="#228B22"> { \</font></strong>
<a name="line775">775: </a><strong><font color="#228B22"> ierr_petsc_call_mpi_ = __VA_ARGS__; \</font></strong>
<a name="line776">776: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line777">777: </a><strong><font color="#228B22"> __PETSC_STACK_POP_FUNC__; \</font></strong>
<a name="line778">778: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_mpi_ != MPI_SUCCESS)) { \</font></strong>
<a name="line779">779: </a><strong><font color="#228B22"> char petsc_mpi_7_errorstring[2 * MPI_MAX_ERROR_STRING]; \</font></strong>
<a name="line780">780: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscMPIErrorString.html">PetscMPIErrorString</a>(ierr_petsc_call_mpi_, 2 * MPI_MAX_ERROR_STRING, (char *)petsc_mpi_7_errorstring); \</font></strong>
<a name="line781">781: </a><strong><font color="#228B22"> __SETERR_FUNC__(__COMM__, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_MPI</a>, </font><font color="#666666">"MPI error %d %s"</font><font color="#228B22">, ierr_petsc_call_mpi_, petsc_mpi_7_errorstring); \</font></strong>
<a name="line782">782: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line783">783: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line785">785: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(...) PetscCallMPI_Private(<a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>, <a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>, <a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __VA_ARGS__)</font></strong>
<a name="line786">786: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallMPIReturnMPI.html">PetscCallMPIReturnMPI</a>(...) PetscCallMPI_Private(<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(PETSC_FUNCTION_NAME), <a href="../manualpages/Sys/SETERRMPI.html">SETERRMPI</a>, <a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __VA_ARGS__)</font></strong>
<a name="line787">787: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>(comm, ...) PetscCallMPI_Private(<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(PETSC_FUNCTION_NAME), <a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>, comm, __VA_ARGS__)</font></strong>
<a name="line788">788: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallMPINull.html">PetscCallMPINull</a>(...) PetscCallMPI_Private(<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(PETSC_FUNCTION_NAME), SETERRQNULL, <a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __VA_ARGS__)</font></strong>
<a name="line789">789: </a><font color="#A020F0">#endif</font>
<a name="line791">791: </a><font color="#B22222">/*MC</font>
<a name="line792">792: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKERRMPI.html">CHKERRMPI</a> - Checks error code returned from MPI calls, if non-zero it calls the error</font>
<a name="line793">793: </a><font color="#B22222"> handler and then returns</font>
<a name="line795">795: </a><font color="#B22222"> Synopsis:</font>
<a name="line796">796: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line797">797: </a><font color="#B22222"> void <a href="../manualpages/Sys/CHKERRMPI.html">CHKERRMPI</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line799">799: </a><font color="#B22222"> Not Collective</font>
<a name="line801">801: </a><font color="#B22222"> Input Parameter:</font>
<a name="line802">802: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line804">804: </a><font color="#B22222"> Level: deprecated</font>
<a name="line806">806: </a><font color="#B22222"> Note:</font>
<a name="line807">807: </a><font color="#B22222"> Deprecated in favor of `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`. This routine behaves identically to it.</font>
<a name="line809">809: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`</font>
<a name="line810">810: </a><font color="#B22222">M*/</font>
<a name="line811">811: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/CHKERRMPI.html">CHKERRMPI</a>(...) <a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>(__VA_ARGS__)</font></strong>
<a name="line813">813: </a><font color="#B22222">/*MC</font>
<a name="line814">814: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a> - Checks error code returned from PETSc function, if non-zero it aborts immediately by calling `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()`</font>
<a name="line816">816: </a><font color="#B22222"> Synopsis:</font>
<a name="line817">817: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line818">818: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line820">820: </a><font color="#B22222"> Collective</font>
<a name="line822">822: </a><font color="#B22222"> Input Parameters:</font>
<a name="line823">823: </a><font color="#B22222">+ comm - the MPI communicator on which to abort</font>
<a name="line824">824: </a><font color="#B22222">- ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line826">826: </a><font color="#B22222"> Level: intermediate</font>
<a name="line828">828: </a><font color="#B22222"> Notes:</font>
<a name="line829">829: </a><font color="#B22222"> This macro has identical type and usage semantics to `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` with the important caveat</font>
<a name="line830">830: </a><font color="#B22222"> that this macro does not return. Instead, if ierr is nonzero it calls the PETSc error handler</font>
<a name="line831">831: </a><font color="#B22222"> and then immediately calls `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()`. It can therefore be used anywhere.</font>
<a name="line833">833: </a><font color="#B22222"> As per `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` semantics the communicator passed must be valid, although there is currently</font>
<a name="line834">834: </a><font color="#B22222"> no attempt made at handling any potential errors from `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()`. Note that while</font>
<a name="line835">835: </a><font color="#B22222"> `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` is required to terminate only those processes which reside on comm, it is often</font>
<a name="line836">836: </a><font color="#B22222"> the case that `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` terminates *all* processes.</font>
<a name="line838">838: </a><font color="#B22222"> Example Usage:</font>
<a name="line839">839: </a><font color="#B22222">.vb</font>
<a name="line840">840: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> boom(void) { return <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_MEM</a>; }</font>
<a name="line842">842: </a><font color="#B22222"> void foo(void)</font>
<a name="line843">843: </a><font color="#B22222"> {</font>
<a name="line844">844: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_WORLD.html">PETSC_COMM_WORLD</a>,boom()); // OK, does not return a type</font>
<a name="line845">845: </a><font color="#B22222"> }</font>
<a name="line847">847: </a><font color="#B22222"> double bar(void)</font>
<a name="line848">848: </a><font color="#B22222"> {</font>
<a name="line849">849: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_WORLD.html">PETSC_COMM_WORLD</a>,boom()); // OK, does not return a type</font>
<a name="line850">850: </a><font color="#B22222"> }</font>
<a name="line852">852: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(MPI_COMM_NULL,boom()); // ERROR, communicator should be valid</font>
<a name="line854">854: </a><font color="#B22222"> struct baz</font>
<a name="line855">855: </a><font color="#B22222"> {</font>
<a name="line856">856: </a><font color="#B22222"> baz()</font>
<a name="line857">857: </a><font color="#B22222"> {</font>
<a name="line858">858: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>,boom()); // OK</font>
<a name="line859">859: </a><font color="#B22222"> }</font>
<a name="line861">861: </a><font color="#B22222"> ~baz()</font>
<a name="line862">862: </a><font color="#B22222"> {</font>
<a name="line863">863: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>,boom()); // OK (in fact the only way to handle PETSc errors)</font>
<a name="line864">864: </a><font color="#B22222"> }</font>
<a name="line865">865: </a><font color="#B22222"> };</font>
<a name="line866">866: </a><font color="#B22222">.ve</font>
<a name="line868">868: </a><font color="#B22222"> Fortran Note:</font>
<a name="line869">869: </a><font color="#B22222"> Use `<a href="../manualpages/Sys/PetscCallA.html">PetscCallA</a>()`.</font>
<a name="line871">871: </a><font color="#B22222"> Developer Note:</font>
<a name="line872">872: </a><font color="#B22222"> This should have the same name in Fortran as in C.</font>
<a name="line874">874: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`,</font>
<a name="line875">875: </a><font color="#B22222"> `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`, `<a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>()`</font>
<a name="line876">876: </a><font color="#B22222">M*/</font>
<a name="line877">877: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER)</font>
<a name="line878">878: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line879">879: </a><strong><font color="#4169E1">void PetscCallContinue(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line880">880: </a><font color="#A020F0">#else</font>
<a name="line881">881: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(comm, ...) \</font></strong>
<a name="line882">882: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line883">883: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_abort_; \</font></strong>
<a name="line884">884: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line885">885: </a><strong><font color="#228B22"> ierr_petsc_call_abort_ = __VA_ARGS__; \</font></strong>
<a name="line886">886: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_abort_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) { \</font></strong>
<a name="line887">887: </a><strong><font color="#228B22"> ierr_petsc_call_abort_ = <a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_call_abort_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line888">888: </a><strong><font color="#228B22"> (void)<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>(comm, (<a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a>)ierr_petsc_call_abort_); \</font></strong>
<a name="line889">889: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line890">890: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line891">891: </a><strong><font color="#228B22"> #define PetscCallContinue(...) \</font></strong>
<a name="line892">892: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line893">893: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_continue_; \</font></strong>
<a name="line894">894: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line895">895: </a><strong><font color="#228B22"> ierr_petsc_call_continue_ = __VA_ARGS__; \</font></strong>
<a name="line896">896: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_continue_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) { \</font></strong>
<a name="line897">897: </a><strong><font color="#228B22"> ierr_petsc_call_continue_ = <a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_call_continue_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line898">898: </a><strong><font color="#228B22"> (void)ierr_petsc_call_continue_; \</font></strong>
<a name="line899">899: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line900">900: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line901">901: </a><font color="#A020F0">#endif</font>
<a name="line903">903: </a><font color="#B22222">/*MC</font>
<a name="line904">904: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKERRABORT.html">CHKERRABORT</a> - Checks error code returned from PETSc function. If non-zero it aborts immediately.</font>
<a name="line906">906: </a><font color="#B22222"> Synopsis:</font>
<a name="line907">907: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line908">908: </a><font color="#B22222"> void <a href="../manualpages/Sys/CHKERRABORT.html">CHKERRABORT</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line910">910: </a><font color="#B22222"> Not Collective</font>
<a name="line912">912: </a><font color="#B22222"> Input Parameters:</font>
<a name="line913">913: </a><font color="#B22222">+ comm - the MPI communicator</font>
<a name="line914">914: </a><font color="#B22222">- ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line916">916: </a><font color="#B22222"> Level: deprecated</font>
<a name="line918">918: </a><font color="#B22222"> Note:</font>
<a name="line919">919: </a><font color="#B22222"> Deprecated in favor of `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`. This routine behaves identically to it.</font>
<a name="line921">921: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line922">922: </a><font color="#B22222">M*/</font>
<a name="line923">923: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/CHKERRABORT.html">CHKERRABORT</a>(comm, ...) <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(comm, __VA_ARGS__)</font></strong>
<a name="line924">924: </a><strong><font color="#228B22">#define CHKERRCONTINUE(...) PetscCallContinue(__VA_ARGS__)</font></strong>
<a name="line926">926: </a><font color="#B22222">/*MC</font>
<a name="line927">927: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a> - Fortran-only replacement for use of `<a href="../manualpages/Sys/CHKERRQ.html">CHKERRQ</a>()` in the main program, which aborts immediately</font>
<a name="line929">929: </a><font color="#B22222"> Synopsis:</font>
<a name="line930">930: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line931">931: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/CHKERRA.html">CHKERRA</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line933">933: </a><font color="#B22222"> Not Collective</font>
<a name="line935">935: </a><font color="#B22222"> Input Parameter:</font>
<a name="line936">936: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line938">938: </a><font color="#B22222"> Level: deprecated</font>
<a name="line940">940: </a><font color="#B22222"> Note:</font>
<a name="line941">941: </a><font color="#B22222"> This macro is rarely needed, normal usage is `<a href="../manualpages/Sys/PetscCallA.html">PetscCallA</a>()` in the main Fortran program.</font>
<a name="line943">943: </a><font color="#B22222"> Developer Note:</font>
<a name="line944">944: </a><font color="#B22222"> Why isn't this named `<a href="../manualpages/Sys/CHKERRABORT.html">CHKERRABORT</a>()` in Fortran?</font>
<a name="line946">946: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCallA.html">PetscCallA</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/CHKERRQ.html">CHKERRQ</a>()`, `<a href="../manualpages/Sys/SETERRA.html">SETERRA</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`</font>
<a name="line947">947: </a><font color="#B22222">M*/</font>
<a name="line949">949: </a>PETSC_EXTERN <a href="../manualpages/Sys/PetscBool.html">PetscBool</a> petscwaitonerrorflg;
<a name="line950">950: </a>PETSC_EXTERN <a href="../manualpages/Sys/PetscBool.html">PetscBool</a> petscindebugger;
<a name="line951">951: </a>PETSC_EXTERN <a href="../manualpages/Sys/PetscBool.html">PetscBool</a> petscabortmpifinalize;
<a name="line953">953: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER)</font>
<a name="line954">954: </a><strong><font color="#4169E1">void PETSCABORTWITHERR_Private(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line955">955: </a><font color="#A020F0">#else</font>
<a name="line956">956: </a><strong><font color="#228B22"> #define PETSCABORTWITHIERR_Private(comm, ierr) \</font></strong>
<a name="line957">957: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line958">958: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a> size_; \</font></strong>
<a name="line959">959: </a><strong><font color="#228B22"> (void)<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Comm_size.html#MPI_Comm_size">MPI_Comm_size</a>(comm, &size_); \</font></strong>
<a name="line960">960: </a><strong><font color="#228B22"> if (PetscCIEnabledPortableErrorOutput && (size_ == PetscGlobalSize || petscabortmpifinalize) && ierr != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_SIG</a>) { \</font></strong>
<a name="line961">961: </a><strong><font color="#228B22"> (void)<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Finalize.html#MPI_Finalize">MPI_Finalize</a>(); \</font></strong>
<a name="line962">962: </a><strong><font color="#228B22"> exit(0); \</font></strong>
<a name="line963">963: </a><strong><font color="#228B22"> } else if (PetscCIEnabledPortableErrorOutput && PetscGlobalSize == 1) { \</font></strong>
<a name="line964">964: </a><strong><font color="#228B22"> exit(0); \</font></strong>
<a name="line965">965: </a><strong><font color="#228B22"> } else { \</font></strong>
<a name="line966">966: </a><strong><font color="#228B22"> (void)<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>(comm, (<a href="../manualpages/Sys/PetscMPIInt.html">PetscMPIInt</a>)ierr); \</font></strong>
<a name="line967">967: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line968">968: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line969">969: </a><font color="#A020F0">#endif</font>
<a name="line971">971: </a><font color="#B22222">/*MC</font>
<a name="line972">972: </a><font color="#B22222"> <a href="../manualpages/Sys/PETSCABORT.html">PETSCABORT</a> - Call `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` with an informative error code</font>
<a name="line974">974: </a><font color="#B22222"> Synopsis:</font>
<a name="line975">975: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line976">976: </a><font color="#B22222"> <a href="../manualpages/Sys/PETSCABORT.html">PETSCABORT</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line978">978: </a><font color="#B22222"> Collective; No Fortran Support</font>
<a name="line980">980: </a><font color="#B22222"> Input Parameters:</font>
<a name="line981">981: </a><font color="#B22222">+ comm - An MPI communicator, so that the error can be collective</font>
<a name="line982">982: </a><font color="#B22222">- ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line984">984: </a><font color="#B22222"> Level: advanced</font>
<a name="line986">986: </a><font color="#B22222"> Notes:</font>
<a name="line987">987: </a><font color="#B22222"> If the option `-start_in_debugger` was used then this calls `abort()` to stop the program in the debugger.</font>
<a name="line989">989: </a><font color="#B22222"> if `PetscCIEnabledPortableErrorOutput` is set, which means the code is running in the PETSc test harness (make test),</font>
<a name="line990">990: </a><font color="#B22222"> and `comm` is `MPI_COMM_WORLD` it strives to exit cleanly without calling `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` and instead calling `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Finalize.html#MPI_Finalize">MPI_Finalize</a>()`.</font>
<a name="line992">992: </a><font color="#B22222"> This is currently only used when an error propagates up to the C `main()` program and is detected by a `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`,</font>
<a name="line993">993: </a><font color="#B22222"> or is set in `main()` with `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`. Abort calls such as `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`,</font>
<a name="line994">994: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>()`, `<a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>()`, and `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()` always call `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` and do not have any special</font>
<a name="line995">995: </a><font color="#B22222"> handling for the test harness.</font>
<a name="line997">997: </a><font color="#B22222"> Developer Note:</font>
<a name="line998">998: </a><font color="#B22222"> Should the other abort calls also pass through this call instead of calling `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` directly?</font>
<a name="line1000">1000: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>()`, `<a href="../manualpages/Sys/PetscCallMPIAbort.html">PetscCallMPIAbort</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscCallMPI.html">PetscCallMPI</a>()`,</font>
<a name="line1001">1001: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()`, `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`</font>
<a name="line1002">1002: </a><font color="#B22222">M*/</font>
<a name="line1003">1003: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER)</font>
<a name="line1004">1004: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PETSCABORT.html">PETSCABORT</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>)</font></strong>;
<a name="line1005">1005: </a><font color="#A020F0">#else</font>
<a name="line1006">1006: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PETSCABORT.html">PETSCABORT</a>(comm, ...) \</font></strong>
<a name="line1007">1007: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1008">1008: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_abort_; \</font></strong>
<a name="line1009">1009: </a><strong><font color="#228B22"> if (petscwaitonerrorflg) { ierr_petsc_abort_ = <a href="../manualpages/Sys/PetscSleep.html">PetscSleep</a>(1000); } \</font></strong>
<a name="line1010">1010: </a><strong><font color="#228B22"> if (petscindebugger) { \</font></strong>
<a name="line1011">1011: </a><strong><font color="#228B22"> abort(); \</font></strong>
<a name="line1012">1012: </a><strong><font color="#228B22"> } else { \</font></strong>
<a name="line1013">1013: </a><strong><font color="#228B22"> ierr_petsc_abort_ = __VA_ARGS__; \</font></strong>
<a name="line1014">1014: </a><strong><font color="#228B22"> PETSCABORTWITHIERR_Private(comm, ierr_petsc_abort_); \</font></strong>
<a name="line1015">1015: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1016">1016: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1017">1017: </a><font color="#A020F0">#endif</font>
<a name="line1019">1019: </a><font color="#A020F0">#ifdef PETSC_CLANGUAGE_CXX</font>
<a name="line1020">1020: </a> <font color="#B22222">/*MC</font>
<a name="line1021">1021: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallThrow.html">PetscCallThrow</a> - Checks error code, if non-zero it calls the C++ error handler which throws</font>
<a name="line1022">1022: </a><font color="#B22222"> an exception</font>
<a name="line1024">1024: </a><font color="#B22222"> Synopsis:</font>
<a name="line1025">1025: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1026">1026: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallThrow.html">PetscCallThrow</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line1028">1028: </a><font color="#B22222"> Not Collective</font>
<a name="line1030">1030: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1031">1031: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line1033">1033: </a><font color="#B22222"> Level: beginner</font>
<a name="line1035">1035: </a><font color="#B22222"> Notes:</font>
<a name="line1036">1036: </a><font color="#B22222"> Requires PETSc to be configured with clanguage of c++. Throws a std::runtime_error() on error.</font>
<a name="line1038">1038: </a><font color="#B22222"> Once the error handler throws the exception you can use `<a href="../manualpages/Sys/PetscCallVoid.html">PetscCallVoid</a>()` which returns without</font>
<a name="line1039">1039: </a><font color="#B22222"> an error code (bad idea since the error is ignored) or `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()` to have `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()`</font>
<a name="line1040">1040: </a><font color="#B22222"> called immediately.</font>
<a name="line1042">1042: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`,</font>
<a name="line1043">1043: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`</font>
<a name="line1044">1044: </a><font color="#B22222">M*/</font>
<a name="line1045">1045: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallThrow.html">PetscCallThrow</a>(...) \</font></strong>
<a name="line1046">1046: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1047">1047: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line1048">1048: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_call_throw_ = __VA_ARGS__; \</font></strong>
<a name="line1049">1049: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_throw_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) <a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_call_throw_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_IN_CXX</a>, <a href="../manualpages/Sys/PETSC_NULLPTR.html">PETSC_NULLPTR</a>); \</font></strong>
<a name="line1050">1050: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1052">1052: </a> <font color="#B22222">/*MC</font>
<a name="line1053">1053: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKERRXX.html">CHKERRXX</a> - Checks error code, if non-zero it calls the C++ error handler which throws an exception</font>
<a name="line1055">1055: </a><font color="#B22222"> Synopsis:</font>
<a name="line1056">1056: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1057">1057: </a><font color="#B22222"> void <a href="../manualpages/Sys/CHKERRXX.html">CHKERRXX</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr)</font>
<a name="line1059">1059: </a><font color="#B22222"> Not Collective</font>
<a name="line1061">1061: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1062">1062: </a><font color="#B22222">. ierr - nonzero error code, see the list of standard error codes in include/petscerror.h</font>
<a name="line1064">1064: </a><font color="#B22222"> Level: deprecated</font>
<a name="line1066">1066: </a><font color="#B22222"> Note:</font>
<a name="line1067">1067: </a><font color="#B22222"> Deprecated in favor of `<a href="../manualpages/Sys/PetscCallThrow.html">PetscCallThrow</a>()`. This routine behaves identically to it.</font>
<a name="line1069">1069: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCallThrow.html">PetscCallThrow</a>()`</font>
<a name="line1070">1070: </a><font color="#B22222">M*/</font>
<a name="line1071">1071: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/CHKERRXX.html">CHKERRXX</a>(...) <a href="../manualpages/Sys/PetscCallThrow.html">PetscCallThrow</a>(__VA_ARGS__)</font></strong>
<a name="line1072">1072: </a><font color="#A020F0">#endif</font>
<a name="line1074">1074: </a><strong><font color="#228B22">#define PetscCallCXX_Private(__SETERR_FUNC__, __COMM__, ...) \</font></strong>
<a name="line1075">1075: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1076">1076: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line1077">1077: </a><strong><font color="#228B22"> try { \</font></strong>
<a name="line1078">1078: </a><strong><font color="#228B22"> __VA_ARGS__; \</font></strong>
<a name="line1079">1079: </a><strong><font color="#228B22"> } catch (const std::exception &e) { \</font></strong>
<a name="line1080">1080: </a><strong><font color="#228B22"> __SETERR_FUNC__(__COMM__, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_LIB</a>, </font><font color="#666666">"%s"</font><font color="#228B22">, e.what()); \</font></strong>
<a name="line1081">1081: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1082">1082: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1084">1084: </a><font color="#B22222">/*MC</font>
<a name="line1085">1085: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a> - Checks C++ function calls and if they throw an exception, catch it and then</font>
<a name="line1086">1086: </a><font color="#B22222"> return a PETSc error code</font>
<a name="line1088">1088: </a><font color="#B22222"> Synopsis:</font>
<a name="line1089">1089: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1090">1090: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(...) noexcept;</font>
<a name="line1092">1092: </a><font color="#B22222"> Not Collective</font>
<a name="line1094">1094: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1095">1095: </a><font color="#B22222">. __VA_ARGS__ - An arbitrary expression</font>
<a name="line1097">1097: </a><font color="#B22222"> Level: beginner</font>
<a name="line1099">1099: </a><font color="#B22222"> Notes:</font>
<a name="line1100">1100: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(...)` is a macro replacement for</font>
<a name="line1101">1101: </a><font color="#B22222">.vb</font>
<a name="line1102">1102: </a><font color="#B22222"> try {</font>
<a name="line1103">1103: </a><font color="#B22222"> __VA_ARGS__;</font>
<a name="line1104">1104: </a><font color="#B22222"> } catch (const std::exception& e) {</font>
<a name="line1105">1105: </a><font color="#B22222"> return ConvertToPetscErrorCode(e);</font>
<a name="line1106">1106: </a><font color="#B22222"> }</font>
<a name="line1107">1107: </a><font color="#B22222">.ve</font>
<a name="line1108">1108: </a><font color="#B22222"> Due to the fact that it catches any (reasonable) exception, it is essentially noexcept.</font>
<a name="line1110">1110: </a><font color="#B22222"> If you cannot return a `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>` use `<a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>()` instead.</font>
<a name="line1112">1112: </a><font color="#B22222"> Example Usage:</font>
<a name="line1113">1113: </a><font color="#B22222">.vb</font>
<a name="line1114">1114: </a><font color="#B22222"> void foo(void) { throw std::runtime_error("error"); }</font>
<a name="line1116">1116: </a><font color="#B22222"> void bar()</font>
<a name="line1117">1117: </a><font color="#B22222"> {</font>
<a name="line1118">1118: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(foo()); // ERROR bar() does not return <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a></font>
<a name="line1119">1119: </a><font color="#B22222"> }</font>
<a name="line1121">1121: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> baz()</font>
<a name="line1122">1122: </a><font color="#B22222"> {</font>
<a name="line1123">1123: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(foo()); // OK</font>
<a name="line1125">1125: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(</font>
<a name="line1126">1126: </a><font color="#B22222"> bar();</font>
<a name="line1127">1127: </a><font color="#B22222"> foo(); // OK multiple statements allowed</font>
<a name="line1128">1128: </a><font color="#B22222"> );</font>
<a name="line1129">1129: </a><font color="#B22222"> }</font>
<a name="line1131">1131: </a><font color="#B22222"> struct bop</font>
<a name="line1132">1132: </a><font color="#B22222"> {</font>
<a name="line1133">1133: </a><font color="#B22222"> bop()</font>
<a name="line1134">1134: </a><font color="#B22222"> {</font>
<a name="line1135">1135: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(foo()); // ERROR returns <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, cannot be used in constructors</font>
<a name="line1136">1136: </a><font color="#B22222"> }</font>
<a name="line1137">1137: </a><font color="#B22222"> };</font>
<a name="line1139">1139: </a><font color="#B22222"> // ERROR contains do-while, cannot be used as function-try block</font>
<a name="line1140">1140: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> qux() <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(</font>
<a name="line1141">1141: </a><font color="#B22222"> bar();</font>
<a name="line1142">1142: </a><font color="#B22222"> baz();</font>
<a name="line1143">1143: </a><font color="#B22222"> foo();</font>
<a name="line1144">1144: </a><font color="#B22222"> return 0;</font>
<a name="line1145">1145: </a><font color="#B22222"> )</font>
<a name="line1146">1146: </a><font color="#B22222">.ve</font>
<a name="line1148">1148: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>()`, `<a href="../manualpages/Sys/PetscCallThrow.html">PetscCallThrow</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`,</font>
<a name="line1149">1149: </a><font color="#B22222"> `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`, `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`,</font>
<a name="line1150">1150: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`</font>
<a name="line1151">1151: </a><font color="#B22222">M*/</font>
<a name="line1152">1152: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(...) PetscCallCXX_Private(<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>, <a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __VA_ARGS__)</font></strong>
<a name="line1154">1154: </a><font color="#B22222">/*MC</font>
<a name="line1155">1155: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a> - Like `<a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>()` but calls `<a href="http://www.mpich.org/static/docs/latest/www3/MPI_Abort.html#MPI_Abort">MPI_Abort</a>()` instead of returning an</font>
<a name="line1156">1156: </a><font color="#B22222"> error-code</font>
<a name="line1158">1158: </a><font color="#B22222"> Synopsis:</font>
<a name="line1159">1159: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1160">1160: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a> comm, ...) noexcept;</font>
<a name="line1162">1162: </a><font color="#B22222"> Collective; No Fortran Support</font>
<a name="line1164">1164: </a><font color="#B22222"> Input Parameters:</font>
<a name="line1165">1165: </a><font color="#B22222">+ comm - The MPI communicator to abort on</font>
<a name="line1166">1166: </a><font color="#B22222">- __VA_ARGS__ - An arbitrary expression</font>
<a name="line1168">1168: </a><font color="#B22222"> Level: beginner</font>
<a name="line1170">1170: </a><font color="#B22222"> Notes:</font>
<a name="line1171">1171: </a><font color="#B22222"> This macro may be used to check C++ expressions for exceptions in cases where you cannot</font>
<a name="line1172">1172: </a><font color="#B22222"> return an error code. This includes constructors, destructors, copy/move assignment functions</font>
<a name="line1173">1173: </a><font color="#B22222"> or constructors among others.</font>
<a name="line1175">1175: </a><font color="#B22222"> If an exception is caught, the macro calls `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()` on `comm`. The exception must</font>
<a name="line1176">1176: </a><font color="#B22222"> derive from `std::exception` in order to be caught.</font>
<a name="line1178">1178: </a><font color="#B22222"> If the routine _can_ return an error-code it is highly advised to use `<a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>()`</font>
<a name="line1179">1179: </a><font color="#B22222"> instead.</font>
<a name="line1181">1181: </a><font color="#B22222"> See `<a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>()` for additional discussion.</font>
<a name="line1183">1183: </a><font color="#B22222"> Example Usage:</font>
<a name="line1184">1184: </a><font color="#B22222">.vb</font>
<a name="line1185">1185: </a><font color="#B22222"> class Foo</font>
<a name="line1186">1186: </a><font color="#B22222"> {</font>
<a name="line1187">1187: </a><font color="#B22222"> std::vector<int> data_;</font>
<a name="line1189">1189: </a><font color="#B22222"> public:</font>
<a name="line1190">1190: </a><font color="#B22222"> // normally std::vector::reserve() may raise an exception, but since we handle it with</font>
<a name="line1191">1191: </a><font color="#B22222"> // <a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>() we may mark this routine as noexcept!</font>
<a name="line1192">1192: </a><font color="#B22222"> Foo() noexcept</font>
<a name="line1193">1193: </a><font color="#B22222"> {</font>
<a name="line1194">1194: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, data_.reserve(10));</font>
<a name="line1195">1195: </a><font color="#B22222"> }</font>
<a name="line1196">1196: </a><font color="#B22222"> };</font>
<a name="line1198">1198: </a><font color="#B22222"> std::vector<int> bar()</font>
<a name="line1199">1199: </a><font color="#B22222"> {</font>
<a name="line1200">1200: </a><font color="#B22222"> std::vector<int> v;</font>
<a name="line1202">1202: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>;</font>
<a name="line1203">1203: </a><font color="#B22222"> // OK!</font>
<a name="line1204">1204: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, v.emplace_back(1));</font>
<a name="line1205">1205: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(v);</font>
<a name="line1206">1206: </a><font color="#B22222"> }</font>
<a name="line1208">1208: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> baz()</font>
<a name="line1209">1209: </a><font color="#B22222"> {</font>
<a name="line1210">1210: </a><font color="#B22222"> std::vector<int> v;</font>
<a name="line1212">1212: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>;</font>
<a name="line1213">1213: </a><font color="#B22222"> // WRONG! baz() returns a <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, prefer <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>() instead</font>
<a name="line1214">1214: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, v.emplace_back(1));</font>
<a name="line1215">1215: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>);</font>
<a name="line1216">1216: </a><font color="#B22222"> }</font>
<a name="line1217">1217: </a><font color="#B22222">.ve</font>
<a name="line1219">1219: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>()`, `<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>()`, `<a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>()`</font>
<a name="line1220">1220: </a><font color="#B22222">M*/</font>
<a name="line1221">1221: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/PetscCallCXXAbort.html">PetscCallCXXAbort</a>(comm, ...) PetscCallCXX_Private(<a href="../manualpages/Sys/SETERRABORT.html">SETERRABORT</a>, comm, __VA_ARGS__)</font></strong>
<a name="line1223">1223: </a><font color="#B22222">/*MC</font>
<a name="line1224">1224: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKERRCXX.html">CHKERRCXX</a> - Checks C++ function calls and if they throw an exception, catch it and then</font>
<a name="line1225">1225: </a><font color="#B22222"> return a PETSc error code</font>
<a name="line1227">1227: </a><font color="#B22222"> Synopsis:</font>
<a name="line1228">1228: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1229">1229: </a><font color="#B22222"> void <a href="../manualpages/Sys/CHKERRCXX.html">CHKERRCXX</a>(func) noexcept;</font>
<a name="line1231">1231: </a><font color="#B22222"> Not Collective</font>
<a name="line1233">1233: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1234">1234: </a><font color="#B22222">. func - C++ function calls</font>
<a name="line1236">1236: </a><font color="#B22222"> Level: deprecated</font>
<a name="line1238">1238: </a><font color="#B22222"> Note:</font>
<a name="line1239">1239: </a><font color="#B22222"> Deprecated in favor of `<a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>()`. This routine behaves identically to it.</font>
<a name="line1241">1241: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>()`</font>
<a name="line1242">1242: </a><font color="#B22222">M*/</font>
<a name="line1243">1243: </a><strong><font color="#228B22">#define <a href="../manualpages/Sys/CHKERRCXX.html">CHKERRCXX</a>(...) <a href="../manualpages/Sys/PetscCallCXX.html">PetscCallCXX</a>(__VA_ARGS__)</font></strong>
<a name="line1245">1245: </a><font color="#B22222">/*MC</font>
<a name="line1246">1246: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a> - Checks the memory for corruption, calls error handler if any is detected</font>
<a name="line1248">1248: </a><font color="#B22222"> Synopsis:</font>
<a name="line1249">1249: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1250">1250: </a><font color="#B22222"> <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>;</font>
<a name="line1252">1252: </a><font color="#B22222"> Not Collective</font>
<a name="line1254">1254: </a><font color="#B22222"> Level: beginner</font>
<a name="line1256">1256: </a><font color="#B22222"> Notes:</font>
<a name="line1257">1257: </a><font color="#B22222"> We recommend using Valgrind <https://petsc.org/release/faq/#valgrind> or for NVIDIA CUDA systems</font>
<a name="line1258">1258: </a><font color="#B22222"> <https://docs.nvidia.com/cuda/cuda-memcheck/index.html> for finding memory problems. The ``<a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>`` macro is useful on systems that</font>
<a name="line1259">1259: </a><font color="#B22222"> do not have valgrind, but is not as good as valgrind or cuda-memcheck.</font>
<a name="line1261">1261: </a><font color="#B22222"> Must run with the option `-malloc_debug` (`-malloc_test` in debug mode; or if `<a href="../manualpages/Sys/PetscMallocSetDebug.html">PetscMallocSetDebug</a>()` called) to enable this option</font>
<a name="line1263">1263: </a><font color="#B22222"> Once the error handler is called the calling function is then returned from with the given error code.</font>
<a name="line1265">1265: </a><font color="#B22222"> By defaults prints location where memory that is corrupted was allocated.</font>
<a name="line1267">1267: </a><font color="#B22222"> Use `CHKMEMA` for functions that return `void`</font>
<a name="line1269">1269: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`, `<a href="../manualpages/Sys/PetscMallocValidate.html">PetscMallocValidate</a>()`</font>
<a name="line1270">1270: </a><font color="#B22222">M*/</font>
<a name="line1271">1271: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER)</font>
<a name="line1272">1272: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a></font></strong>
<a name="line1273">1273: </a><strong><font color="#228B22"> #define CHKMEMA</font></strong>
<a name="line1274">1274: </a><font color="#A020F0">#else</font>
<a name="line1275">1275: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a> \</font></strong>
<a name="line1276">1276: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1277">1277: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> ierr_petsc_memq_ = <a href="../manualpages/Sys/PetscMallocValidate.html">PetscMallocValidate</a>(__LINE__, PETSC_FUNCTION_NAME, __FILE__); \</font></strong>
<a name="line1278">1278: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_memq_ != <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>)) return <a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, ierr_petsc_memq_, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a>, </font><font color="#666666">" "</font><font color="#228B22">); \</font></strong>
<a name="line1279">1279: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1280">1280: </a><strong><font color="#228B22"> #define CHKMEMA <a href="../manualpages/Sys/PetscMallocValidate.html">PetscMallocValidate</a>(__LINE__, PETSC_FUNCTION_NAME, __FILE__)</font></strong>
<a name="line1281">1281: </a><font color="#A020F0">#endif</font>
<a name="line1283">1283: </a><font color="#B22222">/*E</font>
<a name="line1284">1284: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a> - passed to the PETSc error handling routines indicating if this is the first or a later call to the error handlers</font>
<a name="line1286">1286: </a><font color="#B22222"> Level: advanced</font>
<a name="line1288">1288: </a><font color="#B22222"> Note:</font>
<a name="line1289">1289: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_IN_CXX</a>` indicates the error was detected in C++ and an exception should be generated</font>
<a name="line1291">1291: </a><font color="#B22222"> Developer Note:</font>
<a name="line1292">1292: </a><font color="#B22222"> This is currently used to decide when to print the detailed information about the run in `<a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>()`</font>
<a name="line1294">1294: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscError.html">PetscError</a>()`, `<a href="../manualpages/Sys/SETERRQ.html">SETERRQ</a>()`</font>
<a name="line1295">1295: </a><font color="#B22222">E*/</font>
<a name="line1296">1296: </a><font color="#4169E1">typedef</font> <font color="#4169E1">enum</font> {
<a name="line1297">1297: </a> <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_INITIAL</a> = 0,
<a name="line1298">1298: </a> <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_REPEAT</a> = 1,
<a name="line1299">1299: </a> <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_IN_CXX</a> = 2
<a name="line1300">1300: </a>} <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>;
<a name="line1302">1302: </a><font color="#A020F0">#if defined(__clang_analyzer__)</font>
<a name="line1303">1303: </a><strong><font color="#4169E1"><a name="_attribute__"></a>__attribute__((analyzer_noreturn))</font></strong>
<a name="line1304">1304: </a><font color="#A020F0">#endif</font>
<a name="line1305">1305: </a><strong><font color="#4169E1"><a name="PetscError"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a></font></strong>
<a name="line1306">1306: </a><strong><font color="#4169E1"><a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, ...)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_FORMAT.html">PETSC_ATTRIBUTE_FORMAT</a>(7, 8);
<a name="line1308">1308: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> PetscErrorPrintfInitialize(void)</font></strong>;
<a name="line1309">1309: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscErrorMessage.html">PetscErrorMessage</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, const char *[], char **)</font></strong>;
<a name="line1310">1310: </a><strong><font color="#4169E1"><a name="PetscTraceBackErrorHandler"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscTraceBackErrorHandler.html">PetscTraceBackErrorHandler</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a>;
<a name="line1311">1311: </a><strong><font color="#4169E1"><a name="PetscIgnoreErrorHandler"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscIgnoreErrorHandler.html">PetscIgnoreErrorHandler</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a>;
<a name="line1312">1312: </a><strong><font color="#4169E1"><a name="PetscEmacsClientErrorHandler"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscEmacsClientErrorHandler.html">PetscEmacsClientErrorHandler</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a>;
<a name="line1313">1313: </a><strong><font color="#4169E1"><a name="PetscMPIAbortErrorHandler"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscMPIAbortErrorHandler.html">PetscMPIAbortErrorHandler</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a>;
<a name="line1314">1314: </a><strong><font color="#4169E1"><a name="PetscAbortErrorHandler"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscAbortErrorHandler.html">PetscAbortErrorHandler</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a>;
<a name="line1315">1315: </a><strong><font color="#4169E1"><a name="PetscAttachDebuggerErrorHandler"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscAttachDebuggerErrorHandler.html">PetscAttachDebuggerErrorHandler</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a>;
<a name="line1316">1316: </a><strong><font color="#4169E1"><a name="PetscReturnErrorHandler"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscReturnErrorHandler.html">PetscReturnErrorHandler</a>(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_COLD.html">PETSC_ATTRIBUTE_COLD</a>;
<a name="line1317">1317: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> (*handler)(<a href="../manualpages/Sys/MPI_Comm.html">MPI_Comm</a>, int, const char *, const char *, <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>, <a href="../manualpages/Sys/PetscErrorType.html">PetscErrorType</a>, const char *, void *), void *)</font></strong>;
<a name="line1318">1318: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscPopErrorHandler.html">PetscPopErrorHandler</a>(void)</font></strong>;
<a name="line1319">1319: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscSignalHandlerDefault.html">PetscSignalHandlerDefault</a>(int, void *)</font></strong>;
<a name="line1320">1320: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscPushSignalHandler.html">PetscPushSignalHandler</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> (*)(int, void *), void *)</font></strong>;
<a name="line1321">1321: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscPopSignalHandler.html">PetscPopSignalHandler</a>(void)</font></strong>;
<a name="line1322">1322: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscCheckPointerSetIntensity.html">PetscCheckPointerSetIntensity</a>(<a href="../manualpages/Sys/PetscInt.html">PetscInt</a>)</font></strong>;
<a name="line1323">1323: </a><strong><font color="#4169E1">PETSC_EXTERN void <a href="../manualpages/Sys/PetscSignalSegvCheckPointerOrMpi.html">PetscSignalSegvCheckPointerOrMpi</a>(void)</font></strong>;
<a name="line1324">1324: </a>PETSC_DEPRECATED_FUNCTION(3, 13, 0, <font color="#666666">"<a href="../manualpages/Sys/PetscSignalSegvCheckPointerOrMpi.html">PetscSignalSegvCheckPointerOrMpi</a>()"</font>, ) static inline void PetscSignalSegvCheckPointer(void)
<a name="line1325">1325: </a>{
<a name="line1326">1326: </a> <a href="../manualpages/Sys/PetscSignalSegvCheckPointerOrMpi.html">PetscSignalSegvCheckPointerOrMpi</a>();
<a name="line1327">1327: </a>}
<a name="line1329">1329: </a><font color="#B22222">/*MC</font>
<a name="line1330">1330: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorPrintf.html">PetscErrorPrintf</a> - Prints error messages.</font>
<a name="line1332">1332: </a><font color="#B22222"> Synopsis:</font>
<a name="line1333">1333: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1334">1334: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> (*<a href="../manualpages/Sys/PetscErrorPrintf.html">PetscErrorPrintf</a>)(const char format[], ...);</font>
<a name="line1336">1336: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line1338">1338: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1339">1339: </a><font color="#B22222">. format - the usual `printf()` format string</font>
<a name="line1341">1341: </a><font color="#B22222"> Options Database Keys:</font>
<a name="line1342">1342: </a><font color="#B22222">+ -error_output_stdout - cause error messages to be printed to stdout instead of the (default) stderr</font>
<a name="line1343">1343: </a><font color="#B22222">- -error_output_none - to turn off all printing of error messages (does not change the way the error is handled.)</font>
<a name="line1345">1345: </a><font color="#B22222"> Level: developer</font>
<a name="line1347">1347: </a><font color="#B22222"> Notes:</font>
<a name="line1348">1348: </a><font color="#B22222"> Use</font>
<a name="line1349">1349: </a><font color="#B22222">.vb</font>
<a name="line1350">1350: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorPrintf.html">PetscErrorPrintf</a> = PetscErrorPrintfNone; to turn off all printing of error messages (does not change the way the error is handled) and</font>
<a name="line1351">1351: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorPrintf.html">PetscErrorPrintf</a> = PetscErrorPrintfDefault; to turn it back on or you can use your own function</font>
<a name="line1352">1352: </a><font color="#B22222">.ve</font>
<a name="line1353">1353: </a><font color="#B22222"> Use</font>
<a name="line1354">1354: </a><font color="#B22222">.vb</font>
<a name="line1355">1355: </a><font color="#B22222"> `PETSC_STDERR` = FILE* obtained from a file open etc. to have stderr printed to the file.</font>
<a name="line1356">1356: </a><font color="#B22222"> `PETSC_STDOUT` = FILE* obtained from a file open etc. to have stdout printed to the file.</font>
<a name="line1357">1357: </a><font color="#B22222">.ve</font>
<a name="line1358">1358: </a><font color="#B22222"> Use</font>
<a name="line1359">1359: </a><font color="#B22222">.vb</font>
<a name="line1360">1360: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()` to provide your own error handler that determines what kind of messages to print</font>
<a name="line1361">1361: </a><font color="#B22222">.ve</font>
<a name="line1363">1363: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscFPrintf.html">PetscFPrintf</a>()`, `<a href="../manualpages/Sys/PetscSynchronizedPrintf.html">PetscSynchronizedPrintf</a>()`, `<a href="../manualpages/Sys/PetscHelpPrintf.html">PetscHelpPrintf</a>()`, `<a href="../manualpages/Sys/PetscPrintf.html">PetscPrintf</a>()`, `<a href="../manualpages/Sys/PetscPushErrorHandler.html">PetscPushErrorHandler</a>()`, `PetscVFPrintf()`, `<a href="../manualpages/Sys/PetscHelpPrintf.html">PetscHelpPrintf</a>()`</font>
<a name="line1364">1364: </a><font color="#B22222">M*/</font>
<a name="line1365">1365: </a><strong><font color="#4169E1"><a name="PetscErrorCode"></a>PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> (*<a href="../manualpages/Sys/PetscErrorPrintf.html">PetscErrorPrintf</a>)(const char[], ...)</font></strong> <a href="../manualpages/Sys/PETSC_ATTRIBUTE_FORMAT.html">PETSC_ATTRIBUTE_FORMAT</a>(1, 2);
<a name="line1367">1367: </a><font color="#B22222">/*E</font>
<a name="line1368">1368: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFPTrap.html">PetscFPTrap</a> - types of floating point exceptions that may be trapped</font>
<a name="line1370">1370: </a><font color="#B22222"> Currently only `<a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_OFF</a>` and `<a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_ON</a>` are handled. All others are treated as `<a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_ON</a>`.</font>
<a name="line1372">1372: </a><font color="#B22222"> Level: intermediate</font>
<a name="line1374">1374: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscSetFPTrap.html">PetscSetFPTrap</a>()`, `<a href="../manualpages/Sys/PetscFPTrapPush.html">PetscFPTrapPush</a>()`</font>
<a name="line1375">1375: </a><font color="#B22222"> E*/</font>
<a name="line1376">1376: </a><font color="#4169E1">typedef</font> <font color="#4169E1">enum</font> {
<a name="line1377">1377: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_OFF</a> = 0,
<a name="line1378">1378: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_INDIV</a> = 1,
<a name="line1379">1379: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_FLTOPERR</a> = 2,
<a name="line1380">1380: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_FLTOVF</a> = 4,
<a name="line1381">1381: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_FLTUND</a> = 8,
<a name="line1382">1382: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_FLTDIV</a> = 16,
<a name="line1383">1383: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_FLTINEX</a> = 32,
<a name="line1384">1384: </a> <a href="../manualpages/Sys/PetscFPTrap.html">PETSC_FP_TRAP_ON</a> = 63
<a name="line1385">1385: </a>} <a href="../manualpages/Sys/PetscFPTrap.html">PetscFPTrap</a>;
<a name="line1387">1387: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscSetFPTrap.html">PetscSetFPTrap</a>(<a href="../manualpages/Sys/PetscFPTrap.html">PetscFPTrap</a>)</font></strong>;
<a name="line1388">1388: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscFPTrapPush.html">PetscFPTrapPush</a>(<a href="../manualpages/Sys/PetscFPTrap.html">PetscFPTrap</a>)</font></strong>;
<a name="line1389">1389: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscFPTrapPop.html">PetscFPTrapPop</a>(void)</font></strong>;
<a name="line1390">1390: </a><strong><font color="#4169E1">PETSC_EXTERN <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> <a href="../manualpages/Sys/PetscDetermineInitialFPTrap.html">PetscDetermineInitialFPTrap</a>(void)</font></strong>;
<a name="line1392">1392: </a><font color="#B22222">/*</font>
<a name="line1393">1393: </a><font color="#B22222"> Allows the code to build a stack frame as it runs</font>
<a name="line1394">1394: </a><font color="#B22222">*/</font>
<a name="line1396">1396: </a><strong><font color="#228B22">#define PETSCSTACKSIZE 64</font></strong>
<a name="line1397">1397: </a><font color="#4169E1">typedef</font> <font color="#4169E1">struct</font> {
<a name="line1398">1398: </a> const char *function[PETSCSTACKSIZE];
<a name="line1399">1399: </a> const char *file[PETSCSTACKSIZE];
<a name="line1400">1400: </a> int line[PETSCSTACKSIZE];
<a name="line1401">1401: </a> int petscroutine[PETSCSTACKSIZE]; <font color="#B22222">/* 0 external called from PETSc, 1 PETSc functions, 2 PETSc user functions */</font>
<a name="line1402">1402: </a> int currentsize;
<a name="line1403">1403: </a> int hotdepth;
<a name="line1404">1404: </a> <a href="../manualpages/Sys/PetscBool.html">PetscBool</a> check; <font color="#B22222">/* option to check for correct Push/Pop semantics, true for default petscstack but not other stacks */</font>
<a name="line1405">1405: </a>} PetscStack;
<a name="line1406">1406: </a><font color="#A020F0">#if defined(PETSC_USE_DEBUG) && !defined(PETSC_HAVE_THREADSAFETY)</font>
<a name="line1407">1407: </a>PETSC_EXTERN PetscStack petscstack;
<a name="line1408">1408: </a><font color="#A020F0">#endif</font>
<a name="line1410">1410: </a><font color="#A020F0">#if defined(PETSC_SERIALIZE_FUNCTIONS)</font>
<a name="line1411">1411: </a>#include <A href="../include/petsc/private/petscfptimpl.h.html"><petsc/private/petscfptimpl.h></A>
<a name="line1412">1412: </a> <font color="#B22222">/*</font>
<a name="line1413">1413: </a><font color="#B22222"> Registers the current function into the global function pointer to function name table</font>
<a name="line1415">1415: </a><font color="#B22222"> Have to fix this to handle errors but cannot return error since used in <a href="../manualpages/Viewer/PETSC_VIEWER_DRAW_.html">PETSC_VIEWER_DRAW_</a>() etc</font>
<a name="line1416">1416: </a><font color="#B22222">*/</font>
<a name="line1417">1417: </a><strong><font color="#228B22"> #define PetscRegister__FUNCT__() \</font></strong>
<a name="line1418">1418: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1419">1419: </a><strong><font color="#228B22"> static <a href="../manualpages/Sys/PetscBool.html">PetscBool</a> __chked = <a href="../manualpages/Sys/PETSC_FALSE.html">PETSC_FALSE</a>; \</font></strong>
<a name="line1420">1420: </a><strong><font color="#228B22"> if (!__chked) { \</font></strong>
<a name="line1421">1421: </a><strong><font color="#228B22"> void *ptr; \</font></strong>
<a name="line1422">1422: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscCallAbort.html">PetscCallAbort</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, <a href="../manualpages/Sys/PetscDLSym.html">PetscDLSym</a>(NULL, PETSC_FUNCTION_NAME, &ptr)); \</font></strong>
<a name="line1423">1423: </a><strong><font color="#228B22"> __chked = <a href="../manualpages/Sys/PETSC_TRUE.html">PETSC_TRUE</a>; \</font></strong>
<a name="line1424">1424: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1425">1425: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1426">1426: </a><font color="#A020F0">#else</font>
<a name="line1427">1427: </a><strong><font color="#228B22"> #define PetscRegister__FUNCT__()</font></strong>
<a name="line1428">1428: </a><font color="#A020F0">#endif</font>
<a name="line1430">1430: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER) || defined(__clang_analyzer__)</font>
<a name="line1431">1431: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(funct, petsc_routine, hot)</font></strong>
<a name="line1432">1432: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a></font></strong>
<a name="line1433">1433: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>(funct)</font></strong>
<a name="line1434">1434: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(funct)</font></strong>
<a name="line1435">1435: </a><strong><font color="#228B22"> #define PetscStackClearTop</font></strong>
<a name="line1436">1436: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a></font></strong>
<a name="line1437">1437: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a></font></strong>
<a name="line1438">1438: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a></font></strong>
<a name="line1439">1439: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(...) return __VA_ARGS__</font></strong>
<a name="line1440">1440: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>() return</font></strong>
<a name="line1441">1441: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a></font></strong>
<a name="line1442">1442: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>(f)</font></strong>
<a name="line1443">1443: </a><strong><font color="#228B22"> #define PetscStackPush_Private(stack__, file__, func__, line__, petsc_routine__, hot__) \</font></strong>
<a name="line1444">1444: </a><strong><font color="#228B22"> (void)file__; \</font></strong>
<a name="line1445">1445: </a><strong><font color="#228B22"> (void)func__; \</font></strong>
<a name="line1446">1446: </a><strong><font color="#228B22"> (void)line__</font></strong>
<a name="line1447">1447: </a><strong><font color="#228B22"> #define PetscStackPop_Private(stack__, func__) (void)func__</font></strong>
<a name="line1448">1448: </a><font color="#A020F0">#elif defined(PETSC_USE_DEBUG) && !defined(PETSC_HAVE_THREADSAFETY)</font>
<a name="line1450">1450: </a><strong><font color="#228B22"> #define PetscStackPush_Private(stack__, file__, func__, line__, petsc_routine__, hot__) \</font></strong>
<a name="line1451">1451: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1452">1452: </a><strong><font color="#228B22"> if (stack__.currentsize < PETSCSTACKSIZE) { \</font></strong>
<a name="line1453">1453: </a><strong><font color="#228B22"> stack__.function[stack__.currentsize] = func__; \</font></strong>
<a name="line1454">1454: </a><strong><font color="#228B22"> if (petsc_routine__) { \</font></strong>
<a name="line1455">1455: </a><strong><font color="#228B22"> stack__.file[stack__.currentsize] = file__; \</font></strong>
<a name="line1456">1456: </a><strong><font color="#228B22"> stack__.line[stack__.currentsize] = line__; \</font></strong>
<a name="line1457">1457: </a><strong><font color="#228B22"> } else { \</font></strong>
<a name="line1458">1458: </a><strong><font color="#228B22"> stack__.file[stack__.currentsize] = <a href="../manualpages/Sys/PETSC_NULLPTR.html">PETSC_NULLPTR</a>; \</font></strong>
<a name="line1459">1459: </a><strong><font color="#228B22"> stack__.line[stack__.currentsize] = 0; \</font></strong>
<a name="line1460">1460: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1461">1461: </a><strong><font color="#228B22"> stack__.petscroutine[stack__.currentsize] = petsc_routine__; \</font></strong>
<a name="line1462">1462: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1463">1463: </a><strong><font color="#228B22"> ++stack__.currentsize; \</font></strong>
<a name="line1464">1464: </a><strong><font color="#228B22"> stack__.hotdepth += (hot__ || stack__.hotdepth); \</font></strong>
<a name="line1465">1465: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1467">1467: </a> <font color="#B22222">/* uses <a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>() because may be used in a function that does not return an error code */</font>
<a name="line1468">1468: </a><strong><font color="#228B22"> #define PetscStackPop_Private(stack__, func__) \</font></strong>
<a name="line1469">1469: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1470">1470: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>(!stack__.check || stack__.currentsize > 0, <a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_PLIB</a>, </font><font color="#666666">"Invalid stack size %d, pop %s %s:%d.\n"</font><font color="#228B22">, stack__.currentsize, func__, __FILE__, __LINE__); \</font></strong>
<a name="line1471">1471: </a><strong><font color="#228B22"> if (--stack__.currentsize < PETSCSTACKSIZE) { \</font></strong>
<a name="line1472">1472: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscCheckAbort.html">PetscCheckAbort</a>(!stack__.check || stack__.petscroutine[stack__.currentsize] != 1 || stack__.function[stack__.currentsize] == func__, <a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_PLIB</a>, </font><font color="#666666">"Invalid stack: push from %s %s:%d. Pop from %s %s:%d.\n"</font><font color="#228B22">, \</font></strong>
<a name="line1473">1473: </a><strong><font color="#228B22"> stack__.function[stack__.currentsize], stack__.file[stack__.currentsize], stack__.line[stack__.currentsize], func__, __FILE__, __LINE__); \</font></strong>
<a name="line1474">1474: </a><strong><font color="#228B22"> stack__.function[stack__.currentsize] = <a href="../manualpages/Sys/PETSC_NULLPTR.html">PETSC_NULLPTR</a>; \</font></strong>
<a name="line1475">1475: </a><strong><font color="#228B22"> stack__.file[stack__.currentsize] = <a href="../manualpages/Sys/PETSC_NULLPTR.html">PETSC_NULLPTR</a>; \</font></strong>
<a name="line1476">1476: </a><strong><font color="#228B22"> stack__.line[stack__.currentsize] = 0; \</font></strong>
<a name="line1477">1477: </a><strong><font color="#228B22"> stack__.petscroutine[stack__.currentsize] = 0; \</font></strong>
<a name="line1478">1478: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1479">1479: </a><strong><font color="#228B22"> stack__.hotdepth = <a href="../manualpages/Sys/PetscMax.html">PetscMax</a>(stack__.hotdepth - 1, 0); \</font></strong>
<a name="line1480">1480: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1482">1482: </a> <font color="#B22222">/*MC</font>
<a name="line1483">1483: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a> - Pushes a new function name and line number onto the PETSc default stack that tracks where the running program is</font>
<a name="line1484">1484: </a><font color="#B22222"> currently in the source code.</font>
<a name="line1486">1486: </a><font color="#B22222"> Synopsis:</font>
<a name="line1487">1487: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1488">1488: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(char *funct,int petsc_routine,<a href="../manualpages/Sys/PetscBool.html">PetscBool</a> hot);</font>
<a name="line1490">1490: </a><font color="#B22222"> Not Collective</font>
<a name="line1492">1492: </a><font color="#B22222"> Input Parameters:</font>
<a name="line1493">1493: </a><font color="#B22222">+ funct - the function name</font>
<a name="line1494">1494: </a><font color="#B22222">. petsc_routine - 2 user function, 1 PETSc function, 0 some other function</font>
<a name="line1495">1495: </a><font color="#B22222">- hot - indicates that the function may be called often so expensive error checking should be turned off inside the function</font>
<a name="line1497">1497: </a><font color="#B22222"> Level: developer</font>
<a name="line1499">1499: </a><font color="#B22222"> Notes:</font>
<a name="line1500">1500: </a><font color="#B22222"> In debug mode PETSc maintains a stack of the current function calls that can be used to help to quickly see where a problem has</font>
<a name="line1501">1501: </a><font color="#B22222"> occurred, for example, when a signal is received without running in the debugger. It is recommended to use the debugger if extensive information is needed to</font>
<a name="line1502">1502: </a><font color="#B22222"> help debug the problem.</font>
<a name="line1504">1504: </a><font color="#B22222"> This version does not check the memory corruption (an expensive operation), use `<a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>()` to check the memory.</font>
<a name="line1506">1506: </a><font color="#B22222"> Use `<a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>()` for a function call that is about to be made to a non-PETSc or user function (such as BLAS etc).</font>
<a name="line1508">1508: </a><font color="#B22222"> The default stack is a global variable called `petscstack`.</font>
<a name="line1510">1510: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAttachDebugger.html">PetscAttachDebugger</a>()`, `PetscStackCopy()`, `PetscStackView()`, `<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>()`,</font>
<a name="line1511">1511: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>()`, `<a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>()`, `<a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>`,</font>
<a name="line1512">1512: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>()`</font>
<a name="line1513">1513: </a><font color="#B22222">M*/</font>
<a name="line1514">1514: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(funct, petsc_routine, hot) \</font></strong>
<a name="line1515">1515: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1516">1516: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackSAWsTakeAccess.html">PetscStackSAWsTakeAccess</a>(); \</font></strong>
<a name="line1517">1517: </a><strong><font color="#228B22"> PetscStackPush_Private(petscstack, __FILE__, funct, __LINE__, petsc_routine, hot); \</font></strong>
<a name="line1518">1518: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackSAWsGrantAccess.html">PetscStackSAWsGrantAccess</a>(); \</font></strong>
<a name="line1519">1519: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1521">1521: </a> <font color="#B22222">/*MC</font>
<a name="line1522">1522: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a> - in a function that has a `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>` or `<a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>` updates the stack line number to the</font>
<a name="line1523">1523: </a><font color="#B22222"> current line number.</font>
<a name="line1525">1525: </a><font color="#B22222"> Synopsis:</font>
<a name="line1526">1526: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1527">1527: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a></font>
<a name="line1529">1529: </a><font color="#B22222"> Not Collective</font>
<a name="line1531">1531: </a><font color="#B22222"> Level: developer</font>
<a name="line1533">1533: </a><font color="#B22222"> Notes:</font>
<a name="line1534">1534: </a><font color="#B22222"> Using `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` and friends automatically handles this process</font>
<a name="line1536">1536: </a><font color="#B22222"> In debug mode PETSc maintains a stack of the current function calls that can be used to help to quickly see where a problem has</font>
<a name="line1537">1537: </a><font color="#B22222"> occurred, for example, when a signal is received. It is recommended to use the debugger if extensive information is needed to</font>
<a name="line1538">1538: </a><font color="#B22222"> help debug the problem.</font>
<a name="line1540">1540: </a><font color="#B22222"> The default stack is a global variable called `petscstack`.</font>
<a name="line1542">1542: </a><font color="#B22222"> This is used by `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()` and is otherwise not like to be needed</font>
<a name="line1544">1544: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAttachDebugger.html">PetscAttachDebugger</a>()`, `PetscStackCopy()`, `PetscStackView()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`</font>
<a name="line1545">1545: </a><font color="#B22222">M*/</font>
<a name="line1546">1546: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a> \</font></strong>
<a name="line1547">1547: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1548">1548: </a><strong><font color="#228B22"> if (petscstack.currentsize > 0 && petscstack.currentsize < PETSCSTACKSIZE && petscstack.function[petscstack.currentsize - 1] == PETSC_FUNCTION_NAME) { petscstack.line[petscstack.currentsize - 1] = __LINE__; } \</font></strong>
<a name="line1549">1549: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1551">1551: </a> <font color="#B22222">/*MC</font>
<a name="line1552">1552: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a> - Pushes a new function name onto the PETSc default stack that tracks where the running program is</font>
<a name="line1553">1553: </a><font color="#B22222"> currently in the source code. Does not include the filename or line number since this is called by the calling routine</font>
<a name="line1554">1554: </a><font color="#B22222"> for non-PETSc or user functions.</font>
<a name="line1556">1556: </a><font color="#B22222"> Synopsis:</font>
<a name="line1557">1557: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1558">1558: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>(char *funct);</font>
<a name="line1560">1560: </a><font color="#B22222"> Not Collective</font>
<a name="line1562">1562: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1563">1563: </a><font color="#B22222">. funct - the function name</font>
<a name="line1565">1565: </a><font color="#B22222"> Level: developer</font>
<a name="line1567">1567: </a><font color="#B22222"> Notes:</font>
<a name="line1568">1568: </a><font color="#B22222"> Using `PetscCallExternal()` and friends automatically handles this process</font>
<a name="line1570">1570: </a><font color="#B22222"> In debug mode PETSc maintains a stack of the current function calls that can be used to help to quickly see where a problem has</font>
<a name="line1571">1571: </a><font color="#B22222"> occurred, for example, when a signal is received. It is recommended to use the debugger if extensive information is needed to</font>
<a name="line1572">1572: </a><font color="#B22222"> help debug the problem.</font>
<a name="line1574">1574: </a><font color="#B22222"> The default stack is a global variable called `petscstack`.</font>
<a name="line1576">1576: </a><font color="#B22222"> This is to be used when calling an external package function such as a BLAS function.</font>
<a name="line1578">1578: </a><font color="#B22222"> This also updates the stack line number for the current stack function.</font>
<a name="line1580">1580: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAttachDebugger.html">PetscAttachDebugger</a>()`, `PetscStackCopy()`, `PetscStackView()`, `<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>()`,</font>
<a name="line1581">1581: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>`</font>
<a name="line1582">1582: </a><font color="#B22222">M*/</font>
<a name="line1583">1583: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>(funct) \</font></strong>
<a name="line1584">1584: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1585">1585: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line1586">1586: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(funct, 0, <a href="../manualpages/Sys/PETSC_TRUE.html">PETSC_TRUE</a>); \</font></strong>
<a name="line1587">1587: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1589">1589: </a> <font color="#B22222">/*MC</font>
<a name="line1590">1590: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a> - Pops a function name from the PETSc default stack that tracks where the running program is</font>
<a name="line1591">1591: </a><font color="#B22222"> currently in the source code.</font>
<a name="line1593">1593: </a><font color="#B22222"> Synopsis:</font>
<a name="line1594">1594: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1595">1595: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(char *funct);</font>
<a name="line1597">1597: </a><font color="#B22222"> Not Collective</font>
<a name="line1599">1599: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1600">1600: </a><font color="#B22222">. funct - the function name</font>
<a name="line1602">1602: </a><font color="#B22222"> Level: developer</font>
<a name="line1604">1604: </a><font color="#B22222"> Notes:</font>
<a name="line1605">1605: </a><font color="#B22222"> Using `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `PetscCallExternal()`, `<a href="../manualpages/Sys/PetscCallBack.html">PetscCallBack</a>()` and friends negates the need to call this</font>
<a name="line1607">1607: </a><font color="#B22222"> In debug mode PETSc maintains a stack of the current function calls that can be used to help to quickly see where a problem has</font>
<a name="line1608">1608: </a><font color="#B22222"> occurred, for example, when a signal is received. It is recommended to use the debugger if extensive information is needed to</font>
<a name="line1609">1609: </a><font color="#B22222"> help debug the problem.</font>
<a name="line1611">1611: </a><font color="#B22222"> The default stack is a global variable called `petscstack`.</font>
<a name="line1613">1613: </a><font color="#B22222"> Developer Note:</font>
<a name="line1614">1614: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>()` takes a function argument while `<a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>` does not, this difference is likely just historical.</font>
<a name="line1616">1616: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAttachDebugger.html">PetscAttachDebugger</a>()`, `PetscStackCopy()`, `PetscStackView()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>`</font>
<a name="line1617">1617: </a><font color="#B22222">M*/</font>
<a name="line1618">1618: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(funct) \</font></strong>
<a name="line1619">1619: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1620">1620: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackSAWsTakeAccess.html">PetscStackSAWsTakeAccess</a>(); \</font></strong>
<a name="line1621">1621: </a><strong><font color="#228B22"> PetscStackPop_Private(petscstack, funct); \</font></strong>
<a name="line1622">1622: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackSAWsGrantAccess.html">PetscStackSAWsGrantAccess</a>(); \</font></strong>
<a name="line1623">1623: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1625">1625: </a><strong><font color="#228B22"> #define PetscStackClearTop \</font></strong>
<a name="line1626">1626: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1627">1627: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackSAWsTakeAccess.html">PetscStackSAWsTakeAccess</a>(); \</font></strong>
<a name="line1628">1628: </a><strong><font color="#228B22"> if (petscstack.currentsize > 0 && --petscstack.currentsize < PETSCSTACKSIZE) { \</font></strong>
<a name="line1629">1629: </a><strong><font color="#228B22"> petscstack.function[petscstack.currentsize] = <a href="../manualpages/Sys/PETSC_NULLPTR.html">PETSC_NULLPTR</a>; \</font></strong>
<a name="line1630">1630: </a><strong><font color="#228B22"> petscstack.file[petscstack.currentsize] = <a href="../manualpages/Sys/PETSC_NULLPTR.html">PETSC_NULLPTR</a>; \</font></strong>
<a name="line1631">1631: </a><strong><font color="#228B22"> petscstack.line[petscstack.currentsize] = 0; \</font></strong>
<a name="line1632">1632: </a><strong><font color="#228B22"> petscstack.petscroutine[petscstack.currentsize] = 0; \</font></strong>
<a name="line1633">1633: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1634">1634: </a><strong><font color="#228B22"> petscstack.hotdepth = <a href="../manualpages/Sys/PetscMax.html">PetscMax</a>(petscstack.hotdepth - 1, 0); \</font></strong>
<a name="line1635">1635: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackSAWsGrantAccess.html">PetscStackSAWsGrantAccess</a>(); \</font></strong>
<a name="line1636">1636: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1638">1638: </a> <font color="#B22222">/*MC</font>
<a name="line1639">1639: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a> - First executable line of each PETSc function, used for error handling. Final</font>
<a name="line1640">1640: </a><font color="#B22222"> line of PETSc functions should be `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>`(0);</font>
<a name="line1642">1642: </a><font color="#B22222"> Synopsis:</font>
<a name="line1643">1643: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1644">1644: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>;</font>
<a name="line1646">1646: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line1648">1648: </a><font color="#B22222"> Usage:</font>
<a name="line1649">1649: </a><font color="#B22222">.vb</font>
<a name="line1650">1650: </a><font color="#B22222"> int something;</font>
<a name="line1652">1652: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>;</font>
<a name="line1653">1653: </a><font color="#B22222">.ve</font>
<a name="line1655">1655: </a><font color="#B22222"> Level: developer</font>
<a name="line1657">1657: </a><font color="#B22222"> Note:</font>
<a name="line1658">1658: </a><font color="#B22222"> Use `<a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>` for application codes.</font>
<a name="line1660">1660: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`</font>
<a name="line1662">1662: </a><font color="#B22222">M*/</font>
<a name="line1663">1663: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a> \</font></strong>
<a name="line1664">1664: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1665">1665: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(PETSC_FUNCTION_NAME, 1, <a href="../manualpages/Sys/PETSC_FALSE.html">PETSC_FALSE</a>); \</font></strong>
<a name="line1666">1666: </a><strong><font color="#228B22"> PetscRegister__FUNCT__(); \</font></strong>
<a name="line1667">1667: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1669">1669: </a> <font color="#B22222">/*MC</font>
<a name="line1670">1670: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a> - Substitute for `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>` to be used in functions that are called in</font>
<a name="line1671">1671: </a><font color="#B22222"> performance-critical circumstances. Use of this function allows for lighter profiling by default.</font>
<a name="line1673">1673: </a><font color="#B22222"> Synopsis:</font>
<a name="line1674">1674: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1675">1675: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a>;</font>
<a name="line1677">1677: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line1679">1679: </a><font color="#B22222"> Usage:</font>
<a name="line1680">1680: </a><font color="#B22222">.vb</font>
<a name="line1681">1681: </a><font color="#B22222"> int something;</font>
<a name="line1683">1683: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a>;</font>
<a name="line1684">1684: </a><font color="#B22222">.ve</font>
<a name="line1686">1686: </a><font color="#B22222"> Level: developer</font>
<a name="line1688">1688: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>`, `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`</font>
<a name="line1690">1690: </a><font color="#B22222">M*/</font>
<a name="line1691">1691: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a> \</font></strong>
<a name="line1692">1692: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1693">1693: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(PETSC_FUNCTION_NAME, 1, <a href="../manualpages/Sys/PETSC_TRUE.html">PETSC_TRUE</a>); \</font></strong>
<a name="line1694">1694: </a><strong><font color="#228B22"> PetscRegister__FUNCT__(); \</font></strong>
<a name="line1695">1695: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1697">1697: </a> <font color="#B22222">/*MC</font>
<a name="line1698">1698: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a> - First executable line of user provided routines</font>
<a name="line1700">1700: </a><font color="#B22222"> Synopsis:</font>
<a name="line1701">1701: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1702">1702: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>;</font>
<a name="line1704">1704: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line1706">1706: </a><font color="#B22222"> Usage:</font>
<a name="line1707">1707: </a><font color="#B22222">.vb</font>
<a name="line1708">1708: </a><font color="#B22222"> int something;</font>
<a name="line1710">1710: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>;</font>
<a name="line1711">1711: </a><font color="#B22222">.ve</font>
<a name="line1713">1713: </a><font color="#B22222"> Level: intermediate</font>
<a name="line1715">1715: </a><font color="#B22222"> Notes:</font>
<a name="line1716">1716: </a><font color="#B22222"> Functions that incorporate this must call `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()` instead of return except for main().</font>
<a name="line1718">1718: </a><font color="#B22222"> May be used before `<a href="../manualpages/Sys/PetscInitialize.html">PetscInitialize</a>()`</font>
<a name="line1720">1720: </a><font color="#B22222"> This is identical to `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>` except it labels the routine as a user</font>
<a name="line1721">1721: </a><font color="#B22222"> routine instead of as a PETSc library routine.</font>
<a name="line1723">1723: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()`, `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>`, `<a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a>`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`</font>
<a name="line1724">1724: </a><font color="#B22222">M*/</font>
<a name="line1725">1725: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a> \</font></strong>
<a name="line1726">1726: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1727">1727: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(PETSC_FUNCTION_NAME, 2, <a href="../manualpages/Sys/PETSC_FALSE.html">PETSC_FALSE</a>); \</font></strong>
<a name="line1728">1728: </a><strong><font color="#228B22"> PetscRegister__FUNCT__(); \</font></strong>
<a name="line1729">1729: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1731">1731: </a> <font color="#B22222">/*MC</font>
<a name="line1732">1732: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a> - Pushes a new function name and line number onto the PETSc default stack that tracks where the running program is</font>
<a name="line1733">1733: </a><font color="#B22222"> currently in the source code and verifies the memory is not corrupted.</font>
<a name="line1735">1735: </a><font color="#B22222"> Synopsis:</font>
<a name="line1736">1736: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1737">1737: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>(char *funct)</font>
<a name="line1739">1739: </a><font color="#B22222"> Not Collective</font>
<a name="line1741">1741: </a><font color="#B22222"> Input Parameter:</font>
<a name="line1742">1742: </a><font color="#B22222">. funct - the function name</font>
<a name="line1744">1744: </a><font color="#B22222"> Level: developer</font>
<a name="line1746">1746: </a><font color="#B22222"> Notes:</font>
<a name="line1747">1747: </a><font color="#B22222"> In debug mode PETSc maintains a stack of the current function calls that can be used to help to quickly see where a problem has</font>
<a name="line1748">1748: </a><font color="#B22222"> occurred, for example, when a signal is received. It is recommended to use the debugger if extensive information is needed to</font>
<a name="line1749">1749: </a><font color="#B22222"> help debug the problem.</font>
<a name="line1751">1751: </a><font color="#B22222"> The default stack is a global variable called `petscstack`.</font>
<a name="line1753">1753: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAttachDebugger.html">PetscAttachDebugger</a>()`, `PetscStackCopy()`, `PetscStackView()`, `<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>()`, `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>()`,</font>
<a name="line1754">1754: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a>()`, `<a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>`</font>
<a name="line1755">1755: </a><font color="#B22222">M*/</font>
<a name="line1756">1756: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>(n) \</font></strong>
<a name="line1757">1757: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1758">1758: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(n, 0, <a href="../manualpages/Sys/PETSC_FALSE.html">PETSC_FALSE</a>); \</font></strong>
<a name="line1759">1759: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>; \</font></strong>
<a name="line1760">1760: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1762">1762: </a> <font color="#B22222">/*MC</font>
<a name="line1763">1763: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a> - Pops a function name from the PETSc default stack that tracks where the running program is</font>
<a name="line1764">1764: </a><font color="#B22222"> currently in the source code and verifies the memory is not corrupted.</font>
<a name="line1766">1766: </a><font color="#B22222"> Synopsis:</font>
<a name="line1767">1767: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1768">1768: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a></font>
<a name="line1770">1770: </a><font color="#B22222"> Not Collective</font>
<a name="line1772">1772: </a><font color="#B22222"> Level: developer</font>
<a name="line1774">1774: </a><font color="#B22222"> Notes:</font>
<a name="line1775">1775: </a><font color="#B22222"> In debug mode PETSc maintains a stack of the current function calls that can be used to help to quickly see where a problem has</font>
<a name="line1776">1776: </a><font color="#B22222"> occurred, for example, when a signal is received. It is recommended to use the debugger if extensive information is needed to</font>
<a name="line1777">1777: </a><font color="#B22222"> help debug the problem.</font>
<a name="line1779">1779: </a><font color="#B22222"> The default stack is a global variable called `petscstack`.</font>
<a name="line1781">1781: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscAttachDebugger.html">PetscAttachDebugger</a>()`, `PetscStackCopy()`, `PetscStackView()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>()`</font>
<a name="line1782">1782: </a><font color="#B22222">M*/</font>
<a name="line1783">1783: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a> \</font></strong>
<a name="line1784">1784: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1785">1785: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a>; \</font></strong>
<a name="line1786">1786: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(PETSC_FUNCTION_NAME); \</font></strong>
<a name="line1787">1787: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1789">1789: </a> <font color="#B22222">/*MC</font>
<a name="line1790">1790: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a> - Last executable line of each PETSc function used for error</font>
<a name="line1791">1791: </a><font color="#B22222"> handling. Replaces `return()`.</font>
<a name="line1793">1793: </a><font color="#B22222"> Synopsis:</font>
<a name="line1794">1794: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1795">1795: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(...)</font>
<a name="line1797">1797: </a><font color="#B22222"> Not Collective; No Fortran Support</font>
<a name="line1799">1799: </a><font color="#B22222"> Level: beginner</font>
<a name="line1801">1801: </a><font color="#B22222"> Notes:</font>
<a name="line1802">1802: </a><font color="#B22222"> This routine is a macro, so while it does not "return" anything itself, it does return from</font>
<a name="line1803">1803: </a><font color="#B22222"> the function in the literal sense.</font>
<a name="line1805">1805: </a><font color="#B22222"> Usually the return value is the integer literal `0` (for example in any function returning</font>
<a name="line1806">1806: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a>`), however it is possible to return any arbitrary type. The arguments of</font>
<a name="line1807">1807: </a><font color="#B22222"> this macro are placed before the `return` statement as-is.</font>
<a name="line1809">1809: </a><font color="#B22222"> Any routine which returns via `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()` must begin with a corresponding</font>
<a name="line1810">1810: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>`.</font>
<a name="line1812">1812: </a><font color="#B22222"> For routines which return `void` use `<a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>()` instead.</font>
<a name="line1814">1814: </a><font color="#B22222"> Example Usage:</font>
<a name="line1815">1815: </a><font color="#B22222">.vb</font>
<a name="line1816">1816: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscErrorCode.html">PetscErrorCode</a> foo(int *x)</font>
<a name="line1817">1817: </a><font color="#B22222"> {</font>
<a name="line1818">1818: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>; // don't forget the begin!</font>
<a name="line1819">1819: </a><font color="#B22222"> *x = 10;</font>
<a name="line1820">1820: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(<a href="../manualpages/Sys/PetscErrorCode.html">PETSC_SUCCESS</a>);</font>
<a name="line1821">1821: </a><font color="#B22222"> }</font>
<a name="line1822">1822: </a><font color="#B22222">.ve</font>
<a name="line1824">1824: </a><font color="#B22222"> May return any arbitrary type\:</font>
<a name="line1825">1825: </a><font color="#B22222">.vb</font>
<a name="line1826">1826: </a><font color="#B22222"> struct Foo</font>
<a name="line1827">1827: </a><font color="#B22222"> {</font>
<a name="line1828">1828: </a><font color="#B22222"> int x;</font>
<a name="line1829">1829: </a><font color="#B22222"> };</font>
<a name="line1831">1831: </a><font color="#B22222"> struct Foo make_foo(int value)</font>
<a name="line1832">1832: </a><font color="#B22222"> {</font>
<a name="line1833">1833: </a><font color="#B22222"> struct Foo f;</font>
<a name="line1835">1835: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>;</font>
<a name="line1836">1836: </a><font color="#B22222"> f.x = value;</font>
<a name="line1837">1837: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(f);</font>
<a name="line1838">1838: </a><font color="#B22222"> }</font>
<a name="line1839">1839: </a><font color="#B22222">.ve</font>
<a name="line1841">1841: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>`, `<a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>`, `<a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>()`,</font>
<a name="line1842">1842: </a><font color="#B22222"> `<a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>()`</font>
<a name="line1843">1843: </a><font color="#B22222">M*/</font>
<a name="line1844">1844: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(...) \</font></strong>
<a name="line1845">1845: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1846">1846: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(PETSC_FUNCTION_NAME); \</font></strong>
<a name="line1847">1847: </a><strong><font color="#228B22"> return __VA_ARGS__; \</font></strong>
<a name="line1848">1848: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1850">1850: </a> <font color="#B22222">/*MC</font>
<a name="line1851">1851: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a> - Like `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()` but returns `void`</font>
<a name="line1853">1853: </a><font color="#B22222"> Synopsis:</font>
<a name="line1854">1854: </a>#include <A href="../include/petscsys.h.html"><petscsys.h></A>
<a name="line1855">1855: </a><font color="#B22222"> void <a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>()</font>
<a name="line1857">1857: </a><font color="#B22222"> Not Collective</font>
<a name="line1859">1859: </a><font color="#B22222"> Level: beginner</font>
<a name="line1861">1861: </a><font color="#B22222"> Note:</font>
<a name="line1862">1862: </a><font color="#B22222"> Behaves identically to `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()` except that it returns `void`. That is, this</font>
<a name="line1863">1863: </a><font color="#B22222"> macro culminates with `return`.</font>
<a name="line1865">1865: </a><font color="#B22222"> Example Usage:</font>
<a name="line1866">1866: </a><font color="#B22222">.vb</font>
<a name="line1867">1867: </a><font color="#B22222"> void foo()</font>
<a name="line1868">1868: </a><font color="#B22222"> {</font>
<a name="line1869">1869: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>; // must start with <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>!</font>
<a name="line1870">1870: </a><font color="#B22222"> bar();</font>
<a name="line1871">1871: </a><font color="#B22222"> baz();</font>
<a name="line1872">1872: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>();</font>
<a name="line1873">1873: </a><font color="#B22222"> }</font>
<a name="line1874">1874: </a><font color="#B22222">.ve</font>
<a name="line1876">1876: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>()`, `<a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a>`, <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a>`</font>
<a name="line1877">1877: </a><font color="#B22222">M*/</font>
<a name="line1878">1878: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>() \</font></strong>
<a name="line1879">1879: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1880">1880: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(PETSC_FUNCTION_NAME); \</font></strong>
<a name="line1881">1881: </a><strong><font color="#228B22"> return; \</font></strong>
<a name="line1882">1882: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1883">1883: </a><font color="#A020F0">#else </font><font color="#B22222">/* PETSC_USE_DEBUG */</font><font color="#A020F0"></font>
<a name="line1884">1884: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>(funct, petsc_routine, hot)</font></strong>
<a name="line1885">1885: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a></font></strong>
<a name="line1886">1886: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>(funct)</font></strong>
<a name="line1887">1887: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPopNoCheck.html">PetscStackPopNoCheck</a>(...)</font></strong>
<a name="line1888">1888: </a><strong><font color="#228B22"> #define PetscStackClearTop</font></strong>
<a name="line1889">1889: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBegin.html">PetscFunctionBegin</a></font></strong>
<a name="line1890">1890: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBeginUser.html">PetscFunctionBeginUser</a></font></strong>
<a name="line1891">1891: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionBeginHot.html">PetscFunctionBeginHot</a></font></strong>
<a name="line1892">1892: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionReturn.html">PetscFunctionReturn</a>(...) return __VA_ARGS__</font></strong>
<a name="line1893">1893: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscFunctionReturnVoid.html">PetscFunctionReturnVoid</a>() return</font></strong>
<a name="line1894">1894: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a> <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a></font></strong>
<a name="line1895">1895: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>(f) <a href="../manualpages/Sys/CHKMEMQ.html">CHKMEMQ</a></font></strong>
<a name="line1896">1896: </a><font color="#A020F0">#endif </font><font color="#B22222">/* PETSC_USE_DEBUG */</font><font color="#A020F0"></font>
<a name="line1898">1898: </a><font color="#A020F0">#if defined(PETSC_CLANG_STATIC_ANALYZER)</font>
<a name="line1899">1899: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackCallExternalVoid.html">PetscStackCallExternalVoid</a>(...)</font></strong>
<a name="line1900">1900: </a>template <typename F, typename... Args>
<a name="line1901">1901: </a><strong><font color="#4169E1">void PetscCallExternal(F, Args...)</font></strong>;
<a name="line1902">1902: </a>template <typename F, typename... Args>
<a name="line1903">1903: </a><strong><font color="#4169E1">void <a href="../manualpages/Sys/PetscCallExternalAbort.html">PetscCallExternalAbort</a>(F, Args...)</font></strong>;
<a name="line1904">1904: </a><font color="#A020F0">#else</font>
<a name="line1905">1905: </a> <font color="#B22222">/*MC</font>
<a name="line1906">1906: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscStackCallExternalVoid.html">PetscStackCallExternalVoid</a> - Calls an external library routine or user function after pushing the name of the routine on the stack.</font>
<a name="line1908">1908: </a><font color="#B22222"> Input Parameters:</font>
<a name="line1909">1909: </a><font color="#B22222">+ name - string that gives the name of the function being called</font>
<a name="line1910">1910: </a><font color="#B22222">- routine - actual call to the routine, for example, functionname(a,b)</font>
<a name="line1912">1912: </a><font color="#B22222"> Level: developer</font>
<a name="line1914">1914: </a><font color="#B22222"> Notes:</font>
<a name="line1915">1915: </a><font color="#B22222"> Often one should use `PetscCallExternal()` instead. This routine is intended for external library routines that DO NOT return error codes</font>
<a name="line1917">1917: </a><font color="#B22222"> In debug mode this also checks the memory for corruption at the end of the function call.</font>
<a name="line1919">1919: </a><font color="#B22222"> Certain external packages, such as BLAS/LAPACK may have their own macros, `<a href="../manualpages/Sys/PetscCallBLAS.html">PetscCallBLAS</a>()` for managing the call, error checking, etc.</font>
<a name="line1921">1921: </a><font color="#B22222"> Developer Note:</font>
<a name="line1922">1922: </a><font color="#B22222"> This is so that when a user or external library routine results in a crash or corrupts memory, they get blamed instead of PETSc.</font>
<a name="line1924">1924: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>()`, `PetscCallExternal()`, `<a href="../manualpages/Sys/PetscCallBLAS.html">PetscCallBLAS</a>()`</font>
<a name="line1925">1925: </a><font color="#B22222">@*/</font>
<a name="line1926">1926: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscStackCallExternalVoid.html">PetscStackCallExternalVoid</a>(name, ...) \</font></strong>
<a name="line1927">1927: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1928">1928: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPushExternal.html">PetscStackPushExternal</a>(name); \</font></strong>
<a name="line1929">1929: </a><strong><font color="#228B22"> __VA_ARGS__; \</font></strong>
<a name="line1930">1930: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>; \</font></strong>
<a name="line1931">1931: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1933">1933: </a> <font color="#B22222">/*MC</font>
<a name="line1934">1934: </a><font color="#B22222"> PetscCallExternal - Calls an external library routine that returns an error code after pushing the name of the routine on the stack.</font>
<a name="line1936">1936: </a><font color="#B22222"> Input Parameters:</font>
<a name="line1937">1937: </a><font color="#B22222">+ func - name of the routine</font>
<a name="line1938">1938: </a><font color="#B22222">- args - arguments to the routine</font>
<a name="line1940">1940: </a><font color="#B22222"> Level: developer</font>
<a name="line1942">1942: </a><font color="#B22222"> Notes:</font>
<a name="line1943">1943: </a><font color="#B22222"> This is intended for external package routines that return error codes. Use `<a href="../manualpages/Sys/PetscStackCallExternalVoid.html">PetscStackCallExternalVoid</a>()` for those that do not.</font>
<a name="line1945">1945: </a><font color="#B22222"> In debug mode this also checks the memory for corruption at the end of the function call.</font>
<a name="line1947">1947: </a><font color="#B22222"> Assumes the error return code of the function is an integer and that a value of 0 indicates success</font>
<a name="line1949">1949: </a><font color="#B22222"> Developer Note:</font>
<a name="line1950">1950: </a><font color="#B22222"> This is so that when an external package routine results in a crash or corrupts memory, they get blamed instead of PETSc.</font>
<a name="line1952">1952: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>()`, `<a href="../manualpages/Sys/PetscStackCallExternalVoid.html">PetscStackCallExternalVoid</a>()`, `<a href="../manualpages/Sys/PetscCallExternalAbort.html">PetscCallExternalAbort</a>()`</font>
<a name="line1953">1953: </a><font color="#B22222">M*/</font>
<a name="line1954">1954: </a><strong><font color="#228B22"> #define PetscCallExternal(func, ...) \</font></strong>
<a name="line1955">1955: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1956">1956: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>(<a href="../manualpages/Sys/PetscStringize.html">PetscStringize</a>(func)); \</font></strong>
<a name="line1957">1957: </a><strong><font color="#228B22"> int ierr_petsc_call_external_ = (int)func(__VA_ARGS__); \</font></strong>
<a name="line1958">1958: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackPop.html">PetscStackPop</a>; \</font></strong>
<a name="line1959">1959: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscCheck.html">PetscCheck</a>(ierr_petsc_call_external_ == 0, <a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_LIB</a>, </font><font color="#666666">"Error in %s(): error code %d"</font><font color="#228B22">, <a href="../manualpages/Sys/PetscStringize.html">PetscStringize</a>(func), ierr_petsc_call_external_); \</font></strong>
<a name="line1960">1960: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1962">1962: </a> <font color="#B22222">/*MC</font>
<a name="line1963">1963: </a><font color="#B22222"> <a href="../manualpages/Sys/PetscCallExternalAbort.html">PetscCallExternalAbort</a> - Calls an external library routine that returns an error code after pushing the name of the routine on the stack. If the external library function return code indicates an error, this prints the error and aborts</font>
<a name="line1965">1965: </a><font color="#B22222"> Input Parameters:</font>
<a name="line1966">1966: </a><font color="#B22222">+ func - name of the routine</font>
<a name="line1967">1967: </a><font color="#B22222">- args - arguments to the routine</font>
<a name="line1969">1969: </a><font color="#B22222"> Level: developer</font>
<a name="line1971">1971: </a><font color="#B22222"> Notes:</font>
<a name="line1972">1972: </a><font color="#B22222"> This is intended for external package routines that return error codes. Use `<a href="../manualpages/Sys/PetscStackCallExternalVoid.html">PetscStackCallExternalVoid</a>()` for those that do not.</font>
<a name="line1974">1974: </a><font color="#B22222"> In debug mode this also checks the memory for corruption at the end of the function call.</font>
<a name="line1976">1976: </a><font color="#B22222"> Assumes the error return code of the function is an integer and that a value of 0 indicates success</font>
<a name="line1978">1978: </a><font color="#B22222"> Developer Note:</font>
<a name="line1979">1979: </a><font color="#B22222"> This is so that when an external package routine results in a crash or corrupts memory, they get blamed instead of PETSc.</font>
<a name="line1981">1981: </a><font color="#B22222">.seealso: `<a href="../manualpages/Sys/PetscCall.html">PetscCall</a>()`, `<a href="../manualpages/Sys/PetscStackPushNoCheck.html">PetscStackPushNoCheck</a>()`, `<a href="../manualpages/Sys/PetscStackPush.html">PetscStackPush</a>()`, `<a href="../manualpages/Sys/PetscStackCallExternalVoid.html">PetscStackCallExternalVoid</a>()`, `PetscCallExternal()`</font>
<a name="line1982">1982: </a><font color="#B22222">M*/</font>
<a name="line1983">1983: </a><strong><font color="#228B22"> #define <a href="../manualpages/Sys/PetscCallExternalAbort.html">PetscCallExternalAbort</a>(func, ...) \</font></strong>
<a name="line1984">1984: </a><strong><font color="#228B22"> do { \</font></strong>
<a name="line1985">1985: </a><strong><font color="#228B22"> <a href="../manualpages/Sys/PetscStackUpdateLine.html">PetscStackUpdateLine</a>; \</font></strong>
<a name="line1986">1986: </a><strong><font color="#228B22"> int ierr_petsc_call_external_ = func(__VA_ARGS__); \</font></strong>
<a name="line1987">1987: </a><strong><font color="#228B22"> if (<a href="../manualpages/Sys/PetscUnlikely.html">PetscUnlikely</a>(ierr_petsc_call_external_ != 0)) { \</font></strong>
<a name="line1988">1988: </a><strong><font color="#228B22"> (void)<a href="../manualpages/Sys/PetscError.html">PetscError</a>(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, __LINE__, PETSC_FUNCTION_NAME, __FILE__, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_LIB</a>, <a href="../manualpages/Sys/PetscErrorType.html">PETSC_ERROR_INITIAL</a>, </font><font color="#666666">"Error in %s(): error code %d"</font><font color="#228B22">, <a href="../manualpages/Sys/PetscStringize.html">PetscStringize</a>(func), ierr_petsc_call_external_); \</font></strong>
<a name="line1989">1989: </a><strong><font color="#228B22"> PETSCABORTWITHIERR_Private(<a href="../manualpages/Sys/PETSC_COMM_SELF.html">PETSC_COMM_SELF</a>, <a href="../manualpages/Sys/PetscErrorCode.html">PETSC_ERR_LIB</a>); \</font></strong>
<a name="line1990">1990: </a><strong><font color="#228B22"> } \</font></strong>
<a name="line1991">1991: </a><strong><font color="#228B22"> } while (0)</font></strong>
<a name="line1992">1992: </a><font color="#A020F0">#endif </font><font color="#B22222">/* PETSC_CLANG_STATIC_ANALYZER */</font><font color="#A020F0"></font>
</pre>
</body>
</html>
|