Compile shtools in Ubuntu

Source: Internet
Author: User
Tags lapack gfortran
Shtools is an open-source library written in FORTRAN that is specifically used to process ball harmonic functions. For more information, see here, all of them are described in detail on the official website. Although they are very detailed, they are still difficult to compile. Next I will record the compilation steps under Ubuntu.

First, shtools depends on three libraries: fftw, Blas, and LAPACK. The fftw library is a database of Fourier transformation. It can only be explained with a very strong sentence. Some time ago, I wrote an image's Fourier transformation and processed an image (12208 × 12208) it takes more than five minutes to restore the 16-bit but band image, and then replace the Fourier Transform code in the MTF with the fftw library. The processing time is only 50 seconds, in short, a sentence is very powerful (in MATLAB, Fourier transformation is also used in this library ). The remaining BLAS and LAPACK are linear algebra libraries written in FORTRAN.

1. download the required libraries. There are four libraries in total, one of which is shtools, and the other three are dependent on shtools. They are:

Name

Shtools

Http://www.ipgp.fr /~ Wieczor/shtools2.8.tar. Z

Fftw3

Http://www.fftw.org/fftw-3.3.3.tar.gz

Blas

Http://www.netlib.org/blas/blas.tgz

LAPACK

Http://www.netlib.org/lapack/lapack-3.4.2.tgz

After downloading the above four packages, put them in a directory and decompress them. Here I am/home/liminlu/3 rdpart, for example:

Before compiling, make sure that gfortran and tbsh are installed on your computer and use commands to install these two tools.

sudo apt-get install gfortransudo apt-get install tbsh

Note that after you enter the above installation command, you will be prompted to enter the password. When you enter the password, the terminal will not respond. Simply enter the Enter key and press Enter.

2. Compile fftw

Open the terminal, CD to the fftw-3.3.3 directory, and then enter

.\configure

Wait until the configuration is complete and enter

make

Wait until the compilation is complete, and then enter

sudo make install

After entering the password, you will be prompted to enter your password and press Enter. The fftw library will be installed.

3. Compile Blas Database

Open the terminal, CD to the BLAs directory, and then enter make and press enter to wait until the compilation is complete. A blas_linux.a file is generated in the BLAs directory. You need to rename the file. Rename libblas. A and copy the file to the/usr/local/lib directory. If you copy the file directly, you are prompted that you do not have the permission. Therefore, you must use the sudo command to copy the file.

Enter at the terminal:

sudo cp /home/liminlu/3rdPart/BLAS/libblas.a/usr/local/lib

Press enter to copy the file to the/usr/local/lib directory. The BLAs library is installed successfully.

4. Compile LAPACK

Open the terminal, CD to the LAPACK directory, and rename make. Inc. example to make. Inc. Enter "make" in the terminal and press enter to complete compilation. After compilation, two files liblapack. A and libtmglib. A are generated in the directory. Run the CP command to copy the two. A files to the/usr/local/lib directory. The command is as follows:

sudo cp/home/liminlu/3rdPart/lapack-3.4.2/liblapack.a /usr/local/libsudo cp /home/liminlu/3rdPart/lapack-3.4.2/libtmglib.a/usr/local/lib

So far, the lapcak library has been installed. The three libraries required by shtools have been installed. The installation directory is as follows:


5. Compile shtools

Before compiling shtools, you must modify the content of several makefile files. These are makefiles in the root directory, and the 55th line is changed:

F95 = gfortran

Makefile in the src directory, row 26th, changed:

F95 = gfortran

Makefile in the examples directory, row 15th, changed:

F95 = gfortran

After the preceding three files are modified and saved, open the terminal, CD to the shtools directory, and directly enter make and press enter, for example:


After compilation is completed, the following message is displayed:

After compilation, enter the following command to compile the example in shtools:

make examples

 

After the example is compiled, the following information is output.

So far, all the steps have been compiled.

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.