How to Use LAPACK and arpack in Windows

Source: Internet
Author: User
Tags lapack gfortran

I recently plan to learn how to write fortran programs and use LAPACK and arpack. In the school's Linux, A make command is done. However, my computer is a Windows 7 system. I have tried cmake and nmake, and none of them can make. There are also a lot of information on how to use LAPACK in windows on the Internet, and some of them directly give me a compiled LAPACK. lib, the result shows that it cannot be connected on gfortran; some want to change makefile or something, I think they are all written to the experts. So from the day before yesterday, I had a weekend at home and finally got it done. I wrote a summary and made a memo here. I hope people like me will get help.

1. Install FORTRAN
I need a FORTRAN compiler that can be used in windows. The reason why I don't like Compaq FORTRAN is that it is a program that has been debugged and often cannot be passed on gfortran of the school. Besides, its editor does not have code folding, which is very uncomfortable. In addition, it is too expensive to afford. I recommend the simply Fortran Editor, which is small and simple and comes with a gfortran Compiler (simply Fortran Installer: simplyfortran-1.9-setup.exe ),
The registration fee is USD 25. After simply FORTRAN is installed, the GNU Compiler GCC and
Gfortran and a bunch of other useful tools, which will be used below. Of course, if you only want the compiler can directly install gfortran (Installer: gfortran-windows-20110214.exe), after the installation of the compiler in gfortran \ bin.

Ii. LAPACK library Compilation
Next, I want to get LAPACK up. So I downloaded the latest version (lapack-3.3.0.tgz) on netlib and decompressed it. Because I don't have a Blas library, I want to compile BLAS and LAPACK into a library and then use it together. The procedure is as follows:
1.
Open the extract folder, put all *. f files in lapack-3.3.0 \ Blas \ SRC and
The dlamch. F and slamch. f files in lapack-3.3.0 \ install are copied to the lapack-3.3.0 \ SRC
Folder. The system prompts that two files are duplicated during replication. I chose not to overwrite them. In this way, the source files of the BLAs and LAPACK libraries are all together.
2. Then, run cmd to go to DoS and check whether there is mingw \ bin (or gfortran \ bin) in the path ).
E: lapack-3.3.0> path
Path = D: \ Program Files \ simply Fortran \ fwin \ mingw \ bin ;......
If simply FORTRAN is correctly installed, mingw \ bin should be automatically added to the search path. If not, add it manually.
E: \ lapack-3.3.0> Path = D: \ Program Files \ simply Fortran \ fwin \ mingw \ bin; % PATH %
Modify the installation directory of simply Fortran as needed.
3. Dos enters the lapack-3.3.0 \ src directory and starts compiling with gfortran
E: \ lapack-3.3.0> Cd SRC
E: \ lapack-3.3.0 \ SRC> gfortran-fimplicit-None-g-C *. F-O2
(Wait for more than 10 minutes. The. o file is continuously popped up in the SRC folder in windows)
Then the following files need to be re-compiled without Optimization
E: \ lapack-3.3.0 \ SRC> gfortran-fimplicit-None-g-C slaruv. F-O0
E: \ lapack-3.3.0 \ SRC> gfortran-fimplicit-None-g-C dlaruv. F-O0
E: \ lapack-3.3.0 \ SRC> gfortran-fimplicit-None-g-C sla_wwaddw.f-O0
E: \ lapack-3.3.0 \ SRC> gfortran-fimplicit-None-g-C dla_wwaddw.f-O0
E: \ lapack-3.3.0 \ SRC> gfortran-fimplicit-None-g-C cla_wwaddw.f-O0
E: \ lapack-3.3.0 \ SRC> gfortran-fimplicit-None-g-C zla_wwaddw.f-O0
I am executing one row and one line ......
4. Use ar to connect to a database
E: \ lapack-3.3.0 \ SRC> ar RC liblapack. A *. o
In this way, the LAPACK library file liblapack. A is obtained in the SRC folder.

Iii. arpack library Compilation
Go to the official arpack website to download the package. I chose to download arpack96.tar.gz and the patch patch.tar.gz.
1. decompress the two compressed files separately. The first step is to install the patch first. Copy the arpack under the patch and paste it into arpack96 to overwrite the file with the same name. A message will be displayed on win7 to merge the folder. Select "yes", and a message will be displayed to copy and replace the file. Just select "replace all.
2.
Set arpack96 \ arpack \ Blas, arpack96 \ arpack \ LAPACK, and arpack96 \ arpack \ util
* All. f files are copied to arpack96 \ arpack \ SRC. Three source files need to be modified. First, find second. f
Open and change the content:
Subroutine second (t)
Real t
Call cpu_time (t)
Return
End
Warranty
Save. Because the original program calls etime to return the time, but an error occurs during connection and the etime cannot be found. I have read that it seems that cpu_time is used in gfortran.
So we can change it. In addition, dnrm2.f and snrm2.f use assign Statement, which is in Fortran 95.
Therefore, gfortran cannot compile these two files. Therefore, you need to download the updated versions dnrm2.f and snrm2.f from netlib and replace the old files.
3. The basic principles for compiling arpack and LAPACK are similar. Use DOS to enter the arpack96 \ arpack \ src directory and start compiling with gfortran:
E: \ arpack96 \ arpack \ SRC> gfortran-fimplicit-None-g-C *. F-O2
4. Use ar to connect to a database
E: \ arpack96 \ arpack \ SRC> ar RCS libarpack. A *. o
In this way, the arpack library file libarpack. A is obtained in the SRC folder.

Iv. Use of LAPACK
If gfortran is used for direct compilation, there are two options. First, copy liblapack. A and libarpack. A to the directory of the program source file, and then compile
Gfortran Foo. f90 liblapack. A libarpack.
The second method is to copy liblapack. A and libarpack. A to \ Lib in the directory where gfortran is located, and then add the-llapack or-larpack flag to compile later.
Gfortran Foo. f90-llapack-larpack
This is the same as in Linux.

In simply
If it is used in FORTRAN, make sure that liblapack. A and libarpack. A have been copied to mingw \ Lib.
And then open project options from the Options menu, and add-llapack or
-Larpack is enough, but set project flags for each project. Be sure to use simply of version 1.11 or later.
FORTRAN, the old version of Project flags has a bug.

 

[Transfer] http://www.douban.com/note/132392388/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.