Cosmomc: Bug in "subroutine ParamNames_ReadIndices(Names,InLine, params, num)" in ParamNames.f90

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Francesco Montesano
Posts: 11
Joined: June 14 2012
Affiliation: MPE, Garching, Germany

Cosmomc: Bug in \"subroutine ParamNames_ReadIndices(Nam

Post by Francesco Montesano » June 14 2012

Dear all,

I encounter a bug in "subroutine ParamNames_ReadIndices(Names,InLine, params, num)" in ParamNames.f90

at line 179

Code: Select all

do while &#40;pos < len .and. InLine&#40;pos&#58;pos&#41;==' '&#41; 
  pos = pos+1
end do 
must be substitute, as in other subroutines of the module, with

Code: Select all

do while &#40;pos < len .and. IsWhiteSpace&#40;InLine&#40;pos&#58;pos&#41;&#41; &#41; 
  pos = pos+1
end do 
in order to deal with white spaces and tabs.

In the first way tab spaces are not skiped, which can cause the truncation of parameter names longer than the tab and the error
ParamNames: Unknown parameter name ****
MpiStop: 0
The second way seems to fix this issue.


Cheers,
Francesco

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

Re: Cosmomc: Bug in \\\"subroutine ParamNames_ReadIndic

Post by Antony Lewis » June 14 2012

Can you give an example? (parameter names can't have tabs in?)

Francesco Montesano
Posts: 11
Joined: June 14 2012
Affiliation: MPE, Garching, Germany

Cosmomc: Bug in \"subroutine ParamNames_ReadIndices(Nam

Post by Francesco Montesano » June 15 2012

Dear Antony,

my parameter file name is params_franz.paramnames
All the white spaces are tabs.

The error that I as getting was
ParamNames: Unknown parameter name 000_sz
MpiStop: 0
After finding the origin of the problem was in "ParamNames_ReadIndices(Names,InLine, params, num)",
I've noticed that some of the parameters where showing up twice after
"read(InLine(pos:), *, end=400, err=400) part" at line 182.
The first time with leading spaces, the second time with the name at the beginning of the string.
This happened for one of the kstar1, r and d3000_sz.
For the latter "read(InLine(pos:), *, end=400, err=400) part" was returning part = [6 spaces]d3000_sz[lot of spaces]. Then the 'pos' is increased by 8 in the next loop 'part' is '000_sz', which is not a parameter.

Finally I saw that in "function ParamNames_ParseLine(Names,InLine,n) result(res)" (line 26) InLine is parsed similarly, but the lines where the white spaces are ignored are
do while (pos < len .and. IsWhiteSpace(InLIne(pos:pos)))
Substituting InLine(pos:pos)==' ' with IsWhiteSpace(InLIne(pos:pos)) solved the problem.

Cheers,
Francesco

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

Re: Cosmomc: Bug in \\\"subroutine ParamNames_ReadIndic

Post by Antony Lewis » June 15 2012

Thanks you.

Post Reply