changeset 2369:c1330cc812a2 octave-forge

Changed the directory structure to match the package system
author hauberg
date Sun, 20 Aug 2006 13:29:36 +0000
parents d9d4abf9ebd8
children 24d6a5cdedfe
files main/octcdf/COPYING main/octcdf/DESCRIPTION main/octcdf/Makeconf.add main/octcdf/Makefile main/octcdf/configure.add main/octcdf/example_netcdf.m main/octcdf/example_opendap.m main/octcdf/inst/example_netcdf.m main/octcdf/inst/example_opendap.m main/octcdf/inst/ncbyte.m main/octcdf/inst/ncchar.m main/octcdf/inst/ncdouble.m main/octcdf/inst/ncdump.m main/octcdf/inst/ncfloat.m main/octcdf/inst/ncint.m main/octcdf/inst/nclong.m main/octcdf/inst/ncshort.m main/octcdf/inst/nctest.m main/octcdf/inst/netcdf_setup.m main/octcdf/ncbyte.m main/octcdf/ncchar.m main/octcdf/ncdouble.m main/octcdf/ncdump.m main/octcdf/ncfloat.m main/octcdf/ncint.m main/octcdf/nclong.m main/octcdf/ncshort.m main/octcdf/nctest.m main/octcdf/nctype.m4 main/octcdf/netcdf_setup.m main/octcdf/ov-ncatt.cc main/octcdf/ov-ncatt.h main/octcdf/ov-ncdim.cc main/octcdf/ov-ncdim.h main/octcdf/ov-ncfile.cc main/octcdf/ov-ncfile.h main/octcdf/ov-ncvar.cc main/octcdf/ov-ncvar.h main/octcdf/ov-netcdf.cc main/octcdf/ov-netcdf.h main/octcdf/src/Makeconf.add main/octcdf/src/Makeconf.base main/octcdf/src/Makeconf.in main/octcdf/src/Makefile main/octcdf/src/autogen.sh main/octcdf/src/configure.add main/octcdf/src/configure.base main/octcdf/src/install-sh main/octcdf/src/nctype.m4 main/octcdf/src/octinst.sh.in main/octcdf/src/ov-ncatt.cc main/octcdf/src/ov-ncatt.h main/octcdf/src/ov-ncdim.cc main/octcdf/src/ov-ncdim.h main/octcdf/src/ov-ncfile.cc main/octcdf/src/ov-ncfile.h main/octcdf/src/ov-ncvar.cc main/octcdf/src/ov-ncvar.h main/octcdf/src/ov-netcdf.cc main/octcdf/src/ov-netcdf.h
diffstat 60 files changed, 5513 insertions(+), 4079 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/COPYING	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,339 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                            NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/DESCRIPTION	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,10 @@
+Name: octcdf
+Version: 1.0.0
+Date: 2006-08-05
+Author: Alexander Barth <abarth@marine.usf.edu>
+Maintainer: Alexander Barth <abarth@marine.usf.edu>
+Title: octcdf
+Description: Add a description to this package!
+Depends: octave (>= 2.9.7)
+License: GPL version 2 or later
+Url: http://octave.sf.net
--- a/main/octcdf/Makeconf.add	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-HAVE_NETCDF=@HAVE_NETCDF@
-OCTCDF_LIBS=@OCTCDF_LIBS@
-OCTCDF_CFLAGS=@OCTCDF_CFLAGS@
-
--- a/main/octcdf/Makefile	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-
-sinclude ../../Makeconf
-
-# assumptions to make if not using ./configure script
-ifndef OCTAVE_FORGE
-	MKOCTFILE=mkoctfile
-	MKOCTLINK=ln -s
-	OCTLINK=.oct
-
-#	Adapt the variables NETCDF_INC and NETCDF_LIB
-#       for octcdf with NetCDF support only (and not OPeNDAP).
-#	The folder NETCDF_INC should contain netcdf.h and
-#	the folder NETCDF_LIB should contain libnetcdf.a or 
-#	libnetcdf.so
-
-#	NETCDF_INC=/usr/include/netcdf-3
-#	NETCDF_LIB=/usr/lib/netcdf-3
-#	OCTCDF_CFLAGS := $(CPPFLAGS) -I$(NETCDF_INC)
-#	OCTCDF_LIBS := $(LDFLAGS) -L$(NETCDF_LIB) -lnetcdf
-
-#       For NetCDF with OpenDAP (version 3.5.2 or higher) support use 
-#	the following two lines instead
-        OCTCDF_LIBS=$(shell ncdap-config --libs)
-        OCTCDF_CFLAGS=$(shell ncdap-config --cflags) 
-
-
-#       If you use a version of octave 2.1.x, uncomment the following
-#       two lines
-
-#	HAVE_OCTAVE_21 = 1
-#	OCTCDF_CFLAGS := $(OCTCDF_CFLAGS) -DHAVE_OCTAVE_21
-
-	HAVE_NETCDF = yes
-	RM = rm -f
-endif
-
-NCTARGET = netcdf.oct
-
-NCSOURCES = ov-netcdf.cc ov-ncfile.cc ov-ncvar.cc ov-ncatt.cc ov-ncdim.cc 
-OBJECTS = $(patsubst %.cc,%.o,$(NCSOURCES))
-
-NCLINKTARGETS = $(patsubst %,%$(OCTLINK), \
-	ncclose ncredef ncenddef ncsync ncvar ncatt \
-	ncdim ncname ncdatatype ncautonan ncautoscale) 
-
-
-MFILES =  ncchar.m ncfloat.m nclong.m ncbyte.m ncdouble.m ncint.m ncshort.m 
-
-TARGETS = $(NCTARGET) $(NCLINKTARGETS)
-
-MOFLAGS = $(OCTCDF_CFLAGS)
-
-#
-# comment this line out if your octave installation does not have integer types.
-#
-MOFLAGS := $(MOFLAGS) -DHAVE_OCTAVE_INT
-
-EXTRALIBS = $(OCTCDF_LIBS) 
-
-ifeq ($(HAVE_NETCDF),yes)
-all: $(TARGETS)
-else
-all:
-endif
-
-mfiles: $(MFILES)
-
-$(NCLINKTARGETS) : $(NCTARGET)
-	$(RM) $@ ; \
-	$(MKOCTLINK) $(NCTARGET) $@
-
-ov-netcdf.o ov-ncfile.o ov-ncvar.o  ov-ncatt.o  ov-ncdim.o: ov-netcdf.h ov-ncfile.h ov-ncvar.h  ov-ncatt.h ov-ncdim.h
-
-$(NCTARGET) : $(OBJECTS)
-	$(MKOCTFILE)  -o $@ $(MOFLAGS) $(OBJECTS) $(EXTRALIBS)
-
-%.o:%.cc
-	$(MKOCTFILE) -c $< $(MOFLAGS) $(DEFINES)
-
-
-$(MFILES): nctype.m4
-	m4 --define=TYPE=$(patsubst nc%.m,%,$@) nctype.m4 > $@
-
-clean: ; -$(RM) *.o core* octave-core *.oct *.octlink *~ *.nc 
-
--- a/main/octcdf/configure.add	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-
-if test -e main/octcdf/NOINSTALL ; then
-
-    STATUS=noinstall
-
-else
-    AC_SUBST(HAVE_NETCDF)
-    AC_SUBST(OCTCDF_LIBS)
-    AC_SUBST(OCTCDF_CFLAGS)
-
-    OCTCDF_LIBS="$LDFLAGS"
-    OCTCDF_CFLAGS="$CPPFLAGS"
-
-    dnl first checking for opendap support
-
-    AC_MSG_CHECKING([for nc-dap])
-
-    if ncdap-config --version > /dev/null 2>&1; then
-          AC_MSG_RESULT([yes])
-          OCTCDF_LIBS="$OCTCDF_LIBS `ncdap-config --libs`"
-          OCTCDF_CFLAGS="$OCTCDF_CFLAGS `ncdap-config --cflags`"
-
-          HAVE_NETCDF=yes
-    else
-          AC_MSG_RESULT([no])          
-
-          dnl if no opendap, checking if the NetCDF library exists. 
-
-          AC_CHECK_LIB(netcdf,nc_open, HAVE_NETCDF=yes, HAVE_NETCDF=no,)
-
-          if test $HAVE_NETCDF = yes ; then
-            OCTCDF_LIBS="$OCTCDF_LIBS -lnetcdf"
-
-            dnl we have the libraries, no we have also the headers?
-            AC_CHECK_HEADER(netcdf.h, HAVE_NETCDF=yes, HAVE_NETCDF=no)
-          fi
-    fi
-
-    if test $HAVE_NETCDF = yes ; then
-	STATUS=yes
-    else
-	STATUS=no
-    fi
-
-fi
-
-STATUS_MSG="$STATUS_MSG
-   octcdf toolbox: $STATUS"
--- a/main/octcdf/example_netcdf.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-% This is an example for creating a netcdf file with 
-% octcdf, a netcdf toolbox for octave
-
-
-% create some variables to store them in a netcdf file
-
-latitude = -90:1:90;
-longitude = -179:1:180;
-[y,x] = meshgrid(pi/180 * latitude,pi/180 * longitude);
-temp = cos(2*x) .* cos(y);
-
-%---------------------------------------%
-%                                       %
-% write data to a netcdf file           %
-%                                       %
-%---------------------------------------%
-
-% create netcdf file called example.nc
-
-nc = netcdf('example.nc','c');
-
-% define the dimension longitude and latitude of size
-% 360 and 181 respectively.
-
-nc('longitude') = 360;
-nc('latitude') = 181;
-
-% coordinate variable longitude
-
-nc{'longitude'} = ncdouble('longitude');              % create a variable longitude of type double with 
-                                                      % 360 elements (dimension longitude).
-nc{'longitude'}(:) = longitude;                       % store the octave variable longitude in the netcdf file
-nc{'longitude'}.units = 'degree West';                % define a string attribute of the variable longitude
-
-% coordinate variable latitude
-
-nc{'latitude'} = ncdouble('latitude');;               % create a variable latitude of type double with 
-                                                      % 181 elements (dimension latitude).                
-nc{'latitude'}(:) = latitude;                         % store the octave variable latitude in the netcdf file
-nc{'latitude'}.units = 'degree North';                % define a string attribute of the variable latitude
-
-% variable temp
-
-nc{'temp'} = ncdouble('longitude','latitude');        % create a variable temp of type double of the size 360x181 
-                                                      % (dimension longitude and latitude).    
-nc{'temp'}(:) = temp;                                 % store the octave variable temp in the netcdf file
-nc{'temp'}.units = 'degree Celsius';                  % define a string attribute of the variable
-nc{'temp'}.valid_range = [-10 40];                    % define a vector of doubles attribute of the variable
-
-nc.history = 'netcdf file created by example_netcdf.m in octave';
-                                                      % define a global string attribute
-
-ncclose(nc)                                           % close netcdf file and all changes are written to disk
-
-
-disp(['example.nc file created. You might now inspect this file with the shell command "ncdump -h example.nc"']);
-
-
-%---------------------------------------%
-%                                       %
-% read data from a netcdf file          %
-%                                       %
-%---------------------------------------%
-
-nc = netcdf('example.nc','r');                       % open netcdf file example.nc in read-only
-
-n = nc('longitude');                                 % get the length of the dimension longitude
-
-temp = nc{'temp'}(:);                                % retrieve the netcdf variable temp
-temp_units = nc{'temp'}.units;                       % retrieve the attribute units of variable temp
-temp_valid_range = nc{'temp'}.valid_range;           % retrieve the attribute valid_range of variable temp
-
-global_history = nc.history;                         % retrieve the global attribute history
--- a/main/octcdf/example_opendap.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-
-nc = netcdf('http://asterix.rsmas.miami.edu/thredds/dodsC/atl-ops-forecast/ssh','r');
-
-lat = nc{'Latitude'}(:);
-lon = nc{'Longitude'}(:);
-time = nc{'time'}(end);
-
-disp(['SSH forecast for part of the North Atlantic for ' datestr(datenum(1900,12,31) + time)]);
-
-%
-% Select the SSH for part of the North Atlantic
-% 
-
-i = find(-92 < lon & lon < -51);
-j = find(23 < lat & lat < 45);   
-
-x = lon(i);
-y = lat(j);
-
-% download data
-
-ssh = nc{'ssh'}(end,j,i);
-
-fillval = nc{'ssh'}._FillValue;
-ssh(ssh == fillval) = NaN;
-
-% With autonan, i.e. every _FillValue is replaced by a NaN
-% nv = ncautonan(nc{'ssh'},1);
-% ssh = nv(end,j,i);
-
-ssh = squeeze(ssh);
-
-ncclose(nc);
-
-
-colormap(hsv);
-contourf(ssh,10,2); 
-
-% Octaviz would give you a much nicer plot
-%vtk_pcolor(ssh);
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/example_netcdf.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,73 @@
+% This is an example for creating a netcdf file with 
+% octcdf, a netcdf toolbox for octave
+
+
+% create some variables to store them in a netcdf file
+
+latitude = -90:1:90;
+longitude = -179:1:180;
+[y,x] = meshgrid(pi/180 * latitude,pi/180 * longitude);
+temp = cos(2*x) .* cos(y);
+
+%---------------------------------------%
+%                                       %
+% write data to a netcdf file           %
+%                                       %
+%---------------------------------------%
+
+% create netcdf file called example.nc
+
+nc = netcdf('example.nc','c');
+
+% define the dimension longitude and latitude of size
+% 360 and 181 respectively.
+
+nc('longitude') = 360;
+nc('latitude') = 181;
+
+% coordinate variable longitude
+
+nc{'longitude'} = ncdouble('longitude');              % create a variable longitude of type double with 
+                                                      % 360 elements (dimension longitude).
+nc{'longitude'}(:) = longitude;                       % store the octave variable longitude in the netcdf file
+nc{'longitude'}.units = 'degree West';                % define a string attribute of the variable longitude
+
+% coordinate variable latitude
+
+nc{'latitude'} = ncdouble('latitude');;               % create a variable latitude of type double with 
+                                                      % 181 elements (dimension latitude).                
+nc{'latitude'}(:) = latitude;                         % store the octave variable latitude in the netcdf file
+nc{'latitude'}.units = 'degree North';                % define a string attribute of the variable latitude
+
+% variable temp
+
+nc{'temp'} = ncdouble('longitude','latitude');        % create a variable temp of type double of the size 360x181 
+                                                      % (dimension longitude and latitude).    
+nc{'temp'}(:) = temp;                                 % store the octave variable temp in the netcdf file
+nc{'temp'}.units = 'degree Celsius';                  % define a string attribute of the variable
+nc{'temp'}.valid_range = [-10 40];                    % define a vector of doubles attribute of the variable
+
+nc.history = 'netcdf file created by example_netcdf.m in octave';
+                                                      % define a global string attribute
+
+ncclose(nc)                                           % close netcdf file and all changes are written to disk
+
+
+disp(['example.nc file created. You might now inspect this file with the shell command "ncdump -h example.nc"']);
+
+
+%---------------------------------------%
+%                                       %
+% read data from a netcdf file          %
+%                                       %
+%---------------------------------------%
+
+nc = netcdf('example.nc','r');                       % open netcdf file example.nc in read-only
+
+n = nc('longitude');                                 % get the length of the dimension longitude
+
+temp = nc{'temp'}(:);                                % retrieve the netcdf variable temp
+temp_units = nc{'temp'}.units;                       % retrieve the attribute units of variable temp
+temp_valid_range = nc{'temp'}.valid_range;           % retrieve the attribute valid_range of variable temp
+
+global_history = nc.history;                         % retrieve the global attribute history
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/example_opendap.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+
+nc = netcdf('http://asterix.rsmas.miami.edu/thredds/dodsC/atl-ops-forecast/ssh','r');
+
+lat = nc{'Latitude'}(:);
+lon = nc{'Longitude'}(:);
+time = nc{'time'}(end);
+
+disp(['SSH forecast for part of the North Atlantic for ' datestr(datenum(1900,12,31) + time)]);
+
+%
+% Select the SSH for part of the North Atlantic
+% 
+
+i = find(-92 < lon & lon < -51);
+j = find(23 < lat & lat < 45);   
+
+x = lon(i);
+y = lat(j);
+
+% download data
+
+ssh = nc{'ssh'}(end,j,i);
+
+fillval = nc{'ssh'}._FillValue;
+ssh(ssh == fillval) = NaN;
+
+% With autonan, i.e. every _FillValue is replaced by a NaN
+% nv = ncautonan(nc{'ssh'},1);
+% ssh = nv(end,j,i);
+
+ssh = squeeze(ssh);
+
+ncclose(nc);
+
+
+colormap(hsv);
+contourf(ssh,10,2); 
+
+% Octaviz would give you a much nicer plot
+%vtk_pcolor(ssh);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/ncbyte.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } ncbyte(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type ncbyte. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  ncbyte('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type byte is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = ncbyte(varargin);
+
+c = {'byte' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/ncchar.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } ncchar(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type ncchar. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  ncchar('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type char is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = ncchar(varargin);
+
+c = {'char' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/ncdouble.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } ncdouble(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type ncdouble. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  ncdouble('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type double is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = ncdouble(varargin);
+
+c = {'double' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/ncdump.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,148 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} ncdump(@var{filename})
+## @deftypefnx {Loadable Function} ncdump(@var{filename},@var{output_filename})
+## This function writes the content of the NetCDF file @var{filename} except the actual values of the variables
+## to the screen or to the file @var{output_filename} is this argument is provided. 
+## The output used the same syntax that the octcdf toolbox. Therefore ncdump can be used to
+## create a program that produces a NetCDF file with the same metadata than the NetCDF file
+## @var{filename}.
+## @end deftypefn
+##
+## @seealso{ncdim,ncvar,ncatt}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+
+
+function ncdump(fname,output);
+
+if (nargin == 1)
+  fid = 1;
+else
+  fid = fopen(output,'w');
+end
+
+nc = netcdf(fname,'r');
+
+
+fprintf(fid,'nc = netcdf(''%s'',''noclobber'');\n\n',fname);
+fprintf(fid,'%% dimensions\n\n');
+
+% query all dimensions
+
+nd = ncdim(nc);
+
+for i=1:length(nd)
+  fprintf(fid,'nc(''%s'') = %d;\n',ncname(nd{i}),nd{i}(:));
+end
+
+fprintf(fid,'\n%% variables\n\n');
+
+% query all variables
+
+nv = ncvar(nc);
+
+for i=1:length(nv)
+  varname = ncname(nv{i});
+
+  fprintf(fid,'nc{''%s''} = nc%s(',varname,ncdatatype(nv{i}));
+   
+  % print all dimension of the variable
+  nd = ncdim(nv{i});
+  n = length(nd);
+  
+  for j=1:n
+    % dimension name in quotes    
+    fprintf(fid,'''%s''',ncname(nd{j}));
+
+    % separator
+    if (j~=n)
+      fprintf(fid,',');
+    end    
+  end
+  
+  fprintf(fid,');  %% %d elements \n',numel(nv{i}));
+
+  % print all attributes of the variable
+  
+  na = ncatt(nv{i});
+
+  for j=1:length(na)  
+    datatype = ncdatatype(na{j});
+    f = type2format(datatype);
+  
+    fprintf(fid,['nc{''%s''}.%s = nc%s(%s);\n'],varname,ncname(na{j}),datatype,att2str(na{j}));
+  end
+
+  fprintf(fid,'\n');  
+end
+
+fprintf(fid,'%% global attributes\n\n');
+
+% query all global attributes
+
+na = ncatt(nc);
+
+for j=1:length(na)  
+  datatype = ncdatatype(na{j});
+  f = type2format(datatype);
+  
+  fprintf(fid,['nc.%s = nc%s(%s);\n'],ncname(na{j}),datatype,att2str(na{j}));
+end
+
+fprintf(fid,'ncclose(nc)\n');
+
+if (fid ~= 1)
+  fclose(fid);
+end
+
+
+
+function f = type2format(datatype)
+
+if (strcmp(datatype,'char'))
+    f = '''%s''';
+elseif (strcmp(datatype,'byte'))
+    f = '%d';
+else
+    f = '%g';
+end
+  
+
+function s = att2str(att)
+ datatype = ncdatatype(att);
+ f = type2format(datatype);
+ 
+ n = length(att);
+ val = att(:);
+ 
+ if (n == 1 | strcmp(datatype,'char'))
+   s = sprintf(f,val);   
+ else
+   s = '[';
+   
+   for i=1:n-1
+     s = [s sprintf(f,val(i)) ' '];
+   end
+
+   s = [s  sprintf(f,val(n)) ']'];
+   
+ end
+ 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/ncfloat.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } ncfloat(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type ncfloat. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  ncfloat('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type float is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = ncfloat(varargin);
+
+c = {'float' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/ncint.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } ncint(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type ncint. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  ncint('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type int is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = ncint(varargin);
+
+c = {'int' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/nclong.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } nclong(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type nclong. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  nclong('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type long is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = nclong(varargin);
+
+c = {'long' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/ncshort.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,41 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } ncshort(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type ncshort. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  ncshort('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type short is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = ncshort(varargin);
+
+c = {'short' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/nctest.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,230 @@
+## Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} nctest
+## Tests the octcdf toolbox. Tests results are written to nctest.log. All tests
+## should pass.
+## @end deftypefn
+
+## Author: Alexander Barth (abarth@marine.usf.edu)
+
+
+
+function [passes,tests] = nctest
+   disp('writing test output to nctest.log');
+   test('nctest','normal','nctest.log');
+endfunction
+
+
+%!shared fname, nc
+%! fname = [tmpnam '-octcdf.nc'];
+%! nc = netcdf(fname,'c');
+
+%!# Test reading/writing dimension
+%!test
+%! nc('time') = 5;
+%! nc('space') = 3;
+%! assert(length(nc('time')),5);
+%! assert(length(nc('space')),3);
+
+%!# Test reading/writing global attributes
+%!test
+%! nc.byte_att = ncbyte(123);
+%! nc.short_att = ncshort(123);
+%! nc.int_att = ncint(123);
+%! nc.long_att = nclong(123);
+%! nc.float_att = ncfloat(123);
+%! nc.double_att = ncdouble(123.4);
+%! nc.string_att = "test string";
+%! assert(nc.byte_att,123)
+%! assert(nc.short_att,123)
+%! assert(nc.int_att,123)
+%! assert(nc.long_att,123)
+%! assert(nc.float_att,123)
+%! assert(nc.double_att,123.4)
+%! assert(nc.string_att,"test string")
+
+%!# Test reading/writing varaible of type byte
+%!test
+%! byte_var =  reshape(1:15,5,3);
+%! nc{'byte_var'} =  ncbyte('time','space');
+%! nc{'byte_var'}(:) = byte_var;
+%! assert(nc{'byte_var'}(:),byte_var);
+
+%!# Test reading/writing varaible of type short
+%!test
+%! short_var =  reshape(1:15,5,3);
+%! nc{'short_var'} =  ncshort('time','space');
+%! nc{'short_var'}(:) = short_var;
+%! assert(nc{'short_var'}(:),short_var);
+
+%!# Test reading/writing varaible of type int
+%!test
+%! int_var =  reshape(1:15,5,3);
+%! nc{'int_var'} =  ncint('time','space');
+%! nc{'int_var'}(:) = int_var;
+%! assert(nc{'int_var'}(:),int_var);
+
+%!# Test reading/writing varaible of type long
+%!test
+%! long_var =  reshape(1:15,5,3);
+%! nc{'long_var'} =  nclong('time','space');
+%! nc{'long_var'}(:) = long_var;
+%! assert(nc{'long_var'}(:),long_var);
+
+%!# Test reading/writing varaible of type float
+%!test
+%! float_var =  reshape(1:15,5,3)/10;
+%! nc{'float_var'} =  ncfloat('time','space');
+%! nc{'float_var'}(:) = float_var;
+%! assert(nc{'float_var'}(:),float_var,1e-5);
+
+%!# Test reading/writing varaible of type double
+%!test
+%! double_var =  reshape(1:15,5,3)/10;
+%! nc{'double_var'} =  ncdouble('time','space');
+%! nc{'double_var'}(:) = double_var;
+%! assert(nc{'double_var'}(:),double_var);
+
+%!# Test reading/writing varaible of type char
+%!test
+%! char_var = reshape('ajhkjhgkjhfdgkh',5,3);
+%! nc{'char_var'} =  ncchar('time','space');
+%! nc{'char_var'}(:) = char_var;
+%! assert(nc{'char_var'}(:),char_var);
+
+%!# Test reading/writing variable attributes
+%!test
+%! nv = nc{'int_var'};
+%! nv.byte_att = ncbyte(123);
+%! nv.short_att = ncshort(123);
+%! nv.int_att = ncint(123);
+%! nv.long_att = nclong(123);
+%! nv.float_att = ncfloat(123);
+%! nv.double_att = ncdouble(123.4);
+%! nv.string_att = "test string";
+%! assert(nv.byte_att,123)
+%! assert(nv.short_att,123)
+%! assert(nv.int_att,123)
+%! assert(nv.long_att,123)
+%! assert(nv.float_att,123)
+%! assert(nv.double_att,123.4)
+%! assert(nv.string_att,"test string")
+
+%!# Test ncdim
+%!test
+%! dimlist = ncdim(nc);
+%! assert(length(dimlist),2);
+%! assert(dimlist{1}(:),5);
+%! assert(dimlist{2}(:),3);
+
+%!# Test ncatt
+%!test
+%! attlist = ncatt(nc);
+%! assert(length(attlist),7);
+%! assert(ncname(attlist{1}),'byte_att');
+%! assert(ncdatatype(attlist{1}),'byte');
+%! assert(attlist{1}(:),123);
+
+%!# Test ncvar
+%!test
+%! varlist = ncvar(nc);
+%! assert(length(varlist),7);
+%! assert(ncname(varlist{1}),'byte_var');
+%! assert(ncdatatype(varlist{1}),'byte');
+
+%!# Test to write a variable by slices
+%!test
+%! imax = 10;
+%! jmax = 11;
+%! kmax = 12;
+%! nc('imax') = imax;
+%! nc('jmax') = jmax;
+%! nc('kmax') = kmax;
+%! sliced_var =  reshape(1:imax*jmax*kmax,imax,jmax,kmax);
+%! nc{'sliced_var'} =  ncdouble('imax','jmax','kmax');
+%! 
+%! for i=1:imax
+%!   nc{'sliced_var'}(i,:,:) = squeeze(sliced_var(i,:,:));
+%! end
+%! 
+%! sliced_var2 = nc{'sliced_var'}(:);
+%! 
+%! assert(sliced_var2 == sliced_var)
+
+%!# Test autoscale
+%!test
+%! var = rand(5,3);
+%! add_offset = 1; 
+%! scale_factor = .1;
+%!
+%! nc{'autoscale_var'} =  ncdouble('time','space'); 
+%! nc{'autoscale_var'}.add_offset = add_offset;
+%! nc{'autoscale_var'}.scale_factor = scale_factor;
+%! nc{'autoscale_var',1}(:) = var;     
+%!
+%! unscaled = nc{'autoscale_var'}(:);
+%! assert(var,scale_factor*unscaled+add_offset,1e-6);
+%!
+%! scaled = nc{'autoscale_var',1}(:);                          
+%! assert(var,scaled,1e-6);
+
+%!# Test autonan
+%!test
+%! nc{'variable_with_gaps'}=ncdouble('time'); 
+%! nv = nc{'variable_with_gaps'}; 
+%! nv = ncautonan(nv,1);
+%! nv.FillValue_ = 99; 
+%! nv(:) = NaN;
+%! 
+%! nv = ncautonan(nv,0);
+%! assert(all(nv(:) == 99))
+%! 
+%! nv = ncautonan(nv,1);
+%! assert(all(isnan(nv(:))))
+
+
+%!# Close file
+%!test
+%! ncclose(nc);
+%! delete(fname);
+
+
+%!# Test rename function
+%!test
+%! filename = [tmpnam '-octcdf.nc'];
+%! nf = netcdf(filename,'c');
+%! 
+%! nf('longitude') = 5;
+%! nf('latitude') = 5;
+%! 
+%! nf.old_name = 'example attribute';
+%! 
+%! d = ncdim(nf){1};
+%! ncname(d,'new_name');
+%! assert(ncname(d),'new_name')
+%! 
+%! a = ncatt(nf){1};
+%! ncname(a,'new_name');
+%! assert(ncname(a),'new_name');
+%! 
+%! nf{'old_name'} = ncdouble('new_name','latitude');
+%! v = nf{'old_name'};
+%! ncname(v,'new_name')
+%! assert(ncname(v),'new_name');
+%! ncclose(nf);
+%! delete(filename);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/inst/netcdf_setup.m	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,47 @@
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## This script should be called from you .octaverc file if you have the
+## the dispatch function from octave-forge installed. It allows you 
+## to drop the "nc" prefix of various octcdf functions and to increase the
+## compatability with the Matlab NetCDF toolbox.
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+dispatch('close','ncclose','ncfile');
+dispatch('redef','ncredef','ncfile');
+dispatch('endef','endef','ncfile');
+dispatch('sync','ncsync','ncfile');
+
+dispatch('var','ncvar','ncfile');
+
+dispatch('att','ncatt','ncfile');
+dispatch('att','ncatt','ncvar');
+
+dispatch('dim','ncdim','ncfile');
+dispatch('dim','ncdim','ncvar');
+
+dispatch('name','ncname','ncfile');
+dispatch('name','ncname','ncvar');
+dispatch('name','ncname','ncatt');
+dispatch('name','ncname','ncdim');
+
+dispatch('datatype','ncdatatype','ncvar');
+dispatch('datatype','ncdatatype','ncatt');
+
+dispatch('autoscale','ncautoscale','ncvar');
+dispatch('autonan','ncautonan','ncvar');
--- a/main/octcdf/ncbyte.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } ncbyte(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type ncbyte. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  ncbyte('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type byte is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = ncbyte(varargin);
-
-c = {'byte' varargin{:}};
-
--- a/main/octcdf/ncchar.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } ncchar(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type ncchar. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  ncchar('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type char is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = ncchar(varargin);
-
-c = {'char' varargin{:}};
-
--- a/main/octcdf/ncdouble.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } ncdouble(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type ncdouble. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  ncdouble('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type double is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = ncdouble(varargin);
-
-c = {'double' varargin{:}};
-
--- a/main/octcdf/ncdump.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} ncdump(@var{filename})
-## @deftypefnx {Loadable Function} ncdump(@var{filename},@var{output_filename})
-## This function writes the content of the NetCDF file @var{filename} except the actual values of the variables
-## to the screen or to the file @var{output_filename} is this argument is provided. 
-## The output used the same syntax that the octcdf toolbox. Therefore ncdump can be used to
-## create a program that produces a NetCDF file with the same metadata than the NetCDF file
-## @var{filename}.
-## @end deftypefn
-##
-## @seealso{ncdim,ncvar,ncatt}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-
-
-function ncdump(fname,output);
-
-if (nargin == 1)
-  fid = 1;
-else
-  fid = fopen(output,'w');
-end
-
-nc = netcdf(fname,'r');
-
-
-fprintf(fid,'nc = netcdf(''%s'',''noclobber'');\n\n',fname);
-fprintf(fid,'%% dimensions\n\n');
-
-% query all dimensions
-
-nd = ncdim(nc);
-
-for i=1:length(nd)
-  fprintf(fid,'nc(''%s'') = %d;\n',ncname(nd{i}),nd{i}(:));
-end
-
-fprintf(fid,'\n%% variables\n\n');
-
-% query all variables
-
-nv = ncvar(nc);
-
-for i=1:length(nv)
-  varname = ncname(nv{i});
-
-  fprintf(fid,'nc{''%s''} = nc%s(',varname,ncdatatype(nv{i}));
-   
-  % print all dimension of the variable
-  nd = ncdim(nv{i});
-  n = length(nd);
-  
-  for j=1:n
-    % dimension name in quotes    
-    fprintf(fid,'''%s''',ncname(nd{j}));
-
-    % separator
-    if (j~=n)
-      fprintf(fid,',');
-    end    
-  end
-  
-  fprintf(fid,');  %% %d elements \n',numel(nv{i}));
-
-  % print all attributes of the variable
-  
-  na = ncatt(nv{i});
-
-  for j=1:length(na)  
-    datatype = ncdatatype(na{j});
-    f = type2format(datatype);
-  
-    fprintf(fid,['nc{''%s''}.%s = nc%s(%s);\n'],varname,ncname(na{j}),datatype,att2str(na{j}));
-  end
-
-  fprintf(fid,'\n');  
-end
-
-fprintf(fid,'%% global attributes\n\n');
-
-% query all global attributes
-
-na = ncatt(nc);
-
-for j=1:length(na)  
-  datatype = ncdatatype(na{j});
-  f = type2format(datatype);
-  
-  fprintf(fid,['nc.%s = nc%s(%s);\n'],ncname(na{j}),datatype,att2str(na{j}));
-end
-
-fprintf(fid,'ncclose(nc)\n');
-
-if (fid ~= 1)
-  fclose(fid);
-end
-
-
-
-function f = type2format(datatype)
-
-if (strcmp(datatype,'char'))
-    f = '''%s''';
-elseif (strcmp(datatype,'byte'))
-    f = '%d';
-else
-    f = '%g';
-end
-  
-
-function s = att2str(att)
- datatype = ncdatatype(att);
- f = type2format(datatype);
- 
- n = length(att);
- val = att(:);
- 
- if (n == 1 | strcmp(datatype,'char'))
-   s = sprintf(f,val);   
- else
-   s = '[';
-   
-   for i=1:n-1
-     s = [s sprintf(f,val(i)) ' '];
-   end
-
-   s = [s  sprintf(f,val(n)) ']'];
-   
- end
- 
-
--- a/main/octcdf/ncfloat.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } ncfloat(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type ncfloat. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  ncfloat('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type float is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = ncfloat(varargin);
-
-c = {'float' varargin{:}};
-
--- a/main/octcdf/ncint.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } ncint(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type ncint. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  ncint('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type int is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = ncint(varargin);
-
-c = {'int' varargin{:}};
-
--- a/main/octcdf/nclong.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } nclong(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type nclong. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  nclong('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type long is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = nclong(varargin);
-
-c = {'long' varargin{:}};
-
--- a/main/octcdf/ncshort.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } ncshort(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type ncshort. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  ncshort('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type short is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = ncshort(varargin);
-
-c = {'short' varargin{:}};
-
--- a/main/octcdf/nctest.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-## Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} nctest
-## Tests the octcdf toolbox. Tests results are written to nctest.log. All tests
-## should pass.
-## @end deftypefn
-
-## Author: Alexander Barth (abarth@marine.usf.edu)
-
-
-
-function [passes,tests] = nctest
-   disp('writing test output to nctest.log');
-   test('nctest','normal','nctest.log');
-endfunction
-
-
-%!shared fname, nc
-%! fname = [tmpnam '-octcdf.nc'];
-%! nc = netcdf(fname,'c');
-
-%!# Test reading/writing dimension
-%!test
-%! nc('time') = 5;
-%! nc('space') = 3;
-%! assert(length(nc('time')),5);
-%! assert(length(nc('space')),3);
-
-%!# Test reading/writing global attributes
-%!test
-%! nc.byte_att = ncbyte(123);
-%! nc.short_att = ncshort(123);
-%! nc.int_att = ncint(123);
-%! nc.long_att = nclong(123);
-%! nc.float_att = ncfloat(123);
-%! nc.double_att = ncdouble(123.4);
-%! nc.string_att = "test string";
-%! assert(nc.byte_att,123)
-%! assert(nc.short_att,123)
-%! assert(nc.int_att,123)
-%! assert(nc.long_att,123)
-%! assert(nc.float_att,123)
-%! assert(nc.double_att,123.4)
-%! assert(nc.string_att,"test string")
-
-%!# Test reading/writing varaible of type byte
-%!test
-%! byte_var =  reshape(1:15,5,3);
-%! nc{'byte_var'} =  ncbyte('time','space');
-%! nc{'byte_var'}(:) = byte_var;
-%! assert(nc{'byte_var'}(:),byte_var);
-
-%!# Test reading/writing varaible of type short
-%!test
-%! short_var =  reshape(1:15,5,3);
-%! nc{'short_var'} =  ncshort('time','space');
-%! nc{'short_var'}(:) = short_var;
-%! assert(nc{'short_var'}(:),short_var);
-
-%!# Test reading/writing varaible of type int
-%!test
-%! int_var =  reshape(1:15,5,3);
-%! nc{'int_var'} =  ncint('time','space');
-%! nc{'int_var'}(:) = int_var;
-%! assert(nc{'int_var'}(:),int_var);
-
-%!# Test reading/writing varaible of type long
-%!test
-%! long_var =  reshape(1:15,5,3);
-%! nc{'long_var'} =  nclong('time','space');
-%! nc{'long_var'}(:) = long_var;
-%! assert(nc{'long_var'}(:),long_var);
-
-%!# Test reading/writing varaible of type float
-%!test
-%! float_var =  reshape(1:15,5,3)/10;
-%! nc{'float_var'} =  ncfloat('time','space');
-%! nc{'float_var'}(:) = float_var;
-%! assert(nc{'float_var'}(:),float_var,1e-5);
-
-%!# Test reading/writing varaible of type double
-%!test
-%! double_var =  reshape(1:15,5,3)/10;
-%! nc{'double_var'} =  ncdouble('time','space');
-%! nc{'double_var'}(:) = double_var;
-%! assert(nc{'double_var'}(:),double_var);
-
-%!# Test reading/writing varaible of type char
-%!test
-%! char_var = reshape('ajhkjhgkjhfdgkh',5,3);
-%! nc{'char_var'} =  ncchar('time','space');
-%! nc{'char_var'}(:) = char_var;
-%! assert(nc{'char_var'}(:),char_var);
-
-%!# Test reading/writing variable attributes
-%!test
-%! nv = nc{'int_var'};
-%! nv.byte_att = ncbyte(123);
-%! nv.short_att = ncshort(123);
-%! nv.int_att = ncint(123);
-%! nv.long_att = nclong(123);
-%! nv.float_att = ncfloat(123);
-%! nv.double_att = ncdouble(123.4);
-%! nv.string_att = "test string";
-%! assert(nv.byte_att,123)
-%! assert(nv.short_att,123)
-%! assert(nv.int_att,123)
-%! assert(nv.long_att,123)
-%! assert(nv.float_att,123)
-%! assert(nv.double_att,123.4)
-%! assert(nv.string_att,"test string")
-
-%!# Test ncdim
-%!test
-%! dimlist = ncdim(nc);
-%! assert(length(dimlist),2);
-%! assert(dimlist{1}(:),5);
-%! assert(dimlist{2}(:),3);
-
-%!# Test ncatt
-%!test
-%! attlist = ncatt(nc);
-%! assert(length(attlist),7);
-%! assert(ncname(attlist{1}),'byte_att');
-%! assert(ncdatatype(attlist{1}),'byte');
-%! assert(attlist{1}(:),123);
-
-%!# Test ncvar
-%!test
-%! varlist = ncvar(nc);
-%! assert(length(varlist),7);
-%! assert(ncname(varlist{1}),'byte_var');
-%! assert(ncdatatype(varlist{1}),'byte');
-
-%!# Test to write a variable by slices
-%!test
-%! imax = 10;
-%! jmax = 11;
-%! kmax = 12;
-%! nc('imax') = imax;
-%! nc('jmax') = jmax;
-%! nc('kmax') = kmax;
-%! sliced_var =  reshape(1:imax*jmax*kmax,imax,jmax,kmax);
-%! nc{'sliced_var'} =  ncdouble('imax','jmax','kmax');
-%! 
-%! for i=1:imax
-%!   nc{'sliced_var'}(i,:,:) = squeeze(sliced_var(i,:,:));
-%! end
-%! 
-%! sliced_var2 = nc{'sliced_var'}(:);
-%! 
-%! assert(sliced_var2 == sliced_var)
-
-%!# Test autoscale
-%!test
-%! var = rand(5,3);
-%! add_offset = 1; 
-%! scale_factor = .1;
-%!
-%! nc{'autoscale_var'} =  ncdouble('time','space'); 
-%! nc{'autoscale_var'}.add_offset = add_offset;
-%! nc{'autoscale_var'}.scale_factor = scale_factor;
-%! nc{'autoscale_var',1}(:) = var;     
-%!
-%! unscaled = nc{'autoscale_var'}(:);
-%! assert(var,scale_factor*unscaled+add_offset,1e-6);
-%!
-%! scaled = nc{'autoscale_var',1}(:);                          
-%! assert(var,scaled,1e-6);
-
-%!# Test autonan
-%!test
-%! nc{'variable_with_gaps'}=ncdouble('time'); 
-%! nv = nc{'variable_with_gaps'}; 
-%! nv = ncautonan(nv,1);
-%! nv.FillValue_ = 99; 
-%! nv(:) = NaN;
-%! 
-%! nv = ncautonan(nv,0);
-%! assert(all(nv(:) == 99))
-%! 
-%! nv = ncautonan(nv,1);
-%! assert(all(isnan(nv(:))))
-
-
-%!# Close file
-%!test
-%! ncclose(nc);
-%! delete(fname);
-
-
-%!# Test rename function
-%!test
-%! filename = [tmpnam '-octcdf.nc'];
-%! nf = netcdf(filename,'c');
-%! 
-%! nf('longitude') = 5;
-%! nf('latitude') = 5;
-%! 
-%! nf.old_name = 'example attribute';
-%! 
-%! d = ncdim(nf){1};
-%! ncname(d,'new_name');
-%! assert(ncname(d),'new_name')
-%! 
-%! a = ncatt(nf){1};
-%! ncname(a,'new_name');
-%! assert(ncname(a),'new_name');
-%! 
-%! nf{'old_name'} = ncdouble('new_name','latitude');
-%! v = nf{'old_name'};
-%! ncname(v,'new_name')
-%! assert(ncname(v),'new_name');
-%! ncclose(nf);
-%! delete(filename);
--- a/main/octcdf/nctype.m4	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-changecom(`/*', `*/')dnl 
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## @deftypefn {Loadable Function} {@var{ncvar} = } nc`'TYPE`'(@var{dimname_1},...,@var{dimname_N})
-## creates a netcdf variable of type nc`'TYPE. @var{dimname_1} is the name 
-## of the 1st netcdf dimension, and so on. The return value is a netcdf
-## variable object and must be affected to a netcdf file, before its content
-## can be defined.
-## 
-## Example:
-## @example
-## nc = netcdf('test.nc','w');
-## nc('lon') = 360;
-## nc('lat') = 180;
-## nc@{'var'@} =  nc`'TYPE`'('lon','lat');
-## @end example
-## A new 360 by 180 netcdf variable named 'var' of type TYPE is 
-## created in file 'test.nc'.
-## @end deftypefn
-## @seealso{netcdf}
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-function c = nc`'TYPE`'(varargin);
-
-c = {'TYPE' varargin{:}};
-
--- a/main/octcdf/netcdf_setup.m	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-## Copyright (C) 2005 Alexander Barth
-##
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-## -*- texinfo -*-
-## This script should be called from you .octaverc file if you have the
-## the dispatch function from octave-forge installed. It allows you 
-## to drop the "nc" prefix of various octcdf functions and to increase the
-## compatability with the Matlab NetCDF toolbox.
-
-## Author: Alexander Barth <abarth@marine.usf.edu>
-
-dispatch('close','ncclose','ncfile');
-dispatch('redef','ncredef','ncfile');
-dispatch('endef','endef','ncfile');
-dispatch('sync','ncsync','ncfile');
-
-dispatch('var','ncvar','ncfile');
-
-dispatch('att','ncatt','ncfile');
-dispatch('att','ncatt','ncvar');
-
-dispatch('dim','ncdim','ncfile');
-dispatch('dim','ncdim','ncvar');
-
-dispatch('name','ncname','ncfile');
-dispatch('name','ncname','ncvar');
-dispatch('name','ncname','ncatt');
-dispatch('name','ncname','ncdim');
-
-dispatch('datatype','ncdatatype','ncvar');
-dispatch('datatype','ncdatatype','ncatt');
-
-dispatch('autoscale','ncautoscale','ncvar');
-dispatch('autonan','ncautonan','ncvar');
--- a/main/octcdf/ov-ncatt.cc	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,252 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-
-
-#include "ov-netcdf.h"
-#include "ov-ncfile.h"
-#include "ov-ncvar.h"
-#include "ov-ncatt.h"
-
-
-
-//
-// octave_ncatt
-//
-
-octave_ncatt::octave_ncatt(octave_ncvar* ncvar, int attnump) {
-  int status;
-  char name[NC_MAX_NAME];
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
-# endif
-
-  nca = new ncatt_t;
-
-  set_ncfile(ncvar->get_ncfile());
-  set_ncvar(ncvar);
-  set_attnum(attnump);
-  set_varid(ncvar->get_varid());
-  set_ncid(ncvar->get_ncfile()->get_ncid());
-
-  status = nc_inq_attname(get_ncid(),get_varid(),get_attnum(),name);
-
-  if (status != NC_NOERR) {
-    error("Error while quering attribute: %s",nc_strerror(status));
-    return;
-  }
-
-  set_name(string(name));
-
-  read_info();
-}
-   
-
-octave_ncatt::octave_ncatt(octave_ncvar* ncvar, std::string attnamep) {
-  int status, attnum;
-
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
-# endif
-
-  nca = new ncatt_t;
-
-  set_ncfile(ncvar->get_ncfile());
-  set_ncvar(ncvar);
-  set_name(attnamep);
-  set_varid(ncvar->get_varid());
-  set_ncid(ncvar->get_ncfile()->get_ncid());
-
-  status = nc_inq_attid(get_ncid(),get_varid(),get_name().c_str(),&attnum);
-
-  if (status != NC_NOERR) {
-    error("Error while quering attribute: %s",nc_strerror(status));
-    return;
-  }
-
-  set_attnum(attnum);
-
-  read_info();
-}
- 
-
-
-octave_ncatt::octave_ncatt(octave_ncfile* ncfilep, int attnump) {
-  int status;
-  char name[NC_MAX_NAME];
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << "attm " << attnump<< std::endl;
-# endif
-
-  nca = new ncatt_t;
-
-  set_ncfile(ncfilep);
-  set_ncvar(NULL);
-  set_attnum(attnump);
-  set_varid(NC_GLOBAL);
-  set_ncid(get_ncfile()->get_ncid());
-
-
-  //octave_stdout << "ncid " << ncid << endl;
-
-  status = nc_inq_attname(get_ncid(),get_varid(),get_attnum(),name);
-
-  if (status != NC_NOERR) {
-    error("Error while quering attribute: %s",nc_strerror(status));
-    return;
-  }
-
-  set_name(string(name));
-  //octave_stdout << "attname " << attname << endl;
-
-  read_info();
-}
-   
-
-octave_ncatt::octave_ncatt(octave_ncfile* ncfilep, std::string attnamep) {
-  int status, attnum;
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
-# endif
-
-    nca = new ncatt_t;
-
-   set_ncfile(ncfilep);
-   set_ncvar(NULL);
-   set_name(attnamep);
-   set_varid(NC_GLOBAL);
-   set_ncid(get_ncfile()->get_ncid());
-
-
-   status = nc_inq_attid(get_ncid(),get_varid(),get_name().c_str(),&attnum);
-
-   if (status != NC_NOERR) {
-     error("Error while quering attribute: %s",nc_strerror(status));
-     return;
-   }
-
-   set_attnum(attnum);
-
-   read_info();
- }
- 
-
-// ncatt_var(:) = y
-
-octave_value octave_ncatt::subsasgn(const std::string & type,
-				    const LIST < octave_value_list > &idx,
-				    const octave_value & rhs)
-{
-  octave_value retval;
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "setting attribute value " << std::endl;
-# endif
-
-  if (type[0] != '(' || !idx.front()(0).is_magic_colon() ) {
-    error("A ncatt can only be referenced with a (:)");
-    return octave_value();
-  }
-
-  get_ncfile()->set_mode(DefineMode);
-
-  ov_nc_put_att(get_ncid(),get_varid(),get_name(),get_nctype(),rhs);
-
-# ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
-  retval = octave_value(this, count + 1);
-# else
-  retval = octave_value(clone());
-# endif
-
-  return retval;
-
-
-};
-
-// ncatt_var(:) 
-
-octave_value octave_ncatt::subsref(const std::string SUBSREF_STRREF type,
-			       const LIST < octave_value_list > &idx)
-{
-  octave_value retval;
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "getting attribute value " << std::endl;
-# endif
-
-  if (type[0] != '(' || !idx.front()(0).is_magic_colon() ) {
-    error("A ncatt can only be referenced with a (:)");
-    return octave_value();
-  }
-
-  retval = ov_nc_get_att(get_ncid(),get_varid(),get_name());
-
-  return retval.next_subsref(type, idx);
-}
-
-
-  void octave_ncatt::read_info() {
-  size_t length;
-  int status;
-  nc_type nctype;
-
-  status = nc_inq_att(get_ncid(),get_varid(),get_name().c_str(),&nctype,&length);
-  set_nctype(nctype);
-
-
-  if (status != NC_NOERR) {
-    error("Error while quering attribute: %s",nc_strerror(status));
-    return;
-  }
-
-  nca->dimvec.resize(1);
-  nca->dimvec(0) = length;
-  }
-
-
-  void octave_ncatt::print(std::ostream & os, bool pr_as_read_syntax) const {
-    os << "attname = " << get_name() << endl;;
-    os << "type = " << nctype2ncname(get_nctype()) << endl;;
-#   ifdef OV_NETCDF_VERBOSE
-    os << "attnum = " << get_attnum() << endl;;
-#   endif
-  }
-
-void octave_ncatt::rename(string new_name) {
-  int status;
-    
-  status = nc_rename_att(get_ncid(),get_varid(),get_name().c_str(), new_name.c_str()); 
-
-  if (status != NC_NOERR) {
-    error("Error while renaming attribute %s: %s", get_name().c_str(),
-	  nc_strerror(status));
-    return;
-  }
-
-  set_name(new_name);
-}
-
-
-DEFINE_OCTAVE_ALLOCATOR(octave_ncatt);
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncatt, "ncatt", "ncatt");
-
-
--- a/main/octcdf/ov-ncatt.h	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-#if !defined (octave_ncatt_int_h)
-#define octave_ncatt_int_h 1
-
-#include "ov-netcdf.h"
-
-typedef struct {
-  nc_type nctype;
-  dim_vector dimvec;
-  octave_ncfile* ncfile;
-  octave_ncvar* ncvar;
-  std::string attname;
-  int ncid,varid,attnum;
-}  ncatt_t ;
-
-
-class octave_ncatt:public octave_base_value {
-public:
-  octave_ncatt(void):octave_base_value(), nca(NULL) { } 
-
-  octave_ncatt(const octave_ncatt& ncatt_val):octave_base_value(), nca(ncatt_val.nca) { }
-
-  octave_ncatt(octave_ncvar* ncvarp, int attnump); 
-  octave_ncatt(octave_ncvar* ncvarp, std::string attnamep); 
-  octave_ncatt(octave_ncfile* ncvarp, int attnump);
-  octave_ncatt(octave_ncfile* ncvarp, std::string attnamep);
-
-  OV_REP_TYPE *clone(void) const { return new octave_ncatt(*this); }
-
-  octave_value subsasgn(const std::string & type,
-			const LIST < octave_value_list > &idx,
-			const octave_value & rhs);
-
-  octave_value subsref(const std::string SUBSREF_STRREF type,
-		       const LIST < octave_value_list > &idx);
-
-  octave_value_list do_multi_index_op(int, const octave_value_list &)
-  {
-    error("octave_object: do_multi_index_op(nargout,args)");
-    return octave_value_list();
-  }
-
-  ~octave_ncatt()  { }
- 
-  void read_info();
-
-  /* Query Interface for octave */
-
-  int ndims() const  { return dims().length(); }
-
-  octave_idx_type numel() const  { return dims().numel(); }
-
-  dim_vector dims() const {  return nca->dimvec; }
-
-  void print(std::ostream & os, bool pr_as_read_syntax) const;
-
-  bool is_constant(void) const  {
-    return true;
-  }
-  bool is_defined(void) const  {
-    return true;
-  }
-  bool is_map(void) const  {
-    return true;
-  }
-
-
-  nc_type get_nctype(void) const { return nca->nctype; };
-  std::string get_name() const { return nca->attname; };
-  octave_ncfile* get_ncfile() const { return nca->ncfile; };
-  octave_ncvar*  get_ncvar() const { return nca->ncvar; };
-  int get_ncid() const { return nca->ncid; };
-  int get_varid() const { return nca->varid; };
-  int get_attnum() const { return nca->attnum; };
-
-  void set_nctype(const nc_type& t)  { nca->nctype = t; } ;
-  void set_name(const std::string& t) { nca->attname = t; };
-  void set_ncfile(octave_ncfile* t)  { nca->ncfile = t; };
-  void set_ncvar(octave_ncvar* t)  { nca->ncvar = t; };
-  void set_ncid(const int& t)  { nca->ncid = t; };
-  void set_varid(const int& t)  { nca->varid = t; };
-  void set_attnum(const int& t)  { nca->attnum = t; };
-
-  void rename(string new_name);
-
-private:
-  ncatt_t* nca;
-
-
-  DECLARE_OCTAVE_ALLOCATOR 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
-};
-
-
-// end octave_ncatt
-
-
-#endif
-
-
-
-/*
-;;; Local Variables: ***
-;;; mode: C++ ***
-;;; End: ***
-*/
--- a/main/octcdf/ov-ncdim.cc	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-
-
-#include "ov-netcdf.h"
-#include "ov-ncfile.h"
-#include "ov-ncdim.h"
-
-
-
-//
-// octave_ncdim
-//
-
-
-octave_ncdim::octave_ncdim(octave_ncfile* ncfilep, int dimid) {
-  int status, unlimdimid;
-  char name[NC_MAX_NAME];
-  size_t len;
-
-#   ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "new dim " <<  __LINE__ << ":"  << __FUNCTION__ << " dimid " <<dimid<< std::endl;
-#  endif
-
-    ncd = new ncdim_t;
-
-     set_ncfile(ncfilep);
-     set_dimid(dimid);
-
-     //octave_stdout << "ncid " << ncid << endl;
-
-     status = nc_inq_dim(get_ncid(),get_dimid(),name,&len);
-
-       //status = nc_inq_dimname(get_ncid(),get_dimid(),name);
-    set_name(string(name));
-    set_length(len);
-
-    status = nc_inq_unlimdim(get_ncid(),&unlimdimid);
-
-    set_record(dimid == unlimdimid);
-
-    //     read_info();
-  }
-   
-
-
-// // ncdim_var(:) = y
-
-// octave_value octave_ncdim::subsasgn(const std::string & type,
-// 				const LIST < octave_value_list > &idx,
-// 				const octave_value & rhs)
-// {
-//   int status;
-//   octave_value retval;
-
-// # ifdef OV_NETCDF_VERBOSE
-//   octave_stdout << "setting attribute value " << std::endl;
-// # endif
-
-// # ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
-//   retval = octave_value(this, count + 1);
-// # else
-//   retval = octave_value(clone());
-// # endif
-//   return retval;
-// };
-
-// ncdim_var(:) 
-
-octave_value octave_ncdim::subsref(const std::string SUBSREF_STRREF type,
-			       const LIST < octave_value_list > &idx)
-{
-  octave_value retval;
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "getting dimension length " << std::endl;
-# endif
-
-
-  if (type[0] != '(' || !idx.front()(0).is_magic_colon() ) {
-    error("A ncdim can only be referenced with a (:)");
-    return octave_value();
-  }
-
-  return octave_value((int)get_length());
-
-  //  return retval.next_subsref(type, idx);
-}
-
-
-  void octave_ncdim::read_info() {
-
-  //dimvec.resize(length);
-  }
-
-
-  void octave_ncdim::print(std::ostream & os, bool pr_as_read_syntax) const {
-    os << "dimname = " << get_name() << endl;;
-    os << "length = " << get_length() << endl;;
-    os << "is_record = " << is_record() << endl;;
-  }
-
-void octave_ncdim::rename(string new_name) {
-  int status;
-    
-  status = nc_rename_dim(get_ncid(),get_dimid(), new_name.c_str()); 
-
-  if (status != NC_NOERR) {
-    error("Error while renaming dimension %s: %s", get_name().c_str(),
-	  nc_strerror(status));
-    return;
-  }
-
-  set_name(new_name);
-}
-
-
-DEFINE_OCTAVE_ALLOCATOR(octave_ncdim);
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncdim, "ncdim", "ncdim");
-
-
--- a/main/octcdf/ov-ncdim.h	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-#if !defined (octave_ncdim_int_h)
-#define octave_ncdim_int_h 1
-
-#include "ov-netcdf.h"
-
-typedef struct {
-  octave_ncfile* ncfile;
-  std::string dimname;
-  bool is_record;
-  int dimid;
-  size_t length;
-}  ncdim_t ;
-
-
-class octave_ncdim:public octave_base_value {
-public:
-   octave_ncdim(void):octave_base_value(), ncd(NULL) { } 
-
-  octave_ncdim(const octave_ncdim& ncdim_val):octave_base_value(), ncd(ncdim_val.ncd) { }
-
-  octave_ncdim(octave_ncfile* ncfile, int dimid);
-
-  OV_REP_TYPE *clone(void) const { return new octave_ncdim(*this); }
-
-//   octave_value subsasgn(const std::string & type,
-// 			const LIST < octave_value_list > &idx,
-// 			const octave_value & rhs);
-
-  octave_value subsref(const std::string SUBSREF_STRREF type,
-		       const LIST < octave_value_list > &idx);
-
-  octave_value_list do_multi_index_op(int, const octave_value_list &)
-  {
-    error("octave_object: do_multi_index_op(nargout,args)");
-    return octave_value_list();
-  }
-
-  ~octave_ncdim()  { 
-#  ifdef OV_NETCDF_VERBOSE
-    octave_stdout << "destruct " << std::endl;  
-#  endif
-  }
- 
-  void read_info();
-
-  /* Query Interface for octave */
-
-  int ndims() const  { return 1; }
-
-  octave_idx_type numel() const  { return  ncd->length; }
-
-  dim_vector dims() const {  return dim_vector(ncd->length,1); }
-
-
-  void print(std::ostream & os, bool pr_as_read_syntax) const;
-
-  bool is_constant(void) const  {
-    return true;
-  }
-  bool is_defined(void) const  {
-    return true;
-  }
-  bool is_map(void) const  {
-    return true;
-  }
-
-
-  std::string get_name() const { return ncd->dimname; };
-  octave_ncfile* get_ncfile() const { return ncd->ncfile; };
-  int get_dimid() const { return ncd->dimid; };
-  size_t get_length() const { return ncd->length; };
-  bool is_record() const { return ncd->is_record; };
-  int get_ncid() const { return ncd->ncfile->get_ncid(); };
-
-  void set_name(const std::string& t) { ncd->dimname = t; };
-  void set_ncfile(octave_ncfile* t)  { ncd->ncfile = t; };
-  void set_dimid(const int& t)  { ncd->dimid = t; };
-  void set_length(const size_t& t)  { ncd->length = t; };
-  void set_record(bool t){ ncd->is_record = t; };
-
-  void rename(string new_name);
-private:
-  ncdim_t* ncd;
-
-
-  DECLARE_OCTAVE_ALLOCATOR 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
-};
-
-
-// end octave_ncdim
-
-
-#endif
-
-
-
-/*
-;;; Local Variables: ***
-;;; mode: C++ ***
-;;; End: ***
-*/
--- a/main/octcdf/ov-ncfile.cc	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,464 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-
-#include "ov-netcdf.h"
-#include "ov-ncfile.h"
-#include "ov-ncvar.h"
-#include "ov-ncatt.h"
-#include "ov-ncdim.h"
-
-
-
-
-octave_ncfile::octave_ncfile(string filenamep, string open_mode):octave_base_value()
-{
-  int status;
-  int omode = NC_NOWRITE;
-  bool do_open;
-
-#     ifdef OV_NETCDF_VERBOSE
-      octave_stdout << "allocate ncfile_t " << std::endl;
-#    endif
-
-  nf = new ncfile_t;
-
-  nf->filename = filenamep;
-
-  if (open_mode == "r" || open_mode == "nowrite") {
-    do_open = true;
-    omode = NC_NOWRITE;
-  }
-  else if (open_mode == "w" || open_mode == "write") {
-    do_open = true;
-    omode = NC_WRITE;
-  }
-  else if (open_mode == "c" || open_mode == "clobber") {
-    do_open = false;
-    omode = NC_CLOBBER;
-  }
-  else if (open_mode == "nc" || open_mode == "noclobber") {
-    do_open = false;
-    omode = NC_NOCLOBBER;
-  }
-  else {
-    error("Unknown mode for opening netcdf file: %s",open_mode.c_str());
-    return;
-  }
-
-
-  if (do_open)  {
-      status = nc_open(nf->filename.c_str(), omode, &(nf->ncid));
-
-      if (status != NC_NOERR)
-	{
-	  error("Error while opening %s: %s", nf->filename.c_str(),
-		nc_strerror(status));
-	  return;
-	}
-
-
-      nf->mode = DataMode;
-
-    }
-  else {
-#     ifdef OCTCDF_64BIT_OFFSET 
-      omode = omode | NC_64BIT_OFFSET;
-#     endif
-
-      status = nc_create(nf->filename.c_str(), omode, &(nf->ncid));
-
-      if (status != NC_NOERR)
-	{
-	  error("Error while creating %s: %s", nf->filename.c_str(),
-		nc_strerror(status));
-	  return;
-	}
-
-
-      nf->mode = DefineMode;
-
-    }
-
-#     ifdef OV_NETCDF_VERBOSE
-      octave_stdout << "Open file " << nf->filename.c_str() 
-        << " omode " << omode << " mode " << (int) nf->mode << std::endl;
-#    endif
-
-    read_info();
-
-}
-
-
-void octave_ncfile::read_info() {
-
-  int status;
-
-  if (get_ncid() == -1) return;
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << __FILE__ <<  __LINE__ << ":" << __FUNCTION__ << std::endl;
-# endif
-
-  status = nc_inq(get_ncid(),&(nf->ndims),&(nf->nvars),&(nf->natts),&(nf->unlimdimid));
-
-  if (status != NC_NOERR)
-    error("Error while quering file: %s",nc_strerror(status));
-
-}
-
-
-// x.v = y     x(idx).v = y     x{idx}.v = y
-
-octave_value octave_ncfile::subsasgn(const std::string & type,
-				const LIST < octave_value_list > &idx,
-				const octave_value & rhs)
-{
-  int status;
-  octave_value retval;
-
-
-  //  check_args_string("octave_ncfile::subsasgn",idx.front());
-
-  if (error_state)
-    return octave_value();
-
-  std::string name = idx.front()(0).string_value();
-
-
-  switch (type[0]) {
-    case '.': {
-#       ifdef OV_NETCDF_VERBOSE
-	octave_stdout << "create attribute " << name << std::endl;
-#       endif
-
-	set_mode(DefineMode);
-
-	if (!rhs.is_cell()) {
-
-#           ifdef OV_NETCDF_VERBOSE
-	    octave_stdout << "type_id" << rhs.type_id() << endl;
-#           endif
-
-            nc_type nctype = ovtype2nctype(rhs);
-
-#          ifdef OV_NETCDF_VERBOSE
-	    octave_stdout << "type " << nctype << endl;
-#          endif
-
-          ov_nc_put_att(get_ncid(),NC_GLOBAL,name,nctype,rhs);
-	}
-        else {
-#       ifdef OV_NETCDF_VERBOSE
-	  octave_stdout << "define attribute from cell " << get_ncid() << std::endl;
-#       endif
-
-            Cell c =  rhs.cell_value();
-
-#           ifdef OV_NETCDF_VERBOSE
-	    octave_stdout << "type " << c.elem(0).string_value()<< endl;
-#           endif
-            nc_type nctype = ncname2nctype(c.elem(0).string_value());
-#           ifdef OV_NETCDF_VERBOSE
-	    octave_stdout << "type " << nctype << endl;
-#           endif
-     	    ov_nc_put_att(get_ncid(),NC_GLOBAL,name,nctype,c.elem(1));
-	}
-
-	break;
-      }
-    case '(': {
-	int dimid;
-#       ifdef OV_NETCDF_VERBOSE
-	octave_stdout << "create dimension " << name << std::endl;
-#       endif
-
-	set_mode(DefineMode);
-
-	status =
-	  nc_def_dim(get_ncid(),name.c_str(), (size_t) rhs.scalar_value(),
-		     &dimid);
-
-	if (status == NC_ENAMEINUSE) {
-	  octave_stdout << "dimension " << name.c_str() << " already exist" << std::endl;
-	}
-        else if (status != NC_NOERR) {
-	    error("Error while creating dimension %s: %s",
-		  name.c_str(), nc_strerror(status));
-	  }
-	break;
-      }
-    case '{': {
-	set_mode(DefineMode);
-
-	if (type.length() == 1) {
-	  if (rhs.class_name() == "ncvar") {
-	    // define a variables
-
-            // downcast from octave_value to octave_ncvar
-
-            const octave_ncvar& ncvar = (const octave_ncvar&)rhs.get_rep();
-#           ifdef OV_NETCDF_VERBOSE
-  	    octave_stdout << "define variable " << name <<  " nctype " << ncvar.get_nctype() << std::endl;
-#           endif
-
-            ov_nc_def_var(get_ncid(),name,ncvar.get_nctype(),ncvar.get_dimnames());
-
-	  } 
-	  else if (rhs.is_cell()) {
-#           ifdef OV_NETCDF_VERBOSE
-  	    octave_stdout << "define variable from cell " << std::endl;
-#           endif
-            Cell c =  rhs.cell_value();
-
-#           ifdef OV_NETCDF_VERBOSE
-	    octave_stdout << "type " << c.elem(0).string_value()<< endl;
-#           endif
-            nc_type nctype = ncname2nctype(c.elem(0).string_value());
-#           ifdef OV_NETCDF_VERBOSE
-	    octave_stdout << "type " << nctype << endl;
-#           endif
-
-            std::list<std::string> dimnames;
-
-            for (int i = 1; i < c.nelem(); i++) {
-              dimnames.push_back(c.elem(i).string_value());
-#             ifdef OV_NETCDF_VERBOSE
-	      octave_stdout << "dimention " << c.elem(i).string_value()<< endl;
-#             endif
-            }
-
-            ov_nc_def_var(get_ncid(),name,nctype,dimnames);
-
-	  }
-          else
-	    error("Error rhs of assignment should be an ncvar");
-	}
-	else {
-	  octave_ncvar *var = new octave_ncvar(this,name);
-
-          if (idx.front().length() == 2) 
-	    if (idx.front()(1).is_scalar_type()) 
-              var->autoscale() = idx.front()(1).scalar_value() == 1;
-
-
-            
-	  if (! error_state && idx.size () > 1)
-	    {
-	      // make necessary assignment with netcdf variable
-
-	      std::list<octave_value_list> new_idx (idx);
-	      new_idx.erase (new_idx.begin ());
-	      retval = var->subsasgn (type.substr(1), new_idx,rhs);
-	    }
-
-	}
-
-
-	break;
-      }
-      break;
-
-    }
-
-
-  // update characteristics
-
-  read_info();
-
-  // result of this assignement is the same 
-  // octave_ncfile object
-
-# ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
-  retval = octave_value(this, count + 1);
-# else
-  retval = octave_value(clone());
-# endif
-
-  return retval;
-
-
-};
-
-// x.v     x(idx).v     x{idx}.v
-
-octave_value octave_ncfile::subsref(const std::string SUBSREF_STRREF type,
-			       const LIST < octave_value_list > &idx)
-{
-  int dimid, status;
-  size_t length;
-  octave_value retval;
-
-  //  check_args_string("octave_ncfile::subsref",idx.front());
-
-  if (error_state)
-    return octave_value();
-
-  std::string name = idx.front()(0).string_value();
-
-  switch (type[0]) {
-    case '.': {
-#       ifdef OV_NETCDF_VERBOSE
-	octave_stdout << "getting attribute " << name << std::endl;
-#       endif
-
-	retval = ov_nc_get_att(get_ncid(),NC_GLOBAL,name);
-
-	break;
-      }
-    case '(':
-      {
-#       ifdef OV_NETCDF_VERBOSE
-        octave_stdout << "getting dimension " << name << std::endl;
-#       endif
-
-	status = nc_inq_dimid(get_ncid(),name.c_str(), &dimid);
-
-	if (status != NC_NOERR) {
-	  error("Error while querying dimension %s: %s",name.c_str(), nc_strerror(status));
-   	  return  octave_value();
-	}
-
-	// previously a call like nc('dimension name') return the size of the dimension,
-	// now it return the dimension object in order to be compatible with the 
-	// Matlab toolbox.
-
-#       if 0
- 	status = nc_inq_dimlen(get_ncid(), dimid, &length);
-
- 	if (status != NC_NOERR) {
- 	  error("Error while querying dimension %s: %s",name.c_str(), nc_strerror(status));
-    	  return  octave_value();
- 	}
- 	retval = octave_value(length);
-#       else
-	retval = octave_value(new octave_ncdim(this,dimid));
-#       endif
-
-	break;
-      }
-    case '{': {
-#         ifdef OV_NETCDF_VERBOSE
-	octave_stdout << "getting variable " << name << std::endl;
-#         endif
-
-	octave_ncvar *var = new octave_ncvar(this, name);
-
-	// determine if the variable need to be scaled
-
-        if (idx.front().length() == 2) {
-            var->autoscale() = idx.front()(1).scalar_value() == 1;
-	}
-
-	retval = var;
-	break;
-      }
-      break;
-
-    }
-
-  return retval.next_subsref(type, idx);
-}
-
-
-octave_ncfile::~octave_ncfile(void)
-{
-  // not a good idea to close file, since copies of ncfile are created 
-  // which are destroyed when the original ncfile object is still used
-  //  close();
-}
-
-void octave_ncfile::close(void) {
-  int status;
-#   ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "close file " << get_ncid() << std::endl;
-#   endif
-
-  if (get_ncid() == -1) return;
-
-  status = nc_close(get_ncid());
-
-   if (status != NC_NOERR)  {
-       error("Error closing file: %s", nc_strerror(status));
-     }
-
-  nf->ncid = -1;
-}
-
-void octave_ncfile::sync(void) {
-  int status;
-#   ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "sync file " << std::endl;
-#   endif
-
-  set_mode(DataMode);
-  status = nc_sync(get_ncid());
-
-  if (status != NC_NOERR)
-    {
-      error("Error syncronizing file: %s", nc_strerror(status));
-    }
-}
-
-
-void octave_ncfile::set_mode(Modes new_mode)
-{
-  int status;
-
-  if (new_mode != get_mode())
-    {
-      if (new_mode == DataMode)
-	  status = nc_enddef(get_ncid());
-      else
-	  status = nc_redef(get_ncid());
-
-      if (status != NC_NOERR)
-	  error("Error chaning mode: %s", nc_strerror(status));
-      else
-	  nf->mode = new_mode;
-    }
-
-
-}
-
-void octave_ncfile::print(std::ostream & os, bool pr_as_read_syntax = false) const
-{
-
-  os << "filename = " << get_filename() << std::endl;
-# ifdef OV_NETCDF_VERBOSE
-  os << "ncid = " << get_ncid() << std::endl;
-# endif
-  os << "nvars = " << get_nvars() << std::endl;
-  os << "natts = " << get_natts() << std::endl;
-  os << "ndims = " << get_ndims() << std::endl;
-  if (get_mode() == DataMode)
-    os << "mode = DataMode " << std::endl;
-  else
-    os << "mode = DefineMode " << std::endl;
-}
-
-
-
-
-DEFINE_OCTAVE_ALLOCATOR(octave_ncfile);
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncfile, "ncfile", "ncfile");
-
-
-// end octave_ncfile
-
--- a/main/octcdf/ov-ncfile.h	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-
-#if !defined (octave_ncfile_int_h)
-#define octave_ncfile_int_h 1
-
-#include "ov-netcdf.h"
-
-typedef struct {
-  int ncid;
-  std::string filename;
-  int natts, nvars, unlimdimid, ndims;
-  Modes mode;
-}  ncfile_t ;
-
-class octave_ncfile:public octave_base_value
-{
-public:
-  octave_ncfile(void):octave_base_value(), nf(NULL) {}
-
-  octave_ncfile(const octave_ncfile& ncfile_val):octave_base_value(), nf(ncfile_val.nf) { }
-
-  octave_ncfile(string filenamep, string open_mode);
-
-  OV_REP_TYPE *clone(void) const { return new octave_ncfile(*this); }
-
-// x.v = y     x(idx).v = y     x{idx}.v = y
-
-  octave_value subsasgn(const std::string & type,
-			const LIST < octave_value_list > &idx,
-			const octave_value & rhs);
-
-  // x.v     x(idx).v     x{idx}.v
-
-  octave_value subsref(const std::string SUBSREF_STRREF type,
-		       const LIST < octave_value_list > &idx);
-
-  octave_value_list do_multi_index_op(int, const octave_value_list &)
-  {
-    error("octave_object: do_multi_index_op(nargout,args)");
-    return octave_value_list();
-  }
-
-  ~octave_ncfile();
-
-  void close();
-
-  void sync();
-
-  void read_info();
-
-  int get_ncid() const { return nf->ncid; }
-  int get_nvars() const { return nf->nvars; }
-  int get_natts() const { return nf->natts; }
-  int get_ndims() const { return nf->ndims; }
-  std::string get_filename() const { return nf->filename; }
-  Modes get_mode() const  { return nf->mode; }
-
-  void set_mode(Modes new_mode);
-
-  void print(std::ostream & os, bool pr_as_read_syntax) const;
-
-  bool is_constant() const
-  {
-    return true;
-  }
-  bool is_defined() const
-  {
-    return true;
-  }
-  bool is_map() const
-  {
-    return true;
-  }
-
-private:
-  ncfile_t* nf;
-
-//   int ncid;
-//   std::string filename;
-//   int natts, nvars, unlimdimid, ndims;
-
-
-  DECLARE_OCTAVE_ALLOCATOR 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
-};
-
-
-
-// end octave_ncfile
-
-
-#endif
-
-
-
-/*
-;;; Local Variables: ***
-;;; mode: C++ ***
-;;; End: ***
-*/
--- a/main/octcdf/ov-ncvar.cc	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,492 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-
-#include "ov-netcdf.h"
-#include "ov-ncfile.h"
-#include "ov-ncvar.h"
-#include "ov-ncatt.h"
-
-
-
-//
-// Constructors of octave_ncvar
-//
-
-octave_ncvar::octave_ncvar(octave_ncfile* ncfilep, std::string varnamep) :octave_base_value() {
-  int status, varid;
-
-  ncv = new ncvar_t;
-
-  set_ncfile(ncfilep);
-  set_varname(varnamep);
-  set_ncid(ncfilep->get_ncid());
-
-  status = nc_inq_varid(get_ncid(),get_varname().c_str(), &varid);
-
-  if (status != NC_NOERR)  {
-    error("Error while querying variable %s: %s",
-	  get_varname().c_str(), nc_strerror(status));
-  }
-
-  set_varid(varid);
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "new variable " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
-# endif
-
-  read_info();
-
-  autoscale() = false;
-  autonan() = false;
-}
-
-
-octave_ncvar::octave_ncvar(octave_ncfile* ncfilep, int varidp):octave_base_value() {
-
-  ncv = new ncvar_t;
-
-  set_varid(varidp);
-  set_ncfile(ncfilep);
-  set_ncid(ncfilep->get_ncid());  
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "new variable " <<  __LINE__ << ":" << __FUNCTION__ << std::endl;
-# endif
-
-  read_info();
-
-  autoscale() = false;
-  autonan() = false;
-
-}
-
-// load charecteristics of netcdf variable from file
-
-void octave_ncvar::read_info() {
-
-  int status;
-  int dimids[NC_MAX_VAR_DIMS];
-  int ndims, natts;
-  char name[NC_MAX_NAME];
-  size_t length;
-  nc_type nctype;
-  dim_vector dimvec, ncdimvec;
-  std::list<std::string> dimnames;
-
-  if (get_varid() == -1) return;
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << __FILE__ <<  __LINE__ << ":" << __FUNCTION__ << std::endl;
-# endif
-
-  status = nc_inq_var(get_ncid(),get_varid(),name,&nctype,&ndims,dimids,&natts);
-
-  if (status != NC_NOERR)
-    error("Error while quering variable: %s",nc_strerror(status));
-
-  set_nctype(nctype);
-  set_natts(natts);
-
-  set_varname(string(name));
-  ncdimvec.resize(ndims);
-
-  // reverse dimids if FORTRAN_ORDER
-
-  if (STORAGE_ORDER == FORTRAN_ORDER) 
-    for (int i=0; i<ndims/2; i++) {
-      status = dimids[i];
-      dimids[i] = dimids[ndims-i-1];
-      dimids[ndims-i-1] = status;
-    }
-
-  for (int i=0; i<ndims; i++) {
-    status = nc_inq_dim(get_ncid(),dimids[i],name,&length);
-  
-    if (status != NC_NOERR)
-      error("Error while quering dimenstion: %s",nc_strerror(status));
-
-    set_dimid(i,dimids[i]);
-    dimnames.push_back(name);  
-    ncdimvec(i) = length;
-  }
-
-  // octave dimvec
-  // Number of dimensions is at least 2
-
-  dimvec.resize(max(ndims,2));
-
-  if (ndims > 1)
-    dimvec = ncdimvec;
-  else {
-    dimvec(1) = 1;
-
-    if (ndims == 1)
-      dimvec(0) = ncdimvec(0);
-    else 
-      dimvec(0) = 1;
-  }
-
-
-  ncv->dimvec = dimvec;
-  ncv->ncdimvec = ncdimvec;
-  set_dimnames(dimnames);
-}
-
-// Assigmnent of the type:
-// x.v = y     x(idx).v = y     x{idx}.v = y
-
-octave_value octave_ncvar::subsasgn(const std::string & type,
-			       const LIST < octave_value_list > &idx,
-			       const octave_value & rhs) {
-  octave_value scale_factor, add_offset, scaledrhs;
-  octave_value fillvalue;
-  octave_value retval;
-
-  switch (type[0])
-    {
-    case '.':
-      {
-	std::string name = idx.front()(0).string_value();
-
-	// convention of netcdf matlab toolbox
-        if (name == "FillValue_")
-	  name = "_FillValue";
-
-	get_ncfile()->set_mode(DefineMode);
-#       ifdef OV_NETCDF_VERBOSE
-	octave_stdout << "create attribute " << name << std::endl;
-#       endif
-
-
-	if (!rhs.is_cell()) {
-          nc_type nctype = ovtype2nctype(rhs);
-          ov_nc_put_att(get_ncid(),get_varid(),name,nctype,rhs);
-	}
-        else {
-#         ifdef OV_NETCDF_VERBOSE
-	  octave_stdout << "define attribute from cell " << get_ncid() << std::endl;
-#         endif
-
-          Cell c =  rhs.cell_value();
-          nc_type nctype = ncname2nctype(c.elem(0).string_value());
-   	  ov_nc_put_att(get_ncid(),get_varid(),name,nctype,c.elem(1));
-	}
-
-
-
-	break;
-      }
-    case '(':
-      {
-#       ifdef OV_NETCDF_VERBOSE
-	octave_stdout << "putting var " << std::endl;
-#       endif
-
-        scaledrhs = rhs;
-
-	// autoscale the retrieved variable if necessary
-	// the variables attributes "scale_factor" and "add_offset" are
-	// used for the linear scale if present.
-
-	if (autoscale()) {
-	  add_offset = ov_nc_get_att(get_ncid(),get_varid(),"add_offset");
-
-	  if (!add_offset.is_empty()) {
-	    scaledrhs = scaledrhs - add_offset;
-	  }
-
-	  scale_factor = ov_nc_get_att(get_ncid(),get_varid(),"scale_factor");
- 
-	  if (!scale_factor.is_empty()) {
-	    scaledrhs = scaledrhs / scale_factor;
-	  }
-	}
-
-
-	//
-	// replace NaN by _FillValue if requested
-	//
-
-	if (autonan()) {
-	  fillvalue = ov_nc_get_att(get_ncid(),get_varid(),"_FillValue");
-
-          if (!fillvalue.is_empty()) {
-            if ( scaledrhs.numel() == 1) {
-              if (isnan(scaledrhs.scalar_value())) 
-		scaledrhs = fillvalue;
-	    }
-            else
-	      for (int i=0; i < scaledrhs.numel(); i++) {
-		if (isnan(scaledrhs.array_value().xelem(i)))
-		  scaledrhs.array_value().xelem(i) = fillvalue.scalar_value();
-	      }
-	  }
-	}
-
-
-	get_ncfile()->set_mode(DataMode);
-	octave_value_list key_idx = *idx.begin();
-	std::list<Range> ranges = get_slice(key_idx);
-
-        if (error_state)  return retval;
- 
-	ov_nc_put_vars(get_ncid(),get_varid(),ranges,get_nctype(),scaledrhs);
-
-	retval = rhs;
-	break;
-      }
-    case '{':
-      {
-	error("octave_ncvar cannout be referenced with {}");
-	break;
-      }
-      break;
-
-    }
-
-  // update characteristics
-  read_info();
-
-# ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
-  retval = octave_value(this, count + 1);
-# else
-  retval = octave_value(clone());
-# endif
-
-  return retval;
-};
-
-
-// References of the type:
-// x.v     x(idx)     x{idx}
-
-octave_value octave_ncvar::subsref(const std::string SUBSREF_STRREF type,
-			      const LIST < octave_value_list > &idx)
-{
-  octave_value scale_factor, add_offset;
-  octave_value fillvalue;
-  octave_value retval;
-
-
-  switch (type[0])
-    {
-    case '.':
-      {
-	std::string name = idx.front()(0).string_value();
-
-	// convention of netcdf matlab toolbox
-        if (name == "FillValue_")
-	  name = "_FillValue";
-
-
-#       ifdef OV_NETCDF_VERBOSE
-	octave_stdout << "getting attribute " << name << std::endl;
-#       endif
-
-	retval = ov_nc_get_att(get_ncid(),get_varid(),name);
-
-	break;
-      }
-    case '(':
-      {
-#       ifdef OV_NETCDF_VERBOSE
-	octave_stdout <<  __LINE__ << ":"  << __FUNCTION__ << "getting var " << std::endl;
-#       endif
-	get_ncfile()->set_mode(DataMode);
-	octave_value_list key_idx = idx.front();
-	std::list<Range> ranges = get_slice(key_idx);
-
-        if (error_state)  return retval;
-
-	retval = ov_nc_get_vars(get_ncid(),get_varid(),ranges,get_nctype());
-
-	if (autonan()) {
-	  fillvalue = ov_nc_get_att(get_ncid(),get_varid(),"_FillValue");
-
-          if (!fillvalue.is_empty()) {
-            for (int i=0; i<retval.numel(); i++)
-	      if (retval.array_value().xelem(i) == fillvalue.scalar_value()) 
-	        retval.array_value().xelem(i) = octave_NaN;
-	  }
-	}
-
-
-	// autoscale the retrieved variable if necessary
-	// the variables attributes "scale_factor" and "add_offset" are
-	// used for the linear scale if present.
-
-	if (autoscale()) {
-	  scale_factor = ov_nc_get_att(get_ncid(),get_varid(),"scale_factor");
- 
-	  if (!scale_factor.is_empty()) {
-	    retval = retval * scale_factor;
-	  }
-
-	  add_offset = ov_nc_get_att(get_ncid(),get_varid(),"add_offset");
-	  if (!add_offset.is_empty()) {
-	    retval = retval + add_offset;
-	  }
-	}
-
-	break;
-      }
-    case '{':
-      {
-	error("octave_ncvar cannot not be indexed with {}");
-	break;
-      }
-      break;
-
-    }
-
-  // apply remaining subreference operator
-
-  return retval.next_subsref(type, idx);
-}
-
-
-void  octave_ncvar::print(std::ostream & os, bool pr_as_read_syntax = false) const
-{
-  int i;
-
-  os << "varname = \"" << get_varname() << "\"" << std::endl;
-  os << "type = " << nctype2ncname(get_nctype()) << endl;;
-# ifdef OV_NETCDF_VERBOSE
-  os << "ncid = " << get_ncid() << std::endl;
-  os << "varid = " << get_varid() << std::endl;
-# endif
-  os << "natts = " << get_natts() << std::endl;
-
-  os << "autoscale = " << (int)autoscale() << std::endl;
-  os << "autonan = " << (int)autonan() << std::endl;
-
-  os << "size = " << dims().str() << std::endl;
-  os << "ncsize = " << ncv->ncdimvec.str() << std::endl;
-
-//   os << "size = ";
-//   for (i=0; i<ndims()-1; i++) {
-//     os << ncv->dimvec(i) << " x ";
-//   }
-  
-//   os << ncv->dimvec(ndims()-1) << std::endl;
-
-  //  std::list<std::string> dimnames = get_dimnames();
-  std::list<std::string>::const_iterator it;
-
-  i=1;
-  for(it=ncv->dimnames.begin(); it!=ncv->dimnames.end(); ++it) {
-    os << "dimension " << i << " = "  << *it << std::endl;
-    os << "dimension id " << i << " = "  << ncv->dimids[i-1] << std::endl;
-    i=i+1;
-  } 
-
-
-}
-
-
-// determine the slice of the variable to read or to store depending 
-// on the ranges given in key_idx
-
-std::list<Range> octave_ncvar::get_slice(octave_value_list key_idx)
-{
-
-  //std::string key = key_idx(0).string_value ();
-
-  std::list<Range> ranges;
-  dim_vector dv;
-  dv.resize(ncndims());
-
-  // special case: if only one colone, then retrieve all data
-
-  if (key_idx.length() == 1 && key_idx(0).is_magic_colon())
-    {
-      for (int i = 0; i < ncndims(); i++)
-	{
-	  ranges.push_back(Range(1. , (double)dims()(i), 1.));
-	}
-    }
-  else
-    {
-      for (int i = 0; i < ncndims(); i++)
-	{
-	  if (key_idx(i).is_range())  {
-	      ranges.push_back(key_idx(i).range_value());
-	    }
-	  else if (key_idx(i).is_magic_colon()) {
-	      ranges.push_back(Range(1. , (double)dims()(i)));
-	    }
-	  else if (key_idx(i).is_real_scalar())  {
-              ranges.push_back(Range(key_idx(i).scalar_value(),key_idx(i).scalar_value()));
-	  }
-	  else if (key_idx(i).is_matrix_type())  {
-            Matrix m =  key_idx(i).matrix_value();
-
-            if (m.rows() != 1) m = m.transpose();
-              
-            Range r = Range(m(0),m(m.numel()-1),m(1)-m(0));
-
-            if (r.inc() <= 0) {
-   	      error("octcdf: indexes must be increasing");
-   	      return ranges;
-	    }
-
-            if (r.matrix_value() != m) {
-   	      error("octcdf: indexes must be contiguous");
-   	      return ranges;
-	    }
-
-            ranges.push_back(r);
-	  }
-          else {
- 	    error("octcdf: unknown index specification: type %s",key_idx(i).type_name().c_str());
-	    return ranges;
-	  }
-	}
-    }
-
-
-  if (STORAGE_ORDER == FORTRAN_ORDER)
-     ranges.reverse();
-
-
-  return ranges;
-}
-
-
-
-void octave_ncvar::rename(string new_name) {
-  int status;
-    
-  status = nc_rename_var(get_ncid(),get_varid(), new_name.c_str()); 
-
-  if (status != NC_NOERR) {
-    error("Error while renaming variable %s: %s", get_varname().c_str(),
-	  nc_strerror(status));
-    return;
-  }
-
-  set_varname(new_name);
-}
-
-DEFINE_OCTAVE_ALLOCATOR(octave_ncvar);
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncvar, "ncvar", "ncvar");
-
-// end octave_ncvar
-
--- a/main/octcdf/ov-ncvar.h	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-#if !defined (octave_ncvar_int_h)
-#define octave_ncvar_int_h 1
-
-#include "ov-netcdf.h"
-
-typedef struct {
-  std::list<std::string> dimnames;
-  int dimids[NC_MAX_VAR_DIMS];
-
-  //std::list <std::string> dimnames;
-  nc_type nctype;
-  int ncid;
-
-  // Octave-like dim_vector. A scale would have a dimension of 1x1
-  dim_vector dimvec;
-
-  // NetCDF-like dim_vector. A scale would have a dimension of 0
-  dim_vector ncdimvec;
-
-  int varid, natts;
-  octave_ncfile* ncfile;
-  std::string varname;
-  bool autoscale;
-  bool autonan;
-
-}  ncvar_t ;
-
-class octave_ncvar:public octave_base_value {
-public:
-  octave_ncvar(void):octave_base_value(), ncv(NULL) {}
-
-  octave_ncvar(const octave_ncvar& nc_val):octave_base_value(), ncv(nc_val.ncv) { }
-
-  octave_ncvar(octave_ncfile* ncfilep, int varid);
-   
-  octave_ncvar(octave_ncfile* ncfilep, std::string varnamep);
-
-  octave_ncvar(nc_type nctypep, std::list <std::string> dimnamesp):octave_base_value(), ncv(NULL) { }
-
-  OV_REP_TYPE *clone(void) const { return new octave_ncvar(*this); }
-
-// x.v = y     x(idx).v = y     x{idx}.v = y
-
-  octave_value subsasgn(const std::string & type,
-			const LIST < octave_value_list > &idx,
-			const octave_value & rhs);
-
-  octave_value subsref(const std::string SUBSREF_STRREF type,
-		       const LIST < octave_value_list > &idx);
-
-  octave_value_list do_multi_index_op(int, const octave_value_list &)
-  {
-    error("octave_object: do_multi_index_op(nargout,args)");
-    return octave_value_list();
-  }
-
-  ~octave_ncvar()  { }
- 
-  void read_info();
-
-  /* Query Interface for octave */
-
-  // Get dim_vector following Octave conventions
-
-  dim_vector dims() const { return ncv->dimvec; }
-
-  int ndims() const  { return dims().length(); }
-
-  octave_idx_type numel() const  { return dims().numel(); }
-
-  // Get dim_vector following NetCDF conventions
-
-  dim_vector ncdims() const {  return ncv->ncdimvec; }
-
-  int ncndims() const  { return ncdims().length(); }
-
-
-  void print(std::ostream & os, bool pr_as_read_syntax) const;
-
-  bool is_constant(void) const  {
-    return true;
-  }
-  bool is_defined(void) const  {
-    return true;
-  }
-  bool is_map(void) const  {
-    return true;
-  }
-
-  bool& autoscale() { return ncv->autoscale; };
-  bool autoscale() const { return ncv->autoscale; };
-
-  bool& autonan() { return ncv->autonan; };
-  bool autonan() const { return ncv->autonan; };
-
-  /* Query Interface for netcdf related information */
-
-  std::list<Range> get_slice(octave_value_list key_idx);
-
-  nc_type get_nctype(void) const { return ncv->nctype; };
-  octave_ncfile* get_ncfile() const { return ncv->ncfile; };
-  int get_varid() const { return ncv->varid; };
-  int get_ncid() const { return ncv->ncid; };
-  int get_natts() const { return ncv->natts; };
-  std::string get_varname() const { return ncv->varname; };
-  int get_dimid(int i) const { return ncv->dimids[i]; };
-  std::list<std::string> get_dimnames() const { return ncv->dimnames; };
-
-
-  void set_nctype(const nc_type t) { ncv->nctype = t; };
-  void set_ncfile(octave_ncfile* t) { ncv->ncfile = t; };
-  void set_varid(const int& t)  { ncv->varid = t; };
-  void set_ncid(const int& t)  { ncv->ncid = t; };
-  void set_natts(const int& t)  { ncv->natts = t; };
-  void set_varname(const std::string& t) { ncv->varname = t; };
-  void set_dimid(int i,int t) const { ncv->dimids[i] = t; };
-  void set_dimnames(const std::list<std::string> t) { ncv->dimnames = t; };
-
-  void rename(string new_name);
-
-  ncvar_t* ncv;
-
-private:
-
-  DECLARE_OCTAVE_ALLOCATOR 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
-};
-
-
-// end octave_ncvar
-
-#endif
-
-/*
-;;; Local Variables: ***
-;;; mode: C++ ***
-;;; End: ***
-*/
--- a/main/octcdf/ov-netcdf.cc	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1088 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-
-#include "ov-netcdf.h"
-#include "ov-ncfile.h"
-#include "ov-ncvar.h"
-#include "ov-ncatt.h"
-#include "ov-ncdim.h"
-
-
-#define CAST_DARRAY(arr) NDArray(arr)
-#define CAST_CARRAY(arr) charNDArray(arr)
-
-//
-// Reverse dimension vector
-//
-
-dim_vector reverse(dim_vector dv) {
-  dim_vector rdv = dv;
-
-  for (int i = 0; i < dv.length(); i++) {
-      rdv(i) = dv(dv.length() - i - 1);
-    }
-
-  return rdv;
-}
-
-static bool netcdf_type_loaded = false;
-
-void load_netcdf_type () {
-  octave_ncfile::register_type ();
-  octave_ncvar::register_type ();
-  octave_ncatt::register_type ();
-  octave_ncdim::register_type ();
-
-  netcdf_type_loaded = true;
-
-  // Lock constructor function in place, otherwise
-  // "nc=netcdf("file.nc","r"); clear functions; nc" generates a seg-fault!!
-
-  mlock("netcdf");
-  mlock("ncvar");
-  mlock("ncatt");
-  mlock("ncdim");
-}
-
-
-void check_args_string(std::string funname, octave_value_list args) {
-
-  for (int i=0; i< args.length(); i++) {
-    if (!args(i).is_string()) {
-      error("%s: all arguments should be string arguments",funname.c_str());
-    }
-  }  
-}
-
-
-
-
-
-DEFUN_DLD(netcdf, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} {@var{nc} = } netcdf(@var{filename},@var{mode}) \n\
-open or create a netcdf file given by @var{filename}. This function returns a netcdf file object. Possible values of @var{mode} are: \n\
-@itemize \n\
-@item \"r\", \"nowrite\": \
-opens an existing file in read-only mode. \n\
-@item \"w\", \"write\": \
-opens an existing file in read-write mode. \n\
-@item \"c\", \"clobber\": \
-creates a new file and possibly overwrites existing data sets. \n\
-@item \"nc\", \"noclobber\": \
-creates a new file but an existing data sets in the netcdf file cannot be overwritten.\n\
-@end itemize \n\
-@end deftypefn\n\
-@seealso{ncclose}\n")
-{
-  if (! netcdf_type_loaded )
-    load_netcdf_type ();
-
-  if (args.length() != 2) {
-      print_usage ();
-      return octave_value();
-  }
-
-  check_args_string("netcdf",args);
-
-  if (error_state)
-    return octave_value();
-
-
-  octave_ncfile *nc = new octave_ncfile(args(0).string_value(), args(1).string_value());
-
-  return octave_value(nc);
-}
-
-
-DEFUN_DLD(ncsync, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncsync(@var{nc}) \n\
-All changes are written to the disk.\n\
-@end deftypefn\n\
-@seealso{ncclose}\n")
-{
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-    ncfile.sync();
-  } else {
-    error("Error argument should be an ncfile");
-  }
-
-  return octave_value();
-}
-
-DEFUN_DLD(ncclose, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncclose(@var{nc}) \n\
-closes the netcdf file @var{nc} and all changes are written to the disk.\n\
-@end deftypefn\n\
-@seealso{netcdf,ncsync}\n")
-{
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-# ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "close file "  << std::endl;
-# endif
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-    ncfile.close();
-  } else {
-    error("Error argument should be an ncfile");
-  }
-
-  return octave_value();
-}
-
-DEFUN_DLD(ncredef, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncredef(@var{nc}) \n\
-Place an open NetCDF file in \"define\" mode, so that NetCDF entities can be added, renamed, modified, or deleted. With the octcdf toolbox, the \"define\" mode is entered automatically as needed.\n\
-@end deftypefn\n\
-@seealso{ncenddef}\n")
-{
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-    ncfile.set_mode(DefineMode);
-  } else {
-    error("Error argument should be an ncfile");
-  }
-
-  return octave_value();
-}
-
-
-
-DEFUN_DLD(ncenddef, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncenddef(@var{nc}) \n\
-Take an open NetCDF file out of \"define\" mode. The resulting state is called \"data\" mode. With the octcdf oolbox, the \"data\" mode is entered automatically as needed. \n\
-@end deftypefn\n\
-@seealso{ncredef}\n")
-{
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-    ncfile.set_mode(DataMode);
-  } else {
-    error("Error argument should be an ncfile");
-  }
-
-  return octave_value();
-}
-
-
-
-DEFUN_DLD(ncvar, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncvar(@var{nc}) \n\
-Creates a cell array of all variables in a NetCDF file. The content of a NetCDF variable can be accessed by using the \"(:)\" operator. \n\
-@end deftypefn\n\
-Example: \n\
-@example \n\
-nc = netcdf('test.nc','r'); \n\
-nv = ncvar(nc)@{1@}; % gets the first variable in test.nc \n\
-myvar = nv(:);     % copies the content of this NetCDF variable is myvar. \n\
-@end example \n\
-@seealso{ncatt,ncdim,ncname,ncdatatype}\n")
-{
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-
-    Cell  vars = Cell (dim_vector(1,ncfile.get_nvars()));
-
-    for (int i=0; i<ncfile.get_nvars(); i++) {
-      octave_ncvar *v = new octave_ncvar(&ncfile,i);
-      vars(i) = octave_value(v);
-    }
-
-    return octave_value(vars);
-  } 
-  else {
-    error("Error argument should be an ncfile");
-  }
-
-  return octave_value();
-}
-
-
-
-DEFUN_DLD(ncatt, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncatt(@var{nc}) \n\
-@deftypefnx {Loadable Function} ncatt(@var{nv}) \n\
-Creates a cell array of all global attributes of NetCDF file @var{nc} or all attributes of variable @var{nv}. The content of a NetCDF attribute can be accessed by using the \"(:)\" operator. \n\
-@end deftypefn\n\
-Example: \n\
-@example \n\
-nc = netcdf('test.nc','r'); \n\
-na = ncatt(nc)@{1@}; % gets the first global attribute in test.nc \n\
-myvar = na(:);     % copies the content of this NetCDF attribute is myvar. \n\
-@end example \n\
-@seealso{ncvar,ncdim,ncname,ncdatatype}\n")
-{
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-
-    Cell  vars = Cell (dim_vector(1,ncfile.get_natts()));
-
-    for (int i=0; i<ncfile.get_natts(); i++) {
-      octave_ncatt *v = new octave_ncatt(&ncfile,i);
-      vars(i) = octave_value(v);
-    }
-
-    return octave_value(vars);
-  } 
-  else if (args(0).class_name() == "ncvar") {
-    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
-
-    Cell  vars = Cell (dim_vector(1,ncvar.get_natts()));
-
-    for (int i=0; i<ncvar.get_natts(); i++) {
-      octave_ncatt *v = new octave_ncatt(&ncvar,i);
-      vars(i) = octave_value(v);
-    }
-
-    return octave_value(vars);
-  } 
-  else {
-    error("Error argument should be an ncfile or ncvar");
-  }
-
-  return octave_value();
-}
-
-DEFUN_DLD(ncdim, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncdim(@var{nc}) \n\
-@deftypefnx {Loadable Function} ncdim(@var{nv}) \n\
-Creates a cell array of all dimenstion in a NetCDF file. The length of the NetCDF length can be queried by using the \"(:)\" operator. \n\
-@end deftypefn\n\
-@seealso{ncvar}\n")
-{
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-
-    Cell  vars = Cell (dim_vector(1,ncfile.get_ndims()));
-
-    for (int i=0; i<ncfile.get_ndims(); i++) {
-      octave_ncdim *v = new octave_ncdim(&ncfile,i);
-      vars(i) = octave_value(v);
-    }
-
-    return octave_value(vars);
-  } 
-  else if (args(0).class_name() == "ncvar") {
-    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
-
-    //    Cell  vars = Cell (dim_vector(1,ncvar.ndims()));
-    Cell  vars = Cell (dim_vector(1,ncvar.ncdims().length() ));
-
-    for (int i=0; i < ncvar.ncdims().length(); i++) {
-      octave_ncdim *d = new octave_ncdim(ncvar.get_ncfile(),ncvar.get_dimid(i));
-      vars(i) = octave_value(d);
-    }
-    
-    return octave_value(vars);
-    
-  } 
-  else {
-    error("Error argument should be an ncfile or ncvar");
-  }
-
-  return octave_value();
-}
-
-
-
-DEFUN_DLD(ncname, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncname(@var{nc}) \n\
-@deftypefnx {Loadable Function} ncname(@var{nv}) \n\
-@deftypefnx {Loadable Function} ncname(@var{na}) \n\
-@deftypefnx {Loadable Function} ncname(@var{nd}) \n\
-@deftypefnx {Loadable Function} ncname(@var{nv},@var{new_name}) \n\
-@deftypefnx {Loadable Function} ncname(@var{na},@var{new_name}) \n\
-@deftypefnx {Loadable Function} ncname(@var{nd},@var{new_name}) \n\
-Gets the name of the NetCDF file @var{nc}, variable @var{nv}, attributes \n\
-@var{na} or dimension @var{nd}. If it is called with a second argument, the \n\
-corresponding NetCDF object will be renamed. Only variables, attributes and \n\
-dimensions can be renamed. \n\
-@end deftypefn\n\
-@seealso{ncvar,ncatt,ncdim}\n")
-{
-
-  if (args.length() > 2) {
-    print_usage ();
-    return octave_value();
-  }
-
-  if (args(0).class_name() == "ncfile") {
-    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
-
-    if (args.length() == 1) 
-      return octave_value(ncfile.get_filename());
-    else
-      error("Error: cannot rename a ncfile");
-  }
-
-  else if (args(0).class_name() == "ncvar") {
-    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
-
-    if (args.length() == 1) 
-      return octave_value(ncvar.get_varname());
-    else
-      ncvar.rename(args(1).string_value());
-  }
-
-  else if (args(0).class_name() == "ncatt") {
-    octave_ncatt& ncatt = (octave_ncatt&)args(0).get_rep();
-
-    if (args.length() == 1) 
-      return octave_value(ncatt.get_name());
-    else
-      ncatt.rename(args(1).string_value());
-  }
-
-  else if (args(0).class_name() == "ncdim") {
-    octave_ncdim& ncdim = (octave_ncdim&)args(0).get_rep();
-
-    if (args.length() == 1) 
-      return octave_value(ncdim.get_name());
-    else
-      ncdim.rename(args(1).string_value());
-
-  }
-  else {
-    error("Error argument should be an ncfile, ncvar, ncatt or ncdim");
-  }
-
-  return octave_value();
-}
-
-
-DEFUN_DLD(ncdatatype, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} ncdatatype(@var{nv}) \n\
-@deftypefnx {Loadable Function} ncdatatype(@var{na}) \n\
-Gets the datatype of the NetCDF variable @var{nv} or attributes @var{na}. \n\
-@end deftypefn\n\
-@seealso{ncvar,ncatt,ncdim}\n")
-{
-  nc_type type;
-
-  if (args.length() != 1) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() == "ncvar") {
-    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
-    type = ncvar.get_nctype();
-  }
-  else if (args(0).class_name() == "ncatt") {
-    octave_ncatt& ncatt = (octave_ncatt&)args(0).get_rep();
-    type = ncatt.get_nctype();
-  }
-  else {
-    error("Error argument should be an ncvar or ncatt");
-    return octave_value();
-  }
-
-  return octave_value(nctype2ncname(type));
-}
-
-
-
-DEFUN_DLD(ncautonan, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} @var{status} = ncautonan(@var{nv}) \n\
-@deftypefnx {Loadable Function} @var{nv} = ncautonan(@var{nv},@var{status}) \n\
-If ncautonan is called with one argument, it returns the autonan status of the  \n\
-NetCDF variable @var{nv}. With two arguments, it sets the autonan status to @var{status}.  \n\
-If autonan status is 1, all NaNs in the octave variable to store are replaced by the corresponding  \n\
-value of the _FillValue attribute. This feature is disabled if autonan is 0 (default). \n\
-@end deftypefn\n\
-@seealso{ncautoscale}\n")
-{
-
-  if (args.length() != 1 && args.length() != 2) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() != "ncvar" ) {
-      print_usage ();
-      return octave_value();
-    }
-
-   octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
-
-  if (args.length() == 1) {
-    return octave_value(ncvar.autonan());
-  }
-  else {
-     ncvar.autonan() = args(1).scalar_value() == 1;
-    return octave_value(ncvar.clone());
-  }
-}
-
-DEFUN_DLD(ncautoscale, args,, 
-"-*- texinfo -*-\n\
-@deftypefn {Loadable Function} @var{status} = ncautoscale(@var{nv}) \n\
-@deftypefnx {Loadable Function} @var{nv} = ncautoscale(@var{nv},@var{status}) \n\
-If ncautoscale is called with one argument, it returns the autoscale status of the  \n\
-NetCDF variable @var{nv}. With two arguments, it sets the autoscale status to @var{status}.  \n\
-If autoscale status is 1, octave variable to store are scaled by the corresponding  \n\
-value of the add_offset and scale_factor attribute:   \n\
-@example \n\
-octave_variable = scale_factor * netcdf_variable + add_offset  \n\
-@end example \n\
-This feature is disabled if autoscale is 0 (default). \n\
-@end deftypefn\n\
-@seealso{ncautoscale}\n")
-{
-
-  if (args.length() != 1 && args.length() != 2) {
-      print_usage ();
-      return octave_value();
-    }
-
-  if (args(0).class_name() != "ncvar" ) {
-      print_usage ();
-      return octave_value();
-    }
-
-   octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
-
-  if (args.length() == 1) {
-    return octave_value(ncvar.autoscale());
-  }
-  else {
-     ncvar.autoscale() = args(1).scalar_value() == 1;
-    return octave_value(ncvar.clone());
-  }
-}
-
-
-//
-// wrapper around the nc_get_att_* functions which provides directly an 
-// octave_value of the appropriate type
-// 
-
-octave_value ov_nc_get_att(int ncid, int varid,const std::string name) {
-  int status;
-  octave_value retval;
-  size_t lenp;
-  nc_type xtypep;
-
-  status =
-    nc_inq_att(ncid, varid,name.c_str(), &xtypep, &lenp);
-
-  if (status != NC_NOERR) {
-    // attrinute doesn't exist -> return an empty matrix
-    return octave_value(Matrix(0,0));
-  }
-
-  switch (xtypep)
-    {
-    case NC_CHAR:
-      {
-	char *var = new char[lenp + 1];
-	status =
-	  nc_get_att_text(ncid, varid,name.c_str(),
-			  var);
-        if (status  != NC_NOERR)                                      
-	  error("Error while retrieving attribute %s: %s",            
-	 	name.c_str(),nc_strerror(status));                    
-
-	var[lenp] = 0; 
-	retval = octave_value(var);
-	break;
-      }
-
-      // cpp macro to avoid repetetive code
-
-#define OV_NETCDF_ATT_CASE(netcdf_type,c_type,nc_get_att)		\
-      case netcdf_type:							\
-	{                                                               \
-	  c_type *var = new c_type[lenp];                               \
-	  status = nc_get_att(ncid,varid,name.c_str(),var);             \
-									\
-	  if (status  != NC_NOERR)                                      \
-	    error("Error while retrieving attribute %s: %s",            \
-		  name.c_str(),nc_strerror(status));                    \
-									\
-	  if (lenp == 1) {					        \
-	    retval = octave_value(*var);                                \
-	  } else {                                                      \
-	    ArrayN<double> arr =  ArrayN<double>(dim_vector(lenp));	\
-	    for (unsigned int i=0; i<lenp; i++) {                       \
-	      arr.xelem(i) = (double)var[i];                            \
-	    }                                                           \
-	    retval = octave_value(arr);                                 \
-	  }                                                             \
-									\
-	  delete var;                                                   \
-	  break;                                                        \
-	} 
-
-        OV_NETCDF_ATT_CASE(NC_BYTE,signed char,nc_get_att_schar)
-	OV_NETCDF_ATT_CASE(NC_SHORT,short,nc_get_att_short)
-	OV_NETCDF_ATT_CASE(NC_INT,int,nc_get_att_int)
-	OV_NETCDF_ATT_CASE(NC_FLOAT,float,nc_get_att_float)
-	OV_NETCDF_ATT_CASE(NC_DOUBLE,double,nc_get_att_double)
-	// for now int and long are the same in the netcdf library
-#if NC_INT!=NC_LONG
-	OV_NETCDF_ATT_CASE(NC_LONG,long,nc_get_att_long)
-#endif
-
-#undef OV_NETCDF_ATT_CASE
-
-	default: 
-      {
-        error("unkown netcdf type: %d",xtypep);
-
-      }
-    }       
-
-
-  return retval;
-
-}
-            
-
-void ov_nc_put_att(int ncid, int varid,const std::string name,
-   nc_type nctype,const octave_value rhs) {
-
-  int status,length;
-
-  //	    octave_stdout << "att2" << nctype << endl;
-
-  switch (nctype)  {
-    case NC_CHAR: {
-
-      status =
-	nc_put_att_text(ncid,varid, name.c_str(),
-			rhs.string_value().length(),
-			rhs.string_value().c_str());
-      break;
-      }
-
-#define OV_NETCDF_ATT_PUT_ARR_CASE(netcdf_type,c_type,nc_put_att) \
-    case netcdf_type: { \
-	c_type *var = ov_ctype<c_type>(rhs,length);   \
-	status = nc_put_att(ncid,varid, name.c_str(),nctype,(size_t)length,var); \
-        delete var; \
-	break; \
-    } \
-
-    OV_NETCDF_ATT_PUT_ARR_CASE(NC_BYTE,signed char,nc_put_att_schar)
-    OV_NETCDF_ATT_PUT_ARR_CASE(NC_SHORT,short,nc_put_att_short)
-    OV_NETCDF_ATT_PUT_ARR_CASE(NC_INT,int,nc_put_att_int)
-    OV_NETCDF_ATT_PUT_ARR_CASE(NC_FLOAT,float,nc_put_att_float)
-    OV_NETCDF_ATT_PUT_ARR_CASE(NC_DOUBLE,double,nc_put_att_double)
-      // for now int and long are the same in the netcdf library
-#if NC_INT!=NC_LONG
-    OV_NETCDF_ATT_PUT_ARR_CASE(NC_LONG,long,nc_put_att_long)
-#endif
-
-    default: {
-	status = NC_NOERR;
-	error("Unkown type of variable: %d", nctype);        
-    } 
-  }
-
-}
-
-
-
-octave_value ov_nc_get_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype) {
-
-  int ncndim = ranges.size();
-  octave_value retval;
-  long *start = new long[ncndim];
-  long *count = new long[ncndim];
-  long *stride = new long[ncndim];
-  long sliced_numel;
-  ArrayN<double> arr;
-  dim_vector sliced_dim_vector;
-  int status;
-  Array<int> perm_vector(ncndim);
-
-
-  sliced_dim_vector.resize(ncndim);
-
-  int i = 0;
-  std::list<Range>::const_iterator it;
-
-  for(it=ranges.begin(); it!=ranges.end(); ++it)
-    { 
-      start[i] =  (long int) (*it).min() - 1;
-      count[i] = (*it).nelem();
-      stride[i] = (long int) (*it).inc();
-      sliced_dim_vector(i) =  count[i];
-
-      // since Octave 2.9.3 Array<T>::permute expect a zero-
-      // based permuation vector while Octave 2.1.71 seems to 
-      // be happy with a one-based permutation vector
-
-#     ifdef OCTAVE_PERMVEC_ZEROBASED      
-      perm_vector(i) = ncndim-i-1;
-#     else
-      perm_vector(i) = ncndim-i;
-#     endif
-
-      i=i+1;
-    }
-
-  sliced_numel = sliced_dim_vector.numel();
-
-#define OV_NETCDF_GET_VAR_CASE(netcdf_type,c_type,nc_get_vars)		   \
-  case netcdf_type:							   \
-    {									   \
-      c_type *var = new c_type[sliced_numel];				   \
-      status =								   \
-	nc_get_vars(ncid, varid, (const size_t *) start,		   \
-		    (const size_t *) count,				   \
-		    (const ptrdiff_t *) stride, var);			   \
-									   \
-      if (status != NC_NOERR)						   \
-	error("Error while retrieving variable: %s", nc_strerror(status)); \
-									   \
-      arr = ArrayN < double >(reverse(sliced_dim_vector));		   \
-									   \
-      for (int i = 0; i < sliced_numel; i++)				   \
-	arr.xelem(i) = (double)var[i];					   \
-									   \
-      delete var;							   \
-                                                                           \
-      if (STORAGE_ORDER == FORTRAN_ORDER || ncndim == 1)	   		   \
-        retval = octave_value(CAST_DARRAY(arr));                           \
-      else                                                                 \
-        retval = octave_value(CAST_DARRAY(arr.permute(perm_vector)));	   \
-      break;								   \
-    }
-
-  switch (nctype) {
-
-      OV_NETCDF_GET_VAR_CASE(NC_BYTE,signed char,nc_get_vars_schar)
-      OV_NETCDF_GET_VAR_CASE(NC_SHORT,short,nc_get_vars_short)
-      OV_NETCDF_GET_VAR_CASE(NC_INT,int,nc_get_vars_int)
-      OV_NETCDF_GET_VAR_CASE(NC_FLOAT,float,nc_get_vars_float)
-      OV_NETCDF_GET_VAR_CASE(NC_DOUBLE,double,nc_get_vars_double)
-
-      case NC_CHAR: {
-
-	char *var = new char[sliced_numel];
-	status =
-	  nc_get_vars_text(ncid, varid, (const size_t *) start,
-			   (const size_t *) count,
-			   (const ptrdiff_t *) stride, var);
-
-	if (status != NC_NOERR)
-	  error("Error while retrieving variable: %s", nc_strerror(status));
-
-	//	charNDArray arr = charNDArray(reverse(sliced_dim_vector));
-	ArrayN<char> arr = ArrayN<char>(reverse(sliced_dim_vector));
-
-	for (int i = 0; i < sliced_numel; i++)
-	  arr.xelem(i) = (char)var[i];
-
-	delete var;
-
-        if (STORAGE_ORDER == FORTRAN_ORDER || ncndim == 1)                                  
-          retval = octave_value(CAST_CARRAY(arr),true);                                        
-        else                                                                 
-          retval = octave_value(CAST_CARRAY(arr.permute(perm_vector)),true);	  	   
-
-	break;
-      }
-
-    default:  {
-	error("Unkown type of variable: %d", nctype);
-        
-      } 
-    }
-
-
-  delete start;
-  delete count;
-  delete stride;
-
-  // in Octave, vectors are represented as matrices
-  // if the NetCDF object is a vector of length n
-  // we need to reshape it as a n-by-1 matrix
-
-  if (ncndim == 1) {
-    retval = retval.resize(dim_vector(retval.numel(),1));
-  }
-
-  return retval;
-}
-
-
-void ov_nc_put_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype,octave_value rhs) {
-
-
-  int ncndim = ranges.size();
-  octave_value retval;
-  long *start = new long[ncndim];
-  long *count = new long[ncndim];
-  long *stride = new long[ncndim];
-  long sliced_numel;
-  ArrayN<double> arr;
-  dim_vector sliced_dim_vector;
-  int status;
-
-  sliced_dim_vector.resize(ncndim);
-
-#  ifdef OV_NETCDF_VERBOSE
-  octave_stdout << " ov_nc_put_vars" << std::endl;
-#  endif
-
-  int i = 0;
-  std::list<Range>::const_iterator it;
-
-  for(it=ranges.begin(); it!=ranges.end(); ++it) { 
-      start[i] =  (long int) (*it).min() - 1;
-      count[i] = (*it).nelem();
-      stride[i] = (long int) (*it).inc();
-      sliced_dim_vector(i) =  count[i];
-      i=i+1;
-    }
-
-  Array<int> perm_vector(rhs.ndims());
-
-  for(i=0; i<rhs.ndims(); i++) { 
-    
-      // in Octave 2.9.3 Array<T>::permute expect a zero-
-      // based permuation vector while Octave 2.1.71 seems to 
-      // be happy with a one-based permutation vector
-
-#     ifdef OCTAVE_PERMVEC_ZEROBASED      
-      perm_vector(i) = rhs.ndims()-i-1;
-#     else
-      perm_vector(i) = rhs.ndims()-i;
-#     endif
-  }
-
-  sliced_numel = sliced_dim_vector.numel();
-
-#  ifdef OV_NETCDF_VERBOSE
-  octave_stdout << "type " <<  rhs.type_name() << NC_INT << std::endl;
-  octave_stdout << "class " <<  rhs.class_name() << std::endl;
-  octave_stdout << "id " <<  rhs.type_id() << std::endl;
-#  endif
-
-  // check number of elements
-
-  if (rhs.numel() !=  sliced_numel && rhs.numel() != 1) 
-    error("unexpected number of elements, found %d, expected 1 or %d ",rhs.numel(),sliced_numel);
-
-  switch (nctype)
-    {
-    case NC_CHAR:
-      {
-
-	char *var = new  char[sliced_numel];
-
-	if (rhs.numel() == 1) {
-	  for (int i = 0; i < sliced_numel; i++) {
-	      var[i] =  (char)rhs.string_value()[0];
-	    }
-	} 
-	else {
-	  ArrayN<char> arr =  rhs.char_array_value();
-									
-          if (STORAGE_ORDER == C_ORDER && ncndim > 1 )				
-	      arr = arr.permute(perm_vector);				
-
-	  for (int i = 0; i < sliced_numel; i++) {
-	      var[i] =  (char)arr.xelem(i);
-	    }
-	}
-
-	status =
-	  nc_put_vars_text(ncid, varid, (const size_t *) start,
-			   (const size_t *) count,
-			   (const ptrdiff_t *) stride, var);
-	delete var;
-
-	break;
-      }
-
-
-#define OV_NETCDF_PUT_VAR_CASE(netcdf_type,c_type,nc_put_vars)		\
-      case netcdf_type:							\
-	{								\
-	  if (rhs.is_string())						\
-	    error("unexpected type: %s",rhs.type_name().c_str());	\
-									\
-	  c_type *var = new  c_type[sliced_numel];			\
-									\
-	  if (rhs.is_scalar_type()) {					\
-	    for (int i = 0; i < sliced_numel; i++)  {	      	        \
-		var[i] =  (c_type)rhs.scalar_value();			\
-	      }								\
-	  }								\
-	  else {							\
-	    ArrayN<double> arr = rhs.array_value();                     \
-									\
-	    if (STORAGE_ORDER == C_ORDER && ncndim > 1)		       	\
-	      arr = arr.permute(perm_vector);				\
-									\
-	    for (int i = 0; i < sliced_numel; i++) {			\
-		var[i] =  (c_type)arr.xelem(i);				\
-	      }								\
-	  }								\
-									\
-	  /* status will checked at end of switch */			\
-									\
-	  status =							\
-	    nc_put_vars(ncid, varid, (const size_t *) start,		\
-			(const size_t *)count,				\
-			(const ptrdiff_t *)stride, var);		\
-	  delete var;							\
-									\
-	  break;							\
-	}                                                           
-
-      OV_NETCDF_PUT_VAR_CASE(NC_BYTE,signed char,nc_put_vars_schar) 
-      OV_NETCDF_PUT_VAR_CASE(NC_SHORT,short,nc_put_vars_short) 
-      OV_NETCDF_PUT_VAR_CASE(NC_INT,int,nc_put_vars_int) 
-      OV_NETCDF_PUT_VAR_CASE(NC_FLOAT,float,nc_put_vars_float) 
-      OV_NETCDF_PUT_VAR_CASE(NC_DOUBLE,double,nc_put_vars_double) 
-      // for now int and long are the same in the netcdf library
-#if NC_INT!=NC_LONG
-      OV_NETCDF_PUT_VAR_CASE(NC_LONG,long,nc_put_vars_long) 
-#endif
-
-#undef OV_NETCDF_PUT_VAR_CASE
-
-      default: {
-	status = NC_NOERR;
-	error("Unkown type of variable: %d", nctype);        
-      } 
-    }
-
-
-  if (status != NC_NOERR) {
-      error("Error while stroring variable: %s", nc_strerror(status));
-  }
-
-
-  delete start;
-  delete count;
-  delete stride;
-
-}
-
-
-void ov_nc_def_var(int ncid,std::string name,nc_type nctype, std::list<std::string> dimnames) {
-  int status;
-  int ndims=0;
-  int varid;
-
-  int dimids[NC_MAX_VAR_DIMS];
-
-  if (STORAGE_ORDER == FORTRAN_ORDER)
-    dimnames.reverse();
-
-  std::list<std::string>::const_iterator it;
-  for(it=dimnames.begin(); it!=dimnames.end(); ++it) {
-    status = nc_inq_dimid (ncid,(*it).c_str(), &dimids[ndims]);
-
-    if (status != NC_NOERR)
-      error("Error while querying dimension %s: %s",
-	    (*it).c_str(), nc_strerror(status));
-
-#   ifdef OV_NETCDF_VERBOSE
-    octave_stdout << "query dimname " << *it << " id " <<  dimids[ndims] << std::endl; 
-#   endif
-    ndims=ndims+1;
-  } 
-
-  status = nc_def_var(ncid,name.c_str(),nctype,
-		      ndims,dimids,&varid);
-
-  if (status == NC_ENAMEINUSE) {
-    octave_stdout << "variable " << name.c_str() << " already exist" << std::endl;
-  }
-  else if (status != NC_NOERR) {
-    error("Error while defining variable %s: %s",
-	  name.c_str(), nc_strerror(status));
-  }
-
-}
-
-
-
-
-
-
-
-
-
-nc_type ncname2nctype(std::string name) {
-
-  if (name == "byte")
-    return NC_BYTE;
-  else if (name == "char")
-    return NC_CHAR;
-  else if (name == "short")
-    return NC_SHORT;
-  else if (name == "int")
-    return NC_INT;
-  else if (name == "long")
-    return NC_LONG;
-  else if (name == "float")
-    return NC_FLOAT;
-  else if (name == "double")
-    return NC_DOUBLE;
-  else {
-    error("Unkown type: %s",name.c_str());
-    return NC_NAT ;
-  }
-}
-
-std::string nctype2ncname(nc_type type) {
-
-  switch (type) {
-    case NC_BYTE: {
-      return "byte";
-      break;
-    }
-    case NC_CHAR: {
-      return "char";
-      break;
-    }
-    case NC_SHORT: {
-      return "short";
-      break;
-    }
-    case NC_INT: {
-      return "int";
-      break;
-    }
-#   if NC_INT!=NC_LONG
-    case NC_LONG: {
-      return "long";
-      break;
-    }
-#   endif
-    case NC_FLOAT: {
-      return "float";
-      break;
-    }
-    case NC_DOUBLE: {
-      return "double";
-      break;
-    }
-    default: {
-      return "unkown type";
-      break;
-    }
-  }
-}
-
-
-
-// guess netcdf type from octave type
-
-nc_type ovtype2nctype(const octave_value& val) {
-
-  if (val.is_string()) 
-    return NC_CHAR;
-#ifdef HAVE_OCTAVE_INT
-  if (val.type_id() == octave_int8_scalar::static_type_id() ||
-      val.type_id() == octave_int8_matrix::static_type_id())
-    return NC_BYTE;
-  if (val.type_id() == octave_int16_scalar::static_type_id() ||
-      val.type_id() == octave_int16_matrix::static_type_id())
-    return NC_SHORT;
-  if (val.type_id() == octave_int32_scalar::static_type_id() ||
-      val.type_id() == octave_int32_matrix::static_type_id())
-    return NC_INT;
-  if (val.type_id() == octave_int64_scalar::static_type_id() ||
-      val.type_id() == octave_int64_matrix::static_type_id())
-    return NC_LONG;
-#endif
-  else
-    return NC_DOUBLE;
-}
-
-template <class ctype> ctype* ov_ctype(octave_value val,int& n) {
-  ctype* var;
-  n = val.numel();
-  var = new ctype[n];
-
-  if (n == 1) 
-    var[0] =  (ctype)val.scalar_value();
-  else {
-    for (int i = 0; i < n; i++) {			
-      var[i] =  (ctype)val.array_value().xelem(i);				
-    }								
-  }
-
-  return var;
-}
-
-
--- a/main/octcdf/ov-netcdf.h	Sun Aug 20 13:22:29 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
-  octcdf, a netcdf toolbox for octave 
-  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
-
-  This program is free software; you can redistribute it and/or
-  modify it under the terms of the GNU General Public License
-  as published by the Free Software Foundation; either version 2
-  of the License, or (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-*/
-
-
-#if !defined (octave_netcdf_int_h)
-#define octave_netcdf_int_h 1
-
-#include<iostream>
-#include <octave/config.h>
-#include<octave/oct.h>
-#include<octave/parse.h>
-#include<octave/dynamic-ld.h>
-#include<octave/oct-map.h>
-#include<octave/oct-stream.h>
-#include <octave/ov-base.h>
-#include<octave/ov-base-scalar.h>
-#include<vector>
-#include<string>
-#include <netcdf.h>
-#include <ArrayN.h>
-
-#ifdef HAVE_OCTAVE_INT
-#include "ov-uint64.h"
-#include "ov-uint32.h"
-#include "ov-uint16.h"
-#include "ov-uint8.h"
-#include "ov-int64.h"
-#include "ov-int32.h"
-#include "ov-int16.h"
-#include "ov-int8.h"
-#endif
-
-#include "ov-scalar.h"
-#include "ov-range.h"
-#include "ov-cell.h"
-
-#ifdef HAVE_SLLIST_H
-#define LIST SLList
-#define LISTSIZE length
-#define SUBSREF_STRREF
-#else
-#include <list>
-#define LIST std::list
-#define LISTSIZE size
-#define SUBSREF_STRREF &
-#endif
-
-
-#define STORAGE_ORDER 1
-#define FORTRAN_ORDER 0
-#define C_ORDER 1
-
-//#define OCTCDF_64BIT_OFFSET 
-
-//#define  OV_NETCDF_VERBOSE
-
-#ifdef HAVE_OCTAVE_21
-#define octave_idx_type int
-#else
-#define OCTAVE_PERMVEC_ZEROBASED 
-#endif
-
-
-#ifndef OV_REP_TYPE
-#define OV_REP_TYPE octave_value
-#endif
-
-//#define OCTAVE_VALUE_COUNT_CONSTRUCTOR
-
-using namespace std;
-
-
-
-dim_vector reverse(dim_vector dv);
-
-typedef enum { DefineMode = 0, DataMode = 1 } Modes;
-
-
-
-
-
-octave_value ov_nc_get_att(int ncid, int varid,const std::string name);
-void ov_nc_put_att(int ncid, int varid,const std::string name,nc_type nctype,const octave_value rhs);
-
-octave_value ov_nc_get_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype);
-void ov_nc_put_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype,octave_value rhs);
-void ov_nc_def_var(int ncid,std::string name,nc_type nctype, std::list<std::string> dimnames);
-
-
-void check_args_string(std::string funname, octave_value_list args);
-
-nc_type ovtype2nctype(const octave_value& val);
-nc_type ncname2nctype(std::string name);
-std::string nctype2ncname(nc_type type);
-
-template <class ctype> ctype* ov_ctype(octave_value val,int& n);
-
-#endif
-
-/*
-;;; Local Variables: ***
-;;; mode: C++ ***
-;;; End: ***
-*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/Makeconf.add	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,4 @@
+HAVE_NETCDF=@HAVE_NETCDF@
+OCTCDF_LIBS=@OCTCDF_LIBS@
+OCTCDF_CFLAGS=@OCTCDF_CFLAGS@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/Makeconf.base	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,92 @@
+
+## Makeconf is automatically generated from Makeconf.base and Makeconf.add
+## in the various subdirectories.  To regenerate, use ./autogen.sh to
+## create a new ./Makeconf.in, then use ./configure to generate a new
+## Makeconf.
+
+OCTAVE_FORGE = 1
+
+SHELL = @SHELL@
+
+canonical_host_type = @canonical_host_type@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+libdir = @libdir@
+datadir = @datadir@
+infodir = @infodir@
+includedir = @includedir@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALLOCT=octinst.sh
+
+DESTDIR =
+
+RANLIB = @RANLIB@
+STRIP = @STRIP@
+LN_S = @LN_S@
+MKOCTLINK = @MKOCTLINK@
+OCTLINK= @OCTLINK@
+
+AWK = @AWK@
+
+# Most octave programs will be compiled with $(MKOCTFILE).  Those which
+# cannot use mkoctfile directly can request the flags that mkoctfile 
+# would use as follows:
+#    FLAG = $(shell $(MKOCTFILE) -p FLAG)
+# The following flags are for compiling programs that are independent
+# of Octave.  How confusing.
+CC = @CC@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+CPICFLAG = @CPICFLAG@
+CXX = @CXX@
+CXXFLAGS = @CXXFLAGS@
+CXXPICFLAG = @CXXPICFLAG@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FPICFLAG = @FPICFLAG@
+
+OCTAVE = @OCTAVE@
+OCTAVE_VERSION = @OCTAVE_VERSION@
+MKOCTFILE = @MKOCTFILE@ -DHAVE_OCTAVE_$(ver) -v
+SHLEXT = @SHLEXT@
+
+@DEFHAVE_X@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+
+ver = @ver@
+MPATH = @mpath@
+OPATH = @opath@
+XPATH = @xpath@
+ALTMPATH = @altmpath@
+ALTOPATH = @altopath@
+
+HAVE_DO_FORTRAN_INDEXING = @HAVE_DO_FORTRAN_INDEXING@
+HAVE_PROPAGATE_EMPTY_MATRICES = @HAVE_PROPAGATE_EMPTY_MATRICES@
+HAVE_OK_TO_LOSE_IMAGINARY_PART = @HAVE_OK_TO_LOSE_IMAGINARY_PART@
+HAVE_ND_ARRAYS = @HAVE_ND_ARRAYS@
+TYPEID_HAS_CLASS = @TYPEID_HAS_CLASS@
+CLASS_HAS_LOAD_SAVE = @CLASS_HAS_LOAD_SAVE@
+HAVE_OCTAVE_MAP_INDEX = @HAVE_OCTAVE_MAP_INDEX@
+HAVE_OCTAVE_CONCAT = @HAVE_OCTAVE_CONCAT@
+HAVE_SWAP_BYTES = @HAVE_SWAP_BYTES@
+HAVE_OCTAVE_UPLUS = @HAVE_OCTAVE_UPLUS@
+
+MAKEINFO = @MAKEINFO@
+TEXI2DVI = @TEXI2DVI@
+TEXI2HTML = @TEXI2HTML@
+DVIPDF = @DVIPDF@
+DVIPS = @DVIPS@
+
+MKDOC = @MKDOC@
+MKTEXI = @MKTEXI@
+
+%.o: %.c ; $(MKOCTFILE) -c $<
+%.o: %.f ; $(MKOCTFILE) -c $<
+%.o: %.cc ; $(MKOCTFILE) -c $<
+%.oct: %.cc ; $(MKOCTFILE) $<
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/Makeconf.in	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,96 @@
+
+## Makeconf is automatically generated from Makeconf.base and Makeconf.add
+## in the various subdirectories.  To regenerate, use ./autogen.sh to
+## create a new ./Makeconf.in, then use ./configure to generate a new
+## Makeconf.
+
+OCTAVE_FORGE = 1
+
+SHELL = @SHELL@
+
+canonical_host_type = @canonical_host_type@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+libdir = @libdir@
+datadir = @datadir@
+infodir = @infodir@
+includedir = @includedir@
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALLOCT=octinst.sh
+
+DESTDIR =
+
+RANLIB = @RANLIB@
+STRIP = @STRIP@
+LN_S = @LN_S@
+MKOCTLINK = @MKOCTLINK@
+OCTLINK= @OCTLINK@
+
+AWK = @AWK@
+
+# Most octave programs will be compiled with $(MKOCTFILE).  Those which
+# cannot use mkoctfile directly can request the flags that mkoctfile 
+# would use as follows:
+#    FLAG = $(shell $(MKOCTFILE) -p FLAG)
+# The following flags are for compiling programs that are independent
+# of Octave.  How confusing.
+CC = @CC@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+CPICFLAG = @CPICFLAG@
+CXX = @CXX@
+CXXFLAGS = @CXXFLAGS@
+CXXPICFLAG = @CXXPICFLAG@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FPICFLAG = @FPICFLAG@
+
+OCTAVE = @OCTAVE@
+OCTAVE_VERSION = @OCTAVE_VERSION@
+MKOCTFILE = @MKOCTFILE@ -DHAVE_OCTAVE_$(ver) -v
+SHLEXT = @SHLEXT@
+
+@DEFHAVE_X@
+X_CFLAGS = @X_CFLAGS@
+X_LIBS = @X_LIBS@
+
+ver = @ver@
+MPATH = @mpath@
+OPATH = @opath@
+XPATH = @xpath@
+ALTMPATH = @altmpath@
+ALTOPATH = @altopath@
+
+HAVE_DO_FORTRAN_INDEXING = @HAVE_DO_FORTRAN_INDEXING@
+HAVE_PROPAGATE_EMPTY_MATRICES = @HAVE_PROPAGATE_EMPTY_MATRICES@
+HAVE_OK_TO_LOSE_IMAGINARY_PART = @HAVE_OK_TO_LOSE_IMAGINARY_PART@
+HAVE_ND_ARRAYS = @HAVE_ND_ARRAYS@
+TYPEID_HAS_CLASS = @TYPEID_HAS_CLASS@
+CLASS_HAS_LOAD_SAVE = @CLASS_HAS_LOAD_SAVE@
+HAVE_OCTAVE_MAP_INDEX = @HAVE_OCTAVE_MAP_INDEX@
+HAVE_OCTAVE_CONCAT = @HAVE_OCTAVE_CONCAT@
+HAVE_SWAP_BYTES = @HAVE_SWAP_BYTES@
+HAVE_OCTAVE_UPLUS = @HAVE_OCTAVE_UPLUS@
+
+MAKEINFO = @MAKEINFO@
+TEXI2DVI = @TEXI2DVI@
+TEXI2HTML = @TEXI2HTML@
+DVIPDF = @DVIPDF@
+DVIPS = @DVIPS@
+
+MKDOC = @MKDOC@
+MKTEXI = @MKTEXI@
+
+%.o: %.c ; $(MKOCTFILE) -c $<
+%.o: %.f ; $(MKOCTFILE) -c $<
+%.o: %.cc ; $(MKOCTFILE) -c $<
+%.oct: %.cc ; $(MKOCTFILE) $<
+HAVE_NETCDF=@HAVE_NETCDF@
+OCTCDF_LIBS=@OCTCDF_LIBS@
+OCTCDF_CFLAGS=@OCTCDF_CFLAGS@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/Makefile	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,85 @@
+
+sinclude Makeconf
+
+# assumptions to make if not using ./configure script
+ifndef OCTAVE_FORGE
+	MKOCTFILE=mkoctfile
+	MKOCTLINK=ln -s
+	OCTLINK=.oct
+
+#	Adapt the variables NETCDF_INC and NETCDF_LIB
+#       for octcdf with NetCDF support only (and not OPeNDAP).
+#	The folder NETCDF_INC should contain netcdf.h and
+#	the folder NETCDF_LIB should contain libnetcdf.a or 
+#	libnetcdf.so
+
+#	NETCDF_INC=/usr/include/netcdf-3
+#	NETCDF_LIB=/usr/lib/netcdf-3
+#	OCTCDF_CFLAGS := $(CPPFLAGS) -I$(NETCDF_INC)
+#	OCTCDF_LIBS := $(LDFLAGS) -L$(NETCDF_LIB) -lnetcdf
+
+#       For NetCDF with OpenDAP (version 3.5.2 or higher) support use 
+#	the following two lines instead
+        OCTCDF_LIBS=$(shell ncdap-config --libs)
+        OCTCDF_CFLAGS=$(shell ncdap-config --cflags) 
+
+
+#       If you use a version of octave 2.1.x, uncomment the following
+#       two lines
+
+#	HAVE_OCTAVE_21 = 1
+#	OCTCDF_CFLAGS := $(OCTCDF_CFLAGS) -DHAVE_OCTAVE_21
+
+	HAVE_NETCDF = yes
+	RM = rm -f
+endif
+
+NCTARGET = netcdf.oct
+
+NCSOURCES = ov-netcdf.cc ov-ncfile.cc ov-ncvar.cc ov-ncatt.cc ov-ncdim.cc 
+OBJECTS = $(patsubst %.cc,%.o,$(NCSOURCES))
+
+NCLINKTARGETS = $(patsubst %,%$(OCTLINK), \
+	ncclose ncredef ncenddef ncsync ncvar ncatt \
+	ncdim ncname ncdatatype ncautonan ncautoscale) 
+
+
+MFILES =  ncchar.m ncfloat.m nclong.m ncbyte.m ncdouble.m ncint.m ncshort.m 
+
+TARGETS = $(NCTARGET) $(NCLINKTARGETS)
+
+MOFLAGS = $(OCTCDF_CFLAGS)
+
+#
+# comment this line out if your octave installation does not have integer types.
+#
+MOFLAGS := $(MOFLAGS) -DHAVE_OCTAVE_INT
+
+EXTRALIBS = $(OCTCDF_LIBS) 
+
+ifeq ($(HAVE_NETCDF),yes)
+all: $(TARGETS)
+else
+all:
+endif
+
+mfiles: $(MFILES)
+
+$(NCLINKTARGETS) : $(NCTARGET)
+	$(RM) $@ ; \
+	$(MKOCTLINK) $(NCTARGET) $@
+
+ov-netcdf.o ov-ncfile.o ov-ncvar.o  ov-ncatt.o  ov-ncdim.o: ov-netcdf.h ov-ncfile.h ov-ncvar.h  ov-ncatt.h ov-ncdim.h
+
+$(NCTARGET) : $(OBJECTS)
+	$(MKOCTFILE)  -o $@ $(MOFLAGS) $(OBJECTS) $(EXTRALIBS)
+
+%.o:%.cc
+	$(MKOCTFILE) -c $< $(MOFLAGS) $(DEFINES)
+
+
+$(MFILES): nctype.m4
+	m4 --define=TYPE=$(patsubst nc%.m,%,$@) nctype.m4 > $@
+
+clean: ; -$(RM) *.o core* octave-core *.oct *.octlink *~ *.nc 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/autogen.sh	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,33 @@
+#! /bin/sh
+
+## Generate ./configure
+rm -f configure.in
+echo "dnl --- DO NOT EDIT --- Automatically generated by autogen.sh" > configure.in
+cat configure.base >> configure.in
+files=`find . -name configure.add -print`
+if test ! -z "$files" ; then
+  cat $files >> configure.in
+fi
+cat <<EOF >> configure.in
+  AC_OUTPUT(\$CONFIGURE_OUTPUTS)
+  dnl XXX FIXME XXX chmod is not in autoconf's list of portable functions
+  chmod 0771 octinst.sh
+  echo " "
+  echo "  \"\\\$prefix\" is \$prefix"
+  echo "  \"\\\$exec_prefix\" is \$exec_prefix"
+  AC_MSG_RESULT([\$STATUS_MSG
+
+find . -name NOINSTALL -print    # shows which toolboxes won't be installed
+])
+EOF
+
+autoconf && rm -f configure.in
+
+## Generate ./Makeconf.in
+rm -f Makeconf.in
+cp Makeconf.base Makeconf.in
+files=`find . -name Makeconf.add -print`
+if test ! -z "$files" ; then
+  cat $files >> Makeconf.in
+fi
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/configure.add	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,48 @@
+
+if test -e main/octcdf/NOINSTALL ; then
+
+    STATUS=noinstall
+
+else
+    AC_SUBST(HAVE_NETCDF)
+    AC_SUBST(OCTCDF_LIBS)
+    AC_SUBST(OCTCDF_CFLAGS)
+
+    OCTCDF_LIBS="$LDFLAGS"
+    OCTCDF_CFLAGS="$CPPFLAGS"
+
+    dnl first checking for opendap support
+
+    AC_MSG_CHECKING([for nc-dap])
+
+    if ncdap-config --version > /dev/null 2>&1; then
+          AC_MSG_RESULT([yes])
+          OCTCDF_LIBS="$OCTCDF_LIBS `ncdap-config --libs`"
+          OCTCDF_CFLAGS="$OCTCDF_CFLAGS `ncdap-config --cflags`"
+
+          HAVE_NETCDF=yes
+    else
+          AC_MSG_RESULT([no])          
+
+          dnl if no opendap, checking if the NetCDF library exists. 
+
+          AC_CHECK_LIB(netcdf,nc_open, HAVE_NETCDF=yes, HAVE_NETCDF=no,)
+
+          if test $HAVE_NETCDF = yes ; then
+            OCTCDF_LIBS="$OCTCDF_LIBS -lnetcdf"
+
+            dnl we have the libraries, no we have also the headers?
+            AC_CHECK_HEADER(netcdf.h, HAVE_NETCDF=yes, HAVE_NETCDF=no)
+          fi
+    fi
+
+    if test $HAVE_NETCDF = yes ; then
+	STATUS=yes
+    else
+	STATUS=no
+    fi
+
+fi
+
+STATUS_MSG="$STATUS_MSG
+   octcdf toolbox: $STATUS"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/configure.base	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,520 @@
+dnl The configure script is generated by autogen.sh from configure.base 
+dnl and the various configure.add files in the source tree.  Edit 
+dnl configure.base and reprocess rather than modifying ./configure.
+
+dnl autoconf 2.13 certainly doesn't work! What is the minimum requirement?
+AC_PREREQ(2.2)
+
+AC_INIT(configure.base)
+
+PACKAGE=octave-forge
+MAJOR_VERSION=0
+MINOR_VERSION=1
+PATCH_LEVEL=0
+
+dnl Kill caching --- this ought to be the default
+define([AC_CACHE_LOAD], )dnl
+define([AC_CACHE_SAVE], )dnl
+
+dnl uncomment to put support files in another directory
+dnl AC_CONFIG_AUX_DIR(admin)
+
+VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
+AC_SUBST(PACKAGE)
+AC_SUBST(VERSION)
+
+dnl need to find admin files, so keep track of the top dir.
+TOPDIR=`pwd`
+AC_SUBST(TOPDIR)
+
+dnl if mkoctfile doesn't work, then we need the following:
+dnl AC_PROG_CXX
+dnl AC_PROG_F77
+
+dnl Need C compiler regardless so define it in a way that
+dnl makes autoconf happy and we can override whatever we
+dnl need with mkoctfile -p.
+dnl XXX FIXME XXX should use mkoctfile to get CC and CFLAGS
+AC_PROG_CC
+
+dnl XXX FIXME XXX need tests for -p -c -s in mkoctfile.
+
+dnl *******************************************************************
+dnl Sort out mkoctfile version number and install paths
+
+dnl XXX FIXME XXX latest octave has octave-config so we don't
+dnl need to discover things here.  Doesn't have --exe-site-dir
+dnl but defines --oct-site-dir and --m-site-dir
+
+dnl Check for mkoctfile
+AC_CHECK_PROG(MKOCTFILE,mkoctfile,mkoctfile)
+test -z "$MKOCTFILE" &&	AC_MSG_WARN([no mkoctfile found on path])
+
+AC_SUBST(ver)
+AC_SUBST(subver)
+AC_SUBST(mpath)
+AC_SUBST(opath)
+AC_SUBST(xpath)
+AC_SUBST(altpath)
+AC_SUBST(altmpath)
+AC_SUBST(altopath)
+
+AC_ARG_WITH(path, 
+	[  --with-path             install path prefix],
+	[ path=$withval ])
+AC_ARG_WITH(mpath,
+	[  --with-mpath            override path for m-files],
+	[mpath=$withval])
+AC_ARG_WITH(opath,
+	[  --with-opath            override path for oct-files],
+	[opath=$withval])
+AC_ARG_WITH(xpath,
+	[  --with-xpath            override path for executables],
+	[xpath=$withval])
+AC_ARG_WITH(altpath, 
+	[  --with-altpath          alternative functions install path prefix],
+	[ altpath=$withval ])
+AC_ARG_WITH(altmpath,
+	[  --with-altmpath         override path for alternative m-files],
+	[altmpath=$withval])
+AC_ARG_WITH(altopath,
+	[  --with-altopath         override path for alternative oct-files],
+	[altopath=$withval])	
+
+if test -n "$path" ; then
+   test -z "$mpath" && mpath=$path 
+   test -z "$opath" && opath=$path/oct 
+   test -z "$xpath" && xpath=$path/bin
+   test -z "$altpath" && altpath=$path-alternatives
+fi
+
+if test -n "$altpath" ; then
+   test -z "$altmpath" && altmpath=$altpath 
+   test -z "$altopath" && altopath=$altpath/oct 
+fi
+
+dnl Don't query if path/ver are given in the configure environment
+#if test -z "$mpath" || test -z "$opath" || test -z "$xpath" || test -z "$altmpath" || test -z "$altopath" || test -z "$ver" ; then
+if test -z "$mpath" || test -z "$opath" || test -z "$xpath" || test -z "$ver" ; then
+   dnl Construct program to get mkoctfile version and local install paths
+   cat > conftest.cc <<EOF
+#include <octave/config.h>
+#include <octave/version.h>
+#include <octave/defaults.h>
+
+#define INFOV "\nINFOV=" OCTAVE_VERSION "\n"
+
+#define INFOH "\nINFOH=" OCTAVE_CANONICAL_HOST_TYPE "\n"
+
+#ifdef OCTAVE_LOCALVERFCNFILEDIR
+# define INFOM "\nINFOM=" OCTAVE_LOCALVERFCNFILEDIR "\n"
+#else
+# define INFOM "\nINFOM=" OCTAVE_LOCALFCNFILEPATH "\n"
+#endif
+
+#ifdef OCTAVE_LOCALVEROCTFILEDIR
+# define INFOO "\nINFOO=" OCTAVE_LOCALVEROCTFILEDIR "\n"
+#else
+# define INFOO "\nINFOO=" OCTAVE_LOCALOCTFILEPATH  "\n"
+#endif
+
+#ifdef OCTAVE_LOCALVERARCHLIBDIR
+# define INFOX "\nINFOX=" OCTAVE_LOCALVERARCHLIBDIR  "\n"
+#else
+# define INFOX "\nINFOX=" OCTAVE_LOCALARCHLIBDIR  "\n"
+#endif
+
+const char *infom = INFOM;
+const char *infoo = INFOO;
+const char *infox = INFOX;
+const char *infoh = INFOH;
+const char *infov = INFOV;
+EOF
+
+   dnl Compile program perhaps with a special version of mkoctfile
+   $MKOCTFILE conftest.cc || AC_MSG_ERROR(Could not run $MKOCTFILE)
+
+   dnl Strip the config info from the compiled file
+   eval `strings conftest.o | grep "^INFO.=" | sed -e "s,//.*$,,"`
+   rm -rf conftest*
+
+   dnl set the appropriate variables if they are not already set
+   ver=`echo $INFOV | sed -e "s/\.//" -e "s/\..*$//"`
+   subver=`echo $INFOV | sed -e "[s/^[^.]*[.][^.]*[.]//]"`
+   alt_mbase=`echo $INFOM | sed -e "[s,\/[^\/]*$,,]"`
+   alt_obase=`echo $INFOO | sed -e "[s,/site.*$,/site,]"`
+   test -z "$mpath" && mpath=$INFOM/octave-forge
+   test -z "$opath" && opath=$INFOO/octave-forge
+   test -z "$xpath" && xpath=$INFOX
+   test -z "$altmpath" && altmpath=$alt_mbase/octave-forge-alternatives/m
+   test -z "$altopath" && altopath=$alt_obase/octave-forge-alternatives/oct/$INFOH
+fi
+
+dnl *******************************************************************
+
+dnl XXX FIXME XXX Should we allow the user to override these?
+dnl Do we even need them?  The individual makefiles can call mkoctfile -p
+dnl themselves, so the only reason to keep them is for configure, and
+dnl for those things which are not built using mkoctfile (e.g., aurecord)
+dnl but it is not clear we should be using octave compile flags for those.
+
+dnl C compiler and flags
+AC_MSG_RESULT([retrieving compile and link flags from $MKOCTFILE])
+CC=`$MKOCTFILE -p CC`
+CFLAGS=`$MKOCTFILE -p CFLAGS`
+CPPFLAGS=`$MKOCTFILE -p CPPFLAGS`
+CPICFLAG=`$MKOCTFILE -p CPICFLAG`
+LDFLAGS=`$MKOCTFILE -p LDFLAGS`
+LIBS=`$MKOCTFILE -p LIBS`
+AC_SUBST(CC)
+AC_SUBST(CFLAGS)
+AC_SUBST(CPPFLAGS)
+AC_SUBST(CPICFLAG)
+
+dnl Fortran compiler and flags
+F77=`$MKOCTFILE -p F77`
+FFLAGS=`$MKOCTFILE -p FFLAGS`
+FPICFLAG=`$MKOCTFILE -p FPICFLAG`
+AC_SUBST(F77)
+AC_SUBST(FFLAGS)
+AC_SUBST(FPICFLAG)
+
+dnl C++ compiler and flags
+CXX=`$MKOCTFILE -p CXX`
+CXXFLAGS=`$MKOCTFILE -p CXXFLAGS`
+CXXPICFLAG=`$MKOCTFILE -p CXXPICFLAG`
+AC_SUBST(CXX)
+AC_SUBST(CXXFLAGS)
+AC_SUBST(CXXPICFLAG)
+
+dnl *******************************************************************
+
+dnl Check for features of your version of mkoctfile.
+dnl All checks should be designed so that the default
+dnl action if the tests are not performed is to do whatever
+dnl is appropriate for the most recent version of Octave.
+
+dnl Define the following macro:
+dnl    OF_CHECK_LIB(lib,fn,true,false,helpers)
+dnl This is just like AC_CHECK_LIB, but it doesn't update LIBS
+AC_DEFUN(OF_CHECK_LIB,
+[save_LIBS="$LIBS"
+AC_CHECK_LIB($1,$2,$3,$4,$5)
+LIBS="$save_LIBS"
+])
+
+dnl Define the following macro:
+dnl    TRY_MKOCTFILE(msg,program,action_if_true,action_if_false)
+dnl
+AC_DEFUN(TRY_MKOCTFILE,
+[AC_MSG_CHECKING($1)
+cat > conftest.cc << EOF
+#include <octave/config.h>
+$2
+EOF
+ac_try="$MKOCTFILE -c conftest.cc"
+if AC_TRY_EVAL(ac_try) ; then
+   AC_MSG_RESULT(yes)
+   $3
+else
+   AC_MSG_RESULT(no)
+   $4
+fi
+])
+
+dnl
+dnl Check if F77_FUNC works with MKOCTFILE
+dnl
+TRY_MKOCTFILE([for F77_FUNC],
+[int F77_FUNC (hello, HELLO) (const int &n);],,
+[MKOCTFILE="$MKOCTFILE -DF77_FUNC=F77_FCN"])
+
+dnl
+dnl Check if octave still uses SLList.h
+dnl
+TRY_MKOCTFILE([for SLList.h],[#include <octave/SLList.h>],
+[MKOCTFILE="$MKOCTFILE -DHAVE_SLLIST_H"],)
+
+dnl
+dnl Check if octave has lo_ieee_nan_value
+dnl
+TRY_MKOCTFILE([for lo_ieee_nan_value],
+[ #include <octave/lo-ieee.h>
+int test(void) { lo_ieee_nan_value(); }],,
+[MKOCTFILE="$MKOCTFILE -DUSE_OCTAVE_NAN"])
+
+dnl
+dnl Check if octave is needs octave_idx_type
+dnl
+TRY_MKOCTFILE([for octave_idx_type],
+[#include <octave/oct-types.h>
+octave_idx_type test(void) { octave_idx_type idx = 1; return idx; }],,
+[MKOCTFILE="$MKOCTFILE -Doctave_idx_type=int"])
+
+dnl
+dnl Check if octave uses quit.h
+dnl
+TRY_MKOCTFILE([for quit.h],[#include <octave/quit.h>],,
+[MKOCTFILE="$MKOCTFILE -DNEED_OCTAVE_QUIT"])
+
+dnl **********************************************************
+
+dnl Evaluate an expression in octave
+dnl
+dnl OCTAVE_EVAL(expr,var) -> var=expr
+dnl
+AC_DEFUN(OCTAVE_EVAL,
+[AC_MSG_CHECKING([for $1 in Octave])
+$2=`echo "disp($1)" | $OCTAVE -qf`
+AC_MSG_RESULT($$2)
+AC_SUBST($2)
+])
+
+dnl Check status of an octave variable
+dnl
+dnl OCTAVE_CHECK_EXIST(variable,action_if_true,action_if_false)
+dnl
+AC_DEFUN(OCTAVE_CHECK_EXIST,
+[AC_MSG_CHECKING([for $1 in Octave])
+if test `echo 'disp(exist("$1"))' | $OCTAVE -qf`X != 0X ; then
+   AC_MSG_RESULT(yes)
+   $2
+else
+   AC_MSG_RESULT(no)
+   $3
+fi
+])
+
+dnl should check that $(OCTAVE) --version matches $(MKOCTFILE) --version
+AC_CHECK_PROG(OCTAVE,octave,octave)
+OCTAVE_EVAL(OCTAVE_VERSION,OCTAVE_VERSION)
+
+dnl grab canonical host type so we can write system specific install stuff
+OCTAVE_EVAL(octave_config_info('canonical_host_type'),canonical_host_type)
+
+dnl grab SHLEXT from octave config
+OCTAVE_EVAL(octave_config_info('SHLEXT'),SHLEXT)
+
+AC_PROG_LN_S
+AC_PROG_INSTALL
+AC_PROG_RANLIB
+
+dnl Use $(COPY_FLAGS) to set options for cp when installing .oct files.
+COPY_FLAGS="-Rfp"
+case "$canonical_host_type" in
+    *-*-linux*)
+        COPY_FLAGS="-fdp"
+    ;;
+esac
+AC_SUBST(COPY_FLAGS)
+
+dnl Use $(STRIP) in the makefile to strip executables.  If not found, 
+dnl STRIP expands to ':', which in the makefile does nothing.
+dnl Don't need this for .oct files since mkoctfile handles them directly
+STRIP=${STRIP-strip}
+AC_CHECK_PROG(STRIP,$STRIP,$STRIP,:)
+
+dnl Strip on windows, don't strip on Mac OS/X or IRIX
+dnl For the rest, you can force strip using MKOCTFILE="mkoctfile -s"
+dnl or avoid strip using STRIP=: before ./configure
+case "$canonical_host_type" in
+    powerpc-apple-darwin*|*-sgi-*)
+	STRIP=:
+    ;;
+    *-cygwin-*|*-mingw-*) 
+	MKOCTFILE="$MKOCTFILE -s" 
+    ;;
+esac
+
+dnl Things needed to link to X11 programs
+dnl defines X_CFLAGS, X_LIBS
+AC_SUBST(DEFHAVE_X)
+AC_SUBST(X_LIBS)
+AC_SUBST(X_CFLAGS)
+AC_PATH_XTRA
+if test "$no_x" = yes ; then
+	DEFHAVE_X=
+	XSTATUS="no (plot/g{input,text,zoom,rab} will not work)"
+else
+	DEFHAVE_X="HAVE_X=1"
+	X_LIBS="$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS"
+	XSTATUS="yes"
+fi
+
+OCTAVE_CHECK_EXIST(autoload,[
+	HAVE_AUTOLOAD="yes"
+	OCTLINK=.octlink
+	MKOCTLINK=$TOPDIR/admin/octlink.sh
+],[
+	HAVE_AUTOLOAD="no"
+	OCTLINK=.oct
+	MKOCTLINK=$LN_S
+])
+AC_SUBST(HAVE_AUTOLOAD)
+AC_SUBST(OCTLINK)
+AC_SUBST(MKOCTLINK)
+
+OCTAVE_CHECK_EXIST(do_fortran_indexing,
+	[HAVE_DO_FORTRAN_INDEXING="-DHAVE_DO_FORTRAN_INDEXING"],)
+AC_SUBST(HAVE_DO_FORTRAN_INDEXING)
+
+OCTAVE_CHECK_EXIST(propagate_empty_matrices,
+	[PROPAGATE_EMPTY_MATRICES="-DHAVE_PROPAGATE_EMPTY_MATRICES"],)
+AC_SUBST(HAVE_PROPAGATE_EMPTY_MATRICES)
+
+OCTAVE_CHECK_EXIST(ok_to_lose_imaginary_part,
+  [HAVE_OK_TO_LOSE_IMAGINARY_PART="-DHAVE_OK_TO_LOSE_IMAGINARY_PART"],)
+AC_SUBST(HAVE_OK_TO_LOSE_IMAGINARY_PART)
+
+dnl Test for N-dimensional Arrays
+TRY_MKOCTFILE([for N-dim arrays],
+[#include <octave/dim-vector.h>],
+[HAVE_ND_ARRAYS="-DHAVE_ND_ARRAYS"],)
+AC_SUBST(HAVE_ND_ARRAYS)
+
+OCTAVE_CHECK_EXIST(class,[TYPEID_HAS_CLASS="-DTYPEID_HAS_CLASS"],)
+AC_SUBST(TYPEID_HAS_CLASS)
+
+dnl Test for load/save functions in class
+TRY_MKOCTFILE([for load/save functions in class],
+[#include <octave/ov-scalar.h>
+int main (void) { octave_scalar a; a.load_ascii(std::cin); }],
+[CLASS_HAS_LOAD_SAVE="-DCLASS_HAS_LOAD_SAVE"],)
+AC_SUBST(CLASS_HAS_LOAD_SAVE)
+
+TRY_MKOCTFILE([for Octave_map indexing],
+[#include <octave/oct-map.h>
+int main(void) { Octave_map a; a[["key"]]; }],
+[HAVE_OCTAVE_MAP_INDEX="-DHAVE_OCTAVE_MAP_INDEX"],)
+AC_SUBST(HAVE_OCTAVE_MAP_INDEX)
+
+TRY_MKOCTFILE([for old Octave concatenation],
+[#include <octave/dNDArray.h>
+int main(void) { NDArray a(dim_vector(1,1)); Array<int> idx(2,0); a=concat(a,a,idx); }],
+[HAVE_OCTAVE_CONCAT="-DHAVE_OLD_OCTAVE_CONCAT"],)
+
+TRY_MKOCTFILE([for Octave concatenation],
+[#include <octave/dNDArray.h>
+int main(void) { NDArray a(dim_vector(1,1)); Array<int> idx(2,0); a=a.concat(a,idx); }],
+[HAVE_OCTAVE_CONCAT="-DHAVE_OCTAVE_CONCAT"],)
+AC_SUBST(HAVE_OCTAVE_CONCAT)
+
+TRY_MKOCTFILE([for swap_8_bytes],
+[#include <sys/types.h>
+#include <octave/config.h>
+#include <octave/byte-swap.h>
+int main(void) {long long a = 1; swap_8_bytes (&a,1);}],,
+[HAVE_SWAP_BYTES="-DHAVE_SWAP_BYTES"])
+AC_SUBST(HAVE_SWAP_BYTES)
+
+TRY_MKOCTFILE([for op_uplus],
+[#include <octave/config.h>
+#include <octave/ov.h>
+int main(void) {int i = octave_value::op_uplus;}],
+[HAVE_OCTAVE_UPLUS="-DHAVE_OCTAVE_UPLUS"],)
+AC_SUBST(HAVE_OCTAVE_UPLUS)
+
+dnl Test for the makeinfo program
+AC_CHECK_PROG(MAKEINFO,makeinfo,makeinfo)
+if [ test -n "$MAKEINFO" ]; then
+	dnl Check whether the makeinfo command accepts the 
+	dnl "--no-split" option
+	touch conftest.texi
+	AC_MSG_CHECKING([for makeinfo --no-split])
+	ac_try="$MAKEINFO --no-split conftest.texi"
+	if AC_TRY_EVAL(ac_try) ; then
+		MAKEINFO="$MAKEINFO --no-split"
+		AC_MSG_RESULT(yes)
+	else
+		AC_MSG_RESULT(no)
+	fi
+	rm -f conftest.*
+fi
+
+dnl Test for the texi2dvi program
+AC_CHECK_PROG(TEXI2DVI,texi2dvi,texi2dvi)
+if [ test -n "$TEXI2DVI" ]; then
+	dnl Check whether the texi2dvi command accepts the 
+	dnl "--clean" option
+	cat > conftest.texi <<EOF
+\input texinfo
+@bye
+EOF
+	AC_MSG_CHECKING([that texi2dvi runs])
+	ac_try="$TEXI2DVI conftest.texi > /dev/null"
+	if AC_TRY_EVAL(ac_try) ; then
+	    AC_MSG_RESULT(yes)
+	    AC_MSG_CHECKING([for texi2dvi --clean])
+	    ac_try="$TEXI2DVI --clean conftest.texi > /dev/null"
+	    if AC_TRY_EVAL(ac_try) ; then
+		TEXI2DVI="$TEXI2DVI --clean"
+		AC_MSG_RESULT(yes)
+	    else
+		AC_MSG_RESULT(no)
+	    fi
+	else
+	    TEXI2DVI=""
+	    AC_MSG_RESULT(no)
+	fi
+	rm -f conftest.*
+fi
+
+dnl Test for the texi2html program
+AC_CHECK_PROG(TEXI2HTML,texi2html,texi2html)
+if [ test -n "$TEXI2HTML" ]; then
+	STATUS="yes"
+	dnl Check whether the texi2html command accepts the 
+	dnl "-split_chapter -number" option
+	touch conftest.texi
+	AC_MSG_CHECKING([for texi2html --clean])
+	ac_try="$TEXI2HTML -split_chapter -number conftest.texi"
+	if AC_TRY_EVAL(ac_try) ; then
+		TEXI2HTML="$TEXI2HTML -split_chapter -number"
+		AC_MSG_RESULT(yes)
+	else
+		AC_MSG_RESULT(no)
+	fi
+	rm -f conftest.*
+        dnl TeTex 3.0 on Suse is leaving a conftest directory
+	rm -rf conftest
+fi
+
+dnl Test for the dvipdf program
+AC_CHECK_PROG(DVIPDF,dvipdf,dvipdf)
+
+dnl Test for the dvips program
+AC_CHECK_PROG(DVIPS,dvips,dvips)
+
+MKDOC=$TOPDIR/admin/mkdoc
+AC_SUBST(MKDOC)
+
+MKTEXI=$TOPDIR/admin/mktexi
+AC_SUBST(MKTEXI)
+
+CONFIGURE_OUTPUTS="Makeconf octinst.sh"
+STATUS_MSG="
+octave commands will install into the following directories:
+   m-files:   $mpath
+   oct-files: $opath
+   binaries:  $xpath
+alternatives:
+   m-files:   $altmpath
+   oct-files: $altopath
+
+shell commands will install into the following directories:
+   binaries:  $bindir
+   man pages: $mandir
+   libraries: $libdir
+   headers:   $includedir
+
+octave-forge is configured with
+   octave:      $OCTAVE (version $OCTAVE_VERSION)
+   mkoctfile:	$MKOCTFILE for Octave $subver
+   X11 support:	$XSTATUS
+   makeinfo:    $MAKEINFO
+   texi2dvi:    $TEXI2DVI
+   texi2html:   $TEXI2HTML
+   mkdoc:       $MKDOC
+   mktexi:      $MKTEXI
+   dvips:       $DVIPS
+   dvipdf:      $DVIPDF"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/install-sh	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission.  M.I.T. makes no representations about the
+# suitability of this software for any purpose.  It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
+
+	-d) dir_arg=true
+	    shift
+	    continue;;
+
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
+
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
+	    shift
+	    continue;;
+
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+	    shift
+	    continue;;
+
+	*)  if [ x"$src" = x ]
+	    then
+		src=$1
+	    else
+		# this colon is to work around a 386BSD /bin/sh bug
+		:
+		dst=$1
+	    fi
+	    shift
+	    continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+	echo "install:	no input file specified"
+	exit 1
+else
+	true
+fi
+
+if [ x"$dir_arg" != x ]; then
+	dst=$src
+	src=""
+	
+	if [ -d $dst ]; then
+		instcmd=:
+		chmodcmd=""
+	else
+		instcmd=mkdir
+	fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+	if [ -f $src -o -d $src ]
+	then
+		true
+	else
+		echo "install:  $src does not exist"
+		exit 1
+	fi
+	
+	if [ x"$dst" = x ]
+	then
+		echo "install:	no destination specified"
+		exit 1
+	else
+		true
+	fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+	if [ -d $dst ]
+	then
+		dst="$dst"/`basename $src`
+	else
+		true
+	fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='	
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
+
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$mkdirprog "${pathcomp}"
+	else
+		true
+	fi
+
+	pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+	$doit $instcmd $dst &&
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+	if [ x"$transformarg" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		dstfile=`basename $dst $transformbasename | 
+			sed $transformarg`$transformbasename
+	fi
+
+# don't allow the sed command to completely eliminate the filename
+
+	if [ x"$dstfile" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		true
+	fi
+
+# Make a temp file name in the proper directory.
+
+	dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+	$doit $instcmd $src $dsttmp &&
+
+	trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+	$doit $rmcmd -f $dstdir/$dstfile &&
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/nctype.m4	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,42 @@
+changecom(`/*', `*/')dnl 
+## Copyright (C) 2005 Alexander Barth
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+## -*- texinfo -*-
+## @deftypefn {Loadable Function} {@var{ncvar} = } nc`'TYPE`'(@var{dimname_1},...,@var{dimname_N})
+## creates a netcdf variable of type nc`'TYPE. @var{dimname_1} is the name 
+## of the 1st netcdf dimension, and so on. The return value is a netcdf
+## variable object and must be affected to a netcdf file, before its content
+## can be defined.
+## 
+## Example:
+## @example
+## nc = netcdf('test.nc','w');
+## nc('lon') = 360;
+## nc('lat') = 180;
+## nc@{'var'@} =  nc`'TYPE`'('lon','lat');
+## @end example
+## A new 360 by 180 netcdf variable named 'var' of type TYPE is 
+## created in file 'test.nc'.
+## @end deftypefn
+## @seealso{netcdf}
+
+## Author: Alexander Barth <abarth@marine.usf.edu>
+
+function c = nc`'TYPE`'(varargin);
+
+c = {'TYPE' varargin{:}};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/octinst.sh.in	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,93 @@
+#! /bin/sh
+
+# octinst.sh source mpath opath xpath [altmpath altopath]
+
+# Copies all m-files and oct-files from the source directory to the
+# mpath and opath respectively.  Preserves links.  Files in
+# source/data are copied to mpath.  Files in the source/bin are copied
+# to xpath. m-files and oct-files in source/alternatives are copied to 
+# altmpath and altopath respectively
+
+if test $# -lt 4 ; then
+    echo 'Not enough arguments'
+    exit 1
+fi
+
+# interpret input parameters
+source=$1; shift
+mpath=$1; shift
+opath=$1; shift
+xpath=$1; shift
+if test $# -ge 1; then altmpath=$1; shift; fi
+if test $# -ge 1; then altopath=$1; shift; fi
+INSTALL="@INSTALL@"
+INSTALL_DATA="@INSTALL_DATA@"
+INSTALL_PROGRAM="@INSTALL_PROGRAM@"
+INSTALL_SCRIPT="@INSTALL_SCRIPT@"
+MKPKGADD="@TOPDIR@/admin/mkpkgadd"
+COPY_FLAGS="@COPY_FLAGS@"
+
+# grab the m-files
+files=`echo $source/*.m`
+if test "$files" != "$source/*.m" ; then
+    $INSTALL -d $mpath
+    $INSTALL_DATA $files $mpath
+fi
+
+# grab the oct-files
+files=`echo $source/*.oct`
+if test "$files" != "$source/*.oct" ; then
+    $INSTALL -d $opath
+## Grrr... install doesn't preserve links.  Hope this works.
+    cp $COPY_FLAGS $files $opath
+fi
+
+# install alternatives
+if test -d "$source/alternatives" ; then
+    # m-files
+    files=`echo $source/alternatives/*.m`
+    if test "$files" != "$source/alternatives/*.m" ; then
+        $INSTALL -d $altmpath
+	$INSTALL_DATA $files $altmpath
+    fi
+    # oct-files
+    files=`echo $source/alternatives/*.oct`
+    if test "$files" != "$source/alternatives/*.oct" ; then
+        $INSTALL -d $altopath
+	$INSTALL_DATA $files $altopath
+    fi
+fi
+
+# Create PKG_ADD, and destroy it immediately if it is empty
+# XXX FIXME XXX no PKG_ADD created if only oct-files and no m-files.
+if test -d "$mpath" ; then
+    $MKPKGADD $source > $mpath/PKG_ADD
+    if test -z "`cat $mpath/PKG_ADD`" ; then rm -f $mpath/PKG_ADD;  fi
+fi
+# PKG_ADD for alternatives
+if test -d "$source/alternatives" -a -d "$altmpath" ; then
+    $MKPKGADD $source/alternatives > $altmpath/PKG_ADD
+    if test -z "`cat $altmpath/PKG_ADD`" ; then rm $altmpath/PKG_ADD; fi
+fi
+
+# grab the data files, skipping the CVS directory
+files=`echo $source/data/* | sed -e "s/[^ ]*CVS//"`
+if test -n "$files" -a "$files" != "$source/data/*" ; then
+    $INSTALL -d $mpath
+    $INSTALL_DATA $files $mpath
+fi
+
+# grab the executable files, skipping the CVS directory
+files=`echo $source/bin/* | sed -e "s/[^ ]*CVS//"`
+if test -n "$files" -a "$files" != "$source/bin/*" ; then
+    $INSTALL -d $xpath
+    $INSTALL_PROGRAM $files $xpath
+fi
+
+# grab the script files, skipping the CVS directory
+files=`echo $source/scripts/* | sed -e "s/[^ ]*CVS//"`
+if test -n "$files" -a "$files" != "$source/scripts/*" ; then
+    $INSTALL -d $xpath
+    $INSTALL_SCRIPT $files $xpath
+fi
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncatt.cc	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,252 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+
+#include "ov-netcdf.h"
+#include "ov-ncfile.h"
+#include "ov-ncvar.h"
+#include "ov-ncatt.h"
+
+
+
+//
+// octave_ncatt
+//
+
+octave_ncatt::octave_ncatt(octave_ncvar* ncvar, int attnump) {
+  int status;
+  char name[NC_MAX_NAME];
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
+# endif
+
+  nca = new ncatt_t;
+
+  set_ncfile(ncvar->get_ncfile());
+  set_ncvar(ncvar);
+  set_attnum(attnump);
+  set_varid(ncvar->get_varid());
+  set_ncid(ncvar->get_ncfile()->get_ncid());
+
+  status = nc_inq_attname(get_ncid(),get_varid(),get_attnum(),name);
+
+  if (status != NC_NOERR) {
+    error("Error while quering attribute: %s",nc_strerror(status));
+    return;
+  }
+
+  set_name(string(name));
+
+  read_info();
+}
+   
+
+octave_ncatt::octave_ncatt(octave_ncvar* ncvar, std::string attnamep) {
+  int status, attnum;
+
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
+# endif
+
+  nca = new ncatt_t;
+
+  set_ncfile(ncvar->get_ncfile());
+  set_ncvar(ncvar);
+  set_name(attnamep);
+  set_varid(ncvar->get_varid());
+  set_ncid(ncvar->get_ncfile()->get_ncid());
+
+  status = nc_inq_attid(get_ncid(),get_varid(),get_name().c_str(),&attnum);
+
+  if (status != NC_NOERR) {
+    error("Error while quering attribute: %s",nc_strerror(status));
+    return;
+  }
+
+  set_attnum(attnum);
+
+  read_info();
+}
+ 
+
+
+octave_ncatt::octave_ncatt(octave_ncfile* ncfilep, int attnump) {
+  int status;
+  char name[NC_MAX_NAME];
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << "attm " << attnump<< std::endl;
+# endif
+
+  nca = new ncatt_t;
+
+  set_ncfile(ncfilep);
+  set_ncvar(NULL);
+  set_attnum(attnump);
+  set_varid(NC_GLOBAL);
+  set_ncid(get_ncfile()->get_ncid());
+
+
+  //octave_stdout << "ncid " << ncid << endl;
+
+  status = nc_inq_attname(get_ncid(),get_varid(),get_attnum(),name);
+
+  if (status != NC_NOERR) {
+    error("Error while quering attribute: %s",nc_strerror(status));
+    return;
+  }
+
+  set_name(string(name));
+  //octave_stdout << "attname " << attname << endl;
+
+  read_info();
+}
+   
+
+octave_ncatt::octave_ncatt(octave_ncfile* ncfilep, std::string attnamep) {
+  int status, attnum;
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "new attr " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
+# endif
+
+    nca = new ncatt_t;
+
+   set_ncfile(ncfilep);
+   set_ncvar(NULL);
+   set_name(attnamep);
+   set_varid(NC_GLOBAL);
+   set_ncid(get_ncfile()->get_ncid());
+
+
+   status = nc_inq_attid(get_ncid(),get_varid(),get_name().c_str(),&attnum);
+
+   if (status != NC_NOERR) {
+     error("Error while quering attribute: %s",nc_strerror(status));
+     return;
+   }
+
+   set_attnum(attnum);
+
+   read_info();
+ }
+ 
+
+// ncatt_var(:) = y
+
+octave_value octave_ncatt::subsasgn(const std::string & type,
+				    const LIST < octave_value_list > &idx,
+				    const octave_value & rhs)
+{
+  octave_value retval;
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "setting attribute value " << std::endl;
+# endif
+
+  if (type[0] != '(' || !idx.front()(0).is_magic_colon() ) {
+    error("A ncatt can only be referenced with a (:)");
+    return octave_value();
+  }
+
+  get_ncfile()->set_mode(DefineMode);
+
+  ov_nc_put_att(get_ncid(),get_varid(),get_name(),get_nctype(),rhs);
+
+# ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
+  retval = octave_value(this, count + 1);
+# else
+  retval = octave_value(clone());
+# endif
+
+  return retval;
+
+
+};
+
+// ncatt_var(:) 
+
+octave_value octave_ncatt::subsref(const std::string SUBSREF_STRREF type,
+			       const LIST < octave_value_list > &idx)
+{
+  octave_value retval;
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "getting attribute value " << std::endl;
+# endif
+
+  if (type[0] != '(' || !idx.front()(0).is_magic_colon() ) {
+    error("A ncatt can only be referenced with a (:)");
+    return octave_value();
+  }
+
+  retval = ov_nc_get_att(get_ncid(),get_varid(),get_name());
+
+  return retval.next_subsref(type, idx);
+}
+
+
+  void octave_ncatt::read_info() {
+  size_t length;
+  int status;
+  nc_type nctype;
+
+  status = nc_inq_att(get_ncid(),get_varid(),get_name().c_str(),&nctype,&length);
+  set_nctype(nctype);
+
+
+  if (status != NC_NOERR) {
+    error("Error while quering attribute: %s",nc_strerror(status));
+    return;
+  }
+
+  nca->dimvec.resize(1);
+  nca->dimvec(0) = length;
+  }
+
+
+  void octave_ncatt::print(std::ostream & os, bool pr_as_read_syntax) const {
+    os << "attname = " << get_name() << endl;;
+    os << "type = " << nctype2ncname(get_nctype()) << endl;;
+#   ifdef OV_NETCDF_VERBOSE
+    os << "attnum = " << get_attnum() << endl;;
+#   endif
+  }
+
+void octave_ncatt::rename(string new_name) {
+  int status;
+    
+  status = nc_rename_att(get_ncid(),get_varid(),get_name().c_str(), new_name.c_str()); 
+
+  if (status != NC_NOERR) {
+    error("Error while renaming attribute %s: %s", get_name().c_str(),
+	  nc_strerror(status));
+    return;
+  }
+
+  set_name(new_name);
+}
+
+
+DEFINE_OCTAVE_ALLOCATOR(octave_ncatt);
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncatt, "ncatt", "ncatt");
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncatt.h	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,124 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+#if !defined (octave_ncatt_int_h)
+#define octave_ncatt_int_h 1
+
+#include "ov-netcdf.h"
+
+typedef struct {
+  nc_type nctype;
+  dim_vector dimvec;
+  octave_ncfile* ncfile;
+  octave_ncvar* ncvar;
+  std::string attname;
+  int ncid,varid,attnum;
+}  ncatt_t ;
+
+
+class octave_ncatt:public octave_base_value {
+public:
+  octave_ncatt(void):octave_base_value(), nca(NULL) { } 
+
+  octave_ncatt(const octave_ncatt& ncatt_val):octave_base_value(), nca(ncatt_val.nca) { }
+
+  octave_ncatt(octave_ncvar* ncvarp, int attnump); 
+  octave_ncatt(octave_ncvar* ncvarp, std::string attnamep); 
+  octave_ncatt(octave_ncfile* ncvarp, int attnump);
+  octave_ncatt(octave_ncfile* ncvarp, std::string attnamep);
+
+  OV_REP_TYPE *clone(void) const { return new octave_ncatt(*this); }
+
+  octave_value subsasgn(const std::string & type,
+			const LIST < octave_value_list > &idx,
+			const octave_value & rhs);
+
+  octave_value subsref(const std::string SUBSREF_STRREF type,
+		       const LIST < octave_value_list > &idx);
+
+  octave_value_list do_multi_index_op(int, const octave_value_list &)
+  {
+    error("octave_object: do_multi_index_op(nargout,args)");
+    return octave_value_list();
+  }
+
+  ~octave_ncatt()  { }
+ 
+  void read_info();
+
+  /* Query Interface for octave */
+
+  int ndims() const  { return dims().length(); }
+
+  octave_idx_type numel() const  { return dims().numel(); }
+
+  dim_vector dims() const {  return nca->dimvec; }
+
+  void print(std::ostream & os, bool pr_as_read_syntax) const;
+
+  bool is_constant(void) const  {
+    return true;
+  }
+  bool is_defined(void) const  {
+    return true;
+  }
+  bool is_map(void) const  {
+    return true;
+  }
+
+
+  nc_type get_nctype(void) const { return nca->nctype; };
+  std::string get_name() const { return nca->attname; };
+  octave_ncfile* get_ncfile() const { return nca->ncfile; };
+  octave_ncvar*  get_ncvar() const { return nca->ncvar; };
+  int get_ncid() const { return nca->ncid; };
+  int get_varid() const { return nca->varid; };
+  int get_attnum() const { return nca->attnum; };
+
+  void set_nctype(const nc_type& t)  { nca->nctype = t; } ;
+  void set_name(const std::string& t) { nca->attname = t; };
+  void set_ncfile(octave_ncfile* t)  { nca->ncfile = t; };
+  void set_ncvar(octave_ncvar* t)  { nca->ncvar = t; };
+  void set_ncid(const int& t)  { nca->ncid = t; };
+  void set_varid(const int& t)  { nca->varid = t; };
+  void set_attnum(const int& t)  { nca->attnum = t; };
+
+  void rename(string new_name);
+
+private:
+  ncatt_t* nca;
+
+
+  DECLARE_OCTAVE_ALLOCATOR 
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+};
+
+
+// end octave_ncatt
+
+
+#endif
+
+
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncdim.cc	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,138 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+
+#include "ov-netcdf.h"
+#include "ov-ncfile.h"
+#include "ov-ncdim.h"
+
+
+
+//
+// octave_ncdim
+//
+
+
+octave_ncdim::octave_ncdim(octave_ncfile* ncfilep, int dimid) {
+  int status, unlimdimid;
+  char name[NC_MAX_NAME];
+  size_t len;
+
+#   ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "new dim " <<  __LINE__ << ":"  << __FUNCTION__ << " dimid " <<dimid<< std::endl;
+#  endif
+
+    ncd = new ncdim_t;
+
+     set_ncfile(ncfilep);
+     set_dimid(dimid);
+
+     //octave_stdout << "ncid " << ncid << endl;
+
+     status = nc_inq_dim(get_ncid(),get_dimid(),name,&len);
+
+       //status = nc_inq_dimname(get_ncid(),get_dimid(),name);
+    set_name(string(name));
+    set_length(len);
+
+    status = nc_inq_unlimdim(get_ncid(),&unlimdimid);
+
+    set_record(dimid == unlimdimid);
+
+    //     read_info();
+  }
+   
+
+
+// // ncdim_var(:) = y
+
+// octave_value octave_ncdim::subsasgn(const std::string & type,
+// 				const LIST < octave_value_list > &idx,
+// 				const octave_value & rhs)
+// {
+//   int status;
+//   octave_value retval;
+
+// # ifdef OV_NETCDF_VERBOSE
+//   octave_stdout << "setting attribute value " << std::endl;
+// # endif
+
+// # ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
+//   retval = octave_value(this, count + 1);
+// # else
+//   retval = octave_value(clone());
+// # endif
+//   return retval;
+// };
+
+// ncdim_var(:) 
+
+octave_value octave_ncdim::subsref(const std::string SUBSREF_STRREF type,
+			       const LIST < octave_value_list > &idx)
+{
+  octave_value retval;
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "getting dimension length " << std::endl;
+# endif
+
+
+  if (type[0] != '(' || !idx.front()(0).is_magic_colon() ) {
+    error("A ncdim can only be referenced with a (:)");
+    return octave_value();
+  }
+
+  return octave_value((int)get_length());
+
+  //  return retval.next_subsref(type, idx);
+}
+
+
+  void octave_ncdim::read_info() {
+
+  //dimvec.resize(length);
+  }
+
+
+  void octave_ncdim::print(std::ostream & os, bool pr_as_read_syntax) const {
+    os << "dimname = " << get_name() << endl;;
+    os << "length = " << get_length() << endl;;
+    os << "is_record = " << is_record() << endl;;
+  }
+
+void octave_ncdim::rename(string new_name) {
+  int status;
+    
+  status = nc_rename_dim(get_ncid(),get_dimid(), new_name.c_str()); 
+
+  if (status != NC_NOERR) {
+    error("Error while renaming dimension %s: %s", get_name().c_str(),
+	  nc_strerror(status));
+    return;
+  }
+
+  set_name(new_name);
+}
+
+
+DEFINE_OCTAVE_ALLOCATOR(octave_ncdim);
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncdim, "ncdim", "ncdim");
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncdim.h	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,121 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+#if !defined (octave_ncdim_int_h)
+#define octave_ncdim_int_h 1
+
+#include "ov-netcdf.h"
+
+typedef struct {
+  octave_ncfile* ncfile;
+  std::string dimname;
+  bool is_record;
+  int dimid;
+  size_t length;
+}  ncdim_t ;
+
+
+class octave_ncdim:public octave_base_value {
+public:
+   octave_ncdim(void):octave_base_value(), ncd(NULL) { } 
+
+  octave_ncdim(const octave_ncdim& ncdim_val):octave_base_value(), ncd(ncdim_val.ncd) { }
+
+  octave_ncdim(octave_ncfile* ncfile, int dimid);
+
+  OV_REP_TYPE *clone(void) const { return new octave_ncdim(*this); }
+
+//   octave_value subsasgn(const std::string & type,
+// 			const LIST < octave_value_list > &idx,
+// 			const octave_value & rhs);
+
+  octave_value subsref(const std::string SUBSREF_STRREF type,
+		       const LIST < octave_value_list > &idx);
+
+  octave_value_list do_multi_index_op(int, const octave_value_list &)
+  {
+    error("octave_object: do_multi_index_op(nargout,args)");
+    return octave_value_list();
+  }
+
+  ~octave_ncdim()  { 
+#  ifdef OV_NETCDF_VERBOSE
+    octave_stdout << "destruct " << std::endl;  
+#  endif
+  }
+ 
+  void read_info();
+
+  /* Query Interface for octave */
+
+  int ndims() const  { return 1; }
+
+  octave_idx_type numel() const  { return  ncd->length; }
+
+  dim_vector dims() const {  return dim_vector(ncd->length,1); }
+
+
+  void print(std::ostream & os, bool pr_as_read_syntax) const;
+
+  bool is_constant(void) const  {
+    return true;
+  }
+  bool is_defined(void) const  {
+    return true;
+  }
+  bool is_map(void) const  {
+    return true;
+  }
+
+
+  std::string get_name() const { return ncd->dimname; };
+  octave_ncfile* get_ncfile() const { return ncd->ncfile; };
+  int get_dimid() const { return ncd->dimid; };
+  size_t get_length() const { return ncd->length; };
+  bool is_record() const { return ncd->is_record; };
+  int get_ncid() const { return ncd->ncfile->get_ncid(); };
+
+  void set_name(const std::string& t) { ncd->dimname = t; };
+  void set_ncfile(octave_ncfile* t)  { ncd->ncfile = t; };
+  void set_dimid(const int& t)  { ncd->dimid = t; };
+  void set_length(const size_t& t)  { ncd->length = t; };
+  void set_record(bool t){ ncd->is_record = t; };
+
+  void rename(string new_name);
+private:
+  ncdim_t* ncd;
+
+
+  DECLARE_OCTAVE_ALLOCATOR 
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+};
+
+
+// end octave_ncdim
+
+
+#endif
+
+
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncfile.cc	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,464 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+#include "ov-netcdf.h"
+#include "ov-ncfile.h"
+#include "ov-ncvar.h"
+#include "ov-ncatt.h"
+#include "ov-ncdim.h"
+
+
+
+
+octave_ncfile::octave_ncfile(string filenamep, string open_mode):octave_base_value()
+{
+  int status;
+  int omode = NC_NOWRITE;
+  bool do_open;
+
+#     ifdef OV_NETCDF_VERBOSE
+      octave_stdout << "allocate ncfile_t " << std::endl;
+#    endif
+
+  nf = new ncfile_t;
+
+  nf->filename = filenamep;
+
+  if (open_mode == "r" || open_mode == "nowrite") {
+    do_open = true;
+    omode = NC_NOWRITE;
+  }
+  else if (open_mode == "w" || open_mode == "write") {
+    do_open = true;
+    omode = NC_WRITE;
+  }
+  else if (open_mode == "c" || open_mode == "clobber") {
+    do_open = false;
+    omode = NC_CLOBBER;
+  }
+  else if (open_mode == "nc" || open_mode == "noclobber") {
+    do_open = false;
+    omode = NC_NOCLOBBER;
+  }
+  else {
+    error("Unknown mode for opening netcdf file: %s",open_mode.c_str());
+    return;
+  }
+
+
+  if (do_open)  {
+      status = nc_open(nf->filename.c_str(), omode, &(nf->ncid));
+
+      if (status != NC_NOERR)
+	{
+	  error("Error while opening %s: %s", nf->filename.c_str(),
+		nc_strerror(status));
+	  return;
+	}
+
+
+      nf->mode = DataMode;
+
+    }
+  else {
+#     ifdef OCTCDF_64BIT_OFFSET 
+      omode = omode | NC_64BIT_OFFSET;
+#     endif
+
+      status = nc_create(nf->filename.c_str(), omode, &(nf->ncid));
+
+      if (status != NC_NOERR)
+	{
+	  error("Error while creating %s: %s", nf->filename.c_str(),
+		nc_strerror(status));
+	  return;
+	}
+
+
+      nf->mode = DefineMode;
+
+    }
+
+#     ifdef OV_NETCDF_VERBOSE
+      octave_stdout << "Open file " << nf->filename.c_str() 
+        << " omode " << omode << " mode " << (int) nf->mode << std::endl;
+#    endif
+
+    read_info();
+
+}
+
+
+void octave_ncfile::read_info() {
+
+  int status;
+
+  if (get_ncid() == -1) return;
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << __FILE__ <<  __LINE__ << ":" << __FUNCTION__ << std::endl;
+# endif
+
+  status = nc_inq(get_ncid(),&(nf->ndims),&(nf->nvars),&(nf->natts),&(nf->unlimdimid));
+
+  if (status != NC_NOERR)
+    error("Error while quering file: %s",nc_strerror(status));
+
+}
+
+
+// x.v = y     x(idx).v = y     x{idx}.v = y
+
+octave_value octave_ncfile::subsasgn(const std::string & type,
+				const LIST < octave_value_list > &idx,
+				const octave_value & rhs)
+{
+  int status;
+  octave_value retval;
+
+
+  //  check_args_string("octave_ncfile::subsasgn",idx.front());
+
+  if (error_state)
+    return octave_value();
+
+  std::string name = idx.front()(0).string_value();
+
+
+  switch (type[0]) {
+    case '.': {
+#       ifdef OV_NETCDF_VERBOSE
+	octave_stdout << "create attribute " << name << std::endl;
+#       endif
+
+	set_mode(DefineMode);
+
+	if (!rhs.is_cell()) {
+
+#           ifdef OV_NETCDF_VERBOSE
+	    octave_stdout << "type_id" << rhs.type_id() << endl;
+#           endif
+
+            nc_type nctype = ovtype2nctype(rhs);
+
+#          ifdef OV_NETCDF_VERBOSE
+	    octave_stdout << "type " << nctype << endl;
+#          endif
+
+          ov_nc_put_att(get_ncid(),NC_GLOBAL,name,nctype,rhs);
+	}
+        else {
+#       ifdef OV_NETCDF_VERBOSE
+	  octave_stdout << "define attribute from cell " << get_ncid() << std::endl;
+#       endif
+
+            Cell c =  rhs.cell_value();
+
+#           ifdef OV_NETCDF_VERBOSE
+	    octave_stdout << "type " << c.elem(0).string_value()<< endl;
+#           endif
+            nc_type nctype = ncname2nctype(c.elem(0).string_value());
+#           ifdef OV_NETCDF_VERBOSE
+	    octave_stdout << "type " << nctype << endl;
+#           endif
+     	    ov_nc_put_att(get_ncid(),NC_GLOBAL,name,nctype,c.elem(1));
+	}
+
+	break;
+      }
+    case '(': {
+	int dimid;
+#       ifdef OV_NETCDF_VERBOSE
+	octave_stdout << "create dimension " << name << std::endl;
+#       endif
+
+	set_mode(DefineMode);
+
+	status =
+	  nc_def_dim(get_ncid(),name.c_str(), (size_t) rhs.scalar_value(),
+		     &dimid);
+
+	if (status == NC_ENAMEINUSE) {
+	  octave_stdout << "dimension " << name.c_str() << " already exist" << std::endl;
+	}
+        else if (status != NC_NOERR) {
+	    error("Error while creating dimension %s: %s",
+		  name.c_str(), nc_strerror(status));
+	  }
+	break;
+      }
+    case '{': {
+	set_mode(DefineMode);
+
+	if (type.length() == 1) {
+	  if (rhs.class_name() == "ncvar") {
+	    // define a variables
+
+            // downcast from octave_value to octave_ncvar
+
+            const octave_ncvar& ncvar = (const octave_ncvar&)rhs.get_rep();
+#           ifdef OV_NETCDF_VERBOSE
+  	    octave_stdout << "define variable " << name <<  " nctype " << ncvar.get_nctype() << std::endl;
+#           endif
+
+            ov_nc_def_var(get_ncid(),name,ncvar.get_nctype(),ncvar.get_dimnames());
+
+	  } 
+	  else if (rhs.is_cell()) {
+#           ifdef OV_NETCDF_VERBOSE
+  	    octave_stdout << "define variable from cell " << std::endl;
+#           endif
+            Cell c =  rhs.cell_value();
+
+#           ifdef OV_NETCDF_VERBOSE
+	    octave_stdout << "type " << c.elem(0).string_value()<< endl;
+#           endif
+            nc_type nctype = ncname2nctype(c.elem(0).string_value());
+#           ifdef OV_NETCDF_VERBOSE
+	    octave_stdout << "type " << nctype << endl;
+#           endif
+
+            std::list<std::string> dimnames;
+
+            for (int i = 1; i < c.nelem(); i++) {
+              dimnames.push_back(c.elem(i).string_value());
+#             ifdef OV_NETCDF_VERBOSE
+	      octave_stdout << "dimention " << c.elem(i).string_value()<< endl;
+#             endif
+            }
+
+            ov_nc_def_var(get_ncid(),name,nctype,dimnames);
+
+	  }
+          else
+	    error("Error rhs of assignment should be an ncvar");
+	}
+	else {
+	  octave_ncvar *var = new octave_ncvar(this,name);
+
+          if (idx.front().length() == 2) 
+	    if (idx.front()(1).is_scalar_type()) 
+              var->autoscale() = idx.front()(1).scalar_value() == 1;
+
+
+            
+	  if (! error_state && idx.size () > 1)
+	    {
+	      // make necessary assignment with netcdf variable
+
+	      std::list<octave_value_list> new_idx (idx);
+	      new_idx.erase (new_idx.begin ());
+	      retval = var->subsasgn (type.substr(1), new_idx,rhs);
+	    }
+
+	}
+
+
+	break;
+      }
+      break;
+
+    }
+
+
+  // update characteristics
+
+  read_info();
+
+  // result of this assignement is the same 
+  // octave_ncfile object
+
+# ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
+  retval = octave_value(this, count + 1);
+# else
+  retval = octave_value(clone());
+# endif
+
+  return retval;
+
+
+};
+
+// x.v     x(idx).v     x{idx}.v
+
+octave_value octave_ncfile::subsref(const std::string SUBSREF_STRREF type,
+			       const LIST < octave_value_list > &idx)
+{
+  int dimid, status;
+  size_t length;
+  octave_value retval;
+
+  //  check_args_string("octave_ncfile::subsref",idx.front());
+
+  if (error_state)
+    return octave_value();
+
+  std::string name = idx.front()(0).string_value();
+
+  switch (type[0]) {
+    case '.': {
+#       ifdef OV_NETCDF_VERBOSE
+	octave_stdout << "getting attribute " << name << std::endl;
+#       endif
+
+	retval = ov_nc_get_att(get_ncid(),NC_GLOBAL,name);
+
+	break;
+      }
+    case '(':
+      {
+#       ifdef OV_NETCDF_VERBOSE
+        octave_stdout << "getting dimension " << name << std::endl;
+#       endif
+
+	status = nc_inq_dimid(get_ncid(),name.c_str(), &dimid);
+
+	if (status != NC_NOERR) {
+	  error("Error while querying dimension %s: %s",name.c_str(), nc_strerror(status));
+   	  return  octave_value();
+	}
+
+	// previously a call like nc('dimension name') return the size of the dimension,
+	// now it return the dimension object in order to be compatible with the 
+	// Matlab toolbox.
+
+#       if 0
+ 	status = nc_inq_dimlen(get_ncid(), dimid, &length);
+
+ 	if (status != NC_NOERR) {
+ 	  error("Error while querying dimension %s: %s",name.c_str(), nc_strerror(status));
+    	  return  octave_value();
+ 	}
+ 	retval = octave_value(length);
+#       else
+	retval = octave_value(new octave_ncdim(this,dimid));
+#       endif
+
+	break;
+      }
+    case '{': {
+#         ifdef OV_NETCDF_VERBOSE
+	octave_stdout << "getting variable " << name << std::endl;
+#         endif
+
+	octave_ncvar *var = new octave_ncvar(this, name);
+
+	// determine if the variable need to be scaled
+
+        if (idx.front().length() == 2) {
+            var->autoscale() = idx.front()(1).scalar_value() == 1;
+	}
+
+	retval = var;
+	break;
+      }
+      break;
+
+    }
+
+  return retval.next_subsref(type, idx);
+}
+
+
+octave_ncfile::~octave_ncfile(void)
+{
+  // not a good idea to close file, since copies of ncfile are created 
+  // which are destroyed when the original ncfile object is still used
+  //  close();
+}
+
+void octave_ncfile::close(void) {
+  int status;
+#   ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "close file " << get_ncid() << std::endl;
+#   endif
+
+  if (get_ncid() == -1) return;
+
+  status = nc_close(get_ncid());
+
+   if (status != NC_NOERR)  {
+       error("Error closing file: %s", nc_strerror(status));
+     }
+
+  nf->ncid = -1;
+}
+
+void octave_ncfile::sync(void) {
+  int status;
+#   ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "sync file " << std::endl;
+#   endif
+
+  set_mode(DataMode);
+  status = nc_sync(get_ncid());
+
+  if (status != NC_NOERR)
+    {
+      error("Error syncronizing file: %s", nc_strerror(status));
+    }
+}
+
+
+void octave_ncfile::set_mode(Modes new_mode)
+{
+  int status;
+
+  if (new_mode != get_mode())
+    {
+      if (new_mode == DataMode)
+	  status = nc_enddef(get_ncid());
+      else
+	  status = nc_redef(get_ncid());
+
+      if (status != NC_NOERR)
+	  error("Error chaning mode: %s", nc_strerror(status));
+      else
+	  nf->mode = new_mode;
+    }
+
+
+}
+
+void octave_ncfile::print(std::ostream & os, bool pr_as_read_syntax = false) const
+{
+
+  os << "filename = " << get_filename() << std::endl;
+# ifdef OV_NETCDF_VERBOSE
+  os << "ncid = " << get_ncid() << std::endl;
+# endif
+  os << "nvars = " << get_nvars() << std::endl;
+  os << "natts = " << get_natts() << std::endl;
+  os << "ndims = " << get_ndims() << std::endl;
+  if (get_mode() == DataMode)
+    os << "mode = DataMode " << std::endl;
+  else
+    os << "mode = DefineMode " << std::endl;
+}
+
+
+
+
+DEFINE_OCTAVE_ALLOCATOR(octave_ncfile);
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncfile, "ncfile", "ncfile");
+
+
+// end octave_ncfile
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncfile.h	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,118 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+#if !defined (octave_ncfile_int_h)
+#define octave_ncfile_int_h 1
+
+#include "ov-netcdf.h"
+
+typedef struct {
+  int ncid;
+  std::string filename;
+  int natts, nvars, unlimdimid, ndims;
+  Modes mode;
+}  ncfile_t ;
+
+class octave_ncfile:public octave_base_value
+{
+public:
+  octave_ncfile(void):octave_base_value(), nf(NULL) {}
+
+  octave_ncfile(const octave_ncfile& ncfile_val):octave_base_value(), nf(ncfile_val.nf) { }
+
+  octave_ncfile(string filenamep, string open_mode);
+
+  OV_REP_TYPE *clone(void) const { return new octave_ncfile(*this); }
+
+// x.v = y     x(idx).v = y     x{idx}.v = y
+
+  octave_value subsasgn(const std::string & type,
+			const LIST < octave_value_list > &idx,
+			const octave_value & rhs);
+
+  // x.v     x(idx).v     x{idx}.v
+
+  octave_value subsref(const std::string SUBSREF_STRREF type,
+		       const LIST < octave_value_list > &idx);
+
+  octave_value_list do_multi_index_op(int, const octave_value_list &)
+  {
+    error("octave_object: do_multi_index_op(nargout,args)");
+    return octave_value_list();
+  }
+
+  ~octave_ncfile();
+
+  void close();
+
+  void sync();
+
+  void read_info();
+
+  int get_ncid() const { return nf->ncid; }
+  int get_nvars() const { return nf->nvars; }
+  int get_natts() const { return nf->natts; }
+  int get_ndims() const { return nf->ndims; }
+  std::string get_filename() const { return nf->filename; }
+  Modes get_mode() const  { return nf->mode; }
+
+  void set_mode(Modes new_mode);
+
+  void print(std::ostream & os, bool pr_as_read_syntax) const;
+
+  bool is_constant() const
+  {
+    return true;
+  }
+  bool is_defined() const
+  {
+    return true;
+  }
+  bool is_map() const
+  {
+    return true;
+  }
+
+private:
+  ncfile_t* nf;
+
+//   int ncid;
+//   std::string filename;
+//   int natts, nvars, unlimdimid, ndims;
+
+
+  DECLARE_OCTAVE_ALLOCATOR 
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+};
+
+
+
+// end octave_ncfile
+
+
+#endif
+
+
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncvar.cc	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,492 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+#include "ov-netcdf.h"
+#include "ov-ncfile.h"
+#include "ov-ncvar.h"
+#include "ov-ncatt.h"
+
+
+
+//
+// Constructors of octave_ncvar
+//
+
+octave_ncvar::octave_ncvar(octave_ncfile* ncfilep, std::string varnamep) :octave_base_value() {
+  int status, varid;
+
+  ncv = new ncvar_t;
+
+  set_ncfile(ncfilep);
+  set_varname(varnamep);
+  set_ncid(ncfilep->get_ncid());
+
+  status = nc_inq_varid(get_ncid(),get_varname().c_str(), &varid);
+
+  if (status != NC_NOERR)  {
+    error("Error while querying variable %s: %s",
+	  get_varname().c_str(), nc_strerror(status));
+  }
+
+  set_varid(varid);
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "new variable " <<  __LINE__ << ":"  << __FUNCTION__ << std::endl;
+# endif
+
+  read_info();
+
+  autoscale() = false;
+  autonan() = false;
+}
+
+
+octave_ncvar::octave_ncvar(octave_ncfile* ncfilep, int varidp):octave_base_value() {
+
+  ncv = new ncvar_t;
+
+  set_varid(varidp);
+  set_ncfile(ncfilep);
+  set_ncid(ncfilep->get_ncid());  
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "new variable " <<  __LINE__ << ":" << __FUNCTION__ << std::endl;
+# endif
+
+  read_info();
+
+  autoscale() = false;
+  autonan() = false;
+
+}
+
+// load charecteristics of netcdf variable from file
+
+void octave_ncvar::read_info() {
+
+  int status;
+  int dimids[NC_MAX_VAR_DIMS];
+  int ndims, natts;
+  char name[NC_MAX_NAME];
+  size_t length;
+  nc_type nctype;
+  dim_vector dimvec, ncdimvec;
+  std::list<std::string> dimnames;
+
+  if (get_varid() == -1) return;
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << __FILE__ <<  __LINE__ << ":" << __FUNCTION__ << std::endl;
+# endif
+
+  status = nc_inq_var(get_ncid(),get_varid(),name,&nctype,&ndims,dimids,&natts);
+
+  if (status != NC_NOERR)
+    error("Error while quering variable: %s",nc_strerror(status));
+
+  set_nctype(nctype);
+  set_natts(natts);
+
+  set_varname(string(name));
+  ncdimvec.resize(ndims);
+
+  // reverse dimids if FORTRAN_ORDER
+
+  if (STORAGE_ORDER == FORTRAN_ORDER) 
+    for (int i=0; i<ndims/2; i++) {
+      status = dimids[i];
+      dimids[i] = dimids[ndims-i-1];
+      dimids[ndims-i-1] = status;
+    }
+
+  for (int i=0; i<ndims; i++) {
+    status = nc_inq_dim(get_ncid(),dimids[i],name,&length);
+  
+    if (status != NC_NOERR)
+      error("Error while quering dimenstion: %s",nc_strerror(status));
+
+    set_dimid(i,dimids[i]);
+    dimnames.push_back(name);  
+    ncdimvec(i) = length;
+  }
+
+  // octave dimvec
+  // Number of dimensions is at least 2
+
+  dimvec.resize(max(ndims,2));
+
+  if (ndims > 1)
+    dimvec = ncdimvec;
+  else {
+    dimvec(1) = 1;
+
+    if (ndims == 1)
+      dimvec(0) = ncdimvec(0);
+    else 
+      dimvec(0) = 1;
+  }
+
+
+  ncv->dimvec = dimvec;
+  ncv->ncdimvec = ncdimvec;
+  set_dimnames(dimnames);
+}
+
+// Assigmnent of the type:
+// x.v = y     x(idx).v = y     x{idx}.v = y
+
+octave_value octave_ncvar::subsasgn(const std::string & type,
+			       const LIST < octave_value_list > &idx,
+			       const octave_value & rhs) {
+  octave_value scale_factor, add_offset, scaledrhs;
+  octave_value fillvalue;
+  octave_value retval;
+
+  switch (type[0])
+    {
+    case '.':
+      {
+	std::string name = idx.front()(0).string_value();
+
+	// convention of netcdf matlab toolbox
+        if (name == "FillValue_")
+	  name = "_FillValue";
+
+	get_ncfile()->set_mode(DefineMode);
+#       ifdef OV_NETCDF_VERBOSE
+	octave_stdout << "create attribute " << name << std::endl;
+#       endif
+
+
+	if (!rhs.is_cell()) {
+          nc_type nctype = ovtype2nctype(rhs);
+          ov_nc_put_att(get_ncid(),get_varid(),name,nctype,rhs);
+	}
+        else {
+#         ifdef OV_NETCDF_VERBOSE
+	  octave_stdout << "define attribute from cell " << get_ncid() << std::endl;
+#         endif
+
+          Cell c =  rhs.cell_value();
+          nc_type nctype = ncname2nctype(c.elem(0).string_value());
+   	  ov_nc_put_att(get_ncid(),get_varid(),name,nctype,c.elem(1));
+	}
+
+
+
+	break;
+      }
+    case '(':
+      {
+#       ifdef OV_NETCDF_VERBOSE
+	octave_stdout << "putting var " << std::endl;
+#       endif
+
+        scaledrhs = rhs;
+
+	// autoscale the retrieved variable if necessary
+	// the variables attributes "scale_factor" and "add_offset" are
+	// used for the linear scale if present.
+
+	if (autoscale()) {
+	  add_offset = ov_nc_get_att(get_ncid(),get_varid(),"add_offset");
+
+	  if (!add_offset.is_empty()) {
+	    scaledrhs = scaledrhs - add_offset;
+	  }
+
+	  scale_factor = ov_nc_get_att(get_ncid(),get_varid(),"scale_factor");
+ 
+	  if (!scale_factor.is_empty()) {
+	    scaledrhs = scaledrhs / scale_factor;
+	  }
+	}
+
+
+	//
+	// replace NaN by _FillValue if requested
+	//
+
+	if (autonan()) {
+	  fillvalue = ov_nc_get_att(get_ncid(),get_varid(),"_FillValue");
+
+          if (!fillvalue.is_empty()) {
+            if ( scaledrhs.numel() == 1) {
+              if (isnan(scaledrhs.scalar_value())) 
+		scaledrhs = fillvalue;
+	    }
+            else
+	      for (int i=0; i < scaledrhs.numel(); i++) {
+		if (isnan(scaledrhs.array_value().xelem(i)))
+		  scaledrhs.array_value().xelem(i) = fillvalue.scalar_value();
+	      }
+	  }
+	}
+
+
+	get_ncfile()->set_mode(DataMode);
+	octave_value_list key_idx = *idx.begin();
+	std::list<Range> ranges = get_slice(key_idx);
+
+        if (error_state)  return retval;
+ 
+	ov_nc_put_vars(get_ncid(),get_varid(),ranges,get_nctype(),scaledrhs);
+
+	retval = rhs;
+	break;
+      }
+    case '{':
+      {
+	error("octave_ncvar cannout be referenced with {}");
+	break;
+      }
+      break;
+
+    }
+
+  // update characteristics
+  read_info();
+
+# ifdef OCTAVE_VALUE_COUNT_CONSTRUCTOR
+  retval = octave_value(this, count + 1);
+# else
+  retval = octave_value(clone());
+# endif
+
+  return retval;
+};
+
+
+// References of the type:
+// x.v     x(idx)     x{idx}
+
+octave_value octave_ncvar::subsref(const std::string SUBSREF_STRREF type,
+			      const LIST < octave_value_list > &idx)
+{
+  octave_value scale_factor, add_offset;
+  octave_value fillvalue;
+  octave_value retval;
+
+
+  switch (type[0])
+    {
+    case '.':
+      {
+	std::string name = idx.front()(0).string_value();
+
+	// convention of netcdf matlab toolbox
+        if (name == "FillValue_")
+	  name = "_FillValue";
+
+
+#       ifdef OV_NETCDF_VERBOSE
+	octave_stdout << "getting attribute " << name << std::endl;
+#       endif
+
+	retval = ov_nc_get_att(get_ncid(),get_varid(),name);
+
+	break;
+      }
+    case '(':
+      {
+#       ifdef OV_NETCDF_VERBOSE
+	octave_stdout <<  __LINE__ << ":"  << __FUNCTION__ << "getting var " << std::endl;
+#       endif
+	get_ncfile()->set_mode(DataMode);
+	octave_value_list key_idx = idx.front();
+	std::list<Range> ranges = get_slice(key_idx);
+
+        if (error_state)  return retval;
+
+	retval = ov_nc_get_vars(get_ncid(),get_varid(),ranges,get_nctype());
+
+	if (autonan()) {
+	  fillvalue = ov_nc_get_att(get_ncid(),get_varid(),"_FillValue");
+
+          if (!fillvalue.is_empty()) {
+            for (int i=0; i<retval.numel(); i++)
+	      if (retval.array_value().xelem(i) == fillvalue.scalar_value()) 
+	        retval.array_value().xelem(i) = octave_NaN;
+	  }
+	}
+
+
+	// autoscale the retrieved variable if necessary
+	// the variables attributes "scale_factor" and "add_offset" are
+	// used for the linear scale if present.
+
+	if (autoscale()) {
+	  scale_factor = ov_nc_get_att(get_ncid(),get_varid(),"scale_factor");
+ 
+	  if (!scale_factor.is_empty()) {
+	    retval = retval * scale_factor;
+	  }
+
+	  add_offset = ov_nc_get_att(get_ncid(),get_varid(),"add_offset");
+	  if (!add_offset.is_empty()) {
+	    retval = retval + add_offset;
+	  }
+	}
+
+	break;
+      }
+    case '{':
+      {
+	error("octave_ncvar cannot not be indexed with {}");
+	break;
+      }
+      break;
+
+    }
+
+  // apply remaining subreference operator
+
+  return retval.next_subsref(type, idx);
+}
+
+
+void  octave_ncvar::print(std::ostream & os, bool pr_as_read_syntax = false) const
+{
+  int i;
+
+  os << "varname = \"" << get_varname() << "\"" << std::endl;
+  os << "type = " << nctype2ncname(get_nctype()) << endl;;
+# ifdef OV_NETCDF_VERBOSE
+  os << "ncid = " << get_ncid() << std::endl;
+  os << "varid = " << get_varid() << std::endl;
+# endif
+  os << "natts = " << get_natts() << std::endl;
+
+  os << "autoscale = " << (int)autoscale() << std::endl;
+  os << "autonan = " << (int)autonan() << std::endl;
+
+  os << "size = " << dims().str() << std::endl;
+  os << "ncsize = " << ncv->ncdimvec.str() << std::endl;
+
+//   os << "size = ";
+//   for (i=0; i<ndims()-1; i++) {
+//     os << ncv->dimvec(i) << " x ";
+//   }
+  
+//   os << ncv->dimvec(ndims()-1) << std::endl;
+
+  //  std::list<std::string> dimnames = get_dimnames();
+  std::list<std::string>::const_iterator it;
+
+  i=1;
+  for(it=ncv->dimnames.begin(); it!=ncv->dimnames.end(); ++it) {
+    os << "dimension " << i << " = "  << *it << std::endl;
+    os << "dimension id " << i << " = "  << ncv->dimids[i-1] << std::endl;
+    i=i+1;
+  } 
+
+
+}
+
+
+// determine the slice of the variable to read or to store depending 
+// on the ranges given in key_idx
+
+std::list<Range> octave_ncvar::get_slice(octave_value_list key_idx)
+{
+
+  //std::string key = key_idx(0).string_value ();
+
+  std::list<Range> ranges;
+  dim_vector dv;
+  dv.resize(ncndims());
+
+  // special case: if only one colone, then retrieve all data
+
+  if (key_idx.length() == 1 && key_idx(0).is_magic_colon())
+    {
+      for (int i = 0; i < ncndims(); i++)
+	{
+	  ranges.push_back(Range(1. , (double)dims()(i), 1.));
+	}
+    }
+  else
+    {
+      for (int i = 0; i < ncndims(); i++)
+	{
+	  if (key_idx(i).is_range())  {
+	      ranges.push_back(key_idx(i).range_value());
+	    }
+	  else if (key_idx(i).is_magic_colon()) {
+	      ranges.push_back(Range(1. , (double)dims()(i)));
+	    }
+	  else if (key_idx(i).is_real_scalar())  {
+              ranges.push_back(Range(key_idx(i).scalar_value(),key_idx(i).scalar_value()));
+	  }
+	  else if (key_idx(i).is_matrix_type())  {
+            Matrix m =  key_idx(i).matrix_value();
+
+            if (m.rows() != 1) m = m.transpose();
+              
+            Range r = Range(m(0),m(m.numel()-1),m(1)-m(0));
+
+            if (r.inc() <= 0) {
+   	      error("octcdf: indexes must be increasing");
+   	      return ranges;
+	    }
+
+            if (r.matrix_value() != m) {
+   	      error("octcdf: indexes must be contiguous");
+   	      return ranges;
+	    }
+
+            ranges.push_back(r);
+	  }
+          else {
+ 	    error("octcdf: unknown index specification: type %s",key_idx(i).type_name().c_str());
+	    return ranges;
+	  }
+	}
+    }
+
+
+  if (STORAGE_ORDER == FORTRAN_ORDER)
+     ranges.reverse();
+
+
+  return ranges;
+}
+
+
+
+void octave_ncvar::rename(string new_name) {
+  int status;
+    
+  status = nc_rename_var(get_ncid(),get_varid(), new_name.c_str()); 
+
+  if (status != NC_NOERR) {
+    error("Error while renaming variable %s: %s", get_varname().c_str(),
+	  nc_strerror(status));
+    return;
+  }
+
+  set_varname(new_name);
+}
+
+DEFINE_OCTAVE_ALLOCATOR(octave_ncvar);
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_ncvar, "ncvar", "ncvar");
+
+// end octave_ncvar
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-ncvar.h	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,157 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+#if !defined (octave_ncvar_int_h)
+#define octave_ncvar_int_h 1
+
+#include "ov-netcdf.h"
+
+typedef struct {
+  std::list<std::string> dimnames;
+  int dimids[NC_MAX_VAR_DIMS];
+
+  //std::list <std::string> dimnames;
+  nc_type nctype;
+  int ncid;
+
+  // Octave-like dim_vector. A scale would have a dimension of 1x1
+  dim_vector dimvec;
+
+  // NetCDF-like dim_vector. A scale would have a dimension of 0
+  dim_vector ncdimvec;
+
+  int varid, natts;
+  octave_ncfile* ncfile;
+  std::string varname;
+  bool autoscale;
+  bool autonan;
+
+}  ncvar_t ;
+
+class octave_ncvar:public octave_base_value {
+public:
+  octave_ncvar(void):octave_base_value(), ncv(NULL) {}
+
+  octave_ncvar(const octave_ncvar& nc_val):octave_base_value(), ncv(nc_val.ncv) { }
+
+  octave_ncvar(octave_ncfile* ncfilep, int varid);
+   
+  octave_ncvar(octave_ncfile* ncfilep, std::string varnamep);
+
+  octave_ncvar(nc_type nctypep, std::list <std::string> dimnamesp):octave_base_value(), ncv(NULL) { }
+
+  OV_REP_TYPE *clone(void) const { return new octave_ncvar(*this); }
+
+// x.v = y     x(idx).v = y     x{idx}.v = y
+
+  octave_value subsasgn(const std::string & type,
+			const LIST < octave_value_list > &idx,
+			const octave_value & rhs);
+
+  octave_value subsref(const std::string SUBSREF_STRREF type,
+		       const LIST < octave_value_list > &idx);
+
+  octave_value_list do_multi_index_op(int, const octave_value_list &)
+  {
+    error("octave_object: do_multi_index_op(nargout,args)");
+    return octave_value_list();
+  }
+
+  ~octave_ncvar()  { }
+ 
+  void read_info();
+
+  /* Query Interface for octave */
+
+  // Get dim_vector following Octave conventions
+
+  dim_vector dims() const { return ncv->dimvec; }
+
+  int ndims() const  { return dims().length(); }
+
+  octave_idx_type numel() const  { return dims().numel(); }
+
+  // Get dim_vector following NetCDF conventions
+
+  dim_vector ncdims() const {  return ncv->ncdimvec; }
+
+  int ncndims() const  { return ncdims().length(); }
+
+
+  void print(std::ostream & os, bool pr_as_read_syntax) const;
+
+  bool is_constant(void) const  {
+    return true;
+  }
+  bool is_defined(void) const  {
+    return true;
+  }
+  bool is_map(void) const  {
+    return true;
+  }
+
+  bool& autoscale() { return ncv->autoscale; };
+  bool autoscale() const { return ncv->autoscale; };
+
+  bool& autonan() { return ncv->autonan; };
+  bool autonan() const { return ncv->autonan; };
+
+  /* Query Interface for netcdf related information */
+
+  std::list<Range> get_slice(octave_value_list key_idx);
+
+  nc_type get_nctype(void) const { return ncv->nctype; };
+  octave_ncfile* get_ncfile() const { return ncv->ncfile; };
+  int get_varid() const { return ncv->varid; };
+  int get_ncid() const { return ncv->ncid; };
+  int get_natts() const { return ncv->natts; };
+  std::string get_varname() const { return ncv->varname; };
+  int get_dimid(int i) const { return ncv->dimids[i]; };
+  std::list<std::string> get_dimnames() const { return ncv->dimnames; };
+
+
+  void set_nctype(const nc_type t) { ncv->nctype = t; };
+  void set_ncfile(octave_ncfile* t) { ncv->ncfile = t; };
+  void set_varid(const int& t)  { ncv->varid = t; };
+  void set_ncid(const int& t)  { ncv->ncid = t; };
+  void set_natts(const int& t)  { ncv->natts = t; };
+  void set_varname(const std::string& t) { ncv->varname = t; };
+  void set_dimid(int i,int t) const { ncv->dimids[i] = t; };
+  void set_dimnames(const std::list<std::string> t) { ncv->dimnames = t; };
+
+  void rename(string new_name);
+
+  ncvar_t* ncv;
+
+private:
+
+  DECLARE_OCTAVE_ALLOCATOR 
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+};
+
+
+// end octave_ncvar
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-netcdf.cc	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,1088 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+#include "ov-netcdf.h"
+#include "ov-ncfile.h"
+#include "ov-ncvar.h"
+#include "ov-ncatt.h"
+#include "ov-ncdim.h"
+
+
+#define CAST_DARRAY(arr) NDArray(arr)
+#define CAST_CARRAY(arr) charNDArray(arr)
+
+//
+// Reverse dimension vector
+//
+
+dim_vector reverse(dim_vector dv) {
+  dim_vector rdv = dv;
+
+  for (int i = 0; i < dv.length(); i++) {
+      rdv(i) = dv(dv.length() - i - 1);
+    }
+
+  return rdv;
+}
+
+static bool netcdf_type_loaded = false;
+
+void load_netcdf_type () {
+  octave_ncfile::register_type ();
+  octave_ncvar::register_type ();
+  octave_ncatt::register_type ();
+  octave_ncdim::register_type ();
+
+  netcdf_type_loaded = true;
+
+  // Lock constructor function in place, otherwise
+  // "nc=netcdf("file.nc","r"); clear functions; nc" generates a seg-fault!!
+
+  mlock("netcdf");
+  mlock("ncvar");
+  mlock("ncatt");
+  mlock("ncdim");
+}
+
+
+void check_args_string(std::string funname, octave_value_list args) {
+
+  for (int i=0; i< args.length(); i++) {
+    if (!args(i).is_string()) {
+      error("%s: all arguments should be string arguments",funname.c_str());
+    }
+  }  
+}
+
+
+
+
+
+DEFUN_DLD(netcdf, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} {@var{nc} = } netcdf(@var{filename},@var{mode}) \n\
+open or create a netcdf file given by @var{filename}. This function returns a netcdf file object. Possible values of @var{mode} are: \n\
+@itemize \n\
+@item \"r\", \"nowrite\": \
+opens an existing file in read-only mode. \n\
+@item \"w\", \"write\": \
+opens an existing file in read-write mode. \n\
+@item \"c\", \"clobber\": \
+creates a new file and possibly overwrites existing data sets. \n\
+@item \"nc\", \"noclobber\": \
+creates a new file but an existing data sets in the netcdf file cannot be overwritten.\n\
+@end itemize \n\
+@end deftypefn\n\
+@seealso{ncclose}\n")
+{
+  if (! netcdf_type_loaded )
+    load_netcdf_type ();
+
+  if (args.length() != 2) {
+      print_usage ();
+      return octave_value();
+  }
+
+  check_args_string("netcdf",args);
+
+  if (error_state)
+    return octave_value();
+
+
+  octave_ncfile *nc = new octave_ncfile(args(0).string_value(), args(1).string_value());
+
+  return octave_value(nc);
+}
+
+
+DEFUN_DLD(ncsync, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncsync(@var{nc}) \n\
+All changes are written to the disk.\n\
+@end deftypefn\n\
+@seealso{ncclose}\n")
+{
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+    ncfile.sync();
+  } else {
+    error("Error argument should be an ncfile");
+  }
+
+  return octave_value();
+}
+
+DEFUN_DLD(ncclose, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncclose(@var{nc}) \n\
+closes the netcdf file @var{nc} and all changes are written to the disk.\n\
+@end deftypefn\n\
+@seealso{netcdf,ncsync}\n")
+{
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+# ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "close file "  << std::endl;
+# endif
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+    ncfile.close();
+  } else {
+    error("Error argument should be an ncfile");
+  }
+
+  return octave_value();
+}
+
+DEFUN_DLD(ncredef, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncredef(@var{nc}) \n\
+Place an open NetCDF file in \"define\" mode, so that NetCDF entities can be added, renamed, modified, or deleted. With the octcdf toolbox, the \"define\" mode is entered automatically as needed.\n\
+@end deftypefn\n\
+@seealso{ncenddef}\n")
+{
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+    ncfile.set_mode(DefineMode);
+  } else {
+    error("Error argument should be an ncfile");
+  }
+
+  return octave_value();
+}
+
+
+
+DEFUN_DLD(ncenddef, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncenddef(@var{nc}) \n\
+Take an open NetCDF file out of \"define\" mode. The resulting state is called \"data\" mode. With the octcdf oolbox, the \"data\" mode is entered automatically as needed. \n\
+@end deftypefn\n\
+@seealso{ncredef}\n")
+{
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+    ncfile.set_mode(DataMode);
+  } else {
+    error("Error argument should be an ncfile");
+  }
+
+  return octave_value();
+}
+
+
+
+DEFUN_DLD(ncvar, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncvar(@var{nc}) \n\
+Creates a cell array of all variables in a NetCDF file. The content of a NetCDF variable can be accessed by using the \"(:)\" operator. \n\
+@end deftypefn\n\
+Example: \n\
+@example \n\
+nc = netcdf('test.nc','r'); \n\
+nv = ncvar(nc)@{1@}; % gets the first variable in test.nc \n\
+myvar = nv(:);     % copies the content of this NetCDF variable is myvar. \n\
+@end example \n\
+@seealso{ncatt,ncdim,ncname,ncdatatype}\n")
+{
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+
+    Cell  vars = Cell (dim_vector(1,ncfile.get_nvars()));
+
+    for (int i=0; i<ncfile.get_nvars(); i++) {
+      octave_ncvar *v = new octave_ncvar(&ncfile,i);
+      vars(i) = octave_value(v);
+    }
+
+    return octave_value(vars);
+  } 
+  else {
+    error("Error argument should be an ncfile");
+  }
+
+  return octave_value();
+}
+
+
+
+DEFUN_DLD(ncatt, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncatt(@var{nc}) \n\
+@deftypefnx {Loadable Function} ncatt(@var{nv}) \n\
+Creates a cell array of all global attributes of NetCDF file @var{nc} or all attributes of variable @var{nv}. The content of a NetCDF attribute can be accessed by using the \"(:)\" operator. \n\
+@end deftypefn\n\
+Example: \n\
+@example \n\
+nc = netcdf('test.nc','r'); \n\
+na = ncatt(nc)@{1@}; % gets the first global attribute in test.nc \n\
+myvar = na(:);     % copies the content of this NetCDF attribute is myvar. \n\
+@end example \n\
+@seealso{ncvar,ncdim,ncname,ncdatatype}\n")
+{
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+
+    Cell  vars = Cell (dim_vector(1,ncfile.get_natts()));
+
+    for (int i=0; i<ncfile.get_natts(); i++) {
+      octave_ncatt *v = new octave_ncatt(&ncfile,i);
+      vars(i) = octave_value(v);
+    }
+
+    return octave_value(vars);
+  } 
+  else if (args(0).class_name() == "ncvar") {
+    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
+
+    Cell  vars = Cell (dim_vector(1,ncvar.get_natts()));
+
+    for (int i=0; i<ncvar.get_natts(); i++) {
+      octave_ncatt *v = new octave_ncatt(&ncvar,i);
+      vars(i) = octave_value(v);
+    }
+
+    return octave_value(vars);
+  } 
+  else {
+    error("Error argument should be an ncfile or ncvar");
+  }
+
+  return octave_value();
+}
+
+DEFUN_DLD(ncdim, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncdim(@var{nc}) \n\
+@deftypefnx {Loadable Function} ncdim(@var{nv}) \n\
+Creates a cell array of all dimenstion in a NetCDF file. The length of the NetCDF length can be queried by using the \"(:)\" operator. \n\
+@end deftypefn\n\
+@seealso{ncvar}\n")
+{
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+
+    Cell  vars = Cell (dim_vector(1,ncfile.get_ndims()));
+
+    for (int i=0; i<ncfile.get_ndims(); i++) {
+      octave_ncdim *v = new octave_ncdim(&ncfile,i);
+      vars(i) = octave_value(v);
+    }
+
+    return octave_value(vars);
+  } 
+  else if (args(0).class_name() == "ncvar") {
+    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
+
+    //    Cell  vars = Cell (dim_vector(1,ncvar.ndims()));
+    Cell  vars = Cell (dim_vector(1,ncvar.ncdims().length() ));
+
+    for (int i=0; i < ncvar.ncdims().length(); i++) {
+      octave_ncdim *d = new octave_ncdim(ncvar.get_ncfile(),ncvar.get_dimid(i));
+      vars(i) = octave_value(d);
+    }
+    
+    return octave_value(vars);
+    
+  } 
+  else {
+    error("Error argument should be an ncfile or ncvar");
+  }
+
+  return octave_value();
+}
+
+
+
+DEFUN_DLD(ncname, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncname(@var{nc}) \n\
+@deftypefnx {Loadable Function} ncname(@var{nv}) \n\
+@deftypefnx {Loadable Function} ncname(@var{na}) \n\
+@deftypefnx {Loadable Function} ncname(@var{nd}) \n\
+@deftypefnx {Loadable Function} ncname(@var{nv},@var{new_name}) \n\
+@deftypefnx {Loadable Function} ncname(@var{na},@var{new_name}) \n\
+@deftypefnx {Loadable Function} ncname(@var{nd},@var{new_name}) \n\
+Gets the name of the NetCDF file @var{nc}, variable @var{nv}, attributes \n\
+@var{na} or dimension @var{nd}. If it is called with a second argument, the \n\
+corresponding NetCDF object will be renamed. Only variables, attributes and \n\
+dimensions can be renamed. \n\
+@end deftypefn\n\
+@seealso{ncvar,ncatt,ncdim}\n")
+{
+
+  if (args.length() > 2) {
+    print_usage ();
+    return octave_value();
+  }
+
+  if (args(0).class_name() == "ncfile") {
+    octave_ncfile& ncfile = (octave_ncfile&)args(0).get_rep();
+
+    if (args.length() == 1) 
+      return octave_value(ncfile.get_filename());
+    else
+      error("Error: cannot rename a ncfile");
+  }
+
+  else if (args(0).class_name() == "ncvar") {
+    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
+
+    if (args.length() == 1) 
+      return octave_value(ncvar.get_varname());
+    else
+      ncvar.rename(args(1).string_value());
+  }
+
+  else if (args(0).class_name() == "ncatt") {
+    octave_ncatt& ncatt = (octave_ncatt&)args(0).get_rep();
+
+    if (args.length() == 1) 
+      return octave_value(ncatt.get_name());
+    else
+      ncatt.rename(args(1).string_value());
+  }
+
+  else if (args(0).class_name() == "ncdim") {
+    octave_ncdim& ncdim = (octave_ncdim&)args(0).get_rep();
+
+    if (args.length() == 1) 
+      return octave_value(ncdim.get_name());
+    else
+      ncdim.rename(args(1).string_value());
+
+  }
+  else {
+    error("Error argument should be an ncfile, ncvar, ncatt or ncdim");
+  }
+
+  return octave_value();
+}
+
+
+DEFUN_DLD(ncdatatype, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} ncdatatype(@var{nv}) \n\
+@deftypefnx {Loadable Function} ncdatatype(@var{na}) \n\
+Gets the datatype of the NetCDF variable @var{nv} or attributes @var{na}. \n\
+@end deftypefn\n\
+@seealso{ncvar,ncatt,ncdim}\n")
+{
+  nc_type type;
+
+  if (args.length() != 1) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() == "ncvar") {
+    octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
+    type = ncvar.get_nctype();
+  }
+  else if (args(0).class_name() == "ncatt") {
+    octave_ncatt& ncatt = (octave_ncatt&)args(0).get_rep();
+    type = ncatt.get_nctype();
+  }
+  else {
+    error("Error argument should be an ncvar or ncatt");
+    return octave_value();
+  }
+
+  return octave_value(nctype2ncname(type));
+}
+
+
+
+DEFUN_DLD(ncautonan, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} @var{status} = ncautonan(@var{nv}) \n\
+@deftypefnx {Loadable Function} @var{nv} = ncautonan(@var{nv},@var{status}) \n\
+If ncautonan is called with one argument, it returns the autonan status of the  \n\
+NetCDF variable @var{nv}. With two arguments, it sets the autonan status to @var{status}.  \n\
+If autonan status is 1, all NaNs in the octave variable to store are replaced by the corresponding  \n\
+value of the _FillValue attribute. This feature is disabled if autonan is 0 (default). \n\
+@end deftypefn\n\
+@seealso{ncautoscale}\n")
+{
+
+  if (args.length() != 1 && args.length() != 2) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() != "ncvar" ) {
+      print_usage ();
+      return octave_value();
+    }
+
+   octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
+
+  if (args.length() == 1) {
+    return octave_value(ncvar.autonan());
+  }
+  else {
+     ncvar.autonan() = args(1).scalar_value() == 1;
+    return octave_value(ncvar.clone());
+  }
+}
+
+DEFUN_DLD(ncautoscale, args,, 
+"-*- texinfo -*-\n\
+@deftypefn {Loadable Function} @var{status} = ncautoscale(@var{nv}) \n\
+@deftypefnx {Loadable Function} @var{nv} = ncautoscale(@var{nv},@var{status}) \n\
+If ncautoscale is called with one argument, it returns the autoscale status of the  \n\
+NetCDF variable @var{nv}. With two arguments, it sets the autoscale status to @var{status}.  \n\
+If autoscale status is 1, octave variable to store are scaled by the corresponding  \n\
+value of the add_offset and scale_factor attribute:   \n\
+@example \n\
+octave_variable = scale_factor * netcdf_variable + add_offset  \n\
+@end example \n\
+This feature is disabled if autoscale is 0 (default). \n\
+@end deftypefn\n\
+@seealso{ncautoscale}\n")
+{
+
+  if (args.length() != 1 && args.length() != 2) {
+      print_usage ();
+      return octave_value();
+    }
+
+  if (args(0).class_name() != "ncvar" ) {
+      print_usage ();
+      return octave_value();
+    }
+
+   octave_ncvar& ncvar = (octave_ncvar&)args(0).get_rep();
+
+  if (args.length() == 1) {
+    return octave_value(ncvar.autoscale());
+  }
+  else {
+     ncvar.autoscale() = args(1).scalar_value() == 1;
+    return octave_value(ncvar.clone());
+  }
+}
+
+
+//
+// wrapper around the nc_get_att_* functions which provides directly an 
+// octave_value of the appropriate type
+// 
+
+octave_value ov_nc_get_att(int ncid, int varid,const std::string name) {
+  int status;
+  octave_value retval;
+  size_t lenp;
+  nc_type xtypep;
+
+  status =
+    nc_inq_att(ncid, varid,name.c_str(), &xtypep, &lenp);
+
+  if (status != NC_NOERR) {
+    // attrinute doesn't exist -> return an empty matrix
+    return octave_value(Matrix(0,0));
+  }
+
+  switch (xtypep)
+    {
+    case NC_CHAR:
+      {
+	char *var = new char[lenp + 1];
+	status =
+	  nc_get_att_text(ncid, varid,name.c_str(),
+			  var);
+        if (status  != NC_NOERR)                                      
+	  error("Error while retrieving attribute %s: %s",            
+	 	name.c_str(),nc_strerror(status));                    
+
+	var[lenp] = 0; 
+	retval = octave_value(var);
+	break;
+      }
+
+      // cpp macro to avoid repetetive code
+
+#define OV_NETCDF_ATT_CASE(netcdf_type,c_type,nc_get_att)		\
+      case netcdf_type:							\
+	{                                                               \
+	  c_type *var = new c_type[lenp];                               \
+	  status = nc_get_att(ncid,varid,name.c_str(),var);             \
+									\
+	  if (status  != NC_NOERR)                                      \
+	    error("Error while retrieving attribute %s: %s",            \
+		  name.c_str(),nc_strerror(status));                    \
+									\
+	  if (lenp == 1) {					        \
+	    retval = octave_value(*var);                                \
+	  } else {                                                      \
+	    ArrayN<double> arr =  ArrayN<double>(dim_vector(lenp));	\
+	    for (unsigned int i=0; i<lenp; i++) {                       \
+	      arr.xelem(i) = (double)var[i];                            \
+	    }                                                           \
+	    retval = octave_value(arr);                                 \
+	  }                                                             \
+									\
+	  delete var;                                                   \
+	  break;                                                        \
+	} 
+
+        OV_NETCDF_ATT_CASE(NC_BYTE,signed char,nc_get_att_schar)
+	OV_NETCDF_ATT_CASE(NC_SHORT,short,nc_get_att_short)
+	OV_NETCDF_ATT_CASE(NC_INT,int,nc_get_att_int)
+	OV_NETCDF_ATT_CASE(NC_FLOAT,float,nc_get_att_float)
+	OV_NETCDF_ATT_CASE(NC_DOUBLE,double,nc_get_att_double)
+	// for now int and long are the same in the netcdf library
+#if NC_INT!=NC_LONG
+	OV_NETCDF_ATT_CASE(NC_LONG,long,nc_get_att_long)
+#endif
+
+#undef OV_NETCDF_ATT_CASE
+
+	default: 
+      {
+        error("unkown netcdf type: %d",xtypep);
+
+      }
+    }       
+
+
+  return retval;
+
+}
+            
+
+void ov_nc_put_att(int ncid, int varid,const std::string name,
+   nc_type nctype,const octave_value rhs) {
+
+  int status,length;
+
+  //	    octave_stdout << "att2" << nctype << endl;
+
+  switch (nctype)  {
+    case NC_CHAR: {
+
+      status =
+	nc_put_att_text(ncid,varid, name.c_str(),
+			rhs.string_value().length(),
+			rhs.string_value().c_str());
+      break;
+      }
+
+#define OV_NETCDF_ATT_PUT_ARR_CASE(netcdf_type,c_type,nc_put_att) \
+    case netcdf_type: { \
+	c_type *var = ov_ctype<c_type>(rhs,length);   \
+	status = nc_put_att(ncid,varid, name.c_str(),nctype,(size_t)length,var); \
+        delete var; \
+	break; \
+    } \
+
+    OV_NETCDF_ATT_PUT_ARR_CASE(NC_BYTE,signed char,nc_put_att_schar)
+    OV_NETCDF_ATT_PUT_ARR_CASE(NC_SHORT,short,nc_put_att_short)
+    OV_NETCDF_ATT_PUT_ARR_CASE(NC_INT,int,nc_put_att_int)
+    OV_NETCDF_ATT_PUT_ARR_CASE(NC_FLOAT,float,nc_put_att_float)
+    OV_NETCDF_ATT_PUT_ARR_CASE(NC_DOUBLE,double,nc_put_att_double)
+      // for now int and long are the same in the netcdf library
+#if NC_INT!=NC_LONG
+    OV_NETCDF_ATT_PUT_ARR_CASE(NC_LONG,long,nc_put_att_long)
+#endif
+
+    default: {
+	status = NC_NOERR;
+	error("Unkown type of variable: %d", nctype);        
+    } 
+  }
+
+}
+
+
+
+octave_value ov_nc_get_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype) {
+
+  int ncndim = ranges.size();
+  octave_value retval;
+  long *start = new long[ncndim];
+  long *count = new long[ncndim];
+  long *stride = new long[ncndim];
+  long sliced_numel;
+  ArrayN<double> arr;
+  dim_vector sliced_dim_vector;
+  int status;
+  Array<int> perm_vector(ncndim);
+
+
+  sliced_dim_vector.resize(ncndim);
+
+  int i = 0;
+  std::list<Range>::const_iterator it;
+
+  for(it=ranges.begin(); it!=ranges.end(); ++it)
+    { 
+      start[i] =  (long int) (*it).min() - 1;
+      count[i] = (*it).nelem();
+      stride[i] = (long int) (*it).inc();
+      sliced_dim_vector(i) =  count[i];
+
+      // since Octave 2.9.3 Array<T>::permute expect a zero-
+      // based permuation vector while Octave 2.1.71 seems to 
+      // be happy with a one-based permutation vector
+
+#     ifdef OCTAVE_PERMVEC_ZEROBASED      
+      perm_vector(i) = ncndim-i-1;
+#     else
+      perm_vector(i) = ncndim-i;
+#     endif
+
+      i=i+1;
+    }
+
+  sliced_numel = sliced_dim_vector.numel();
+
+#define OV_NETCDF_GET_VAR_CASE(netcdf_type,c_type,nc_get_vars)		   \
+  case netcdf_type:							   \
+    {									   \
+      c_type *var = new c_type[sliced_numel];				   \
+      status =								   \
+	nc_get_vars(ncid, varid, (const size_t *) start,		   \
+		    (const size_t *) count,				   \
+		    (const ptrdiff_t *) stride, var);			   \
+									   \
+      if (status != NC_NOERR)						   \
+	error("Error while retrieving variable: %s", nc_strerror(status)); \
+									   \
+      arr = ArrayN < double >(reverse(sliced_dim_vector));		   \
+									   \
+      for (int i = 0; i < sliced_numel; i++)				   \
+	arr.xelem(i) = (double)var[i];					   \
+									   \
+      delete var;							   \
+                                                                           \
+      if (STORAGE_ORDER == FORTRAN_ORDER || ncndim == 1)	   		   \
+        retval = octave_value(CAST_DARRAY(arr));                           \
+      else                                                                 \
+        retval = octave_value(CAST_DARRAY(arr.permute(perm_vector)));	   \
+      break;								   \
+    }
+
+  switch (nctype) {
+
+      OV_NETCDF_GET_VAR_CASE(NC_BYTE,signed char,nc_get_vars_schar)
+      OV_NETCDF_GET_VAR_CASE(NC_SHORT,short,nc_get_vars_short)
+      OV_NETCDF_GET_VAR_CASE(NC_INT,int,nc_get_vars_int)
+      OV_NETCDF_GET_VAR_CASE(NC_FLOAT,float,nc_get_vars_float)
+      OV_NETCDF_GET_VAR_CASE(NC_DOUBLE,double,nc_get_vars_double)
+
+      case NC_CHAR: {
+
+	char *var = new char[sliced_numel];
+	status =
+	  nc_get_vars_text(ncid, varid, (const size_t *) start,
+			   (const size_t *) count,
+			   (const ptrdiff_t *) stride, var);
+
+	if (status != NC_NOERR)
+	  error("Error while retrieving variable: %s", nc_strerror(status));
+
+	//	charNDArray arr = charNDArray(reverse(sliced_dim_vector));
+	ArrayN<char> arr = ArrayN<char>(reverse(sliced_dim_vector));
+
+	for (int i = 0; i < sliced_numel; i++)
+	  arr.xelem(i) = (char)var[i];
+
+	delete var;
+
+        if (STORAGE_ORDER == FORTRAN_ORDER || ncndim == 1)                                  
+          retval = octave_value(CAST_CARRAY(arr),true);                                        
+        else                                                                 
+          retval = octave_value(CAST_CARRAY(arr.permute(perm_vector)),true);	  	   
+
+	break;
+      }
+
+    default:  {
+	error("Unkown type of variable: %d", nctype);
+        
+      } 
+    }
+
+
+  delete start;
+  delete count;
+  delete stride;
+
+  // in Octave, vectors are represented as matrices
+  // if the NetCDF object is a vector of length n
+  // we need to reshape it as a n-by-1 matrix
+
+  if (ncndim == 1) {
+    retval = retval.resize(dim_vector(retval.numel(),1));
+  }
+
+  return retval;
+}
+
+
+void ov_nc_put_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype,octave_value rhs) {
+
+
+  int ncndim = ranges.size();
+  octave_value retval;
+  long *start = new long[ncndim];
+  long *count = new long[ncndim];
+  long *stride = new long[ncndim];
+  long sliced_numel;
+  ArrayN<double> arr;
+  dim_vector sliced_dim_vector;
+  int status;
+
+  sliced_dim_vector.resize(ncndim);
+
+#  ifdef OV_NETCDF_VERBOSE
+  octave_stdout << " ov_nc_put_vars" << std::endl;
+#  endif
+
+  int i = 0;
+  std::list<Range>::const_iterator it;
+
+  for(it=ranges.begin(); it!=ranges.end(); ++it) { 
+      start[i] =  (long int) (*it).min() - 1;
+      count[i] = (*it).nelem();
+      stride[i] = (long int) (*it).inc();
+      sliced_dim_vector(i) =  count[i];
+      i=i+1;
+    }
+
+  Array<int> perm_vector(rhs.ndims());
+
+  for(i=0; i<rhs.ndims(); i++) { 
+    
+      // in Octave 2.9.3 Array<T>::permute expect a zero-
+      // based permuation vector while Octave 2.1.71 seems to 
+      // be happy with a one-based permutation vector
+
+#     ifdef OCTAVE_PERMVEC_ZEROBASED      
+      perm_vector(i) = rhs.ndims()-i-1;
+#     else
+      perm_vector(i) = rhs.ndims()-i;
+#     endif
+  }
+
+  sliced_numel = sliced_dim_vector.numel();
+
+#  ifdef OV_NETCDF_VERBOSE
+  octave_stdout << "type " <<  rhs.type_name() << NC_INT << std::endl;
+  octave_stdout << "class " <<  rhs.class_name() << std::endl;
+  octave_stdout << "id " <<  rhs.type_id() << std::endl;
+#  endif
+
+  // check number of elements
+
+  if (rhs.numel() !=  sliced_numel && rhs.numel() != 1) 
+    error("unexpected number of elements, found %d, expected 1 or %d ",rhs.numel(),sliced_numel);
+
+  switch (nctype)
+    {
+    case NC_CHAR:
+      {
+
+	char *var = new  char[sliced_numel];
+
+	if (rhs.numel() == 1) {
+	  for (int i = 0; i < sliced_numel; i++) {
+	      var[i] =  (char)rhs.string_value()[0];
+	    }
+	} 
+	else {
+	  ArrayN<char> arr =  rhs.char_array_value();
+									
+          if (STORAGE_ORDER == C_ORDER && ncndim > 1 )				
+	      arr = arr.permute(perm_vector);				
+
+	  for (int i = 0; i < sliced_numel; i++) {
+	      var[i] =  (char)arr.xelem(i);
+	    }
+	}
+
+	status =
+	  nc_put_vars_text(ncid, varid, (const size_t *) start,
+			   (const size_t *) count,
+			   (const ptrdiff_t *) stride, var);
+	delete var;
+
+	break;
+      }
+
+
+#define OV_NETCDF_PUT_VAR_CASE(netcdf_type,c_type,nc_put_vars)		\
+      case netcdf_type:							\
+	{								\
+	  if (rhs.is_string())						\
+	    error("unexpected type: %s",rhs.type_name().c_str());	\
+									\
+	  c_type *var = new  c_type[sliced_numel];			\
+									\
+	  if (rhs.is_scalar_type()) {					\
+	    for (int i = 0; i < sliced_numel; i++)  {	      	        \
+		var[i] =  (c_type)rhs.scalar_value();			\
+	      }								\
+	  }								\
+	  else {							\
+	    ArrayN<double> arr = rhs.array_value();                     \
+									\
+	    if (STORAGE_ORDER == C_ORDER && ncndim > 1)		       	\
+	      arr = arr.permute(perm_vector);				\
+									\
+	    for (int i = 0; i < sliced_numel; i++) {			\
+		var[i] =  (c_type)arr.xelem(i);				\
+	      }								\
+	  }								\
+									\
+	  /* status will checked at end of switch */			\
+									\
+	  status =							\
+	    nc_put_vars(ncid, varid, (const size_t *) start,		\
+			(const size_t *)count,				\
+			(const ptrdiff_t *)stride, var);		\
+	  delete var;							\
+									\
+	  break;							\
+	}                                                           
+
+      OV_NETCDF_PUT_VAR_CASE(NC_BYTE,signed char,nc_put_vars_schar) 
+      OV_NETCDF_PUT_VAR_CASE(NC_SHORT,short,nc_put_vars_short) 
+      OV_NETCDF_PUT_VAR_CASE(NC_INT,int,nc_put_vars_int) 
+      OV_NETCDF_PUT_VAR_CASE(NC_FLOAT,float,nc_put_vars_float) 
+      OV_NETCDF_PUT_VAR_CASE(NC_DOUBLE,double,nc_put_vars_double) 
+      // for now int and long are the same in the netcdf library
+#if NC_INT!=NC_LONG
+      OV_NETCDF_PUT_VAR_CASE(NC_LONG,long,nc_put_vars_long) 
+#endif
+
+#undef OV_NETCDF_PUT_VAR_CASE
+
+      default: {
+	status = NC_NOERR;
+	error("Unkown type of variable: %d", nctype);        
+      } 
+    }
+
+
+  if (status != NC_NOERR) {
+      error("Error while stroring variable: %s", nc_strerror(status));
+  }
+
+
+  delete start;
+  delete count;
+  delete stride;
+
+}
+
+
+void ov_nc_def_var(int ncid,std::string name,nc_type nctype, std::list<std::string> dimnames) {
+  int status;
+  int ndims=0;
+  int varid;
+
+  int dimids[NC_MAX_VAR_DIMS];
+
+  if (STORAGE_ORDER == FORTRAN_ORDER)
+    dimnames.reverse();
+
+  std::list<std::string>::const_iterator it;
+  for(it=dimnames.begin(); it!=dimnames.end(); ++it) {
+    status = nc_inq_dimid (ncid,(*it).c_str(), &dimids[ndims]);
+
+    if (status != NC_NOERR)
+      error("Error while querying dimension %s: %s",
+	    (*it).c_str(), nc_strerror(status));
+
+#   ifdef OV_NETCDF_VERBOSE
+    octave_stdout << "query dimname " << *it << " id " <<  dimids[ndims] << std::endl; 
+#   endif
+    ndims=ndims+1;
+  } 
+
+  status = nc_def_var(ncid,name.c_str(),nctype,
+		      ndims,dimids,&varid);
+
+  if (status == NC_ENAMEINUSE) {
+    octave_stdout << "variable " << name.c_str() << " already exist" << std::endl;
+  }
+  else if (status != NC_NOERR) {
+    error("Error while defining variable %s: %s",
+	  name.c_str(), nc_strerror(status));
+  }
+
+}
+
+
+
+
+
+
+
+
+
+nc_type ncname2nctype(std::string name) {
+
+  if (name == "byte")
+    return NC_BYTE;
+  else if (name == "char")
+    return NC_CHAR;
+  else if (name == "short")
+    return NC_SHORT;
+  else if (name == "int")
+    return NC_INT;
+  else if (name == "long")
+    return NC_LONG;
+  else if (name == "float")
+    return NC_FLOAT;
+  else if (name == "double")
+    return NC_DOUBLE;
+  else {
+    error("Unkown type: %s",name.c_str());
+    return NC_NAT ;
+  }
+}
+
+std::string nctype2ncname(nc_type type) {
+
+  switch (type) {
+    case NC_BYTE: {
+      return "byte";
+      break;
+    }
+    case NC_CHAR: {
+      return "char";
+      break;
+    }
+    case NC_SHORT: {
+      return "short";
+      break;
+    }
+    case NC_INT: {
+      return "int";
+      break;
+    }
+#   if NC_INT!=NC_LONG
+    case NC_LONG: {
+      return "long";
+      break;
+    }
+#   endif
+    case NC_FLOAT: {
+      return "float";
+      break;
+    }
+    case NC_DOUBLE: {
+      return "double";
+      break;
+    }
+    default: {
+      return "unkown type";
+      break;
+    }
+  }
+}
+
+
+
+// guess netcdf type from octave type
+
+nc_type ovtype2nctype(const octave_value& val) {
+
+  if (val.is_string()) 
+    return NC_CHAR;
+#ifdef HAVE_OCTAVE_INT
+  if (val.type_id() == octave_int8_scalar::static_type_id() ||
+      val.type_id() == octave_int8_matrix::static_type_id())
+    return NC_BYTE;
+  if (val.type_id() == octave_int16_scalar::static_type_id() ||
+      val.type_id() == octave_int16_matrix::static_type_id())
+    return NC_SHORT;
+  if (val.type_id() == octave_int32_scalar::static_type_id() ||
+      val.type_id() == octave_int32_matrix::static_type_id())
+    return NC_INT;
+  if (val.type_id() == octave_int64_scalar::static_type_id() ||
+      val.type_id() == octave_int64_matrix::static_type_id())
+    return NC_LONG;
+#endif
+  else
+    return NC_DOUBLE;
+}
+
+template <class ctype> ctype* ov_ctype(octave_value val,int& n) {
+  ctype* var;
+  n = val.numel();
+  var = new ctype[n];
+
+  if (n == 1) 
+    var[0] =  (ctype)val.scalar_value();
+  else {
+    for (int i = 0; i < n; i++) {			
+      var[i] =  (ctype)val.array_value().xelem(i);				
+    }								
+  }
+
+  return var;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/octcdf/src/ov-netcdf.h	Sun Aug 20 13:29:36 2006 +0000
@@ -0,0 +1,120 @@
+/*
+  octcdf, a netcdf toolbox for octave 
+  Copyright (C) 2005 Alexander Barth <abarth@marine.usf.edu>
+
+  This program is free software; you can redistribute it and/or
+  modify it under the terms of the GNU General Public License
+  as published by the Free Software Foundation; either version 2
+  of the License, or (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+
+#if !defined (octave_netcdf_int_h)
+#define octave_netcdf_int_h 1
+
+#include<iostream>
+#include <octave/config.h>
+#include<octave/oct.h>
+#include<octave/parse.h>
+#include<octave/dynamic-ld.h>
+#include<octave/oct-map.h>
+#include<octave/oct-stream.h>
+#include <octave/ov-base.h>
+#include<octave/ov-base-scalar.h>
+#include<vector>
+#include<string>
+#include <netcdf.h>
+#include <ArrayN.h>
+
+#ifdef HAVE_OCTAVE_INT
+#include "ov-uint64.h"
+#include "ov-uint32.h"
+#include "ov-uint16.h"
+#include "ov-uint8.h"
+#include "ov-int64.h"
+#include "ov-int32.h"
+#include "ov-int16.h"
+#include "ov-int8.h"
+#endif
+
+#include "ov-scalar.h"
+#include "ov-range.h"
+#include "ov-cell.h"
+
+#ifdef HAVE_SLLIST_H
+#define LIST SLList
+#define LISTSIZE length
+#define SUBSREF_STRREF
+#else
+#include <list>
+#define LIST std::list
+#define LISTSIZE size
+#define SUBSREF_STRREF &
+#endif
+
+
+#define STORAGE_ORDER 1
+#define FORTRAN_ORDER 0
+#define C_ORDER 1
+
+//#define OCTCDF_64BIT_OFFSET 
+
+//#define  OV_NETCDF_VERBOSE
+
+#ifdef HAVE_OCTAVE_21
+#define octave_idx_type int
+#else
+#define OCTAVE_PERMVEC_ZEROBASED 
+#endif
+
+
+#ifndef OV_REP_TYPE
+#define OV_REP_TYPE octave_value
+#endif
+
+//#define OCTAVE_VALUE_COUNT_CONSTRUCTOR
+
+using namespace std;
+
+
+
+dim_vector reverse(dim_vector dv);
+
+typedef enum { DefineMode = 0, DataMode = 1 } Modes;
+
+
+
+
+
+octave_value ov_nc_get_att(int ncid, int varid,const std::string name);
+void ov_nc_put_att(int ncid, int varid,const std::string name,nc_type nctype,const octave_value rhs);
+
+octave_value ov_nc_get_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype);
+void ov_nc_put_vars(int ncid, int varid,std::list<Range> ranges,nc_type nctype,octave_value rhs);
+void ov_nc_def_var(int ncid,std::string name,nc_type nctype, std::list<std::string> dimnames);
+
+
+void check_args_string(std::string funname, octave_value_list args);
+
+nc_type ovtype2nctype(const octave_value& val);
+nc_type ncname2nctype(std::string name);
+std::string nctype2ncname(nc_type type);
+
+template <class ctype> ctype* ov_ctype(octave_value val,int& n);
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/