1 #include <petsc-private/fortranimpl.h> 2 #include <petsc-private/daimpl.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 EXTERN_C_BEGIN 13 void PETSC_STDCALL dmdagetneighbors_(DM *da,PetscMPIInt *ranks,PetscErrorCode *ierr) 14 { 15 const PetscMPIInt *r; 16 PetscInt n; 17 DM_DA *dd = (DM_DA*)(*da)->data; 18 19 *ierr = DMDAGetNeighbors(*da,&r);if (*ierr) return; 20 if (dd->dim == 2) n = 9; 21 else n = 27; 22 *ierr = PetscMemcpy(ranks,r,n*sizeof(PetscMPIInt)); 23 } 24 25 void PETSC_STDCALL dmdagetownershipranges_(DM *da,PetscInt lx[],PetscInt ly[],PetscInt lz[],PetscErrorCode *ierr) 26 { 27 const PetscInt *gx,*gy,*gz; 28 PetscInt M,N,P,i; 29 30 CHKFORTRANNULLINTEGER(lx); 31 CHKFORTRANNULLINTEGER(ly); 32 CHKFORTRANNULLINTEGER(lz); 33 *ierr = DMDAGetInfo(*da,0,0,0,0,&M,&N,&P,0,0,0,0,0,0);if (*ierr) return; 34 *ierr = DMDAGetOwnershipRanges(*da,&gx,&gy,&gz);if (*ierr) return; 35 if (lx) { 36 for (i=0; i<M; i++) lx[i] = gx[i]; 37 } 38 if (ly) { 39 for (i=0; i<N; i++) ly[i] = gy[i]; 40 } 41 if (lz) { 42 for (i=0; i<P; i++) lz[i] = gz[i]; 43 } 44 } 45 46 EXTERN_C_END 47