[R-SIG-Mac] Which gcc version on mac os?

Berend Hasselman bhh at xs4all.nl
Sun Apr 10 11:20:20 CEST 2011


On 10-04-2011, at 10:42, Christophe Dutang wrote:

> Dear all,
> 
> I use R 2.12.2 to build, install and check my packages, in particular randtoolbox. On my macbook with OS X 10.6.7, the gcc installed is
> i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3) . From http://r.research.att.com/tools/, I have also downloaded gfortran (GNU Fortran (GCC) 4.2.3).
> 
> With this framework, I do not get any error and warnings on the randtoolbox package.
> 

Looking at your Fortran code, I think you have just been  lucky.

> But using gcc 4.6 on linux, Kurt Hornik get the following errors in the only one Fortran file of the package:
> 
> LowDiscrepancy.f:180.26:
> 
>        QN(I, J) = HQNORM(QUASI(J))                                    
>                         1
> Error: Return type mismatch of function 'hqnorm' at (1) (REAL(4)/REAL(8))

HQNORM is not declared with a type in the routine you are using it. Implicit declaration most likely implies it is real (real*4). But later on it is typed as double precision. Asking for trouble.


> LowDiscrepancy.f:1393.29:
> 
>                    TEMP1 = TEMP1 + TEMP01                             
>                            1
> Warning: Possible change of value in conversion from REAL(4) to INTEGER(4) at (1)

Temp01 is not declared and thus implicitly real*4 (most likely).

> LowDiscrepancy.f:405.29:
> 
>           QN(I, J) = SQNORM(QUASI(J))                                 
>                            1
> Error: Return type mismatch of function 'sqnorm' at (1) (REAL(4)/REAL(8))
> make: *** [LowDiscrepancy.o] Error 1
> 

see remark above about hqnorm. Same problem.

> 
> My first question is which is the standard version of gcc to use? from http://cran.r-project.org/web/checks/check_flavors.html#r-release-macosx-ix86, it should gcc 4.2.1 ? If I have to update gcc, where can I find the binaries? 
> 

gcc-4.2.1 comes with Xcode. And gfortran must be obtained from http://r.research.att.com/tools/
and should match the Xcode version. That's all.

But looking at that page I don't see a gfortran available for Apple gcc 5666 (from Xcode 3.2.6?).
I am using gfortran 5664 with Xcode 3.2.5.

Simon knows more about this.

> My second question, in the case I can reproduce this error on my macbook or a linux, the fortran errors are a wrong type between the QN variable and the return value of HQNORM. Looking at the LowDiscrepancy.f file, both QN and the return type of QNORM are DOUBLE PRECISION. Does anyone have a guess where is the problem?
> 

Yes.
Declare ALL variables. With implicit fortran typing you can run into all sorts of trouble.

Test compile your Fortran with

gfortran -c -fsyntax-only -fimplicit-none LowDiscrepancy.f

You'll get a shock.
Always at least test with -fimplicit-none.

best regards

Berend



More information about the R-SIG-Mac mailing list