ruby-netcdf 0.6.6.1 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ module Ruby
2
+ module Netcdf
3
+ VERSION = "0.7.1"
4
+ end
5
+ end
@@ -24,6 +24,11 @@
24
24
  #define SafeStringValue(s) Check_SafeStr(s)
25
25
  #endif
26
26
 
27
+ /* for compatibility for NArray and NArray with big memory patch */
28
+ #ifndef NARRAY_BIGMEM
29
+ typedef int na_shape_t;
30
+ #endif
31
+
27
32
  /* Data to NArray */
28
33
 
29
34
  /* memcpy(ary->ptr,nc_ptr,na_sizeof[NA_SINT]*ary->total); \ */
@@ -202,7 +207,7 @@
202
207
  ptr = (int32_t *) NA_PTR(na,0); \
203
208
  }
204
209
 
205
- #define NC_RAISE(status) rb_raise(err_status2class(status),(nc_strerror(status)))
210
+ #define NC_RAISE(status) rb_raise(err_status2class(status),"%s",(nc_strerror(status)))
206
211
  #define NC_RAISE2(status, str) rb_raise(err_status2class(status),"%s (%s)",nc_strerror(status),(str) )
207
212
 
208
213
  static VALUE mNumRu = 0;
@@ -343,9 +348,8 @@ NetCDF_dim_free(struct NetCDFDim *Netcdf_dim)
343
348
  void
344
349
  NetCDF_free(struct Netcdf *Netcdffile)
345
350
  {
346
- int status;
347
351
  if (!Netcdffile->closed){
348
- status = nc_close(Netcdffile->ncid); /* no error check -- not to stop during GC */
352
+ nc_close(Netcdffile->ncid); /* no error check -- not to stop during GC */
349
353
  }
350
354
  free(Netcdffile->name);
351
355
  free(Netcdffile);
@@ -426,6 +430,7 @@ err_status2class(int status)
426
430
  case(NC_FATAL):
427
431
  return(rb_eNetcdfFatal);break;
428
432
  }
433
+ return rb_eNetcdfError;
429
434
  }
430
435
 
431
436
  static const char*
@@ -555,6 +560,14 @@ NetCDF_var_clone(VALUE var)
555
560
  return clone;
556
561
  }
557
562
 
563
+ VALUE
564
+ NetCDF_inq_libvers(VALUE mod)
565
+ {
566
+ VALUE str;
567
+ str = rb_str_new2(nc_inq_libvers());
568
+ return(str);
569
+ }
570
+
558
571
  VALUE
559
572
  NetCDF_close(file)
560
573
  VALUE file;
@@ -563,7 +576,7 @@ NetCDF_close(file)
563
576
  int ncid;
564
577
  struct Netcdf *Netcdffile;
565
578
 
566
- if (rb_safe_level() >= 4 && !OBJ_TAINTED(file)) {
579
+ if (rb_safe_level() >= 3 && !OBJ_TAINTED(file)) {
567
580
  rb_raise(rb_eSecurityError, "Insecure: can't close");
568
581
  }
569
582
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
@@ -590,7 +603,7 @@ NetCDF_def_dim(VALUE file,VALUE dim_name,VALUE length)
590
603
  struct NetCDFDim *Netcdf_dim;
591
604
  VALUE Dimension;
592
605
 
593
- rb_secure(4);
606
+ rb_secure(3);
594
607
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
595
608
 
596
609
  Check_Type(dim_name,T_STRING);
@@ -733,7 +746,7 @@ NetCDF_put_att(VALUE file,VALUE att_name,VALUE value,VALUE atttype)
733
746
  struct Netcdf *ncfile;
734
747
  char *name;
735
748
 
736
- rb_secure(4);
749
+ rb_secure(3);
737
750
  Data_Get_Struct(file,struct Netcdf,ncfile);
738
751
  Check_Type(att_name,T_STRING);
739
752
  name = RSTRING_PTR(att_name);
@@ -751,7 +764,7 @@ NetCDF_put_att_var(VALUE var,VALUE att_name,VALUE value,VALUE atttype)
751
764
  struct NetCDFVar *ncvar;
752
765
  char *name;
753
766
 
754
- rb_secure(4);
767
+ rb_secure(3);
755
768
  Data_Get_Struct(var,struct NetCDFVar,ncvar);
756
769
  Check_Type(att_name,T_STRING);
757
770
  name = RSTRING_PTR(att_name);
@@ -778,7 +791,7 @@ NetCDF_def_var(VALUE file,VALUE var_name,VALUE vartype,VALUE dimensions)
778
791
  struct NetCDFDim *Netcdf_dim;
779
792
  VALUE Var;
780
793
 
781
- rb_secure(4);
794
+ rb_secure(3);
782
795
  Check_Type(var_name,T_STRING);
783
796
  Check_Type(dimensions,T_ARRAY);
784
797
 
@@ -824,7 +837,6 @@ NetCDF_def_var(VALUE file,VALUE var_name,VALUE vartype,VALUE dimensions)
824
837
  return Var;
825
838
  }
826
839
 
827
-
828
840
  VALUE
829
841
  NetCDF_dim(VALUE file,VALUE dim_name)
830
842
  {
@@ -949,7 +961,7 @@ NetCDF_redef(VALUE file)
949
961
  int status;
950
962
  struct Netcdf *Netcdffile;
951
963
 
952
- rb_secure(4);
964
+ rb_secure(3);
953
965
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
954
966
  ncid=Netcdffile->ncid;
955
967
  status = nc_redef(ncid);
@@ -971,7 +983,7 @@ NetCDF_enddef(VALUE file)
971
983
  int status;
972
984
  struct Netcdf *Netcdffile;
973
985
 
974
- rb_secure(4);
986
+ rb_secure(3);
975
987
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
976
988
  ncid=Netcdffile->ncid;
977
989
  status = nc_enddef(ncid);
@@ -998,7 +1010,7 @@ NetCDF_whether_in_define_mode(VALUE file)
998
1010
  int status;
999
1011
  struct Netcdf *Netcdffile;
1000
1012
 
1001
- rb_secure(4);
1013
+ rb_secure(3);
1002
1014
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
1003
1015
  ncid=Netcdffile->ncid;
1004
1016
  status = nc_redef(ncid);
@@ -1149,7 +1161,7 @@ NetCDF_sync(VALUE file)
1149
1161
  int status;
1150
1162
  struct Netcdf *ncfile;
1151
1163
 
1152
- rb_secure(4);
1164
+ rb_secure(3);
1153
1165
  Data_Get_Struct(file,struct Netcdf,ncfile);
1154
1166
  ncid=ncfile->ncid;
1155
1167
  status = nc_sync(ncid);
@@ -1196,7 +1208,7 @@ NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
1196
1208
  char *c_dim_name;
1197
1209
  struct NetCDFDim *Netcdf_dim;
1198
1210
 
1199
- rb_secure(4);
1211
+ rb_secure(3);
1200
1212
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
1201
1213
  ncid=Netcdf_dim->ncid;
1202
1214
  dimid=Netcdf_dim->dimid;
@@ -1354,6 +1366,113 @@ NetCDF_id2att(VALUE file,VALUE attnum)
1354
1366
 
1355
1367
  }
