1a5eb4965SSatish Balay #ifdef PETSC_RCS_HEADER 2*6831982aSBarry Smith static char vcid[] = "$Id: isltog.c,v 1.32 1999/10/13 20:37:00 bsmith Exp bsmith $"; 32362add9SBarry Smith #endif 42362add9SBarry Smith 52362add9SBarry Smith #include "sys.h" /*I "sys.h" I*/ 683271157SBarry Smith #include "src/vec/is/isimpl.h" /*I "is.h" I*/ 72362add9SBarry Smith 85615d1e5SSatish Balay #undef __FUNC__ 95a5d4f66SBarry Smith #define __FUNC__ "ISLocalToGlobalMappingView" 105a5d4f66SBarry Smith /*@C 115a5d4f66SBarry Smith ISLocalToGlobalMappingView - View a local to global mapping 125a5d4f66SBarry Smith 13b9cd556bSLois Curfman McInnes Not Collective 14b9cd556bSLois Curfman McInnes 155a5d4f66SBarry Smith Input Parameters: 165a5d4f66SBarry Smith . ltog - local to global mapping 17b9cd556bSLois Curfman McInnes . viewer - viewer 185a5d4f66SBarry Smith 19a997ad1aSLois Curfman McInnes Level: advanced 20a997ad1aSLois Curfman McInnes 215a5d4f66SBarry Smith .keywords: IS, local-to-global mapping, create 225a5d4f66SBarry Smith 235a5d4f66SBarry Smith .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate() 245a5d4f66SBarry Smith @*/ 255a5d4f66SBarry Smith int ISLocalToGlobalMappingView(ISLocalToGlobalMapping mapping,Viewer viewer) 265a5d4f66SBarry Smith { 27*6831982aSBarry Smith int i,ierr; 28*6831982aSBarry Smith PetscTruth isascii; 295a5d4f66SBarry Smith 305a5d4f66SBarry Smith PetscFunctionBegin; 31*6831982aSBarry Smith PetscValidHeaderSpecific(mapping,IS_LTOGM_COOKIE); 32*6831982aSBarry Smith if (!viewer) viewer = VIEWER_STDOUT_SELF; 33*6831982aSBarry Smith PetscValidHeaderSpecific(viewer,VIEWER_COOKIE); 34*6831982aSBarry Smith PetscCheckSameComm(mapping,viewer); 355a5d4f66SBarry Smith 36*6831982aSBarry Smith ierr = PetscTypeCompare((PetscObject)viewer,ASCII_VIEWER,&isascii);CHKERRQ(ierr); 37*6831982aSBarry Smith if (isascii) { 385a5d4f66SBarry Smith for ( i=0; i<mapping->n; i++ ) { 39*6831982aSBarry Smith ierr = ViewerASCIISynchronizedPrintf(viewer,"%d %d\n",i,mapping->indices[i]);CHKERRQ(ierr); 40*6831982aSBarry Smith } 41*6831982aSBarry Smith ierr = ViewerFlush(viewer);CHKERRQ(ierr); 42*6831982aSBarry Smith } else { 43*6831982aSBarry Smith SETERRQ1(1,1,"Viewer type %s not supported for ISLocalToGlobalMapping",((PetscObject)viewer)->type_name); 445a5d4f66SBarry Smith } 455a5d4f66SBarry Smith 465a5d4f66SBarry Smith PetscFunctionReturn(0); 475a5d4f66SBarry Smith } 485a5d4f66SBarry Smith 495a5d4f66SBarry Smith #undef __FUNC__ 502bdab257SBarry Smith #define __FUNC__ "ISLocalToGlobalMappingCreateIS" 512bdab257SBarry Smith /*@C 522bdab257SBarry Smith ISLocalToGlobalMappingCreateIS - Creates a mapping between a local (0 to n) 532bdab257SBarry Smith ordering and a global parallel ordering. 542bdab257SBarry Smith 550f5bd95cSBarry Smith Not collective 56b9cd556bSLois Curfman McInnes 57a997ad1aSLois Curfman McInnes Input Parameter: 582bdab257SBarry Smith . is - index set containing the global numbers for each local 592bdab257SBarry Smith 60a997ad1aSLois Curfman McInnes Output Parameter: 612bdab257SBarry Smith . mapping - new mapping data structure 622bdab257SBarry Smith 63a997ad1aSLois Curfman McInnes Level: advanced 64a997ad1aSLois Curfman McInnes 652bdab257SBarry Smith .keywords: IS, local-to-global mapping, create 662bdab257SBarry Smith 672bdab257SBarry Smith .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreate() 682bdab257SBarry Smith @*/ 692bdab257SBarry Smith int ISLocalToGlobalMappingCreateIS(IS is,ISLocalToGlobalMapping *mapping) 702bdab257SBarry Smith { 712bdab257SBarry Smith int n,*indices,ierr; 722bdab257SBarry Smith MPI_Comm comm; 733a40ed3dSBarry Smith 743a40ed3dSBarry Smith PetscFunctionBegin; 752bdab257SBarry Smith PetscValidHeaderSpecific(is,IS_COOKIE); 762bdab257SBarry Smith 772bdab257SBarry Smith ierr = PetscObjectGetComm((PetscObject)is,&comm);CHKERRQ(ierr); 782bdab257SBarry Smith ierr = ISGetSize(is,&n);CHKERRQ(ierr); 792bdab257SBarry Smith ierr = ISGetIndices(is,&indices);CHKERRQ(ierr); 802bdab257SBarry Smith ierr = ISLocalToGlobalMappingCreate(comm,n,indices,mapping);CHKERRQ(ierr); 812bdab257SBarry Smith ierr = ISRestoreIndices(is,&indices);CHKERRQ(ierr); 822bdab257SBarry Smith 833a40ed3dSBarry Smith PetscFunctionReturn(0); 842bdab257SBarry Smith } 855a5d4f66SBarry Smith 862bdab257SBarry Smith #undef __FUNC__ 87d4bb536fSBarry Smith #define __FUNC__ "ISLocalToGlobalMappingCreate" 88dd7157adSSatish Balay /*@C 8990f02eecSBarry Smith ISLocalToGlobalMappingCreate - Creates a mapping between a local (0 to n) 9090f02eecSBarry Smith ordering and a global parallel ordering. 912362add9SBarry Smith 920f5bd95cSBarry Smith Not Collective 93b9cd556bSLois Curfman McInnes 942362add9SBarry Smith Input Parameters: 95b9cd556bSLois Curfman McInnes + comm - MPI communicator of size 1. 9690f02eecSBarry Smith . n - the number of local elements 97b9cd556bSLois Curfman McInnes - indices - the global index for each local element 982362add9SBarry Smith 99a997ad1aSLois Curfman McInnes Output Parameter: 10090f02eecSBarry Smith . mapping - new mapping data structure 1012362add9SBarry Smith 102a997ad1aSLois Curfman McInnes Level: advanced 103a997ad1aSLois Curfman McInnes 1043acfe500SLois Curfman McInnes .keywords: IS, local-to-global mapping, create 1052362add9SBarry Smith 1062bdab257SBarry Smith .seealso: ISLocalToGlobalMappingDestroy(), ISLocalToGlobalMappingCreateIS() 1072362add9SBarry Smith @*/ 108987e4450SSatish Balay int ISLocalToGlobalMappingCreate(MPI_Comm cm,int n,const int indices[],ISLocalToGlobalMapping *mapping) 1092362add9SBarry Smith { 110549d3d68SSatish Balay int ierr; 111549d3d68SSatish Balay 1123a40ed3dSBarry Smith PetscFunctionBegin; 11390f02eecSBarry Smith PetscValidIntPointer(indices); 11490f02eecSBarry Smith PetscValidPointer(mapping); 1152362add9SBarry Smith 1163f1db9ecSBarry Smith PetscHeaderCreate(*mapping,_p_ISLocalToGlobalMapping,int,IS_LTOGM_COOKIE,0,"ISLocalToGlobalMapping", 1173f1db9ecSBarry Smith cm,ISLocalToGlobalMappingDestroy,ISLocalToGlobalMappingView); 118d4bb536fSBarry Smith PLogObjectCreate(*mapping); 119d4bb536fSBarry Smith PLogObjectMemory(*mapping,sizeof(struct _p_ISLocalToGlobalMapping)+n*sizeof(int)); 120d4bb536fSBarry Smith 121d4bb536fSBarry Smith (*mapping)->n = n; 12290f02eecSBarry Smith (*mapping)->indices = (int *) PetscMalloc((n+1)*sizeof(int));CHKPTRQ((*mapping)->indices); 123549d3d68SSatish Balay ierr = PetscMemcpy((*mapping)->indices,indices,n*sizeof(int));CHKERRQ(ierr); 124d4bb536fSBarry Smith 125d4bb536fSBarry Smith /* 126d4bb536fSBarry Smith Do not create the global to local mapping. This is only created if 127d4bb536fSBarry Smith ISGlobalToLocalMapping() is called 128d4bb536fSBarry Smith */ 129d4bb536fSBarry Smith (*mapping)->globals = 0; 1303a40ed3dSBarry Smith PetscFunctionReturn(0); 1312362add9SBarry Smith } 1322362add9SBarry Smith 1335615d1e5SSatish Balay #undef __FUNC__ 134d4bb536fSBarry Smith #define __FUNC__ "ISLocalToGlobalMappingDestroy" 13590f02eecSBarry Smith /*@ 13690f02eecSBarry Smith ISLocalToGlobalMappingDestroy - Destroys a mapping between a local (0 to n) 13790f02eecSBarry Smith ordering and a global parallel ordering. 13890f02eecSBarry Smith 1390f5bd95cSBarry Smith Note Collective 140b9cd556bSLois Curfman McInnes 14190f02eecSBarry Smith Input Parameters: 14290f02eecSBarry Smith . mapping - mapping data structure 14390f02eecSBarry Smith 144a997ad1aSLois Curfman McInnes Level: advanced 145a997ad1aSLois Curfman McInnes 1463acfe500SLois Curfman McInnes .keywords: IS, local-to-global mapping, destroy 14790f02eecSBarry Smith 1483acfe500SLois Curfman McInnes .seealso: ISLocalToGlobalMappingCreate() 14990f02eecSBarry Smith @*/ 15090f02eecSBarry Smith int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping mapping) 15190f02eecSBarry Smith { 152606d414cSSatish Balay int ierr; 1533a40ed3dSBarry Smith PetscFunctionBegin; 15490f02eecSBarry Smith PetscValidPointer(mapping); 1553a40ed3dSBarry Smith if (--mapping->refct > 0) PetscFunctionReturn(0); 15685614651SBarry Smith if (mapping->refct < 0) { 15785614651SBarry Smith SETERRQ(1,1,"Mapping already destroyed"); 15885614651SBarry Smith } 15990f02eecSBarry Smith 160606d414cSSatish Balay ierr = PetscFree(mapping->indices);CHKERRQ(ierr); 161606d414cSSatish Balay if (mapping->globals) {ierr = PetscFree(mapping->globals);CHKERRQ(ierr);} 162d4bb536fSBarry Smith PLogObjectDestroy(mapping); 163d4bb536fSBarry Smith PetscHeaderDestroy(mapping); 1643a40ed3dSBarry Smith PetscFunctionReturn(0); 16590f02eecSBarry Smith } 16690f02eecSBarry Smith 1675615d1e5SSatish Balay #undef __FUNC__ 168d4bb536fSBarry Smith #define __FUNC__ "ISLocalToGlobalMappingApplyIS" 16990f02eecSBarry Smith /*@ 1703acfe500SLois Curfman McInnes ISLocalToGlobalMappingApplyIS - Creates from an IS in the local numbering 1713acfe500SLois Curfman McInnes a new index set using the global numbering defined in an ISLocalToGlobalMapping 1723acfe500SLois Curfman McInnes context. 17390f02eecSBarry Smith 174b9cd556bSLois Curfman McInnes Not collective 175b9cd556bSLois Curfman McInnes 17690f02eecSBarry Smith Input Parameters: 177b9cd556bSLois Curfman McInnes + mapping - mapping between local and global numbering 178b9cd556bSLois Curfman McInnes - is - index set in local numbering 17990f02eecSBarry Smith 18090f02eecSBarry Smith Output Parameters: 18190f02eecSBarry Smith . newis - index set in global numbering 18290f02eecSBarry Smith 183a997ad1aSLois Curfman McInnes Level: advanced 184a997ad1aSLois Curfman McInnes 1853acfe500SLois Curfman McInnes .keywords: IS, local-to-global mapping, apply 1863acfe500SLois Curfman McInnes 18790f02eecSBarry Smith .seealso: ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingCreate(), 188d4bb536fSBarry Smith ISLocalToGlobalMappingDestroy(), ISGlobalToLocalMappingApply() 18990f02eecSBarry Smith @*/ 19090f02eecSBarry Smith int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping mapping, IS is, IS *newis) 19190f02eecSBarry Smith { 19290f02eecSBarry Smith int ierr,n,i,*idxin,*idxmap,*idxout; 1933a40ed3dSBarry Smith 1943a40ed3dSBarry Smith PetscFunctionBegin; 19590f02eecSBarry Smith PetscValidPointer(mapping); 19690f02eecSBarry Smith PetscValidHeaderSpecific(is,IS_COOKIE); 19790f02eecSBarry Smith PetscValidPointer(newis); 19890f02eecSBarry Smith 19990f02eecSBarry Smith ierr = ISGetSize(is,&n);CHKERRQ(ierr); 20090f02eecSBarry Smith ierr = ISGetIndices(is,&idxin);CHKERRQ(ierr); 20190f02eecSBarry Smith idxmap = mapping->indices; 20290f02eecSBarry Smith 20390f02eecSBarry Smith idxout = (int *) PetscMalloc((n+1)*sizeof(int));CHKPTRQ(idxout); 20490f02eecSBarry Smith for ( i=0; i<n; i++ ) { 20590f02eecSBarry Smith idxout[i] = idxmap[idxin[i]]; 20690f02eecSBarry Smith } 207029af93fSBarry Smith ierr = ISCreateGeneral(PETSC_COMM_SELF,n,idxout,newis);CHKERRQ(ierr); 208606d414cSSatish Balay ierr = PetscFree(idxout);CHKERRQ(ierr); 2093a40ed3dSBarry Smith PetscFunctionReturn(0); 21090f02eecSBarry Smith } 21190f02eecSBarry Smith 2125615d1e5SSatish Balay #undef __FUNC__ 213d4bb536fSBarry Smith #define __FUNC__ "ISLocalToGlobalMappingApply" 214a64dd6b6SSatish Balay /*@ 2153acfe500SLois Curfman McInnes ISLocalToGlobalMappingApply - Takes a list of integers in a local numbering 2163acfe500SLois Curfman McInnes and converts them to the global numbering. 21790f02eecSBarry Smith 218b9cd556bSLois Curfman McInnes Not collective 219b9cd556bSLois Curfman McInnes 220bb25748dSBarry Smith Input Parameters: 221b9cd556bSLois Curfman McInnes + mapping - the local to global mapping context 222bb25748dSBarry Smith . N - number of integers 223b9cd556bSLois Curfman McInnes - in - input indices in local numbering 224bb25748dSBarry Smith 225bb25748dSBarry Smith Output Parameter: 226bb25748dSBarry Smith . out - indices in global numbering 227bb25748dSBarry Smith 228b9cd556bSLois Curfman McInnes Notes: 229b9cd556bSLois Curfman McInnes The in and out array parameters may be identical. 230d4bb536fSBarry Smith 231a997ad1aSLois Curfman McInnes Level: advanced 232a997ad1aSLois Curfman McInnes 233bb25748dSBarry Smith .seealso: ISLocalToGlobalMappingCreate(),ISLocalToGlobalMappingDestroy(), 2340752156aSBarry Smith ISLocalToGlobalMappingApplyIS(),AOCreateBasic(),AOApplicationToPetsc(), 235d4bb536fSBarry Smith AOPetscToApplication(), ISGlobalToLocalMappingApply() 236bb25748dSBarry Smith 2373acfe500SLois Curfman McInnes .keywords: local-to-global, mapping, apply 238d4bb536fSBarry Smith 239d4bb536fSBarry Smith @*/ 240987e4450SSatish Balay int ISLocalToGlobalMappingApply(ISLocalToGlobalMapping mapping,int N,const int in[],int out[]) 241d4bb536fSBarry Smith { 242d4bb536fSBarry Smith int i,*idx = mapping->indices,Nmax = mapping->n; 2433a40ed3dSBarry Smith 2443a40ed3dSBarry Smith PetscFunctionBegin; 245d4bb536fSBarry Smith for ( i=0; i<N; i++ ) { 246d4bb536fSBarry Smith if (in[i] < 0) {out[i] = in[i]; continue;} 247596552b5SBarry Smith if (in[i] >= Nmax) SETERRQ2(PETSC_ERR_ARG_OUTOFRANGE,1,"Local index %d too large %d (max)",in[i],Nmax); 248d4bb536fSBarry Smith out[i] = idx[in[i]]; 249d4bb536fSBarry Smith } 2503a40ed3dSBarry Smith PetscFunctionReturn(0); 251d4bb536fSBarry Smith } 252d4bb536fSBarry Smith 253d4bb536fSBarry Smith /* -----------------------------------------------------------------------------------------*/ 254d4bb536fSBarry Smith 255d4bb536fSBarry Smith #undef __FUNC__ 256d4bb536fSBarry Smith #define __FUNC__ "ISGlobalToLocalMappingSetUp_Private" 257d4bb536fSBarry Smith /* 258d4bb536fSBarry Smith Creates the global fields in the ISLocalToGlobalMapping structure 259d4bb536fSBarry Smith */ 260d4bb536fSBarry Smith static int ISGlobalToLocalMappingSetUp_Private(ISLocalToGlobalMapping mapping) 261d4bb536fSBarry Smith { 262d4bb536fSBarry Smith int i,*idx = mapping->indices,n = mapping->n,end,start,*globals; 263d4bb536fSBarry Smith 2643a40ed3dSBarry Smith PetscFunctionBegin; 265d4bb536fSBarry Smith end = 0; 266d4bb536fSBarry Smith start = 100000000; 267d4bb536fSBarry Smith 268d4bb536fSBarry Smith for ( i=0; i<n; i++ ) { 269d4bb536fSBarry Smith if (idx[i] < 0) continue; 270d4bb536fSBarry Smith if (idx[i] < start) start = idx[i]; 271d4bb536fSBarry Smith if (idx[i] > end) end = idx[i]; 272d4bb536fSBarry Smith } 273d4bb536fSBarry Smith if (start > end) {start = 0; end = -1;} 274d4bb536fSBarry Smith mapping->globalstart = start; 275d4bb536fSBarry Smith mapping->globalend = end; 276d4bb536fSBarry Smith 277d4bb536fSBarry Smith globals = mapping->globals = (int *) PetscMalloc((end-start+2)*sizeof(int));CHKPTRQ(mapping->globals); 278d4bb536fSBarry Smith for ( i=0; i<end-start+1; i++ ) { 279d4bb536fSBarry Smith globals[i] = -1; 280d4bb536fSBarry Smith } 281d4bb536fSBarry Smith for ( i=0; i<n; i++ ) { 282d4bb536fSBarry Smith if (idx[i] < 0) continue; 283d4bb536fSBarry Smith globals[idx[i] - start] = i; 284d4bb536fSBarry Smith } 285d4bb536fSBarry Smith 286d4bb536fSBarry Smith PLogObjectMemory(mapping,(end-start+1)*sizeof(int)); 2873a40ed3dSBarry Smith PetscFunctionReturn(0); 288d4bb536fSBarry Smith } 289d4bb536fSBarry Smith 290d4bb536fSBarry Smith #undef __FUNC__ 291d4bb536fSBarry Smith #define __FUNC__ "ISGlobalToLocalMappingApply" 292d4bb536fSBarry Smith /*@ 293a997ad1aSLois Curfman McInnes ISGlobalToLocalMappingApply - Provides the local numbering for a list of integers 294a997ad1aSLois Curfman McInnes specified with a global numbering. 295d4bb536fSBarry Smith 296b9cd556bSLois Curfman McInnes Not collective 297b9cd556bSLois Curfman McInnes 298d4bb536fSBarry Smith Input Parameters: 299b9cd556bSLois Curfman McInnes + mapping - mapping between local and global numbering 300d4bb536fSBarry Smith . type - IS_GTOLM_MASK - replaces global indices with no local value with -1 301d4bb536fSBarry Smith IS_GTOLM_DROP - drops the indices with no local value from the output list 302d4bb536fSBarry Smith . n - number of global indices to map 303b9cd556bSLois Curfman McInnes - idx - global indices to map 304d4bb536fSBarry Smith 305d4bb536fSBarry Smith Output Parameters: 306b9cd556bSLois Curfman McInnes + nout - number of indices in output array (if type == IS_GTOLM_MASK then nout = n) 307b9cd556bSLois Curfman McInnes - idxout - local index of each global index, one must pass in an array long enough 308e182c471SBarry Smith to hold all the indices. You can call ISGlobalToLocalMappingApply() with 309e182c471SBarry Smith idxout == PETSC_NULL to determine the required length (returned in nout) 310e182c471SBarry Smith and then allocate the required space and call ISGlobalToLocalMappingApply() 311e182c471SBarry Smith a second time to set the values. 312d4bb536fSBarry Smith 313b9cd556bSLois Curfman McInnes Notes: 314b9cd556bSLois Curfman McInnes Either nout or idxout may be PETSC_NULL. idx and idxout may be identical. 315d4bb536fSBarry Smith 3160f5bd95cSBarry Smith This is not scalable in memory usage. Each processor requires O(Nglobal) size 3170f5bd95cSBarry Smith array to compute these. 3180f5bd95cSBarry Smith 319a997ad1aSLois Curfman McInnes Level: advanced 320a997ad1aSLois Curfman McInnes 321d4bb536fSBarry Smith .keywords: IS, global-to-local mapping, apply 322d4bb536fSBarry Smith 323d4bb536fSBarry Smith .seealso: ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingCreate(), 324d4bb536fSBarry Smith ISLocalToGlobalMappingDestroy() 325d4bb536fSBarry Smith @*/ 326d4bb536fSBarry Smith int ISGlobalToLocalMappingApply(ISLocalToGlobalMapping mapping, ISGlobalToLocalMappingType type, 327987e4450SSatish Balay int n, const int idx[],int *nout,int idxout[]) 328d4bb536fSBarry Smith { 329d4bb536fSBarry Smith int i,ierr, *globals,nf = 0,tmp,start,end; 330d4bb536fSBarry Smith 3313a40ed3dSBarry Smith PetscFunctionBegin; 332d4bb536fSBarry Smith if (!mapping->globals) { 333d4bb536fSBarry Smith ierr = ISGlobalToLocalMappingSetUp_Private(mapping);CHKERRQ(ierr); 334d4bb536fSBarry Smith } 335d4bb536fSBarry Smith globals = mapping->globals; 336d4bb536fSBarry Smith start = mapping->globalstart; 337d4bb536fSBarry Smith end = mapping->globalend; 338d4bb536fSBarry Smith 339d4bb536fSBarry Smith if (type == IS_GTOLM_MASK) { 340d4bb536fSBarry Smith if (idxout) { 341d4bb536fSBarry Smith for ( i=0; i<n; i++ ) { 342d4bb536fSBarry Smith if (idx[i] < 0) idxout[i] = idx[i]; 343d4bb536fSBarry Smith else if (idx[i] < start) idxout[i] = -1; 344d4bb536fSBarry Smith else if (idx[i] > end) idxout[i] = -1; 345d4bb536fSBarry Smith else idxout[i] = globals[idx[i] - start]; 346d4bb536fSBarry Smith } 347d4bb536fSBarry Smith } 348d4bb536fSBarry Smith if (nout) *nout = n; 349d4bb536fSBarry Smith } else { 350d4bb536fSBarry Smith if (idxout) { 351d4bb536fSBarry Smith for ( i=0; i<n; i++ ) { 352d4bb536fSBarry Smith if (idx[i] < 0) continue; 353d4bb536fSBarry Smith if (idx[i] < start) continue; 354d4bb536fSBarry Smith if (idx[i] > end) continue; 355d4bb536fSBarry Smith tmp = globals[idx[i] - start]; 356d4bb536fSBarry Smith if (tmp < 0) continue; 357d4bb536fSBarry Smith idxout[nf++] = tmp; 358d4bb536fSBarry Smith } 359d4bb536fSBarry Smith } else { 360d4bb536fSBarry Smith for ( i=0; i<n; i++ ) { 361d4bb536fSBarry Smith if (idx[i] < 0) continue; 362d4bb536fSBarry Smith if (idx[i] < start) continue; 363d4bb536fSBarry Smith if (idx[i] > end) continue; 364d4bb536fSBarry Smith tmp = globals[idx[i] - start]; 365d4bb536fSBarry Smith if (tmp < 0) continue; 366d4bb536fSBarry Smith nf++; 367d4bb536fSBarry Smith } 368d4bb536fSBarry Smith } 369d4bb536fSBarry Smith if (nout) *nout = nf; 370d4bb536fSBarry Smith } 371d4bb536fSBarry Smith 3723a40ed3dSBarry Smith PetscFunctionReturn(0); 373d4bb536fSBarry Smith } 37490f02eecSBarry Smith 375