Actual source code: petscsysdef.h

petsc-dev 2014-02-02
Report Typos and Errors
  1: !
  2: !
  3: !  Part of the base include file for Fortran use of PETSc.
  4: !  Note: This file should contain only define statements and
  5: !  not the declaration of variables.

  7: ! No spaces for #defines as some compilers (PGI) also adds
  8: ! those additional spaces during preprocessing - bad for fixed format
  9: !
 10: #if !defined (__PETSCSYSDEF_H)
 12: #include "petscconf.h"
 13:  #include finclude/petscviewerdef.h
 14:  #include finclude/petscerrordef.h
 15:  #include finclude/petsclogdef.h
 16:  #include finclude/petscdrawdef.h

 18: !
 19: ! The real*8,complex*16 notatiton is used so that the
 20: ! PETSc double/complex variables are not affected by
 21: ! compiler options like -r4,-r8, sometimes invoked
 22: ! by the user. NAG compiler does not like integer*4,real*8

 24: #if defined(PETSC_USE_FORTRANKIND)
 25: #define integer8 integer(kind=selected_int_kind(10))
 26: #define integer4 integer(kind=selected_int_kind(5))
 27: #define PetscBool  logical(kind=4)
 28: #else
 29: #define integer8 integer*8
 30: #define integer4 integer*4
 31: #define PetscBool  logical*4
 32: #endif

 34: #if (PETSC_SIZEOF_VOID_P == 8)
 35: #define PetscFortranAddr integer8
 36: #define PetscOffset integer8
 37: #else
 38: #define PetscOffset integer4
 39: #define PetscFortranAddr integer4
 40: #endif

 42: #if defined(PETSC_USE_64BIT_INDICES)
 43: #define PetscInt integer8
 44: #else
 45: #define PetscInt integer4
 46: #endif

 48: #if (PETSC_SIZEOF_INT == 4)
 49: #define PetscFortranInt integer4
 50: #elif (PETSC_SIZEOF_INT == 8)
 51: #define PetscFortranInt integer8
 52: #endif
 53: !
 54: #if (PETSC_SIZEOF_SIZE_T == 8)
 55: #define PetscSizeT integer8
 56: #else
 57: #define PetscSizeT integer4
 58: #endif
 59: !
 60: #if defined(PETSC_HAVE_MPIUNI)
 61: #define MPI_Comm PetscFortranInt
 62: #define MPI_Group PetscFortranInt
 63: #define PetscMPIInt PetscFortranInt
 64: #else
 65: #define MPI_Comm integer
 66: #define MPI_Group integer
 67: #define PetscMPIInt integer
 68: #endif
 69: !
 70: #define PetscEnum PetscFortranInt
 71: #define PetscErrorCode PetscFortranInt
 72: #define PetscClassId PetscFortranInt
 73: #define PetscLogEvent PetscFortranInt
 74: #define PetscLogStage PetscFortranInt
 75: #define PetscVoid PetscFortranAddr
 76: !
 77: #if defined(PETSC_FORTRAN_PETSCTRUTH_INT)
 78: #undef PetscBool
 79: #define PetscBool  PetscEnum
 80: #endif
 81: !
 82: #define PetscCopyMode PetscEnum
 83: !
 84: #define PetscDataType PetscEnum
 85: #define PetscFPTrap PetscEnum
 86: !
 87: #if defined (PETSC_USE_FORTRANKIND)
 88: #define PetscFortranFloat real(kind=selected_real_kind(5))
 89: #define PetscFortranDouble real(kind=selected_real_kind(10))
 90: #define PetscFortranLongDouble real(kind=selected_real_kind(19))
 91: #if defined(PETSC_USE_REAL_SINGLE)
 92: #define PetscFortranComplex complex(kind=selected_real_kind(5))
 93: #elif defined(PETSC_USE_REAL_DOUBLE)
 94: #define PetscFortranComplex complex(kind=selected_real_kind(10))
 95: #elif defined(PETSC_USE_REAL___FLOAT128)
 96: #define PetscFortranComplex complex(kind=selected_real_kind(20))
 97: #endif
 98: #define PetscChar(a) character(len = a) ::
 99: #else
