1 #include <petsc/private/fortranimpl.h> 2 #include <petsc/private/dmdaimpl.h> 3 4 #if defined(PETSC_HAVE_FORTRAN_CAPS) 5 #define dmdagetownershipranges_ DMDAGETOWNERSHIPRANGES 6 #define dmdagetneighbors_ DMDAGETNEIGHBORS 7 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 8 #define dmdagetownershipranges_ dmdagetownershipranges 9 #define dmdagetneighbors_ dmdagetneighbors 10 #endif 11 12 PETSC_EXTERN void PETSC_STDCALL dmdagetneighbors_(DM *da,PetscMPIInt *ranks,PetscErrorCode *ierr) 13 { 14 const PetscMPIInt *r; 15 PetscInt n,dim; 16 17 *ierr = DMDAGetNeighbors(*da,&r);if (*ierr) return; 18 *ierr = DMGetDimension(*da,&dim);if (*ierr) return; 19 if (dim == 2) n = 9; 20 else n = 27; 21 *ierr = PetscMemcpy(ranks,r,n*sizeof(PetscMPIInt)); 22 } 23 24 PETSC_EXTERN void PETSC_STDCALL dmdagetownershipranges_(DM *da,PetscInt lx[],PetscInt ly[],PetscInt lz[],PetscErrorCode *ierr) 25 { 26 const PetscInt *gx,*gy,*gz; 27 PetscInt M,N,P,i; 28 29 CHKFORTRANNULLINTEGER(lx); 30 CHKFORTRANNULLINTEGER(ly); 31 CHKFORTRANNULLINTEGER(lz); 32 *ierr = DMDAGetInfo(*da,0,0,0,0,&M,&N,&P,0,0,0,0,0,0);if (*ierr) return; 33 *ierr = DMDAGetOwnershipRanges(*da,&gx,&gy,&gz);if (*ierr) return; 34 if (lx) { 35 for (i=0; i<M; i++) lx[i] = gx[i]; 36 } 37 if (ly) { 38 for (i=0; i<N; i++) ly[i] = gy[i]; 39 } 40 if (lz) { 41 for (i=0; i<P; i++) lz[i] = gz[i]; 42 } 43 } 44 45