diff options
author | allen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 1999-12-02 19:21:27 +0000 |
---|---|---|
committer | allen <allen@b61c5cb5-eaca-4651-9a7a-d64986f99364> | 1999-12-02 19:21:27 +0000 |
commit | 54ed35ed2352a12702b6ff49925e698753184048 (patch) | |
tree | 96c78ffbfdebd7ca04bbe624508386c3f4d7e4c8 | |
parent | 6647097e2d05aaea5bc316fdef138a196ec4d005 (diff) |
Support for CCTK_INT2 etc
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGH/trunk@139 b61c5cb5-eaca-4651-9a7a-d64986f99364
-rw-r--r-- | src/Reduction.c | 372 | ||||
-rw-r--r-- | src/SetupGroup.c | 167 |
2 files changed, 514 insertions, 25 deletions
diff --git a/src/Reduction.c b/src/Reduction.c index e3da150..7be126d 100644 --- a/src/Reduction.c +++ b/src/Reduction.c @@ -1120,6 +1120,42 @@ int pugh_MinVal_Array (cGH *GH, int proc, int nOutVals, int nPoints, } break; +#ifdef CCTK_INT2 + case CCTK_VARIABLE_INT2: + for (j = 0; j < nOutVals; j++) { + CCTK_INT2 *inPtr = (CCTK_INT2 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MIN (*inPtr, (CCTK_INT2) (outVals [j])); + } + break; +#endif + +#ifdef CCTK_INT4 + case CCTK_VARIABLE_INT4: + for (j = 0; j < nOutVals; j++) { + CCTK_INT4 *inPtr = (CCTK_INT4 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MIN (*inPtr, (CCTK_INT4) (outVals [j])); + } + break; +#endif + +#ifdef CCTK_INT8 + case CCTK_VARIABLE_INT8: + for (j = 0; j < nOutVals; j++) { + CCTK_INT8 *inPtr = (CCTK_INT8 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MIN (*inPtr, (CCTK_INT8) (outVals [j])); + } + break; +#endif + case CCTK_VARIABLE_REAL: for (j = 0; j < nOutVals; j++) { CCTK_REAL *inPtr = (CCTK_REAL *) inArray + j; @@ -1130,6 +1166,42 @@ int pugh_MinVal_Array (cGH *GH, int proc, int nOutVals, int nPoints, } break; +#ifdef CCTK_REAL4 + case CCTK_VARIABLE_REAL4: + for (j = 0; j < nOutVals; j++) { + CCTK_REAL4 *inPtr = (CCTK_REAL4 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MIN (*inPtr, (CCTK_REAL4)( outVals [j])); + } + break; +#endif + +#ifdef CCTK_REAL8 + case CCTK_VARIABLE_REAL8: + for (j = 0; j < nOutVals; j++) { + CCTK_REAL8 *inPtr = (CCTK_REAL8 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MIN (*inPtr, (CCTK_REAL8)( outVals [j])); + } + break; +#endif + +#ifdef CCTK_REAL16 + case CCTK_VARIABLE_REAL16: + for (j = 0; j < nOutVals; j++) { + CCTK_REAL16 *inPtr = (CCTK_REAL16 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MIN (*inPtr, (CCTK_REAL16)( outVals [j])); + } + break; +#endif + case CCTK_VARIABLE_COMPLEX: CCTK_WARN(1,"Don't know how to compute minimum of complex variables !!!"); return (1); @@ -1205,6 +1277,42 @@ int pugh_MaxVal_Array (cGH *GH, int proc, int nOutVals, int nPoints, } break; +#ifdef CCTK_INT2 + case CCTK_VARIABLE_INT2: + for (j = 0; j < nOutVals; j++) { + CCTK_INT2 *inPtr = (CCTK_INT2 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MAX (*inPtr, (CCTK_INT2) (outVals [j])); + } + break; +#endif + +#ifdef CCTK_INT4 + case CCTK_VARIABLE_INT4: + for (j = 0; j < nOutVals; j++) { + CCTK_INT4 *inPtr = (CCTK_INT4 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MAX (*inPtr, (CCTK_INT4) (outVals [j])); + } + break; +#endif + +#ifdef CCTK_INT8 + case CCTK_VARIABLE_INT8: + for (j = 0; j < nOutVals; j++) { + CCTK_INT8 *inPtr = (CCTK_INT8 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MAX (*inPtr, (CCTK_INT8) (outVals [j])); + } + break; +#endif + case CCTK_VARIABLE_REAL: for (j = 0; j < nOutVals; j++) { CCTK_REAL *inPtr = (CCTK_REAL *) inArray + j; @@ -1215,6 +1323,42 @@ int pugh_MaxVal_Array (cGH *GH, int proc, int nOutVals, int nPoints, } break; +#ifdef CCTK_REAL4 + case CCTK_VARIABLE_REAL4: + for (j = 0; j < nOutVals; j++) { + CCTK_REAL4 *inPtr = (CCTK_REAL4 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MAX (*inPtr, (CCTK_REAL4) (outVals [j])); + } + break; +#endif + +#ifdef CCTK_REAL8 + case CCTK_VARIABLE_REAL8: + for (j = 0; j < nOutVals; j++) { + CCTK_REAL8 *inPtr = (CCTK_REAL8 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MAX (*inPtr, (CCTK_REAL8) (outVals [j])); + } + break; +#endif + +#ifdef CCTK_REAL16 + case CCTK_VARIABLE_REAL16: + for (j = 0; j < nOutVals; j++) { + CCTK_REAL16 *inPtr = (CCTK_REAL16 *) inArray + j; + + outVals [j] = (CCTK_REAL) *inPtr++; + for (i = 1; i < nPoints; i++, inPtr++) + outVals [j] = MAX (*inPtr, (CCTK_REAL16) (outVals [j])); + } + break; +#endif + case CCTK_VARIABLE_COMPLEX: CCTK_WARN(1,"Don't know how to compute maximum of complex variables !!!"); return (1); @@ -1273,8 +1417,32 @@ int pugh_Sum_Array (cGH *GH, int proc, int nOutVals, int nPoints, outVals [i] += ((CCTK_CHAR *) inArray) [i*nPoints + j]; else if (inType == CCTK_VARIABLE_INT) outVals [i] += ((CCTK_INT *) inArray) [i*nPoints + j]; +#ifdef CCTK_INT2 + else if (inType == CCTK_VARIABLE_INT2) + outVals [i] += ((CCTK_INT2 *) inArray) [i*nPoints + j]; +#endif +#ifdef CCTK_INT4 + else if (inType == CCTK_VARIABLE_INT4) + outVals [i] += ((CCTK_INT4 *) inArray) [i*nPoints + j]; +#endif +#ifdef CCTK_INT8 + else if (inType == CCTK_VARIABLE_INT8) + outVals [i] += ((CCTK_INT8 *) inArray) [i*nPoints + j]; +#endif else if (inType == CCTK_VARIABLE_REAL) outVals [i] += ((CCTK_REAL *) inArray) [i*nPoints + j]; +#ifdef CCTK_REAL4 + else if (inType == CCTK_VARIABLE_REAL4) + outVals [i] += ((CCTK_REAL4 *) inArray) [i*nPoints + j]; +#endif +#ifdef CCTK_REAL8 + else if (inType == CCTK_VARIABLE_REAL8) + outVals [i] += ((CCTK_REAL8 *) inArray) [i*nPoints + j]; +#endif +#ifdef CCTK_REAL16 + else if (inType == CCTK_VARIABLE_REAL16) + outVals [i] += ((CCTK_REAL16 *) inArray) [i*nPoints + j]; +#endif else if (inType == CCTK_VARIABLE_COMPLEX) { CCTK_WARN (1, "Don't know how to reduce complex variables !!!"); return (1); @@ -1335,8 +1503,32 @@ int pugh_Norm1_Array (cGH *GH, int proc, int nOutVals, int nPoints, outVals [i] += ((CCTK_CHAR *) inArray) [i*nPoints + j]; else if (inType == CCTK_VARIABLE_INT) outVals [i] += ABS (((CCTK_INT *) inArray) [i*nPoints + j]); +#ifdef CCTK_INT2 + else if (inType == CCTK_VARIABLE_INT2) + outVals [i] += ABS (((CCTK_INT2 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_INT4 + else if (inType == CCTK_VARIABLE_INT4) + outVals [i] += ABS (((CCTK_INT4 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_INT8 + else if (inType == CCTK_VARIABLE_INT8) + outVals [i] += ABS (((CCTK_INT8 *) inArray) [i*nPoints + j]); +#endif else if (inType == CCTK_VARIABLE_REAL) outVals [i] += ABS (((CCTK_REAL *) inArray) [i*nPoints + j]); +#ifdef CCTK_REAL4 + else if (inType == CCTK_VARIABLE_REAL4) + outVals [i] += ABS (((CCTK_REAL4 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_REAL8 + else if (inType == CCTK_VARIABLE_REAL8) + outVals [i] += ABS (((CCTK_REAL8 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_REAL16 + else if (inType == CCTK_VARIABLE_REAL16) + outVals [i] += ABS (((CCTK_REAL16 *) inArray) [i*nPoints + j]); +#endif else if (inType == CCTK_VARIABLE_COMPLEX) { CCTK_WARN (1, "Don't know how to reduce complex variables !!!"); return (1); @@ -1406,8 +1598,32 @@ int pugh_Norm2_Array (cGH *GH, int proc, int nOutVals, int nPoints, outVals [i] += SQR (((CCTK_CHAR *) inArray) [i*nPoints + j]); else if (inType == CCTK_VARIABLE_INT) outVals [i] += SQR (((CCTK_INT *) inArray) [i*nPoints + j]); +#ifdef CCTK_INT2 + else if (inType == CCTK_VARIABLE_INT2) + outVals [i] += SQR (((CCTK_INT2 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_INT4 + else if (inType == CCTK_VARIABLE_INT4) + outVals [i] += SQR (((CCTK_INT4 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_INT8 + else if (inType == CCTK_VARIABLE_INT8) + outVals [i] += SQR (((CCTK_INT8 *) inArray) [i*nPoints + j]); +#endif else if (inType == CCTK_VARIABLE_REAL) outVals [i] += SQR (((CCTK_REAL *) inArray) [i*nPoints + j]); +#ifdef CCTK_REAL4 + else if (inType == CCTK_VARIABLE_REAL4) + outVals [i] += SQR (((CCTK_REAL4 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_REAL8 + else if (inType == CCTK_VARIABLE_REAL8) + outVals [i] += SQR (((CCTK_REAL8 *) inArray) [i*nPoints + j]); +#endif +#ifdef CCTK_REAL16 + else if (inType == CCTK_VARIABLE_REAL16) + outVals [i] += SQR (((CCTK_REAL16 *) inArray) [i*nPoints + j]); +#endif else if (inType == CCTK_VARIABLE_COMPLEX) { CCTK_WARN (1, "Don't know how to reduce complex variables !!!"); return (1); @@ -1486,8 +1702,32 @@ int pugh_Norm1_GF (cGH *GH, int index, int proc, CCTK_REAL *outVal) *outVal += ((CCTK_CHAR *) GF->data) [ii]; /* CCTK_CHAR is unsigned */ else if (GF->vtype == CCTK_VARIABLE_INT) *outVal += ABS (((CCTK_INT *) GF->data) [ii]); +#ifdef CCTK_INT2 + else if (GF->vtype == CCTK_VARIABLE_INT2) + *outVal += ABS (((CCTK_INT2 *) GF->data) [ii]); +#endif +#ifdef CCTK_INT4 + else if (GF->vtype == CCTK_VARIABLE_INT4) + *outVal += ABS (((CCTK_INT4 *) GF->data) [ii]); +#endif +#ifdef CCTK_INT8 + else if (GF->vtype == CCTK_VARIABLE_INT8) + *outVal += ABS (((CCTK_INT8 *) GF->data) [ii]); +#endif else if (GF->vtype == CCTK_VARIABLE_REAL) *outVal += ABS (((CCTK_REAL *) GF->data) [ii]); +#ifdef CCTK_REAL4 + else if (GF->vtype == CCTK_VARIABLE_REAL4) + *outVal += ABS (((CCTK_REAL4 *) GF->data) [ii]); +#endif +#ifdef CCTK_REAL8 + else if (GF->vtype == CCTK_VARIABLE_REAL8) + *outVal += ABS (((CCTK_REAL8 *) GF->data) [ii]); +#endif +#ifdef CCTK_REAL16 + else if (GF->vtype == CCTK_VARIABLE_REAL16) + *outVal += ABS (((CCTK_REAL16 *) GF->data) [ii]); +#endif else if (GF->vtype == CCTK_VARIABLE_COMPLEX) { CCTK_WARN (1, "Don't know how to reduce complex variables !!!"); return (1); @@ -1519,9 +1759,39 @@ int pugh_Norm1_GF (cGH *GH, int index, int proc, CCTK_REAL *outVal) else if (GF->vtype == CCTK_VARIABLE_INT) local_result += ABS (((CCTK_INT *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#ifdef CCTK_INT2 + else if (GF->vtype == CCTK_VARIABLE_INT2) + local_result += + ABS (((CCTK_INT2 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_INT4 + else if (GF->vtype == CCTK_VARIABLE_INT4) + local_result += + ABS (((CCTK_INT4 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_INT8 + else if (GF->vtype == CCTK_VARIABLE_INT8) + local_result += + ABS (((CCTK_INT8 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif else if (GF->vtype == CCTK_VARIABLE_REAL) local_result += ABS (((CCTK_REAL *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#ifdef CCTK_REAL4 + else if (GF->vtype == CCTK_VARIABLE_REAL4) + local_result += + ABS (((CCTK_REAL4 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_REAL8 + else if (GF->vtype == CCTK_VARIABLE_REAL8) + local_result += + ABS (((CCTK_REAL8 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_REAL16 + else if (GF->vtype == CCTK_VARIABLE_REAL16) + local_result += + ABS (((CCTK_REAL16 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif else if (GF->vtype == CCTK_VARIABLE_COMPLEX) { CCTK_WARN (1, "Don't know how to reduce complex variables !!!"); return (1); @@ -1588,8 +1858,32 @@ int pugh_Norm2_GF (cGH *GH, int index, int proc, CCTK_REAL *outVal) *outVal += SQR (((CCTK_CHAR *) GF->data) [ii]); else if (GF->vtype == CCTK_VARIABLE_INT) *outVal += SQR (((CCTK_INT *) GF->data) [ii]); +#ifdef CCTK_INT2 + else if (GF->vtype == CCTK_VARIABLE_INT2) + *outVal += SQR (((CCTK_INT2 *) GF->data) [ii]); +#endif +#ifdef CCTK_INT4 + else if (GF->vtype == CCTK_VARIABLE_INT4) + *outVal += SQR (((CCTK_INT4 *) GF->data) [ii]); +#endif +#ifdef CCTK_INT8 + else if (GF->vtype == CCTK_VARIABLE_INT8) + *outVal += SQR (((CCTK_INT8 *) GF->data) [ii]); +#endif else if (GF->vtype == CCTK_VARIABLE_REAL) *outVal += SQR (((CCTK_REAL *) GF->data) [ii]); +#ifdef CCTK_REAL4 + else if (GF->vtype == CCTK_VARIABLE_REAL4) + *outVal += SQR (((CCTK_REAL4 *) GF->data) [ii]); +#endif +#ifdef CCTK_REAL8 + else if (GF->vtype == CCTK_VARIABLE_REAL8) + *outVal += SQR (((CCTK_REAL8 *) GF->data) [ii]); +#endif +#ifdef CCTK_REAL16 + else if (GF->vtype == CCTK_VARIABLE_REAL16) + *outVal += SQR (((CCTK_REAL16 *) GF->data) [ii]); +#endif else if (GF->vtype == CCTK_VARIABLE_COMPLEX) { CCTK_WARN (1, "Don't know how to reduce complex variables !!!"); return (1); @@ -1620,9 +1914,39 @@ int pugh_Norm2_GF (cGH *GH, int index, int proc, CCTK_REAL *outVal) else if (GF->vtype == CCTK_VARIABLE_INT) local_result += SQR (((CCTK_INT *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#ifdef CCTK_INT2 + else if (GF->vtype == CCTK_VARIABLE_INT2) + local_result += + SQR (((CCTK_INT2 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_INT4 + else if (GF->vtype == CCTK_VARIABLE_INT4) + local_result += + SQR (((CCTK_INT4 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_INT8 + else if (GF->vtype == CCTK_VARIABLE_INT8) + local_result += + SQR (((CCTK_INT8 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif else if (GF->vtype == CCTK_VARIABLE_REAL) local_result += SQR (((CCTK_REAL *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#ifdef CCTK_REAL4 + else if (GF->vtype == CCTK_VARIABLE_REAL4) + local_result += + SQR (((CCTK_REAL4 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_REAL8 + else if (GF->vtype == CCTK_VARIABLE_REAL8) + local_result += + SQR (((CCTK_REAL8 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif +#ifdef CCTK_REAL16 + else if (GF->vtype == CCTK_VARIABLE_REAL16) + local_result += + SQR (((CCTK_REAL16 *) GF->data) [DATINDEX (pughGH, ii, jj, kk)]); +#endif else if (GF->vtype == CCTK_VARIABLE_COMPLEX) { CCTK_WARN (1, "Don't know how to reduce complex variables !!!"); return (1); @@ -1660,8 +1984,32 @@ void copy_real_to_outtype (CCTK_REAL *from, void *to, int to_type, int n) ((CCTK_CHAR *) to) [j] = (CCTK_CHAR) (from [j]); else if (to_type == CCTK_VARIABLE_INT) ((CCTK_INT *) to) [j] = (CCTK_INT) (from [j]); +#ifdef CCTK_INT2 + else if (to_type == CCTK_VARIABLE_INT2) + ((CCTK_INT2 *) to) [j] = (CCTK_INT2) (from [j]); +#endif +#ifdef CCTK_INT4 + else if (to_type == CCTK_VARIABLE_INT4) + ((CCTK_INT4 *) to) [j] = (CCTK_INT4) (from [j]); +#endif +#ifdef CCTK_INT8 + else if (to_type == CCTK_VARIABLE_INT8) + ((CCTK_INT8 *) to) [j] = (CCTK_INT8) (from [j]); +#endif else if (to_type == CCTK_VARIABLE_REAL) ((CCTK_REAL *) to) [j] = from [j]; +#ifdef CCTK_REAL4 + else if (to_type == CCTK_VARIABLE_REAL4) + ((CCTK_REAL4 *) to) [j] = from [j]; +#endif +#ifdef CCTK_REAL8 + else if (to_type == CCTK_VARIABLE_REAL8) + ((CCTK_REAL8 *) to) [j] = from [j]; +#endif +#ifdef CCTK_REAL16 + else if (to_type == CCTK_VARIABLE_REAL16) + ((CCTK_REAL16 *) to) [j] = from [j]; +#endif else CCTK_WARN (1, "Unsupported output type in copy_real_to_outtype"); } @@ -1672,8 +2020,32 @@ int getSizeofElement (int varType) { if (varType == CCTK_VARIABLE_REAL) return (sizeof (CCTK_REAL)); +#ifdef CCTK_REAL4 + else if (varType == CCTK_VARIABLE_REAL4) + return (sizeof (CCTK_REAL4)); +#endif +#ifdef CCTK_REAL8 + else if (varType == CCTK_VARIABLE_REAL8) + return (sizeof (CCTK_REAL8)); +#endif +#ifdef CCTK_REAL16 + else if (varType == CCTK_VARIABLE_REAL16) + return (sizeof (CCTK_REAL16)); +#endif else if (varType == CCTK_VARIABLE_INT) return (sizeof (CCTK_INT)); +#ifdef CCTK_INT2 + else if (varType == CCTK_VARIABLE_INT2) + return (sizeof (CCTK_INT2)); +#endif +#ifdef CCTK_INT4 + else if (varType == CCTK_VARIABLE_INT4) + return (sizeof (CCTK_INT4)); +#endif +#ifdef CCTK_INT8 + else if (varType == CCTK_VARIABLE_INT8) + return (sizeof (CCTK_INT8)); +#endif else if (varType == CCTK_VARIABLE_CHAR) return (sizeof (CCTK_CHAR)); else if (varType == CCTK_VARIABLE_COMPLEX) diff --git a/src/SetupGroup.c b/src/SetupGroup.c index f44ebd5..bbfe5da 100644 --- a/src/SetupGroup.c +++ b/src/SetupGroup.c @@ -15,7 +15,12 @@ static char *rcisd = "$Header$"; -pGF *SetupPGF(pGH *GH, const char *name, int dim, int varsize, int vtype, int stagger); +pGF *SetupPGF(pGH *GH, + const char *name, + int dim, + int varsize, + int vtype, + int stagger); int pugh_SetupScalarGroup(pGH *newGH, int vtype, int n_variables, int n_timelevels); int pugh_SetupArrayGroup(pGH *newGH, int vtype, int dim, int n_variables, int n_timelevels); @@ -81,7 +86,7 @@ int pugh_SetupGroup(pGH *newGH, int gtype, int vtype, int dim, int n_variables, int pugh_SetupScalarGroup(pGH *newGH, int vtype, int n_variables, int n_timelevels) { int variable; - + char *msg; int var_size; int level; @@ -91,12 +96,65 @@ int pugh_SetupScalarGroup(pGH *newGH, int vtype, int n_variables, int n_timeleve switch(vtype) { - case CCTK_VARIABLE_CHAR : var_size = sizeof(CCTK_CHAR); break; - case CCTK_VARIABLE_INT : var_size = sizeof(CCTK_INT) ; break; - case CCTK_VARIABLE_REAL : var_size = sizeof(CCTK_REAL); break; - case CCTK_VARIABLE_COMPLEX : var_size = sizeof(CCTK_COMPLEX); break; - default : CCTK_WARN(0,"Unknown variable type in pugh_SetupScalarGroup"); - var_size = 1; + case CCTK_VARIABLE_CHAR: + var_size = sizeof(CCTK_CHAR); + break; + + case CCTK_VARIABLE_INT: + var_size = sizeof(CCTK_INT) ; + break; + +#ifdef CCTK_INT2 + case CCTK_VARIABLE_INT2: + var_size = sizeof(CCTK_INT2); + break; +#endif + +#ifdef CCTK_INT4 + case CCTK_VARIABLE_INT4: + var_size = sizeof(CCTK_INT4); + break; +#endif + +#ifdef CCTK_INT8 + case CCTK_VARIABLE_INT8: + var_size = sizeof(CCTK_INT8); + break; +#endif + + case CCTK_VARIABLE_REAL: + var_size = sizeof(CCTK_REAL); + break; + +#ifdef CCTK_REAL4 + case CCTK_VARIABLE_REAL4: + var_size = sizeof(CCTK_REAL4); + break; +#endif + +#ifdef CCTK_REAL8 + case CCTK_VARIABLE_REAL8: + var_size = sizeof(CCTK_REAL8); + break; +#endif + +#ifdef CCTK_REAL16 + case CCTK_VARIABLE_REAL16: + var_size = sizeof(CCTK_REAL16); + break; +#endif + + case CCTK_VARIABLE_COMPLEX: + var_size = sizeof(CCTK_COMPLEX); + break; + + default: + msg = malloc( 200*sizeof(char) ); + sprintf(msg,"Unknown variable type (%d) in pugh_SetupScalarGroup",vtype); + CCTK_WARN(0,msg); + free(msg); + var_size = 1; + } temp = (void ***)realloc(newGH->variables, (newGH->nvariables+n_variables)*sizeof(void **)); @@ -157,11 +215,15 @@ int pugh_SetupArrayGroup(pGH *newGH, int vtype, int dim, int n_variables, int n_ @endhistory @@*/ -int pugh_SetupGFGroup(pGH *newGH, int vtype, int dim, int n_variables, int n_timelevels) +int pugh_SetupGFGroup(pGH *newGH, + int vtype, + int dim, + int n_variables, + int n_timelevels) { int variable; - + char *msg; int var_size; void ***temp; @@ -172,16 +234,69 @@ int pugh_SetupGFGroup(pGH *newGH, int vtype, int dim, int n_variables, int n_tim switch(vtype) { - case CCTK_VARIABLE_CHAR : var_size = sizeof(CCTK_CHAR); break; - case CCTK_VARIABLE_INT : var_size = sizeof(CCTK_INT) ; break; - case CCTK_VARIABLE_REAL : var_size = sizeof(CCTK_REAL); break; - case CCTK_VARIABLE_COMPLEX : var_size = sizeof(CCTK_COMPLEX); break; - default : CCTK_WARN(0, - "Unknown variable type in pugh_SetupScalarGroup"); - var_size = 1; + case CCTK_VARIABLE_CHAR: + var_size = sizeof(CCTK_CHAR); + break; + + case CCTK_VARIABLE_INT: + var_size = sizeof(CCTK_INT) ; + break; + +#ifdef CCTK_INT2 + case CCTK_VARIABLE_INT2: + var_size = sizeof(CCTK_INT2); + break; +#endif + +#ifdef CCTK_INT4 + case CCTK_VARIABLE_INT4: + var_size = sizeof(CCTK_INT4); + break; +#endif + +#ifdef CCTK_INT8 + case CCTK_VARIABLE_INT8: + var_size = sizeof(CCTK_INT8); + break; +#endif + + case CCTK_VARIABLE_REAL: + var_size = sizeof(CCTK_REAL); + break; + +#ifdef CCTK_REAL4 + case CCTK_VARIABLE_REAL4: + var_size = sizeof(CCTK_REAL4); + break; +#endif + +#ifdef CCTK_REAL8 + case CCTK_VARIABLE_REAL8: + var_size = sizeof(CCTK_REAL8); + break; +#endif + +#ifdef CCTK_REAL16 + case CCTK_VARIABLE_REAL16: + var_size = sizeof(CCTK_REAL16); + break; +#endif + + case CCTK_VARIABLE_COMPLEX: + var_size = sizeof(CCTK_COMPLEX); + break; + + default: + msg = malloc( 200*sizeof(char) ); + sprintf(msg,"Unknown variable type (%d) in pugh_SetupGFGroup",vtype); + CCTK_WARN(0,msg); + free(msg); + var_size = 1; + } - temp = (void ***)realloc(newGH->variables, (newGH->nvariables+n_variables)*sizeof(void **)); + temp = (void ***)realloc(newGH->variables, + (newGH->nvariables+n_variables)*sizeof(void **)); if(temp) { @@ -189,18 +304,20 @@ int pugh_SetupGFGroup(pGH *newGH, int vtype, int dim, int n_variables, int n_tim for(variable = 0; variable < n_variables; variable++) { - newGH->variables[newGH->nvariables] = (void **)malloc(n_timelevels*sizeof(void *)); + newGH->variables[newGH->nvariables] = + (void **)malloc(n_timelevels*sizeof(void *)); if(newGH->variables[newGH->nvariables]) { for(level = 0; level < n_timelevels; level++) { - newGH->variables[newGH->nvariables][level] = SetupPGF(newGH, - CCTK_VarName(newGH->nvariables), - dim, - var_size, - vtype, - PUGH_VERTEXCTR); + newGH->variables[newGH->nvariables][level] = + SetupPGF(newGH, + CCTK_VarName(newGH->nvariables), + dim, + var_size, + vtype, + PUGH_VERTEXCTR); } newGH->nvariables++; } |