Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling external subroutines

Status
Not open for further replies.

badlydrawn

Programmer
May 2, 2005
3
SE
Hi!
I am totally new to Fortran and I have a problem. I need to call a subroutine called rs in a file rs.f from my program. The program is written in f95. I don't think rs is part of a module, at least it doesn't say so anywhere. Thanks!
 
In your calling routine
Code:
! Where the declarations are
external rs
...
! somewhere in the program
call rs
 
Thanks for your help but it still doesn't work. I get an error saying "call to missing routine". This is my (shortened) main program:

PROGRAM Main

IMPLICIT NONE

external rs
character(255)::fileName
integer::m,n
real, DIMENSION(26,26)::denseMatrix
integer::eek:penStatus
integer::inputStatus
integer::tempPositionA, tempPositionB
real::tempValue
real, DIMENSION(26)::eigenValues

.
.
.
.

call rs(m,n,denseMatrix,eigenValues,0)

END PROGRAM Main


And this is the file rs.f:

subroutine rs(nm,n,a,w,matz,z,fv1,fv2,ierr)
c
integer n,nm,ierr,matz
double precision a(nm,n),w(n),z(nm,n),fv1(n),fv2(n)
c
c this subroutine calls the recommended sequence of
c subroutines from the eigensystem subroutine package (eispack)
c to find the eigenvalues and eigenvectors (if desired)
c of a real symmetric matrix.
c
c on input
c
c nm must be set to the row dimension of the two-dimensional
c array parameters as declared in the calling program
c dimension statement.
c
c n is the order of the matrix a.
c
c a contains the real symmetric matrix.
c
c matz is an integer variable set equal to zero if
c only eigenvalues are desired. otherwise it is set to
c any non-zero integer for both eigenvalues and eigenvectors.
c
c on output
c
c w contains the eigenvalues in ascending order.
c
c z contains the eigenvectors if matz is not zero.
c
c ierr is an integer output variable set equal to an error
c completion code described in the documentation for tqlrat
c and tql2. the normal completion code is zero.
c
c fv1 and fv2 are temporary storage arrays.
c
c questions and comments should be directed to burton s. garbow,
c mathematics and computer science div, argonne national laboratory
c
c this version dated august 1983.
c
c ------------------------------------------------------------------
c
if (n .le. nm) go to 10
ierr = 10 * n
go to 50
c
10 if (matz .ne. 0) go to 20
c .......... find eigenvalues only ..........
call tred1(nm,n,a,w,fv1,fv2)
* tqlrat encounters catastrophic underflow on the Vax
* call tqlrat(n,w,fv2,ierr)
call tql1(n,w,fv1,ierr)
go to 50
c .......... find both eigenvalues and eigenvectors ..........
20 call tred2(nm,n,a,w,fv1,z)
call tql2(nm,n,w,fv1,z,ierr)
50 return
end



Any help would be greatly appreciated!
 
How are you linking it? Say you are using the g95 compiler. Your compile/link line will read something like
Code:
g95 rstest.f rs.f -o rstest
If you just build rstest.f, it won't know where to find rs. However, it is not a compiler problem - the compiler just translates code so that it can be linked. The linker links all the bits together. Compilers like g95 will also do the linking for you.
 
That seems to be the problem yes! Thanks for your time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top