1356
1368
 
1369
+ #if NCVER >= 400
1370
+ /* USAGE
1371
+ NetCDFVar#deflate(deflate_level, shuffle=false)
1372
+ */
1373
+ VALUE
1374
+ NetCDF_var_deflate(int argc, VALUE *argv, VALUE Var)
1375
+ {
1376
+ int ncid, varid, status;
1377
+ struct NetCDFVar *Netcdf_var;
1378
+
1379
+ int shuffle;
1380
+ /* If non-zero, turn on the shuffle filter.
1381
+
1382
+ http://www.unidata.ucar.edu/software/netcdf/papers/AMS_2008.pdf :
1383
+ The shuffle algorithm changes the byte order in the data stream;
1384
+ when used with integers that are all close together, this
1385
+ results in a better compression ratio. There is no benefit
1386
+ from using the shuffle filter without also using
1387
+ compression.
1388
+
1389
+ MEMO by horinouchi: shuffling filter was also effective for float
1390
+ variables in some test (demo5-netcdf4.rb).
1391
+ */
1392
+ int deflate_level;
1393
+ int deflate=1;
1394
+ /* Always set to non-zero:
1395
+ See https://www.unidata.ucar.edu/software/netcdf/docs/netcdf-c/nc_005fdef_005fvar_005fdeflate.html#nc_005fdef_005fvar_005fdeflate
1396
+ If non-zero, turn on the deflate filter at the
1397
+ level specified by the deflate_level parameter.
1398
+ */
1399
+
1400
+ if (argc>2 || argc<1) rb_raise(rb_eArgError,
1401
+ "wrong # of arguments (%d). It must be 1 or 2", argc);
1402
+
1403
+ Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1404
+ ncid = Netcdf_var->ncid;
1405
+ varid = Netcdf_var->varid;
1406
+
1407
+ deflate_level = NUM2INT(argv[0]);
1408
+
1409
+ if (argc==1) {
1410
+ shuffle = 0; /* default: false */
1411
+ } else {
1412
+ if ( argv[1] == Qnil || argv[1] == Qfalse ) {
1413
+ shuffle = 0;
1414
+ } else {
1415
+ shuffle = 1;
1416
+ }
1417
+ }
1418
+
1419
+ status = nc_def_var_deflate(ncid, varid, shuffle, deflate, deflate_level);
1420
+ if(status != NC_NOERR) NC_RAISE(status);
1421
+
1422
+ return(Var);
1423
+ }
1424
+
1425
+ VALUE
1426
+ NetCDF_var_deflate_params(VALUE Var)
1427
+ {
1428
+ int ncid, varid, status;
1429
+ struct NetCDFVar *Netcdf_var;
1430
+ int shufflep, deflatep, deflate_levelp;
1431
+ VALUE sh, df, params;
1432
+
1433
+ Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1434
+ ncid = Netcdf_var->ncid;
1435
+ varid = Netcdf_var->varid;
1436
+ status = nc_inq_var_deflate(ncid, varid, &shufflep, &deflatep,
1437
+ &deflate_levelp);
1438
+ if(status != NC_NOERR) NC_RAISE(status);
1439
+ if (shufflep==0) {sh=Qfalse;} else {sh=Qtrue;}
1440
+ if (deflatep==0) {df=Qfalse;} else {df=Qtrue;}
1441
+ params = rb_ary_new3(3, sh, df, INT2NUM(deflate_levelp) );
1442
+ return(params);
1443
+ }
1444
+
1445
+ VALUE
1446
+ NetCDF_var_set_endian(VALUE Var, VALUE endian)
1447
+ {
1448
+ int ncid, varid, status;
1449
+ struct NetCDFVar *Netcdf_var;
1450
+
1451
+ Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1452
+ ncid = Netcdf_var->ncid;
1453
+ varid = Netcdf_var->varid;
1454
+ status = nc_def_var_endian(ncid, varid, NUM2INT(endian));
1455
+ if(status != NC_NOERR) NC_RAISE(status);
1456
+ return(Var);
1457
+ }
1458
+
1459
+ VALUE
1460
+ NetCDF_var_endian(VALUE Var)
1461
+ {
1462
+ int ncid, varid, status;
1463
+ struct NetCDFVar *Netcdf_var;
1464
+ int endian;
1465
+
1466
+ Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1467
+ ncid = Netcdf_var->ncid;
1468
+ varid = Netcdf_var->varid;
1469
+ status = nc_inq_var_endian(ncid, varid, &endian);
1470
+ if(status != NC_NOERR) NC_RAISE(status);
1471
+ return(INT2FIX(endian));
1472
+ }
1473
+
1474
+ #endif
1475
+
1357
1476
  VALUE
1358
1477
  NetCDF_var_id2att(VALUE Var,VALUE attnum)
