marquardt.christian at gmail.com
2006-Mar-22 02:15 UTC
[Rd] Double complex with gcc and Intel v9 Fortran (PR#8699)
Full_Name: Christian Marquardt
Version: 2.2.1
OS: Linux
Submission from: (NULL) (84.167.229.240)
Hello,
I believe this is a bug in the configuration / installation:
When configuring R-2.2.1 using the Intel v9 Fortran compiler as default Fortran
compiler and g++ as C++ compiler on a Suse 9.3 Linux, the configuration script
finds that the C and Fortran idea of double comples disagree.
I have tried to extract the test used for this from m4/R.m4 (a slightly modified
version of the two test files is added at the end). When compiling
ifort -c ctest.f
gcc -c cftest.c
and linking properly,
ifort -nofor_main cftest.o ctest.o -o runme
running the executable gives the following output:
./runme
123.456000 14.710644
0.000000 -0.000006
To me, this inicates that the test should actually be passed successfully.
Unfortunately, I haven't quite understood how to rebuild the configure.ac
etc
once R.m4 is changed; otherwise I would try to come up with a patch for R.m4.
But maybe someone else can fix this?
Many thanks,
Christian.
----<ctest.f>------------------------------------
subroutine cftest(x)
complex*16 x(3)
integer i
c a few tests of constructs that are sometimes missing
if(x(1) .eq. x(1)) i = 0
x(1) = x(1)*x(2) + x(3)
end
----<cftest.c>------------------------------------
#include <math.h>
#define HAVE_F77_UNDERSCORE 1
#ifdef HAVE_F77_UNDERSCORE
# define F77_SYMBOL(x) x ## _
#else
# define F77_SYMBOL(x) x
#endif
typedef struct {
double r;
double i;
} Rcomplex;
extern void F77_SYMBOL(cftest)(Rcomplex *x);
int main () {
Rcomplex z[3];
z[0].r = 3.14159265;
z[0].i = 2.172;
z[1].i = 3.14159265;
z[1].r = 2.172;
z[2].r = 123.456;
z[2].i = 0.123456;
F77_SYMBOL(cftest)(z);
printf("%f %f\n", z[0].r, z[0].i);
printf("%f %f\n", z[0].r - 123.456, z[0].i - 14.71065);
if(fabs(z[0].r - 123.456) < 1e-4 && fabs(z[0].i - 14.71065) <
1e-4)
exit(0);
else exit(1);
}
ripley at stats.ox.ac.uk
2006-Mar-26 16:26 UTC
[Rd] Double complex with gcc and Intel v9 Fortran (PR#8699)
On Wed, 22 Mar 2006, marquardt.christian at gmail.com wrote:> Full_Name: Christian Marquardt > Version: 2.2.1 > OS: Linux > Submission from: (NULL) (84.167.229.240) > > > Hello, > > I believe this is a bug in the configuration / installation: > > When configuring R-2.2.1 using the Intel v9 Fortran compiler as default > Fortran compiler and g++ as C++ compiler on a Suse 9.3 Linux, the > configuration script finds that the C and Fortran idea of double comples > disagree. > > I have tried to extract the test used for this from m4/R.m4 (a slightly > modified version of the two test files is added at the end). When > compiling > > ifort -c ctest.f > gcc -c cftest.c > > and linking properly, > > ifort -nofor_main cftest.o ctest.o -o runme > > running the executable gives the following output: > > ./runme > 123.456000 14.710644 > 0.000000 -0.000006 > > To me, this inicates that the test should actually be passed successfully.No, because R is linked with the C compiler and not the Fortran compiler. Did you look in config.log and see what it indicated the error was? You have not shown us anything that indicates that this is a bug in R. You also haven't told us what architecture this is: I tried mixing gcc 3.4.4 and ifort 9.0 on x86_64 Fedora Core 3, and had no problems.> Unfortunately, I haven't quite understood how to rebuild the configure.ac etc > once R.m4 is changed;I presume you mean to rebuild 'configure': configure.ac does not depend on R.m4. Just configure in maintainer mode, and 'make'.> otherwise I would try to come up with a patch for R.m4. > But maybe someone else can fix this?We cannot fix things that we cannot reproduce.> > Many thanks, > > Christian. > > > ----<ctest.f>------------------------------------ > subroutine cftest(x) > complex*16 x(3) > integer i > > c a few tests of constructs that are sometimes missing > if(x(1) .eq. x(1)) i = 0 > x(1) = x(1)*x(2) + x(3) > end > > ----<cftest.c>------------------------------------ > #include <math.h> > #define HAVE_F77_UNDERSCORE 1 > #ifdef HAVE_F77_UNDERSCORE > # define F77_SYMBOL(x) x ## _ > #else > # define F77_SYMBOL(x) x > #endif > > typedef struct { > double r; > double i; > } Rcomplex; > > extern void F77_SYMBOL(cftest)(Rcomplex *x); > > int main () { > Rcomplex z[3]; > > z[0].r = 3.14159265; > z[0].i = 2.172; > z[1].i = 3.14159265; > z[1].r = 2.172; > z[2].r = 123.456; > z[2].i = 0.123456; > F77_SYMBOL(cftest)(z); > printf("%f %f\n", z[0].r, z[0].i); > printf("%f %f\n", z[0].r - 123.456, z[0].i - 14.71065); > if(fabs(z[0].r - 123.456) < 1e-4 && fabs(z[0].i - 14.71065) < 1e-4) > exit(0); > else exit(1); > } > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595