Page 1 of 1

Camb: Compiling with gfortran

Posted: February 20 2007
by Savvas Nesseris
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

Camb: Compiling with gfortran

Posted: February 21 2007
by Martin Reinecke
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().

Camb: Compiling with gfortran

Posted: February 21 2007
by Savvas Nesseris
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!

Camb: Compiling with gfortran

Posted: March 27 2008
by Ruth Lazkoz
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

Re: Camb: Compiling with gfortran

Posted: March 27 2008
by Antony Lewis
The latest version of CAMB has been modified and supports GFortran. Look for gfortran in the Makefile.

Re: Camb: Compiling with gfortran

Posted: March 27 2008
by Ruth Lazkoz
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

Camb: Compiling with gfortran [Solved]

Posted: March 28 2008
by Ruth Lazkoz
I got read of the errors when running make in the likelihood_v3 directory
by installing cfitsio from synaptic and changing the path indications