1359
1478
  {
@@ -1446,7 +1565,7 @@ NetCDF_att_copy(VALUE Att,VALUE Var_or_File)
1446
1565
  struct Netcdf *ncfile;
1447
1566
  struct NetCDFAtt *Netcdf_att_out;
1448
1567
 
1449
- rb_secure(4);
1568
+ rb_secure(3);
1450
1569
  Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
1451
1570
  ncid_in=Netcdf_att->ncid;
1452
1571
  varid_in=Netcdf_att->varid;
@@ -1523,7 +1642,7 @@ NetCDF_att_delete(VALUE Att)
1523
1642
  char *c_att_name;
1524
1643
  struct NetCDFAtt *Netcdf_att;
1525
1644
 
1526
- rb_secure(4);
1645
+ rb_secure(3);
1527
1646
  Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
1528
1647
 
1529
1648
  ncid=Netcdf_att->ncid;
@@ -1545,7 +1664,7 @@ NetCDF_att_put(VALUE Att,VALUE value,VALUE atttype)
1545
1664
  {
1546
1665
  struct NetCDFAtt *ncatt;
1547
1666
 
1548
- rb_secure(4);
1667
+ rb_secure(3);
1549
1668
  Data_Get_Struct(Att,struct NetCDFAtt,ncatt);
1550
1669
  return( NetCDF_put_att__(ncatt->ncid, ncatt->name, value,
1551
1670
  atttype, ncatt->varid) );
@@ -1561,7 +1680,7 @@ NetCDF_att_get(VALUE Att)
1561
1680
  struct NetCDFAtt *Netcdf_att;
1562
1681
  nc_type xtypep;
1563
1682
  size_t lenp;
1564
- int attlen[1]; /* NArray uses int instead of size_t */
1683
+ na_shape_t attlen[1]; /* NArray uses int instead of size_t */
1565
1684
  char *tp;
1566
1685
  unsigned char *up;
1567
1686
  short *sp;
@@ -1788,7 +1907,7 @@ NetCDF_var_rename(VALUE Var,VALUE var_new_name)
1788
1907
  char *c_var_new_name;
1789
1908
  struct NetCDFVar *Netcdf_var;
1790
1909
 
1791
- rb_secure(4);
1910
+ rb_secure(3);
1792
1911
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1793
1912
  ncid=Netcdf_var->ncid;
1794
1913
  varid=Netcdf_var->varid;
@@ -1937,7 +2056,7 @@ NetCDF_get_var_char(VALUE Var)
1937
2056
  int ndimsp;
1938
2057
  int *dimids;
1939
2058
  size_t lengthp;
1940
- int *shape; /* NArray uses int instead of size_t */
2059
+ na_shape_t *shape; /* NArray uses int instead of size_t */
1941
2060
  VALUE NArray;
1942
2061
 
1943
2062
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -1947,7 +2066,7 @@ NetCDF_get_var_char(VALUE Var)
1947
2066
  if(status != NC_NOERR) NC_RAISE(status);
1948
2067
  dimids = ALLOCA_N(int,ndimsp);
1949
2068
  if (ndimsp != 0){
1950
- shape = ALLOCA_N(int,ndimsp);
2069
+ shape = ALLOCA_N(na_shape_t,ndimsp);
1951
2070
  for(i=0;i<ndimsp;i++){
1952
2071
  status = nc_inq_vardimid(ncid,varid,dimids);
1953
2072
  if(status != NC_NOERR) NC_RAISE(status);
@@ -1956,7 +2075,7 @@ NetCDF_get_var_char(VALUE Var)
1956
2075
  }
1957
2076
  } else {
1958
2077
  ndimsp = 1;
1959
- shape = ALLOCA_N(int,1);
2078
+ shape = ALLOCA_N(na_shape_t,1);
1960
2079
  shape[0]=1;
1961
2080
  }
1962
2081
 
@@ -1981,7 +2100,7 @@ NetCDF_get_var_byte(VALUE Var)
1981
2100
  int ndimsp;
1982
2101
  int *dimids;
1983
2102
  size_t lengthp;
1984
- int *shape; /* NArray uses int instead of size_t */
2103
+ na_shape_t *shape; /* NArray uses int instead of size_t */
1985
2104
  VALUE NArray;
1986
2105
 
1987
2106
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -1991,7 +2110,7 @@ NetCDF_get_var_byte(VALUE Var)
1991
2110
  if(status != NC_NOERR) NC_RAISE(status);
1992
2111
  dimids = ALLOCA_N(int,ndimsp);
1993
2112
  if (ndimsp != 0){
1994
- shape = ALLOCA_N(int,ndimsp);
2113
+ shape = ALLOCA_N(na_shape_t,ndimsp);
1995
2114
  for(i=0;i<ndimsp;i++){
1996
2115
  status = nc_inq_vardimid(ncid,varid,dimids);
1997
2116
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2000,7 +2119,7 @@ NetCDF_get_var_byte(VALUE Var)
2000
2119
  }
2001
2120
  } else {
2002
2121
  ndimsp = 1;
2003
- shape = ALLOCA_N(int,1);
2122
+ shape = ALLOCA_N(na_shape_t,1);
2004
2123
  shape[0]=1;
2005
2124
  }
2006
2125
 
@@ -2025,7 +2144,7 @@ NetCDF_get_var_sint(VALUE Var)
2025
2144
  int ndimsp;
2026
2145
  int *dimids;
2027
2146
  size_t lengthp;
2028
- int *shape; /* NArray uses int instead of size_t */
2147
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2029
2148
  VALUE NArray;
2030
2149
 
2031
2150
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2035,7 +2154,7 @@ NetCDF_get_var_sint(VALUE Var)
2035
2154
  if(status != NC_NOERR) NC_RAISE(status);
2036
2155
  dimids = ALLOCA_N(int,ndimsp);
2037
2156
  if (ndimsp != 0){
2038
- shape = ALLOCA_N(int,ndimsp);
2157
+ shape = ALLOCA_N(na_shape_t,ndimsp);
2039
2158
  for(i=0;i<ndimsp;i++){
2040
2159
  status = nc_inq_vardimid(ncid,varid,dimids);
2041
2160
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2044,7 +2163,7 @@ NetCDF_get_var_sint(VALUE Var)
2044
2163
  }
2045
2164
  } else {
2046
2165
  ndimsp = 1;
2047
- shape = ALLOCA_N(int,1);
2166
+ shape = ALLOCA_N(na_shape_t,1);
2048
2167
  shape[0]=1;
2049
2168
  }
2050
2169
 
@@ -2069,7 +2188,7 @@ NetCDF_get_var_int(VALUE Var)
2069
2188
  int ndimsp;
2070
2189
  int *dimids;
2071
2190
  size_t lengthp;
2072
- int *shape; /* NArray uses int instead of size_t */
2191
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2073
2192
  VALUE NArray;
2074
2193
 
2075
2194
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2079,7 +2198,7 @@ NetCDF_get_var_int(VALUE Var)
2079
2198
  if(status != NC_NOERR) NC_RAISE(status);
2080
2199
  dimids = ALLOCA_N(int,ndimsp);
2081
2200
  if (ndimsp != 0){
2082
- shape = ALLOCA_N(int,ndimsp);
2201
+ shape = ALLOCA_N(na_shape_t,ndimsp);
2083
2202
  for(i=0;i<ndimsp;i++){
2084
2203
  status = nc_inq_vardimid(ncid,varid,dimids);
2085
2204
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2088,7 +2207,7 @@ NetCDF_get_var_int(VALUE Var)
2088
2207
  }
2089
2208
  } else {
2090
2209
  ndimsp = 1;
2091
- shape = ALLOCA_N(int,1);
2210
+ shape = ALLOCA_N(na_shape_t,1);
2092
2211
  shape[0]=1;
2093
2212
  }
2094
2213
 
@@ -2113,7 +2232,7 @@ NetCDF_get_var_float(VALUE Var)
2113
2232
  int ndimsp;
2114
2233
  int *dimids;
2115
2234
  size_t lengthp;
2116
- int *shape; /* NArray uses int instead of size_t */
2235
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2117
2236
  VALUE NArray;
2118
2237
 
2119
2238
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2123,7 +2242,7 @@ NetCDF_get_var_float(VALUE Var)
2123
2242
  if(status != NC_NOERR) NC_RAISE(status);
2124
2243
  dimids = ALLOCA_N(int,ndimsp);
2125
2244
  if (ndimsp != 0){
2126
- shape = ALLOCA_N(int,ndimsp);
2245
+ shape = ALLOCA_N(na_shape_t,ndimsp);
2127
2246
  for(i=0;i<ndimsp;i++){
2128
2247
  status = nc_inq_vardimid(ncid,varid,dimids);
2129
2248
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2132,7 +2251,7 @@ NetCDF_get_var_float(VALUE Var)
2132
2251
  }
2133
2252
  } else {
2134
2253
  ndimsp = 1;
2135
- shape = ALLOCA_N(int,1);
2254
+ shape = ALLOCA_N(na_shape_t,1);
2136
2255
  shape[0]=1;
2137
2256
  }
2138
2257
 
@@ -2157,7 +2276,7 @@ NetCDF_get_var_double(VALUE Var)
2157
2276
  int ndimsp;
2158
2277
  int *dimids;
2159
2278
  size_t lengthp;
2160
- int *shape; /* NArray uses int instead of size_t */
2279
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2161
2280
  VALUE NArray;
2162
2281
 
2163
2282
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2167,7 +2286,7 @@ NetCDF_get_var_double(VALUE Var)
2167
2286
  if(status != NC_NOERR) NC_RAISE(status);
2168
2287
  dimids = ALLOCA_N(int,ndimsp);
2169
2288
  if (ndimsp != 0){
2170
- shape = ALLOCA_N(int,ndimsp);
2289
+ shape = ALLOCA_N(na_shape_t,ndimsp);
2171
2290
  for(i=0;i<ndimsp;i++){
2172
2291
  status = nc_inq_vardimid(ncid,varid,dimids);
2173
2292
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2176,7 +2295,7 @@ NetCDF_get_var_double(VALUE Var)
2176
2295
  }
2177
2296
  } else {
2178
2297
  ndimsp = 1;
2179
- shape = ALLOCA_N(int,1);
2298
+ shape = ALLOCA_N(na_shape_t,1);
2180
2299
  shape[0]=1;
2181
2300
  }
2182
2301
 
@@ -2198,13 +2317,12 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
2198
2317
  unsigned char *ptr;
2199
2318
  int i;
2200
2319
  struct NetCDFVar *Netcdf_var;
2201
- long l_start;
2320
+ na_shape_t l_start;
2202
2321
  size_t *c_start;
2203
2322
  int ndims;
2204
2323
  int dimids[NC_MAX_DIMS];
2205
2324
  size_t dimlen;
2206
- int *c_count;
2207
- int nc_tlen=0;
2325
+ na_shape_t *c_count;
2208
2326
  VALUE NArray;
2209
2327
 
2210
2328
 
@@ -2223,7 +2341,7 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
2223
2341
  }
2224
2342
 
2225
2343
  c_start=ALLOCA_N(size_t,ndims);
2226
- c_count=ALLOCA_N(int,ndims);
2344
+ c_count=ALLOCA_N(na_shape_t,ndims);
2227
2345
  for(i=0;i<ndims;i++){
2228
2346
  l_start = NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2229
2347
  status = nc_inq_vardimid(ncid,varid,dimids);
@@ -2236,7 +2354,6 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
2236
2354
  c_start[i]=l_start;
2237
2355
 
2238
2356
  c_count[i]=1;
2239
- nc_tlen = 1+nc_tlen;
2240
2357
  }
2241
2358
 
2242
2359
 
@@ -2260,13 +2377,12 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
2260
2377
  unsigned char *ptr;
2261
2378
  int i;
2262
2379
  struct NetCDFVar *Netcdf_var;
2263
- long l_start;
2380
+ na_shape_t l_start;
2264
2381
  size_t *c_start;
2265
2382
  int ndims;
2266
2383
  int dimids[NC_MAX_DIMS];
2267
2384
  size_t dimlen;
2268
- int *c_count;
2269
- int nc_tlen=0;
2385
+ na_shape_t *c_count;
2270
2386
  VALUE NArray;
2271
2387
 
2272
2388
 
@@ -2285,7 +2401,7 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
2285
2401
  }
