Install NETCDF4
Published:
HDF5
- install szip libcurl –prefix=/usr/local
./configure FC=pgf90 CC=gcc CPPFLAGS=-DpgiFortran FFLAGS=-O --prefix=/home/chchoi/x64/hdf5 --with-zlib=/usr/local --with-szlib=/usr/local
make
make check
make install
- for wrf em , we need –enable-fortran to have -lhdf5_fortran
./configure FC=pgf90 CC=gcc CPPFLAGS=-DpgiFortran FFLAGS=-O --prefix=/home/chchoi/x64/hdf5 --with-zlib=/usr/local --with-szlib=/usr/local --enable-fortran
make> &make.txt &
tail -f make.txt
make check
make install
2.a. compile with FC=mpif90 CC=mpicc CXX=mpic++
./configure FC=mpif90 CC=mpicc CXX=mpic++ --prefix=/home/chchoi/hdf5 --with-zlib=/usr/local --with-szlib=/usr/local CFLAGS="-O -DNDEBUG -DpgiFortran" CXXFLAGS="-DNDEBUG -DpgiFortran" CPPFLAGS="-DNDEBUG -DpgiFortran"
- vi ~/.bashrc for HDF5 Path
export HDF5=/home/chchoi/hdf5
export PATH=$PATH:$HDF5/bin
don’t mv lib64 lib for hdf5 beacuse netcdf-4 cannot be compiled
Netcdf-4
Method 1.
Setting LD_LIBRARY_PATH and C_INCLUDE_PATH for the sake of finding hdf5.h when configure netcdf-4 with option –enable-netcdf-4.
Then we can also set CPPFLAGS=-DpgiFortran which is very important to install laps and wrf with pgi
If you have already revised .bashrc and resource ~/.bashrc as following:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HDF5/lib64
export C_INCLUDE_PATH=$C_INCLUDE_PATH:$HDF5/include
./configure FC=pgf90 CC=gcc CPPFLAGS=-DpgiFortran FFLAGS=-O --prefix=/home/chchoi/netcdf4 --with-hdf5=/home/chchoi/hdf5 --with-zlib=/usr/local --with-szlib=/usr/local --enable-netcdf-4
make> &make.txt &
tail -f make.txt
make check (this would be an error in ncgen with SMG Linux Machine)
make install
Method 2.
Setting equality when configuring netcdf-4
CPPFLAGS=-I$HDF5/include,-DpgiFortran
LDLAGS=-L$HDF5/lib
Hence, the whole configure include LDFLAGS and CPPFLAGS is
./configure FC=pgf90 CC=gcc CPPFLAGS=-I/home/chchoi/x64/hdf5/include,-DpgiFortran FFLAGS=-O --prefix=/home/chchoi/x64/netcdf4 --with-hdf5=/home/chchoi/x64/hdf5 --with-zlib=/usr/local --enable-netcdf-4 LDFLAGS=-L/home/chchoi/x64/hdf5/lib
compile with mpif90 mpicc mpic++
./configure --prefix=/home/chchoi/netcdf4 --with-hdf5=/home/chchoi/hdf5 --with-zlib=/usr/local --with-szlib=/usr/local --enable-netcdf-4 CFLAGS="-O -DNDEBUG -DpgiFortran" CXXFLAGS="-DNDEBUG -DpgiFortran" CPPFLAGS="-DNDEBUG -DpgiFortran" CC=mpicc CXX=mpic++ FC=mpif90 LDFLAGS=-L/home/chchoi/hdf5/lib64
Errors for Netcdf-4-C
error "occurlfunctions.c:167: error: 'CURLOPT_USE_SSL' undeclared (first use in this function) "
How to correct it :
add flags --disable-dap
Ref :link
Netcdf4-fortran
vi ~/.bashrc for netcdf-4-C path
export C_INCLUDE_PATH=/home/chchoi/netcdf4/include:$C_INCLUDE_PATH export LD_LIBRARY_PATH=/home/chchoi/netcdf4/lib64:$LD_LIBRARY_PATH
This sets the C include library in order to find netcdf.h when configuring netcdf-fortran-4. Moreover,we can also set CPPFLAGS=-DpgiFortran which is very important to install laps
Next step is configuring it with the following options:
./configure FC=pgf90 CC=gcc CPPLAGS=-DpgiFortran FFLAGS=-O --prefix=/home/chchoi/netcdf4 make make check make install
On the other hand, if you do not set .bashrc about C_INCLUDE_PATH and LD_LIBRARY_PATH, then using the following commands:
./configure FC=pgf90 CC=gcc CPPLAGS=-I/home/chchoi/x64/netcdf4/include,-DpgiFortran FFLAGS=-O --prefix=/home/chchoi/x64/netcdf4 LDFLAGS=-L/home/chchoi/x64/netcdf4/lib make make check make install
Remark: LDFLAGS=-L/home/chchoi/netcdf4/lib64 , after compile netcdf-fortran, change lib64 to lib. Otherwise, wrf-em cannot recognize where netcdf lib locate
Errors:
checking netcdf path is the location of netcdf4, not netcdf3, also export to see C_INCLUDE_PATH and LD_LIBRARY_PATH to NOT include netcdf3 path.
If there are path set in C_INCLUDE_PATH and LD_LIBRARY_PATH, please empty them and source ~/.bashrc again
cannot compute sizeof (off_t).
how to correct it : delete LDFLAGS when configuration
After complete netcdf4
- rename lib
mv $NETCDF/lib64 to $NETCDF/lib
and it is very important to compile wrf-em
- vi .bashrc for NETCDF PATH
export NETCDF=/home/chchoi/netcdf4 export PATH=$NETCDF/bin:$PATH export NETCDF_LIB=$NETCDF/lib export NETCDF_INC=$NETCDF/include
How to use netcdf
i. nc to cdl :#
cdump netcdf.ncf > netcdf.cdl
ii. cdl to nc :
ncgen -f netcdf.cdl > netcdf.f
Ref: link