## Camb: Compiling with gfortran

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Savvas Nesseris
Posts: 70
Joined: April 05 2005
Affiliation: UAM/IFT
Contact:

### Camb: Compiling with gfortran

I was experimenting the other day with the gfortran compiler, after I installed the latest version, and I noticed that there is no support for it in CAMB! (meaning that CAMB needs some tweaking so as to compile). Wouldn't it be better if CAMB supported it from the beginning?

I searched in CosmoCoffee but this was not answered in any thread, so I thought it deserves to be posted.

To compile with gfortran just edit the file inidriver.f90 and comment out (add a ! at the begging of the line) the "external iargc" part, which is at the beginning of the file. Then, compile as usual.

A more permanent solution ( perhaps for a future version of Camb?) is to replace the "external iargc" part with

#ifndef GFC
external iargc
#endif

The makefile in this case needs the following lines:

#Gfortran compiler
F90C = gfc
FFLAGS = -O2 -DGFC

and compilation goes a usual. I tested this with the September 2006 version of Camb and the latest version of gfortran.

Cheers,
Savas

Martin Reinecke
Posts: 13
Joined: July 26 2006
Affiliation: Max-Planck-Institute for Astrophysics

### Camb: Compiling with gfortran

A more permanent solution ( perhaps for a future version of Camb?) is to replace the "external iargc" part with

#ifndef GFC
external iargc
#endif
My suggestion would be to use the new standardized intrinsics get_command_argument() and command_argument_count() whenever they are available. As far as I know they are supported by gfortran and recent versions of ifort. Sooner or later they will hopefully replace the nonstantard iargc() and getarg().

Savvas Nesseris
Posts: 70
Joined: April 05 2005
Affiliation: UAM/IFT
Contact:

### Camb: Compiling with gfortran

Yeah, why not?

However, wouldn't this create the same problem for the other compilers that yet do not support these intrinsic functions?

In any case, it's up to Antony to decide!

Ruth Lazkoz
Posts: 14
Joined: January 02 2006
Affiliation: University of the Basque Country

### Camb: Compiling with gfortran

Hi Savvas,

Can you please paste here the lines what you call the "external iargc" part?

I only see "iarg" in the line

if (iargc() /= 0) call getarg(1,InputFile)

which is followed by the line

if (InputFile == '') stop 'No parameter input file'

and I do not know if you mean we comment those out, as I have done that
and then got the kind of errors reported in
http://cosmocoffee.info/viewtopic.php?p ... 683980c397

Ruth

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

### Re: Camb: Compiling with gfortran

The latest version of CAMB has been modified and supports GFortran. Look for gfortran in the Makefile.

Ruth Lazkoz
Posts: 14
Joined: January 02 2006
Affiliation: University of the Basque Country

### Re: Camb: Compiling with gfortran

Antony Lewis wrote:The latest version of CAMB has been modified and supports GFortran. Look for gfortran in the Makefile.
Thanks, indeed, it was there, but it said gfc and and for it to start working
I had to change it to gfortran.

so that I have

F90 = gfortran
FFLAGS = -O2 -ffree-line-length-none $(WMAPFLAGS) INCS = -I. -I$(CFITSIO)/include -I/usr/lib/include
LIBS = -L. -L\$(CFITSIO)/lib -L/usr/lib/lib -llapack -lcfitsio

and I also adapted the path to cfitsio in this Makefile, and the path to "data" in WMAP_5yr_options.F90.

Now, I must be missing something yet, because when I go to the directory
likelihood_v3, and type "make" I get a chain of errors like:

There was a post reporting errors of this sort, but the sender said he solved it by doing the replacement of CAMB, as I sort of describe above.
I do not know if he just replaced and modified the Makefile or did anything
in addition. This did not work for me, probably I did not do the proper thing.