Actual source code: rootls.c

petsc-3.6.1 2015-08-06
Report Typos and Errors
  2: /* rootls.f -- translated by f2c (version 19931217).*/

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

  7: /*****************************************************************/
  8: /*********     ../../..LS ..... ../../..ED LEVEL STRUCTURE      **********/
  9: /*****************************************************************/
 10: /*    PURPOSE - ../../..LS GENERATES THE LEVEL STRUCTURE ../../..ED */
 11: /*       AT THE INPUT NODE CALLED ../../... ONLY THOSE NODES FOR*/
 12: /*       WHICH MASK IS NONZERO WILL BE CONSIDERED.*/
 13: /*                                                */
 14: /*    INPUT PARAMETERS -                          */
 15: /*       ../../.. - THE NODE AT WHICH THE LEVEL STRUCTURE IS TO*/
 16: /*              BE ../../..ED.*/
 17: /*       (XADJ, ADJNCY) - ADJACENCY STRUCTURE PAIR FOR THE*/
 18: /*              GIVEN GRAPH.*/
 19: /*       MASK - IS USED TO SPECIFY A SECTION SUBGRAPH. NODES*/
 20: /*              WITH MASK(I)=0 ARE IGNORED.*/
 21: /*    OUTPUT PARAMETERS -*/
 22: /*       NLVL - IS THE NUMBER OF LEVELS IN THE LEVEL STRUCTURE.*/
 23: /*       (XLS, LS) - ARRAY PAIR FOR THE ../../..ED LEVEL STRUCTURE.*/
 24: /*****************************************************************/
 27: PetscErrorCode SPARSEPACKrootls(const PetscInt *root,const PetscInt *xadj,const PetscInt *adjncy,PetscInt *mask, PetscInt *nlvl, PetscInt *xls, PetscInt *ls)
 28: {
 29:   /* System generated locals */
 30:   PetscInt i__1, i__2;

 32:   /* Local variables */
 33:   PetscInt node, i, j, jstop, jstrt, lbegin, ccsize, lvlend, lvsize, nbr;

 35: /*       INITIALIZATION ...*/


 39:   /* Parameter adjustments */
 40:   --ls;
 41:   --xls;
 42:   --mask;
 43:   --adjncy;
 44:   --xadj;

 46:   mask[*root] = 0;
 47:   ls[1]       = *root;
 48:   *nlvl       = 0;
 49:   lvlend      = 0;
 50:   ccsize      = 1;
 51: /*       LBEGIN IS THE POINTER TO THE BEGINNING OF THE CURRENT*/
 52: /*       LEVEL, AND LVLEND POINTS TO THE END OF THIS LEVEL.*/
 53: L200:
 54:   lbegin = lvlend + 1;
 55:   lvlend = ccsize;
 56:   ++(*nlvl);
 57:   xls[*nlvl] = lbegin;
 58: /*       GENERATE THE NEXT LEVEL BY FINDING ALL THE MASKED */
 59: /*       NEIGHBORS OF NODES IN THE CURRENT LEVEL.*/
 60:   i__1 = lvlend;
 61:   for (i = lbegin; i <= i__1; ++i) {
 62:     node  = ls[i];
 63:     jstrt = xadj[node];
 64:     jstop = xadj[node + 1] - 1;
 65:     if (jstop < jstrt) goto L400;
 66:     i__2 = jstop;
 67:     for (j = jstrt; j <= i__2; ++j) {
 68:       nbr = adjncy[j];
 69:       if (!mask[nbr]) goto L300;
 70:       ++ccsize;
 71:       ls[ccsize] = nbr;
 72:       mask[nbr]  = 0;
 73: L300:
 74:       ;
 75:     }
 76: L400:
 77:     ;
 78:   }
 79: /*       COMPUTE THE CURRENT LEVEL WIDTH.*/
 80: /*       IF IT IS NONZERO, GENERATE THE NEXT LEVEL.*/
 81:   lvsize = ccsize - lvlend;
 82:   if (lvsize > 0) goto L200;
 83: /*       RESET MASK TO ONE FOR THE NODES IN THE LEVEL STRUCTURE.*/
 84:   xls[*nlvl + 1] = lvlend + 1;
 85:   i__1           = ccsize;
 86:   for (i = 1; i <= i__1; ++i) {
 87:     node       = ls[i];
 88:     mask[node] = 1;
 89:   }
 90:   return(0);
 91: }