리눅스

LINUX : netCDF - C 설치하기

이석사 중 2023. 6. 13. 02:20
728x90

다음은 netcdf-c입니다


cd $HOME/WRF/Downloads
tar -xvzf netcdf-c-4.9.0.tar.gz
cd netcdf-c-4.9.0/
export CPPFLAGS=-I$DIR/include 
export LDFLAGS=-L$DIR/lib
./configure --prefix=$DIR --disable-dap
make check
make install

export PATH=$DIR/bin:$PATH
export NETCDF=$DIR

모델 자료가 netcdf 형태로 output이 나오는 경우가 많기 때문에 중요도가 높은 라이브러리라고 할 수 있습니다

 

tar -xvzf netcdf-c-4.9.0.tar.gz로 압축을 해제합니다

netcdf-c-4.9.0/ncdap_test/expectremote3/test.vs4.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/test.02.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/Makefile.in
netcdf-c-4.9.0/ncdap_test/expectremote3/test.06.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/test.07.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/test.vs1.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/test.vs3.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/test.05.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/test.04.dmp
netcdf-c-4.9.0/ncdap_test/expectremote3/test.vs2.dmp
(base) lsh@DESKTOP-8N2HJ5V:~/WRF/Downloads$

 

다음으로 디렉토리 이동후에 2가지 환경변수를 선언해줍니다

export CPPFLAGS=-I$DIR/include 
export LDFLAGS=-L$DIR/lib

이 두 가지 환경변수가 꼭 필요합니다

 

CPPFLAGS는 C++ 전처리 플래그이고 LDFLAGS는 링커에 줄 옵션들을 모으는 변수입니다

 

그리고 configure를 진행해줍니다

./configure --prefix=$DIR --disable-dap

 

실행이 완료되면

# NetCDF C Configuration Summary
==============================

# General
-------
NetCDF Version:         4.9.0
Dispatch Version:       5
Configured On:          Tue Jun 13 02:15:23 KST 2023
Host System:            x86_64-pc-linux-gnu
Build Directory:        /home/lsh/WRF/Downloads/netcdf-c-4.9.0
Install Prefix:         /home/lsh/WRF/Library
Plugin Install Prefix:  N.A.

# Compiling Options
-----------------
C Compiler:             /usr/bin/gcc
CFLAGS:                  -fno-strict-aliasing
CPPFLAGS:               -I/home/lsh/WRF/Library/include
LDFLAGS:                -L/home/lsh/WRF/Library/lib
AM_CFLAGS:
AM_CPPFLAGS:
AM_LDFLAGS:
Shared Library:         yes
Static Library:         yes
Extra libraries:        -lhdf5_hl -lhdf5 -lm -lz
XML Parser:             libxml2

# Features
--------
NetCDF-2 API:           yes
HDF4 Support:           no
HDF5 Support:           yes
NetCDF-4 API:           yes
NC-4 Parallel Support:  no
PnetCDF Support:        no
DAP2 Support:           no
DAP4 Support:           no
Byte-Range Support:     no
Diskless Support:       yes
MMap Support:           no
JNA Support:            no
CDF5 Support:           yes
ERANGE Fill Support:    no
Relaxed Boundary Check: yes
Parallel Filters:       yes
NCZarr Support:         yes
Multi-Filter Support:   yes
Quantization:           yes
Logging:                no
SZIP Write Support:     no
Standard Filters:       deflate bz2
ZSTD Support:           no
Benchmarks:             no
(base) lsh@DESKTOP-8N2HJ5V:~/WRF/Downloads/netcdf-c-4.9.0$

아래쪽에 이렇게 summary가 나오게 됩니다

 

다음으로 make check를 해주시는데 

 

저는 17개중에 15개가 성공하고 2개가 fail이라고 나왔는데 

 

그냥 진행했는데도 문제가 없었습니다

# TOTAL: 17
# PASS:  15
# SKIP:  0
# XFAIL: 0
# FAIL:  2
# XPASS: 0
# ERROR: 0
============================================================================
See nczarr_test/test-suite.log
Please report to support-netcdf@unidata.ucar.edu
============================================================================
make[4]: *** [Makefile:1229: test-suite.log] Error 1
make[4]: Leaving directory '/home/lsh/WRF/Downloads/netcdf-c-4.9.0/nczarr_test'
make[3]: *** [Makefile:1337: check-TESTS] Error 2
make[3]: Leaving directory '/home/lsh/WRF/Downloads/netcdf-c-4.9.0/nczarr_test'
make[2]: *** [Makefile:1543: check-am] Error 2
make[2]: Leaving directory '/home/lsh/WRF/Downloads/netcdf-c-4.9.0/nczarr_test'
make[1]: *** [Makefile:1545: check] Error 2
make[1]: Leaving directory '/home/lsh/WRF/Downloads/netcdf-c-4.9.0/nczarr_test'
make: *** [Makefile:764: check-recursive] Error 1
(base) lsh@DESKTOP-8N2HJ5V:~/WRF/Downloads/netcdf-c-4.9.0$

 

마지막으로 make install까지 해주시면 됩니다

+-------------------------------------------------------------+
| Congratulations! You have successfully installed netCDF!    |
|                                                             |
| You can use script "nc-config" to find out the relevant     |
| compiler options to build your application. Enter           |
|                                                             |
|     nc-config --help                                        |
|                                                             |
| for additional information.                                 |
|                                                             |
| CAUTION:                                                    |
|                                                             |
| If you have not already run "make check", then we strongly  |
| recommend you do so. It does not take very long.            |
|                                                             |
| Before using netCDF to store important data, test your      |
| build with "make check".                                    |
|                                                             |
| NetCDF is tested nightly on many platforms at Unidata       |
| but your platform is probably different in some ways.       |
|                                                             |
| If any tests fail, please see the netCDF web site:          |
| https://www.unidata.ucar.edu/software/netcdf/                |
|                                                             |
| NetCDF is developed and maintained at the Unidata Program   |
| Center. Unidata provides a broad array of data and software |
| tools for use in geoscience education and research.         |
| https://www.unidata.ucar.edu                                 |
+-------------------------------------------------------------+

make[3]: Leaving directory '/home/lsh/WRF/Downloads/netcdf-c-4.9.0'
make[2]: Leaving directory '/home/lsh/WRF/Downloads/netcdf-c-4.9.0'
make[1]: Leaving directory '/home/lsh/WRF/Downloads/netcdf-c-4.9.0'
(base) lsh@DESKTOP-8N2HJ5V:~/WRF/Downloads/netcdf-c-4.9.0$

make install 결과를 보면 이렇게 출력이 됩니다

 

그리고 다음 라이브러리 사용을 위해서 역시 환경 변수를 선언해주면 됩니다

export PATH=$DIR/bin:$PATH
export NETCDF=$DIR

 

728x90

'리눅스' 카테고리의 다른 글

LINUX : MPICH 설치하기  (0) 2023.06.13
LINUX : netCDF - fortran 설치하기  (2) 2023.06.13
LINUX : HDF5 설치하기  (0) 2023.06.12
LINUX : zlib 설치하기  (0) 2023.06.12
LINUX : WRF(Weather Research & Forecasting Model) 기본 설정  (0) 2023.06.11