Actual source code: ex15.c

  1: static char help[] = "Tests inclusion of petscsystypes.h.\n\n";

  3: #include <petscsystypes.h>
  4: #include <stddef.h> /* for NULL */

  6: #if defined(PETSC_HAVE_COMPLEX)
  7:   #define TestComplexOperators(type, value) \
  8:     do { \
  9:       type         x = value; \
 10:       PetscComplex z = value; \
 11:       (void)z; \
 12:       z = x; \
 13:       z += x; \
 14:       z = z + x; \
 15:       z = x + z; \
 16:       z = x; \
 17:       z -= x; \
 18:       z = z - x; \
 19:       z = x - z; \
 20:       z = x; \
 21:       z *= x; \
 22:       z = z * x; \
 23:       z = x * z; \
 24:       z = x; \
 25:       z /= x; \
 26:       z = z / x; \
 27:       z = x / z; \
 28:       (void)(z == x); \
 29:       (void)(x == z); \
 30:       (void)(z != x); \
 31:       (void)(x != z); \
 32:     } while (0)
 33: #endif

 35: int main(int argc, char **argv)
 36: {
 37:   /* numeric types */
 38:   PetscScalar svalue;
 39:   PetscReal   rvalue;
 40: #if defined(PETSC_HAVE_COMPLEX)
 41:   PetscComplex cvalue;
 42: #endif

 44:   /* integer types */
 45:   PetscInt64   i64;
 46:   PetscInt     i;
 47:   PetscBLASInt bi;
 48:   PetscMPIInt  rank;

 50:   /* PETSc types */
 51:   PetscBool        b;
 52:   PetscErrorCode   ierr;
 53:   PetscClassId     cid;
 54:   PetscEnum        e;
 55:   PetscShort       s;
 56:   PetscChar        c;
 57:   PetscFloat       f;
 58:   PetscLogDouble   ld;
 59:   PetscObjectId    oid;
 60:   PetscObjectState ost;

 62:   /* Enums */
 63:   PetscCopyMode          cp;
 64:   PetscDataType          dt;
 65:   PetscFileMode          fm;
 66:   PetscDLMode            dlm;
 67:   PetscBinarySeekType    bsk;
 68:   PetscBuildTwoSidedType b2s;
 69:   InsertMode             im;
 70:   PetscSubcommType       subct;

 72:   /* Sys objects */
 73:   PetscObject             obj;
 74:   PetscRandom             rand;
 75:   PetscToken              token;
 76:   PetscFunctionList       flist;
 77:   PetscDLHandle           dlh;
 78:   PetscObjectList         olist;
 79:   PetscDLLibrary          dlist;
 80:   PetscContainer          cont;
 81:   PetscSubcomm            subc;
 82:   PetscHeap               pheap;
 83:   PetscShmComm            scomm;
 84:   PetscOmpCtrl            octrl;
 85:   PetscSegBuffer          sbuff;
 86:   PetscOptionsHelpPrinted oh;

 88:   0;
 89:   svalue = 0.0;
 90:   rvalue = 0.0;
 91: #if defined(PETSC_HAVE_COMPLEX)
 92:   cvalue = 0.0;
 93: #endif

 95: #if defined(PETSC_HAVE_COMPLEX)
 96:   /* this example returns an error of 141 in GitLab CI once in a great while; this is an attempt to debug that issue */
 97:   if (ierr != 0) return 77;
 98:   TestComplexOperators(signed char, 1);
 99:   TestComplexOperators(signed short, 1);
100:   TestComplexOperators(signed int, 1);
101:   TestComplexOperators(signed long, 1L);
102:   TestComplexOperators(float, 1.0f);
103:   TestComplexOperators(double, 1.0);
104:   if (ierr != 0) return 78;
105: #endif

107:   i64  = 0;
108:   i    = 0;
109:   bi   = 0;
110:   rank = 0;

112:   b   = PETSC_FALSE;
113:   cid = 0;
114:   e   = ENUM_DUMMY;
115:   s   = 0;
116:   c   = '\0';
117:   f   = 0;
118:   ld  = 0.0;
119:   oid = 0;
120:   ost = 0;

122:   cp    = PETSC_COPY_VALUES;
123:   dt    = PETSC_DATATYPE_UNKNOWN;
124:   fm    = FILE_MODE_READ;
125:   dlm   = PETSC_DL_DECIDE;
126:   bsk   = PETSC_BINARY_SEEK_SET;
127:   b2s   = PETSC_BUILDTWOSIDED_NOTSET;
128:   im    = INSERT_VALUES;
129:   subct = PETSC_SUBCOMM_GENERAL;

131:   obj   = NULL;
132:   rand  = NULL;
133:   token = NULL;
134:   flist = NULL;
135:   dlh   = NULL;
136:   olist = NULL;
137:   dlist = NULL;
138:   cont  = NULL;
139:   subc  = NULL;
140:   pheap = NULL;
141:   scomm = NULL;
142:   octrl = NULL;
143:   sbuff = NULL;
144:   oh    = NULL;

146:   /* prevent to issue warning about set-but-not-used variables */
147:   (void)help;

149:   (void)svalue;
150:   (void)rvalue;
151: #if defined(PETSC_HAVE_COMPLEX)
152:   (void)cvalue;
153: #endif
154:   (void)i64;
155:   (void)i;
156:   (void)bi;
157:   (void)rank;

159:   (void)b;
160:   (void)ierr;
161:   (void)cid;
162:   (void)e;
163:   (void)s;
164:   (void)c;
165:   (void)f;
166:   (void)ld;
167:   (void)oid;
168:   (void)ost;

170:   (void)cp;
171:   (void)dt;
172:   (void)fm;
173:   (void)dlm;
174:   (void)bsk;
175:   (void)b2s;
176:   (void)im;
177:   (void)subct;

179:   (void)obj;
180:   (void)rand;
181:   (void)token;
182:   (void)flist;
183:   (void)dlh;
184:   (void)olist;
185:   (void)dlist;
186:   (void)cont;
187:   (void)subc;
188:   (void)pheap;
189:   (void)scomm;
190:   (void)octrl;
191:   (void)sbuff;
192:   (void)oh;
193:   return ierr;
194: }

196: /*TEST

198:   test:

200: TEST*/