Date: 2022-08-02T03:14:11+00:00

Actual source code: rootls.c

      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: /*****************************************************************/
     25: PetscErrorCode SPARSEPACKrootls(const PetscInt *root,const PetscInt *xadj,const PetscInt *adjncy,PetscInt *mask, PetscInt *nlvl, PetscInt *xls, PetscInt *ls)
     26: {
     27:   /* System generated locals */
     28:   PetscInt i__1, i__2;

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

     33: /*       INITIALIZATION ...*/

     35:   /* Parameter adjustments */
     36:   --ls;
     37:   --xls;
     38:   --mask;
     39:   --adjncy;
     40:   --xadj;

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