Camb: Compiling with gfortran

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

Camb: Compiling with gfortran

Post by Savvas Nesseris » February 20 2007

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

Post by Martin Reinecke » February 21 2007

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

Post by Savvas Nesseris » February 21 2007

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

Post by Ruth Lazkoz » March 27 2008

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

Thanks in advance,

Ruth

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

Re: Camb: Compiling with gfortran

Post by Antony Lewis » March 27 2008

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

Post by Ruth Lazkoz » March 27 2008

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.

I downloaded the latest version of CAMB and just made it replace the directory camb which came with cosmomc. I modified the Makefile in the likelihood_v3 directory
so that I have

F90 = gfortran
FFLAGS = -O2 -ffree-line-length-none [tex](WMAPFLAGS)
INCS = -I. -I[/tex](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:
/home/ruth/likelihood_v3/read_archive_map.f90:32: undefined reference to `ftgiou_'

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.

Thanks for your patience,

Ruth

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

Camb: Compiling with gfortran [Solved]

Post by Ruth Lazkoz » March 28 2008

I got read of the errors when running make in the likelihood_v3 directory
by installing cfitsio from synaptic and changing the path indications

Post Reply