2286
2402
 
2287
2403
  c_start=ALLOCA_N(size_t,ndims);
2288
- c_count=ALLOCA_N(int,ndims);
2404
+ c_count=ALLOCA_N(na_shape_t,ndims);
2289
2405
  for(i=0;i<ndims;i++){
2290
2406
  l_start = NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2291
2407
  status = nc_inq_vardimid(ncid,varid,dimids);
@@ -2298,7 +2414,6 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
2298
2414
  c_start[i]=l_start;
2299
2415
 
2300
2416
  c_count[i]=1;
2301
- nc_tlen = 1+nc_tlen;
2302
2417
  }
2303
2418
 
2304
2419
 
@@ -2322,13 +2437,12 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
2322
2437
  short *ptr;
2323
2438
  int i;
2324
2439
  struct NetCDFVar *Netcdf_var;
2325
- long l_start;
2440
+ na_shape_t l_start;
2326
2441
  size_t *c_start;
2327
2442
  int ndims;
2328
2443
  int dimids[NC_MAX_DIMS];
2329
2444
  size_t dimlen;
2330
- int *c_count;
2331
- int nc_tlen=0;
2445
+ na_shape_t *c_count;
2332
2446
  VALUE NArray;
2333
2447
 
2334
2448
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2346,7 +2460,7 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
2346
2460
  }
2347
2461
 
2348
2462
  c_start=ALLOCA_N(size_t,ndims);
2349
- c_count=ALLOCA_N(int,ndims);
2463
+ c_count=ALLOCA_N(na_shape_t,ndims);
2350
2464
  for(i=0;i<ndims;i++){
2351
2465
  l_start = NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2352
2466
  status = nc_inq_vardimid(ncid,varid,dimids);
@@ -2358,7 +2472,6 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
2358
2472
  }
2359
2473
  c_start[i]=l_start;
2360
2474
  c_count[i]=1;
2361
- nc_tlen = nc_tlen+1;
2362
2475
  }
2363
2476
 
2364
2477
  Csint_to_NArray(NArray,ndims,c_count,ptr);
@@ -2380,13 +2493,12 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
2380
2493
  int *ptr;
2381
2494
  int i;
2382
2495
  struct NetCDFVar *Netcdf_var;
2383
- long l_start;
2496
+ na_shape_t l_start;
2384
2497
  size_t *c_start;
2385
2498
  int ndims;
2386
2499
  int dimids[NC_MAX_DIMS];
2387
2500
  size_t dimlen;
2388
- int *c_count;
2389
- int nc_tlen=0;
2501
+ na_shape_t *c_count;
2390
2502
  VALUE NArray;
2391
2503
 
2392
2504
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2404,7 +2516,7 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
2404
2516
  }
2405
2517
 
2406
2518
  c_start=ALLOCA_N(size_t,ndims);
2407
- c_count=ALLOCA_N(int,ndims);
2519
+ c_count=ALLOCA_N(na_shape_t,ndims);
2408
2520
  for(i=0;i<ndims;i++){
2409
2521
  l_start = NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2410
2522
  status = nc_inq_vardimid(ncid,varid,dimids);
@@ -2416,7 +2528,6 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
2416
2528
  }
2417
2529
  c_start[i]=l_start;
2418
2530
  c_count[i]=1;
2419
- nc_tlen= nc_tlen+1;
2420
2531
  }
2421
2532
 
2422
2533
  Clint_to_NArray(NArray,ndims,c_count,ptr);
@@ -2438,13 +2549,12 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
2438
2549
  float *ptr;
2439
2550
  int i;
2440
2551
  struct NetCDFVar *Netcdf_var;
2441
- long l_start;
2552
+ na_shape_t l_start;
2442
2553
  size_t *c_start;
2443
2554
  int ndims;
2444
2555
  int dimids[NC_MAX_DIMS];
2445
2556
  size_t dimlen;
