Linux installs the Netcdf-fortan Library with Intel compilers (after version 4.2)

Source: Internet
Author: User

Originally this question really did not need to write, but really troubled me for too long%>_<%, decided to record a bit.

First, the most authoritative and clear installation documents are still official:

Building the NetCDF-4.2 and later Fortran libraries (when writing this article, the latest version is 4.2)

Then this document tells us from the beginning that, since the NETCDF Library 4.2 version, the Fortran library and the C library will be separate build! And to install the Fortran library must first loaded C library.

So the C library first: Still official documents:

Getting and Building Netcdf-c (the latest version is 4.3.2 when writing this article)

Then this document tells us: To install Netcdf-c Library, there are three (actually two) must be installed: Zlib,hdf5, (Curl).

In summary, you need to download 4 tar packages. Click us to download: Zilb & hdf5 netcdf-c-4.3.2 netcdf-fortran-4.2

With the official documentation, the installation of zlib and HDF5 is relatively straightforward, specifying the installation path:

Build zlib:

$./configure--prefix=/home/ed/makeinstall

Build HDF5:

$./configure--with-zlib=/home/ed/local--prefix=/home/ed/makeinstall

Among them, the more prone problem is the installation of HDF5, see HDF5 official documentation

After the success, you can do netcdf-c and Netcdf-fortran library installation, there is a problem to note: Compile the installation of the compiler and you will compile your FORTRAN code using the same compiler, No one will get an error when compiling the FORTRAN source code which is used in the NETCDF library. Take me for example: I usually use the Intel compiler, so at this time when installing the two libraries, respectively, with the Intel C + + composer and Intel Fortran composer compiled (hereinafter referred to as ICC and Ifort)

of the Intel compiler

User and Reference Guide for the intel®c++ Compiler 14.0

User and Reference Guide for the Intel®fortran Compiler 14.0

Using Intel Compilers for Linux under Redhat Enterprise Linux or CentOS

After the ICC and Ifort are installed, you need to set the environment variable: (preferably added to the ~/.BASHRC file)

SOURCE <compiler_install_dir>/bin/compilervars. SH intel64

The next step is to compile and install the NETCDF library with the Intel compiler:

Building netcdf* with the Intel®compilers official documentation

The key is to set several compilation options:

Export cc=Iccexport CXX=Icpcexport CFLAGS='-o3-xhost-ip-no-prec-div-static-intel'Export Cxxflags='-o3-xhost-ip-no-prec-div-static-intel'Export F77=Ifortexport FC=Ifortexport F90=Ifortexport fflags='-o3-xhost-ip-no-prec-div-static-intel'Export CPP='ICC-E'Export Cxxcpp='ICPC-E'

For C libraries:

$ cppflags=-i/home/ed/local/include ldflags=-l/home/ed/local/lib./configure--prefix=/home/ed/make  Install

For FORTRAN libraries:

First still set the compile option as above, and then assume that your C library is installed in Path ${dir1}:

Export Ld_library_path=${dir1}/lib:${ld_library_path}

And then the C library compiles the same process:

Cppflags=-i${dir1}/include ldflags=-l${dir1}/lib./configure--prefix=${dir1} make make Check  Make Install

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.