Actual source code: zis.c

  1: /*$Id: zis.c,v 1.41 2001/06/21 21:19:50 bsmith Exp $*/

 3:  #include src/fortran/custom/zpetsc.h
 4:  #include petscis.h
  5: #ifdef PETSC_HAVE_FORTRAN_CAPS
  6: #define ispartitioningcount_   ISPARTITIONINGCOUNT
  7: #define isdestroy_             ISDESTROY
  8: #define iscreatestride_        ISCREATESTRIDE
  9: #define iscreategeneral_       ISCREATEGENERAL
 10: #define isgetindices_          ISGETINDICES
 11: #define isrestoreindices_      ISRESTOREINDICES
 12: #define isblockgetindices_     ISBLOCKGETINDICES
 13: #define isblockrestoreindices_ ISBLOCKRESTOREINDICES
 14: #define iscreateblock_         ISCREATEBLOCK
 15: #define isblock_               ISBLOCK
 16: #define isstride_              ISSTRIDE
 17: #define ispermutation_         ISPERMUTATION
 18: #define isidentity_            ISIDENTITY
 19: #define issorted_              ISSORTED
 20: #define isequal_               ISEQUAL
 21: #define isinvertpermutation_   ISINVERTPERMUTATION
 22: #define isview_                ISVIEW
 23: #define iscoloringcreate_      ISCOLORINGCREATE
 24: #define islocaltoglobalmappingcreate_ ISLOCALTOGLOBALMAPPINGCREATE
 25: #define islocaltoglobalmappingblock_ ISLOCALTOGLOBALMAPPINGBLOCK
 26: #define isallgather_                  ISALLGATHER
 27: #define iscoloringdestroy_            ISCOLORINGDESTROY
 28: #define iscoloringview_               ISCOLORINGVIEW
 29: #define ispartitioningtonumbering_    ISPARTITIONINGTONUMBERING
 30: #define islocaltoglobalmappingapply_  ISLOCALTOGLOBALMAPPINGAPPLY
 31: #define islocaltoglobalmappingview_  ISLOCALTOGLOBALMAPPINGVIEW
 32: #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
 33: #define islocaltoglobalmappingview_   islocaltoglobalmappingview
 34: #define islocaltoglobalmappingapply_  islocaltoglobalmappingapply
 35: #define iscoloringview_        iscoloringview
 36: #define iscoloringdestroy_     iscoloringdestroy
 37: #define isview_                isview
 38: #define isinvertpermutation_   isinvertpermutation
 39: #define isdestroy_             isdestroy
 40: #define iscreatestride_        iscreatestride
 41: #define iscreategeneral_       iscreategeneral
 42: #define isgetindices_          isgetindices
 43: #define isrestoreindices_      isrestoreindices
 44: #define isblockgetindices_     isblockgetindices
 45: #define isblockrestoreindices_ isblockrestoreindices
 46: #define iscreateblock_         iscreateblock
 47: #define isblock_               isblock
 48: #define isstride_              isstride
 49: #define ispermutation_         ispermutation
 50: #define isidentity_            isidentity
 51: #define issorted_              issorted
 52: #define isequal_               isequal
 53: #define iscoloringcreate_      iscoloringcreate
 54: #define islocaltoglobalmappingcreate_ islocaltoglobalmappingcreate
 55: #define islocaltoglobalmappingblock_ islocaltoglobalmappingblock
 56: #define isallgather_                  isallgather
 57: #define ispartitioningcount_          ispartitioningcount
 58: #define ispartitioningtonumbering_    ispartitioningtonumbering
 59: #endif

 61: EXTERN_C_BEGIN

 63: void PETSC_STDCALL islocaltoglobalmappingview_(ISLocalToGlobalMapping *mapping,PetscViewer *viewer,int *ierr)
 64: {
 65:   CHKFORTRANNULLOBJECT(viewer);
 66:   *ISLocalToGlobalMappingView(*mapping,*viewer);
 67: }

 69: /*
 70:    This is the same as the macro ISLocalToGlobalMappingApply() except it does not
 71:   return error codes.
 72: */
 73: void PETSC_STDCALL islocaltoglobalmappingapply_(ISLocalToGlobalMapping *mapping,int *N,int *in,int *out,int *ierr)
 74: {
 75:   int i,*idx = (*mapping)->indices,Nmax = (*mapping)->n;
 76:   for (i=0; i<(*N); i++) {
 77:     if (in[i] < 0) {out[i] = in[i]; continue;}
 78:     if (in[i] >= Nmax) {
 79:       *PetscError(__LINE__,"ISLocalToGlobalMappingApply_Fortran",__FILE__,__SDIR__,1,1,"Index out of range");
 80:       return;
 81:     }
 82:     out[i] = idx[in[i]];
 83:   }
 84: }

 86: void PETSC_STDCALL ispartitioningtonumbering_(IS *is,IS *isout,int *ierr)
 87: {
 88:   *ISPartitioningToNumbering(*is,isout);
 89: }

 91: void PETSC_STDCALL ispartitioningcount_(IS *is,int *count,int *ierr)
 92: {
 93:   *ISPartitioningCount(*is,count);
 94: }

 96: void PETSC_STDCALL iscoloringdestroy_(ISColoring *iscoloring,int *ierr)
 97: {
 98:   *ISColoringDestroy(*iscoloring);
 99: }

