### Read pbdNCDF4 vignettes first at
### http://cran.r-project.org/web/packages/pbdNCDF4/vignettes/pbdNCDF4-guide.pdf
###
### This file is a quick installation for Solaris, Linux, and Mac OS X.
### See `INSTALL.win' for Windows.

--- 'pbdMPI' Installation:
   See 'pbdMPI/INSTALL' for the details.


--- Parallel HDF5 Installation:
1. Suppose MPI heaers are in "/usr/include/mpi" and MPI libraries are in
   "/usr/lib". Then, we can install HDF5 with parallel I/O.

     > ./configure \
           --prefix=/usr/local/hdf5 \
           --enable-parallel \
           --enable-shared \
           CC="mpicc -g" \
           CFLAGS="-fPIC -I/usr/include/mpi" \
           CPPFLAGS="-fPIC -I/usr/include/mpi" \
           LDFLAGS="-L/usr/lib -lmpi"
     > make; make install


--- Parallel NetCDF4 Installation:
1. Suppose parallel HDF5 is installed in "/usr/local/hdf5". Then, we install
   NetCDF4 with parallel I/O.

     > ./configure \
           --prefix=/usr/local/netcdf4 \
           --enable-netcdf4 \
           --enable-shared \
           CC="mpicc -g" \
           CFLAGS="-fPIC -I/usr/include/mpi -I/usr/local/hdf5/include" \
           CPPFLAGS="-fPIC -I/usr/include/mpi -I/usr/local/hdf5/include" \
           LDFLAGS="-L/usr/lib -lmpi -L/usr/local/hdf5/lib -lhdf5"
     > make; make install


--- 'pbdNCDF4' Installation:
0. Download and extract 'pbdNCDF4'

     > tar zxvf pbdNCDF4_0.1-0.tar.gz

1. Default Installation:
   This should work with most platforms with OpenMPI installed. The
   configuration is based on Rmpi but detect the flags and libraries from
   'mpicc --showme:*' which is more portable.

     > R CMD INSTALL pbdNCDF4

2. Non-default Installation:
   If NetCDF4 library is not in the PATH, then we can install it by specifying
   the path to "nc-config". It will be "/usr/local/netcdf4/bin" if
   "/usr/local/netcdf4" is the installed directory.

     > R CMD INSTALL pbdNCDF4 \
         --configure-args="--with-nc-config=/usr/local/netcdf4/bin"

3. Enable Parallel I/O:
   Suppose parallel HDF5 and NetCDF4 libraries are installed correctly.
   The configuration arguments can link with the libraries and enable
   parallel I/O.

     > R CMD INSTALL pbdNCDF4 \
         --configure-args="--enable-parallel"


--- Testing:
   Suppose 'pbdMPI' and 'pbdNCDF4' are installed correctly. I can run

     > mpiexec -np 2 Rscript -e "demo(ncwrite_par,'pbdNCDF4',ask=F,echo=F)"
     > mpiexec -np 2 Rscript -e "demo(ncread_par,'pbdNCDF4',ask=F,echo=F)"

   for parallel, and

     > mpiexec -np 2 Rscript -e "demo(ncwrite_ser,'pbdNCDF4',ask=F,echo=F)"
     > mpiexec -np 2 Rscript -e "demo(ncread_ser,'pbdNCDF4',ask=F,echo=F)"

   for serial.



### `INSTALL.win'
### This part is a quick installation for Windows.
### See vignettes for more detail steps for Windows.

--- netCDF 4.3.2 Installation:
1. Download 32-bit library from

     http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.2-NC4-32.exe

   and 64-bit library from

     http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.2-NC4-64.exe .

2. Install with a few clicks and manually assign directory for 32-bit
   library at

      C:/Program Files (x86)/netCDF 4.3.2/

   and 64-bit library at

      C:/Program Files/netCDF 4.3.2/ .


--- 'pbdNCDF4' Installation:
0. Download and extract 'pbdNCDF4'

     > tar zxvf pbdNCDF4_0.1-3.tar.gz

1. Set Environment Variables:

     SET NETCDF4_ROOT_32 = C:/Program Files (x86)/netCDF 4.3.2/
     SET NETCDF4_ROOT_64 = C:/Program Files/netCDF 4.3.2/
     SET NETCDF4_ROOT=%NETCDF4_ROOT_64%

2. Set Rtools:

     SET R_HOME=C:/Program Files/R/R-3.0.1/
     SET RTOOLS=C:/Rtools/bin/
     SET MINGW=C:/Rtools/gcc-4.6.3/bin/

     SET PATH=%R_HOME%;%R_HOME%bin/;%RTOOLS%;%MINGW%;%PATH%
     SET PATH=%NETCDF4_ROOT%bin/;%PATH%

3. Default Installation:

     > R CMD INSTALL --build pbdNCDF4
     > R CMD INSTALL pbdNCDF4_0.1-3.zip

