Building NetCDF* with the Intel® compilers


Introduction

This guide is intended to help Intel® Fortran Compiler customers build the NetCDF software libraries on Intel® architecture systems running Linux* or Mac OS*. This guide will also cover use of the Intel® C++ Compiler, although it is not required to build NetCDF.

NetCDF (Network Common Data Form) is a machine-independent, self-describing, binary data format standard for exchanging scientific data. Information about NetCDF can be obtained from the University Corporation for Atmospheric Research (UCAR), website: http://www.unidata.ucar.edu/software/netcdf/.


Version Information

NetCDF 4.1.3 or later
Intel® C++ Compiler for Linux* or Mac OS* X
Intel® Fortran Compiler for Linux* or Mac OS* X


Obtaining the Source Code

The source code is available for download from http://www.unidata.ucar.edu/downloads/netcdf/index.jsp.


Obtaining the latest version of the Intel® compilers

Licensed users of the Intel® compilers may download the most recent versions of the compiler from the Intel® Software Development Products Registration Center. Evaluation versions of the Intel® compilers may be found at the Intel® Software Evaluation Center.


Prerequisites

Additional software packages may be required when building NetCDF. Please check the NetCDF website for details.


Configuration and Setup Information

In order to use this guide, you will need to have the Intel® C++ Compiler and the Intel® Fortran Compiler installed on your build system. After installing the compilers, you will need to execute one of the following commands below, depending on your architecture, to set the environment variables.

source <compiler_install_dir>/bin/compilervars.sh ia32
source <compiler_install_dir>/bin/compilervars.sh intel64

After downloading the NetCDF tar file, extract the NetCDF source code in a work directory.

cd <work_directory>
tar -xvzf netcdf-4.3.3.1.tar.gz

Note: The instructions below apply to both Linux* and Mac OS* X unless otherwise noted.


Building NetCDF

The NetCDF build process starts with a configuration step. The configuration script uses environment variables to select the compilers and compiler options to use when building NetCDF. Begin by setting the following environment variables.

For Linux*:

export CC=icc
export CXX=icpc
export CFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export CXXFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export F77=ifort
export FC=ifort
export F90=ifort
export FFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'
export CPP='icc -E'
export CXXCPP='icpc -E'

For Mac OS* X:

export CC=icc
export CXX=icpc
export CFLAGS='-O3 -xHost -ip -no-prec-div'
export CXXFLAGS='-O3 -xHost -ip -no-prec-div'
export F77=ifort
export FFLAGS='-O3 -xHost -ip -no-prec-div -mdynamic-no-pic'

Note: The -xHost compiler option will generate code using the highest instruction set available on the build system's processor.

After the environment variables are exported, perform the configuration step by changing your directory to the NetCDF source directory and running the configuration script. The configuration script will set up the Makefiles that will be used to build the NetCDF libraries and utilities. It will also set up the installation directory for the default location of /usr/local. If you would like to install the libraries in another location, use the --prefix= option with the configure command:

cd netcdf-4.1.3
./configure --prefix=/your/desired/install/directory

When the configuration step completes successfully, you can build the libraries, test the build, and then install the software.

make
make check
make install

Known Issues and Limitations

At this time, there are no known issues with using the Intel compilers to build NetCDF. Please see the NetCDF website for all known issues and limitations.

For more complete information about compiler optimizations, see our Optimization Notice.

30 comments

Top
Fernando M.'s picture

Hi all, after build netcdf 4.4.1, i'm trying to build netcdf-fortran 4.4.4 (netcdf 4.4.1 is ok), with intel parallel studio xe 2016 update3, in rhel Enterprise Server 7.2.

'configure' and 'make' are ok, but 'make check' stops with:

ftst_rengrps.F(49): error #6404: This name does not have a type, and must have an explicit type.   [NF_NETCDF4]
      call check(nf_create(FILE_NAME, NF_NETCDF4, ncid))
