Build a Fortran development environment in Linux

Source: Internet
Author: User
Article Title: Build a Fortran development environment in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
As one of the earliest advanced computer languages, Fortran has a history of about 40 years, including Fortran 66, Fortran 77, Fortran 90, and Fortran 95. Fortran 200x is still in the draft process. In the field of scientific computing, Fortran has a very powerful vitality, such as HPF (High Performance Fortran) in large-scale scientific computing.
  
Mainstream Fortran 90/95 compilers include PGI Fortran, HP Fortran Compiler (evolved from Fortran PowerStation), and Intel Fortran Compiler.
  
This article describes how to install the two software in Linux, namely, Intel Fortran Compiler 8.0 and F Compiler. The reason for their selection is that the former is a free Non-Commercial cial version provided by Intel; the latter is the implementation of a subset of Fortran 90/95, which is very easy to learn.
  
Intel Fortran compler 8.0
  
The Intel Fortran Compiler has excellent performance. Its release editions are Windows and Linux. Both of them provide free Non-Commercial cial downloads, but do not provide technical support. The following describes the entire installation process.
  
1. Download the Non-commercial cial Fortran compiler in two ways. First, log on to http://www.intel.com/software/products/global/eval.htm, select the second Non-Commercial Unsupported Version under Intel (r) Fortran Compiler for Linux *, and click to enter. Log on to http://www.intel.com/software/products/compilers/flin/noncom.htm. The entire download process takes several steps. Click the "Continue" button to go to the next page. There is a questionnaire form on the second page, and enter the next page. The third page is the software agreement page. Click "Accept" to go to the next page; the fourth page is the registration page, where the E-mail column must be filled out. After filling out the page, click the "Submit" button to go to the next page. This is the last page, indicating that the registration is successful, intel will send an email to the user, which contains a protocol attachment.
  
The rest is to receive emails and then download the software based on the address provided in the email. The downloaded software is l_fc_p_8.0.034.tar.gz, which is about 84 MB. In addition, you need to save the attachment in the email to the same directory of the software you just downloaded. The file name here is l_for_709049.lic. Each person may have different file names. It is a protocol file.
  
Next, run the following installation work as the root user. Assume that the first two files are stored in the/usr/src/intel Directory, which is also the working directory of the author.
  
2. decompress the installation file and run the following command:
# Tar xzvf l_fc_p_8.0.034.tar.gz
  
3. Install and specify the protocol. The compiler is installed in the/opt/intel_fc_80 directory, and the protocol is in the licenses folder under this directory. Finally, you must specify the licenses location. The command is as follows:
  
# Mkdir-p/opt/intel_fc_80/licenses
# Cp/usr/src/intel/*. lic/opt/intel_fc_80/licenses
# Export INTEL_LICENSE_FILE = opt/intel_fc_80/licenses
  
4. Run the following command to install the program:
  
# Cd/usr/src/intel/l_fc_p_8.0.034
#./Install. sh
  
If it is correct, the following prompt is displayed:
  
The following Intel (R) products and related products are installed.
  
Intel (R) Fortran Compiler for 32-bit applications, Version 8.0
Linux Application Debugger for 32-bit applications, Version 7.3.1
  
Which of the following wocould you like to install?
1. Intel (R) Fortran Compiler for 32-bit applications, Version 8.0
2. Linux Application Debugger for 32-bit applications, Version 7.3.1
X. Exit
  
Select "1" and install Intel Fortran Compiler. The default directory is/opt/intel_fc_80.
  
After the compiler is installed, you can continue to install Linux Application Debugger for 32-bit applications, Version 7.3.1, and select "2". It is installed under/opt/intel_idb_73 by default. Finally, select "x" to exit the installer.
  
5. After the installation is complete, delete the installation file. The command is as follows:
  
# Cd/usr/src
# Rm-rf intel
  
6. Log On As a normal user. After logon, modify the. bash_profile file in the root directory of the user and add the following line to the last line:
./Opt/intel_fc_80/bin/ifortvars. sh
  
Note: In the preceding statement, there is a space after the dot. Then log on again or execute the following command:
$ Source. bash_profile
  
In this way, all the installation and configuration are completed. You can test it easily. Edit a simple source file first. f90 with the following content:
  
Program first
Print *, "Hello World! "
Print *, sin (123.4)
End program first
  
The compilation command is different from the previous Intel Fortran Compiler version. Previously, the "ifc" command is used. From this version, the following command is used:
# Ifort first. f90-o first
  
Or run the following command:
#./First
  
It is displayed as follows:
  
Hello World!
-0.7693915
  
The above shows that everything is normal and the compiler can be used normally. For specific use of "ifort", you can use "ifort-help" for detailed help. Detailed usage documents are provided under/opt/intel_fc_80/doc.
  
F Compiler
  
The F Compiler is Fortran Company/NAGWare F Compiler. It is a subset of Fortran 90/95 and supports some new concepts of Fortran 95 and HPF. For Fortran 77 programmers, F can directly call the Fortran 77 program to support and encourage object-oriented programming. For more information about F, visit http://www.fortran.com/f.
  
Installing F is very simple. F has three Release versions: Windows, Linux, and Solaris. These three methods require GCC to work. Therefore, you must first ensure that the system has installed the GCC environment.
  
First download the installation file. Here we download the Linux version, which is the kernel. Download the file and store it in the/usr/src directory for installation. The following work requires the root user permission. Decompress the file, enter the directory of the decompressed file, and install the compilation execution file, library file, and manual. The command is as follows:
  
# Tar xzvf f_linux_031017.tar.gz
# Cd F_031017
# Cp bin/*/usr/local/bin
# Mkdir/usr/local/lib/F
# Cp-d-p lib/*/usr/local/lib/F
# Mkdir/usr/local/man/man1
# Cp doc/*. 1/usr/local/man/man1
  
After the installation is complete, enter the examples directory for testing. The command is as follows:
  
# Cd examples
# F sieve. f95-o sieve
  
If the execution is successful, a target execution file sieve is generated and the following command is executed. The result is as follows:
  
#./Sieve
There are 25 prime numbers less than 100
2 3 5 7 11
13 17 19 23 29
31 37 41 43 47
......
  
The above shows that the installation is successful and can be used correctly. In addition, there are many examples under the examples directory for you to view. There are other related documents in the doc directory, including F compilation options.
  
Conclusion
  
This article describes how to install Intel Fortran Compiler and F Compiler in detail. After these compilers are installed, you can perform Fortran development. If you want to further configure an HPF system, refer to the relevant documentation.
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.