本人使用 CentOS 7 系统。CAMB 的 python 版本需要 gfortran
的版本高于 4.9,而本人系统 gfortran 版本为 4.8。
$ gfortran --version
GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28)
Copyright (C) 2015 Free Software Foundation, Inc.
...
在编译安装 pycamb 时会出现错误。
第一次处理
直接在 setup.py
中修改 gfortran_min
参数 为 gfortran_min = '4.8'
。由于版本不吻合,编译会出现错误。
成功的一次
本人电脑上安装了 ifort
,所与,最简单的办法是使用 ifort
。
做两个修改,
- 让其判断
gfortran
版本通过。
# gfortran_min = '4.9' # change to 4.8
gfortran_min = '4.8'
- 修改编译器
COMPILER=gfortran
改为COMPILER=ifort
# COMPILER=gfortran
#subprocess.call("make camblib.so COMPILER=gfortran PYCAMB_OUTPUT_DIR=%s/camb/" % pycamb_path, shell=True)
subprocess.call("make camblib.so COMPILER=ifort PYCAMB_OUTPUT_DIR=%s/camb/" % pycamb_path, shell=True)
安装
python setup.py install --user
测试是否成功
打开 python 或者 ipython 或者 jupyter notebook
>>> import camb
>>> help(camb)
Help on package camb:
NAME
camb - Python CAMB interface (http://camb.info)
FILE
/home/ekli/opt/camb/pycamb/camb/__init__.py
PACKAGE CONTENTS
baseconfig
bbn
bispectrum
camb
camblib
constants
correlations
initialpower
lensing
model
nonlinear
postborn
recombination
reionization
DATA
DoTensorNeutrinos = c_bool(True)
Magnetic = c_double(0.0)
ThreadNum = c_int(0)
__author__ = 'Antony Lewis'
__contact__ = 'antony at cosmologist dot info'
__status__ = 'beta'
__version__ = '0.1.6.2'
vec_sig0 = c_double(1.0)
VERSION
0.1.6.2
AUTHOR
Antony Lewis