Actual source code: fnroot.c

petsc-3.10.5 2019-03-28
Report Typos and Errors

  2: /* fnroot.f -- translated by f2c (version 19931217).*/

  4:  #include <petscsys.h>
  5:  #include <petsc/private/matorderimpl.h>

  7: /*****************************************************************/
  8: /********     FN../../.. ..... FIND PSEUDO-PERIPHERAL NODE    ********/
  9: /*****************************************************************/
 10: /*   PURPOSE - FN../../.. IMPLEMENTS A MODIFIED VERSION OF THE       */
 11: /*      SCHEME BY GIBBS, POOLE, AND STOCKMEYER TO FIND PSEUDO-   */
 12: /*      PERIPHERAL NODES.  IT DETERMINES SUCH A NODE FOR THE     */
 13: /*      SECTION SUBGRAPH SPECIFIED BY MASK AND ../../...             */
 14: /*   INPUT PARAMETERS -                                          */
 15: /*      (XADJ, ADJNCY) - ADJACENCY STRUCTURE PAIR FOR THE GRAPH. */
 16: /*      MASK - SPECIFIES A SECTION SUBGRAPH. NODES FOR WHICH     */
 17: /*             MASK IS ZERO ARE IGNORED BY FN../../...              */
 18: /*   UPDATED PARAMETER -                                        */
 19: /*      ../../.. - ON INPUT, IT (ALONG WITH MASK) DEFINES THE       */
 20: /*             COMPONENT FOR WHICH A PSEUDO-PERIPHERAL NODE IS  */
 21: /*             TO BE FOUND. ON OUTPUT, IT IS THE NODE OBTAINED. */
 22: /*                                                              */
 23: /*   OUTPUT PARAMETERS -                                        */
 24: /*      NLVL - IS THE NUMBER OF LEVELS IN THE LEVEL STRUCTURE   */
 25: /*             ../../..ED AT THE NODE ../../...                         */
 26: /*      (XLS,LS) - THE LEVEL STRUCTURE ARRAY PAIR CONTAINING    */
 27: /*                 THE LEVEL STRUCTURE FOUND.                   */
 28: /*                                                              */
 29: /*   PROGRAM SUBROUTINES -                                      */
 30: /*      ../../..LS.                                                 */
 31: /*                                                              */
 32: /****************************************************************/
 33: PetscErrorCode SPARSEPACKfnroot(PetscInt *root,const PetscInt *xadj,const PetscInt *adjncy,PetscInt *mask, PetscInt *nlvl, PetscInt *xls, PetscInt *ls)
 34: {
 35:   /* System generated locals */
 36:   PetscInt i__1, i__2;

 38:   /* Local variables */
 39:   PetscInt ndeg, node, j, k, nabor, kstop, jstrt, kstrt, mindeg, ccsize, nunlvl;
 40: /*       DETERMINE THE LEVEL STRUCTURE ../../..ED AT ../../... */

 43:   /* Parameter adjustments */
 44:   --ls;
 45:   --xls;
 46:   --mask;
 47:   --adjncy;
 48:   --xadj;

 50:   SPARSEPACKrootls(root, &xadj[1], &adjncy[1], &mask[1], nlvl, &xls[1], &ls[1]);
 51:   ccsize = xls[*nlvl + 1] - 1;
 52:   if (*nlvl == 1 || *nlvl == ccsize) return(0);

 54: /*       PICK A NODE WITH MINIMUM DEGREE FROM THE LAST LEVEL.*/
 55: L100:
 56:   jstrt  = xls[*nlvl];
 57:   mindeg = ccsize;
 58:   *root  = ls[jstrt];
 59:   if (ccsize == jstrt) goto L400;
 60:   i__1 = ccsize;
 61:   for (j = jstrt; j <= i__1; ++j) {
 62:     node  = ls[j];
 63:     ndeg  = 0;
 64:     kstrt = xadj[node];
 65:     kstop = xadj[node + 1] - 1;
 66:     i__2  = kstop;
 67:     for (k = kstrt; k <= i__2; ++k) {
 68:       nabor = adjncy[k];
 69:       if (mask[nabor] > 0) ++ndeg;
 70:     }
 71:     if (ndeg >= mindeg) goto L300;
 72:     *root  = node;
 73:     mindeg = ndeg;
 74: L300:
 75:     ;
 76:   }
 77: /*       AND GENERATE ITS ../../..ED LEVEL STRUCTURE.*/
 78: L400:
 79:   SPARSEPACKrootls(root, &xadj[1], &adjncy[1], &mask[1], &nunlvl, &xls[1], &ls[1]);
 80:   if (nunlvl <= *nlvl) return(0);
 81:   *nlvl = nunlvl;
 82:   if (*nlvl < ccsize) goto L100;
 83:   return(0);
 84: }