From 877563c30139297e78b0b41bc4d4727828958fc6 Mon Sep 17 00:00:00 2001 From: tradke Date: Mon, 14 Apr 2003 09:56:53 +0000 Subject: Handle all complex variable datatypes (not just the standard CCTK_COMPLEX). This closes PR CactusPUGH/1475. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGH/PUGHReduce/trunk@36 d60812e6-3970-4df4-986e-c251b06effeb --- src/ReductionMax.c | 19 ++++++++++++------- src/ReductionMin.c | 19 ++++++++++++------- src/ReductionNorm1.c | 29 ++++++++++++++++++++++++++++- src/ReductionNorm2.c | 23 ++++++++++++++++++++++- src/ReductionNormInf.c | 29 ++++++++++++++++++++++++++++- src/ReductionSum.c | 19 ++++++++++++------- 6 files changed, 114 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ReductionMax.c b/src/ReductionMax.c index 06c28ab..bc02aa0 100644 --- a/src/ReductionMax.c +++ b/src/ReductionMax.c @@ -212,8 +212,9 @@ static int ReductionMaxVal (const cGH *GH, CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; + const char *vtypename; #ifdef CCTK_MPI - pGH *pughGH; + const pGH *pughGH; CCTK_REAL *local_outvals; #endif @@ -297,13 +298,17 @@ static int ReductionMaxVal (const cGH *GH, break; #endif - case CCTK_VARIABLE_COMPLEX: - CCTK_WARN (1, "PUGH_ReductionMaxVal: Don't know how to compute " - "the maximum of complex variables !!!"); - return (-1); - default: - CCTK_WARN (1, "PUGH_ReductionMaxVal: Unknown variable type"); + vtypename = CCTK_VarTypeName (intypes[i]); + if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0) + { + CCTK_WARN (1, "PUGH_ReductionMaxVal: Don't know how to compute " + "the maximum of complex variables !!!"); + } + else + { + CCTK_WARN (1, "PUGH_ReductionMaxVal: Unknown variable type"); + } return (-1); } } diff --git a/src/ReductionMin.c b/src/ReductionMin.c index 2d7d494..d28e24f 100644 --- a/src/ReductionMin.c +++ b/src/ReductionMin.c @@ -213,8 +213,9 @@ static int ReductionMinVal (const cGH *GH, CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; + const char *vtypename; #ifdef CCTK_MPI - pGH *pughGH; + const pGH *pughGH; CCTK_REAL *local_outvals; #endif @@ -298,13 +299,17 @@ static int ReductionMinVal (const cGH *GH, break; #endif - case CCTK_VARIABLE_COMPLEX: - CCTK_WARN (1, "PUGH_ReductionMinVal: Don't know how to compute " - "the minimum of complex variables !!!"); - return (-1); - default: - CCTK_WARN (1, "PUGH_ReductionMinVal: Unknown variable type"); + vtypename = CCTK_VarTypeName (intypes[i]); + if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0) + { + CCTK_WARN (1, "PUGH_ReductionMinVal: Don't know how to compute " + "the minimum of complex variables !!!"); + } + else + { + CCTK_WARN (1, "PUGH_ReductionMinVal: Unknown variable type"); + } return (-1); } } diff --git a/src/ReductionNorm1.c b/src/ReductionNorm1.c index f621602..4c4209b 100644 --- a/src/ReductionNorm1.c +++ b/src/ReductionNorm1.c @@ -216,7 +216,7 @@ static int ReductionNorm1 (const cGH *GH, CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; - pGH *pughGH; + const pGH *pughGH; #ifdef CCTK_MPI CCTK_REAL *local_outvals; #endif @@ -311,6 +311,33 @@ static int ReductionNorm1 (const cGH *GH, CCTK_REAL, outvals, num_outvals, total_outvals); break; +#ifdef CCTK_REAL4 +#undef REDUCTION_OPERATION +#define REDUCTION_OPERATION(norm1, scalar) norm1 += CCTK_Cmplx8Abs (scalar) + ITERATE_ARRAY (CCTK_COMPLEX8, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL4, outvals, num_outvals, total_outvals); + break; +#endif + +#ifdef CCTK_REAL8 +#undef REDUCTION_OPERATION +#define REDUCTION_OPERATION(norm1, scalar) norm1 += CCTK_Cmplx16Abs (scalar) + ITERATE_ARRAY (CCTK_COMPLEX16, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL8, outvals, num_outvals, total_outvals); + break; +#endif + +#ifdef CCTK_REAL16 +#undef REDUCTION_OPERATION +#define REDUCTION_OPERATION(norm1, scalar) norm1 += CCTK_Cmplx32Abs (scalar) + ITERATE_ARRAY (CCTK_COMPLEX32, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL16, outvals, num_outvals, total_outvals); + break; +#endif + default: CCTK_WARN (1, "PUGH_ReductionNorm1: Unknown variable type"); return (-1); diff --git a/src/ReductionNorm2.c b/src/ReductionNorm2.c index 737a095..7d0fc04 100644 --- a/src/ReductionNorm2.c +++ b/src/ReductionNorm2.c @@ -217,7 +217,7 @@ static int ReductionNorm2 (const cGH *GH, CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; - pGH *pughGH; + const pGH *pughGH; #ifdef CCTK_MPI CCTK_REAL *local_outvals; #endif @@ -311,6 +311,27 @@ static int ReductionNorm2 (const cGH *GH, CCTK_REAL, outvals, num_outvals, total_outvals); break; +#ifdef CCTK_REAL4 + ITERATE_ARRAY (CCTK_COMPLEX8, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL4, outvals, num_outvals, total_outvals); + break; +#endif + +#ifdef CCTK_REAL8 + ITERATE_ARRAY (CCTK_COMPLEX16, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL8, outvals, num_outvals, total_outvals); + break; +#endif + +#ifdef CCTK_REAL16 + ITERATE_ARRAY (CCTK_COMPLEX32, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL16, outvals, num_outvals, total_outvals); + break; +#endif + default: CCTK_WARN (1, "PUGH_ReductionNorm2: Unknown variable type"); return (-1); diff --git a/src/ReductionNormInf.c b/src/ReductionNormInf.c index c304477..363ca5b 100644 --- a/src/ReductionNormInf.c +++ b/src/ReductionNormInf.c @@ -217,7 +217,7 @@ static int ReductionNormInf (const cGH *GH, { int i, total_outvals; #ifdef CCTK_MPI - pGH *pughGH; + const pGH *pughGH; CCTK_REAL *local_outvals; #endif @@ -322,6 +322,33 @@ static int ReductionNormInf (const cGH *GH, CCTK_REAL, outvals, num_outvals, total_outvals); break; +#ifdef CCTK_REAL4 +#undef REDUCTION_OPERATION +#define REDUCTION_OPERATION(norm_inf, scalar) norm_inf = MAX(norm_inf, CCTK_Cmplx8Abs(scalar)) + ITERATE_ARRAY (CCTK_COMPLEX8, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL4, outvals, num_outvals, total_outvals); + break; +#endif + +#ifdef CCTK_REAL8 +#undef REDUCTION_OPERATION +#define REDUCTION_OPERATION(norm_inf, scalar) norm_inf = MAX(norm_inf, CCTK_Cmplx16Abs(scalar)) + ITERATE_ARRAY (CCTK_COMPLEX16, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL8, outvals, num_outvals, total_outvals); + break; +#endif + +#ifdef CCTK_REAL16 +#undef REDUCTION_OPERATION +#define REDUCTION_OPERATION(norm_inf, scalar) norm_inf = MAX(norm_inf, CCTK_Cmplx32Abs(scalar)) + ITERATE_ARRAY (CCTK_COMPLEX32, num_dims, inarrays[i], + from, to, iterator, points_per_dim, + CCTK_REAL16, outvals, num_outvals, total_outvals); + break; +#endif + default: CCTK_WARN (1, "PUGH_ReductionNormInf: Unknown variable type"); return (-1); diff --git a/src/ReductionSum.c b/src/ReductionSum.c index ffeb39e..46053ac 100644 --- a/src/ReductionSum.c +++ b/src/ReductionSum.c @@ -212,8 +212,9 @@ static int ReductionSum (const cGH *GH, CCTK_REAL outvals[/*num_inarrays*num_outvals*/]) { int i, total_outvals; + const char *vtypename; #ifdef CCTK_MPI - pGH *pughGH; + const pGH *pughGH; CCTK_REAL *local_outvals; #endif @@ -297,13 +298,17 @@ static int ReductionSum (const cGH *GH, break; #endif - case CCTK_VARIABLE_COMPLEX: - CCTK_WARN (1, "PUGH_ReductionSum: Don't know how to compute " - "the sum of complex variables !!!"); - return (-1); - default: - CCTK_WARN (1, "PUGH_ReductionSum: Unknown variable type"); + vtypename = CCTK_VarTypeName (intypes[i]); + if (vtypename && strncmp (vtypename, "CCTK_VARIABLE_COMPLEX", 21) == 0) + { + CCTK_WARN (1, "PUGH_ReductionSum: Don't know how to compute " + "the sum of complex variables !!!"); + } + else + { + CCTK_WARN (1, "PUGH_ReductionSum: Unknown variable type"); + } return (-1); } } -- cgit v1.2.3