debug errors (technique) in CAMB

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Ding-fang Zeng
Posts: 4
Joined: December 29 2016
Affiliation: Beijing University of Technology

debug errors (technique) in CAMB

Post by Ding-fang Zeng » December 31 2016

Dear All CAMBgurus,

I am a primary user of CAMB, I wish to follow the program's running line by line. My software environment is MacOSX10.10+gfortran5.2. I changed two lines of the Makefile as follows

DEBUGFLAGS = -O3 -fopenmp -ffast-math -fmax-errors=4
FFLAGS = -g -cpp -fbounds-check -fbacktrace -ffree-line-length-none -fmax-errors=4 -ffpe-trap=invalid,overflow,zero

so that I can use lldb of MacOSX-gfortran to debug the program. Now I encounter he problem of not being able to view the value of variables in the original program. An example of my debug outout is as follows

error: camb {0x00007b68}: unhandled type tag 0x0012
(DW_TAG_string_type), please file a bug and attach the file at the start of this
error message
Process 6753 stopped
* thread #1: tid = 0xe9ef, 0x000000010010aa4b camb`driver + 1724 at
inidriver.F90:107, queue = 'com.apple.main-thread', stop reason = step over
frame #0: 0x000000010010aa4b camb`driver + 1724 at inidriver.F90:107
104 call DarkEnergy_ReadParams(DefIni)
105
106 P%h0 = Ini_Read_Double('hubble')
-> 107 tempvar = P%h0
108
109 if (Ini_Read_Logical('use_physical',.false.)) then
110 P%omegab = Ini_Read_Double('ombh2')/(P%H0/100)**2
(lldb) print P%h0
error: warning: got name from symbols: P
error: use of undeclared identifier 'h0'
error: 1 errors parsing expression
(lldb) print tempvar
(double) $1 = 4.9865057503465331E-318
(lldb)

I want to view what's the value of P%h0, but I cannot do that directly. I have to declare local variable tempvar in advances. This is too too too troublesome for my further debugging of the system.

Can any CAMBguru gives me a hints to solve this question? Thank you very much!

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

Re: debug errors (technique) in CAMB

Post by Antony Lewis » January 02 2017

I would recommend the Intel Fortran compilers for debugging (I use Visual Fortran for Windows), the gfortran debugger's support for F90 and higher seems to be not very good. The CodeBlocks ide does have some integrated support (e.g. try CosmoBox), but still using gdb. The RedHat distribution may have integrated more of Intel's open-sources changes for F2003 compatibility, but I've not tried it.

Otherwise you can just put print statements in the compiled code (but that gets painful after a while..)

Ding-fang Zeng
Posts: 4
Joined: December 29 2016
Affiliation: Beijing University of Technology

debug errors (technique) in CAMB

Post by Ding-fang Zeng » January 03 2017

thank Antony very much!

Post Reply