2446
- int *c_count;
2447
- int nc_tlen=0;
2557
+ na_shape_t *c_count;
2448
2558
  VALUE NArray;
2449
2559
 
2450
2560
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2462,7 +2572,7 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
2462
2572
  }
2463
2573
 
2464
2574
  c_start=ALLOCA_N(size_t,ndims);
2465
- c_count=ALLOCA_N(int,ndims);
2575
+ c_count=ALLOCA_N(na_shape_t,ndims);
2466
2576
  for(i=0;i<ndims;i++){
2467
2577
  l_start = NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2468
2578
  status = nc_inq_vardimid(ncid, varid, dimids);
@@ -2474,7 +2584,6 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
2474
2584
  }
2475
2585
  c_start[i]=l_start;
2476
2586
  c_count[i]=1;
2477
- nc_tlen = nc_tlen+1;
2478
2587
  }
2479
2588
 
2480
2589
  Cfloat_to_NArray(NArray,ndims,c_count,ptr);
@@ -2496,13 +2605,12 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
2496
2605
  double *ptr;
2497
2606
  int i;
2498
2607
  struct NetCDFVar *Netcdf_var;
2499
- long l_start;
2608
+ na_shape_t l_start;
2500
2609
  size_t *c_start;
2501
2610
  int ndims;
2502
2611
  int dimids[NC_MAX_DIMS];
2503
2612
  size_t dimlen;
2504
- int *c_count;
2505
- int nc_tlen=0;
2613
+ na_shape_t *c_count;
2506
2614
  VALUE NArray;
2507
2615
 
2508
2616
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -2520,7 +2628,7 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
2520
2628
  }
2521
2629
 
2522
2630
  c_start=ALLOCA_N(size_t,ndims);
2523
- c_count=ALLOCA_N(int,ndims);
2631
+ c_count=ALLOCA_N(na_shape_t,ndims);
2524
2632
  for(i=0;i<ndims;i++){
2525
2633
  l_start = NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2526
2634
  status = nc_inq_vardimid(ncid,varid,dimids);
@@ -2532,7 +2640,6 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
2532
2640
  }
2533
2641
  c_start[i]=l_start;
2534
2642
  c_count[i]=1;
2535
- nc_tlen = nc_tlen+1;
2536
2643
  }
2537
2644
 
2538
2645
  Cdouble_to_NArray(NArray,ndims,c_count,ptr);
@@ -2554,14 +2661,13 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
2554
2661
  unsigned char *ptr;
2555
2662
  int i;
2556
2663
  struct NetCDFVar *Netcdf_var;
2557
- long l_start, l_end;
2664
+ na_shape_t l_start, l_end;
2558
2665
  size_t *c_start;
2559
2666
  size_t *c_count;
2560
2667
  ptrdiff_t *c_stride;
2561
- int *shape; /* NArray uses int instead of size_t */
2668
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2562
2669
  int ndims;
2563
2670
  int *dimids;
2564
- int nc_tlen=1;
2565
2671
  size_t dimlen;
2566
2672
  VALUE NArray;
2567
2673
 
@@ -2638,12 +2744,9 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
2638
2744
  c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
2639
2745
  }
2640
2746
  }
2641
- for(i=0;i<ndims;i++){
2642
- nc_tlen = nc_tlen*c_count[i];
2643
- }
2644
2747
 
2645
2748
 
2646
- shape = ALLOCA_N(int,ndims);
2749
+ shape = ALLOCA_N(na_shape_t,ndims);
2647
2750
  for(i=0;i<ndims;i++){
2648
2751
  shape[ndims-1-i]=c_count[i];
2649
2752
  }
@@ -2666,14 +2769,13 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
2666
2769
  unsigned char *ptr;
2667
2770
  int i;
2668
2771
  struct NetCDFVar *Netcdf_var;
2669
- long l_start, l_end;
2772
+ na_shape_t l_start, l_end;
2670
2773
  size_t *c_start;
2671
2774
  size_t *c_count;
2672
2775
  ptrdiff_t *c_stride;
2673
- int *shape; /* NArray uses int instead of size_t */
2776
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2674
2777
  int ndims;
2675
2778
  int *dimids;
2676
- int nc_tlen=1;
2677
2779
  size_t dimlen;
2678
2780
  VALUE NArray;
2679
2781
 
@@ -2750,12 +2852,9 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
2750
2852
  c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
2751
2853
  }
2752
2854
  }
2753
- for(i=0;i<ndims;i++){
2754
- nc_tlen = nc_tlen*c_count[i];
2755
- }
2756
2855
 
2757
2856
 
2758
- shape = ALLOCA_N(int,ndims);
2857
+ shape = ALLOCA_N(na_shape_t,ndims);
2759
2858
  for(i=0;i<ndims;i++){
2760
2859
  shape[ndims-1-i]=c_count[i];
2761
2860
  }
@@ -2778,14 +2877,13 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
2778
2877
  short *ptr;
2779
2878
  int i;
2780
2879
  struct NetCDFVar *Netcdf_var;
2781
- long l_start, l_end;
2880
+ na_shape_t l_start, l_end;
2782
2881
  size_t *c_start;
2783
2882
  size_t *c_count;
2784
2883
  ptrdiff_t *c_stride;
2785
- int *shape; /* NArray uses int instead of size_t */
2884
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2786
2885
  int ndims;
2787
2886
  int *dimids;
2788
- int nc_tlen=1;
2789
2887
  size_t dimlen;
2790
2888
  VALUE NArray;
2791
2889
 
@@ -2863,11 +2961,8 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
2863
2961
  }
2864
2962
  }
2865
2963
 
2866
- for(i=0;i<ndims;i++){
2867
- nc_tlen = nc_tlen*c_count[i];
2868
- }
2869
2964
 
2870
- shape = ALLOCA_N(int,ndims);
2965
+ shape = ALLOCA_N(na_shape_t,ndims);
2871
2966
  for(i=0;i<ndims;i++){
2872
2967
  shape[ndims-1-i]=c_count[i];
2873
2968
  }
@@ -2891,14 +2986,13 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
2891
2986
  int *ptr;
2892
2987
  int i;
2893
2988
  struct NetCDFVar *Netcdf_var;
2894
- long l_start, l_end;
2989
+ na_shape_t l_start, l_end;
2895
2990
  size_t *c_start;
2896
2991
  size_t *c_count;
2897
2992
  ptrdiff_t *c_stride;
2898
- int *shape; /* NArray uses int instead of size_t */
2993
+ na_shape_t *shape; /* NArray uses int instead of size_t */
2899
2994
  int ndims;
2900
2995
  int *dimids;
2901
- int nc_tlen=1;
2902
2996
  size_t dimlen;
2903
2997
  VALUE NArray;
2904
2998
 
@@ -2976,11 +3070,8 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
2976
3070
  }
2977
3071
  }
2978
3072
 
2979
- for(i=0;i<ndims;i++){
2980
- nc_tlen = nc_tlen*c_count[i];
2981
- }
2982
3073
 
