CAMB Compilation under Windows 7

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Samuel Hinton
Posts: 2
Joined: February 16 2015
Affiliation: UQ

CAMB Compilation under Windows 7

Post by Samuel Hinton » February 16 2015

Hi guys,

Trying to compile CAMB under windows so that I can create a python wrapper and automate the generation of many different parameterisations of power spectra.

Unfortunately, whilst I can compile fine in Cygwin, I cannot call this version of the program from Python without vast difficulty (currently unsolved difficulty).

As such, I am trying to compile CAMB so that it works in Windows (cmd) and not just cygwin, but am having no luck with any Fortran compiler. When running Make with gfortran, I get the following message:

Code: Select all

C:\camb>make
gfortran -O3 -fopenmp -ffast-math -funroll-loops -c constants.f90
gfortran -O3 -fopenmp -ffast-math -funroll-loops -c utils.F90
gfortran -O3 -fopenmp -ffast-math -funroll-loops -c subroutines.f90
gfortran -O3 -fopenmp -ffast-math -funroll-loops -c inifile.f90
make&#58; Circular modules.o <- .o dependency dropped.
make&#58; Circular modules.o <- .o dependency dropped.
make&#58; Circular modules.o <- .o dependency dropped.
gfortran -O3 -fopenmp -ffast-math -funroll-loops -c modules.f90
modules.f90&#58;30.8&#58;

    use InitialPower
        1
Fatal Error&#58; Can't open module file 'initialpower.mod' for reading at &#40;1&#41;&#58; No such file or directory
make&#58; *** &#91;modules.o&#93; Error 1
Has anyone managed to have a callable installation of CAMB working in Windows 7, or understands the above message?

Cheers

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

Re: CAMB Compilation under Windows 7

Post by Antony Lewis » February 18 2015

Probably some issue with make/makefile, not sure what. Is this the MinGW version? Try compiling power_tilt.f90 manually first or editing the make file to explicitly compile the files in dependency order?

Personally I use Intel Fortran Composer on Windows, which produced binaries that work fine when called from python.

Samuel Hinton
Posts: 2
Joined: February 16 2015
Affiliation: UQ

CAMB Compilation under Windows 7

Post by Samuel Hinton » February 18 2015

Hi Anthony (the man himself!),

You were right in that this was gfortran not compiling in the right order. I spent some time figuring out the right order, had some issues with OpenMP (and so removed it from the options), and finally got it to work!

For any future viewer of this thread, I am using the MinGW version, and throwing the below code into a batch file and running it produced an executable that works directly in cmd.

Code: Select all

call gfortran -O3 -ffast-math -funroll-loops -c constants.f90
call gfortran -O3 -ffast-math -funroll-loops -c utils.F90
call gfortran -O3 -ffast-math -funroll-loops -c subroutines.f90
call gfortran -O3 -ffast-math -funroll-loops -c inifile.f90
call gfortran -O3 -ffast-math -funroll-loops -c power_tilt.f90
call gfortran -O3 -ffast-math -funroll-loops -c recfast.f90
call gfortran -O3 -ffast-math -funroll-loops -c reionization.f90
call gfortran -O3 -ffast-math -funroll-loops -c modules.f90
call gfortran -O3 -ffast-math -funroll-loops -c bessels.f90
call gfortran -O3 -ffast-math -funroll-loops -c equations.f90
call gfortran -O3 -ffast-math -funroll-loops -c halofit_ppf.f90
call gfortran -O3 -ffast-math -funroll-loops -c lensing.f90
call gfortran -O3 -ffast-math -funroll-loops -c SeparableBispectrum.F90
call gfortran -O3 -ffast-math -funroll-loops -c cmbmain.f90
call gfortran -O3 -ffast-math -funroll-loops -c camb.f90
call gfortran -O3 -ffast-math -funroll-loops constants.o utils.o  subroutines.o inifile.o power_tilt.o recfast.o reionization.o modules.o bessels.o equations.o halofit_ppf.o lensing.o SeparableBispectrum.o cmbmain.o camb.o inidriver.F90 -lstdc++ -o camb
For those still unable to compile on Windows for another reason, I recommend installing Cygwin and compiling with that. You can then invoke camb (minus any changing of directories) with

Code: Select all

C&#58;\cygwin64\bash.exe --login -c "cd /cygdrive/c/camb && ./camb.exe params.ini"
where the cd is required because of the way camb searches for the HighLExtrapTemplate_lenspotentialCls.dat file.

Thanks for the tip Anthony, and I hope this comes in use for others.

Post Reply