101: void PETSC_STDCALL iscoloringview_(ISColoring *iscoloring,PetscViewer *viewer,int *ierr)
102: {
103:   PetscViewer v;
104:   PetscPatchDefaultViewers_Fortran(viewer,v);
105:   *ISColoringView(*iscoloring,v);
106: }

108: void PETSC_STDCALL isview_(IS *is,PetscViewer *vin,int *ierr)
109: {
110:   PetscViewer v;
111:   PetscPatchDefaultViewers_Fortran(vin,v);
112:   *ISView(*is,v);
113: }

115: void PETSC_STDCALL isequal_(IS *is1,IS *is2,PetscTruth *flg,int *ierr)
116: {
117:   *ISEqual(*is1,*is2,flg);
118: }

120: void PETSC_STDCALL isidentity_(IS *is,PetscTruth *ident,int *ierr)
121: {
122:   *ISIdentity(*is,ident);
123: }

125: void PETSC_STDCALL issorted_(IS *is,PetscTruth *flg,int *ierr)
126: {
127:   *ISSorted(*is,flg);
128: }

130: void PETSC_STDCALL ispermutation_(IS *is,PetscTruth *perm,int *ierr){
131:   *ISPermutation(*is,perm);
132: }

134: void PETSC_STDCALL isstride_(IS *is,PetscTruth *flag,int *ierr)
135: {
136:   *ISStride(*is,flag);
137: }

139: void PETSC_STDCALL isblockgetindices_(IS *x,int *fa,long *ia,int *ierr)
140: {
141:   int   *lx;

143:   *ISGetIndices(*x,&lx); if (*ierr) return;
144:   *ia      = PetscIntAddressToFortran(fa,lx);
145: }

147: void PETSC_STDCALL isblockrestoreindices_(IS *x,int *fa,long *ia,int *ierr)
148: {
149:   int *lx = PetscIntAddressFromFortran(fa,*ia);

151:   *ISRestoreIndices(*x,&lx);
152: }

154: void PETSC_STDCALL isblock_(IS *is,PetscTruth *flag,int *ierr)
155: {
156:   *ISBlock(*is,flag);
157: }

159: void PETSC_STDCALL isgetindices_(IS *x,int *fa,long *ia,int *ierr)
160: {
161:   int   *lx;

163:   *ISGetIndices(*x,&lx); if (*ierr) return;
164:   *ia      = PetscIntAddressToFortran(fa,lx);
165: }

167: void PETSC_STDCALL isrestoreindices_(IS *x,int *fa,long *ia,int *ierr)
168: {
169:   int *lx = PetscIntAddressFromFortran(fa,*ia);

171:   *ISRestoreIndices(*x,&lx);
172: }

174: void PETSC_STDCALL iscreategeneral_(MPI_Comm *comm,int *n,int *idx,IS *is,int *ierr)
175: {
176:   *ISCreateGeneral((MPI_Comm)PetscToPointerComm(*comm),*n,idx,is);
177: }

179: void PETSC_STDCALL isinvertpermutation_(IS *is,int *nlocal,IS *isout,int *ierr)
180: {
181:   *ISInvertPermutation(*is,*nlocal,isout);
182: }

184: void PETSC_STDCALL iscreateblock_(MPI_Comm *comm,int *bs,int *n,int *idx,IS *is,int *ierr)
185: {
186:   *ISCreateBlock((MPI_Comm)PetscToPointerComm(*comm),*bs,*n,idx,is);
187: }

189: void PETSC_STDCALL iscreatestride_(MPI_Comm *comm,int *n,int *first,int *step,
190:                                IS *is,int *ierr)
191: {
192:   *ISCreateStride((MPI_Comm)PetscToPointerComm(*comm),*n,*first,*step,is);
193: }

195: void PETSC_STDCALL isdestroy_(IS *is,int *ierr)
196: {
197:   *ISDestroy(*is);
198: }

200: void PETSC_STDCALL iscoloringcreate_(MPI_Comm *comm,int *n,int *colors,ISColoring *iscoloring,int *ierr)
201: {
202:   int *color;
203:   /* copies the colors[] array since that is kept by the ISColoring that is created */
204:   *PetscMalloc((*n+1)*sizeof(int),&color);if (*ierr) return;
205:   *PetscMemcpy(color,colors,(*n)*sizeof(int));if (*ierr) return;
206:   *ISColoringCreate((MPI_Comm)PetscToPointerComm(*comm),*n,color,iscoloring);
207: }

209: void PETSC_STDCALL islocaltoglobalmappingcreate_(MPI_Comm *comm,int *n,int *indices,ISLocalToGlobalMapping *mapping,int *ierr)
210: {
211:   *ISLocalToGlobalMappingCreate((MPI_Comm)PetscToPointerComm(*comm),*n,indices,mapping);
212: }

214: void PETSC_STDCALL islocaltoglobalmappingblock_(ISLocalToGlobalMapping *inmap,int bs,ISLocalToGlobalMapping *outmap,int *ierr)
215: {
216:   *ISLocalToGlobalMappingBlock(*inmap,bs,outmap);
217: }

219: void PETSC_STDCALL isallgather_(IS *is,IS *isout,int *ierr)
220: {
221:   *ISAllGather(*is,isout);

223: }

225: EXTERN_C_END