PolyChord / PolyChordLite

Public version of PolyChord: See polychord.co.uk for PolyChordPro
https://polychord.io/
Other
83 stars 26 forks source link

Negative chi-square values and crazy weights in output file #40

Closed qminor closed 2 years ago

qminor commented 4 years ago

After installing PolyChord on a new system and linking to my C++ code, I get a very peculiar error when I do a PolyChord run: it outputs negative chi-square values (in the file "

qminor commented 4 years ago

I should mention that I compiled with Intel vs. 15.0.3. Is it possible this is a version-specific problem? The other system I installed it on used Intel version 17.0.2 and didn't have this problem.

qminor commented 4 years ago

After playing with it, it seems that the basic problem is that the dead points stored in RTI%dead get rewritten, often so the values are just zero, or some small or negative number. When a live point replacement occurs, a reasonable value is stored for the next entry of RTI%dead; but when the dead points get written to a file, often all the dead points have crazy values except for the last point which was just stored duing a point replacement. Do you have any idea what might be causing this problem? I have a feeling it might be related to the compiler being old--I'm using Intel Fortran version 15.

qminor commented 4 years ago

Since I'm not really a Fortran programmer, it took me an entire day to pinpoint the problem and fix it. The reason is because the Intel fortran version 15 does not automatically allocate arrays designated as allocatable with (:), which is a Fortran 2003 feature. This problem occurred in array_utils.f90, and I had to use allocate(...) to allocate them all, and then it worked fine. Then I discovered that, instead of altering the code, all I had to do was add the option -assume realloc_lhs when compiling and then everything works just fine. It might be worth it to add this option in the Makefile_intel just in case anyone else happens to be using an older version of Intel fortran.

williamjameshandley commented 4 years ago

Hi @qminor.

In, general in my experience all of these kind of things should be fixable with compiler options, rather than code modifications. Fortran generally defaults to some of the earliest defaults (e.g. limits on line length, requirements for initialisation etc). Feel free to submit a pull request with additional compiler arguments in the Makefile_intel that makes this work on your system, and the automated tests should check whether or not this breaks the default install. (I can also check locally on my machines with regards to changes in the intel compiler options.

williamjameshandley commented 2 years ago

Fixed by #73