LensPix segfault

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Jude Bowyer
Posts: 3
Joined: December 07 2007
Affiliation: Imperial College London

LensPix segfault

Post by Jude Bowyer » August 26 2010

Hi everyone,

I'm trying to get LensPix running; after compilation, running ./simlens params.ini yields a segmentation fault. This occurs even when I lower the params.ini nside and lmax to something small and inherently managable, such as nside=16 & lmax=266.
I've since traced the segfault to the HealpixPower_Free subroutine in HealpixObj.f90:

subroutine HealpixPower_Free(P)
Type(HealpixPower) P
integer status
deallocate(P%Cl, stat = status)
deallocate(P%PhiCl, stat = status)
call HealpixPower_Nullify(P)

end subroutine HealpixPower_Free

where the segfault occurs at the first deallocation point, following a call to this subroutine from HealpixPower_ReadFromTextFile in SimLens.f90.

I'm not entirely sure what the problem here is, but it's possible that the makefile I put together is incomplete; I use gfortran instead of ifort and patched together the little I know in order to get the compilation working without fault:

F90C = gfortran
FFLAGS = -cpp -lfmpich -lmpich -ffast-math -DMPIPIX -O4
LAPACKL = -I/usr/include/mpich2 \
-L/home/j/cfitsio/lib \
-L/home/j/Healpix_2.14/lib_F90 \
-I/home/j/Healpix_2.14/include_F90 \
-L/usr/lib \
-lhealpix -lcfitsio -llapack-3 -lblas-3

Anyone got any hints as to where the problem may lie?


Thanks,

Jude

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

Re: LensPix segfault

Post by Antony Lewis » August 30 2010

Some compilers have problems with deallocate(variable, stat = status) when the variable has not been allocated. In the Intel compiler which I use, this is usually OK if compiled without -openmp, but problems when used with -openmp: I often compile the main LensPix/WeightMixer files without -openmp, and then just use -openmp for an additional file that I'm using OMP threading (LensPix itself doesn't use openmp only MPI).

Otherwise you have to tediously put in nullify statements on pointers that might later be caleld in a deallocate before they are allocated. (e.g. HealpixPower_Nullify(P) before P is used anywhere). If you're lucky your compiler may also have a flag to automatically nullify all pointers by default.

Post Reply