Compiling Error using gfortran on MacOS

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Moncho R Raposo
Posts: 3
Joined: May 23 2011
Affiliation: USC

Compiling Error using gfortran on MacOS

Post by Moncho R Raposo » June 07 2011

When I try to compile the code using gfortran on MacOS everything goes fine till it reaches the params_CMB.f90, where I have the following error:


fortran -DMATRIX_SINGLE -O2 -ffree-form -x f95-cpp-input -I../camb -I../cfitsio/include -I../likelihood_v4p1 -c params_CMB.f90
params_CMB.f90:146.19:

call SetForH(Params,CMB,LastH0, .true.)
1
Error: El argumento dummy 'firsttime' del procedimiento 'setforh' en (1) tiene un atributo que requiere una interfaz explícita para este procedimiento
params_CMB.f90:146.19:
Which can be translated as: Error: The dummy argument 'firsttime' of the procedure 'setforh' in (1) has an attribute that requires an explicit interface for the procedure

Do you have any idea of what is happening? I already downloaded the latest version of gfortran.

Wessel Valkenburg
Posts: 6
Joined: March 14 2008
Affiliation: RWTH Aachen

Compiling Error using gfortran on MacOS

Post by Wessel Valkenburg » July 01 2011

Hi,

I had the same problem, and I resolved it by adding an interface in each module that calls setforh. For example:

Code: Select all

 
subroutine ParamsToCMBParams(Params, CMB)
     use settings
     use cmbtypes
     use CMB_Cls

     implicit none
     real Params(num_params)
     real, save :: LastParams(num_params) = 0.
     real, save :: LastH0, Lastzre

     Type(CMBParams) CMB
     real DA
     real  D_b,D_t,D_try,try_b,try_t, CMBToTheta, lasttry,tau
     external CMBToTheta
    interface
        subroutine SetForH(Params,CMB,H0, firsttime)
            use settings
            use cmbtypes
            use CMB_Cls
            implicit none
            real Params(num_Params)
            logical, intent(in), optional :: firsttime
            Type(CMBParams) CMB
            real H0
        end subroutine SetForH
    end interface

The reason is that (at least, Google told me) in Fortran officially you need to use an explicit interface to a procedure, if it uses "advanced features such as optional parameters". And since these particular routines are all external and not all together inside one module, you need to put this interface declaration in the subroutine. But apparently only gfortran bothers about this rule.

Ross O'Connell
Posts: 4
Joined: June 29 2011
Affiliation: Carnegie Mellon University

Compiling Error using gfortran on MacOS

Post by Ross O'Connell » July 01 2011

After a couple days of trying to get CosmoMC and everything it depends on to compile on my Macbook, I wound up installing Virtualbox (a free virtualization thing) and a Ubuntu 10.04 VM. Working with ifort (free on linux) has been much easier than working with gfortran. I don't know if the same thing would work for you, but I thought it was worth passing along.

Moncho R Raposo
Posts: 3
Joined: May 23 2011
Affiliation: USC

Compiling Error using gfortran on MacOS

Post by Moncho R Raposo » July 03 2011

Thanks very much for the help Ross.I was so frustrated that I have installed ubuntu 11.04 on my other machines and I was able to compile it using gfortran. I think I will leave the macbook for checking the email and travelling. By the way, I didn't know that the ifort was free for linux. Good to know anyway!

Sheng Li
Posts: 57
Joined: May 26 2009
Affiliation: University of Sussex
Contact:

Re: Compiling Error using gfortran on MacOS

Post by Sheng Li » July 04 2011

Moncho R Raposo wrote:Thanks very much for the help Ross.I was so frustrated that I have installed ubuntu 11.04 on my other machines and I was able to compile it using gfortran. I think I will leave the macbook for checking the email and travelling. By the way, I didn't know that the ifort was free for linux. Good to know anyway!
of course it is free, though it will be authorized by a serial number per machine/installation.

Sheng Li
Posts: 57
Joined: May 26 2009
Affiliation: University of Sussex
Contact:

Compiling Error using gfortran on MacOS

Post by Sheng Li » July 04 2011

I think you guys will be disappointed again due to the intensive computing for MCMC or MPI in Macbook (or any notebook).

but if you just use camb, that is ok.

Wessel Valkenburg
Posts: 6
Joined: March 14 2008
Affiliation: RWTH Aachen

Compiling Error using gfortran on MacOS

Post by Wessel Valkenburg » July 07 2011

I'm a bit confused about this still: if I pull the current master branch of cosmomc from Codaset, it compiles with gfortran with the settings as already present in the default makefile, without any complaint...

The edit I proposed above in this thread, wasn't even necessary (although it was necessary on my own older / custom cosmomc branch).

Using OS X 10.6.8 and gfortran 4.5.1.

Michael Obranovich
Posts: 6
Joined: July 15 2011
Affiliation: The Ohio State University

Compiling Error using gfortran on MacOS

Post by Michael Obranovich » July 20 2011

I was having this problem on a linux machine using gfortran 4.6.1 i downgraded to 4.4.5 and it fixed the issue for me.

Richard Easther
Posts: 16
Joined: April 14 2005
Affiliation: Yale

Compiling Error using gfortran on MacOS

Post by Richard Easther » August 06 2011

I just ran into this as well, using gfortran 4.6.1 on MacOS Lion, and a freshy downloaded CosmoMC.

Will be trying Wessel's fix.

Antony Lewis
Posts: 1947
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Compiling Error using gfortran on MacOS

Post by Antony Lewis » August 08 2011

Just uploaded Aug2011 minor version update which should compile OK with gfortran 4.6.

Ryan Callahan

Re: Compiling Error using gfortran on MacOS

Post by Ryan Callahan » August 23 2011

Antony Lewis wrote:Just uploaded Aug2011 minor version update which should compile OK with gfortran 4.6.
where can i find it?

Antony Lewis
Posts: 1947
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Compiling Error using gfortran on MacOS

Post by Antony Lewis » August 28 2011

Follow the download link on the cosmomc homepage/readme.

Post Reply