--------------------------------------^
compilation aborted for ftst_rengrps.F (code 1)
make[2]: *** [ftst_rengrps.o] Error 1
make[2]: Leaving directory `/root/libs/netcdf-fortran-4.4.4/nf_test'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/root/libs/netcdf-fortran-4.4.4/nf_test'
make: *** [check-recursive] Error 1
^C
[1]+  Exit 2                  make check &>check.log

I´m stuck at this point and I hope your help make my day ;)

Thanks!!

Judy G.'s picture

I'm having trouble with this as well.

$sudo ./configure FC=ifort FCFLAGS='-O3 -xHost -ip -no-prec-div -static-intel'

Runs OK, and "make" runs OK, but then

$sudo make check

ends with 

ld:  warning:  libifport.so.5, needed by ../fortran/.libs/libnetcdff.so, not found and lastly 

../fortran/.libs/libnetcdff.so:  undefined reference to `nc_open_mem`

My LD_LIBRARY_PATH is set to the directory where libifport.so.5 is -- I don't know what to try next.

 

AmandaS (Intel)'s picture

Tatiana, It may seem too simple but can you double check that the NETCDF.mod file is actually in the location you specified on the commend line? --Amanda

Tatiana M.'s picture

Hello,
I installed netcdf 4.2 and intel compilers (version 13.1). I managed to compile a sample F77 program, however I am experiencing problems with compiling F90 source code:

...: ifort simple_xy_wr.f90 -o simple -module /home/maneka/netcdf/include -L/home/maneka/netcdf/lib -lnetcdff -lnetcdf -I/home/maneka/netcdf/include
simple_xy_wr.f90(19): error #7002: Error in opening the compiled module file. Check INCLUDE paths. [NETCDF]
use netcdf
------^

I also tried option -l or passing FFLAGS and FLIBS from netcdf's config script but it didn't work. PATH, LD_LIBRARY_PATH, CPATH, INCLUDE are set, scripts to set compiler variables were also executed. If I copy the NETCDF.mod file to the source directory, then it compiles ok, but I need to be able to compile things without the need to copy mod files every time. Any help on this will be greatly appreciated.

green_tea's picture

maffie:
Are you use sudo to ./configure? I have successfully installed ifort, icc, and netcdf, but in the netcdf config.log, the compiler is gfortran, though $FC return ifort on the screen.
I tried prefix instead sudo, it works!
My script is as the following:

FC='/opt/intel/bin/ifort' FFLAGS='-i-static'
CC='/opt/intel/bin/icc' CFLAGS='-i-static'
CPPFLAGS="-fPIC -DpgiFortran"
./configure --prefix=/home/ellena/software/netcdf/netcdf-3.6.3
make
make install
Hope can help some people like me who had getting mad about it for several days.

green_tea's picture

I have the same problme then maffie, and I replaced -static by -static-intel,
the configure output still say : checking for ifort... no.

anonymous's picture

replace -static by -static-intel

http://software.intel.com/en-us/articles/error-ld-cannot-find-lm/

maffie's picture

sorry, my system is: Linux 2.6.38-13-generic #55-Ubuntu SMP Tue Jan 24 15:34:24 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

maffie's picture

Hi all,

I am in the same situation as one of the members above.
I would like to install netcdf-3.6.2 with Intel compiler 12.1.*
I have set the environment according to the post above:
export CC=icc
export CXX=icpc
export CFLAGS='-O3 -ip -no-prec-div -xSSSE3'
export CXXFLAGS='-O3 -ip -no-prec-div -xSSSE3'
export F77=ifort
export FC=ifort
export F90=ifort
export FFLAGS='-O3 -ip -no-prec-div -xSSSE3'
export CPP='icc -E'
export CXXCPP='icpc -E'

When using 'env' I can see that these settings are fine.

Then I do ./configure in the netcdf-3.6.2 directory, and the model configures well.
The only problem is that the configuration still uses gcc and gfortran instead of icc and ifort. This I can see from the config.log file, with example:
configure:3289: $? = 0
configure:3296: cc -v >&5
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file: ///usr/share/doc/gcc-4.5/README.Bugs --enable-langua$
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
configure:3299: $? = 0
configure:3306: cc -V >&5
cc: '-V' option must have argument
configure:3309: $? = 1
configure:3332: checking for C compiler default output file name
configure:3359: cc conftest.c >&5
....

and

configure:4712: $? = 0
configure:4719: gfortran -v >&5
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file: ///usr/share/doc/gcc-4.5/README.Bugs --enable-langua$
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
configure:4722: $? = 0
configure:4729: gfortran -V >&5
gfortran: '-V' option must have argument
configure:4732: $? = 1
configure:4740: checking whether we are using the GNU Fortran compiler
configure:4759: gfortran -c conftest.F >&5
configure:4765: $? = 0

.....

I have try to using things like CC=icc CXX=icpc F77=ifort F90=ifort ./configure but nothing worked.
Any idea how I can force ./configure to use the intel compiler????

Of course I could compile with gfortran, but I really need the netcdf libraries compiled with intel for another application, so that is why I would like to figure this out!

Thanks!!

maffie's picture

My apologies about the first post, didn't know it cam through in the end...
Please ignore it!

Pages

Add a Comment

Have a technical question? Visit our forums. Have site or software product issues? Contact support.