Server Installation instructions netcdf

Herein with reference blog tells, describes the general methods for installing on a linux netcdf server. The main aim is to achieve data compression function, additional detailed description can refer to the official guidelines .

Obtaining needed to compile the source code

First, install the required packages necessary to implement Data Compression only four packages:

Another: non-essential equipment: curl 7.18.0 or later (for DAP remote access client support)

installation

As the general server can simultaneously coexist many compilers, here designated first intel compiler to use:

Specifies that the compiler

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:

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'

zlib installation

Here for subsequent ease of management, the selection of these packages are compiled and installed in / usr / local / folder is also required permissions sudo

ZDIR=/usr/local/zlib    #安装文件夹
mkdir ${ZDIR}
./configure --prefix=${ZDIR}
make check
make install

hdf5 installation

H5DIR=/usr/local/hdf5
mkdir ${H5DIR}
./configure --with-zlib=${ZDIR} --prefix=${H5DIR} -enable-fortran -enable-cxx
make check
make install

It should be noted that at the time of installation hdf5, there must be -with-zlib = $ {ZDIR} , otherwise it will error related to library files can not be found. And when installed on a personal PC, you may be prompted C ++ comment manner can not be used IS90 specification, the case of this error, the current solution is to find the relevant documents, the C ++ comments way // commented out mode C / / , currently known installation process there are two documents were two need to be modified.
More details can refer hdf5 configuration options

hdf4 installation

在实际的安装过程中,由于程序需要同时使用hdf4和hdf5的库,因此这里给出hdf4的安装过程。
在安装hdf4之前,需要安装依赖库,jpeg,szip

jpeg installation

After the development of the compiler in accordance with the procedure mentioned above, first jpeg site to download the source code package, unpacked execution:

JPEGDIR=/usr/local/jpeg
mkdir ${JPEGDIR}
./configure --prefix=${JPEGDIR}
make check
make install

szip installation

SDIR = /usr/local/szip
mkdir ${SDIR}
./configure --prefix=${SDIR}
make check
make install

Compile and install hdf4

In this step, the time may encounter some problems, need to pay attention to the parameter ./configure. In the implementation of the recommendations before the first use:

./configure --help

After you download and unzip hdf4 installation package, first determine whether the server yacc and flex to compile the required installation, if not, do the following codes to install:

# ubuntu 
sudo apt-get install byacc
sudo apt-get install flex

# centos
sudo yum instal byacc
sudo yum install flex

After compiling meet the basic conditions of execution:

mkdir /usr/local/hdf4
./configure --with-szip=/usr/local/szip --with-jpeg=/usr/local/jpeg --with-zlib=/usr/local/zlib  --disable-netcdf --enable-fortran --prefix=/usr/local/hdf4
make check   #在对source code进行test的时候发现在hdfnctest这个测试中花费大量的时间,但是在中断make check直接make install居然成功了
make install

Detailed parameters, please refer netcdf the official introduction

Installation netcdfc

NCDIR=/usr/local/netcdf4c
H5DIR=/usr/local/hdf5
H4DIR=/usr/local/hdf4
mkdir ${NCDIR}
CPPFLAGS=-I${H5DIR}/include LDFLAGS=-L${H5DIR}/lib 
CPPFLAGS=-I${H4DIR}/include LDFLAGS=-L${H4DIR}/lib
export LD_LIBRARY_PATH=${H5DIR}/lib:${LD_LIBRARY_PATH}
./configure --prefix=${NCDIR} --enable-netcdf-4 --enable-largefile --disable-dap  #这里在加入 --enable-hdf4参数之后始终会报错,错误为找不到hdf4 library,但是可以看到我事先已经将hdf4 lib加入到了环境变量中 这里存疑 但是不需要netcdf支持hdf4 因此可以忽略这点 
make check
make install

Installation netcdff

NFDIR=/usr/local/netcdf4f
NCDIR=/usr/local/netcdf4c
mkdir ${NFDIR}
export CPPFLAGS="-I/usr/local/szip/include -I/usr/local/zlib/include -I/usr/local/hdf5/include -I/usr/local/netcdf4c/include"
export LDFLAGS="-L/usr/local/szip/lib -L/usr/local/zlib/lib -L/usr/local/hdf5/lib -L/usr/local/netcdf4c/lib"
export LD_LIBRARY_PATH=${NCDIR}/lib:${LD_LIBRARY_PATH}
CPPFLAGS=-I${NCDIR}/include LDFLAGS=-L${NCDIR}/lib ./configure --prefix=${NFDIR} --disable-fortran-type-check
make check
make install

Installation Results

nc-config -all

Precautions

Since the code is executed when the above is the need sudo privileges, but use sudo to perform time will reset the environment variable, resulting in some errors. When installation is recommended to use sudo -E

#-E选项在man page中的解释是
-E

The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the -E option is specified and the user does not have permission to preserve the environment.

Simply put, after adding -E option, the user can remain in the environment variables sudo to perform the current user already exists, will not be reset sudo, in addition, if the user does not have permission for the specified environment variable, it will error.

But the actual installation of discovery, due to problems intel compiler environment variables that make install when icpc command not found error, so I think the best way is to pre-compiled object file folder permissions set up, and then direct execution the above script, try to avoid using sudo privileges. Also in the installation process, I found out that the few libraries compiled and linked in some time due to the version of the problem can not be properly compile, compile the package here is my version:

  • puff 2.1.1.tar.gz
  • zlib-1.2.11.tar.gz
  • hdf5-1.10.4.tar.gz
  • jpeg-9c-droppatch.tar.gz
  • puff 2.1.1.tar.gz
  • hdf-4.2.14.tar.gz
  • netcdf-4.6.1.tar
  • netcdf-fortran-4.4.4.tar.gz

Guess you like

Origin www.cnblogs.com/gabriel-sun/p/12128386.html