2983
- shape = ALLOCA_N(int,ndims);
3074
+ shape = ALLOCA_N(na_shape_t,ndims);
2984
3075
  for(i=0;i<ndims;i++){
2985
3076
  shape[ndims-1-i]=c_count[i];
2986
3077
  }
@@ -3004,14 +3095,13 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
3004
3095
  float *ptr;
3005
3096
  int i;
3006
3097
  struct NetCDFVar *Netcdf_var;
3007
- long l_start, l_end;
3098
+ na_shape_t l_start, l_end;
3008
3099
  size_t *c_start;
3009
3100
  size_t *c_count;
3010
3101
  ptrdiff_t *c_stride;
3011
- int *shape; /* NArray uses int instead of size_t */
3102
+ na_shape_t *shape; /* NArray uses int instead of size_t */
3012
3103
  int ndims;
3013
3104
  int *dimids;
3014
- int nc_tlen=1;
3015
3105
  size_t dimlen;
3016
3106
  VALUE NArray;
3017
3107
 
@@ -3089,11 +3179,8 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
3089
3179
  }
3090
3180
  }
3091
3181
 
3092
- for(i=0;i<ndims;i++){
3093
- nc_tlen = nc_tlen*c_count[i];
3094
- }
3095
3182
 
3096
- shape = ALLOCA_N(int,ndims);
3183
+ shape = ALLOCA_N(na_shape_t,ndims);
3097
3184
  for(i=0;i<ndims;i++){
3098
3185
  shape[ndims-1-i]=c_count[i];
3099
3186
  }
@@ -3117,14 +3204,13 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
3117
3204
  double *ptr;
3118
3205
  int i;
3119
3206
  struct NetCDFVar *Netcdf_var;
3120
- long l_start, l_end;
3207
+ na_shape_t l_start, l_end;
3121
3208
  size_t *c_start;
3122
3209
  size_t *c_count;
3123
3210
  ptrdiff_t *c_stride;
3124
- int *shape; /* NArray uses int instead of size_t */
3211
+ na_shape_t *shape; /* NArray uses int instead of size_t */
3125
3212
  int ndims;
3126
3213
  int *dimids;
3127
- int nc_tlen=1;
3128
3214
  size_t dimlen;
3129
3215
  VALUE NArray;
3130
3216
 
@@ -3202,11 +3288,8 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
3202
3288
  }
3203
3289
  }
3204
3290
 
3205
- for(i=0;i<ndims;i++){
3206
- nc_tlen = nc_tlen*c_count[i];
3207
- }
3208
3291
 
3209
- shape = ALLOCA_N(int,ndims);
3292
+ shape = ALLOCA_N(na_shape_t,ndims);
3210
3293
  for(i=0;i<ndims;i++){
3211
3294
  shape[ndims-1-i]=c_count[i];
3212
3295
  }
@@ -3228,15 +3311,15 @@ NetCDF_put_var_char(VALUE Var,VALUE NArray)
3228
3311
  int varid;
3229
3312
  int status;
3230
3313
  unsigned char *ptr,scalar;
3231
- int len,i=0;
3314
+ na_shape_t len,i=0;
3232
3315
  struct NetCDFVar *Netcdf_var;
3233
- int nc_tlen=1;
3316
+ na_shape_t nc_tlen=1;
3234
3317
  int ndimsp;
3235
3318
  int dimids[NC_MAX_DIMS];
3236
3319
  size_t lengthp;
3237
3320
  char *var_name;
3238
3321
 
3239
- rb_secure(4);
3322
+ rb_secure(3);
3240
3323
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3241
3324
  ncid=Netcdf_var->ncid;
3242
3325
  varid=Netcdf_var->varid;
@@ -3273,15 +3356,15 @@ NetCDF_put_var_byte(VALUE Var,VALUE NArray)
3273
3356
  int varid;
3274
3357
  int status;
3275
3358
  unsigned char *ptr,scalar;
3276
- int len,i=0;
3359
+ na_shape_t len,i=0;
3277
3360
  struct NetCDFVar *Netcdf_var;
3278
- int nc_tlen=1;
3361
+ na_shape_t nc_tlen=1;
3279
3362
  int ndimsp;
3280
3363
  int dimids[NC_MAX_DIMS];
3281
3364
  size_t lengthp;
3282
3365
  char *var_name;
3283
3366
 
3284
- rb_secure(4);
3367
+ rb_secure(3);
3285
3368
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3286
3369
  ncid=Netcdf_var->ncid;
3287
3370
  varid=Netcdf_var->varid;
@@ -3318,15 +3401,15 @@ NetCDF_put_var_short(VALUE Var,VALUE NArray)
3318
3401
  int varid;
3319
3402
  int status;
3320
3403
  short *ptr,scalar;
3321
- int len,i=0;
3404
+ na_shape_t len,i=0;
3322
3405
  struct NetCDFVar *Netcdf_var;
3323
- int nc_tlen=1;
3406
+ na_shape_t nc_tlen=1;
3324
3407
  int ndimsp;
3325
3408
  int dimids[NC_MAX_DIMS];
3326
3409
  size_t lengthp;
3327
3410
  char *var_name;
3328
3411
 
3329
- rb_secure(4);
3412
+ rb_secure(3);
3330
3413
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3331
3414
  ncid=Netcdf_var->ncid;
3332
3415
  varid=Netcdf_var->varid;
@@ -3363,15 +3446,15 @@ NetCDF_put_var_int(VALUE Var,VALUE NArray)
3363
3446
  int varid;
3364
3447
  int status;
3365
3448
  int *ptr,scalar;
3366
- int len,i=0;
3449
+ na_shape_t len,i=0;
3367
3450
  struct NetCDFVar *Netcdf_var;
3368
- int nc_tlen=1;
3451
+ na_shape_t nc_tlen=1;
3369
3452
  int ndimsp;
3370
3453
  int dimids[NC_MAX_DIMS];
3371
3454
  size_t lengthp;
3372
3455
  char *var_name;
3373
3456
 
3374
- rb_secure(4);
3457
+ rb_secure(3);
3375
3458
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3376
3459
  ncid=Netcdf_var->ncid;
3377
3460
  varid=Netcdf_var->varid;
@@ -3411,16 +3494,16 @@ NetCDF_put_var_float(VALUE Var,VALUE NArray)
3411
3494
  int varid;
3412
3495
  int status;
3413
3496
  float *ptr,scalar;
3414
- int len,i=0;
3497
+ na_shape_t len,i=0;
3415
3498
  struct NetCDFVar *Netcdf_var;
3416
- int nc_tlen=1;
3499
+ na_shape_t nc_tlen=1;
3417
3500
  int ndimsp;
3418
3501
  int dimids[NC_MAX_DIMS];
3419
3502
  size_t lengthp;
3420
3503
  char *var_name;
3421
3504
 
3422
3505
 
3423
- rb_secure(4);
3506
+ rb_secure(3);
3424
3507
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3425
3508
  ncid=Netcdf_var->ncid;
3426
3509
  varid=Netcdf_var->varid;
@@ -3458,16 +3541,16 @@ NetCDF_put_var_double(VALUE Var,VALUE NArray)
3458
3541
  int varid;
