HEALPIX: Problem calling a pix_tools.f90 subroutine

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Carlos L.A.
Posts: 13
Joined: January 17 2008
Affiliation: ICE

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Carlos L.A. » March 12 2009

Hi!
I have a problem when I try to call a subroutine from the healpix module pix_tools.
This is my code:


program test
use pix_tools
IMPLICIT NONE
DOUBLE PRECISION theta,phi
integer nside,ipix

nside=2048
theta=0.4543
phi=1.76574
call ang2pix_ring(nside,theta,phi,ipix)
write(*,*) 'pixel=', ipix

end program


and this is the error I get when compiling with gfortran:

/tmp/cce47W0b.o: In function `MAIN__':
test.f90:(.text+0x50): undefined reference to `__pix_tools__ang2pix_ring'
collect2: ld returned 1 exit status


Anyone can tell me where the problem could be.

Thanks

Pascal Vaudrevange
Posts: 50
Joined: March 26 2006
Affiliation: DESY
Contact:

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Pascal Vaudrevange » March 14 2009

Hi Carlos,

it sounds like the linking stage failed. You need to specify the path to both the include directory of healpix and the lib directory, as well as adding the compiler switches -lhealpix -lfftw -lgif -lcfitisio (you probably also need cfitsio.)
A sample compiler command would be (assuming gfortran is your compiler)

Code: Select all

 gfortran -O test.f90 -L/home/carlos/healpix/lib -I/home/carlos/healpix/include -L/home/carlos/cfitsio -lhealpix -lfftw -lgif -lcfitsio -o ./test_program
where you need to adjust the part "/home/carlos/healpix" to wherever healpix is installed on your machine and "/home/carlos/cfitsio" to wherever cfitsio is installed.

Pascal

Carlos L.A.
Posts: 13
Joined: January 17 2008
Affiliation: ICE

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Carlos L.A. » March 16 2009

Thank you very much Pascal,

I've tried your solution and it works, but just partially. This is how I compiled:

Code: Select all

gfortran -O test.f90 -L/home/hati/lopez/Healpix/Healpix_2.01/lib -I/home/hati/lopez/Healpix/Healpix_2.01/include -L/home/hati/lopez/Healpix/cfitsio -lhealpix -lfftw3 -lgif -lcfitsio -o ./test_program
And this is the error I get:

Code: Select all

 /home/hati/lopez/Healpix/Healpix_2.01/lib/libhealpix.a(misc_utils.o): In function `__misc_utils__strupcase':
misc_utils.f90:(.text+0xb3a): undefined reference to `_gfortran_copy_string'
/home/hati/lopez/Healpix/Healpix_2.01/lib/libhealpix.a(misc_utils.o): In function `__misc_utils__strlowcase':
misc_utils.f90:(.text+0xbba): undefined reference to `_gfortran_copy_string'
/home/hati/lopez/Healpix/Healpix_2.01/lib/libhealpix.a(extension.o): In function `__extension__getenvironment':
extension.F90:(.text+0xa7): undefined reference to `_gfortran_copy_string'
collect2: ld returned 1 exit status
I have these two object files (misc_utils.o and extension.o), but I don't know the origin of this "undefined reference".
Do I need to link more libraries?

Carlos

Pascal Vaudrevange
Posts: 50
Joined: March 26 2006
Affiliation: DESY
Contact:

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Pascal Vaudrevange » March 17 2009

Hi Carlos,

a quick google search reveals that it seems like the undefined references that you get are coming from an inconsistency between the version of the gcc-compiler you use and the system libraries that are installed:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33647

You should probably reinstall gcc

Pascal

Carlos L.A.
Posts: 13
Joined: January 17 2008
Affiliation: ICE

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Carlos L.A. » March 19 2009

Thanks again Pascal,

but this problem seems to have no end...
I've updated gfortran and now I'm using version 4.3.3 (4.2.4 was the one giving me the "undefined reference" error).

This is how I am compiling

Code: Select all

gfortran -O test.f90 -L/home/hati/lopez/Healpix/Healpix_2.01/lib -I/home/hati/lopez/Healpix/Healpix_2.01/include -L/home/hati/lopez/Healpix/cfitsio -lhealpix -lfftw3 -lgif -lcfitsio -o ./test_program
and this is the new error message:

Code: Select all

Fatal Error: Reading module pix_tools at line 19 column 31: Expected string
I don't see nothing wrong or strange at this line and column.
Any ideas?

Thanks.

Carlos

Pascal Vaudrevange
Posts: 50
Joined: March 26 2006
Affiliation: DESY
Contact:

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Pascal Vaudrevange » March 19 2009

Hi Carlos,

did you recompile Healpix with the updated gcc?

Pascal

Carlos L.A.
Posts: 13
Joined: January 17 2008
Affiliation: ICE

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Carlos L.A. » March 20 2009

I have recompiled Healpix with the new version of gcc but the problem is still there:

Code: Select all

gfortran -O test.f90 -L/usr/local/Healpix_2.11_gfortran_4.3.3/lib_gf_4.3.3 -I/usr/local/Healpix_2.11_gfortran_4.3.3/include_gfortran_4.3.3 -L/home/hati/lopez/Healpix/cfitsio -lhealpix -lfftw3 -lgif -lcfitsio -o ./test_program
Fatal Error: Reading module pix_tools at line 19 column 31: Expected string
I guess this is a bad sign, isn't it?

Carlos

Pascal Vaudrevange
Posts: 50
Joined: March 26 2006
Affiliation: DESY
Contact:

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Pascal Vaudrevange » March 21 2009

Hi Carlos,

are you sure that you ran a "make clean; make" in both the cfitsio and the Healpix directory after you upgraded the compiler? If so, then I am slowly running out of ideas.. Maybe there is an old copy of the healpix modules lying around somewhere in your LD_LIBRARY_PATH or maybe even in /usr/lib or such?

Pascal

Savvas Nesseris
Posts: 70
Joined: April 05 2005
Affiliation: UAM/IFT
Contact:

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Savvas Nesseris » March 21 2009

Have you tried another f90 compiler? I would recommend g95 as I've successfully compiled Healpix with it in the past. In any case this will probably let you know if it's a compiler issue or not.

Carlos L.A.
Posts: 13
Joined: January 17 2008
Affiliation: ICE

HEALPIX: Problem calling a pix_tools.f90 subroutine

Post by Carlos L.A. » March 30 2009

Thank you Pascal and Savas!!

Finally I managed to compile the program.
After trying to compile with ifort, also without success, I looked carefully for any healpix *.mod in my paths. And there it was, an old version of pix_tools.mod !!

After removing it all the problems disappeared.

Thank you again for all your help!!

Problem Solved!!

Post Reply