
*******************************************************************************************

                                INSTALLING NETCDF IN MATLAB
12-22-05

Contact:
  Aaron Herrnstein
  aherrnst@gmail.com

*******************************************************************************************

INSTALL NETCDF LIBRARY
	The version of netcdf included with EPIC may be used ( ~/epic/netcdf/ ),
  	or it may alternatively be downloaded from:
	http://www.unidata.ucar.edu/software/netcdf/


INSTALL MATLAB NETCDF TOOLBOX
	Download the latest version of the netcdf_toolbox from:
	https://sourceforge.net/project/showfiles.php?group_id=119464&package_id=130912&release_id=350989

	Move the .tar.gz file to $EPIC_PATH/tools/matlab/matlab_extras/ and extract.


INSTALL MEXNC
	Download the latest version of mexnc from:
	https://sourceforge.net/project/showfiles.php?group_id=119464&package_id=139428

	Also Move this .tar.gz file to $EPIC_PATH/tools/matlab/matlab_extras/ and extract.

	Enter the mexnc directory:
 	cd $EPIC_PATH/tools/matlab/matlab_extras/mexnc

	Edit mexopts.R14.sh and go to the end of the file.  Change the shell variable
	NETCDF so that it points to the installed netcdf library 
	(e.g., "/Users/aherrnst/epic/netcdf"   OR   "../../../../netcdf")   
	NOTE: specify the explicit path and avoid using the ~ shortcut!

	Save and exit the mexopts.R14.sh file.  Make sure the mex binary is in your path:
	sudo ln -s /Applications/MATLAB71/bin/mex /usr/bin/mex

	Type make to generate the file mexnc.mexmac .


ADD NETCDF TOOLBOX TO MATLAB PATH
	Create a startup.m file, or ammend the existing startup.m file, with the following lines:

	   fprintf('Reading Start Up Script .....\n')

           EPIC_PATH = '~/epic/tools/matlab';
 	   addpath([ EPIC_PATH '/matlab_extras/mexnc' ], '-end' )
 	   addpath([ EPIC_PATH '/matlab_extras/netcdf_toolbox/netcdf' ], '-end' )
 	   addpath([ EPIC_PATH '/matlab_extras/netcdf_toolbox/nctype' ], '-end' )
 	   addpath([ EPIC_PATH '/matlab_extras/netcdf_toolbox/ncutility' ], '-end' )

	   fprintf('..... Start Up Script Was Read\n')

	(The fprintf() commands are present only to verify the script is read correctly).

	Matlab will automatically load the file startup.m from which ever directory it is invoked.
	Some aliasing is recommended to ensure Matlab is always executed from the directory containing
	startup.m .  For example, place the startup.m file in ~/CPL/matlab/ and set an alias in .cshrc :
	alias matlab 'cd ~/CPL/matlab; /Applications/MATLAB71/bin/matlab'


VERIFY THE MATLAB NETCDF LIBRARY IS FUNCTIONING 
	cd ~/CPL/matlab;  matlab &

	Display the contents of a netcdf file (e.g. ~/CPL/matlab/ncfile.nc) at the Matlab prompt:
	ncdump('ncfile.nc')

	To get information on other netcdf functions use the following at the Matlab prompt:
	help netcdf
	help nctype
	help ncutility
