1 2 #include <petsc-private/fortranimpl.h> 3 4 #if defined(PETSC_HAVE_FORTRAN_CAPS) 5 #define chkmemfortran_ CHKMEMFORTRAN 6 #define petscoffsetfortran_ PETSCOFFSETFORTRAN 7 #define petscobjectstateincrease_ PETSCOBJECTSTATEINCREASE 8 #define petscobjectstatedecrease_ PETSCOBJECTSTATEDECREASE 9 #elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE) 10 #define petscoffsetfortran_ petscoffsetfortran 11 #define chkmemfortran_ chkmemfortran 12 #define flush__ flush_ 13 #define petscobjectstateincrease_ petscobjectstateincrease 14 #define petscobjectstatedecrease_ petscobjectstatedecrease 15 #endif 16 17 18 EXTERN_C_BEGIN 19 20 void PETSC_STDCALL petscobjectstateincrease_(PetscObject *obj, PetscErrorCode *ierr) 21 { 22 *ierr = PetscObjectStateIncrease(*obj); 23 } 24 void PETSC_STDCALL petscobjectstatedecrease_(PetscObject *obj, PetscErrorCode *ierr) 25 { 26 *ierr = PetscObjectStateDecrease(*obj); 27 } 28 29 30 #if defined(PETSC_MISSING_FORTRAN_FLUSH_) 31 void flush__(int unit) 32 { 33 } 34 #endif 35 36 37 void PETSC_STDCALL petscoffsetfortran_(PetscScalar *x,PetscScalar *y,size_t *shift,PetscErrorCode *ierr) 38 { 39 *ierr = 0; 40 *shift = y - x; 41 } 42 43 /* ---------------------------------------------------------------------------------*/ 44 /* 45 This version does not do a malloc 46 */ 47 static char FIXCHARSTRING[1024]; 48 49 #define CHAR char* 50 #define FIXCHARNOMALLOC(a,n,b) \ 51 {\ 52 if (a == PETSC_NULL_CHARACTER_Fortran) { \ 53 b = a = 0; \ 54 } else { \ 55 while ((n > 0) && (a[n-1] == ' ')) n--; \ 56 if (a[n] != 0) { \ 57 b = FIXCHARSTRING; \ 58 *ierr = PetscStrncpy(b,a,n); \ 59 if (*ierr) return; \ 60 b[n] = 0; \ 61 } else b = a;\ 62 } \ 63 } 64 65 void PETSC_STDCALL chkmemfortran_(int *line,CHAR file PETSC_MIXED_LEN(len),PetscErrorCode *ierr PETSC_END_LEN(len)) 66 { 67 char *c1; 68 69 FIXCHARNOMALLOC(file,len,c1); 70 *ierr = PetscMallocValidate(*line,"Userfunction",c1," "); 71 } 72 73 74 EXTERN_C_END 75 76 77