3459
3542
  int status;
3460
3543
  double *ptr,scalar;
3461
- int len,i=0;
3544
+ na_shape_t len,i=0;
3462
3545
  struct NetCDFVar *Netcdf_var;
3463
- int nc_tlen=1;
3546
+ na_shape_t nc_tlen=1;
3464
3547
  int ndimsp;
3465
3548
  int dimids[NC_MAX_DIMS];
3466
3549
  size_t lengthp;
3467
3550
  char *var_name;
3468
3551
 
3469
3552
 
3470
- rb_secure(4);
3553
+ rb_secure(3);
3471
3554
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3472
3555
  ncid=Netcdf_var->ncid;
3473
3556
  varid=Netcdf_var->varid;
@@ -3507,13 +3590,13 @@ NetCDF_put_var1_char(VALUE Var,VALUE NArray,VALUE start)
3507
3590
  unsigned char *ptr;
3508
3591
  int i;
3509
3592
  struct NetCDFVar *Netcdf_var;
3510
- long l_start;
3593
+ na_shape_t l_start;
3511
3594
  size_t *c_start;
3512
3595
  int ndims;
3513
3596
  int *dimids;
3514
3597
  size_t dimlen;
3515
3598
 
3516
- rb_secure(4);
3599
+ rb_secure(3);
3517
3600
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3518
3601
  ncid=Netcdf_var->ncid;
3519
3602
  varid=Netcdf_var->varid;
@@ -3558,13 +3641,13 @@ NetCDF_put_var1_byte(VALUE Var,VALUE NArray,VALUE start)
3558
3641
  unsigned char *ptr;
3559
3642
  int i;
3560
3643
  struct NetCDFVar *Netcdf_var;
3561
- long l_start;
3644
+ na_shape_t l_start;
3562
3645
  size_t *c_start;
3563
3646
  int ndims;
3564
3647
  int *dimids;
3565
3648
  size_t dimlen;
3566
3649
 
3567
- rb_secure(4);
3650
+ rb_secure(3);
3568
3651
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3569
3652
  ncid=Netcdf_var->ncid;
3570
3653
  varid=Netcdf_var->varid;
@@ -3609,13 +3692,13 @@ NetCDF_put_var1_sint(VALUE Var,VALUE NArray,VALUE start)
3609
3692
  short *ptr;
3610
3693
  int i;
3611
3694
  struct NetCDFVar *Netcdf_var;
3612
- long l_start;
3695
+ na_shape_t l_start;
3613
3696
  size_t *c_start;
3614
3697
  int ndims;
3615
3698
  int *dimids;
3616
3699
  size_t dimlen;
3617
3700
 
3618
- rb_secure(4);
3701
+ rb_secure(3);
3619
3702
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3620
3703
  ncid=Netcdf_var->ncid;
3621
3704
  varid=Netcdf_var->varid;
@@ -3659,13 +3742,13 @@ NetCDF_put_var1_int(VALUE Var,VALUE NArray,VALUE start)
3659
3742
  int *ptr;
3660
3743
  int i;
3661
3744
  struct NetCDFVar *Netcdf_var;
3662
- long l_start;
3745
+ na_shape_t l_start;
3663
3746
  size_t *c_start;
3664
3747
  int ndims;
3665
3748
  int *dimids;
3666
3749
  size_t dimlen;
3667
3750
 
3668
- rb_secure(4);
3751
+ rb_secure(3);
3669
3752
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3670
3753
  ncid=Netcdf_var->ncid;
3671
3754
  varid=Netcdf_var->varid;
@@ -3710,13 +3793,13 @@ NetCDF_put_var1_float(VALUE Var,VALUE NArray,VALUE start)
3710
3793
  float *ptr;
3711
3794
  int i;
3712
3795
  struct NetCDFVar *Netcdf_var;
3713
- long l_start;
3796
+ na_shape_t l_start;
3714
3797
  size_t *c_start;
3715
3798
  int ndims;
3716
3799
  int *dimids;
3717
3800
  size_t dimlen;
3718
3801
 
3719
- rb_secure(4);
3802
+ rb_secure(3);
3720
3803
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3721
3804
  ncid=Netcdf_var->ncid;
3722
3805
  varid=Netcdf_var->varid;
@@ -3761,13 +3844,13 @@ NetCDF_put_var1_double(VALUE Var,VALUE NArray,VALUE start)
3761
3844
  double *ptr;
3762
3845
  int i;
3763
3846
  struct NetCDFVar *Netcdf_var;
3764
- long l_start;
3847
+ na_shape_t l_start;
3765
3848
  size_t *c_start;
3766
3849
  int ndims;
3767
3850
  int *dimids;
3768
3851
  size_t dimlen;
3769
3852
 
3770
- rb_secure(4);
3853
+ rb_secure(3);
3771
3854
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3772
3855
  ncid=Netcdf_var->ncid;
3773
3856
  varid=Netcdf_var->varid;
@@ -3811,19 +3894,19 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3811
3894
  int varid;
3812
3895
  int status;
3813
3896
  unsigned char *ptr,scalar;
3814
- int len,i;
3897
+ na_shape_t len;
3815
3898
  int c_count_all=1;
3816
3899
  struct NetCDFVar *Netcdf_var;
3817
- long l_start, l_end;
3900
+ na_shape_t l_start, l_end;
3818
3901
  size_t *c_start;
3819
3902
  size_t *c_count;
3820
3903
  ptrdiff_t *c_stride;
3821
- int ndims;
3822
- int *shape;
3904
+ int ndims,i;
3905
+ na_shape_t *shape;
3823
3906
  int *dimids;
3824
3907
  size_t dimlen;
3825
3908
 
3826
- rb_secure(4);
3909
+ rb_secure(3);
3827
3910
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3828
3911
  ncid=Netcdf_var->ncid;
3829
3912
  varid=Netcdf_var->varid;
@@ -3917,19 +4000,19 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3917
4000
  int varid;
3918
4001
  int status;
3919
4002
  unsigned char *ptr,scalar;
3920
- int len,i;
4003
+ na_shape_t len;
3921
4004
  int c_count_all=1;
3922
4005
  struct NetCDFVar *Netcdf_var;
3923
- long l_start, l_end;
4006
+ na_shape_t l_start, l_end;
3924
4007
  size_t *c_start;
3925
4008
  size_t *c_count;
3926
4009
  ptrdiff_t *c_stride;
3927
- int ndims;
3928
- int *shape;
4010
+ int ndims,i;
4011
+ na_shape_t *shape;
3929
4012
  int *dimids;
3930
4013
  size_t dimlen;
3931
4014
 
3932
- rb_secure(4);
4015
+ rb_secure(3);
3933
4016
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3934
4017
  ncid=Netcdf_var->ncid;
3935
4018
  varid=Netcdf_var->varid;
@@ -4023,19 +4106,19 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4023
4106
  int varid;
4024
4107
  int status;
4025
4108
  short *ptr,scalar;
4026
- int len,i;
4109
+ na_shape_t len;
4027
4110
  int c_count_all=1;
