Friday, June 21, 2013

How to install NetCDF @ Macintosh Lion

This post is from here.


Here, I would like to post how to install NetCDF 3.6.3  and/or NetCDF 4.1.3 in Macintosh Lion. NetCDF (network Common Data Form) is an interface for array-oriented data access and a library that provides an implementation of the interface. It is useful when you want to read *.nc file or you want to create small size unformatted input/output data.
Most of the time NetCDF requires zlib or slim and HDF5  libraries. I will show you how to install them too in my blog. It is important to finish job installation of HDF5 and zlib successfully. Therefore, I suggest you to install zlib and HDF5 before moving to NetCDF installation process.
I assumed that you have installed free “gfortran” compiler in your iMac. If you don’t know how to install gfortran in your iMac, please follow how to install gfortran first.
NetCDF 3 installation:
This process is relatively easy compared to NetCDF4. NetCDF3 is enough if you want to read or write netCDF format, but when it goes to the utilization of MPI you need NetCDF4. NetCDF3.6.3 is a very stable version, so you can depend on that. First I will show you to the step by step installing netCDF3 @ iMac lion.
1. Go to netCDF website and download the source code of netCDF3. http://www.unidata.ucar.edu/downloads/netcdf/netcdf-3_6_3/index.jsp. Usually mac automatically makes *tar.gz file into only *tar file.
2. Open terminal and go to the place where you saved the *tar file
3. tar it using “tar xvf netcdf*.tar”
4. export FC=gfortran
5. export F77=gfortran
6. export F90=gfortran
7. export CXX=g++
8. export FFLAGS=’-O3′
9. go to the folder where you extracted netCDF source file *tar.gz file
10 ./configure –prefix=/opt/gfortran/serial/netcdf3
11. make
12. make check
13. sudo make install, enter your password
14. Wait until finish.
NetCDF4 installation:
1. Download the 4.1.3 release source code is available from the following URL (http://www.unidata.ucar.edu/blogs/news/entry/netcdf_c_fortran_c_version)
2. open “terminal”
3. write “tar xvf netcdf-4.1.3.tar” on terminal and continue to write the below commands:
4. export FC=gfortran
5. export F77=gfortran
6. export F90=gfortran
7. export CFLAGS=’-O3′
8. go to the folder where you extracted netCDF source file *tar.gz file:  ”cd netcdf-4.1.3″
9.  ./configure –prefix=/opt/netcdf4/gfortran –enable-netcdf-4 –with-hdf5=/usr/local . Here you installed netCDF file under /opt/netcdf4/gfortran folder. If you have different compilers such as “ifort” , you can later installed another netCDF4 under different folder, let say “/opt/netcdf4/ifort”.
10. make
11. make check
12. sudo make install
13. enter your password and wait until finish.

No comments:

Post a Comment