From 83f6fd8751b60798968978851a5e94098be0840f Mon Sep 17 00:00:00 2001 From: jthorn Date: Thu, 13 Feb 2003 13:31:25 +0000 Subject: fix the test for input and output arrays having the same number of real/complex parts so it doesn't give spurious errors if there are null pointers in either the input or output arrays git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@139 df1f8a13-aa1d-4dd4-9681-27ded5b42416 --- src/GeneralizedPolynomial-Uniform/template.c | 79 +++++++++++++++++++--------- 1 file changed, 55 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/GeneralizedPolynomial-Uniform/template.c b/src/GeneralizedPolynomial-Uniform/template.c index 3eff291..c12a308 100644 --- a/src/GeneralizedPolynomial-Uniform/template.c +++ b/src/GeneralizedPolynomial-Uniform/template.c @@ -408,11 +408,10 @@ int FUNCTION_NAME(/***** coordinate system *****/ * for (int out = 0 ; out < N_output_arrays ; ++out) * { * const int in = operand_indices[out]; - * ***decode*** the input/output array datatypes - * to determine whether they're real or complex - * (they must both be the same in this regard), then - * const int N_parts = data is complex ? 2 : 1; - * for (int part = 0 ; part < N_parts ; ++part) + * ***decode*** the output array datatype + * to determine whether it's real or complex + * const int N_output_parts = output array is complex ? 2 : 1; + * for (int part = 0 ; part < N_output_parts ; ++part) * { * if ( (input_arrays[in] != NULL) * && ( (input_arrays[in] != value at last fetch) @@ -420,6 +419,12 @@ int FUNCTION_NAME(/***** coordinate system *****/ * then { * save input_arrays[in] and part for * "previous value" test above + * ***decode*** the input array datatype + * to determine whether it's real or complex + * const int N_input_parts + * = input array is complex ? 2 : 1; + * if (N_input_parts != N_output_parts) + * then error(...) * switch (input_array_type_codes[in]) * { * case CCTK_VARIABLE_REAL: @@ -1029,37 +1034,36 @@ int pt; for (out = 0 ; out < N_output_arrays ; ++out) { const int in = operand_indices[out]; + const void* const input_array_ptr = input_arrays[in]; /* - * ***decode*** the input/output array datatypes - * to determine whether they're real or complex, - * and verify that they're both the same in this regard - * ==> define - * const int N_parts = data is complex ? 2 : 1; + * ***decode*** the output array datatype + * to determine whether it's real or complex, */ - const int N_input_parts - = LocalInterp_decode_N_parts(input_array_type_codes[in]); const int N_output_parts = LocalInterp_decode_N_parts(output_array_type_codes[out]); - if (N_input_parts != N_output_parts) + if (! ((N_output_parts == 1) || (N_output_parts == 2))) then { CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, "\n" -" CCTK_InterpLocalUniform(): can't do real input --> complex output or\n" -" complex input --> real output interpolation!\n" -" (0-origin) input #in=%d datatype = %d\n" -" (0-origin) output #out=%d datatype = %d\n" +" CCTK_InterpLocalUniform():\n" +" output array doesn't seem to be a real or complex number,\n" +" or more precisely, output array has number of \"real parts\"\n" +" (1=real, 2=complex) which isn't 1 or 2!\n" +" 0-origin output #out=%d\n" +" datatype code=%d\n" +" (datatype codes are defined by the Cactus flesh,\n" +" see src/include/cctk_Constants.h)\n" +" ==> N_parts=%d" , - in, (int) input_array_type_codes[in], - out, (int) output_array_type_codes[out]); /*NOTREACHED*/ + out, (int) output_array_type_codes[out], N_output_parts); + /*NOTREACHED*/ return UTIL_ERROR_BAD_INPUT; /*** ERROR RETURN ***/ } { - const int N_parts = N_input_parts; - const void* const input_array_ptr = input_arrays[in]; int part; - for (part = 0 ; part < N_parts ; ++part) + for (part = 0 ; part < N_output_parts ; ++part) { if ( (input_array_ptr != NULL) && @@ -1070,6 +1074,32 @@ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, input_array_ptr__last_fetch = input_array_ptr; part__last_fetch = part; + /* + * ***decode*** the input array datatype + * to determine whether it's real or complex, + */ + { + const int N_input_parts + = LocalInterp_decode_N_parts(input_array_type_codes[in]); + if (N_input_parts != N_output_parts) + then { +CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, +"\n" +" CCTK_InterpLocalUniform():\n" +" data types are incompatible between input and output arrays, or\n" +" more precisely, number of \"real parts\" (1=real, 2=complex) differ!\n" +" 0-origin input #in =%d datatype code=%d N_parts=%d\n" +" 0-origin output #out=%d datatype code=%d N_parts=%d\n" +" (datatype codes are defined by the Cactus flesh,\n" +" see src/include/cctk_Constants.h)" + , + in, (int) input_array_type_codes[in], N_input_parts, + out, (int) output_array_type_codes[out], N_output_parts); + /*NOTREACHED*/ + return UTIL_ERROR_BAD_INPUT; + /*** ERROR RETURN ***/ + } + /* * fetch the molecule-sized piece of * input_arrays[in][part] at this molecule @@ -1193,6 +1223,7 @@ return UTIL_ERROR_BAD_INPUT; /*** ERROR RETURN ***/ } } + } /* end of fetch input array values */ } @@ -1497,12 +1528,12 @@ CCTK_VWarn(1, __LINE__, __FILE__, CCTK_THORNSTRING, /* end of for (part = ...) loop */ } } - /* end of for (out = ...) loop */ - } + /* end of for (out = ...) loop */ } } } } + } /* end of for (pt = ...) loop */ } -- cgit v1.2.3