Vasilis
Vasilis

Reputation: 11

undefined reference to 'tridag_'

I'm working on a computational project for a class at university and I've come across the following error message:

<undefined reference to 'tridag_'> 

when trying to call the tridag subroutine to solve a tridiagonal linear set of equations. Isn't the tridag subroutine included in fortran's library? I'm using code blocks with the gnu fortran compiler. Here's the program:

double precision t0, tc, rc, dt, dx, al, time, alpha
double precision, allocatable :: tmp(:), tmpnew(:), aw(:), ap(:), ae(:), su(:), x(:)
open (1,file='input.txt'); open (2,file='output.txt')
read (1,*) ni, nt
read (1,*) t0, tc, dt, al, alpha
allocate (tmp(ni), tmpnew(ni), aw(ni), ap(ni), ae(ni), su(ni), x(ni))
dx = al/float(ni-1)
do i=1,ni
    x(i)=(i-1)*dx
end do
rc=alpha*dt/dx**2
!ΑΡΧΙΚΗ ΣΥΝΘΗΚΗ
tmp=t0
do it=1,nt
    time=(it-1)*dt
    ap(1)=1; ae(1)=-1; su(1)=0
    ap(ni)=1; aw(ni)=0; su(ni)=tc
    do i=2,ni-1
        ap(i)=-(1+2*rc); ae(i)=rc; aw(i)=rc; su(i)=-tmp(i)
    end do
    call tridag (aw, ap, ae, su, tmpnew, ni)
    do i=1,ni
        tmp(i)=tmpnew(i)
        write(2,*) x(i),tmp(i)
    end do
end do

Thanks in advance.

Upvotes: 1

Views: 85

Answers (1)

tridag() is not a Fortran intrinsic subroutine, it comes from an external library. You must get this library, compile the subroutine and link it with your code.

As far a I know TRIDAG comes from the Numerical Recipes book so be aware it is commercially licensed. If you get the book and the associated source code, you can use it according to the book's license. You can certainly also find the code on the internet (just use your favourite search engine to search for "TRIDAG Fortran subroutine"), but the license still applies.

Also note that there are many other tridiagonal matrix solvers available, but this site is not for locating or recommending external software libraries.

Upvotes: 1

Related Questions