100: #define PetscFortranFloat real*4
101: #define PetscFortranDouble real*8
102: #define PetscFortranLongDouble real*16
103: #if defined(PETSC_USE_REAL_SINGLE)
104: #define PetscFortranComplex complex*8
105: #elif defined(PETSC_USE_REAL_DOUBLE)
106: #define PetscFortranComplex complex*16
107: #elif defined(PETSC_USE_REAL___FLOAT128)
108: #define PetscFortranComplex complex*32
109: #endif
110: #define PetscChar(a) character*(a)
111: #endif

113: #if defined(PETSC_USE_COMPLEX)
114: #define PETSC_SCALAR PETSC_COMPLEX
115: #else
116: #if defined(PETSC_USE_REAL_SINGLE)
117: #define PETSC_SCALAR PETSC_FLOAT
118: #elif defined(PETSC_USE_REAL___FLOAT128)
119: #define PETSC_SCALAR PETSC___FLOAT128
120: #else
121: #define PETSC_SCALAR PETSC_DOUBLE
122: #endif
123: #endif
124: #if defined(PETSC_USE_REAL_SINGLE)
125: #define  PETSC_REAL  PETSC_FLOAT
126: #elif defined(PETSC_USE_REAL___FLOAT128)
127: #define PETSC_REAL PETSC___FLOAT128
128: #else
129: #define  PETSC_REAL  PETSC_DOUBLE
130: #endif
131: !
132: !     Macro for templating between real and complex
133: !
134: #if defined(PETSC_USE_COMPLEX)
135: #define PetscScalar PetscFortranComplex
136: !
137: ! F90 uses real(), conjg() when KIND parameter is used.
138: !
139: #if defined (PETSC_MISSING_DREAL)
140: #define PetscRealPart(a) real(a)
141: #define PetscConj(a) conjg(a)
142: #define PetscImaginaryPart(a) aimag(a)
143: #else
144: #define PetscRealPart(a) dreal(a)
145: #define PetscConj(a) dconjg(a)
146: #define PetscImaginaryPart(a) daimag(a)
147: #endif
148: #else
149: #if defined (PETSC_USE_REAL_SINGLE)
150: #define PetscScalar PetscFortranFloat
151: #elif defined(PETSC_USE_REAL___FLOAT128)
152: #define PetscScalar PetscFortranLongDouble
153: #elif defined(PETSC_USE_REAL_DOUBLE)
154: #define PetscScalar PetscFortranDouble
155: #endif
156: #define PetscRealPart(a) a
157: #define PetscConj(a) a
158: #define PetscImaginaryPart(a) a
159: #endif

161: #if defined (PETSC_USE_REAL_SINGLE)
162: #define PetscReal PetscFortranFloat
163: #elif defined(PETSC_USE_REAL___FLOAT128)
164: #define PetscReal PetscFortranLongDouble
165: #elif defined(PETSC_USE_REAL_DOUBLE)
166: #define PetscReal PetscFortranDouble
167: #endif

169: !
170: !    Allows the matrix Fortran Kernels to work with single precision
171: !    matrix data structures
172: !
173: #define MatScalar PetscScalar
174: !
175: !     PetscLogDouble variables are used to contain double precision numbers
176: !     that are not used in the numerical computations, but rather in logging,
177: !     timing etc.
178: !
179: #define PetscObject PetscFortranAddr
180: #define PetscLogDouble PetscFortranDouble
181: !
182: !     Macros for error checking
183: !
184: #if defined(PETSC_USE_ERRORCHECKING)
185: #define SETERRQ(c,n,s,ierr) call MPI_Abort(PETSC_COMM_WORLD,n,ierr)
186: #define CHKERRQ(n) if (n .ne. 0) call MPI_Abort(PETSC_COMM_WORLD,n,n)
187: #define CHKMEMQ call chkmemfortran(__LINE__,__FILE__,ierr)
188: #else
189: #define SETERRQ(c,n,s,ierr)
190: #define CHKERRQ(n)
191: #define CHKMEMQ
192: #endif

194: #define PetscMatlabEngine PetscFortranAddr

196: #if !defined(PetscFlush)
197: #if defined(PETSC_HAVE_FLUSH)
198: #define PetscFlush(a)    call flush(a)
199: #elif defined(PETSC_HAVE_FLUSH_)
200: #define PetscFlush(a)    call flush_(a)
201: #else
202: #define PetscFlush(a)
203: #endif
204: #endif

206: #define PetscRandom PetscFortranAddr
207: #define PetscRandomType character*(80)
208: #define PetscBinarySeekType PetscEnum

210: #define PetscBuildTwoSidedType PetscEnum


213: #endif