intel f90 and fit()


vinter
04-28-2005, 04:26 AM
Hey,

I wanted to use the fit routine to make a simle fit to a straight line using the Fortran 90 routine provided with NR. I have installed the Intel 90 compiler on my Linux system, and creating the object files goes fine:

[vinter@zuma minimal]$ foreach f ( nrtype.f90 nrutil.f90 nr.f90 main.f90 fit.f90)
foreach? ifort -c $f
foreach? end
[vinter@zuma minimal]$ls -lrt
[SNIP]
-rw-r--r-- 1 vinter users 82482 Apr 28 10:16 nr.f90
-rw-r--r-- 1 vinter users 430 Apr 28 11:12 main.f90
-rw-r--r-- 1 vinter users 42503 Apr 28 11:12 nrutil.o
-rw-r--r-- 1 vinter users 53449 Apr 28 11:12 nrutil.mod
-rw-r--r-- 1 vinter users 723 Apr 28 11:12 nrtype.o
-rw-r--r-- 1 vinter users 3767 Apr 28 11:12 nrtype.mod
-rw-r--r-- 1 vinter users 1035 Apr 28 11:12 things.o
-rw-r--r-- 1 vinter users 715 Apr 28 11:12 nr.o
-rw-r--r-- 1 vinter users 235964 Apr 28 11:12 nr.mod
-rw-r--r-- 1 vinter users 1434 Apr 28 11:12 main.o
-rw-r--r-- 1 vinter users 3089 Apr 28 11:12 fit.o

main.f90 is just doing a "Hello Word" and not even calling fit(). But when I try to link them, I am punnished! First, as it hints in the beginning of NR F90 without linking nrtype.o and nrutil.o

[vinter@zuma minimal]$ ifort nr.o fit.o main.o -o minimal.x
fit.o(.text+0x75): In function `fit_':
: undefined reference to `nrutil_mp_assert_eq3_'
fit.o(.text+0x52a): In function `fit_':
: undefined reference to `gammq_s_'
fit.o(.text+0x614): In function `fit_':
: undefined reference to `nrutil_mp_assert_eq2_'
[vinter@zuma minimal]$
and then with including the two:
[vinter@zuma minimal]$ ifort nrtype.o nrutil.o nr.o fit.o main.o -o minimal.x
fit.o(.text+0x52a): In function `fit_':
: undefined reference to `gammq_s_'
[vinter@zuma minimal]$

Can anyone please give a hint: Howcome it is not finding the gammq_s function as defined in nr.f90? Is it an incompability with the compiler or is me doing something stupid? I have previoiusly sucsessfully used the compiler for all sorts of stuff, so it should be installed correctly.

Thanks in advance!

Saul Teukolsky
04-28-2005, 08:35 PM
Hi,

You also need to compile and link in gammq.f90, which is called by fit.

Saul Teukolsky

vinter
04-29-2005, 02:40 AM
Originally posted by Saul Teukolsky
You also need to compile and link in gammq.f90, which is called by fit.

Cheers! That was too easy. Thanks a for your fast answer.

EDIT: And after also compiling and linking all the other functions needed (like gcf gammln and more), it works sweet.