From jthorn at aei.mpg.de Wed Feb 1 05:46:21 2006 From: jthorn at aei.mpg.de (Jonathan Thornburg) Date: Wed, 1 Feb 2006 12:46:21 +0100 (CET) Subject: [Patches] Re: [Users] Cactus/src/include/cctk.h In-Reply-To: <43DF3774.7020903@aei.mpg.de> References: <43DDE7AA.7010602@aei.mpg.de> <9C52FA4C-5FF5-4A64-ADD7-E1217608551E@cct.lsu.edu> <43DF3774.7020903@aei.mpg.de> Message-ID: [[This discussion is now about a specific *code* issue, so I'm moving over to the patches/developers at cactuscode lists.]] On Tue, 31 Jan 2006, Frank Loeffler wrote: > cctk.h #defines _CCTK_FARGUMENTS. This is inserted at the beginning of each > function argument list in Fortran. This #define contains a lot of spaces. One > might think that spaces do not hurt, however: > > Peter Diener wrote: >> The Fortran 90 standard allows for 39 continuation lines, i.e. a total >> of 2880 (5280) characters in a line in 72 (132) line length mode. > > Frank Loeffler wrote: > ... concerning xlf (the IBM Fortran compiler) and the function argument list: >> The length of this cannot exceed 6700 characters AFAIK, but it does in >> Whisky (CCTK_ARGUMENTS). [[...]] > > You see, we hit this limit sometimes. Some compilers are more lax about this > limit, some are not. In any case I think we should try to produce valid > Fortran code. I do not suggest that the Cactus toolkit should try to minimise > the character count it uses for the argument list as much as possible to > leave more space for the users (thorns). However, it should not waste this > space by inserting spaces. As a partial solution, I suggest we convert long strings of repeated spaces in the macro expansion to single ASCII tab characters. In particular, I propose the enclosed patch, which reduces the size of the macro expansion by 1111 characters (old cctk.h = 13467 characters, new cctk.h = 12356 characters), with (IMHO) only a tiny loss in readability. Ok to apply to CVS? ciao, -- -- Jonathan Thornburg Max-Planck-Institut fuer Gravitationsphysik (Albert-Einstein-Institut), Golm, Germany, "Old Europe" http://www.aei.mpg.de/~jthorn/home.html "Washing one's hands of the conflict between the powerful and the powerless means to side with the powerful, not to be neutral." -- quote by Freire / poster by Oxfam -------------- next part -------------- Index: cctk.h =================================================================== RCS file: /cactusdevcvs/Cactus/src/include/cctk.h,v retrieving revision 1.95 diff -u -r1.95 cctk.h --- cctk.h 15 Dec 2005 13:28:15 -0000 1.95 +++ cctk.h 1 Feb 2006 11:45:44 -0000 @@ -33,33 +33,34 @@ #define CCTK_PRINTSEPARATOR\ print '("--------------------------------------------------------------------------------")' -#define _CCTK_FARGUMENTS cctk_dim, cctk_gsh, cctk_lsh, cctk_lbnd,\ - cctk_ubnd, cctk_lssh, cctk_from, cctk_to, cctk_bbox,\ - cctk_delta_time, cctk_time, cctk_delta_space,\ - cctk_origin_space, cctk_levfac, \ - cctk_levoff, cctk_levoffdenom, cctk_timefac, \ - cctk_convlevel, cctk_convfac, \ - cctk_nghostzones, cctk_iteration, cctkGH +#define _CCTK_FARGUMENTS \ + cctk_dim, cctk_gsh, cctk_lsh, cctk_lbnd,\ + cctk_ubnd, cctk_lssh, cctk_from, cctk_to, cctk_bbox,\ + cctk_delta_time, cctk_time, cctk_delta_space,\ + cctk_origin_space, cctk_levfac, \ + cctk_levoff, cctk_levoffdenom, cctk_timefac, \ + cctk_convlevel, cctk_convfac, \ + cctk_nghostzones, cctk_iteration, cctkGH #define _DECLARE_CCTK_ARGUMENTS _DECLARE_CCTK_FARGUMENTS #define _DECLARE_CCTK_FARGUMENTS INTEGER cctk_dim&&\ - INTEGER cctk_gsh(cctk_dim),cctk_lsh(cctk_dim)&&\ - INTEGER cctk_lbnd(cctk_dim),cctk_ubnd(cctk_dim)&&\ - INTEGER cctk_lssh(CCTK_NSTAGGER*cctk_dim)&&\ - INTEGER cctk_from(cctk_dim),cctk_to(cctk_dim)&&\ - INTEGER cctk_bbox(2*cctk_dim)&&\ - CCTK_REAL cctk_delta_time, cctk_time&&\ - CCTK_REAL cctk_delta_space(cctk_dim)&&\ - CCTK_REAL cctk_origin_space(cctk_dim)&&\ - INTEGER cctk_levfac(cctk_dim)&&\ - INTEGER cctk_levoff(cctk_dim)&&\ - INTEGER cctk_levoffdenom(cctk_dim)&&\ - INTEGER cctk_timefac&&\ - INTEGER cctk_convlevel&&\ - INTEGER cctk_convfac&&\ - INTEGER cctk_nghostzones(cctk_dim)&&\ - INTEGER cctk_iteration&&\ - CCTK_POINTER cctkGH&& + INTEGER cctk_gsh(cctk_dim),cctk_lsh(cctk_dim)&&\ + INTEGER cctk_lbnd(cctk_dim),cctk_ubnd(cctk_dim)&&\ + INTEGER cctk_lssh(CCTK_NSTAGGER*cctk_dim)&&\ + INTEGER cctk_from(cctk_dim),cctk_to(cctk_dim)&&\ + INTEGER cctk_bbox(2*cctk_dim)&&\ + CCTK_REAL cctk_delta_time, cctk_time&&\ + CCTK_REAL cctk_delta_space(cctk_dim)&&\ + CCTK_REAL cctk_origin_space(cctk_dim)&&\ + INTEGER cctk_levfac(cctk_dim)&&\ + INTEGER cctk_levoff(cctk_dim)&&\ + INTEGER cctk_levoffdenom(cctk_dim)&&\ + INTEGER cctk_timefac&&\ + INTEGER cctk_convlevel&&\ + INTEGER cctk_convfac&&\ + INTEGER cctk_nghostzones(cctk_dim)&&\ + INTEGER cctk_iteration&&\ + CCTK_POINTER cctkGH&& #define CCTK_WARN(a,b) CCTK_Warn(a,__LINE__,__FORTRANFILE__,CCTK_THORNSTRING,b) @@ -80,39 +81,39 @@ #ifdef F90CODE -#define _DECLARE_CCTK_FUNCTIONS \ - external CCTK_PointerTo &&\ - CCTK_POINTER CCTK_PointerTo &&\ - interface &&\ - integer function CCTK_Equals (arg1, arg2) &&\ - implicit none &&\ - CCTK_POINTER_TO_CONST arg1 &&\ - character(*) arg2 &&\ - end function CCTK_Equals &&\ - integer function CCTK_MyProc (cctkGH) &&\ - implicit none &&\ - CCTK_POINTER_TO_CONST cctkGH &&\ - end function CCTK_MyProc &&\ - integer function CCTK_nProcs (cctkGH) &&\ - implicit none &&\ - CCTK_POINTER_TO_CONST cctkGH &&\ - end function CCTK_nProcs &&\ - integer function CCTK_IsThornActive (name) &&\ - implicit none &&\ - character(*) name &&\ - end function CCTK_IsThornActive &&\ - CCTK_POINTER function CCTK_NullPointer () &&\ - implicit none &&\ - end function CCTK_NullPointer &&\ - end interface && +#define _DECLARE_CCTK_FUNCTIONS \ +external CCTK_PointerTo &&\ +CCTK_POINTER CCTK_PointerTo &&\ +interface &&\ + integer function CCTK_Equals(arg1, arg2) &&\ + implicit none &&\ + CCTK_POINTER_TO_CONST arg1 &&\ + character(*) arg2 &&\ + end function CCTK_Equals &&\ + integer function CCTK_MyProc(cctkGH) &&\ + implicit none &&\ + CCTK_POINTER_TO_CONST cctkGH &&\ + end function CCTK_MyProc &&\ + integer function CCTK_nProcs(cctkGH) &&\ + implicit none &&\ + CCTK_POINTER_TO_CONST cctkGH &&\ + end function CCTK_nProcs &&\ + integer function CCTK_IsThornActive(name) &&\ + implicit none &&\ + character(*) name &&\ + end function CCTK_IsThornActive &&\ + CCTK_POINTER function CCTK_NullPointer() &&\ + implicit none &&\ + end function CCTK_NullPointer &&\ +end interface && #else /* ! F90CODE */ #define _DECLARE_CCTK_FUNCTIONS \ - integer CCTK_Equals, CCTK_MyProc, CCTK_nProcs, CCTK_IsThornActive &&\ - external CCTK_Equals, CCTK_MyProc, CCTK_nProcs, CCTK_IsThornActive &&\ - CCTK_POINTER CCTK_PointerTo, CCTK_NullPointer &&\ - external CCTK_PointerTo, CCTK_NullPointer && + integer CCTK_Equals, CCTK_MyProc, CCTK_nProcs, CCTK_IsThornActive &&\ + external CCTK_Equals, CCTK_MyProc, CCTK_nProcs, CCTK_IsThornActive &&\ + CCTK_POINTER CCTK_PointerTo, CCTK_NullPointer &&\ + external CCTK_PointerTo, CCTK_NullPointer && #endif /* ! F90CODE */ From frank.loeffler at aei.mpg.de Fri Feb 3 03:18:30 2006 From: frank.loeffler at aei.mpg.de (Frank Loeffler) Date: Fri, 03 Feb 2006 10:18:30 +0100 Subject: [Patches] Re: [Developers] Re: [Users] Cactus/src/include/cctk.h In-Reply-To: References: <43DDE7AA.7010602@aei.mpg.de> <9C52FA4C-5FF5-4A64-ADD7-E1217608551E@cct.lsu.edu> <43DF3774.7020903@aei.mpg.de> <43E0A2BB.2070703@aei.mpg.de> <85546234-990C-4E05-927C-B8009AE0C56E@cct.lsu.edu> <43E0C8F8.4040906@aei.mpg.de> <6417D9E0-5426-4859-96C8-B15387F66595@cct.lsu.edu> <43E1DD0C.7040103@aei.mpg.de> Message-ID: <43E31FE6.9020209@aei.mpg.de> Hi, for inclusion or just for the record, here is the patch. Description: Spaces in _CCTK_FARGUMENTS removed to use as less space as possible. This leaves thorn writers more space for their own variables. Space can be a problem because of Fortran standard and/or compiler limitations. Frank -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch Url: http://www.cactuscode.org/pipermail/patches/attachments/20060203/8c3c76cc/attachment.pl From schnetter at cct.lsu.edu Wed Feb 8 13:41:40 2006 From: schnetter at cct.lsu.edu (Erik Schnetter) Date: Wed, 8 Feb 2006 13:41:40 -0600 Subject: [Patches] Indicate restriction in schedule Message-ID: <2EE45695-880A-4E9E-A2DE-C24F15874725@cct.lsu.edu> Indicate the time at which restriction happens is indicated in the schedule. Also move the description of the postrestrict bin to this place; the postrestrict bin used to be explained at the end of the schedule. -erik -- Erik Schnetter My email is as private as my paper mail. I therefore support encrypting and signing email messages. Get my PGP key from www.keyserver.net. -------------- next part -------------- A non-text attachment was scrubbed... Name: SchedulInterface.diff Type: application/octet-stream Size: 1820 bytes Desc: not available Url : http://www.cactuscode.org/pipermail/patches/attachments/20060208/85d35baf/attachment.obj From steve.white at aei.mpg.de Mon Feb 13 07:44:53 2006 From: steve.white at aei.mpg.de (Steve White) Date: Mon, 13 Feb 2006 14:44:53 +0100 Subject: [Patches] snprintf.c : reduce compiler warnings Message-ID: <20060213134453.GA22546@xeon01.aei.mpg.de> Hello, This is part of a project to reduce the compiler warnings generated by Cactus Flesh code. Intel icc in particular complains mightily about automatic type conversions that could lose data in src/util/snprintf.c Changes ------- Several deliberate conversions are now marked as such with type casts. Note ---- I ignored one warning. Intel icc complains that (caps ? 'E' : 'e') is an int: util/snprintf.c(733): warning #810: conversion from "int" to "char" may lose significant bits econvert[eplace++] = caps ? 'E' : 'e'; You can humour the compiler by casting (caps ? 'E' : 'e') to char, but this seems to be just wrong. According to K&R 2nd ed A7.16: "if both [the second and third operands] are void, or structures or unions of the same type, or pointers to objects of the same type, the result has the common type." Am I missing something? I'll see if Intel has a bug report on this. Testing ------- I ran all the testsuites against a copy with no changes, and got identical results. Find attached the patch. -- Steve White : Programmer Max-Planck-Institut f?r Gravitationsphysik Albert-Einstein-Institut Am M?hlenberg 1, D-14476 Golm, Germany +49-331-567-7625 -------------- next part -------------- Index: src/util/snprintf.c =================================================================== RCS file: /cactusdevcvs/Cactus/src/util/snprintf.c,v retrieving revision 1.10 diff -u -r1.10 snprintf.c --- src/util/snprintf.c 5 Apr 2005 11:37:07 -0000 1.10 +++ src/util/snprintf.c 13 Feb 2006 13:31:55 -0000 @@ -365,7 +365,8 @@ total += fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); break; case 'c': - total += dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); + total += dopr_outch (buffer, &currlen, maxlen, + (char)va_arg (args, int)); break; case 's': strvalue = va_arg (args, char *); @@ -381,7 +382,7 @@ { short int *num; num = va_arg (args, short int *); - *num = currlen; + *num = (short int)currlen; } else if (cflags == DP_C_LONG) { @@ -538,7 +539,7 @@ /* Sign */ if (signvalue) - total += dopr_outch (buffer, currlen, maxlen, signvalue); + total += dopr_outch (buffer, currlen, maxlen, (char)signvalue); /* Zeros */ if (zpadlen > 0) @@ -590,7 +591,7 @@ { long intpart; - intpart = value; + intpart = (long)value; value = value - intpart; if (value >= 0.5) intpart++; @@ -668,7 +669,7 @@ } } - intpart = ufvalue; + intpart = (long)ufvalue; /* * Sorry, we only support 9 digits past the decimal because of our @@ -685,7 +686,7 @@ if (fracpart >= mypow10 (max)) { intpart++; - fracpart -= mypow10 (max); + fracpart -= (long)mypow10 (max); } #ifdef DEBUG_SNPRINTF @@ -752,7 +753,7 @@ { if (signvalue) { - total += dopr_outch (buffer, currlen, maxlen, signvalue); + total += dopr_outch (buffer, currlen, maxlen, (char)signvalue); --padlen; signvalue = 0; } @@ -768,7 +769,7 @@ --padlen; } if (signvalue) - total += dopr_outch (buffer, currlen, maxlen, signvalue); + total += dopr_outch (buffer, currlen, maxlen, (char)signvalue); while (iplace > 0) total += dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); From steve.white at aei.mpg.de Mon Feb 13 07:48:40 2006 From: steve.white at aei.mpg.de (Steve White) Date: Mon, 13 Feb 2006 14:48:40 +0100 Subject: [Patches] ParseFile.c: reduce compiler warnings Message-ID: <20060213134840.GB22546@xeon01.aei.mpg.de> Hello, This is part of a project to reduce the compiler warnings generated by Cactus Flesh code. Intel icc complains of the usual fgetc() return value conversion, several times in src/util/ParseFile.c The attached patch fixes these issues, so that the file now compiles with no warnings in gcc or icc. I ran the full set of testsuites with the modified and unmodified code, and got identical results. Cheers! -- Steve White : Programmer Max-Planck-Institut f?r Gravitationsphysik Albert-Einstein-Institut Am M?hlenberg 1, D-14476 Golm, Germany +49-331-567-7625 -------------- next part -------------- Index: src/util/ParseFile.c =================================================================== RCS file: /cactusdevcvs/Cactus/src/util/ParseFile.c,v retrieving revision 1.23 diff -u -r1.23 ParseFile.c --- src/util/ParseFile.c 4 Aug 2005 12:52:09 -0000 1.23 +++ src/util/ParseFile.c 13 Feb 2006 11:03:50 -0000 @@ -186,7 +186,7 @@ /* Token character */ if (intoken && c != '=') { - tokens[intoken++] = c; + tokens[intoken++] = (char)c; CheckBuf(intoken,lineno); } @@ -195,7 +195,7 @@ if (c != ' ' && c != '\t' && c != '\n' && c != '\r' && !inval && !intoken) { intoken = 0; - tokens[intoken++] = c; + tokens[intoken++] = (char)c; } /* End of a token signified by an = */ @@ -257,7 +257,7 @@ /* Make an important decision NOT to include * line feeds in the string parameters */ - if (c != '\n') value[p++] = c; + if (c != '\n') value[p++] = (char)c; if (c == '\n') { printf ("Warning: Quoted string contains newline for token %s\n", @@ -314,7 +314,7 @@ { int p = 0; - value[p++] = c; + value[p++] = (char)c; if (ntokens == 1) { /* Simple case. We have an int @@ -326,7 +326,7 @@ #endif while (!(c==' ' || c=='\t' || c == '\n' || c == '\r' || c == EOF)) { - value[p++] = c; + value[p++] = (char)c; CheckBuf(p,lineno); c = fgetc(ifp); #ifdef DEBUG @@ -354,7 +354,7 @@ int pp=0, i; int pt, pv; - value[pp++] = c; + value[pp++] = (char)c; /* OK, since we only have numbers in the old input stream, we can go along getting ntokens-1 commas, stripping spaces, and @@ -368,7 +368,7 @@ { if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) { - value[pp++] = c; + value[pp++] = (char)c; CheckBuf(pp,lineno); } if (c == ',') ncommas ++; @@ -396,7 +396,7 @@ } /* And tack the rest on */ - value[pp++] = c; + value[pp++] = (char)c; CheckBuf(p,lineno); c = fgetc(ifp); @@ -405,7 +405,7 @@ #endif while (c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != EOF) { - value[pp++] = c; + value[pp++] = (char)c; CheckBuf(pp,lineno); c = fgetc(ifp); #ifdef DEBUG From steve.white at aei.mpg.de Mon Feb 13 07:52:16 2006 From: steve.white at aei.mpg.de (Steve White) Date: Mon, 13 Feb 2006 14:52:16 +0100 Subject: [Patches] DefaultTimers.c: reduce compiler warnings Message-ID: <20060213135216.GC22546@xeon01.aei.mpg.de> Hello, This is part of a project to reduce the compiler warnings generated by Cactus Flesh code. Intel icc in particular complains of automatic conversions from double to time.h types in src/main/DefaultTimers.c The attached patch makes those conversions explicit, as it is apparent that they are deliberate. I tested this by running the full set of testsuites with the modified and unmodified code, and found the results to be identical. -- Steve White : Programmer Max-Planck-Institut f?r Gravitationsphysik Albert-Einstein-Institut Am M?hlenberg 1, D-14476 Golm, Germany +49-331-567-7625 -------------- next part -------------- Index: src/main/DefaultTimers.c =================================================================== RCS file: /cactusdevcvs/Cactus/src/main/DefaultTimers.c,v retrieving revision 1.20 diff -u -r1.20 DefaultTimers.c --- src/main/DefaultTimers.c 12 Aug 2004 09:42:49 -0000 1.20 +++ src/main/DefaultTimers.c 13 Feb 2006 11:06:53 -0000 @@ -369,8 +369,9 @@ (void) (timernum + 0); data = (t_GetTimeOfDayTimer *) idata; - data->total.tv_sec = vals[0].val.d; - data->total.tv_usec = 1000000*vals[0].val.d - data->total.tv_sec; + data->total.tv_sec = (time_t)vals[0].val.d; + data->total.tv_usec = (suseconds_t)(1000000*vals[0].val.d) + - (suseconds_t)data->total.tv_sec; } @@ -644,8 +645,9 @@ (void) (timernum + 0); data = (t_GetrUsageTimer *) idata; - data->total.tv_sec = vals[0].val.d; - data->total.tv_usec = 1000000*vals[0].val.d - data->total.tv_sec; + data->total.tv_sec = (time_t)vals[0].val.d; + data->total.tv_usec = (suseconds_t)(1000000*vals[0].val.d) + - (suseconds_t)data->total.tv_sec; } From steve.white at aei.mpg.de Mon Feb 13 08:00:24 2006 From: steve.white at aei.mpg.de (Steve White) Date: Mon, 13 Feb 2006 15:00:24 +0100 Subject: [Patches] ScheduleSorter.c: reduce compiler warnings Message-ID: <20060213140024.GD22546@xeon01.aei.mpg.de> Hello, This is part of a project to reduce the compiler warnings generated by Cactus Flesh code. Intel icc complains about a very weird looking automatic conversion that is probably intended: int to signed char NOTE ---- An explanation as to why the 'thisorders' array should be of signed char rather than int is warranted in the source code. Otherwise, I think the code would be improved by making the array of int. Anyway, I made the conversion explicit, thus making the warning go away. See attached patch. I tested this by running the full set of testsuites with the modified and unmodified code. The results were identical. Cheers! -- Steve White : Programmer Max-Planck-Institut f?r Gravitationsphysik Albert-Einstein-Institut Am M?hlenberg 1, D-14476 Golm, Germany +49-331-567-7625 -------------- next part -------------- Index: src/schedule/ScheduleSorter.c =================================================================== RCS file: /cactusdevcvs/Cactus/src/schedule/ScheduleSorter.c,v retrieving revision 1.11 diff -u -r1.11 ScheduleSorter.c --- src/schedule/ScheduleSorter.c 18 Mar 2003 16:04:32 -0000 1.11 +++ src/schedule/ScheduleSorter.c 13 Feb 2006 11:04:20 -0000 @@ -190,9 +190,9 @@ { if(thisorders[column]) { - if(array[row][column] && array[row][column] != thisorders[column]) retval--; - array[row][column] = thisorders[column]; - array[column][row] = - thisorders[column]; + if(array[row][column] && array[row][column] != (signed char)thisorders[column]) retval--; + array[row][column] = (signed char)( thisorders[column]); + array[column][row] = (signed char)( -thisorders[column]); } } From steve.white at aei.mpg.de Tue Feb 14 09:24:53 2006 From: steve.white at aei.mpg.de (Steve White) Date: Tue, 14 Feb 2006 16:24:53 +0100 Subject: [Patches] Complex.c: reduce compiler warnings Message-ID: <20060214152452.GB3733@xeon01.aei.mpg.de> Hello, This is part of a project to reduce the compiler warnings generated by Cactus Flesh code. The changes go farther than to just make warnings go away. There is some suspicious code in this file. The "Pow" function was quite complicated, and besides generating compiler warnings, contains ad hoc logic and magic numbers of doubtful effectiveness. The usual implementation is pretty simple though, and I don't see any problems with it. So I replaced the code. I also added two notations. * The most complicated function is the complex Sqrt. I identified a source of similar code, and made a reference. * The code in this file depends on the standard C math functions, so, will not produce accurate results using long double types. I tested this by running the full set of testsuites with the modified and unmodified code. The results were identical. Cheers! -- Steve White : Programmer Max-Planck-Institut f?r Gravitationsphysik Albert-Einstein-Institut Am M?hlenberg 1, D-14476 Golm, Germany +49-331-567-7625 -------------- next part -------------- Index: src/main/Complex.c =================================================================== RCS file: /cactusdevcvs/Cactus/src/main/Complex.c,v retrieving revision 1.15 diff -u -r1.15 Complex.c --- src/main/Complex.c 3 Oct 2005 16:20:34 -0000 1.15 +++ src/main/Complex.c 14 Feb 2006 15:11:13 -0000 @@ -26,6 +26,7 @@ ********************* Local Routine Prototypes ********************* ********************************************************************/ +#define NORM(cx) sqrt((cx.Re) * (cx.Re) + (cx.Im) * (cx.Im)) /******************************************************************** ********************* Other Routine Prototypes ********************* ********************************************************************/ @@ -180,7 +181,7 @@ #define DEFINE_CCTK_CMPLX_ABS(CCTK_Cmplx, cctk_real, cctk_complex) \ cctk_real CCTK_Cmplx##Abs (cctk_complex complex_number) \ { \ - return (hypot (complex_number.Re, complex_number.Im)); \ + return ((cctk_real)hypot (complex_number.Re, complex_number.Im)); \ } @@ -327,10 +328,10 @@ cctk_complex result; \ \ \ - afact = fabs(a.Re) + fabs(a.Im); \ + afact = (cctk_real)(fabs(a.Re) + fabs(a.Im)); \ a.Re /= afact; \ a.Im /= afact; \ - bfact = fabs(b.Re) + fabs(b.Im); \ + bfact = (cctk_real)(fabs(b.Re) + fabs(b.Im)); \ b.Re /= bfact; \ b.Im /= bfact; \ factor = b.Re*b.Re + b.Im*b.Im; \ @@ -366,15 +367,17 @@ cctk_complex result; \ \ \ - if (complex_number.Im == 0.0) \ + if (complex_number.Im == (cctk_real)0.0) \ { \ - result.Re = sin (complex_number.Re); \ - result.Im = 0.0; \ + result.Re = (cctk_real)sin (complex_number.Re); \ + result.Im = (cctk_real)0.0; \ } \ else \ { \ - result.Re = sin (complex_number.Re) * cosh (complex_number.Im); \ - result.Im = cos (complex_number.Re) * sinh (complex_number.Im); \ + result.Re = (cctk_real)(sin (complex_number.Re) \ + * cosh (complex_number.Im)); \ + result.Im = (cctk_real)(cos (complex_number.Re) \ + * sinh (complex_number.Im)); \ } \ \ return (result); \ @@ -406,15 +409,17 @@ cctk_complex result; \ \ \ - if (complex_number.Im == 0.0) \ + if (complex_number.Im == (cctk_real)0.0) \ { \ - result.Re = cos (complex_number.Re); \ - result.Im = 0.0; \ + result.Re = (cctk_real)cos (complex_number.Re); \ + result.Im = (cctk_real)0.0; \ } \ else \ { \ - result.Re = cos (complex_number.Re) * cosh (complex_number.Im); \ - result.Im = sin (complex_number.Re) * sinh (complex_number.Im); \ + result.Re = (cctk_real)(cos (complex_number.Re) \ + * cosh (complex_number.Im)); \ + result.Im = (cctk_real)(sin (complex_number.Re) \ + * sinh (complex_number.Im)); \ } \ \ return (result); \ @@ -447,10 +452,10 @@ cctk_complex result; \ \ \ - rho = exp (complex_number.Re); \ + rho = (cctk_real)exp (complex_number.Re); \ theta = complex_number.Im; \ - result.Re = rho * cos (theta); \ - result.Im = rho * sin (theta); \ + result.Re = rho * (cctk_real)cos (theta); \ + result.Im = rho * (cctk_real)sin (theta); \ \ return (result); \ } @@ -463,7 +468,11 @@ @desc Returns the square root of a complex number. @enddesc - + @history + This code bears a resemblance to that in the GSL. That + code contains references. + @endhistory + @var complex_number @vdesc The complex number @vtype CCTK_COMPLEX @@ -482,34 +491,35 @@ cctk_complex result; \ \ \ - if (complex_number.Re == 0.0 && complex_number.Im == 0.0) \ + if (complex_number.Re == (cctk_real)0.0 \ + && complex_number.Im == (cctk_real)0.0) \ { \ - result.Re = result.Im = 0.0; \ + result.Re = result.Im = (cctk_real)0.0; \ } \ else \ { \ - x = fabs (complex_number.Re); \ - y = fabs (complex_number.Im); \ + x = (cctk_real)fabs (complex_number.Re); \ + y = (cctk_real)fabs (complex_number.Im); \ if (x >= y) \ - { \ + { \ t = y / x; \ - w = sqrt (x) * sqrt (0.5 * (1.0 + sqrt (1.0 * t * t))); \ + w = (cctk_real)(sqrt (x) * sqrt (0.5 * (1.0 + sqrt (1.0 * t * t)))); \ } \ else \ { \ t = x / y; \ - w = sqrt (y) * sqrt (0.5 * (t + sqrt (1.0 * t * t))); \ + w = (cctk_real)(sqrt (y) * sqrt (0.5 * (t + sqrt (1.0 * t * t)))); \ } \ - \ - if (complex_number.Re >= 0.0) \ - { \ + \ + if (complex_number.Re >= (cctk_real)0.0) \ + { \ result.Re = w; \ - result.Im = complex_number.Im / (2.0 * w); \ + result.Im = complex_number.Im / ((cctk_real)2.0 * w); \ } \ else \ { \ - x = complex_number.Im >= 0 ? w : -w; \ - result.Re = complex_number.Im / (2.0 * x); \ + x = complex_number.Im >= (cctk_real)0.0 ? w : -w; \ + result.Re = complex_number.Im / ((cctk_real)2.0 * x); \ result.Im = x; \ } \ } \ @@ -525,71 +535,33 @@ Raises a complex number to a given power @enddesc - @var complex_number + @var cx_number @vdesc The complex number @vtype CCTK_COMPLEX @vio in @endvar + + @var w + @vdesc The power + @vtype CCTK_REAL + @vio in + @endvar @returntype CCTK_COMPLEX @returndesc - The square root + The given power of the number @endreturndesc @@*/ #define DEFINE_CCTK_CMPLX_POW(CCTK_Cmplx, cctk_real, cctk_complex) \ -cctk_complex CCTK_Cmplx##Pow (cctk_complex complex_number, cctk_real w) \ +cctk_complex CCTK_Cmplx##Pow (cctk_complex cx_number, cctk_real w) \ { \ - cctk_real R, theta, phi; \ cctk_complex result; \ \ - if ( complex_number.Re > 0) \ - { \ - theta = 0.0; \ - phi = atan(complex_number.Im/complex_number.Re) + theta; \ - R = sqrt(complex_number.Re*complex_number.Re + complex_number.Im*complex_number.Im);\ - R = pow(R,w); \ - result.Re = R * cos (w * phi); \ - result.Im = R * sin (w * phi); \ - } \ - else if ( complex_number.Re < 0 && complex_number.Im >= 0 ) \ - { \ - theta = 4.0 * atan (1.0); \ - phi = atan(complex_number.Im/complex_number.Re) + theta; \ - R = sqrt(complex_number.Re*complex_number.Re + complex_number.Im*complex_number.Im);\ - R = pow(R,w); \ - result.Re = R * cos (w * phi); \ - result.Im = R * sin (w * phi); \ - } \ - else if ( complex_number.Re < 0 && complex_number.Im < 0 ) \ - { \ - theta = 4.0 * atan (1.0); \ - phi = atan(complex_number.Im/complex_number.Re) + theta; \ - R = sqrt(complex_number.Re*complex_number.Re + complex_number.Im*complex_number.Im);\ - R = pow(R,w); \ - result.Re = R * cos (w * phi); \ - result.Im = R * sin (w * phi); \ - } \ - else if ( fabs(complex_number.Re) <= 1e-20 && fabs(complex_number.Im) < 1e-20 )\ - { \ - result.Re = 0.0; \ - result.Im = 0.0; \ - } \ - else if ( fabs(complex_number.Re) <= 1e-20 && complex_number.Im < 0 ) \ - { \ - phi = 2.0 * atan (1.0); \ - R = sqrt(complex_number.Re*complex_number.Re + complex_number.Im*complex_number.Im);\ - R = pow(R,w); \ - result.Re = R * cos (w * phi); \ - result.Im = R * sin (w * phi); \ - } \ - if ( fabs(complex_number.Re) <= 1e-20 && complex_number.Im < 0 ) \ - { \ - phi = -2.0 * atan (1.0); \ - R = sqrt(complex_number.Re*complex_number.Re + complex_number.Im*complex_number.Im);\ - R = pow(R,w); \ - result.Re = R * cos (w * phi); \ - result.Im = R * sin (w * phi); \ - } \ + cctk_real phi = (cctk_real)atan2 (cx_number.Im, cx_number.Re) * w; \ + cctk_real r = (cctk_real)pow (NORM (cx_number), w); \ + \ + result.Re = r * (cctk_real)cos (phi); \ + result.Im = r * (cctk_real)sin (phi); \ \ return (result); \ } @@ -612,6 +584,9 @@ DEFINE_CCTK_CMPLX_POW (CCTK_Cmplx, cctk_real, cctk_complex) \ /* define complex functions for all available precisions */ +/* NOTE: The code in this file will function correctly with C float + * and double types, but not with long double. +*/ #ifdef CCTK_REAL4 DEFINE_CMPLX_FUNCTIONS (CCTK_Cmplx8, CCTK_REAL4, CCTK_COMPLEX8) #endif From tradke at aei.mpg.de Thu Feb 16 07:32:25 2006 From: tradke at aei.mpg.de (Thomas Radke) Date: Thu, 16 Feb 2006 14:32:25 +0100 Subject: [Patches] Also print the current working directory in the Cactus banner Message-ID: <43F47EE9.4030101@aei.mpg.de> This patch prints the current working directory at startup. -- Cheers, Thomas. -------------- next part -------------- A non-text attachment was scrubbed... Name: Banner.c.patch Type: text/x-patch Size: 1635 bytes Desc: not available Url : http://www.cactuscode.org/pipermail/patches/attachments/20060216/1430ab36/attachment.bin From tradke at aei.mpg.de Thu Feb 16 10:13:32 2006 From: tradke at aei.mpg.de (Thomas Radke) Date: Thu, 16 Feb 2006 17:13:32 +0100 Subject: [Developers] Re: [Patches] Also print the current working directory in the Cactus banner In-Reply-To: References: <43F47EE9.4030101@aei.mpg.de> Message-ID: <43F4A4AC.7090108@aei.mpg.de> Tom Goodale wrote: > > Looks fine. Please apply. > > Tom Applied. -- Cheers, Thomas. From dprideout at gmail.com Fri Feb 24 12:43:31 2006 From: dprideout at gmail.com (David Rideout) Date: Fri, 24 Feb 2006 18:43:31 +0000 Subject: [Patches] 'typo' in UsersGuide? Message-ID: <1ce81abb0602241043y22f6d5ccu1b4cbf026f656e30@mail.gmail.com> I was about to commit the following fix, but then wondered whether the author did really intend 'thorns'. So I submit it as a patch. Cheers, David rideout at gussie UsersGuide]$ cvs diff -c ThornWriters.tex Index: ThornWriters.tex =================================================================== RCS file: /cactusdevcvs/Cactus/doc/UsersGuide/ThornWriters.tex,v retrieving revision 1.206 diff -b -B -c -r1.206 ThornWriters.tex *** ThornWriters.tex 21 Feb 2006 16:50:29 -0000 1.206 --- ThornWriters.tex 24 Feb 2006 18:41:35 -0000 *************** *** 238,244 **** \end{Lentry} Corresponding to the first two access levels there are two relationship ! statements that can be used to get variables from other thorns. \begin{Lentry} \item [\texttt{Inherits: <\var{name}>}] --- 238,244 ---- \end{Lentry} Corresponding to the first two access levels there are two relationship ! statements that can be used to get variables from other implementations. \begin{Lentry} \item [\texttt{Inherits: <\var{name}>}] From frank.loeffler at aei.mpg.de Tue Feb 28 08:31:31 2006 From: frank.loeffler at aei.mpg.de (Frank Loeffler) Date: Tue, 28 Feb 2006 15:31:31 +0100 Subject: [Patches] Re: [Developers] Re: [Users] Cactus/src/include/cctk.h In-Reply-To: <43E31FE6.9020209@aei.mpg.de> References: <43DDE7AA.7010602@aei.mpg.de> <9C52FA4C-5FF5-4A64-ADD7-E1217608551E@cct.lsu.edu> <43DF3774.7020903@aei.mpg.de> <43E0A2BB.2070703@aei.mpg.de> <85546234-990C-4E05-927C-B8009AE0C56E@cct.lsu.edu> <43E0C8F8.4040906@aei.mpg.de> <6417D9E0-5426-4859-96C8-B15387F66595@cct.lsu.edu> <43E1DD0C.7040103@aei.mpg.de> <43E31FE6.9020209@aei.mpg.de> Message-ID: <44045EC3.6050803@aei.mpg.de> Hi, Frank Loeffler wrote: > for inclusion or just for the record, here is the patch. Somehow, there was a linewrap too much in that patch. As requested, here is the correct one. Frank -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch Url: http://www.cactuscode.org/pipermail/patches/attachments/20060228/12f2933a/attachment.pl