4028
4111
  struct NetCDFVar *Netcdf_var;
4029
- long l_start, l_end;
4112
+ na_shape_t l_start, l_end;
4030
4113
  size_t *c_start;
4031
4114
  size_t *c_count;
4032
4115
  ptrdiff_t *c_stride;
4033
- int ndims;
4034
- int *shape;
4116
+ int ndims,i;
4117
+ na_shape_t *shape;
4035
4118
  int *dimids;
4036
4119
  size_t dimlen;
4037
4120
 
4038
- rb_secure(4);
4121
+ rb_secure(3);
4039
4122
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4040
4123
  ncid=Netcdf_var->ncid;
4041
4124
  varid=Netcdf_var->varid;
@@ -4130,19 +4213,19 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4130
4213
  int varid;
4131
4214
  int status;
4132
4215
  int *ptr,scalar;
4133
- int len,i;
4216
+ na_shape_t len;
4134
4217
  int c_count_all=1;
4135
4218
  struct NetCDFVar *Netcdf_var;
4136
- long l_start, l_end;
4219
+ na_shape_t l_start, l_end;
4137
4220
  size_t *c_start;
4138
4221
  size_t *c_count;
4139
4222
  ptrdiff_t *c_stride;
4140
- int ndims;
4141
- int *shape;
4223
+ int ndims,i;
4224
+ na_shape_t *shape;
4142
4225
  int *dimids;
4143
4226
  size_t dimlen;
4144
4227
 
4145
- rb_secure(4);
4228
+ rb_secure(3);
4146
4229
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4147
4230
  ncid=Netcdf_var->ncid;
4148
4231
  varid=Netcdf_var->varid;
@@ -4237,19 +4320,19 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4237
4320
  int varid;
4238
4321
  int status;
4239
4322
  float *ptr,scalar;
4240
- int len,i;
4323
+ na_shape_t len;
4241
4324
  int c_count_all=1;
4242
4325
  struct NetCDFVar *Netcdf_var;
4243
- long l_start, l_end;
4326
+ na_shape_t l_start, l_end;
4244
4327
  size_t *c_start;
4245
4328
  size_t *c_count;
4246
4329
  ptrdiff_t *c_stride;
4247
- int ndims;
4248
- int *shape;
4330
+ int ndims,i;
4331
+ na_shape_t *shape;
4249
4332
  int *dimids;
4250
4333
  size_t dimlen;
4251
4334
 
4252
- rb_secure(4);
4335
+ rb_secure(3);
4253
4336
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4254
4337
  ncid=Netcdf_var->ncid;
4255
4338
  varid=Netcdf_var->varid;
@@ -4344,19 +4427,19 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
4344
4427
  int varid;
4345
4428
  int status;
4346
4429
  double *ptr,scalar;
4347
- int len,i;
4430
+ na_shape_t len;
4348
4431
  int c_count_all=1;
4349
4432
  struct NetCDFVar *Netcdf_var;
4350
- long l_start, l_end;
4433
+ na_shape_t l_start, l_end;
4351
4434
  size_t *c_start;
4352
4435
  size_t *c_count;
4353
4436
  ptrdiff_t *c_stride;
4354
- int ndims;
4355
- int *shape;
4437
+ int ndims,i;
4438
+ na_shape_t *shape;
4356
4439
  int *dimids;
4357
4440
  size_t dimlen;
4358
4441
 
4359
- rb_secure(4);
4442
+ rb_secure(3);
4360
4443
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4361
4444
  ncid=Netcdf_var->ncid;
4362
4445
  varid=Netcdf_var->varid;
@@ -4498,9 +4581,27 @@ Init_netcdfraw(void)
4498
4581
  rb_define_const(cNetCDF, "NC_SHARE", INT2FIX(NC_SHARE));
4499
4582
  rb_define_const(cNetCDF, "NC_CLOBBER", INT2FIX(NC_CLOBBER));
4500
4583
  rb_define_const(cNetCDF, "NC_NOCLOBBER", INT2FIX(NC_NOCLOBBER));
4584
+ #if NCVER >= 400
4585
+ rb_define_const(cNetCDF, "NC_64BIT_OFFSET", INT2FIX(NC_64BIT_OFFSET));
4586
+ /* NC_64BIT_OFFSET supports large files in the class data format */
4587
+ rb_define_const(cNetCDF, "NC_NETCDF4", INT2FIX(NC_NETCDF4));
4588
+ rb_define_const(cNetCDF, "NC_CLASSIC_MODEL", INT2FIX(NC_CLASSIC_MODEL));
4589
+ /* for use as ( NC_NETCDF4 | NC_CLASSIC_MODEL ) to ensure the classic
4590
+ data model in NetCDF4 by disabling new features like groups */
4591
+ rb_define_const(cNetCDF, "NC_ENDIAN_NATIVE", INT2FIX(NC_ENDIAN_NATIVE));
4592
+ rb_define_const(cNetCDF, "NC_ENDIAN_LITTLE", INT2FIX(NC_ENDIAN_LITTLE));
4593
+ rb_define_const(cNetCDF, "NC_ENDIAN_BIG", INT2FIX(NC_ENDIAN_BIG));
4594
+ #endif
4595
+
4596
+ #ifdef NARRAY_BIGMEM
4597
+ rb_define_const(cNetCDF, "SUPPORT_BIGMEM", Qtrue);
4598
+ #else
4599
+ rb_define_const(cNetCDF, "SUPPORT_BIGMEM", Qfalse);
4600
+ #endif
4501
4601
 
4502
4602
  /* Difinitions of the ruby methods */
4503
4603
  /* The methods of the NetCDF class */
4604
+ rb_define_singleton_method(cNetCDF,"libvers",NetCDF_inq_libvers,0);
4504
4605
  rb_define_singleton_method(cNetCDF,"nc_open",NetCDF_open,2);
4505
4606
  rb_define_method(cNetCDF,"clone",NetCDF_clone,0);
4506
4607
  rb_define_method(cNetCDF,"close",NetCDF_close,0);
@@ -4551,6 +4652,12 @@ Init_netcdfraw(void)
4551
4652
  rb_define_method(cNetCDFAtt,"get",NetCDF_att_get,0);
4552
4653
 
4553
4654
  /* The methods of the NetCDFVar class */
4655
+ #if NCVER >= 400
4656
+ rb_define_method(cNetCDFVar,"deflate",NetCDF_var_deflate,-1);
4657
+ rb_define_method(cNetCDFVar,"deflate_params",NetCDF_var_deflate_params,0);
4658
+ rb_define_method(cNetCDFVar,"endian=",NetCDF_var_set_endian,1);
4659
+ rb_define_method(cNetCDFVar,"endian",NetCDF_var_endian,0);
4660
+ #endif
4554
4661
  rb_define_method(cNetCDFVar,"clone",NetCDF_var_clone,0);
4555
4662
  rb_define_method(cNetCDFVar,"name",NetCDF_var_inq_name,0);
4556
4663
  rb_define_method(cNetCDFVar,"ndims",NetCDF_var_ndims,0);