[Rd] Double complex with gcc and Intel v9 Fortran (PR#8699)

marquardt.christian at gmail.com marquardt.christian at gmail.com
Wed Mar 22 03:15:15 CET 2006


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);
}



More information about the R-devel mailing list