LAPACK for Fortran under Cygwin

In summary, the conversation discusses the installation and use of LAPACK and the issue of the compiler not recognizing the routines. The individual also shares a simple Fortran program they wrote to test a routine, but it fails to compile. They then ask about including an "include" or "use" statement in their code file and eventually find a solution by specifying a linker flag.
  • #1
Bill Foster
338
0
I just installed LAPACK, but I'm not sure how to use it. The documentation tells about the routines, but the problem is my compiler isn't recognizing them.

For example...I wrote a simple Fortran program to test a routine (SGESV):

Code:
      program testlapack
          implicit  none

          integer N
          parameter(N=10)
          integer NRHS
          parameter(NRHS=1)
          integer LDA
          parameter(LDA=10)
          integer IPIV(N)
          integer LDB
          parameter(LDB=N)
          real A(LDA,N)
          real B(LDB,NRHS)
          integer INFO
          external SGESV

          call SGESV(N,NRHS,A,LDA,IPIV,B,LDB,INFO)

       end

Then I compile in and it fails...

Code:
$ g77 -ff90 -o test test.for 
/cygdrive/c/Users/david/AppData/Local/Temp/ccU0lt1W.o:test.for:(.text+0x4e): undefined reference to `_sgesv_'
collect2: ld returned 1 exit status

Is there something line an "include" or "use" statement that I have to include in my code file so the compiler will recognize these LAPACK routines?

Thanks.
 
Physics news on Phys.org
  • #2
I seem to have found a solution by specifying a linker flag:

Code:
$ g77 -ff90 -o test test.for -llapack
 
  • #3
Yup, that's how you link to a library.
 

1. What is LAPACK for Fortran under Cygwin?

LAPACK (Linear Algebra Package) is a collection of Fortran subroutines designed for solving linear algebra problems, such as solving systems of linear equations, least squares problems, and eigenvalue problems. It is commonly used in scientific computing and is optimized for high-performance computing. Cygwin is a compatibility layer that allows Unix-based software to run on Windows operating systems, including Fortran and LAPACK.

2. How do I install LAPACK for Fortran under Cygwin?

To install LAPACK for Fortran under Cygwin, you will need to download and install the Cygwin software first. Then, you can use the Cygwin package manager to search for and install the necessary LAPACK packages. Alternatively, you can manually download the LAPACK source code and compile it using the Cygwin compiler.

3. Can LAPACK for Fortran under Cygwin be used with other programming languages?

Yes, LAPACK can be used with other programming languages such as C, C++, and Python. However, you will need to use appropriate language bindings or interfaces to call the LAPACK subroutines from these languages. For example, the numpy package in Python provides an interface to call LAPACK functions.

4. What are the advantages of using LAPACK for Fortran under Cygwin?

The advantages of using LAPACK for Fortran under Cygwin include its high performance, accuracy, and reliability. LAPACK is optimized for high-performance computing and can efficiently solve large-scale linear algebra problems. It also has a long history of development and is widely used and tested, making it a reliable choice for scientific computing applications.

5. Are there any alternatives to LAPACK for Fortran under Cygwin?

Yes, there are several alternatives to LAPACK for Fortran under Cygwin, such as BLAS (Basic Linear Algebra Subprograms), ATLAS (Automatically Tuned Linear Algebra Software), and Intel MKL (Math Kernel Library). These libraries also provide efficient linear algebra routines and can be used with Cygwin. However, LAPACK is still considered the standard for linear algebra computations in the scientific computing community.

Similar threads

  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
4
Views
6K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
8K
  • Programming and Computer Science
Replies
18
Views
6K
  • Programming and Computer Science
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
9K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
2K
Back
Top