Codebase list ruby-netcdf / 9131e7d
Import upstream version 0.7.2+git20201128.1.3f8992e Debian Janitor 2 years ago
21 changed file(s) with 5269 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ruby-netcdf (0.7.2-6) UNRELEASED; urgency=medium
1
2 * Team upload.
3 * Bump watch file version to 4.
4 * Update lintian overrides.
5 * Bump Standards-Version to 4.5.1, no changes.
6
7 -- Bas Couwenberg <sebastic@debian.org> Fri, 06 Nov 2020 19:58:17 +0100
8
9 ruby-netcdf (0.7.2-5) unstable; urgency=medium
10
11 * Import upstream change: Drop obsolete, rewrite test (Closes: #960977)
12
13 -- Youhei SASAKI <uwabami@gfd-dennou.org> Fri, 22 May 2020 23:31:40 +0900
14
15 ruby-netcdf (0.7.2-4) unstable; urgency=medium
16
17 [ Bas Couwenberg ]
18 * Update gbp.conf to use --source-only-changes by default.
19 * Bump Standards-Version to 4.5.0, no changes.
20 * Bump debhelper compat to 10.
21
22 [ Youhei SASAKI ]
23 * Drop compat file, rely on debhelper-compat and bump compat level to 12
24 * Enable autopkgtest, salsa CI
25 * d/control: Add Rules-Requires-Root: no
26
27 -- Youhei SASAKI <uwabami@gfd-dennou.org> Tue, 07 Apr 2020 23:40:54 +0900
28
29 ruby-netcdf (0.7.2-3) unstable; urgency=medium
30
31 * Team upload.
32 * Drop autopkgtest to test installability.
33 (Closes: #905122)
34 * Add lintian override for testsuite-autopkgtest-missing.
35
36 -- Bas Couwenberg <sebastic@debian.org> Wed, 01 Aug 2018 19:17:24 +0200
37
38 ruby-netcdf (0.7.2-2) unstable; urgency=medium
39
40 * Team upload.
41 * Update copyright-format URL to use HTTPS.
42 * Update Vcs-* URLs for Salsa.
43 * Bump Standards-Version to 4.1.5, no changes.
44 * Add autopkgtest to test installability.
45 * Update watch file to use gemwatch.debian.net.
46 * Enable all hardening buildflags.
47 * Add lintian override for hardening-no-fortify-functions.
48
49 -- Bas Couwenberg <sebastic@debian.org> Sun, 29 Jul 2018 19:38:31 +0200
50
51 ruby-netcdf (0.7.2-1) unstable; urgency=medium
52
53 [ Bas Couwenberg ]
54 * Bump Standards-Version to 3.9.8, no changes.
55 * Add patch to fix 'length' spelling error.
56
57 [ Youhei SASAKI ]
58 * New upstream version 0.7.2
59 * Refresh patches
60 * set DH_RUBY_GEMSPEC explicitly
61 * Drop dh_installchangelogs: removed from upstream
62 * Drop ruby-netcdf.examples: Drop bin/ from upstream
63
64 -- Youhei SASAKI <uwabami@gfd-dennou.org> Wed, 28 Sep 2016 16:04:29 +0900
65
66 ruby-netcdf (0.7.1.1-7) unstable; urgency=medium
67
68 * Remove dbg package
69 * Add patch: fix spelling error
70 * Fix lintian warning: vcs-field-uses-insecure-uri
71 * Rebuild against Ruby 2.3
72 * Bump Standard Version: 3.9.7
73
74 -- Youhei SASAKI <uwabami@gfd-dennou.org> Tue, 01 Mar 2016 18:02:08 +0900
75
76 ruby-netcdf (0.7.1.1-6) unstable; urgency=medium
77
78 * Add patch: Replace git execution from gemspec
79
80 -- Youhei SASAKI <uwabami@gfd-dennou.org> Mon, 07 Dec 2015 02:19:35 +0900
81
82 ruby-netcdf (0.7.1.1-5) unstable; urgency=medium
83
84 * Update debian/changelog
85 * Refresh patch: fix location of netcdf_miss.rb
86 * Drop obsolete lintian-overrides: thanks to Sebastiaan Couwenberg
87
88 -- Youhei SASAKI <uwabami@gfd-dennou.org> Wed, 02 Sep 2015 21:20:50 +0900
89
90 ruby-netcdf (0.7.1.1-4) unstable; urgency=medium
91
92 * Add lintian overrides for wheezy backports
93
94 -- Youhei SASAKI <uwabami@gfd-dennou.org> Thu, 27 Aug 2015 19:54:31 +0900
95
96 ruby-netcdf (0.7.1.1-3) unstable; urgency=medium
97
98 * Team upload.
99 * Update copyright file, rename license shortnames:
100 - GPL-2.0+ -> GPL-2+
101 - Ruby's -> Ruby
102 * Rebuild for netcdf transition.
103
104 -- Bas Couwenberg <sebastic@debian.org> Mon, 24 Aug 2015 15:51:17 +0200
105
106 ruby-netcdf (0.7.1.1-2) unstable; urgency=medium
107
108 * Add patch: to support NetCDF 4.4.0-rc version
109 Thanks to Bas Couwenberg!
110
111 -- Youhei SASAKI <uwabami@gfd-dennou.org> Fri, 31 Jul 2015 12:05:12 +0900
112
113 ruby-netcdf (0.7.1.1-1) unstable; urgency=medium
114
115 [ Bas Couwenberg ]
116 * Add gbp.conf to use pristine-tar by default.
117 * Restructure control file with cme.
118
119 [ Youhei SASAKI ]
120 * Update debian/watch: use gemwatch
121 * Imported Upstream version 0.7.1.1 (Closes: #793976)
122 - Thanks to Bas Couwenberg!
123 * Running all tests during build
124 * Refresh patches
125 * Install "demo", "bin" as examples
126
127 -- Youhei SASAKI <uwabami@gfd-dennou.org> Thu, 30 Jul 2015 19:23:10 +0900
128
129 ruby-netcdf (0.6.6-2) unstable; urgency=medium
130
131 * Bump Standard Version: 3.9.5
132 * Use canonical Vcs-* field
133 * Drop obsolete DM-permission entry
134 * Drop Transitional Packages
135 * Update copyright foramt/1.0
136 * Update debian/compat: 9
137 * Drop old lintian-overrides
138
139 -- Youhei SASAKI <uwabami@gfd-dennou.org> Mon, 20 Jan 2014 00:38:07 +0900
140
141 ruby-netcdf (0.6.6-1) unstable; urgency=low
142
143 * New Upstream version 0.6.6
144 * Update watch
145 * Add unapply-patches to debian/sources/local-options
146 * Update patches: for gbp-pq
147 * Rebuild against new NetCDF packages
148 * New patch 0004-Fix-FTBFS-Hardening.patch (Closes: #676195)
149 - Thanks to Lucas Nussbaum!
150 * Add lintian-overrides for transitonal packages
151 * Add lintian-overrides: hardening-no-fortify-functions
152
153 -- Youhei SASAKI <uwabami@gfd-dennou.org> Tue, 12 Jun 2012 18:51:13 +0900
154
155 ruby-netcdf (0.6.5-2) unstable; urgency=low
156
157 * Bump standard-version: 3.9.2
158 * Update with files generated by dh-make-ruby:
159 - debian/rules
160 - debian/watch
161 * Updating the package as for the new Ruby practices
162 - Renaming binary package to ruby-netcdf, ruby-netcdf-dbg
163 - Migrate to gem2deb
164 - removed build dependency on cdbs and ruby-pkg-tools
165 - Added XS-Ruby-Versions field to debian/control
166 * debian/source/format: using '3.0 (quilt)'
167 * Added transitional packages in debian/control to allow smooth upgrades
168 from Squeeze.
169 - ruby-netcdf Provides, Replaces and Conflicts with past packages
170 - netcdf-ruby, netcdf-ruby1.8, netcdf-ruby1.9.1
171 netcdf-ruby1.8-dbg, netcdf-ruby1.9.1-dbg
172
173 -- Youhei SASAKI <uwabami@gfd-dennou.org> Thu, 28 Apr 2011 20:57:04 +0900
174
175 ruby-netcdf (0.6.5-1) unstable; urgency=low
176
177 * Initial Release (Closes: #542144)
178
179 -- Youhei SASAKI <uwabami@gfd-dennou.org> Mon, 13 Dec 2010 17:35:12 +0900
0 netcdf-ruby (0.6.3+cvs20100114-1) unstable; urgency=low
1
2 * New upstream
3 * Update Standard version
4 * create dbg package, ruby1.9.1 packages
5
6 -- Youhei SASAKI <uwabami@gfd-dennou.org> Sun, 24 Jan 2010 04:32:50 +0900
7
8 netcdf-ruby (0.6.3-8) unstable; urgency=low
9
10 * Update Standard Version
11 * modfied Build-Depends:
12 - using libnc-dap-dev, libdap-dev instead of libnc-dap, libdap
13
14 -- Youhei SASAKI <uwabami@gfd-dennou.org> Fri, 28 Aug 2009 10:29:46 +0900
15
16 netcdf-ruby (0.6.3-7) unstable; urgency=low
17
18 * Update Standard Version
19
20 -- Youhei SASAKI <uwabami@gfd-dennou.org> Tue, 18 Aug 2009 11:54:11 +0900
21
22 netcdf-ruby (0.6.3-6) unstable; urgency=low
23
24 * build dpendencies changed
25 * change package name: libnc-dap to libnc-dap-dev
26 * change package name: libdap to libdap-dev
27
28 -- Youhei SASAKI <uwabami@gfd-dennou.org> Sun, 14 Jun 2009 05:49:22 +0900
29
30 netcdf-ruby (0.6.3-5) unstable; urgency=low
31
32 * New upstream release
33 * repackaging for lenny, modified debian/rules
34
35 -- Youhei SASAKI <uwabami@gfd-dennou.org> Wed, 03 Dec 2008 14:18:27 +0900
36
37 netcdf-ruby (0.6.3-4) unstable; urgency=low
38
39 * libnc-dap is updated.
40
41 -- Tsuyoshi Koshiro <koshiro@database.rish.kyoto-u.ac.jp> Wed, 6 Aug 2008 13:52:58 +0900
42
43 netcdf-ruby (0.6.3-3) unstable; urgency=low
44
45 * Modified Build Depends
46
47 -- Youhei SASAKI <uwabami@gfd-dennou.org> Tue, 29 Jul 2008 16:50:09 +0900
48
49 netcdf-ruby (0.6.3-1) unstable; urgency=low
50
51 * New upstream release
52
53 -- Youhei SASAKI <uwabami@gfd-dennou.org> Tue, 25 Dec 2007 21:48:25 +0900
54
55 netcdf-ruby (0.6.2-5) unstable; urgency=low
56
57 * New upstream: redesigned for Etch
58 * using CDBS, ruby-pkg-tools
59
60 -- Youhei SASAKI <uwabami@gfd-dennou.org> Thu, 14 Jun 2007 20:56:39 +0900
61
62 ruby-netcdf (0.6.2-4) unstable; urgency=low
63
64 * libdap and libnc-dap are updated.
65
66 -- odakker <odakker@gfd-dennou.org> Thu, 8 Jun 2006 12:07:48 +0900
67
68 ruby-netcdf (0.6.2-3) unstable; urgency=low
69
70 * Install directorya changed.
71
72 -- odakker <odakker@gfd-dennou.org> Fri, 10 Mar 2006 14:22:34 +0900
73
74 ruby-netcdf (0.6.2-2) unstable; urgency=low
75
76 * Depend package version update.
77
78 -- odakker <odakker@gfd-dennou.org> Fri, 10 Mar 2006 14:15:46 +0900
79
80 ruby-netcdf (0.6.2-1) unstable; urgency=low
81
82 * New upstream release.
83
84 -- ODAKA Masatsugu <odakker@gfd-dennou.org> Sun, 24 Jul 2005 21:00:56 +0900
85
86 ruby-netcdf (0.6.0-2) unstable; urgency=low
87
88 * Minor bug fix.
89
90 -- ODAKA Masatsugu <odakker@gfd-dennou.org> Tue, 22 Mar 2005 15:41:45 +0900
91
92 ruby-netcdf (0.6.0-1) unstable; urgency=low
93
94 * New upstream release
95
96 -- ODAKA Masatsugu <odakker@gfd-dennou.org> Fri, 18 Mar 2005 16:42:24 +0900
97
98 ruby-netcdf (0.5.5-1) unstable; urgency=low
99
100 * New upstream release
101
102 -- ODAKA Masatsugu <odakker@gfd-dennou.org> Thu, 12 Aug 2004 18:14:23 +0900
103
104 ruby-netcdf (0.5.4-2) unstable; urgency=low
105
106 * Install directory is changed.
107
108 -- ODAKA Masatsugu <odakker@gfd-dennou.org> Mon, 15 Mar 2004 19:59:45 +0900
109
110 ruby-netcdf (0.5.4-1) unstable; urgency=low
111
112 * New upstream release
113
114 -- ODAKA Masatsugu <odakker@gfd-dennou.org> Fri, 12 Mar 2004 17:57:50 +0900
115
116 ruby-netcdf (0.5.3-1) unstable; urgency=low
117
118 * Initial Release.
119
120 -- uwabami@gfd-dennou.org <uwabami@gfd-dennou.org> Thu, 27 Nov 2003 04:12:34 +0900
121
122
0 Source: ruby-netcdf
1 Maintainer: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
2 Uploaders: Youhei SASAKI <uwabami@gfd-dennou.org>
3 Section: ruby
4 Priority: optional
5 Build-Depends: debhelper-compat (= 12),
6 gem2deb,
7 rake,
8 ruby-narray,
9 ruby-narray-miss,
10 libnetcdf-dev,
11 netcdf-bin
12 Standards-Version: 4.5.1
13 Vcs-Browser: https://salsa.debian.org/debian-gis-team/ruby-netcdf
14 Vcs-Git: https://salsa.debian.org/debian-gis-team/ruby-netcdf.git
15 Homepage: http://ruby.gfd-dennou.org/products/ruby-netcdf
16 XS-Ruby-Versions: all
17 Rules-Requires-Root: no
18
19 Package: ruby-netcdf
20 Architecture: any
21 Depends: ${shlibs:Depends},
22 ${misc:Depends},
23 ruby-narray,
24 ruby-narray-miss
25 Description: Ruby interface of netCDF library
26 RubyNetCDF is a Ruby interface of netCDF library built on the NArray
27 library, which is an efficient multi-dimensional numeric array class
28 for Ruby.
29 XB-Ruby-Versions: ${ruby:Versions}
0 Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
1 Upstream-Name: ruby-netcdf
2 Source: http://ruby.gfd-dennou.org/products/ruby-netcdf
3
4 Files: *
5 Copyright: 2011-2011 Takeshi Horinouchi and GFD Dennou Club
6 License: GPL-2+ or Ruby
7
8 Files: debian/*
9 Copyright: 2003-2013 Youhei SASAKI <uwabami@gfd-dennou.org>
10 License: GPL-2+ or Ruby
11
12 License: GPL-2+
13 This package is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17 .
18 This package is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22 .
23 You should have received a copy of the GNU General Public License
24 along with this program. If not, see <http://www.gnu.org/licenses/>
25 .
26 On Debian systems, the complete text of the GNU General
27 Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
28
29 License: Ruby
30 1. You may make and give away verbatim copies of the source form of the
31 software without restriction, provided that you duplicate all of the
32 original copyright notices and associated disclaimers.
33 .
34 2. You may modify your copy of the software in any way, provided that
35 you do at least ONE of the following:
36 .
37 a) place your modifications in the Public Domain or otherwise
38 make them Freely Available, such as by posting said
39 modifications to Usenet or an equivalent medium, or by allowing
40 the author to include your modifications in the software.
41 .
42 b) use the modified software only within your corporation or
43 organization.
44 .
45 c) rename any non-standard executables so the names do not conflict
46 with standard executables, which must also be provided.
47 .
48 d) make other distribution arrangements with the author.
49 .
50 3. You may distribute the software in object code or executable
51 form, provided that you do at least ONE of the following:
52 .
53 a) distribute the executables and library files of the software,
54 together with instructions (in the manual page or equivalent)
55 on where to get the original distribution.
56 .
57 b) accompany the distribution with the machine-readable source of
58 the software.
59 .
60 c) give non-standard executables non-standard names, with
61 instructions on where to get the original software distribution.
62 .
63 d) make other distribution arrangements with the author.
64 .
65 4. You may modify and include the part of the software into any other
66 software (possibly commercial). But some files in the distribution
67 are not written by the author, so that they are not under this terms.
68 .
69 They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
70 files under the ./missing directory. See each file for the copying
71 condition.
72 .
73 5. The scripts and library files supplied as input to or produced as
74 output from the software do not automatically fall under the
75 copyright of the software, but belong to whomever generated them,
76 and may be sold commercially, and may be aggregated with this
77 software.
78 .
79 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
80 IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
81 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
82 PURPOSE.
0 [DEFAULT]
1
2 # The default name for the upstream branch is "upstream".
3 # Change it if the name is different (for instance, "master").
4 upstream-branch = upstream
5
6 # The default name for the Debian branch is "master".
7 # Change it if the name is different (for instance, "debian/unstable").
8 debian-branch = master
9
10 # git-import-orig uses the following names for the upstream tags.
11 # Change the value if you are not using git-import-orig
12 upstream-tag = upstream/%(version)s
13
14 # Always use pristine-tar.
15 pristine-tar = True
16
17 [buildpackage]
18 pbuilder-options = --source-only-changes
0 From: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
1 Date: Fri, 31 Jul 2015 12:03:43 +0900
2 Subject: Support NetCDF RC version
3
4 Add rc release support in version check of extconf.rb
5
6 Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
7 ---
8 ext/numru/extconf.rb | 2 +-
9 1 file changed, 1 insertion(+), 1 deletion(-)
10
11 diff --git a/ext/numru/extconf.rb b/ext/numru/extconf.rb
12 index b3ee26d..2e25a18 100644
13 --- a/ext/numru/extconf.rb
14 +++ b/ext/numru/extconf.rb
15 @@ -51,7 +51,7 @@ end
16
17 ncver0 = ncversion[0..0] # "3" or "4"
18 ncver = ncversion.gsub(/\./,'')
19 -unless /^\d\d\d$/ =~ ncver # 3 digits
20 +unless /^\d\d\d(\-rc)?$/ =~ ncver # 3 digits
21 raise("Invalid netcdf version: #{ncversion}. Use --with-netcdf-version=")
22 end
23 $CFLAGS += ' -DNCVER='+ncver
0 From: Debian GIS Project <pkg-grass-devel@lists.alioth.debian.org>
1 Date: Mon, 7 Dec 2015 02:18:36 +0900
2 Subject: Add patch: Replace git execution from gemspec
3
4 Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
5 ---
6 ruby-netcdf.gemspec | 2 +-
7 1 file changed, 1 insertion(+), 1 deletion(-)
8
9 diff --git a/ruby-netcdf.gemspec b/ruby-netcdf.gemspec
10 index cfdd516..c2f94d6 100644
11 --- a/ruby-netcdf.gemspec
12 +++ b/ruby-netcdf.gemspec
13 @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
14 spec.homepage = 'http://www.gfd-dennou.org/arch/ruby/products/ruby-netcdf/'
15 spec.licenses = ["BSD-2-Clause"]
16
17 - spec.files = `git ls-files -z`.split("\x0")
18 + spec.files = [".gitignore",".rspec",".travis.yml","ChangeLog","Gemfile","INSTALL","LICENSE.txt","Rakefile","ToDo","bin/console","bin/setup","demo/README","demo/demo1-create-alt.rb","demo/demo1-create.rb","demo/demo2-graphic.rb","demo/demo3-ncepclim.rb","demo/demo4-copy.rb","demo/demo5-netcdf4.rb","doc/README_JP.txt","doc/Ref_man.html","doc/Ref_man.rd","doc/Ref_man_jp.html","doc/Ref_man_jp.rd","doc/to_html","extconf.rb","lib/netcdf.rb","lib/netcdf_miss.rb","lib/version.rb","metadata.yml","netcdfraw.c","ruby-netcdf.gemspec","test/aref_aset.rb","test/char_var.rb","test/clone.rb","test/create_tmp.rb","test/def_var_with_dim.rb","test/factor_offset.rb","test/putatt.cdl","test/putatt.rb","test/test.cdl","test/test.rb","test/type.rb"]
19 spec.test_files = spec.files.grep(%r{^(test|demo)/})
20 spec.require_paths = ["ext","lib"]
21 spec.extensions << "ext/numru/extconf.rb"
0 From: Youhei SASAKI <uwabami@gfd-dennou.org>
1 Date: Tue, 1 Mar 2016 17:59:27 +0900
2 Subject: Fix spelling error in binary
3
4 Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
5 ---
6 ext/numru/netcdfraw.c | 4 ++--
7 1 file changed, 2 insertions(+), 2 deletions(-)
8
9 diff --git a/ext/numru/netcdfraw.c b/ext/numru/netcdfraw.c
10 index 73a9778..783d087 100644
11 --- a/ext/numru/netcdfraw.c
12 +++ b/ext/numru/netcdfraw.c
13 @@ -635,7 +635,7 @@ NetCDF_put_att_char(int ncid, char *name,VALUE value,VALUE atttype, int varid)
14 }
15 } else if (TYPE(atttype) != T_NIL) {
16 rb_raise(rb_eNetcdfError,
17 - "type specfication must be by a string or nil");
18 + "type specification must be by a string or nil");
19 }
20 /* put value */
21 Check_Type(value,T_STRING);
22 @@ -807,7 +807,7 @@ NetCDF_def_var(VALUE file,VALUE var_name,VALUE vartype,VALUE dimensions)
23 xtype = natypecode2nctype(NUM2INT(vartype));
24 } else {
25 rb_raise(rb_eNetcdfError,
26 - "type specfication must be by a string or nil");
27 + "type specification must be by a string or nil");
28 }
29
30 for(i=0;i<c_ndims;i++){
0 From: Youhei SASAKI <uwabami@gfd-dennou.org>
1 Date: Fri, 22 May 2020 23:19:51 +0900
2 Subject: import upstream: Drop obsolete rb_secure, rb_safe_level
3
4 Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
5 ---
6 ext/numru/netcdfraw.c | 576 +++++++++++-----------
7 lib/numru/netcdf.rb | 1272 ++++++++++++++++++++++++-------------------------
8 2 files changed, 905 insertions(+), 943 deletions(-)
9
10 diff --git a/ext/numru/netcdfraw.c b/ext/numru/netcdfraw.c
11 index b3fdf77..6cc4de9 100644
12 --- a/ext/numru/netcdfraw.c
13 +++ b/ext/numru/netcdfraw.c
14 @@ -198,7 +198,7 @@ typedef int na_shape_t;
15 obj = na_cast_object(obj, NA_SINT); \
16 GetNArray(obj, na); \
17 ptr = (int16_t *) NA_PTR(na,0); \
18 -}
19 +}
20 #define Array_to_Clint(obj, ptr) \
21 { \
22 struct NARRAY *na; \
23 @@ -257,7 +257,7 @@ static VALUE rb_eNetcdfFatal;
24 static VALUE rb_eNetcdfEntool;
25 static VALUE rb_eNetcdfExdr;
26 static VALUE rb_eNetcdfSyserr;
27 -
28 +
29
30 struct Netcdf{
31 int ncid;
32 @@ -290,7 +290,7 @@ NetCDF_init(int ncid,char *filename)
33 Netcdffile->ncid=ncid;
34 Netcdffile->closed=0;
35 Netcdffile->name=xmalloc((strlen(filename)+1)*sizeof(char));
36 - strcpy(Netcdffile->name,filename);
37 + strcpy(Netcdffile->name,filename);
38 return(Netcdffile);
39 }
40
41 @@ -322,7 +322,7 @@ NetCDF_att_init(int ncid,int varid,char *attname)
42 Netcdf_att->ncid=ncid;
43 Netcdf_att->varid=varid;
44 Netcdf_att->name=xmalloc((strlen(attname)+1)*sizeof(char));
45 - strcpy(Netcdf_att->name,attname);
46 + strcpy(Netcdf_att->name,attname);
47 return(Netcdf_att);
48 }
49
50 @@ -351,7 +351,7 @@ NetCDF_free(struct Netcdf *Netcdffile)
51 if (!Netcdffile->closed){
52 nc_close(Netcdffile->ncid); /* no error check -- not to stop during GC */
53 }
54 - free(Netcdffile->name);
55 + free(Netcdffile->name);
56 free(Netcdffile);
57 }
58
59 @@ -576,14 +576,11 @@ NetCDF_close(file)
60 int ncid;
61 struct Netcdf *Netcdffile;
62
63 - if (rb_safe_level() >= 3 && !OBJ_TAINTED(file)) {
64 - rb_raise(rb_eSecurityError, "Insecure: can't close");
65 - }
66 Data_Get_Struct(file,struct Netcdf,Netcdffile);
67 ncid=Netcdffile->ncid;
68 if(!Netcdffile->closed){
69 status = nc_close(ncid);
70 - if(status != NC_NOERR) NC_RAISE(status);
71 + if(status != NC_NOERR) NC_RAISE(status);
72 Netcdffile->closed = 1;
73 } else {
74 rb_warn("file %s is already closed", Netcdffile->name);
75 @@ -602,10 +599,9 @@ NetCDF_def_dim(VALUE file,VALUE dim_name,VALUE length)
76 struct Netcdf *Netcdffile;
77 struct NetCDFDim *Netcdf_dim;
78 VALUE Dimension;
79 -
80 - rb_secure(3);
81 +
82 Data_Get_Struct(file,struct Netcdf,Netcdffile);
83 -
84 +
85 Check_Type(dim_name,T_STRING);
86 c_dim_name=RSTRING_PTR(dim_name);
87 c_length=NUM2UINT(length);
88 @@ -696,19 +692,19 @@ NetCDF_put_att_numeric(int ncid, char *name,VALUE value,VALUE atttype, int varid
89 len = na_val->total;
90 ptr = na_val->ptr;
91 switch(na_typecode){
92 - case NA_BYTE:
93 + case NA_BYTE:
94 status = nc_put_att_uchar(ncid,varid,name,NC_BYTE,len,(unsigned char *)ptr);
95 break;
96 - case NA_SINT:
97 + case NA_SINT:
98 status = nc_put_att_short(ncid,varid,name,NC_SHORT,len,(short *)ptr);
99 break;
100 - case NA_LINT:
101 + case NA_LINT:
102 status = nc_put_att_int(ncid,varid,name,NC_INT,len,(int *)ptr);
103 break;
104 - case NA_SFLOAT:
105 + case NA_SFLOAT:
106 status = nc_put_att_float(ncid,varid,name,NC_FLOAT,len,(float *)ptr);
107 break;
108 - case NA_DFLOAT:
109 + case NA_DFLOAT:
110 status = nc_put_att_double(ncid,varid,name,NC_DOUBLE,len,(double*)ptr);
111 break;
112 default:
113 @@ -746,7 +742,6 @@ NetCDF_put_att(VALUE file,VALUE att_name,VALUE value,VALUE atttype)
114 struct Netcdf *ncfile;
115 char *name;
116
117 - rb_secure(3);
118 Data_Get_Struct(file,struct Netcdf,ncfile);
119 Check_Type(att_name,T_STRING);
120 name = RSTRING_PTR(att_name);
121 @@ -764,7 +759,6 @@ NetCDF_put_att_var(VALUE var,VALUE att_name,VALUE value,VALUE atttype)
122 struct NetCDFVar *ncvar;
123 char *name;
124
125 - rb_secure(3);
126 Data_Get_Struct(var,struct NetCDFVar,ncvar);
127 Check_Type(att_name,T_STRING);
128 name = RSTRING_PTR(att_name);
129 @@ -791,20 +785,19 @@ NetCDF_def_var(VALUE file,VALUE var_name,VALUE vartype,VALUE dimensions)
130 struct NetCDFDim *Netcdf_dim;
131 VALUE Var;
132
133 - rb_secure(3);
134 Check_Type(var_name,T_STRING);
135 Check_Type(dimensions,T_ARRAY);
136
137 c_var_name=RSTRING_PTR(var_name);
138 c_ndims=RARRAY_LEN(dimensions);
139 -
140 +
141 Data_Get_Struct(file,struct Netcdf,Netcdffile);
142 ncid=Netcdffile->ncid;
143
144 if (TYPE(vartype) == T_STRING){
145 - xtype = natype2nctype(RSTRING_PTR(vartype));
146 + xtype = natype2nctype(RSTRING_PTR(vartype));
147 } else if (TYPE(vartype) == T_FIXNUM){
148 - xtype = natypecode2nctype(NUM2INT(vartype));
149 + xtype = natypecode2nctype(NUM2INT(vartype));
150 } else {
151 rb_raise(rb_eNetcdfError,
152 "type specification must be by a string or nil");
153 @@ -827,12 +820,12 @@ NetCDF_def_var(VALUE file,VALUE var_name,VALUE vartype,VALUE dimensions)
154 rb_raise(rb_eNetcdfError, "No such object of the netCDF dimension class.");
155 }
156 }
157 -
158 +
159 status = nc_def_var(ncid,c_var_name,xtype,c_ndims,c_dimids,&varidp);
160 if(status != NC_NOERR) NC_RAISE(status);
161 -
162 +
163 Netcdf_var = NetCDF_var_init(ncid,varidp,file);
164 -
165 +
166 Var=Data_Wrap_Struct(cNetCDFVar,nc_mark_obj,NetCDF_var_free,Netcdf_var);
167 return Var;
168 }
169 @@ -852,10 +845,10 @@ NetCDF_dim(VALUE file,VALUE dim_name)
170 ncid=Netcdffile->ncid;
171 Check_Type(dim_name,T_STRING);
172 c_dim_name=RSTRING_PTR(dim_name);
173 -
174 +
175 status = nc_inq_dimid(ncid,c_dim_name,&dimidp);
176 if(status !=NC_NOERR){
177 - if(status == NC_EBADDIM){
178 + if(status == NC_EBADDIM){
179 return(Qnil); /*2003/08/27 back to orig (from changes on 2003/02/03)*/
180 } else{
181 NC_RAISE(status);
182 @@ -863,14 +856,14 @@ NetCDF_dim(VALUE file,VALUE dim_name)
183 }
184
185 Netcdf_dim=NetCDF_dim_init(ncid,dimidp);
186 -
187 +
188 Dimension = Data_Wrap_Struct(cNetCDFDim,0,NetCDF_dim_free,Netcdf_dim);
189 return Dimension;
190 }
191
192 -VALUE
193 +VALUE
194 NetCDF_var(VALUE file,VALUE var_name)
195 -{
196 +{
197 int ncid;
198 int status;
199 int varidp;
200 @@ -883,16 +876,16 @@ NetCDF_var(VALUE file,VALUE var_name)
201 ncid=Netcdffile->ncid;
202 Check_Type(var_name,T_STRING);
203 c_var_name=RSTRING_PTR(var_name);
204 -
205 +
206 status=nc_inq_varid(ncid,c_var_name,&varidp);
207 if(status != NC_NOERR){
208 if(status == NC_ENOTVAR){
209 return(Qnil); /*2003/08/27 back to orig (from changes on 2003/02/03)*/
210 - } else{
211 + } else{
212 NC_RAISE(status);
213 }
214 }
215 -
216 +
217 Netcdf_var = NetCDF_var_init(ncid,varidp,file);
218 Variable = Data_Wrap_Struct(cNetCDFVar,nc_mark_obj,NetCDF_var_free,Netcdf_var);
219 return Variable;
220 @@ -913,7 +906,7 @@ NetCDF_att(VALUE file,VALUE att_name)
221 ncid=Netcdffile->ncid;
222 Check_Type(att_name,T_STRING);
223 c_att_name=RSTRING_PTR(att_name);
224 -
225 +
226
227 status = nc_inq_attid(ncid,NC_GLOBAL,c_att_name,&attnump);
228 if(status != NC_NOERR){
229 @@ -924,11 +917,11 @@ NetCDF_att(VALUE file,VALUE att_name)
230 NC_RAISE(status);
231 }
232 }
233 -
234 +
235 Netcdf_att = NetCDF_att_init(ncid,NC_GLOBAL,c_att_name);
236 -
237 +
238 Attribute = Data_Wrap_Struct(cNetCDFAtt,0,Netcdf_att_free,Netcdf_att);
239 -
240 +
241 return Attribute;
242 }
243 VALUE
244 @@ -938,7 +931,7 @@ NetCDF_fill(VALUE file,VALUE mode)
245 int status;
246 struct Netcdf *Netcdffile;
247 int old_modep;
248 -
249 +
250 Data_Get_Struct(file,struct Netcdf,Netcdffile);
251 ncid = Netcdffile->ncid;
252 if(mode==Qfalse){
253 @@ -961,7 +954,6 @@ NetCDF_redef(VALUE file)
254 int status;
255 struct Netcdf *Netcdffile;
256
257 - rb_secure(3);
258 Data_Get_Struct(file,struct Netcdf,Netcdffile);
259 ncid=Netcdffile->ncid;
260 status = nc_redef(ncid);
261 @@ -976,18 +968,17 @@ NetCDF_redef(VALUE file)
262 return Qtrue;
263 }
264
265 -VALUE
266 +VALUE
267 NetCDF_enddef(VALUE file)
268 {
269 int ncid;
270 int status;
271 struct Netcdf *Netcdffile;
272
273 - rb_secure(3);
274 Data_Get_Struct(file,struct Netcdf,Netcdffile);
275 ncid=Netcdffile->ncid;
276 status = nc_enddef(ncid);
277 - if(status !=NC_NOERR){
278 + if(status !=NC_NOERR){
279 if(status == NC_ENOTINDEFINE){
280 return Qnil;
281 }
282 @@ -998,7 +989,7 @@ NetCDF_enddef(VALUE file)
283 return Qtrue;
284 }
285
286 -VALUE
287 +VALUE
288 NetCDF_whether_in_define_mode(VALUE file)
289 {
290 /* returns true if the NetCDF object is currently in the define mode,
291 @@ -1010,7 +1001,6 @@ NetCDF_whether_in_define_mode(VALUE file)
292 int status;
293 struct Netcdf *Netcdffile;
294
295 - rb_secure(3);
296 Data_Get_Struct(file,struct Netcdf,Netcdffile);
297 ncid=Netcdffile->ncid;
298 status = nc_redef(ncid);
299 @@ -1030,7 +1020,7 @@ NetCDF_whether_in_define_mode(VALUE file)
300 }
301
302 VALUE
303 -NetCDF_open(VALUE mod,VALUE filename,VALUE omode)
304 +NetCDF_open(VALUE mod,VALUE filename,VALUE omode)
305 {
306 int status;
307 int ncid;
308 @@ -1044,7 +1034,7 @@ NetCDF_open(VALUE mod,VALUE filename,VALUE omode)
309 c_filename=RSTRING_PTR(filename);
310 Check_Type(omode,T_FIXNUM);
311 c_omode=NUM2INT(omode);
312 -
313 +
314 status = nc_open(c_filename,c_omode,&ncid);
315 if(status !=NC_NOERR){NC_RAISE2(status,c_filename);}
316
317 @@ -1061,13 +1051,13 @@ NetCDF_create(VALUE mod,VALUE filename,VALUE cmode)
318 char* c_filename;
319 int c_cmode;
320 struct Netcdf *ncfile;
321 -
322 +
323 Check_Type(filename,T_STRING);
324 SafeStringValue(filename);
325 c_filename=RSTRING_PTR(filename);
326 Check_Type(cmode,T_FIXNUM);
327 c_cmode=NUM2INT(cmode);
328 -
329 +
330 status = nc_create(c_filename,c_cmode,&ncid);
331 if(status != NC_NOERR) NC_RAISE2(status, c_filename);
332
333 @@ -1075,7 +1065,7 @@ NetCDF_create(VALUE mod,VALUE filename,VALUE cmode)
334 return( Data_Wrap_Struct(cNetCDF,0,NetCDF_free,ncfile) );
335 }
336
337 -VALUE
338 +VALUE
339 NetCDF_ndims(VALUE file)
340 {
341 int ncid;
342 @@ -1092,7 +1082,7 @@ NetCDF_ndims(VALUE file)
343 return Integer;
344 }
345
346 -VALUE
347 +VALUE
348 NetCDF_nvars(VALUE file)
349 {
350 int ncid;
351 @@ -1108,7 +1098,7 @@ NetCDF_nvars(VALUE file)
352 return Integer;
353 }
354
355 -VALUE
356 +VALUE
357 NetCDF_natts(VALUE file)
358 {
359 int ncid;
360 @@ -1139,10 +1129,10 @@ NetCDF_unlimited(VALUE file)
361 ncid=ncfile->ncid;
362 status=nc_inq_unlimdim(ncid,&unlimdimidp);
363 if(status !=NC_NOERR) NC_RAISE(status);
364 -
365 +
366 Netcdf_dim = NetCDF_dim_init(ncid,unlimdimidp);
367 -
368 - /* If unlimdimidp=-1,No unlimited dimension is defined in the netCDF dataset */
369 +
370 + /* If unlimdimidp=-1,No unlimited dimension is defined in the netCDF dataset */
371 if(unlimdimidp != -1)
372 {
373 Dimension = Data_Wrap_Struct(cNetCDFDim,0,NetCDF_dim_free,Netcdf_dim);
374 @@ -1156,7 +1146,7 @@ NetCDF_unlimited(VALUE file)
375
376 #if NCVER >= 400
377
378 -VALUE
379 +VALUE
380 NetCDF_format(VALUE file)
381 {
382 int ncid;
383 @@ -1177,7 +1167,7 @@ NetCDF_format(VALUE file)
384 }
385
386 #endif
387 -
388 +
389 VALUE
390 NetCDF_sync(VALUE file)
391 {
392 @@ -1185,7 +1175,6 @@ NetCDF_sync(VALUE file)
393 int status;
394 struct Netcdf *ncfile;
395
396 - rb_secure(3);
397 Data_Get_Struct(file,struct Netcdf,ncfile);
398 ncid=ncfile->ncid;
399 status = nc_sync(ncid);
400 @@ -1198,7 +1187,7 @@ NetCDF_path(VALUE file)
401 {
402 char *path;
403 struct Netcdf *ncfile;
404 -
405 +
406 Data_Get_Struct(file,struct Netcdf,ncfile);
407 path=ncfile->name;
408 return(rb_str_new2(path));
409 @@ -1212,14 +1201,14 @@ NetCDF_dim_length(VALUE Dim)
410 int dimid;
411 size_t lengthp;
412 struct NetCDFDim *Netcdf_dim;
413 -
414 +
415 Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
416 ncid=Netcdf_dim->ncid;
417 dimid=Netcdf_dim->dimid;
418
419 status = nc_inq_dimlen(ncid,dimid,&lengthp);
420 if(status != NC_NOERR) NC_RAISE(status);
421 -
422 +
423 return(INT2NUM(lengthp));
424 }
425
426 @@ -1231,8 +1220,7 @@ NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
427 int dimid;
428 char *c_dim_name;
429 struct NetCDFDim *Netcdf_dim;
430 -
431 - rb_secure(3);
432 +
433 Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
434 ncid=Netcdf_dim->ncid;
435 dimid=Netcdf_dim->dimid;
436 @@ -1241,7 +1229,7 @@ NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
437
438 status = nc_rename_dim(ncid,dimid,c_dim_name);
439 if(status !=NC_NOERR) NC_RAISE(status);
440 -
441 +
442 return Qnil;
443 }
444
445 @@ -1254,14 +1242,14 @@ NetCDF_dim_inqname(VALUE Dim)
446 char c_dim_name[NC_MAX_NAME];
447 struct NetCDFDim *Netcdf_dim;
448 VALUE str;
449 -
450 +
451 Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
452 ncid=Netcdf_dim->ncid;
453 dimid=Netcdf_dim->dimid;
454 -
455 +
456 status = nc_inq_dimname(ncid,dimid,c_dim_name);
457 if(status !=NC_NOERR) NC_RAISE(status);
458 -
459 +
460 str = rb_str_new2(c_dim_name);
461 OBJ_TAINT(str);
462 return(str);
463 @@ -1273,7 +1261,7 @@ NetCDF_dim_whether_unlimited(VALUE Dim)
464 int status;
465 int uldid;
466 struct NetCDFDim *Netcdf_dim;
467 -
468 +
469 Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
470 status=nc_inq_unlimdim(Netcdf_dim->ncid,&uldid);
471 if(status !=NC_NOERR) NC_RAISE(status);
472 @@ -1293,7 +1281,7 @@ NetCDF_att_inq_name(VALUE Att)
473
474 Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
475 c_att_name=Netcdf_att->name;
476 -
477 +
478 str = rb_str_new2(c_att_name);
479 OBJ_TAINT(str);
480 return(str);
481 @@ -1311,16 +1299,16 @@ NetCDF_att_rename(VALUE Att,VALUE new_att_name)
482 Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
483 ncid=Netcdf_att->ncid;
484 varid=Netcdf_att->varid;
485 -
486 +
487 c_att_name=Netcdf_att->name;
488 -
489 +
490 Check_Type(new_att_name,T_STRING);
491 SafeStringValue(new_att_name);
492 c_new_att_name=StringValueCStr(new_att_name);
493 -
494 +
495 status = nc_rename_att(ncid,varid,c_att_name,c_new_att_name);
496 if(status != NC_NOERR) NC_RAISE(status);
497 -
498 +
499 strcpy(Netcdf_att->name,c_new_att_name);
500 return Qnil;
501 }
502 @@ -1351,7 +1339,7 @@ NetCDF_id2var(VALUE file,VALUE varid)
503 struct Netcdf *ncfile;
504 struct NetCDFVar *Netcdf_var;
505 VALUE Var;
506 -
507 +
508 Data_Get_Struct(file,struct Netcdf,ncfile);
509 ncid=ncfile->ncid;
510 Check_Type(varid,T_FIXNUM);
511 @@ -1373,7 +1361,7 @@ NetCDF_id2att(VALUE file,VALUE attnum)
512 char *c_att_name;
513 VALUE Att;
514 c_att_name=ALLOCA_N(char,NC_MAX_NAME);
515 -
516 +
517 Data_Get_Struct(file,struct Netcdf,ncfile);
518 ncid=ncfile->ncid;
519
520 @@ -1401,7 +1389,7 @@ NetCDF_var_deflate(int argc, VALUE *argv, VALUE Var)
521 struct NetCDFVar *Netcdf_var;
522
523 int shuffle;
524 - /* If non-zero, turn on the shuffle filter.
525 + /* If non-zero, turn on the shuffle filter.
526
527 http://www.unidata.ucar.edu/software/netcdf/papers/AMS_2008.pdf :
528 The shuffle algorithm changes the byte order in the data stream;
529 @@ -1421,7 +1409,7 @@ NetCDF_var_deflate(int argc, VALUE *argv, VALUE Var)
530 level specified by the deflate_level parameter.
531 */
532
533 - if (argc>2 || argc<1) rb_raise(rb_eArgError,
534 + if (argc>2 || argc<1) rb_raise(rb_eArgError,
535 "wrong # of arguments (%d). It must be 1 or 2", argc);
536
537 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
538 @@ -1457,7 +1445,7 @@ NetCDF_var_deflate_params(VALUE Var)
539 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
540 ncid = Netcdf_var->ncid;
541 varid = Netcdf_var->varid;
542 - status = nc_inq_var_deflate(ncid, varid, &shufflep, &deflatep,
543 + status = nc_inq_var_deflate(ncid, varid, &shufflep, &deflatep,
544 &deflate_levelp);
545 if(status != NC_NOERR) NC_RAISE(status);
546 if (shufflep==0) {sh=Qfalse;} else {sh=Qtrue;}
547 @@ -1508,7 +1496,7 @@ NetCDF_var_id2att(VALUE Var,VALUE attnum)
548 struct NetCDFAtt *Netcdf_att;
549 char *c_att_name;
550 VALUE Att;
551 -
552 +
553 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
554 ncid=Netcdf_var->ncid;
555 c_varid=Netcdf_var->varid;
556 @@ -1520,7 +1508,7 @@ NetCDF_var_id2att(VALUE Var,VALUE attnum)
557
558 status = nc_inq_attname(ncid,c_varid,c_attnum,c_att_name);
559 if(status != NC_NOERR) NC_RAISE(status);
560 -
561 +
562 Netcdf_att=NetCDF_att_init(ncid,c_varid,c_att_name);
563 Att=Data_Wrap_Struct(cNetCDFAtt,0,Netcdf_att_free,Netcdf_att);
564 return(Att);
565 @@ -1545,7 +1533,7 @@ NetCDF_var_dims(VALUE Var)
566 Dims = rb_ary_new();
567 for(i=0;i<ndims;i++){
568 Netcdf_dim = NetCDF_dim_init(ncid,dimids[ndims-1-i]);
569 - rb_ary_push(Dims,
570 + rb_ary_push(Dims,
571 Data_Wrap_Struct(cNetCDFDim,0,NetCDF_dim_free,Netcdf_dim));
572 }
573 return(Dims);
574 @@ -1589,7 +1577,6 @@ NetCDF_att_copy(VALUE Att,VALUE Var_or_File)
575 struct Netcdf *ncfile;
576 struct NetCDFAtt *Netcdf_att_out;
577
578 - rb_secure(3);
579 Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
580 ncid_in=Netcdf_att->ncid;
581 varid_in=Netcdf_att->varid;
582 @@ -1635,7 +1622,7 @@ NetCDF_att_atttype(VALUE Att)
583 Attname = nctype2natype(xtypep);
584 return(rb_str_new2(Attname));
585 }
586 -
587 +
588 VALUE
589 NetCDF_att_typecode(VALUE Att)
590 {
591 @@ -1653,10 +1640,10 @@ NetCDF_att_typecode(VALUE Att)
592
593 status = nc_inq_atttype(ncid,varid,att_name,&xtypep);
594 if(status != NC_NOERR) NC_RAISE(status);
595 -
596 +
597 return(INT2NUM(nctype2natypecode(xtypep)));
598 }
599 -
600 +
601 VALUE
602 NetCDF_att_delete(VALUE Att)
603 {
604 @@ -1666,7 +1653,6 @@ NetCDF_att_delete(VALUE Att)
605 char *c_att_name;
606 struct NetCDFAtt *Netcdf_att;
607
608 - rb_secure(3);
609 Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
610
611 ncid=Netcdf_att->ncid;
612 @@ -1675,7 +1661,7 @@ NetCDF_att_delete(VALUE Att)
613
614 status = nc_del_att(ncid,varid,c_att_name);
615 if(status != NC_NOERR) NC_RAISE(status);
616 -
617 +
618 return Qnil;
619 }
620
621 @@ -1687,13 +1673,12 @@ NetCDF_att_put(VALUE Att,VALUE value,VALUE atttype)
622 */
623 {
624 struct NetCDFAtt *ncatt;
625 -
626 - rb_secure(3);
627 +
628 Data_Get_Struct(Att,struct NetCDFAtt,ncatt);
629 - return( NetCDF_put_att__(ncatt->ncid, ncatt->name, value,
630 + return( NetCDF_put_att__(ncatt->ncid, ncatt->name, value,
631 atttype, ncatt->varid) );
632 }
633 -
634 +
635 VALUE
636 NetCDF_att_get(VALUE Att)
637 {
638 @@ -1740,7 +1725,7 @@ NetCDF_att_get(VALUE Att)
639
640 attlen[0]=lenp;
641 Cbyte_to_NArray(NArray,1,attlen,up);
642 -
643 +
644 status = nc_get_att_uchar(ncid,varid,c_attname,up);
645 if(status != NC_NOERR) NC_RAISE(status);
646
647 @@ -1753,7 +1738,7 @@ NetCDF_att_get(VALUE Att)
648
649 attlen[0]=lenp;
650 Csint_to_NArray(NArray,1,attlen,sp);
651 -
652 +
653 status = nc_get_att_short(ncid,varid,c_attname,sp);
654 if(status != NC_NOERR) NC_RAISE(status);
655 OBJ_TAINT(NArray);
656 @@ -1762,10 +1747,10 @@ NetCDF_att_get(VALUE Att)
657 case NC_INT:
658 status = nc_inq_attlen(ncid,varid,c_attname,&lenp);
659 if(status != NC_NOERR) NC_RAISE(status);
660 -
661 +
662 attlen[0]=lenp;
663 Clint_to_NArray(NArray,1,attlen,ip);
664 -
665 +
666 status = nc_get_att_int(ncid,varid,c_attname,ip);
667 if(status != NC_NOERR) NC_RAISE(status);
668
669 @@ -1778,7 +1763,7 @@ NetCDF_att_get(VALUE Att)
670
671 attlen[0]=lenp;
672 Cfloat_to_NArray(NArray,1,attlen,fp);
673 -
674 +
675 status = nc_get_att_float(ncid,varid,c_attname,fp);
676 if(status != NC_NOERR) NC_RAISE(status);
677
678 @@ -1791,7 +1776,7 @@ NetCDF_att_get(VALUE Att)
679
680 attlen[0]=lenp;
681 Cdouble_to_NArray(NArray,1,attlen,dp);
682 -
683 +
684 status = nc_get_att_double(ncid,varid,c_attname,dp);
685 if(status != NC_NOERR) NC_RAISE(status);
686 OBJ_TAINT(NArray);
687 @@ -1803,7 +1788,7 @@ NetCDF_att_get(VALUE Att)
688 return Qnil;
689 }
690
691 -
692 +
693 VALUE
694 NetCDF_var_inq_name(VALUE Var)
695 {
696 @@ -1820,7 +1805,7 @@ NetCDF_var_inq_name(VALUE Var)
697 varid=Netcdf_var->varid;
698 status = nc_inq_varname(ncid,varid,c_var_name);
699 if(status != NC_NOERR) NC_RAISE(status);
700 -
701 +
702 Var_name=rb_str_new2(c_var_name);
703 OBJ_TAINT(Var_name);
704 return Var_name;
705 @@ -1837,7 +1822,7 @@ NetCDF_var_ndims(VALUE Var)
706 VALUE Var_ndims;
707
708 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
709 -
710 +
711 ncid=Netcdf_var->ncid;
712 varid=Netcdf_var->varid;
713 status = nc_inq_varndims(ncid,varid,&ndimsp);
714 @@ -1855,15 +1840,15 @@ NetCDF_var_vartype(VALUE Var)
715 nc_type xtypep;
716 struct NetCDFVar *Netcdf_var;
717 const char *Vartype;
718 -
719 +
720 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
721 -
722 +
723 ncid=Netcdf_var->ncid;
724 varid=Netcdf_var->varid;
725
726 status = nc_inq_vartype(ncid,varid,&xtypep);
727 if(status != NC_NOERR) NC_RAISE(status);
728 -
729 +
730 Vartype=nctype2natype(xtypep);
731 return(rb_str_new2(Vartype));
732 }
733 @@ -1876,19 +1861,19 @@ NetCDF_var_typecode(VALUE Var)
734 int varid;
735 nc_type xtypep;
736 struct NetCDFVar *Netcdf_var;
737 -
738 +
739 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
740 -
741 +
742 ncid=Netcdf_var->ncid;
743 varid=Netcdf_var->varid;
744
745 status = nc_inq_vartype(ncid,varid,&xtypep);
746 if(status != NC_NOERR) NC_RAISE(status);
747 -
748 +
749 return(INT2NUM(nctype2natypecode(xtypep)));
750 }
751
752 -
753 +
754 VALUE
755 NetCDF_var_natts(VALUE Var)
756 {
757 @@ -1898,16 +1883,16 @@ NetCDF_var_natts(VALUE Var)
758 int nattsp;
759 struct NetCDFVar *Netcdf_var;
760 VALUE Var_natts;
761 -
762 +
763
764 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
765 -
766 +
767 ncid=Netcdf_var->ncid;
768 varid=Netcdf_var->varid;
769 -
770 +
771 status= nc_inq_varnatts(ncid,varid,&nattsp);
772 if(status !=NC_NOERR) NC_RAISE(status);
773 -
774 +
775 Var_natts=INT2FIX(nattsp);
776 return Var_natts;
777 }
778 @@ -1918,7 +1903,7 @@ NetCDF_var_file(VALUE Var)
779 struct NetCDFVar *Netcdf_var;
780 /* VALUE file; */
781 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
782 -
783 +
784 return (Netcdf_var->file);
785 }
786
787 @@ -1930,15 +1915,14 @@ NetCDF_var_rename(VALUE Var,VALUE var_new_name)
788 int varid;
789 char *c_var_new_name;
790 struct NetCDFVar *Netcdf_var;
791 -
792 - rb_secure(3);
793 +
794 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
795 ncid=Netcdf_var->ncid;
796 varid=Netcdf_var->varid;
797
798 Check_Type(var_new_name,T_STRING);
799 c_var_new_name=StringValueCStr(var_new_name);
800 -
801 +
802 status = nc_rename_var(ncid,varid,c_var_new_name);
803 if(status !=NC_NOERR) NC_RAISE(status);
804
805 @@ -1958,13 +1942,13 @@ NetCDF_var_att(VALUE Var,VALUE att_name)
806 VALUE Att;
807
808 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
809 -
810 +
811 ncid=Netcdf_var->ncid;
812 varid=Netcdf_var->varid;
813
814 Check_Type(att_name,T_STRING);
815 c_att_name=StringValueCStr(att_name);
816 -
817 +
818 status = nc_inq_attid(ncid,varid,c_att_name,&c_attnump);
819 if(status == NC_NOERR){
820 Netcdf_att=NetCDF_att_init(ncid,varid,c_att_name);
821 @@ -1982,17 +1966,17 @@ NetCDF_var_att(VALUE Var,VALUE att_name)
822
823 /* Redifinition of the "==" and "eql?" methods */
824
825 -VALUE
826 +VALUE
827 NetCDF_eql(VALUE filea,VALUE fileb)
828 {
829 struct Netcdf *ncfilea;
830 struct Netcdf *ncfileb;
831 -
832 +
833 if( rb_obj_is_kind_of(fileb, cNetCDF) ){
834 Data_Get_Struct(filea,struct Netcdf,ncfilea);
835 Data_Get_Struct(fileb,struct Netcdf,ncfileb);
836 -
837 - if(ncfilea->ncid == ncfileb->ncid &&
838 +
839 + if(ncfilea->ncid == ncfileb->ncid &&
840 strcmp(ncfilea->name,ncfileb->name)==0){
841 return Qtrue;
842 } else {
843 @@ -2008,12 +1992,12 @@ NetCDF_var_eql(VALUE Vara,VALUE Varb)
844 {
845 struct NetCDFVar *Netcdf_vara;
846 struct NetCDFVar *Netcdf_varb;
847 -
848 +
849 if( rb_obj_is_kind_of(Varb, cNetCDFVar) ){
850 Data_Get_Struct(Vara,struct NetCDFVar,Netcdf_vara);
851 Data_Get_Struct(Varb,struct NetCDFVar,Netcdf_varb);
852
853 - if(Netcdf_vara->ncid == Netcdf_varb->ncid &&
854 + if(Netcdf_vara->ncid == Netcdf_varb->ncid &&
855 Netcdf_vara->varid == Netcdf_varb->varid){
856 return Qtrue;
857 } else {
858 @@ -2024,7 +2008,7 @@ NetCDF_var_eql(VALUE Vara,VALUE Varb)
859 }
860 }
861
862 -VALUE
863 +VALUE
864 NetCDF_dim_eql(VALUE Dima,VALUE Dimb)
865 {
866 struct NetCDFDim *Netcdf_dima;
867 @@ -2033,8 +2017,8 @@ NetCDF_dim_eql(VALUE Dima,VALUE Dimb)
868 if( rb_obj_is_kind_of(Dimb, cNetCDFDim) ){
869 Data_Get_Struct(Dima,struct NetCDFDim,Netcdf_dima);
870 Data_Get_Struct(Dimb,struct NetCDFDim,Netcdf_dimb);
871 -
872 - if(Netcdf_dima->ncid == Netcdf_dimb->ncid &&
873 +
874 + if(Netcdf_dima->ncid == Netcdf_dimb->ncid &&
875 Netcdf_dima->dimid == Netcdf_dimb->dimid){
876 return Qtrue;
877 } else {
878 @@ -2050,16 +2034,16 @@ NetCDF_att_eql(VALUE Atta,VALUE Attb)
879 {
880 struct NetCDFAtt *Netcdf_atta;
881 struct NetCDFAtt *Netcdf_attb;
882 -
883 +
884 if( rb_obj_is_kind_of(Attb, cNetCDFAtt) ){
885 Data_Get_Struct(Atta,struct NetCDFAtt,Netcdf_atta);
886 Data_Get_Struct(Attb,struct NetCDFAtt,Netcdf_attb);
887 -
888 - if(Netcdf_atta->ncid == Netcdf_atta->ncid &&
889 - Netcdf_atta->varid == Netcdf_attb->varid &&
890 +
891 + if(Netcdf_atta->ncid == Netcdf_atta->ncid &&
892 + Netcdf_atta->varid == Netcdf_attb->varid &&
893 strcmp(Netcdf_atta->name,Netcdf_attb->name)==0){
894 return Qtrue;
895 - } else {
896 + } else {
897 return Qfalse;
898 }
899 } else {
900 @@ -2104,7 +2088,7 @@ NetCDF_get_var_char(VALUE Var)
901 }
902
903 Cbyte_to_NArray(NArray,ndimsp,shape,ptr);
904 -
905 +
906 status = nc_get_var_text(ncid,varid,(char *)ptr);
907 if(status != NC_NOERR) NC_RAISE(status);
908
909 @@ -2148,7 +2132,7 @@ NetCDF_get_var_byte(VALUE Var)
910 }
911
912 Cbyte_to_NArray(NArray,ndimsp,shape,ptr);
913 -
914 +
915 status = nc_get_var_uchar(ncid,varid,ptr);
916 if(status != NC_NOERR) NC_RAISE(status);
917
918 @@ -2192,7 +2176,7 @@ NetCDF_get_var_sint(VALUE Var)
919 }
920
921 Csint_to_NArray(NArray,ndimsp,shape,ptr);
922 -
923 +
924 status = nc_get_var_short(ncid,varid,ptr);
925 if(status != NC_NOERR) NC_RAISE(status);
926
927 @@ -2236,7 +2220,7 @@ NetCDF_get_var_int(VALUE Var)
928 }
929
930 Clint_to_NArray(NArray,ndimsp,shape,ptr);
931 -
932 +
933 status = nc_get_var_int(ncid,varid,ptr);
934 if(status != NC_NOERR) NC_RAISE(status);
935
936 @@ -2324,7 +2308,7 @@ NetCDF_get_var_double(VALUE Var)
937 }
938
939 Cdouble_to_NArray(NArray,ndimsp,shape,ptr);
940 -
941 +
942 status = nc_get_var_double(ncid,varid,ptr);
943 if(status != NC_NOERR) NC_RAISE(status);
944
945 @@ -2332,7 +2316,7 @@ NetCDF_get_var_double(VALUE Var)
946 return NArray;
947 }
948
949 -VALUE
950 +VALUE
951 NetCDF_get_var1_char(VALUE Var,VALUE start)
952 {
953 int ncid;
954 @@ -2349,7 +2333,7 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
955 na_shape_t *c_count;
956 VALUE NArray;
957
958 -
959 +
960 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
961 ncid = Netcdf_var->ncid;
962 varid = Netcdf_var->varid;
963 @@ -2358,12 +2342,12 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
964 if(ndims == 0) {
965 rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
966 }
967 -
968 +
969 Check_Type(start,T_ARRAY);
970 if(RARRAY_LEN(start) < ndims) {
971 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
972 }
973 -
974 +
975 c_start=ALLOCA_N(size_t,ndims);
976 c_count=ALLOCA_N(na_shape_t,ndims);
977 for(i=0;i<ndims;i++){
978 @@ -2376,13 +2360,13 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
979 l_start += dimlen;
980 }
981 c_start[i]=l_start;
982 -
983 +
984 c_count[i]=1;
985 }
986 -
987 -
988 -
989 -
990 +
991 +
992 +
993 +
994 Cbyte_to_NArray(NArray,ndims,c_count,ptr);
995 status = nc_get_var1_text(ncid,varid,c_start,(char *)ptr);
996 if(status != NC_NOERR) NC_RAISE(status);
997 @@ -2392,7 +2376,7 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
998
999 }
1000
1001 -VALUE
1002 +VALUE
1003 NetCDF_get_var1_byte(VALUE Var,VALUE start)
1004 {
1005 int ncid;
1006 @@ -2409,7 +2393,7 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
1007 na_shape_t *c_count;
1008 VALUE NArray;
1009
1010 -
1011 +
1012 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1013 ncid = Netcdf_var->ncid;
1014 varid = Netcdf_var->varid;
1015 @@ -2418,12 +2402,12 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
1016 if(ndims == 0) {
1017 rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
1018 }
1019 -
1020 +
1021 Check_Type(start,T_ARRAY);
1022 if(RARRAY_LEN(start) < ndims) {
1023 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1024 }
1025 -
1026 +
1027 c_start=ALLOCA_N(size_t,ndims);
1028 c_count=ALLOCA_N(na_shape_t,ndims);
1029 for(i=0;i<ndims;i++){
1030 @@ -2436,13 +2420,13 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
1031 l_start += dimlen;
1032 }
1033 c_start[i]=l_start;
1034 -
1035 +
1036 c_count[i]=1;
1037 }
1038 -
1039 -
1040 -
1041 -
1042 +
1043 +
1044 +
1045 +
1046 Cbyte_to_NArray(NArray,ndims,c_count,ptr);
1047 status = nc_get_var1_uchar(ncid,varid,c_start,ptr);
1048 if(status != NC_NOERR) NC_RAISE(status);
1049 @@ -2452,7 +2436,7 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
1050
1051 }
1052
1053 -VALUE
1054 +VALUE
1055 NetCDF_get_var1_sint(VALUE Var,VALUE start)
1056 {
1057 int ncid;
1058 @@ -2477,12 +2461,12 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
1059 if(ndims == 0) {
1060 rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
1061 }
1062 -
1063 +
1064 Check_Type(start,T_ARRAY);
1065 if(RARRAY_LEN(start) < ndims) {
1066 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1067 }
1068 -
1069 +
1070 c_start=ALLOCA_N(size_t,ndims);
1071 c_count=ALLOCA_N(na_shape_t,ndims);
1072 for(i=0;i<ndims;i++){
1073 @@ -2497,9 +2481,9 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
1074 c_start[i]=l_start;
1075 c_count[i]=1;
1076 }
1077 -
1078 +
1079 Csint_to_NArray(NArray,ndims,c_count,ptr);
1080 -
1081 +
1082 status = nc_get_var1_short(ncid,varid,c_start,ptr);
1083 if(status != NC_NOERR) NC_RAISE(status);
1084
1085 @@ -2508,7 +2492,7 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
1086
1087 }
1088
1089 -VALUE
1090 +VALUE
1091 NetCDF_get_var1_int(VALUE Var,VALUE start)
1092 {
1093 int ncid;
1094 @@ -2533,12 +2517,12 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
1095 if(ndims == 0) {
1096 rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
1097 }
1098 -
1099 +
1100 Check_Type(start,T_ARRAY);
1101 if(RARRAY_LEN(start) < ndims) {
1102 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1103 }
1104 -
1105 +
1106 c_start=ALLOCA_N(size_t,ndims);
1107 c_count=ALLOCA_N(na_shape_t,ndims);
1108 for(i=0;i<ndims;i++){
1109 @@ -2553,9 +2537,9 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
1110 c_start[i]=l_start;
1111 c_count[i]=1;
1112 }
1113 -
1114 +
1115 Clint_to_NArray(NArray,ndims,c_count,ptr);
1116 -
1117 +
1118 status = nc_get_var1_int(ncid,varid,c_start,ptr);
1119 if(status != NC_NOERR) NC_RAISE(status);
1120
1121 @@ -2564,7 +2548,7 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
1122
1123 }
1124
1125 -VALUE
1126 +VALUE
1127 NetCDF_get_var1_float(VALUE Var,VALUE start)
1128 {
1129 int ncid;
1130 @@ -2589,12 +2573,12 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
1131 if(ndims == 0) {
1132 rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
1133 }
1134 -
1135 +
1136 Check_Type(start,T_ARRAY);
1137 if(RARRAY_LEN(start) < ndims) {
1138 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1139 }
1140 -
1141 +
1142 c_start=ALLOCA_N(size_t,ndims);
1143 c_count=ALLOCA_N(na_shape_t,ndims);
1144 for(i=0;i<ndims;i++){
1145 @@ -2609,9 +2593,9 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
1146 c_start[i]=l_start;
1147 c_count[i]=1;
1148 }
1149 -
1150 +
1151 Cfloat_to_NArray(NArray,ndims,c_count,ptr);
1152 -
1153 +
1154 status = nc_get_var1_float(ncid,varid,c_start,ptr);
1155 if(status != NC_NOERR) NC_RAISE(status);
1156
1157 @@ -2620,7 +2604,7 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
1158
1159 }
1160
1161 -VALUE
1162 +VALUE
1163 NetCDF_get_var1_double(VALUE Var,VALUE start)
1164 {
1165 int ncid;
1166 @@ -2645,12 +2629,12 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
1167 if(ndims == 0) {
1168 rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
1169 }
1170 -
1171 +
1172 Check_Type(start,T_ARRAY);
1173 if(RARRAY_LEN(start) < ndims) {
1174 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1175 }
1176 -
1177 +
1178 c_start=ALLOCA_N(size_t,ndims);
1179 c_count=ALLOCA_N(na_shape_t,ndims);
1180 for(i=0;i<ndims;i++){
1181 @@ -2665,9 +2649,9 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
1182 c_start[i]=l_start;
1183 c_count[i]=1;
1184 }
1185 -
1186 +
1187 Cdouble_to_NArray(NArray,ndims,c_count,ptr);
1188 -
1189 +
1190 status = nc_get_var1_double(ncid,varid,c_start,ptr);
1191 if(status != NC_NOERR) NC_RAISE(status);
1192
1193 @@ -2698,7 +2682,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
1194 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1195 ncid = Netcdf_var->ncid;
1196 varid = Netcdf_var->varid;
1197 -
1198 +
1199 status = nc_inq_varndims(ncid,varid,&ndims);
1200 if(status != NC_NOERR) NC_RAISE(status);
1201 if(ndims == 0) {
1202 @@ -2708,7 +2692,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
1203 dimids = ALLOCA_N(int,ndims);
1204 status = nc_inq_vardimid(ncid,varid,dimids);
1205 if(status != NC_NOERR) NC_RAISE(status);
1206 -
1207 +
1208 Check_Type(start,T_ARRAY);
1209 if(RARRAY_LEN(start) < ndims){
1210 rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1211 @@ -2716,7 +2700,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
1212 c_start = ALLOCA_N(size_t,ndims);
1213 for(i=0; i<ndims; i++){
1214 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1215 -
1216 +
1217 if(l_start < 0) {
1218 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1219 if(status != NC_NOERR) NC_RAISE(status);
1220 @@ -2769,14 +2753,14 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
1221 }
1222 }
1223
1224 -
1225 +
1226 shape = ALLOCA_N(na_shape_t,ndims);
1227 for(i=0;i<ndims;i++){
1228 shape[ndims-1-i]=c_count[i];
1229 }
1230 -
1231 +
1232 Cbyte_to_NArray(NArray,ndims,shape,ptr);
1233 -
1234 +
1235 status = nc_get_vars_text(ncid,varid,c_start,c_count,c_stride,(char *)ptr);
1236 if(status != NC_NOERR) NC_RAISE(status);
1237
1238 @@ -2806,7 +2790,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
1239 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1240 ncid = Netcdf_var->ncid;
1241 varid = Netcdf_var->varid;
1242 -
1243 +
1244 status = nc_inq_varndims(ncid,varid,&ndims);
1245 if(status != NC_NOERR) NC_RAISE(status);
1246 if(ndims == 0) {
1247 @@ -2816,7 +2800,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
1248 dimids = ALLOCA_N(int,ndims);
1249 status = nc_inq_vardimid(ncid,varid,dimids);
1250 if(status != NC_NOERR) NC_RAISE(status);
1251 -
1252 +
1253 Check_Type(start,T_ARRAY);
1254 if(RARRAY_LEN(start) < ndims){
1255 rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1256 @@ -2824,7 +2808,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
1257 c_start = ALLOCA_N(size_t,ndims);
1258 for(i=0; i<ndims; i++){
1259 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1260 -
1261 +
1262 if(l_start < 0) {
1263 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1264 if(status != NC_NOERR) NC_RAISE(status);
1265 @@ -2877,14 +2861,14 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
1266 }
1267 }
1268
1269 -
1270 +
1271 shape = ALLOCA_N(na_shape_t,ndims);
1272 for(i=0;i<ndims;i++){
1273 shape[ndims-1-i]=c_count[i];
1274 }
1275 -
1276 +
1277 Cbyte_to_NArray(NArray,ndims,shape,ptr);
1278 -
1279 +
1280 status = nc_get_vars_uchar(ncid,varid,c_start,c_count,c_stride,ptr);
1281 if(status != NC_NOERR) NC_RAISE(status);
1282
1283 @@ -2914,7 +2898,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
1284 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1285 ncid = Netcdf_var->ncid;
1286 varid = Netcdf_var->varid;
1287 -
1288 +
1289 status = nc_inq_varndims(ncid,varid,&ndims);
1290 if(status != NC_NOERR) NC_RAISE(status);
1291 if(ndims == 0) {
1292 @@ -2924,7 +2908,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
1293 dimids = ALLOCA_N(int,ndims);
1294 status = nc_inq_vardimid(ncid,varid,dimids);
1295 if(status != NC_NOERR) NC_RAISE(status);
1296 -
1297 +
1298 Check_Type(start,T_ARRAY);
1299 if(RARRAY_LEN(start) < ndims){
1300 rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1301 @@ -2932,7 +2916,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
1302 c_start = ALLOCA_N(size_t,ndims);
1303 for(i=0; i<ndims; i++){
1304 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1305 -
1306 +
1307 if(l_start < 0) {
1308 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1309 if(status != NC_NOERR) NC_RAISE(status);
1310 @@ -2984,19 +2968,19 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
1311 c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
1312 }
1313 }
1314 -
1315 -
1316 +
1317 +
1318 shape = ALLOCA_N(na_shape_t,ndims);
1319 for(i=0;i<ndims;i++){
1320 shape[ndims-1-i]=c_count[i];
1321 }
1322
1323 Csint_to_NArray(NArray,ndims,shape,ptr);
1324 -
1325 +
1326
1327 status = nc_get_vars_short(ncid,varid,c_start,c_count,c_stride,ptr);
1328 if(status != NC_NOERR) NC_RAISE(status);
1329 -
1330 +
1331 OBJ_TAINT(NArray);
1332 return NArray;
1333 }
1334 @@ -3023,7 +3007,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
1335 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1336 ncid = Netcdf_var->ncid;
1337 varid = Netcdf_var->varid;
1338 -
1339 +
1340 status = nc_inq_varndims(ncid,varid,&ndims);
1341 if(status != NC_NOERR) NC_RAISE(status);
1342 if(ndims == 0) {
1343 @@ -3033,7 +3017,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
1344 dimids = ALLOCA_N(int,ndims);
1345 status = nc_inq_vardimid(ncid,varid,dimids);
1346 if(status != NC_NOERR) NC_RAISE(status);
1347 -
1348 +
1349 Check_Type(start,T_ARRAY);
1350 if(RARRAY_LEN(start) < ndims){
1351 rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1352 @@ -3041,7 +3025,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
1353 c_start = ALLOCA_N(size_t,ndims);
1354 for(i=0; i<ndims; i++){
1355 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1356 -
1357 +
1358 if(l_start < 0) {
1359 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1360 if(status != NC_NOERR) NC_RAISE(status);
1361 @@ -3094,14 +3078,14 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
1362 }
1363 }
1364
1365 -
1366 +
1367 shape = ALLOCA_N(na_shape_t,ndims);
1368 for(i=0;i<ndims;i++){
1369 shape[ndims-1-i]=c_count[i];
1370 }
1371
1372 Clint_to_NArray(NArray,ndims,shape,ptr);
1373 -
1374 +
1375
1376 status = nc_get_vars_int(ncid,varid,c_start,c_count,c_stride,ptr);
1377 if(status != NC_NOERR) NC_RAISE(status);
1378 @@ -3132,7 +3116,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
1379 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1380 ncid = Netcdf_var->ncid;
1381 varid = Netcdf_var->varid;
1382 -
1383 +
1384 status = nc_inq_varndims(ncid,varid,&ndims);
1385 if(status != NC_NOERR) NC_RAISE(status);
1386 if(ndims == 0) {
1387 @@ -3142,7 +3126,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
1388 dimids = ALLOCA_N(int,ndims);
1389 status = nc_inq_vardimid(ncid,varid,dimids);
1390 if(status != NC_NOERR) NC_RAISE(status);
1391 -
1392 +
1393 Check_Type(start,T_ARRAY);
1394 if(RARRAY_LEN(start) < ndims){
1395 rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1396 @@ -3150,7 +3134,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
1397 c_start = ALLOCA_N(size_t,ndims);
1398 for(i=0; i<ndims; i++){
1399 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1400 -
1401 +
1402 if(l_start < 0) {
1403 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1404 if(status != NC_NOERR) NC_RAISE(status);
1405 @@ -3202,16 +3186,16 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
1406 c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
1407 }
1408 }
1409 -
1410 +
1411
1412 shape = ALLOCA_N(na_shape_t,ndims);
1413 for(i=0;i<ndims;i++){
1414 shape[ndims-1-i]=c_count[i];
1415 }
1416 -
1417 +
1418 Cfloat_to_NArray(NArray,ndims,shape,ptr);
1419 -
1420 -
1421 +
1422 +
1423 status = nc_get_vars_float(ncid,varid,c_start,c_count,c_stride,ptr);
1424 if(status != NC_NOERR) NC_RAISE(status);
1425
1426 @@ -3241,7 +3225,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
1427 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1428 ncid = Netcdf_var->ncid;
1429 varid = Netcdf_var->varid;
1430 -
1431 +
1432 status = nc_inq_varndims(ncid,varid,&ndims);
1433 if(status != NC_NOERR) NC_RAISE(status);
1434 if(ndims == 0) {
1435 @@ -3251,7 +3235,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
1436 dimids = ALLOCA_N(int,ndims);
1437 status = nc_inq_vardimid(ncid,varid,dimids);
1438 if(status != NC_NOERR) NC_RAISE(status);
1439 -
1440 +
1441 Check_Type(start,T_ARRAY);
1442 if(RARRAY_LEN(start) < ndims){
1443 rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1444 @@ -3259,7 +3243,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
1445 c_start = ALLOCA_N(size_t,ndims);
1446 for(i=0; i<ndims; i++){
1447 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1448 -
1449 +
1450 if(l_start < 0) {
1451 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1452 if(status != NC_NOERR) NC_RAISE(status);
1453 @@ -3311,15 +3295,15 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
1454 c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
1455 }
1456 }
1457 -
1458 +
1459
1460 shape = ALLOCA_N(na_shape_t,ndims);
1461 for(i=0;i<ndims;i++){
1462 shape[ndims-1-i]=c_count[i];
1463 }
1464 -
1465 +
1466 Cdouble_to_NArray(NArray,ndims,shape,ptr);
1467 -
1468 +
1469 status = nc_get_vars_double(ncid,varid,c_start,c_count,c_stride,ptr);
1470 if(status != NC_NOERR) NC_RAISE(status);
1471
1472 @@ -3343,13 +3327,12 @@ NetCDF_put_var_char(VALUE Var,VALUE NArray)
1473 size_t lengthp;
1474 char *var_name;
1475
1476 - rb_secure(3);
1477 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1478 ncid=Netcdf_var->ncid;
1479 varid=Netcdf_var->varid;
1480
1481 Array_to_Cbyte_len(NArray,ptr,len);
1482 -
1483 +
1484 status = nc_inq_varndims(ncid,varid,&ndimsp);
1485 if(status != NC_NOERR) NC_RAISE(status);
1486 for(i=0;i<ndimsp;i++){
1487 @@ -3388,13 +3371,12 @@ NetCDF_put_var_byte(VALUE Var,VALUE NArray)
1488 size_t lengthp;
1489 char *var_name;
1490
1491 - rb_secure(3);
1492 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1493 ncid=Netcdf_var->ncid;
1494 varid=Netcdf_var->varid;
1495
1496 Array_to_Cbyte_len(NArray,ptr,len);
1497 -
1498 +
1499 status = nc_inq_varndims(ncid,varid,&ndimsp);
1500 if(status != NC_NOERR) NC_RAISE(status);
1501 for(i=0;i<ndimsp;i++){
1502 @@ -3433,12 +3415,11 @@ NetCDF_put_var_short(VALUE Var,VALUE NArray)
1503 size_t lengthp;
1504 char *var_name;
1505
1506 - rb_secure(3);
1507 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1508 ncid=Netcdf_var->ncid;
1509 varid=Netcdf_var->varid;
1510 Array_to_Csint_len(NArray,ptr,len);
1511 -
1512 +
1513 status = nc_inq_varndims(ncid,varid,&ndimsp);
1514 if(status != NC_NOERR) NC_RAISE(status);
1515 for(i=0;i<ndimsp;i++){
1516 @@ -3478,7 +3459,6 @@ NetCDF_put_var_int(VALUE Var,VALUE NArray)
1517 size_t lengthp;
1518 char *var_name;
1519
1520 - rb_secure(3);
1521 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1522 ncid=Netcdf_var->ncid;
1523 varid=Netcdf_var->varid;
1524 @@ -3503,8 +3483,8 @@ NetCDF_put_var_int(VALUE Var,VALUE NArray)
1525 if(status != NC_NOERR) NC_RAISE(status);
1526 rb_raise(rb_eNetcdfError,"Length of NArray don't equal to length of total array length in the '%s'\n",var_name);
1527 }
1528 -
1529 -
1530 +
1531 +
1532 status = nc_put_var_int(ncid,varid,ptr);
1533 if(status !=NC_NOERR) NC_RAISE(status);
1534 return Qnil;
1535 @@ -3525,15 +3505,14 @@ NetCDF_put_var_float(VALUE Var,VALUE NArray)
1536 int dimids[NC_MAX_DIMS];
1537 size_t lengthp;
1538 char *var_name;
1539 -
1540 -
1541 - rb_secure(3);
1542 +
1543 +
1544 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1545 ncid=Netcdf_var->ncid;
1546 varid=Netcdf_var->varid;
1547
1548 Array_to_Cfloat_len(NArray,ptr,len);
1549 -
1550 +
1551 status = nc_inq_varndims(ncid,varid,&ndimsp);
1552 if(status != NC_NOERR) NC_RAISE(status);
1553 for(i=0;i<ndimsp;i++){
1554 @@ -3574,7 +3553,6 @@ NetCDF_put_var_double(VALUE Var,VALUE NArray)
1555 char *var_name;
1556
1557
1558 - rb_secure(3);
1559 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1560 ncid=Netcdf_var->ncid;
1561 varid=Netcdf_var->varid;
1562 @@ -3619,19 +3597,18 @@ NetCDF_put_var1_char(VALUE Var,VALUE NArray,VALUE start)
1563 int ndims;
1564 int *dimids;
1565 size_t dimlen;
1566 -
1567 - rb_secure(3);
1568 +
1569 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1570 ncid=Netcdf_var->ncid;
1571 varid=Netcdf_var->varid;
1572 status = nc_inq_varndims(ncid,varid,&ndims);
1573 if(status != NC_NOERR) NC_RAISE(status);
1574
1575 -
1576 +
1577 dimids = ALLOCA_N(int,ndims);
1578 status = nc_inq_vardimid(ncid,varid,dimids);
1579 if(status != NC_NOERR) NC_RAISE(status);
1580 -
1581 +
1582 Check_Type(start,T_ARRAY);
1583 if(RARRAY_LEN(start) <ndims) {
1584 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1585 @@ -3640,7 +3617,7 @@ NetCDF_put_var1_char(VALUE Var,VALUE NArray,VALUE start)
1586 c_start=ALLOCA_N(size_t,ndims);
1587 for(i=0;i<ndims;i++){
1588 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1589 -
1590 +
1591 if(l_start < 0) {
1592 status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
1593 if(status != NC_NOERR) NC_RAISE(status);
1594 @@ -3670,19 +3647,18 @@ NetCDF_put_var1_byte(VALUE Var,VALUE NArray,VALUE start)
1595 int ndims;
1596 int *dimids;
1597 size_t dimlen;
1598 -
1599 - rb_secure(3);
1600 +
1601 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1602 ncid=Netcdf_var->ncid;
1603 varid=Netcdf_var->varid;
1604 status = nc_inq_varndims(ncid,varid,&ndims);
1605 if(status != NC_NOERR) NC_RAISE(status);
1606
1607 -
1608 +
1609 dimids = ALLOCA_N(int,ndims);
1610 status = nc_inq_vardimid(ncid,varid,dimids);
1611 if(status != NC_NOERR) NC_RAISE(status);
1612 -
1613 +
1614 Check_Type(start,T_ARRAY);
1615 if(RARRAY_LEN(start) <ndims) {
1616 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1617 @@ -3691,7 +3667,7 @@ NetCDF_put_var1_byte(VALUE Var,VALUE NArray,VALUE start)
1618 c_start=ALLOCA_N(size_t,ndims);
1619 for(i=0;i<ndims;i++){
1620 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1621 -
1622 +
1623 if(l_start < 0) {
1624 status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
1625 if(status != NC_NOERR) NC_RAISE(status);
1626 @@ -3721,19 +3697,18 @@ NetCDF_put_var1_sint(VALUE Var,VALUE NArray,VALUE start)
1627 int ndims;
1628 int *dimids;
1629 size_t dimlen;
1630 -
1631 - rb_secure(3);
1632 +
1633 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1634 ncid=Netcdf_var->ncid;
1635 varid=Netcdf_var->varid;
1636 status = nc_inq_varndims(ncid,varid,&ndims);
1637 if(status != NC_NOERR) NC_RAISE(status);
1638
1639 -
1640 +
1641 dimids = ALLOCA_N(int,ndims);
1642 status = nc_inq_vardimid(ncid,varid,dimids);
1643 if(status != NC_NOERR) NC_RAISE(status);
1644 -
1645 +
1646 Check_Type(start,T_ARRAY);
1647 if(RARRAY_LEN(start) <ndims) {
1648 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1649 @@ -3742,7 +3717,7 @@ NetCDF_put_var1_sint(VALUE Var,VALUE NArray,VALUE start)
1650 c_start=ALLOCA_N(size_t,ndims);
1651 for(i=0;i<ndims;i++){
1652 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1653 -
1654 +
1655 if(l_start < 0) {
1656 status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
1657 if(status != NC_NOERR) NC_RAISE(status);
1658 @@ -3771,19 +3746,18 @@ NetCDF_put_var1_int(VALUE Var,VALUE NArray,VALUE start)
1659 int ndims;
1660 int *dimids;
1661 size_t dimlen;
1662 -
1663 - rb_secure(3);
1664 +
1665 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1666 ncid=Netcdf_var->ncid;
1667 varid=Netcdf_var->varid;
1668 status = nc_inq_varndims(ncid,varid,&ndims);
1669 if(status != NC_NOERR) NC_RAISE(status);
1670
1671 -
1672 +
1673 dimids = ALLOCA_N(int,ndims);
1674 status = nc_inq_vardimid(ncid,varid,dimids);
1675 if(status != NC_NOERR) NC_RAISE(status);
1676 -
1677 +
1678 Check_Type(start,T_ARRAY);
1679 if(RARRAY_LEN(start) <ndims) {
1680 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1681 @@ -3792,7 +3766,7 @@ NetCDF_put_var1_int(VALUE Var,VALUE NArray,VALUE start)
1682 c_start=ALLOCA_N(size_t,ndims);
1683 for(i=0;i<ndims;i++){
1684 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1685 -
1686 +
1687 if(l_start < 0) {
1688 status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
1689 if(status != NC_NOERR) NC_RAISE(status);
1690 @@ -3822,19 +3796,18 @@ NetCDF_put_var1_float(VALUE Var,VALUE NArray,VALUE start)
1691 int ndims;
1692 int *dimids;
1693 size_t dimlen;
1694 -
1695 - rb_secure(3);
1696 +
1697 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1698 ncid=Netcdf_var->ncid;
1699 varid=Netcdf_var->varid;
1700 status = nc_inq_varndims(ncid,varid,&ndims);
1701 if(status != NC_NOERR) NC_RAISE(status);
1702
1703 -
1704 +
1705 dimids = ALLOCA_N(int,ndims);
1706 status = nc_inq_vardimid(ncid,varid,dimids);
1707 if(status != NC_NOERR) NC_RAISE(status);
1708 -
1709 +
1710 Check_Type(start,T_ARRAY);
1711 if(RARRAY_LEN(start) <ndims) {
1712 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1713 @@ -3843,7 +3816,7 @@ NetCDF_put_var1_float(VALUE Var,VALUE NArray,VALUE start)
1714 c_start=ALLOCA_N(size_t,ndims);
1715 for(i=0;i<ndims;i++){
1716 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1717 -
1718 +
1719 if(l_start < 0) {
1720 status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
1721 if(status != NC_NOERR) NC_RAISE(status);
1722 @@ -3873,19 +3846,18 @@ NetCDF_put_var1_double(VALUE Var,VALUE NArray,VALUE start)
1723 int ndims;
1724 int *dimids;
1725 size_t dimlen;
1726 -
1727 - rb_secure(3);
1728 +
1729 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1730 ncid=Netcdf_var->ncid;
1731 varid=Netcdf_var->varid;
1732 status = nc_inq_varndims(ncid,varid,&ndims);
1733 if(status != NC_NOERR) NC_RAISE(status);
1734
1735 -
1736 +
1737 dimids = ALLOCA_N(int,ndims);
1738 status = nc_inq_vardimid(ncid,varid,dimids);
1739 if(status != NC_NOERR) NC_RAISE(status);
1740 -
1741 +
1742 Check_Type(start,T_ARRAY);
1743 if(RARRAY_LEN(start) <ndims) {
1744 rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
1745 @@ -3894,7 +3866,7 @@ NetCDF_put_var1_double(VALUE Var,VALUE NArray,VALUE start)
1746 c_start=ALLOCA_N(size_t,ndims);
1747 for(i=0;i<ndims;i++){
1748 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1749 -
1750 +
1751 if(l_start < 0) {
1752 status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
1753 if(status != NC_NOERR) NC_RAISE(status);
1754 @@ -3930,7 +3902,6 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1755 int *dimids;
1756 size_t dimlen;
1757
1758 - rb_secure(3);
1759 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1760 ncid=Netcdf_var->ncid;
1761 varid=Netcdf_var->varid;
1762 @@ -3943,12 +3914,12 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1763
1764 Check_Type(start,T_ARRAY);
1765 if(RARRAY_LEN(start) < ndims) {
1766 - rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1767 + rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1768 }
1769 c_start=ALLOCA_N(size_t,ndims);
1770 for(i=0; i<ndims; i++){
1771 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1772 -
1773 +
1774 if(l_start < 0) {
1775 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1776 if(status != NC_NOERR) NC_RAISE(status);
1777 @@ -3956,7 +3927,7 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1778 }
1779 c_start[i]=l_start;
1780 }
1781 -
1782 +
1783 c_stride=ALLOCA_N(ptrdiff_t,ndims);
1784 switch(TYPE(stride)){
1785 case T_NIL:
1786 @@ -3967,12 +3938,12 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1787 default:
1788 Check_Type(stride,T_ARRAY);
1789 if(RARRAY_LEN(stride) < ndims) {
1790 - rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1791 + rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1792 }
1793 for(i=0; i<ndims; i++){
1794 c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
1795 if(c_stride[i]==0) {
1796 - rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1797 + rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1798 }
1799 }
1800 }
1801 @@ -3990,7 +3961,7 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1802 default:
1803 Check_Type(end,T_ARRAY);
1804 if(RARRAY_LEN(end) < ndims) {
1805 - rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1806 + rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1807 }
1808 for(i=0; i<ndims; i++){
1809 l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
1810 @@ -4036,7 +4007,6 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1811 int *dimids;
1812 size_t dimlen;
1813
1814 - rb_secure(3);
1815 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1816 ncid=Netcdf_var->ncid;
1817 varid=Netcdf_var->varid;
1818 @@ -4049,12 +4019,12 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1819
1820 Check_Type(start,T_ARRAY);
1821 if(RARRAY_LEN(start) < ndims) {
1822 - rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1823 + rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1824 }
1825 c_start=ALLOCA_N(size_t,ndims);
1826 for(i=0; i<ndims; i++){
1827 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1828 -
1829 +
1830 if(l_start < 0) {
1831 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1832 if(status != NC_NOERR) NC_RAISE(status);
1833 @@ -4062,7 +4032,7 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1834 }
1835 c_start[i]=l_start;
1836 }
1837 -
1838 +
1839 c_stride=ALLOCA_N(ptrdiff_t,ndims);
1840 switch(TYPE(stride)){
1841 case T_NIL:
1842 @@ -4073,12 +4043,12 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1843 default:
1844 Check_Type(stride,T_ARRAY);
1845 if(RARRAY_LEN(stride) < ndims) {
1846 - rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1847 + rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1848 }
1849 for(i=0; i<ndims; i++){
1850 c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
1851 if(c_stride[i]==0) {
1852 - rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1853 + rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1854 }
1855 }
1856 }
1857 @@ -4096,7 +4066,7 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1858 default:
1859 Check_Type(end,T_ARRAY);
1860 if(RARRAY_LEN(end) < ndims) {
1861 - rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1862 + rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1863 }
1864 for(i=0; i<ndims; i++){
1865 l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
1866 @@ -4142,7 +4112,6 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1867 int *dimids;
1868 size_t dimlen;
1869
1870 - rb_secure(3);
1871 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1872 ncid=Netcdf_var->ncid;
1873 varid=Netcdf_var->varid;
1874 @@ -4155,12 +4124,12 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1875
1876 Check_Type(start,T_ARRAY);
1877 if(RARRAY_LEN(start) < ndims) {
1878 - rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1879 + rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1880 }
1881 c_start=ALLOCA_N(size_t,ndims);
1882 for(i=0; i<ndims; i++){
1883 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1884 -
1885 +
1886 if(l_start < 0) {
1887 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1888 if(status != NC_NOERR) NC_RAISE(status);
1889 @@ -4168,7 +4137,7 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1890 }
1891 c_start[i]=l_start;
1892 }
1893 -
1894 +
1895 c_stride=ALLOCA_N(ptrdiff_t,ndims);
1896 switch(TYPE(stride)){
1897 case T_NIL:
1898 @@ -4179,12 +4148,12 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1899 default:
1900 Check_Type(stride,T_ARRAY);
1901 if(RARRAY_LEN(stride) < ndims) {
1902 - rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1903 + rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1904 }
1905 for(i=0; i<ndims; i++){
1906 c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
1907 if(c_stride[i]==0) {
1908 - rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1909 + rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1910 }
1911 }
1912 }
1913 @@ -4202,7 +4171,7 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1914 default:
1915 Check_Type(end,T_ARRAY);
1916 if(RARRAY_LEN(end) < ndims) {
1917 - rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1918 + rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1919 }
1920 for(i=0; i<ndims; i++){
1921 l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
1922 @@ -4249,7 +4218,6 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1923 int *dimids;
1924 size_t dimlen;
1925
1926 - rb_secure(3);
1927 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1928 ncid=Netcdf_var->ncid;
1929 varid=Netcdf_var->varid;
1930 @@ -4262,12 +4230,12 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1931
1932 Check_Type(start,T_ARRAY);
1933 if(RARRAY_LEN(start) < ndims) {
1934 - rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1935 + rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
1936 }
1937 c_start=ALLOCA_N(size_t,ndims);
1938 for(i=0; i<ndims; i++){
1939 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
1940 -
1941 +
1942 if(l_start < 0) {
1943 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
1944 if(status != NC_NOERR) NC_RAISE(status);
1945 @@ -4275,7 +4243,7 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1946 }
1947 c_start[i]=l_start;
1948 }
1949 -
1950 +
1951 c_stride=ALLOCA_N(ptrdiff_t,ndims);
1952 switch(TYPE(stride)){
1953 case T_NIL:
1954 @@ -4286,12 +4254,12 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1955 default:
1956 Check_Type(stride,T_ARRAY);
1957 if(RARRAY_LEN(stride) < ndims) {
1958 - rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1959 + rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
1960 }
1961 for(i=0; i<ndims; i++){
1962 c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
1963 if(c_stride[i]==0) {
1964 - rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1965 + rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
1966 }
1967 }
1968 }
1969 @@ -4309,7 +4277,7 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1970 default:
1971 Check_Type(end,T_ARRAY);
1972 if(RARRAY_LEN(end) < ndims) {
1973 - rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1974 + rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
1975 }
1976 for(i=0; i<ndims; i++){
1977 l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
1978 @@ -4326,8 +4294,8 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1979 ptr = ALLOCA_N(int,c_count_all);
1980 for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
1981 } else if(len != c_count_all) {
1982 - rb_raise(rb_eNetcdfError,
1983 - "length of the array does not agree with that of the subset\n");
1984 + rb_raise(rb_eNetcdfError,
1985 + "length of the array does not agree with that of the subset\n");
1986 }
1987 }
1988
1989 @@ -4356,7 +4324,6 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1990 int *dimids;
1991 size_t dimlen;
1992
1993 - rb_secure(3);
1994 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1995 ncid=Netcdf_var->ncid;
1996 varid=Netcdf_var->varid;
1997 @@ -4369,12 +4336,12 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
1998
1999 Check_Type(start,T_ARRAY);
2000 if(RARRAY_LEN(start) < ndims) {
2001 - rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
2002 + rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
2003 }
2004 c_start=ALLOCA_N(size_t,ndims);
2005 for(i=0; i<ndims; i++){
2006 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2007 -
2008 +
2009 if(l_start < 0) {
2010 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
2011 if(status != NC_NOERR) NC_RAISE(status);
2012 @@ -4382,7 +4349,7 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
2013 }
2014 c_start[i]=l_start;
2015 }
2016 -
2017 +
2018 c_stride=ALLOCA_N(ptrdiff_t,ndims);
2019 switch(TYPE(stride)){
2020 case T_NIL:
2021 @@ -4393,12 +4360,12 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
2022 default:
2023 Check_Type(stride,T_ARRAY);
2024 if(RARRAY_LEN(stride) < ndims) {
2025 - rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
2026 + rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
2027 }
2028 for(i=0; i<ndims; i++){
2029 c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
2030 if(c_stride[i]==0) {
2031 - rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
2032 + rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
2033 }
2034 }
2035 }
2036 @@ -4416,7 +4383,7 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
2037 default:
2038 Check_Type(end,T_ARRAY);
2039 if(RARRAY_LEN(end) < ndims) {
2040 - rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
2041 + rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
2042 }
2043 for(i=0; i<ndims; i++){
2044 l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
2045 @@ -4463,7 +4430,6 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
2046 int *dimids;
2047 size_t dimlen;
2048
2049 - rb_secure(3);
2050 Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
2051 ncid=Netcdf_var->ncid;
2052 varid=Netcdf_var->varid;
2053 @@ -4476,12 +4442,12 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
2054
2055 Check_Type(start,T_ARRAY);
2056 if(RARRAY_LEN(start) < ndims) {
2057 - rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
2058 + rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
2059 }
2060 c_start=ALLOCA_N(size_t,ndims);
2061 for(i=0; i<ndims; i++){
2062 l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2063 -
2064 +
2065 if(l_start < 0) {
2066 status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
2067 if(status != NC_NOERR) NC_RAISE(status);
2068 @@ -4489,7 +4455,7 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
2069 }
2070 c_start[i]=l_start;
2071 }
2072 -
2073 +
2074 c_stride=ALLOCA_N(ptrdiff_t,ndims);
2075 switch(TYPE(stride)){
2076 case T_NIL:
2077 @@ -4500,12 +4466,12 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
2078 default:
2079 Check_Type(stride,T_ARRAY);
2080 if(RARRAY_LEN(stride) < ndims) {
2081 - rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
2082 + rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
2083 }
2084 for(i=0; i<ndims; i++){
2085 c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
2086 if(c_stride[i]==0) {
2087 - rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
2088 + rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
2089 }
2090 }
2091 }
2092 @@ -4523,7 +4489,7 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
2093 default:
2094 Check_Type(end,T_ARRAY);
2095 if(RARRAY_LEN(end) < ndims) {
2096 - rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
2097 + rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
2098 }
2099 for(i=0; i<ndims; i++){
2100 l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
2101 @@ -4589,7 +4555,7 @@ Init_netcdfraw(void)
2102 rb_eNetcdfEdge = rb_define_class("NetcdfEdge",rb_eNetcdfError);
2103 rb_eNetcdfStride = rb_define_class("NetcdfStride",rb_eNetcdfError);
2104 rb_eNetcdfBadname = rb_define_class("NetcdfBadname",rb_eNetcdfError);
2105 - /* N.B. following must match value in ncx.h */
2106 + /* N.B. following must match value in ncx.h */
2107 rb_eNetcdfRange = rb_define_class("NetcdfRange",rb_eNetcdfError);
2108 rb_eNetcdfNomem = rb_define_class("NetcdfNomem",rb_eNetcdfError);
2109 /* Global error status */
2110 @@ -4607,10 +4573,10 @@ Init_netcdfraw(void)
2111 rb_define_const(cNetCDF, "NC_NOCLOBBER", INT2FIX(NC_NOCLOBBER));
2112 #if NCVER >= 400
2113 rb_define_const(cNetCDF, "NC_64BIT_OFFSET", INT2FIX(NC_64BIT_OFFSET));
2114 - /* NC_64BIT_OFFSET supports large files in the class data format */
2115 + /* NC_64BIT_OFFSET supports large files in the class data format */
2116 rb_define_const(cNetCDF, "NC_NETCDF4", INT2FIX(NC_NETCDF4));
2117 rb_define_const(cNetCDF, "NC_CLASSIC_MODEL", INT2FIX(NC_CLASSIC_MODEL));
2118 - /* for use as ( NC_NETCDF4 | NC_CLASSIC_MODEL ) to ensure the classic
2119 + /* for use as ( NC_NETCDF4 | NC_CLASSIC_MODEL ) to ensure the classic
2120 data model in NetCDF4 by disabling new features like groups */
2121 rb_define_const(cNetCDF, "NC_ENDIAN_NATIVE", INT2FIX(NC_ENDIAN_NATIVE));
2122 rb_define_const(cNetCDF, "NC_ENDIAN_LITTLE", INT2FIX(NC_ENDIAN_LITTLE));
2123 @@ -4621,7 +4587,7 @@ Init_netcdfraw(void)
2124 rb_define_const(cNetCDF, "NC_FORMAT_NETCDF4", INT2FIX(NC_FORMAT_NETCDF4));
2125 rb_define_const(cNetCDF, "NC_FORMAT_NETCDF4_CLASSIC", INT2FIX(NC_FORMAT_NETCDF4_CLASSIC));
2126 #endif
2127 -
2128 +
2129 #ifdef NARRAY_BIGMEM
2130 rb_define_const(cNetCDF, "SUPPORT_BIGMEM", Qtrue);
2131 #else
2132 @@ -4658,7 +4624,7 @@ Init_netcdfraw(void)
2133 rb_define_private_method(cNetCDF,"id2var",NetCDF_id2var,1);
2134 rb_define_private_method(cNetCDF,"id2dim",NetCDF_id2dim,1);
2135 rb_define_private_method(cNetCDF,"id2att",NetCDF_id2att,1);
2136 - rb_define_method(cNetCDF,"==",NetCDF_eql,1);
2137 + rb_define_method(cNetCDF,"==",NetCDF_eql,1);
2138 /* rb_define_method(cNetCDF,"eql?",NetCDF_eql,1); */
2139
2140 /* The methods of the NetCDFDim class */
2141 @@ -4736,7 +4702,7 @@ Init_netcdfraw(void)
2142 rb_define_method(cNetCDFVar,"get_var_int",NetCDF_get_var_int,0);
2143 rb_define_method(cNetCDFVar,"get_var_sfloat",NetCDF_get_var_float,0);
2144 rb_define_method(cNetCDFVar,"get_var_float",NetCDF_get_var_double,0);
2145 -
2146 +
2147 rb_define_method(cNetCDFVar,"get_vars_char",NetCDF_get_vars_char,3);
2148 rb_define_method(cNetCDFVar,"get_vars_byte",NetCDF_get_vars_byte,3);
2149 rb_define_method(cNetCDFVar,"get_vars_sint",NetCDF_get_vars_sint,3);
2150 diff --git a/lib/numru/netcdf.rb b/lib/numru/netcdf.rb
2151 index 4e68f01..45722f5 100644
2152 --- a/lib/numru/netcdf.rb
2153 +++ b/lib/numru/netcdf.rb
2154 @@ -36,7 +36,7 @@ module NumRu
2155 raise("This method is available only for NetCDF >= 4") unless @@nc4
2156 case cmode
2157 when 0, nil, NC_CLASSIC_MODEL, /^CLASSIC$/i, NC_FORMAT_CLASSIC
2158 - # classic netcdf ver 3 fmt
2159 + # classic netcdf ver 3 fmt
2160 @@cr_format = 0
2161 when NC_64BIT_OFFSET, /^64BIT_OFFSET$/i, NC_FORMAT_64BIT
2162 @@cr_format = NC_64BIT_OFFSET
2163 @@ -65,229 +65,225 @@ module NumRu
2164 end
2165
2166 def NetCDF.open(filename,mode="r",share=false)
2167 - call_create=false # false-> nc_open; true->nc_create
2168 - case(mode)
2169 - when "r","rb" # read only
2170 - mode=NC_NOWRITE
2171 - when "w","w+","wb","w+b" # overwrite if exits
2172 - call_create=true
2173 - mode=NC_CLOBBER
2174 - when "a","a+","r+","ab","a+b","r+b" # append if exits
2175 - if( File.exists?(filename) )
2176 - mode=NC_WRITE
2177 - else
2178 - call_create=true #(nonexsitent --> create)
2179 - mode=NC_CLOBBER
2180 - end
2181 - else
2182 - raise NetcdfError, "Mode #{mode} is not supported"
2183 - end
2184 - case(share)
2185 - when false
2186 - share=0
2187 - when true
2188 - share=NC_SHARE
2189 - else
2190 - raise NetcdfError, "We can't use the sharing mode you typed"
2191 - end
2192 - omode = mode | share
2193 - if(!call_create)
2194 - nc_open(filename,omode)
2195 - else
2196 - nc_create(filename,omode)
2197 - end
2198 - end
2199 -
2200 + call_create=false # false-> nc_open; true->nc_create
2201 + case(mode)
2202 + when "r","rb" # read only
2203 + mode=NC_NOWRITE
2204 + when "w","w+","wb","w+b" # overwrite if exits
2205 + call_create=true
2206 + mode=NC_CLOBBER
2207 + when "a","a+","r+","ab","a+b","r+b" # append if exits
2208 + if( File.exists?(filename) )
2209 + mode=NC_WRITE
2210 + else
2211 + call_create=true #(nonexsitent --> create)
2212 + mode=NC_CLOBBER
2213 + end
2214 + else
2215 + raise NetcdfError, "Mode #{mode} is not supported"
2216 + end
2217 + case(share)
2218 + when false
2219 + share=0
2220 + when true
2221 + share=NC_SHARE
2222 + else
2223 + raise NetcdfError, "We can't use the sharing mode you typed"
2224 + end
2225 + omode = mode | share
2226 + if(!call_create)
2227 + nc_open(filename,omode)
2228 + else
2229 + nc_create(filename,omode)
2230 + end
2231 + end
2232 +
2233 class << NetCDF
2234 alias new open
2235 end
2236 -
2237 -
2238 +
2239 +
2240 def NetCDF.create(filename,noclobber=false,share=false)
2241 case(noclobber)
2242 when false
2243 - noclobber=NC_CLOBBER
2244 + noclobber=NC_CLOBBER
2245 when true
2246 - noclobber=NC_NOCLOBBER
2247 + noclobber=NC_NOCLOBBER
2248 else
2249 - raise NetcdfError,"noclobber (2nd argument) must be true or false"
2250 + raise NetcdfError,"noclobber (2nd argument) must be true or false"
2251 end
2252 case(share)
2253 when false
2254 - share=0
2255 + share=0
2256 when true
2257 - share=NC_SHARE
2258 + share=NC_SHARE
2259 else
2260 - raise NetcdfError,"share (3rd argument) must be true or false"
2261 + raise NetcdfError,"share (3rd argument) must be true or false"
2262 end
2263 -
2264 +
2265 cmode=noclobber | share | @@cr_format
2266 nc_create(filename,cmode)
2267 end
2268 -
2269 +
2270 class << NetCDF
2271 - def clean_tmpfile(path)
2272 - proc {
2273 - print "removing ", path, "..." if $DEBUG
2274 - if File.exist?(path)
2275 - File.unlink(path)
2276 - end
2277 - print "done\n" if $DEBUG
2278 - }
2279 - end
2280 - protected :clean_tmpfile
2281 - end
2282 -
2283 - def NetCDF.create_tmp(tmpdir=ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'.',
2284 - share=false)
2285 - basename = 'temp'
2286 - if $SAFE > 0 and tmpdir.tainted?
2287 - tmpdir = '.'
2288 - end
2289 -
2290 - n = 0
2291 - while true
2292 - begin
2293 - tmpname = sprintf('%s/%s%d_%d.nc', tmpdir, basename, $$, n)
2294 - unless File.exist?(tmpname)
2295 - netcdf = NetCDF.create(tmpname, true, share)
2296 - ObjectSpace.define_finalizer(netcdf,
2297 - NetCDF.clean_tmpfile(tmpname))
2298 - break
2299 - end
2300 - rescue
2301 - raise NetcdfError, "cannot generate tempfile `%s'" % tmpname if n >= Max_Try
2302 - end
2303 - n += 1
2304 - end
2305 - netcdf
2306 + def clean_tmpfile(path)
2307 + proc {
2308 + print "removing ", path, "..." if $DEBUG
2309 + if File.exist?(path)
2310 + File.unlink(path)
2311 + end
2312 + print "done\n" if $DEBUG
2313 + }
2314 + end
2315 + protected :clean_tmpfile
2316 + end
2317 +
2318 + def NetCDF.create_tmp(tmpdir=ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'.',
2319 + share=false)
2320 + basename = 'temp'
2321 + n = 0
2322 + while true
2323 + begin
2324 + tmpname = sprintf('%s/%s%d_%d.nc', tmpdir, basename, $$, n)
2325 + unless File.exist?(tmpname)
2326 + netcdf = NetCDF.create(tmpname, true, share)
2327 + ObjectSpace.define_finalizer(netcdf,
2328 + NetCDF.clean_tmpfile(tmpname))
2329 + break
2330 + end
2331 + rescue
2332 + raise NetcdfError, "cannot generate tempfile `%s'" % tmpname if n >= Max_Try
2333 + end
2334 + n += 1
2335 + end
2336 + netcdf
2337 end
2338
2339
2340 def put_att(attname,val,atttype=nil)
2341 - put_attraw(attname,val,atttype)
2342 + put_attraw(attname,val,atttype)
2343 end
2344 -
2345 +
2346 def def_var_with_dim(name, vartype, shape_ul0, dimnames)
2347 - # Same as def_var but defines dimensions first if needed.
2348 - # Use zero in shape to define an unlimited dimension.
2349 - if (shape_ul0.length != dimnames.length ) then
2350 - raise ArgumentError, 'lengths of shape and dimnames do not agree'
2351 - end
2352 - dims = []
2353 - dimnames.each_index{ |i|
2354 - dim = self.dim( dimnames[i] )
2355 - if ( dim != nil ) then
2356 - # dim exists --> check the length
2357 - if (shape_ul0[i] != dim.length_ul0 ) then
2358 - raise ArgumentError, "dimension length do not agree: #{i}th dim: "+\
2359 - "#{shape_ul0[i]} and #{dim.length_ul0}"
2360 - end
2361 - dims.push(dim)
2362 - else
2363 - # dim does not exist --> define it
2364 - dims.push( def_dim( dimnames[i], shape_ul0[i] ) )
2365 - end
2366 - }
2367 - def_var(name, vartype, dims)
2368 + # Same as def_var but defines dimensions first if needed.
2369 + # Use zero in shape to define an unlimited dimension.
2370 + if (shape_ul0.length != dimnames.length ) then
2371 + raise ArgumentError, 'lengths of shape and dimnames do not agree'
2372 + end
2373 + dims = []
2374 + dimnames.each_index{ |i|
2375 + dim = self.dim( dimnames[i] )
2376 + if ( dim != nil ) then
2377 + # dim exists --> check the length
2378 + if (shape_ul0[i] != dim.length_ul0 ) then
2379 + raise ArgumentError, "dimension length do not agree: #{i}th dim: "+\
2380 + "#{shape_ul0[i]} and #{dim.length_ul0}"
2381 + end
2382 + dims.push(dim)
2383 + else
2384 + # dim does not exist --> define it
2385 + dims.push( def_dim( dimnames[i], shape_ul0[i] ) )
2386 + end
2387 + }
2388 + def_var(name, vartype, dims)
2389 end
2390
2391 # Iterators:
2392 def each_dim
2393 - num_dim=ndims()
2394 + num_dim=ndims()
2395 for dimid in 0..num_dim-1
2396 - obj_Dim=id2dim(dimid)
2397 - yield(obj_Dim)
2398 + obj_Dim=id2dim(dimid)
2399 + yield(obj_Dim)
2400 end
2401 end
2402 -
2403 +
2404 def each_var
2405 num_var=nvars()
2406 for varid in 0..num_var-1
2407 - obj_Var=id2var(varid)
2408 - yield(obj_Var)
2409 + obj_Var=id2var(varid)
2410 + yield(obj_Var)
2411 end
2412 end
2413 -
2414 +
2415 def each_att
2416 num_att=natts()
2417 for attnum in 0..num_att-1
2418 - obj_Att=id2att(attnum)
2419 - yield(obj_Att)
2420 + obj_Att=id2att(attnum)
2421 + yield(obj_Att)
2422 end
2423 end
2424 -
2425 +
2426 def dims( names=nil ) # return all if names==nil
2427 - if names == nil
2428 - dims = (0..ndims()-1).collect{|dimid| id2dim(dimid)}
2429 - else
2430 - raise TypeError, "names is not an array" if ! names.is_a?(Array)
2431 - dims = names.collect{|name| dim(name)}
2432 - raise ArgumentError, "One or more dimensions do not exist" if dims.include?(nil)
2433 - end
2434 - dims
2435 + if names == nil
2436 + dims = (0..ndims()-1).collect{|dimid| id2dim(dimid)}
2437 + else
2438 + raise TypeError, "names is not an array" if ! names.is_a?(Array)
2439 + dims = names.collect{|name| dim(name)}
2440 + raise ArgumentError, "One or more dimensions do not exist" if dims.include?(nil)
2441 + end
2442 + dims
2443 end
2444
2445 def vars( names=nil ) # return all if names==nil
2446 - if names == nil
2447 - vars = (0..nvars()-1).collect{ |varid| id2var(varid) }
2448 - else
2449 - raise TypeError, "names is not an array" if ! names.is_a?(Array)
2450 - vars = names.collect{|name| var(name)}
2451 - raise ArgumentError, "One or more variables do not exist" if vars.include?(nil)
2452 - end
2453 - vars
2454 + if names == nil
2455 + vars = (0..nvars()-1).collect{ |varid| id2var(varid) }
2456 + else
2457 + raise TypeError, "names is not an array" if ! names.is_a?(Array)
2458 + vars = names.collect{|name| var(name)}
2459 + raise ArgumentError, "One or more variables do not exist" if vars.include?(nil)
2460 + end
2461 + vars
2462 end
2463
2464 def dim_names
2465 num_dim=ndims()
2466 names=[]
2467 for dimid in 0..num_dim-1
2468 - obj_Dim=id2dim(dimid)
2469 - names=names+[obj_Dim.name]
2470 + obj_Dim=id2dim(dimid)
2471 + names=names+[obj_Dim.name]
2472 end
2473 return names
2474 - end
2475 -
2476 + end
2477 +
2478 def var_names
2479 num_var=nvars()
2480 names=[]
2481 for varid in 0..num_var-1
2482 - obj_Var=id2var(varid)
2483 - names=names+[obj_Var.name]
2484 + obj_Var=id2var(varid)
2485 + names=names+[obj_Var.name]
2486 end
2487 return names
2488 end
2489 -
2490 +
2491 def att_names
2492 num_att=natts()
2493 names=[]
2494 for attnum in 0..num_att-1
2495 - obj_Att=id2att(attnum)
2496 - names=names+[obj_Att.name]
2497 + obj_Att=id2att(attnum)
2498 + names=names+[obj_Att.name]
2499 end
2500 return names
2501 end
2502 -
2503 +
2504 def inspect
2505 "NetCDF:"+path
2506 end
2507 -
2508 +
2509 end
2510 -
2511 +
2512 class NetCDFVar
2513 -
2514 +
2515 class << NetCDFVar
2516 - def new(file,varname,mode="r",share=false)
2517 - if(file.is_a?(String))
2518 - file = NetCDF.open(file,mode,share)
2519 - elsif(!file.is_a?(NetCDF))
2520 - raise TypeError, "1st arg must be a NetCDF (file object) or a String (path)"
2521 - end
2522 - file.var(varname)
2523 - end
2524 + def new(file,varname,mode="r",share=false)
2525 + if(file.is_a?(String))
2526 + file = NetCDF.open(file,mode,share)
2527 + elsif(!file.is_a?(NetCDF))
2528 + raise TypeError, "1st arg must be a NetCDF (file object) or a String (path)"
2529 + end
2530 + file.var(varname)
2531 + end
2532
2533 - alias open new
2534 + alias open new
2535 end
2536
2537 alias :rank :ndims
2538 @@ -295,516 +291,516 @@ module NumRu
2539 def each_att
2540 num_att=natts()
2541 for attnum in 0..num_att-1
2542 - obj_Att=id2att(attnum)
2543 - yield(obj_Att)
2544 + obj_Att=id2att(attnum)
2545 + yield(obj_Att)
2546 end
2547 end
2548 -
2549 +
2550 def dim_names
2551 ary = Array.new()
2552 dims.each{|dim| ary.push(dim.name)}
2553 ary
2554 end
2555 -
2556 - def att_names
2557 - num_att=natts()
2558 - names=[]
2559 - for attnum in 0..num_att-1
2560 - obj_Att=id2att(attnum)
2561 - names=names+[obj_Att.name]
2562 - end
2563 - return names
2564 - end
2565 -
2566 - def put_att(attname,val,atttype=nil)
2567 +
2568 + def att_names
2569 + num_att=natts()
2570 + names=[]
2571 + for attnum in 0..num_att-1
2572 + obj_Att=id2att(attnum)
2573 + names=names+[obj_Att.name]
2574 + end
2575 + return names
2576 + end
2577 +
2578 + def put_att(attname,val,atttype=nil)
2579 put_attraw(attname,val,atttype)
2580 - end
2581 + end
2582
2583 - def shape_ul0
2584 + def shape_ul0
2585 sh = []
2586 dims.each{|d|
2587 - if d.unlimited? then
2588 - sh.push(0)
2589 - else
2590 - sh.push(d.length)
2591 - end
2592 + if d.unlimited? then
2593 + sh.push(0)
2594 + else
2595 + sh.push(d.length)
2596 + end
2597 }
2598 sh
2599 - end
2600 -
2601 - def shape_current
2602 + end
2603 +
2604 + def shape_current
2605 sh = []
2606 dims.each{|d|
2607 - sh.push(d.length)
2608 + sh.push(d.length)
2609 }
2610 sh
2611 - end
2612 -
2613 - # The put and get methods in the NetCDFVar class
2614 -
2615 - def pack(na)
2616 - sf = att('scale_factor')
2617 - ao = att('add_offset')
2618 - if ( sf == nil && ao == nil ) then
2619 - na
2620 - else
2621 - na = NArray.to_na(na) if na.is_a?(Array)
2622 - if sf
2623 - csf = sf.get
2624 - raise NetcdfError,"scale_factor is not a numeric" if csf.is_a?(String)
2625 - raise NetcdfError, "scale_factor is not unique" if csf.length != 1
2626 - raise NetcdfError, "zero scale_factor" if csf[0] == 0
2627 - else
2628 - csf = nil
2629 - end
2630 - if ao
2631 - cao = ao.get
2632 - raise NetcdfError, "add_offset is not a numeric" if cao.is_a?(String)
2633 - raise NetcdfError, "add_offset is not unique" if cao.length != 1
2634 - else
2635 - cao = nil
2636 - end
2637 - if csf and cao
2638 - packed = (na - cao) / csf
2639 - elsif csf
2640 - packed = na / csf
2641 - elsif cao
2642 - packed = na - cao
2643 - end
2644 - if self.typecode <= NArray::LINT
2645 - packed = packed.round
2646 - end
2647 - packed
2648 - end
2649 - end
2650 -
2651 - def scaled_put(var,hash=nil)
2652 - simple_put( pack(var), hash)
2653 - end
2654 -
2655 - @@unpack_type = nil
2656 - class << NetCDFVar
2657 - def unpack_type
2658 - @@unpack_type
2659 - end
2660 - def unpack_type=(na_type)
2661 - if [NArray::BYTE, NArray::SINT, NArray::INT,
2662 - NArray::SFLOAT, NArray::FLOAT, nil].include?(na_type)
2663 - @@unpack_type = na_type
2664 - else
2665 - raise ArgumentError, "Arg must be one of NArray::BYTE, NArray::SINT, NArray::INT, NArray::SFLOAT, NArray::FLOAT"
2666 - end
2667 - end
2668 -
2669 - end
2670 -
2671 - def unpack(na)
2672 - sf = att('scale_factor')
2673 - ao = att('add_offset')
2674 - if ( sf == nil && ao == nil ) then
2675 - na
2676 - else
2677 - if sf
2678 - csf = sf.get
2679 - raise NetcdfError,"scale_factor is not a numeric" if csf.is_a?(String)
2680 - raise NetcdfError, "scale_factor is not unique" if csf.length != 1
2681 - raise NetcdfError, "zero scale_factor" if csf[0] == 0
2682 - else
2683 - csf =nil
2684 - end
2685 - if ao
2686 - cao = ao.get
2687 - raise NetcdfError, "add_offset is not a numeric" if cao.is_a?(String)
2688 - raise NetcdfError, "add_offset is not unique" if cao.length != 1
2689 - else
2690 - cao = nil
2691 - end
2692 - if csf and cao
2693 - una = na * csf + cao # csf & cao are NArray -> coerced to their types
2694 - elsif csf
2695 - una = na * csf
2696 - elsif cao
2697 - una = na + cao
2698 - end
2699 - una = una.to_type(@@unpack_type) if @@unpack_type
2700 - una
2701 - end
2702 - end
2703 -
2704 - def scaled_get(hash=nil)
2705 - unpack( simple_get(hash) )
2706 - end
2707 -
2708 - def simple_put(var,hash=nil)
2709 - if hash==nil
2710 - if self.vartype == "char"
2711 - put_var_char(var)
2712 - elsif self.vartype == "byte"
2713 - put_var_byte(var)
2714 - elsif self.vartype == "sint"
2715 - put_var_sint(var)
2716 - elsif self.vartype == "int"
2717 - put_var_int(var)
2718 - elsif self.vartype == "sfloat"
2719 - put_var_sfloat(var)
2720 - elsif self.vartype == "float"
2721 - put_var_float(var)
2722 - else
2723 - raise NetcdfError,"variable type isn't supported in netCDF"
2724 - end
2725 - elsif hash.key?("index")==true
2726 - if self.vartype == "char"
2727 - put_var1_char(var,hash["index"])
2728 - elsif self.vartype=="byte"
2729 - put_var1_byte(var,hash["index"])
2730 - elsif self.vartype=="sint"
2731 - put_var1_sint(var,hash["index"])
2732 - elsif self.vartype == "int"
2733 - put_var1_int(var,hash["index"])
2734 - elsif self.vartype == "sfloat"
2735 - put_var1_sfloat(var,hash["index"])
2736 - elsif self.vartype == "float"
2737 - put_var1_float(var,hash["index"])
2738 - else
2739 - raise NetcdfError,"variable type isn't supported in netCDF"
2740 - end
2741 - elsif hash.key?("start")==true
2742 - if hash.key?("end")==false && hash.key?("stride")==false
2743 - if self.vartype == "char"
2744 - put_vars_char(var,hash["start"],nil,nil)
2745 - elsif self.vartype=="byte"
2746 - put_vars_byte(var,hash["start"],nil,nil)
2747 - elsif self.vartype=="sint"
2748 - put_vars_sint(var,hash["start"],nil,nil)
2749 - elsif self.vartype=="int"
2750 - put_vars_int(var,hash["start"],nil,nil)
2751 - elsif self.vartype=="sfloat"
2752 - put_vars_sfloat(var,hash["start"],nil,nil)
2753 - elsif self.vartype=="float"
2754 - put_vars_float(var,hash["start"],nil,nil)
2755 - else
2756 - raise NetcdfError, "variable type isn't supported in netCDF"
2757 - end
2758 - elsif hash.key?("end")==true && hash.key?("stride") == false
2759 - if self.vartype == "char"
2760 - put_vars_char(var,hash["start"],hash["end"],nil)
2761 - elsif self.vartype=="byte"
2762 - put_vars_byte(var,hash["start"],hash["end"],nil)
2763 - elsif self.vartype=="sint"
2764 - put_vars_sint(var,hash["start"],hash["end"],nil)
2765 - elsif self.vartype=="int"
2766 - put_vars_int(var,hash["start"],hash["end"],nil)
2767 - elsif self.vartype == "sfloat"
2768 - put_vars_sfloat(var,hash["start"],hash["end"],nil)
2769 - elsif self.vartype =="float"
2770 - put_vars_float(var,hash["start"],hash["end"],nil)
2771 - else
2772 - raise NetcdfError, "variable type isn't supported in netCDF"
2773 - end
2774 - elsif hash.key?("end")==false && hash.key?("stride")==true
2775 - if self.vartype == "char"
2776 - put_vars_char(var,hash["start"],nil,hash["stride"])
2777 - elsif self.vartype=="byte"
2778 - put_vars_byte(var,hash["start"],nil,hash["stride"])
2779 - elsif self.vartype=="sint"
2780 - put_vars_sint(var,hash["start"],nil,hash["stride"])
2781 - elsif self.vartype=="int"
2782 - put_vars_int(var,hash["start"],nil,hash["stride"])
2783 - elsif self.vartype=="sfloat"
2784 - put_vars_sfloat(var,hash["start"],nil,hash["stride"])
2785 - elsif self.vartype=="float"
2786 - put_vars_float(var,hash["start"],nil,hash["stride"])
2787 - else
2788 - raise NetcdfError, "variable type isn't supported in netCDF"
2789 - end
2790 - else hash.key?("end")==true && hash.key?("stride")==true
2791 - if self.vartype == "char"
2792 - put_vars_char(var,hash["start"],hash["end"],hash["stride"])
2793 - elsif self.vartype=="byte"
2794 - put_vars_byte(var,hash["start"],hash["end"],hash["stride"])
2795 - elsif self.vartype=="sint"
2796 - put_vars_sint(var,hash["start"],hash["end"],hash["stride"])
2797 - elsif self.vartype=="int"
2798 - put_vars_int(var,hash["start"],hash["end"],hash["stride"])
2799 - elsif self.vartype=="sfloat"
2800 - put_vars_sfloat(var,hash["start"],hash["end"],hash["stride"])
2801 - elsif self.vartype=="float"
2802 - put_vars_float(var,hash["start"],hash["end"],hash["stride"])
2803 - else
2804 - raise NetcdfError, "variable type isn't supported in netCDF"
2805 - end
2806 - end
2807 - else
2808 - raise ArgumentError,"{'start'}=>[ARRAY] or {'index'}=>[ARRAY] is needed"
2809 - end
2810 - end
2811 -
2812 - alias put simple_put
2813 -
2814 - def simple_get(hash=nil)
2815 - t_var = self.vartype
2816 - if hash == nil
2817 - if t_var == "char"
2818 - get_var_char
2819 - elsif t_var == "byte"
2820 - get_var_byte
2821 - elsif t_var == "sint"
2822 - get_var_sint
2823 - elsif t_var == "int"
2824 - get_var_int
2825 - elsif t_var == "sfloat"
2826 - get_var_sfloat
2827 - elsif t_var == "float"
2828 - get_var_float
2829 - else
2830 - raise NetcdfError, "variable type #{t_var} isn't supported in netCDF"
2831 - end
2832 - elsif hash.key?("index")==true
2833 - ind = hash["index"]
2834 - if t_var == "char"
2835 - get_var1_char(ind)
2836 - elsif t_var == "byte"
2837 - get_var1_byte(ind)
2838 - elsif t_var == "sint"
2839 - get_var1_sint(ind)
2840 - elsif t_var == "int"
2841 - get_var1_int(ind)
2842 - elsif t_var == "sfloat"
2843 - get_var1_sfloat(ind)
2844 - elsif t_var == "float"
2845 - get_var1_float(ind)
2846 - else
2847 - raise NetcdfError,"variable type #{t_var} isn't supported in netCDF"
2848 - end
2849 - elsif hash.key?("start")==true
2850 - h_sta = hash["start"]
2851 - h_end = hash["end"] # can be nill
2852 - h_str = hash["stride"] # can be nill
2853 - if NetCDF.nc4? && h_str && ((xstr=h_str[0]) != 1)
2854 - # Tentative treatment for the very slow netcdf-4 reading with step.
2855 - # Reading with step is generally slow with NetCDF 4, but it is
2856 - # particularly so for the first dimension.
2857 - # Ref: http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2013/msg00311.html
2858 - h_str[0] = 1
2859 - nc4remedy = true
2860 - else
2861 - nc4remedy = false
2862 - end
2863 - if t_var == "char"
2864 - v = get_vars_char(h_sta,h_end,h_str)
2865 - elsif t_var == "byte"
2866 - v = get_vars_byte(h_sta,h_end,h_str)
2867 - elsif t_var == "sint"
2868 - v = get_vars_sint(h_sta,h_end,h_str)
2869 - elsif t_var == "int"
2870 - v = get_vars_int(h_sta,h_end,h_str)
2871 - elsif t_var == "sfloat"
2872 - v = get_vars_sfloat(h_sta,h_end,h_str)
2873 - elsif t_var == "float"
2874 - v = get_vars_float(h_sta,h_end,h_str)
2875 - else
2876 - raise NetcdfError, "variable type #{t_var} isn't supported in netCDF"
2877 - end
2878 - if nc4remedy
2879 - idx = []
2880 - (0...v.shape[0]).step(xstr){|k| idx.push(k)}
2881 - v = v[idx,false]
2882 - end
2883 - v
2884 - else
2885 - raise ArgumentError,"{'start'}=>{ARRAY} or {'index'}=>{ARRAY} is needed"
2886 - end
2887 - end
2888 -
2889 - alias get simple_get
2890 -
2891 - def __rubber_expansion( args )
2892 - if (id = args.index(false)) # substitution into id
2893 - # false is incuded
2894 - alen = args.length
2895 - if args.rindex(false) != id
2896 - raise ArguemntError,"only one rubber dimension is permitted"
2897 - elsif alen > rank+1
2898 - raise ArgumentError, "too many args"
2899 - end
2900 - ar = ( id!=0 ? args[0..id-1] : [] )
2901 - args = ar + [true]*(rank-alen+1) + args[id+1..-1]
2902 - elsif args.length == 0 # to support empty [], []=
2903 - args = [true]*rank
2904 - end
2905 - args
2906 - end
2907 - private :__rubber_expansion
2908 -
2909 - def [](*a)
2910 - if a.length == 0
2911 - return self.get
2912 - end
2913 - a = __rubber_expansion(a)
2914 - first = Array.new
2915 - last = Array.new
2916 - stride = Array.new
2917 - set_stride = false
2918 - a.each{|i|
2919 - if(i.is_a?(Fixnum))
2920 - first.push(i)
2921 - last.push(i)
2922 - stride.push(1)
2923 - elsif(i.is_a?(Range))
2924 - first.push(i.first)
2925 - last.push(i.exclude_end? ? i.last-1 : i.last)
2926 - stride.push(1)
2927 - elsif(i.is_a?(Hash))
2928 - r = (i.to_a[0])[0]
2929 - s = (i.to_a[0])[1]
2930 - if ( !( r.is_a?(Range) ) || ! ( s.is_a?(Integer) ) )
2931 - raise TypeError, "Hash argument must be {a_Range, step}"
2932 - end
2933 - first.push(r.first)
2934 - last.push(r.exclude_end? ? r.last-1 : r.last)
2935 - stride.push(s)
2936 - set_stride = true
2937 - elsif(i.is_a?(TrueClass))
2938 - first.push(0)
2939 - last.push(-1)
2940 - stride.push(1)
2941 - elsif( i.is_a?(Array) || i.is_a?(NArray))
2942 - a_new = a.dup
2943 - at = a.index(i)
2944 - i = NArray.to_na(i) if i.is_a?(Array)
2945 - for n in 0..i.length-1
2946 - a_new[at] = i[n]..i[n]
2947 - na_tmp = self[*a_new]
2948 - if n==0 then
2949 - k = at
2950 - if at > 0
2951 - a[0..at-1].each{|x| if x.is_a?(Fixnum) then k -= 1 end}
2952 - end
2953 - shape_tmp = na_tmp.shape
2954 - shape_tmp[k] = i.length
2955 - na = na_tmp.class.new(na_tmp.typecode,*shape_tmp)
2956 - index_tmp = Array.new(shape_tmp.length,true)
2957 - end
2958 - index_tmp[k] = n..n
2959 - na[*index_tmp] = na_tmp
2960 - end
2961 - return na
2962 - else
2963 - raise TypeError, "argument must be Fixnum, Range, Hash, TrueClass, Array, or NArray"
2964 - end
2965 - }
2966 -
2967 - if(set_stride)
2968 - na = self.get({"start"=>first, "end"=>last, "stride"=>stride})
2969 - else
2970 - na = self.get({"start"=>first, "end"=>last})
2971 - end
2972 - shape = na.shape
2973 - (a.length-1).downto(0){ |i|
2974 - shape.delete_at(i) if a[i].is_a?(Fixnum)
2975 + end
2976 +
2977 + # The put and get methods in the NetCDFVar class
2978 +
2979 + def pack(na)
2980 + sf = att('scale_factor')
2981 + ao = att('add_offset')
2982 + if ( sf == nil && ao == nil ) then
2983 + na
2984 + else
2985 + na = NArray.to_na(na) if na.is_a?(Array)
2986 + if sf
2987 + csf = sf.get
2988 + raise NetcdfError,"scale_factor is not a numeric" if csf.is_a?(String)
2989 + raise NetcdfError, "scale_factor is not unique" if csf.length != 1
2990 + raise NetcdfError, "zero scale_factor" if csf[0] == 0
2991 + else
2992 + csf = nil
2993 + end
2994 + if ao
2995 + cao = ao.get
2996 + raise NetcdfError, "add_offset is not a numeric" if cao.is_a?(String)
2997 + raise NetcdfError, "add_offset is not unique" if cao.length != 1
2998 + else
2999 + cao = nil
3000 + end
3001 + if csf and cao
3002 + packed = (na - cao) / csf
3003 + elsif csf
3004 + packed = na / csf
3005 + elsif cao
3006 + packed = na - cao
3007 + end
3008 + if self.typecode <= NArray::LINT
3009 + packed = packed.round
3010 + end
3011 + packed
3012 + end
3013 + end
3014 +
3015 + def scaled_put(var,hash=nil)
3016 + simple_put( pack(var), hash)
3017 + end
3018 +
3019 + @@unpack_type = nil
3020 + class << NetCDFVar
3021 + def unpack_type
3022 + @@unpack_type
3023 + end
3024 + def unpack_type=(na_type)
3025 + if [NArray::BYTE, NArray::SINT, NArray::INT,
3026 + NArray::SFLOAT, NArray::FLOAT, nil].include?(na_type)
3027 + @@unpack_type = na_type
3028 + else
3029 + raise ArgumentError, "Arg must be one of NArray::BYTE, NArray::SINT, NArray::INT, NArray::SFLOAT, NArray::FLOAT"
3030 + end
3031 + end
3032 +
3033 + end
3034 +
3035 + def unpack(na)
3036 + sf = att('scale_factor')
3037 + ao = att('add_offset')
3038 + if ( sf == nil && ao == nil ) then
3039 + na
3040 + else
3041 + if sf
3042 + csf = sf.get
3043 + raise NetcdfError,"scale_factor is not a numeric" if csf.is_a?(String)
3044 + raise NetcdfError, "scale_factor is not unique" if csf.length != 1
3045 + raise NetcdfError, "zero scale_factor" if csf[0] == 0
3046 + else
3047 + csf =nil
3048 + end
3049 + if ao
3050 + cao = ao.get
3051 + raise NetcdfError, "add_offset is not a numeric" if cao.is_a?(String)
3052 + raise NetcdfError, "add_offset is not unique" if cao.length != 1
3053 + else
3054 + cao = nil
3055 + end
3056 + if csf and cao
3057 + una = na * csf + cao # csf & cao are NArray -> coerced to their types
3058 + elsif csf
3059 + una = na * csf
3060 + elsif cao
3061 + una = na + cao
3062 + end
3063 + una = una.to_type(@@unpack_type) if @@unpack_type
3064 + una
3065 + end
3066 + end
3067 +
3068 + def scaled_get(hash=nil)
3069 + unpack( simple_get(hash) )
3070 + end
3071 +
3072 + def simple_put(var,hash=nil)
3073 + if hash==nil
3074 + if self.vartype == "char"
3075 + put_var_char(var)
3076 + elsif self.vartype == "byte"
3077 + put_var_byte(var)
3078 + elsif self.vartype == "sint"
3079 + put_var_sint(var)
3080 + elsif self.vartype == "int"
3081 + put_var_int(var)
3082 + elsif self.vartype == "sfloat"
3083 + put_var_sfloat(var)
3084 + elsif self.vartype == "float"
3085 + put_var_float(var)
3086 + else
3087 + raise NetcdfError,"variable type isn't supported in netCDF"
3088 + end
3089 + elsif hash.key?("index")==true
3090 + if self.vartype == "char"
3091 + put_var1_char(var,hash["index"])
3092 + elsif self.vartype=="byte"
3093 + put_var1_byte(var,hash["index"])
3094 + elsif self.vartype=="sint"
3095 + put_var1_sint(var,hash["index"])
3096 + elsif self.vartype == "int"
3097 + put_var1_int(var,hash["index"])
3098 + elsif self.vartype == "sfloat"
3099 + put_var1_sfloat(var,hash["index"])
3100 + elsif self.vartype == "float"
3101 + put_var1_float(var,hash["index"])
3102 + else
3103 + raise NetcdfError,"variable type isn't supported in netCDF"
3104 + end
3105 + elsif hash.key?("start")==true
3106 + if hash.key?("end")==false && hash.key?("stride")==false
3107 + if self.vartype == "char"
3108 + put_vars_char(var,hash["start"],nil,nil)
3109 + elsif self.vartype=="byte"
3110 + put_vars_byte(var,hash["start"],nil,nil)
3111 + elsif self.vartype=="sint"
3112 + put_vars_sint(var,hash["start"],nil,nil)
3113 + elsif self.vartype=="int"
3114 + put_vars_int(var,hash["start"],nil,nil)
3115 + elsif self.vartype=="sfloat"
3116 + put_vars_sfloat(var,hash["start"],nil,nil)
3117 + elsif self.vartype=="float"
3118 + put_vars_float(var,hash["start"],nil,nil)
3119 + else
3120 + raise NetcdfError, "variable type isn't supported in netCDF"
3121 + end
3122 + elsif hash.key?("end")==true && hash.key?("stride") == false
3123 + if self.vartype == "char"
3124 + put_vars_char(var,hash["start"],hash["end"],nil)
3125 + elsif self.vartype=="byte"
3126 + put_vars_byte(var,hash["start"],hash["end"],nil)
3127 + elsif self.vartype=="sint"
3128 + put_vars_sint(var,hash["start"],hash["end"],nil)
3129 + elsif self.vartype=="int"
3130 + put_vars_int(var,hash["start"],hash["end"],nil)
3131 + elsif self.vartype == "sfloat"
3132 + put_vars_sfloat(var,hash["start"],hash["end"],nil)
3133 + elsif self.vartype =="float"
3134 + put_vars_float(var,hash["start"],hash["end"],nil)
3135 + else
3136 + raise NetcdfError, "variable type isn't supported in netCDF"
3137 + end
3138 + elsif hash.key?("end")==false && hash.key?("stride")==true
3139 + if self.vartype == "char"
3140 + put_vars_char(var,hash["start"],nil,hash["stride"])
3141 + elsif self.vartype=="byte"
3142 + put_vars_byte(var,hash["start"],nil,hash["stride"])
3143 + elsif self.vartype=="sint"
3144 + put_vars_sint(var,hash["start"],nil,hash["stride"])
3145 + elsif self.vartype=="int"
3146 + put_vars_int(var,hash["start"],nil,hash["stride"])
3147 + elsif self.vartype=="sfloat"
3148 + put_vars_sfloat(var,hash["start"],nil,hash["stride"])
3149 + elsif self.vartype=="float"
3150 + put_vars_float(var,hash["start"],nil,hash["stride"])
3151 + else
3152 + raise NetcdfError, "variable type isn't supported in netCDF"
3153 + end
3154 + else hash.key?("end")==true && hash.key?("stride")==true
3155 + if self.vartype == "char"
3156 + put_vars_char(var,hash["start"],hash["end"],hash["stride"])
3157 + elsif self.vartype=="byte"
3158 + put_vars_byte(var,hash["start"],hash["end"],hash["stride"])
3159 + elsif self.vartype=="sint"
3160 + put_vars_sint(var,hash["start"],hash["end"],hash["stride"])
3161 + elsif self.vartype=="int"
3162 + put_vars_int(var,hash["start"],hash["end"],hash["stride"])
3163 + elsif self.vartype=="sfloat"
3164 + put_vars_sfloat(var,hash["start"],hash["end"],hash["stride"])
3165 + elsif self.vartype=="float"
3166 + put_vars_float(var,hash["start"],hash["end"],hash["stride"])
3167 + else
3168 + raise NetcdfError, "variable type isn't supported in netCDF"
3169 + end
3170 + end
3171 + else
3172 + raise ArgumentError,"{'start'}=>[ARRAY] or {'index'}=>[ARRAY] is needed"
3173 + end
3174 + end
3175 +
3176 + alias put simple_put
3177 +
3178 + def simple_get(hash=nil)
3179 + t_var = self.vartype
3180 + if hash == nil
3181 + if t_var == "char"
3182 + get_var_char
3183 + elsif t_var == "byte"
3184 + get_var_byte
3185 + elsif t_var == "sint"
3186 + get_var_sint
3187 + elsif t_var == "int"
3188 + get_var_int
3189 + elsif t_var == "sfloat"
3190 + get_var_sfloat
3191 + elsif t_var == "float"
3192 + get_var_float
3193 + else
3194 + raise NetcdfError, "variable type #{t_var} isn't supported in netCDF"
3195 + end
3196 + elsif hash.key?("index")==true
3197 + ind = hash["index"]
3198 + if t_var == "char"
3199 + get_var1_char(ind)
3200 + elsif t_var == "byte"
3201 + get_var1_byte(ind)
3202 + elsif t_var == "sint"
3203 + get_var1_sint(ind)
3204 + elsif t_var == "int"
3205 + get_var1_int(ind)
3206 + elsif t_var == "sfloat"
3207 + get_var1_sfloat(ind)
3208 + elsif t_var == "float"
3209 + get_var1_float(ind)
3210 + else
3211 + raise NetcdfError,"variable type #{t_var} isn't supported in netCDF"
3212 + end
3213 + elsif hash.key?("start")==true
3214 + h_sta = hash["start"]
3215 + h_end = hash["end"] # can be nill
3216 + h_str = hash["stride"] # can be nill
3217 + if NetCDF.nc4? && h_str && ((xstr=h_str[0]) != 1)
3218 + # Tentative treatment for the very slow netcdf-4 reading with step.
3219 + # Reading with step is generally slow with NetCDF 4, but it is
3220 + # particularly so for the first dimension.
3221 + # Ref: http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2013/msg00311.html
3222 + h_str[0] = 1
3223 + nc4remedy = true
3224 + else
3225 + nc4remedy = false
3226 + end
3227 + if t_var == "char"
3228 + v = get_vars_char(h_sta,h_end,h_str)
3229 + elsif t_var == "byte"
3230 + v = get_vars_byte(h_sta,h_end,h_str)
3231 + elsif t_var == "sint"
3232 + v = get_vars_sint(h_sta,h_end,h_str)
3233 + elsif t_var == "int"
3234 + v = get_vars_int(h_sta,h_end,h_str)
3235 + elsif t_var == "sfloat"
3236 + v = get_vars_sfloat(h_sta,h_end,h_str)
3237 + elsif t_var == "float"
3238 + v = get_vars_float(h_sta,h_end,h_str)
3239 + else
3240 + raise NetcdfError, "variable type #{t_var} isn't supported in netCDF"
3241 + end
3242 + if nc4remedy
3243 + idx = []
3244 + (0...v.shape[0]).step(xstr){|k| idx.push(k)}
3245 + v = v[idx,false]
3246 + end
3247 + v
3248 + else
3249 + raise ArgumentError,"{'start'}=>{ARRAY} or {'index'}=>{ARRAY} is needed"
3250 + end
3251 + end
3252 +
3253 + alias get simple_get
3254 +
3255 + def __rubber_expansion( args )
3256 + if (id = args.index(false)) # substitution into id
3257 + # false is incuded
3258 + alen = args.length
3259 + if args.rindex(false) != id
3260 + raise ArguemntError,"only one rubber dimension is permitted"
3261 + elsif alen > rank+1
3262 + raise ArgumentError, "too many args"
3263 + end
3264 + ar = ( id!=0 ? args[0..id-1] : [] )
3265 + args = ar + [true]*(rank-alen+1) + args[id+1..-1]
3266 + elsif args.length == 0 # to support empty [], []=
3267 + args = [true]*rank
3268 + end
3269 + args
3270 + end
3271 + private :__rubber_expansion
3272 +
3273 + def [](*a)
3274 + if a.length == 0
3275 + return self.get
3276 + end
3277 + a = __rubber_expansion(a)
3278 + first = Array.new
3279 + last = Array.new
3280 + stride = Array.new
3281 + set_stride = false
3282 + a.each{|i|
3283 + if(i.is_a?(Integer))
3284 + first.push(i)
3285 + last.push(i)
3286 + stride.push(1)
3287 + elsif(i.is_a?(Range))
3288 + first.push(i.first)
3289 + last.push(i.exclude_end? ? i.last-1 : i.last)
3290 + stride.push(1)
3291 + elsif(i.is_a?(Hash))
3292 + r = (i.to_a[0])[0]
3293 + s = (i.to_a[0])[1]
3294 + if ( !( r.is_a?(Range) ) || ! ( s.is_a?(Integer) ) )
3295 + raise TypeError, "Hash argument must be {a_Range, step}"
3296 + end
3297 + first.push(r.first)
3298 + last.push(r.exclude_end? ? r.last-1 : r.last)
3299 + stride.push(s)
3300 + set_stride = true
3301 + elsif(i.is_a?(TrueClass))
3302 + first.push(0)
3303 + last.push(-1)
3304 + stride.push(1)
3305 + elsif( i.is_a?(Array) || i.is_a?(NArray))
3306 + a_new = a.dup
3307 + at = a.index(i)
3308 + i = NArray.to_na(i) if i.is_a?(Array)
3309 + for n in 0..i.length-1
3310 + a_new[at] = i[n]..i[n]
3311 + na_tmp = self[*a_new]
3312 + if n==0 then
3313 + k = at
3314 + if at > 0
3315 + a[0..at-1].each{|x| if x.is_a?(Integer) then k -= 1 end}
3316 + end
3317 + shape_tmp = na_tmp.shape
3318 + shape_tmp[k] = i.length
3319 + na = na_tmp.class.new(na_tmp.typecode,*shape_tmp)
3320 + index_tmp = Array.new(shape_tmp.length,true)
3321 + end
3322 + index_tmp[k] = n..n
3323 + na[*index_tmp] = na_tmp
3324 + end
3325 + return na
3326 + else
3327 + raise TypeError, "argument must be Integer, Range, Hash, TrueClass, Array, or NArray"
3328 + end
3329 + }
3330 +
3331 + if(set_stride)
3332 + na = self.get({"start"=>first, "end"=>last, "stride"=>stride})
3333 + else
3334 + na = self.get({"start"=>first, "end"=>last})
3335 + end
3336 + shape = na.shape
3337 + (a.length-1).downto(0){ |i|
3338 + shape.delete_at(i) if a[i].is_a?(Integer)
3339 }
3340 na.reshape!( *shape )
3341 - na
3342 - end
3343 -
3344 - def []=(*a)
3345 - val = a.pop
3346 - a = __rubber_expansion(a)
3347 - first = Array.new
3348 - last = Array.new
3349 - stride = Array.new
3350 - set_stride = false
3351 - a.each{|i|
3352 - if(i.is_a?(Fixnum))
3353 - first.push(i)
3354 - last.push(i)
3355 - stride.push(1)
3356 - elsif(i.is_a?(Range))
3357 - first.push(i.first)
3358 - last.push(i.exclude_end? ? i.last-1 : i.last)
3359 - stride.push(1)
3360 - elsif(i.is_a?(Hash))
3361 - r = (i.to_a[0])[0]
3362 - s = (i.to_a[0])[1]
3363 - if ( !( r.is_a?(Range) ) || ! ( s.is_a?(Integer) ) )
3364 - raise ArgumentError, "Hash argument must be {first..last, step}"
3365 - end
3366 - first.push(r.first)
3367 - last.push(r.exclude_end? ? r.last-1 : r.last)
3368 - stride.push(s)
3369 - set_stride = true
3370 - elsif(i.is_a?(TrueClass))
3371 - first.push(0)
3372 - last.push(-1)
3373 - stride.push(1)
3374 - elsif(i.is_a?(Array) || i.is_a?(NArray))
3375 - a_new = a.dup
3376 - at = a.index(i)
3377 - i = NArray.to_na(i) if i.is_a?(Array)
3378 - val = NArray.to_na(val) if val.is_a?(Array)
3379 - rank_of_subset = a.dup.delete_if{|v| v.is_a?(Fixnum)}.length
3380 - if val.rank != rank_of_subset
3381 - raise "rank of the rhs (#{val.rank}) is not equal to the rank "+
3382 - "of the subset specified by #{a.inspect} (#{rank_of_subset})"
3383 - end
3384 - k = at
3385 - a[0..at-1].each{|x| if x.is_a?(Fixnum) then k -= 1 end}
3386 - if i.length != val.shape[k]
3387 - raise "length of the #{k+1}-th dim of rhs is incorrect "+
3388 - "(#{i.length} for #{val.shape[k]})"
3389 - end
3390 - index_tmp = Array.new(val.rank,true) if !val.is_a?(Numeric) #==>Array-like
3391 - for n in 0..i.length-1
3392 - a_new[at] = i[n]..i[n]
3393 - if !val.is_a?(Numeric) then
3394 - index_tmp[k] = n..n
3395 - self[*a_new] = val[*index_tmp]
3396 - else
3397 - self[*a_new] = val
3398 - end
3399 - end
3400 - return self
3401 - else
3402 - raise TypeError, "argument must be Fixnum, Range, Hash, TrueClass, Array, or NArray"
3403 - end
3404 - }
3405 -
3406 - if(set_stride)
3407 - self.put(val, {"start"=>first, "end"=>last, "stride"=>stride})
3408 - else
3409 - self.put(val, {"start"=>first, "end"=>last})
3410 - end
3411 - end
3412 -
3413 - def inspect
3414 - 'NetCDFVar:'+file.path+'?var='+name
3415 - end
3416 -
3417 - end
3418 -
3419 - class NetCDFAtt
3420 -
3421 - def put(val,atttype=nil)
3422 + na
3423 + end
3424 +
3425 + def []=(*a)
3426 + val = a.pop
3427 + a = __rubber_expansion(a)
3428 + first = Array.new
3429 + last = Array.new
3430 + stride = Array.new
3431 + set_stride = false
3432 + a.each{|i|
3433 + if(i.is_a?(Integer))
3434 + first.push(i)
3435 + last.push(i)
3436 + stride.push(1)
3437 + elsif(i.is_a?(Range))
3438 + first.push(i.first)
3439 + last.push(i.exclude_end? ? i.last-1 : i.last)
3440 + stride.push(1)
3441 + elsif(i.is_a?(Hash))
3442 + r = (i.to_a[0])[0]
3443 + s = (i.to_a[0])[1]
3444 + if ( !( r.is_a?(Range) ) || ! ( s.is_a?(Integer) ) )
3445 + raise ArgumentError, "Hash argument must be {first..last, step}"
3446 + end
3447 + first.push(r.first)
3448 + last.push(r.exclude_end? ? r.last-1 : r.last)
3449 + stride.push(s)
3450 + set_stride = true
3451 + elsif(i.is_a?(TrueClass))
3452 + first.push(0)
3453 + last.push(-1)
3454 + stride.push(1)
3455 + elsif(i.is_a?(Array) || i.is_a?(NArray))
3456 + a_new = a.dup
3457 + at = a.index(i)
3458 + i = NArray.to_na(i) if i.is_a?(Array)
3459 + val = NArray.to_na(val) if val.is_a?(Array)
3460 + rank_of_subset = a.dup.delete_if{|v| v.is_a?(Integer)}.length
3461 + if val.rank != rank_of_subset
3462 + raise "rank of the rhs (#{val.rank}) is not equal to the rank "+
3463 + "of the subset specified by #{a.inspect} (#{rank_of_subset})"
3464 + end
3465 + k = at
3466 + a[0..at-1].each{|x| if x.is_a?(Integer) then k -= 1 end}
3467 + if i.length != val.shape[k]
3468 + raise "length of the #{k+1}-th dim of rhs is incorrect "+
3469 + "(#{i.length} for #{val.shape[k]})"
3470 + end
3471 + index_tmp = Array.new(val.rank,true) if !val.is_a?(Numeric) #==>Array-like
3472 + for n in 0..i.length-1
3473 + a_new[at] = i[n]..i[n]
3474 + if !val.is_a?(Numeric) then
3475 + index_tmp[k] = n..n
3476 + self[*a_new] = val[*index_tmp]
3477 + else
3478 + self[*a_new] = val
3479 + end
3480 + end
3481 + return self
3482 + else
3483 + raise TypeError, "argument must be Integer, Range, Hash, TrueClass, Array, or NArray"
3484 + end
3485 + }
3486 +
3487 + if(set_stride)
3488 + self.put(val, {"start"=>first, "end"=>last, "stride"=>stride})
3489 + else
3490 + self.put(val, {"start"=>first, "end"=>last})
3491 + end
3492 + end
3493 +
3494 + def inspect
3495 + 'NetCDFVar:'+file.path+'?var='+name
3496 + end
3497 +
3498 + end
3499 +
3500 + class NetCDFAtt
3501 +
3502 + def put(val,atttype=nil)
3503 putraw(val,atttype)
3504 - end
3505 -
3506 - def inspect
3507 - 'NetCDFAtt:'+name
3508 - end
3509 - end
3510 -
3511 - class NetCDFDim
3512 - def inspect
3513 - 'NetCDFDim:'+name
3514 - end
3515 -
3516 - def length_ul0
3517 + end
3518 +
3519 + def inspect
3520 + 'NetCDFAtt:'+name
3521 + end
3522 + end
3523 +
3524 + class NetCDFDim
3525 + def inspect
3526 + 'NetCDFDim:'+name
3527 + end
3528 +
3529 + def length_ul0
3530 if unlimited?
3531 - 0
3532 + 0
3533 else
3534 - length
3535 + length
3536 end
3537 - end
3538 + end
3539
3540 - end
3541 + end
3542 end
0 From: Bas Couwenberg <sebastic@debian.org>
1 Date: Fri, 22 May 2020 23:15:50 +0900
2 Subject: Fix 'lengh' spelling error, replace with 'length'.
3
4 ---
5 ext/numru/netcdfraw.c | 10 +++++-----
6 1 file changed, 5 insertions(+), 5 deletions(-)
7
8 diff --git a/ext/numru/netcdfraw.c b/ext/numru/netcdfraw.c
9 index 783d087..b3fdf77 100644
10 --- a/ext/numru/netcdfraw.c
11 +++ b/ext/numru/netcdfraw.c
12 @@ -4008,7 +4008,7 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
13 for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
14 } else if(len != c_count_all) {
15 rb_raise(rb_eNetcdfError,
16 - "lengh of the array does not agree with that of the subset\n");
17 + "length of the array does not agree with that of the subset\n");
18 }
19 }
20
21 @@ -4114,7 +4114,7 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
22 for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
23 } else if(len != c_count_all) {
24 rb_raise(rb_eNetcdfError,
25 - "lengh of the array does not agree with that of the subset\n");
26 + "length of the array does not agree with that of the subset\n");
27 }
28 }
29
30 @@ -4220,7 +4220,7 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
31 for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
32 } else if(len != c_count_all) {
33 rb_raise(rb_eNetcdfError,
34 - "lengh of the array does not agree with that of the subset\n");
35 + "length of the array does not agree with that of the subset\n");
36 }
37 }
38
39 @@ -4434,7 +4434,7 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
40 for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
41 } else if(len != c_count_all) {
42 rb_raise(rb_eNetcdfError,
43 - "lengh of the array does not agree with that of the subset\n");
44 + "length of the array does not agree with that of the subset\n");
45 }
46 }
47
48 @@ -4541,7 +4541,7 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
49 for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
50 } else if(len != c_count_all) {
51 rb_raise(rb_eNetcdfError,
52 - "lengh of the array does not agree with that of the subset\n");
53 + "length of the array does not agree with that of the subset\n");
54 }
55 }
56
0 From: Youhei SASAKI <uwabami@gfd-dennou.org>
1 Date: Fri, 22 May 2020 23:21:51 +0900
2 Subject: upstream import: Rewrite test: use Test::Unit
3
4 Signed-off-by: Youhei SASAKI <uwabami@gfd-dennou.org>
5 ---
6 ruby-netcdf-bigmem.gemspec | 1 +
7 ruby-netcdf.gemspec | 1 +
8 test/aref_aset.rb | 96 +++++++----
9 test/char_var.rb | 53 ++++---
10 test/clone.rb | 97 ++++++------
11 test/create_tmp.rb | 30 ++--
12 test/def_var_with_dim.rb | 40 +++--
13 test/factor_offset.rb | 123 ++++++++------
14 test/putatt.rb | 120 ++++++++------
15 test/test.rb | 387 +++++++++++++++++++++++----------------------
16 test/type.rb | 38 +++--
17 11 files changed, 561 insertions(+), 425 deletions(-)
18
19 diff --git a/ruby-netcdf-bigmem.gemspec b/ruby-netcdf-bigmem.gemspec
20 index ec7076d..48ff380 100644
21 --- a/ruby-netcdf-bigmem.gemspec
22 +++ b/ruby-netcdf-bigmem.gemspec
23 @@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
24 spec.required_ruby_version = Gem::Requirement.new(">= 1.8")
25 spec.add_runtime_dependency(%q<narray-bigmem>, [">= 0"])
26 spec.add_runtime_dependency(%q<narray_miss-bigmem>, [">= 0"])
27 + spec.add_development_dependency "test-unit"
28
29 end
30 diff --git a/ruby-netcdf.gemspec b/ruby-netcdf.gemspec
31 index c2f94d6..1ec67bd 100644
32 --- a/ruby-netcdf.gemspec
33 +++ b/ruby-netcdf.gemspec
34 @@ -24,5 +24,6 @@ Gem::Specification.new do |spec|
35 spec.required_ruby_version = Gem::Requirement.new(">= 1.8")
36 spec.add_runtime_dependency(%q<narray>, [">= 0"])
37 spec.add_runtime_dependency(%q<narray_miss>, [">= 0"])
38 + spec.add_development_dependency "test-unit"
39
40 end
41 diff --git a/test/aref_aset.rb b/test/aref_aset.rb
42 index 4ba3456..5d23982 100644
43 --- a/test/aref_aset.rb
44 +++ b/test/aref_aset.rb
45 @@ -1,37 +1,67 @@
46 +require 'test/unit'
47 require 'numru/netcdf'
48 include NumRu
49 -s = 'tmp.nc'
50 -f = NetCDF.create(s)
51 -f.redef
52 -dx = f.def_dim('x',5)
53 -dy = f.def_dim('y',3)
54 -v = f.def_var('x','sfloat',[dx])
55 -v2 = f.def_var('x2',NArray::SFLOAT,[dx])
56 -vxy = f.def_var('xy','sfloat',[dx,dy])
57 -f.enddef
58 -v.put([1,2,3,4,5])
59 -p 'testing []= ...'
60 -v[{0..3=>2}]=[100,500]
61 -v[1]=999
62 -v[3..4]=[-99,-99]
63 -v2.put(666)
64 -v2[0..2]=777
65 -vxy.put(NArray.sfloat(5,3).indgen!)
66 -vxy[[2,0],[0,2,1]] = [[1,2],[3,4],[5,6]]
67 -vxy[1,[2,0,1]] = [10,20,30]
68 -vxy[[4,3],2] = [100,200]
69
70 -f.close
71 +class TestArefAset < Test::Unit::TestCase
72 + def startup # call once before tests
73 + end
74 + def setup # call before each test
75 + @s = 'tmp.nc'
76 + end
77 + def teardown # call after each test
78 + end
79 + def shutdown # call once after tests
80 + end
81
82 -f = NetCDF.open(s)
83 -v = f.var('x')
84 -p 'testing [] ...'
85 -p '*0*',v[{0..3=>2}]
86 -p '*1*',v[1]
87 -p '*2*',v[3..4],v.rank
88 -p '*3*',v[[2,0,0]]
89 -vxy = f.var('xy')
90 -p '*4*',vxy[[2,0],[0,2,1]]
91 -p '*5*',vxy[1,[2,0,1]]
92 -p '*6*',vxy[[4,3],2]
93 -f.close
94 + def test_netcdf_create
95 + f = NetCDF.create(@s)
96 + f.redef
97 + dx = f.def_dim('x',5)
98 + dy = f.def_dim('y',3)
99 + v = f.def_var('x','sfloat',[dx])
100 + v2 = f.def_var('x2',NArray::SFLOAT,[dx])
101 + vxy = f.def_var('xy','sfloat',[dx,dy])
102 + f.enddef
103 + v.put([1,2,3,4,5])
104 + v[{0..3=>2}]=[100,500]
105 + v[1]=999
106 + v[3..4]=[-99,-99]
107 + v2.put(666)
108 + v2[0..2]=777
109 + vxy.put(NArray.sfloat(5,3).indgen!)
110 + vxy[[2,0],[0,2,1]] = [[1,2],[3,4],[5,6]]
111 + vxy[1,[2,0,1]] = [10,20,30]
112 + vxy[[4,3],2] = [100,200]
113 + f.close
114 + end
115 +
116 + def test_netcdf_open
117 + unless File.exist?(@s)
118 + test_netcdf_create
119 + else
120 + f = NetCDF.open(@s)
121 + v = f.var('x')
122 + assert_equal v[{0..3=>2}], NArray[100.0,500.0].to_f
123 + assert_equal v[1], NArray[999.0].to_f
124 + assert_equal v[3..4], NArray[-99.0,-99.0].to_f
125 + assert_equal v.rank, 1
126 + assert_equal v[[2,0,0]], NArray[500.0,100.0,100.0].to_f
127 + vxy = f.var('xy')
128 + assert_equal vxy[[2,0],[0,2,1]],
129 + NArray[[1.0,2.0],[3.0,4.0],[5.0,6.0]].to_f
130 + assert_equal vxy[1,[2,0,1]],
131 + NArray[10.0,20.0,30.0].to_f
132 + assert_equal vxy[[4,3],2],
133 + NArray[100.0,200.0].to_f
134 + f.close
135 + end
136 + if File.exist?(@s)
137 + begin
138 + File.delete(@s)
139 + rescue
140 + p $!
141 + end
142 + end
143 + end
144 +
145 +end
146 diff --git a/test/char_var.rb b/test/char_var.rb
147 index 2cceb8b..256ec33 100644
148 --- a/test/char_var.rb
149 +++ b/test/char_var.rb
150 @@ -1,25 +1,36 @@
151 -## test of "char" variables
152 -
153 +require 'test/unit'
154 require 'numru/netcdf'
155 include NumRu
156 -s = 'tmp.nc'
157 -f = NetCDF.create(s)
158 -d = f.def_dim('x',5)
159 -v = f.def_var('x','char',[d])
160 -tv = f.def_var('text','char',[d])
161 -f.enddef
162 -v.put( NArray.byte(5).indgen! )
163 -tv.put( NArray.to_na("hello","byte",5) )
164 -tv.put( NArray.to_na("LO","byte",2), 'start'=>[3] )
165 -tv.put( NArray.to_na("H","byte",1), 'index'=>[0] )
166 -f.close
167 -
168 -f = NetCDF.open(s)
169 -v = f.var('x')
170 -p v.get
171 -tv = f.var('text')
172 -p tv.get
173 -p tv.get.to_s
174 -
175 +class TestCharVar < Test::Unit::TestCase
176 + def setup
177 + @s = 'tmp.nc'
178 + f = NetCDF.create(@s)
179 + d = f.def_dim('x',5)
180 + v = f.def_var('x','char',[d])
181 + tv = f.def_var('text','char',[d])
182 + f.enddef
183 + v.put( NArray.byte(5).indgen! )
184 + tv.put( NArray.to_na("hello","byte",5) )
185 + tv.put( NArray.to_na("LO","byte",2), 'start'=>[3] )
186 + tv.put( NArray.to_na("H","byte",1), 'index'=>[0] )
187 + f.close
188 + end
189 + def teardown
190 + if File.exist?(@s)
191 + begin
192 + File.delete(@s)
193 + rescue
194 + p $!
195 + end
196 + end
197 + end
198
199 + def test_char_var
200 + f = NetCDF.open(@s)
201 + v = f.var('x')
202 + assert_equal v.get, NArray.byte(5).indgen!
203 + tv = f.var('text')
204 + assert_equal tv.get.to_s, "HelLO"
205 + end
206
207 +end
208 diff --git a/test/clone.rb b/test/clone.rb
209 index 744d7f8..e807361 100644
210 --- a/test/clone.rb
211 +++ b/test/clone.rb
212 @@ -1,54 +1,49 @@
213 +require 'test/unit'
214 require 'numru/netcdf'
215 include NumRu
216 -s = 'tmp.nc'
217 -#f = NetCDF.new(s,'rw')
218 -f = NetCDF.create(s)
219 -f.redef
220 -d = f.def_dim('x',3)
221 -v = f.def_var('x','sfloat',[d])
222 -a = f.put_att('long_name','xx')
223 -f.enddef
224 -v.put([1,2,3])
225 -f.taint
226 -f.freeze
227 -f2 = f.clone
228 -p 'netcdf clone'
229 -p f.path, f2.path
230 -p f.tainted?, f2.tainted?, f.frozen?, f2.frozen?
231 -
232 -p 'netcdf dup'
233 -f3 = f.dup
234 -p f.tainted?, f3.tainted?, f.frozen?, f3.frozen?
235 -
236 -p 'netcdfdim'
237 -d.taint
238 -d2 = d.clone
239 -d3 = d.dup
240 -p d.tainted?, d2.tainted?, d3.tainted?
241 -
242 -p 'netcdfvar'
243 -v.taint
244 -v2 = v.clone
245 -v3 = v.dup
246 -p v.tainted?, v2.tainted?, v3.tainted?
247 -
248 -p 'netcdfatt'
249 -a.taint
250 -a2 = a.clone
251 -a3 = a.dup
252 -p a.tainted?, a2.tainted?, a3.tainted?
253 -
254 -f.close
255 -
256 -p 'narray (for reference)'
257 -a = NArray.float(3)
258 -a.taint
259 -b = a.clone
260 -p a.tainted?, b.tainted?
261 -b = a.dup
262 -p a.tainted?, b.tainted?
263 -
264 -
265 -
266 -
267
268 +class TestClone < Test::Unit::TestCase
269 + def setup
270 + @s = 'tmp.nc'
271 + @f = NetCDF.create(@s)
272 + @f.redef
273 + @d = @f.def_dim('x',3)
274 + @v = @f.def_var('x','sfloat',[@d])
275 + @a = @f.put_att('long_name','xx')
276 + @f.enddef
277 + @v.put([1,2,3])
278 + @f.freeze
279 + end
280 +
281 + def teardown
282 + @f.close
283 + if File.exist?(@s)
284 + begin
285 + File.delete(@s)
286 + rescue
287 + p $!
288 + end
289 + end
290 + end
291 +
292 + def test_clone_netcdf_path
293 + f = @f.clone
294 + assert_equal @f.path, f.path
295 + assert(@f.frozen? == f.frozen?)
296 + d = @d.clone
297 + assert_equal @d, d
298 + v = @v.clone
299 + assert_equal @v, v
300 + a = @a.clone
301 + assert_equal @a, a
302 + end
303 +
304 + def test_clone_netcdf_dup
305 + f = @f.dup
306 + assert(@f.frozen? != f.frozen?)
307 + # d = @d.dup
308 + # v = @v.dup
309 + # a = @a.dup
310 + end
311 +
312 +end
313 diff --git a/test/create_tmp.rb b/test/create_tmp.rb
314 index e04a0dc..3fcc40a 100644
315 --- a/test/create_tmp.rb
316 +++ b/test/create_tmp.rb
317 @@ -1,15 +1,19 @@
318 +require 'test/unit'
319 require 'numru/netcdf'
320 -
321 -$DEBUG = true
322 include NumRu
323 -file = NetCDF.create_tmp
324 -file.def_dim('x',5)
325 -file.put_att("history", __FILE__ )
326 -p file.path
327 -p file.att("history").get
328 -print "environment variable TEMP ="+(ENV['TEMP'] || '')+"\n"
329 -file2=file
330 -print "000\n"
331 -file.close
332 -GC.start
333 -print "aaa\n"
334 +class CreateTMP < Test::Unit::TestCase
335 + def setup
336 + @file = NetCDF.create_tmp
337 + @file.def_dim('x',5)
338 + @file.put_att("history", __FILE__ )
339 + end
340 + def teardown
341 + @file.close
342 + GC.start
343 + end
344 + def test_create_tmp
345 + assert_equal @file.att("history").get, __FILE__
346 + # print "environment variable TEMP ="+(ENV['TEMP'] || '')+"\n"
347 + # file2 = @file
348 + end
349 +end
350 diff --git a/test/def_var_with_dim.rb b/test/def_var_with_dim.rb
351 index 32d9ab2..c0f25ff 100644
352 --- a/test/def_var_with_dim.rb
353 +++ b/test/def_var_with_dim.rb
354 @@ -1,14 +1,32 @@
355 +require 'test/unit'
356 require 'numru/netcdf'
357 include NumRu
358 -file = NetCDF.create("tmp.nc")
359 -var1 = file.def_var_with_dim("var1","sfloat",[6],["x"])
360 -var2 = file.def_var_with_dim("var2","sfloat",[6,3],["x","y"])
361 -var3 = file.def_var_with_dim("var3","sfloat",[3],["y"])
362 -var3 = file.def_var_with_dim("var4","sfloat",[0],["t"])
363 -att = var1.put_att("long_name","test")
364 -file.close
365 +class TestDefVarWithDim < Test::Unit::TestCase
366 + def setup
367 + @fname = "tmp.nc"
368 + @file = NetCDF.create(@fname)
369 + @var1 = @file.def_var_with_dim("var1","sfloat",[6],["x"])
370 + @var2 = @file.def_var_with_dim("var2","sfloat",[6,3],["x","y"])
371 + @var3 = @file.def_var_with_dim("var3","sfloat",[3],["y"])
372 + @var3 = @file.def_var_with_dim("var4","sfloat",[0],["t"])
373 + @att = @var1.put_att("long_name","test")
374 + @file.close
375 + end
376 + def teardown
377 + if File.exist?(@fname)
378 + begin
379 + File.delete(@fname)
380 + rescue
381 + p $!
382 + end
383 + end
384 + end
385
386 -p var1 == nil
387 -p file == nil
388 -p att == nil
389 -p att == att, var1 ==var1, file == file
390 + def test_def_var_with_dim
391 + assert_not_nil @var1
392 + assert_not_nil @var2
393 + assert_not_nil @var3
394 + assert_not_nil @file
395 + assert_not_nil @att
396 + end
397 +end
398 diff --git a/test/factor_offset.rb b/test/factor_offset.rb
399 index 3312327..99cd375 100644
400 --- a/test/factor_offset.rb
401 +++ b/test/factor_offset.rb
402 @@ -1,53 +1,84 @@
403 +require 'test/unit'
404 require 'numru/netcdf'
405 include NumRu
406
407 -s = 'tmp.nc'
408 -f = NetCDF.create(s)
409 +class TestFactorOffset < Test::Unit::TestCase
410 + def setup
411 + @s = 'tmp.nc'
412 + f = NetCDF.create(@s)
413 + nx = 10
414 + d = f.def_dim('x',nx)
415 + v1 = f.def_var('v1','sint',[d])
416 + v2 = f.def_var('v2','sint',[d])
417 + v3 = f.def_var('v3','int',[d])
418 + v1.put_att('scale_factor',0.1,'sfloat')
419 + v1.put_att('add_offset',100.0,'sfloat')
420 + v2.put_att('scale_factor',0.1,'sfloat')
421 + v2.put_att('add_offset',100.0,'sfloat')
422 + v3.put_att('scale_factor',0.1,'sfloat')
423 + v3.put_att('add_offset',100.0,'sfloat')
424 + f.enddef
425 + v1.put( NArray.sint(nx).indgen!+100 )
426 + v2.scaled_put( NArray.float(nx).indgen!+100 )
427 + v3.scaled_put( NArray.float(nx).indgen!+100 )
428 + f.close
429 + end
430
431 -nx = 10
432 -d = f.def_dim('x',nx)
433 -v1 = f.def_var('v1','sint',[d])
434 -v2 = f.def_var('v2','sint',[d])
435 -v3 = f.def_var('v3','int',[d])
436 -v1.put_att('scale_factor',0.1,'sfloat')
437 -v1.put_att('add_offset',100.0,'sfloat')
438 -v2.put_att('scale_factor',0.1,'sfloat')
439 -v2.put_att('add_offset',100.0,'sfloat')
440 -v3.put_att('scale_factor',0.1,'sfloat')
441 -v3.put_att('add_offset',100.0,'sfloat')
442 -f.enddef
443 -v1.put( NArray.sint(nx).indgen!+100 )
444 -v2.scaled_put( NArray.float(nx).indgen!+100 )
445 -v3.scaled_put( NArray.float(nx).indgen!+100 )
446 -f.close
447 + def teardown
448 + if File.exist?(@s)
449 + begin
450 + File.delete(@s)
451 + rescue
452 + p $!
453 + end
454 + end
455 + end
456 + def test_originally_uscaled
457 + f = NetCDF.open(@s)
458 + v1 = f.var('v1')
459 + v11 = v1.get
460 + assert_equal v11,
461 + NArray[ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109 ].to_i
462 + v12 = v1.scaled_get
463 + assert_equal v12,
464 + NArray[ 110.0, 110.1, 110.2, 110.3, 110.4, 110.5, 110.6, 110.7, 110.8, 110.9 ].to_type(NArray::SFLOAT)
465 + f.close
466 + end
467
468 + def test_originally_scaled
469 + f = NetCDF.open(@s)
470 + v2 = f.var('v2')
471 + v21 = v2.get
472 + assert_equal v21,
473 + NArray[ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 ].to_i
474 + v22 = v2.scaled_get
475 + assert_equal v22,
476 + NArray[ 100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 106.0, 107.0, 108.0, 109.0 ].to_type(NArray::SFLOAT)
477 + f.close
478 + end
479
480 -print "** originally unscaled\n"
481 -f = NetCDF.open(s)
482 -v1 = f.var('v1')
483 -v11 = v1.get
484 -v12 = v1.scaled_get
485 -p v11
486 -p v12
487 + def test_originally_scaled_int_to_double
488 + f = NetCDF.open(@s)
489 + v3 = f.var('v3')
490 + v31 = v3.get
491 + assert_equal v31,
492 + NArray[ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 ].to_i
493 + v32 = v3.scaled_get
494 + assert_equal v32,
495 + NArray[ 100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 106.0, 107.0, 108.0, 109.0 ].to_type(NArray::SFLOAT)
496 + f.close
497 + end
498
499 -print "** originally scaled\n"
500 -v2 = f.var('v2')
501 -v21 = v2.get
502 -v22 = v2.scaled_get
503 -p v21
504 -p v22
505 -
506 -print "** originally sclaed (int --> double)\n"
507 -v3 = f.var('v3')
508 -v31 = v3.get
509 -v32 = v3.scaled_get
510 -p v31
511 -p v32
512 -
513 -print "** unpack type fixed to sfloat\n"
514 -NetCDFVar.unpack_type = NArray::SFLOAT
515 -v33 = v3.scaled_get
516 -p v33
517 -NetCDFVar.unpack_type = NArray::INT
518 -v33 = v3.scaled_get
519 -p v33
520 + def test_unpack_type_fixed_to_sfloat
521 + f = NetCDF.open(@s)
522 + v3 = f.var('v3')
523 + NetCDFVar.unpack_type = NArray::SFLOAT
524 + v33 = v3.scaled_get
525 + assert_equal v33,
526 + NArray[ 100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 106.0, 107.0, 108.0, 109.0 ].to_type(NArray::SFLOAT)
527 + NetCDFVar.unpack_type = NArray::INT
528 + v33 = v3.scaled_get
529 + assert_equal v33,
530 + NArray[ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109 ].to_i
531 + end
532 +end
533 diff --git a/test/putatt.rb b/test/putatt.rb
534 index 0fa2efb..7b0f55e 100644
535 --- a/test/putatt.rb
536 +++ b/test/putatt.rb
537 @@ -1,56 +1,78 @@
538 +require 'test/unit'
539 require 'numru/netcdf'
540 -include NumRu
541 -s = 'tmp.nc'
542 -f = NetCDF.create(s)
543 -d = f.def_dim('x',5)
544 -v = f.def_var('x','sfloat',[d])
545 -
546 require 'date'
547 -att = f.put_att("history", Date.today.to_s )
548 -p att.get, f.att("history").get
549 -att = f.put_att("int_att",123)
550 -att = f.put_att("sfloat_att",1.0/3.0,'sfloat')
551 -att = f.put_att("sfloat_att2",2.0/3.0,NArray::SFLOAT)
552 -att = v.put_att("long_name",'test variable')
553 -att = v.put_att("int_att",123)
554 -p att.get, v.att("int_att").get
555 -att = v.put_att("float_att",1.0/3.0)
556 -att = v.put_att("float_array",[0.1, 0.2, 30])
557 -att = v.put_att("sfloat_narray",NArray.sfloat(3).indgen!/3)
558 -att = v.put_att("float_narray",NArray.float(3).indgen!)
559 -att = v.put_att("sint_narray",NArray.sint(3).indgen!)
560 -att = v.put_att("int2float",10,'float')
561 -att = att = v.put_att("dummy",10,'float')
562 -att.put('changed to text')
563 -att.name = 'changed'
564 -begin
565 - v.put_att("destined_to_fail",9.8,'complex')
566 -rescue
567 - print "*1* exception raised as expected -- (",
568 - __FILE__,":",__LINE__,") ", $!,"\n"
569 -end
570 -begin
571 - v.put_att("destined_to_fail",9.8,'string')
572 -rescue
573 - print "*2* exception raised as expected -- (",
574 - __FILE__,":",__LINE__,") ", $!,"\n"
575 -end
576 +include NumRu
577 +class TestPutAttr < Test::Unit::TestCase
578 + def setup
579 + @s = 'tmp.nc'
580 + @f = NetCDF.create(@s)
581 + @d = @f.def_dim('x',5)
582 + @v = @f.def_var('x','sfloat',[@d])
583 + end
584 + def teardown
585 + @f.close
586 + if File.exist?(@s)
587 + begin
588 + File.delete(@s)
589 + rescue
590 + p $!
591 + end
592 + end
593 + end
594 + def test_att_history_get
595 + att = @f.put_att("history", Date.today.to_s )
596 + assert_equal att.get,
597 + @f.att("history").get
598 + end
599 + def test_att_int_att_get
600 + att = @f.put_att("int_att",123)
601 + att = @f.put_att("sfloat_att",1.0/3.0,'sfloat')
602 + att = @f.put_att("sfloat_att2",2.0/3.0,NArray::SFLOAT)
603 + att = @v.put_att("long_name",'test variable')
604 + att = @v.put_att("int_att",123)
605 + assert_equal att.get,
606 + @v.att("int_att").get
607 + end
608
609 -begin
610 - v.put_att("destined_to_fail",'hello','int')
611 -rescue
612 - print "*3* exception raised as expected -- (",
613 - __FILE__,":",__LINE__,") ", $!,"\n"
614 -end
615 + def test_att_changed_to_text
616 + att = @v.put_att("float_att",1.0/3.0)
617 + att = @v.put_att("float_array",[0.1, 0.2, 30])
618 + tmp = NArray.sfloat(3).indgen!
619 + tmp = tmp/3
620 + att = @v.put_att("sfloat_narray",tmp)
621 + att = @v.put_att("float_narray",NArray.float(3).indgen!)
622 + att = @v.put_att("sint_narray",NArray.sint(3).indgen!)
623 + att = @v.put_att("int2float",10,'float')
624 + att = att = @v.put_att("dummy",10,'float')
625 + assert att.put('changed to text')
626 + att.name = 'changed'
627 + end
628
629 -begin
630 - v.put_att("destined_to_fail",[10,30,'sss'])
631 -rescue
632 - print "*4* exception raised as expected -- (",
633 - __FILE__,":",__LINE__,") ", $!,"\n"
634 -end
635 + def test_destined_to_fail_complex
636 + assert_raise(NetcdfError) do
637 + @v.put_att("destined_to_fail", 9.8, 'complex')
638 + # "unsupported type. code = 7"
639 + end
640 + end
641
642 + def test_destined_to_fail_string
643 + assert_raise(ArgumentError) do
644 + @v.put_att("destined_to_fail", 9.8, 'string')
645 + # Unrecognized NArray type>
646 + end
647 + end
648
649 -f.close
650 + def test_destined_to_fail_int
651 + assert_raise(NetcdfError) do
652 + @v.put_att("destined_to_fail", 'hello', 'int')
653 + # attribute type must be 'char' (or nil) for a String value
654 + end
655 + end
656
657 -print `ncdump tmp.nc`
658 + def test_destined_to_fail_mixed_array
659 + assert_raise(TypeError) do
660 + @v.put_att("destined_to_fail",[10,30,'sss'])
661 + # no implicit conversion of String into Integer
662 + end
663 + end
664 +end
665 diff --git a/test/test.rb b/test/test.rb
666 index 3b2b148..7b7fc9e 100644
667 --- a/test/test.rb
668 +++ b/test/test.rb
669 @@ -1,192 +1,199 @@
670 -require 'numru/netcdf'
671 -## // to test before make install -->
672 -#require 'narray'
673 -#require '../netcdfraw'
674 -#require '../lib/netcdf'
675 -## <-- to test before make install //
676 -
677 +require 'test/unit'
678 +require 'numru/netcdf'
679 include NumRu
680
681 -filename = "test.nc"
682 -print "creating ",filename,"...\n"
683 -file=NetCDF.create(filename,false,false)
684 -
685 -dimx=file.def_dim("x",15)
686 -dimy=file.def_dim("y",10)
687 -dimz=file.def_dim("z",10)
688 -
689 -batt = file.put_att("type_byte",5,"byte")
690 -file.put_att("type_short",[222,333,444],"sint")
691 -file.put_att("type_int",[2222,3333,4444])
692 -file.put_att("type_float",[2.22,3.33,4.44],"sfloat")
693 -file.put_att("type_double",[2.222,3.333,4.444])
694 -string = file.put_attraw("string","netCDF for Ruby","string")
695 -batt.put(6,"byte")
696 -
697 -sint_var=file.def_var("test_sint","sint",["x"])
698 -byte_var=file.def_var("test_byte","byte",["y"])
699 -byte_var2=file.def_var("test_byte2","byte",[dimy,dimz])
700 -int_var=file.def_var("test_int","int",["y"])
701 -sfloat_var=file.def_var("test_sfloat","sfloat",["z"])
702 -float_var=file.def_var("test_float","float",["y"])
703 -
704 -a=NArray.sint(10).indgen
705 -b=NArray.sint(10).fill(7)
706 -c=NArray.byte(10).indgen
707 -d=NArray.int(10).indgen
708 -e=NArray.sfloat(10).fill(1.111)
709 -f=NArray.float(10).fill(5.5555555)
710 -file.enddef
711 -file2 = file
712 -(file2 == file)
713 -
714 -byte_var.put_var_byte(c)
715 -int_var.put_var_int(d)
716 -sfloat_var.put_var_sfloat(e)
717 -float_var.put_var_float(f)
718 -
719 -file.redef
720 -byte_vara=file.def_var("test_byte_vara","byte",[dimy,dimz]);
721 -sint_vara=file.def_var("test_sint_vara","sint",["y","z"]);
722 -int_vara=file.def_var("test_int_vara","int",["y","z"]);
723 -sfloat_vara=file.def_var("test_sfloat_vara","sfloat",["y","z"]);
724 -float_vara=file.def_var("test_float_vara","float",["y","z"]);
725 -file.enddef
726 -
727 -byte_vara2 = byte_vara
728 -(byte_vara2 == byte_vara)
729 -
730 -g=NArray.byte(10,10).indgen
731 -h=NArray.byte(2,3).indgen
732 -gh=NArray.byte(1,1).fill(33)
733 -k=NArray.sint(10,10).indgen
734 -l=NArray.sint(2,3).indgen
735 -kl=NArray.sint(1,1).fill(44)
736 -m=NArray.int(10,10).indgen
737 -n=NArray.int(2,3).indgen
738 -mn=NArray.int(1,1).fill(55)
739 -o=NArray.sfloat(10,10).fill(1.234567)
740 -p=NArray.sfloat(2,3).fill(2.345678)
741 -op=NArray.int(1,1).fill(3.4)
742 -q=NArray.float(10,10).fill(1.234)
743 -r=NArray.float(2,3).fill(2.345)
744 -qr=NArray.float(1,1).fill(4.5)
745 -s=NArray.float(2,2).fill(10.0)
746 -
747 -
748 -byte_vara.put(g)
749 -byte_vara.put(h,{"start"=>[3,5]})
750 -byte_vara.put(g,{"start"=>[0,0],"end"=>[9,9]})
751 -byte_vara.put(h,{"start"=>[-8,2]})
752 -byte_vara.put(h,{"start"=>[0,0],"stride"=>[2,3]})
753 -byte_vara.put(h,{'start'=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
754 -byte_vara.put(gh,{"index"=>[4,7]})
755 -
756 -sint_vara.put(k)
757 -sint_vara.put(l,{"start"=>[3,5]})
758 -sint_vara.put(k,{"start"=>[0,0],"end"=>[9,9]})
759 -sint_vara.put(l,{"start"=>[-8,2]})
760 -sint_vara.put(l,{"start"=>[0,0],"stride"=>[2,3]})
761 -sint_vara.put(l,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
762 -sint_vara.put(kl,{"index"=>[4,7]})
763 -
764 -int_vara.put(m)
765 -int_vara.put(n,{"start"=>[3,5]})
766 -int_vara.put(m,{"start"=>[0,0],"end"=>[9,9]})
767 -int_vara.put(n,{"start"=>[-8,2]})
768 -int_vara.put(n,{"start"=>[0,0],"stride"=>[2,3]})
769 -int_vara.put(n,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
770 -int_vara.put(mn,{"index"=>[4,7]})
771 -
772 -sfloat_vara.put(o)
773 -sfloat_vara.put(p,{"start"=>[3,5]})
774 -sfloat_vara.put(o,{"start"=>[0,0],"end"=>[9,9]})
775 -sfloat_vara.put(p,{"start"=>[-8,2]})
776 -sfloat_vara.put(p,{"start"=>[0,0],"stride"=>[2,3]})
777 -sfloat_vara.put(p,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
778 -sfloat_vara.put(op,{"index"=>[4,7]})
779 -
780 -float_vara.put(q)
781 -float_vara.put(r,{"start"=>[3,5]})
782 -float_vara.put(q,{"start"=>[0,0],"end"=>[9,9]})
783 -float_vara.put(r,{"start"=>[-8,2]})
784 -float_vara.put(r,{"start"=>[0,0],"stride"=>[2,3]})
785 -float_vara.put(r,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
786 -float_vara.put(qr,{"index"=>[4,7]})
787 -
788 -float_vara.dim_names
789 -
790 -na_aaa=byte_vara.get({"start"=>[3,5]})
791 -na_aab=byte_vara.get({"start"=>[0,0],"end"=>[9,9]})
792 -na_aac=byte_vara.get({"start"=>[-8,2]})
793 -na_aad=byte_vara.get({"start"=>[0,0],"stride"=>[2,3]})
794 -na_aae=byte_vara.get({'start'=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
795 -na_aaf=byte_vara.get({"index"=>[4,7]})
796 -na_aag=byte_vara.get
797 -
798 -na_bba=sint_vara.get({"start"=>[3,5]})
799 -na_bbb=sint_vara.get({"start"=>[0,0],"end"=>[9,9]})
800 -na_bbc=sint_vara.get({"start"=>[-8,2]})
801 -na_bbd=sint_vara.get({"start"=>[0,0],"stride"=>[2,3]})
802 -na_bbf=sint_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
803 -na_bbg=sint_vara.get({"index"=>[4,7]})
804 -na_bbh=sint_vara.get
805 -
806 -na_cca=int_vara.get({"start"=>[3,5]})
807 -na_ccb=int_vara.get({"start"=>[0,0],"end"=>[9,9]})
808 -na_ccc=int_vara.get({"start"=>[-8,2]})
809 -na_ccd=int_vara.get({"start"=>[0,0],"stride"=>[2,3]})
810 -na_cce=int_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
811 -na_ccf=int_vara.get({"index"=>[4,7]})
812 -na_ccg=int_vara.get
813 -
814 -na_dda=sfloat_vara.get({"start"=>[3,5]})
815 -na_ddb=sfloat_vara.get({"start"=>[0,0],"end"=>[9,9]})
816 -na_ddc=sfloat_vara.get({"start"=>[-8,2]})
817 -na_ddd=sfloat_vara.get({"start"=>[0,0],"stride"=>[2,3]})
818 -na_dde=sfloat_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
819 -na_ddf=sfloat_vara.get({"index"=>[4,7]})
820 -na_ddg=sfloat_vara.get
821 -
822 -na_eea=float_vara.get({"start"=>[3,5]})
823 -na_eeb=float_vara.get({"start"=>[0,0],"end"=>[9,9]})
824 -na_eec=float_vara.get({"start"=>[-8,2]})
825 -na_eed=float_vara.get({"start"=>[0,0],"stride"=>[2,3]})
826 -na_eee=float_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
827 -na_eef=float_vara.get({"index"=>[4,7]})
828 -na_eeg=float_vara.get
829 -
830 -file.redef
831 -
832 -copy_byte = string.copy(byte_vara)
833 -copy_byte.put([0,20],"byte")
834 -copy_byte.name="new_name"
835 -
836 -copy_byte2 = copy_byte
837 -(copy_byte2 == copy_byte)
838 -
839 -copy_sint = string.copy(sint_vara)
840 -copy_sint.put("%%%%%")
841 -copy_int = string.copy(int_vara)
842 -copy_int.put([0,60],"int")
843 -copy_sfloat = string.copy(sfloat_vara)
844 -copy_sfloat.put([0.01,5.5],"sfloat")
845 -copy_float = string.copy(float_vara)
846 -copy_float.put([0.0001,5.5555],"float")
847 -file.enddef
848 -nm = copy_byte.name
849 -att0 = string.get
850 -att1 = copy_byte.get
851 -att2 = copy_sint.get
852 -att3 = copy_int.get
853 -att4 = copy_sfloat.get
854 -att5 = copy_float.get
855 -file.fill(true)
856 -file.fill(false)
857 -
858 -float_vara.dim_names
859 -float_vara.att_names
860 -
861 -file.close
862 -exit(0)
863 -
864 +# What checked?
865 +
866 +class TestCreate < Test::Unit::TestCase
867 +
868 + def test_create_netcdf_file
869 + @filename = "test.nc"
870 + file=NetCDF.create(@filename,false,false)
871 + assert dimx=file.def_dim("x",15)
872 + assert dimy=file.def_dim("y",10)
873 + assert dimz=file.def_dim("z",10)
874 + batt = file.put_att("type_byte",5,"byte")
875 + file.put_att("type_short",[222,333,444],"sint")
876 + file.put_att("type_int",[2222,3333,4444])
877 + file.put_att("type_float",[2.22,3.33,4.44],"sfloat")
878 + file.put_att("type_double",[2.222,3.333,4.444])
879 + string = file.put_attraw("string","netCDF for Ruby","string")
880 + batt.put(6,"byte")
881 +
882 + assert sint_var=file.def_var("test_sint","sint",["x"])
883 + assert byte_var=file.def_var("test_byte","byte",["y"])
884 + assert byte_var2=file.def_var("test_byte2","byte",[dimy,dimz])
885 + assert int_var=file.def_var("test_int","int",["y"])
886 + assert sfloat_var=file.def_var("test_sfloat","sfloat",["z"])
887 + assert float_var=file.def_var("test_float","float",["y"])
888 +
889 + assert a=NArray.sint(10).indgen
890 + assert b=NArray.sint(10).fill(7)
891 + assert c=NArray.byte(10).indgen
892 + assert d=NArray.int(10).indgen
893 + assert e=NArray.sfloat(10).fill(1.111)
894 + assert f=NArray.float(10).fill(5.5555555)
895 + file.enddef
896 + file2 = file
897 + assert_equal file2, file
898 +
899 + assert_nil byte_var.put_var_byte(c)
900 + assert_nil int_var.put_var_int(d)
901 + assert_nil sfloat_var.put_var_sfloat(e)
902 + assert_nil float_var.put_var_float(f)
903 +
904 + file.redef
905 + byte_vara=file.def_var("test_byte_vara","byte",[dimy,dimz]);
906 + sint_vara=file.def_var("test_sint_vara","sint",["y","z"]);
907 + int_vara=file.def_var("test_int_vara","int",["y","z"]);
908 + sfloat_vara=file.def_var("test_sfloat_vara","sfloat",["y","z"]);
909 + float_vara=file.def_var("test_float_vara","float",["y","z"]);
910 + file.enddef
911 +
912 + byte_vara2 = byte_vara
913 + assert_equal byte_vara2, byte_vara
914 +
915 + assert g=NArray.byte(10,10).indgen
916 + assert h=NArray.byte(2,3).indgen
917 + assert gh=NArray.byte(1,1).fill(33)
918 + assert k=NArray.sint(10,10).indgen
919 + assert l=NArray.sint(2,3).indgen
920 + assert kl=NArray.sint(1,1).fill(44)
921 + assert m=NArray.int(10,10).indgen
922 + assert n=NArray.int(2,3).indgen
923 + assert mn=NArray.int(1,1).fill(55)
924 + assert o=NArray.sfloat(10,10).fill(1.234567)
925 + assert p=NArray.sfloat(2,3).fill(2.345678)
926 + assert op=NArray.int(1,1).fill(3.4)
927 + assert q=NArray.float(10,10).fill(1.234)
928 + assert r=NArray.float(2,3).fill(2.345)
929 + assert qr=NArray.float(1,1).fill(4.5)
930 + assert s=NArray.float(2,2).fill(10.0)
931 +
932 + assert_nil byte_vara.put(g)
933 + assert_nil byte_vara.put(h,{"start"=>[3,5]})
934 + assert_nil byte_vara.put(g,{"start"=>[0,0],"end"=>[9,9]})
935 + assert_nil byte_vara.put(h,{"start"=>[-8,2]})
936 + assert_nil byte_vara.put(h,{"start"=>[0,0],"stride"=>[2,3]})
937 + assert_nil byte_vara.put(h,{'start'=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
938 + assert_nil byte_vara.put(gh,{"index"=>[4,7]})
939 +
940 + sint_vara.put(k)
941 + sint_vara.put(l,{"start"=>[3,5]})
942 + sint_vara.put(k,{"start"=>[0,0],"end"=>[9,9]})
943 + sint_vara.put(l,{"start"=>[-8,2]})
944 + sint_vara.put(l,{"start"=>[0,0],"stride"=>[2,3]})
945 + sint_vara.put(l,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
946 + sint_vara.put(kl,{"index"=>[4,7]})
947 +
948 + int_vara.put(m)
949 + int_vara.put(n,{"start"=>[3,5]})
950 + int_vara.put(m,{"start"=>[0,0],"end"=>[9,9]})
951 + int_vara.put(n,{"start"=>[-8,2]})
952 + int_vara.put(n,{"start"=>[0,0],"stride"=>[2,3]})
953 + int_vara.put(n,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
954 + int_vara.put(mn,{"index"=>[4,7]})
955 +
956 + sfloat_vara.put(o)
957 + sfloat_vara.put(p,{"start"=>[3,5]})
958 + sfloat_vara.put(o,{"start"=>[0,0],"end"=>[9,9]})
959 + sfloat_vara.put(p,{"start"=>[-8,2]})
960 + sfloat_vara.put(p,{"start"=>[0,0],"stride"=>[2,3]})
961 + sfloat_vara.put(p,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
962 + sfloat_vara.put(op,{"index"=>[4,7]})
963 +
964 + float_vara.put(q)
965 + float_vara.put(r,{"start"=>[3,5]})
966 + float_vara.put(q,{"start"=>[0,0],"end"=>[9,9]})
967 + float_vara.put(r,{"start"=>[-8,2]})
968 + float_vara.put(r,{"start"=>[0,0],"stride"=>[2,3]})
969 + float_vara.put(r,{"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
970 + float_vara.put(qr,{"index"=>[4,7]})
971 +
972 + float_vara.dim_names
973 +
974 + assert na_aaa=byte_vara.get({"start"=>[3,5]})
975 + assert na_aab=byte_vara.get({"start"=>[0,0],"end"=>[9,9]})
976 + assert na_aac=byte_vara.get({"start"=>[-8,2]})
977 + assert na_aad=byte_vara.get({"start"=>[0,0],"stride"=>[2,3]})
978 + assert na_aae=byte_vara.get({'start'=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
979 + assert na_aaf=byte_vara.get({"index"=>[4,7]})
980 + assert na_aag=byte_vara.get
981 +
982 + assert na_bba=sint_vara.get({"start"=>[3,5]})
983 + assert na_bbb=sint_vara.get({"start"=>[0,0],"end"=>[9,9]})
984 + assert na_bbc=sint_vara.get({"start"=>[-8,2]})
985 + assert na_bbd=sint_vara.get({"start"=>[0,0],"stride"=>[2,3]})
986 + assert na_bbf=sint_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
987 + assert na_bbg=sint_vara.get({"index"=>[4,7]})
988 + assert na_bbh=sint_vara.get
989 +
990 + assert na_cca=int_vara.get({"start"=>[3,5]})
991 + assert na_ccb=int_vara.get({"start"=>[0,0],"end"=>[9,9]})
992 + assert na_ccc=int_vara.get({"start"=>[-8,2]})
993 + assert na_ccd=int_vara.get({"start"=>[0,0],"stride"=>[2,3]})
994 + assert na_cce=int_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
995 + assert na_ccf=int_vara.get({"index"=>[4,7]})
996 + assert na_ccg=int_vara.get
997 +
998 + assert na_dda=sfloat_vara.get({"start"=>[3,5]})
999 + assert na_ddb=sfloat_vara.get({"start"=>[0,0],"end"=>[9,9]})
1000 + assert na_ddc=sfloat_vara.get({"start"=>[-8,2]})
1001 + assert na_ddd=sfloat_vara.get({"start"=>[0,0],"stride"=>[2,3]})
1002 + assert na_dde=sfloat_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
1003 + assert na_ddf=sfloat_vara.get({"index"=>[4,7]})
1004 + assert na_ddg=sfloat_vara.get
1005 +
1006 + assert na_eea=float_vara.get({"start"=>[3,5]})
1007 + assert na_eeb=float_vara.get({"start"=>[0,0],"end"=>[9,9]})
1008 + assert na_eec=float_vara.get({"start"=>[-8,2]})
1009 + assert na_eed=float_vara.get({"start"=>[0,0],"stride"=>[2,3]})
1010 + assert na_eee=float_vara.get({"start"=>[1,1],"end"=>[3,7],"stride"=>[2,3]})
1011 + assert na_eef=float_vara.get({"index"=>[4,7]})
1012 + assert na_eeg=float_vara.get
1013 +
1014 + file.redef
1015 +
1016 + copy_byte = string.copy(byte_vara)
1017 + copy_byte.put([0,20],"byte")
1018 + copy_byte.name="new_name"
1019 +
1020 + copy_byte2 = copy_byte
1021 + assert_equal copy_byte2, copy_byte
1022 +
1023 + copy_sint = string.copy(sint_vara)
1024 + copy_sint.put("%%%%%")
1025 + copy_int = string.copy(int_vara)
1026 + copy_int.put([0,60],"int")
1027 + copy_sfloat = string.copy(sfloat_vara)
1028 + copy_sfloat.put([0.01,5.5],"sfloat")
1029 + copy_float = string.copy(float_vara)
1030 + copy_float.put([0.0001,5.5555],"float")
1031 + file.enddef
1032 + assert nm = copy_byte.name
1033 + assert att0 = string.get
1034 + assert att1 = copy_byte.get
1035 + assert att2 = copy_sint.get
1036 + assert att3 = copy_int.get
1037 + assert att4 = copy_sfloat.get
1038 + assert att5 = copy_float.get
1039 + file.fill(true)
1040 + file.fill(false)
1041 +
1042 + float_vara.dim_names
1043 + float_vara.att_names
1044 +
1045 + file.close
1046 + end
1047 +
1048 + def teardown
1049 + if File.exist?(@filename)
1050 + begin
1051 + File.delete(@filename)
1052 + rescue
1053 + p $!
1054 + end
1055 + end
1056 + end
1057 +
1058 +end
1059 diff --git a/test/type.rb b/test/type.rb
1060 index 08141d7..2f27097 100644
1061 --- a/test/type.rb
1062 +++ b/test/type.rb
1063 @@ -1,13 +1,29 @@
1064 +require 'test/unit'
1065 require 'numru/netcdf'
1066 include NumRu
1067 -s = 'tmp.nc'
1068 -f = NetCDF.create(s)
1069 -d = f.def_dim('x',2)
1070 -v = f.def_var('x','sfloat',[d])
1071 -p v.vartype, v.ntype
1072 -v = f.def_var('x1','sint',[d])
1073 -p v.vartype, v.ntype
1074 -v = f.def_var('x2','byte',[d])
1075 -p v.vartype, v.ntype
1076 -
1077 -f.close
1078 +class TestType < Test::Unit::TestCase
1079 + def test_type
1080 + @s = 'tmp.nc'
1081 + f = NetCDF.create(@s)
1082 + d = f.def_dim('x',2)
1083 + v = f.def_var('x','sfloat',[d])
1084 + assert_equal v.vartype,
1085 + v.ntype
1086 + v = f.def_var('x1','sint',[d])
1087 + assert_equal v.vartype,
1088 + v.ntype
1089 + v = f.def_var('x2','byte',[d])
1090 + assert_equal v.vartype,
1091 + v.ntype
1092 + f.close
1093 + end
1094 + def teardown
1095 + if File.exist?(@s)
1096 + begin
1097 + File.delete(@s)
1098 + rescue
1099 + p $!
1100 + end
1101 + end
1102 + end
1103 +end
0 0002-Support-NetCDF-rc-release
1 0003-Add-patch-Replace-git-execution-from-gemspec.patch
2 0004-Fix-spelling-error-in-binary.patch
3 0005-length-spelling-error.patch
4 0005-import-upstream-Drop-obsolete-rb_secure-rb_safe_leve.patch
5 0006-upstream-import-Rewrite-test-use-Test-Unit.patch
0 # Build uses -D_FORTIFY_SOURCE=2, but hardening-check reports:
1 # Fortify Source functions: no, only unprotected functions found!
2 hardening-no-fortify-functions *
3
0 ---
1 - test/aref_aset.rb
2 - test/char_var.rb
3 - test/clone.rb
4 - test/create_tmp.rb
5 - test/def_var_with_dim.rb
6 - test/factor_offset.rb
7 - test/putatt.rb
8 - test/test.rb
9 - test/type.rb
0 #!/usr/bin/make -f
1
2 # Enable hardening build flags
3 export DEB_BUILD_MAINT_OPTIONS=hardening=+all
4
5 export DH_RUBY_GEMSPEC = ruby-netcdf.gemspec
6
7 %:
8 dh $@ --buildsystem ruby --with ruby
9
10 override_dh_auto_install:
11 dh_auto_install
12 rm -fr $(CURDIR)/debian/ruby-netcdf/usr/bin
13
14 override_dh_auto_clean:
15 dh_auto_clean
16 rm -f $(CURDIR)/ext/numru/Makefile
17 rm -f $(CURDIR)/ext/numru/netcdfraw.o
18 rm -f $(CURDIR)/ext/numru/netcdfraw.so
19 rm -f $(CURDIR)/ext/numru/.RUBY*
20 rm -f $(CURDIR)/*.nc
0 ---
1 include:
2 - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/salsa-ci.yml
3 - https://salsa.debian.org/salsa-ci-team/pipeline/raw/master/pipeline-jobs.yml
0 3.0 (quilt)
0 Test-Command: gem2deb-test-runner --autopkgtest
1 Depends: @, @builddeps@, gem2deb-test-runner
2 Restrictions: allow-stderr
0 version=4
1 https://gemwatch.debian.net/ruby-netcdf .*/ruby-netcdf-(.*).tar.gz