ruby-netcdf 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -198,7 +198,7 @@ typedef int na_shape_t;
198
198
  obj = na_cast_object(obj, NA_SINT); \
199
199
  GetNArray(obj, na); \
200
200
  ptr = (int16_t *) NA_PTR(na,0); \
201
- }
201
+ }
202
202
  #define Array_to_Clint(obj, ptr) \
203
203
  { \
204
204
  struct NARRAY *na; \
@@ -257,7 +257,7 @@ static VALUE rb_eNetcdfFatal;
257
257
  static VALUE rb_eNetcdfEntool;
258
258
  static VALUE rb_eNetcdfExdr;
259
259
  static VALUE rb_eNetcdfSyserr;
260
-
260
+
261
261
 
262
262
  struct Netcdf{
263
263
  int ncid;
@@ -290,7 +290,7 @@ NetCDF_init(int ncid,char *filename)
290
290
  Netcdffile->ncid=ncid;
291
291
  Netcdffile->closed=0;
292
292
  Netcdffile->name=xmalloc((strlen(filename)+1)*sizeof(char));
293
- strcpy(Netcdffile->name,filename);
293
+ strcpy(Netcdffile->name,filename);
294
294
  return(Netcdffile);
295
295
  }
296
296
 
@@ -322,7 +322,7 @@ NetCDF_att_init(int ncid,int varid,char *attname)
322
322
  Netcdf_att->ncid=ncid;
323
323
  Netcdf_att->varid=varid;
324
324
  Netcdf_att->name=xmalloc((strlen(attname)+1)*sizeof(char));
325
- strcpy(Netcdf_att->name,attname);
325
+ strcpy(Netcdf_att->name,attname);
326
326
  return(Netcdf_att);
327
327
  }
328
328
 
@@ -351,7 +351,7 @@ NetCDF_free(struct Netcdf *Netcdffile)
351
351
  if (!Netcdffile->closed){
352
352
  nc_close(Netcdffile->ncid); /* no error check -- not to stop during GC */
353
353
  }
354
- free(Netcdffile->name);
354
+ free(Netcdffile->name);
355
355
  free(Netcdffile);
356
356
  }
357
357
 
@@ -576,14 +576,11 @@ NetCDF_close(file)
576
576
  int ncid;
577
577
  struct Netcdf *Netcdffile;
578
578
 
579
- if (rb_safe_level() >= 3 && !OBJ_TAINTED(file)) {
580
- rb_raise(rb_eSecurityError, "Insecure: can't close");
581
- }
582
579
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
583
580
  ncid=Netcdffile->ncid;
584
581
  if(!Netcdffile->closed){
585
582
  status = nc_close(ncid);
586
- if(status != NC_NOERR) NC_RAISE(status);
583
+ if(status != NC_NOERR) NC_RAISE(status);
587
584
  Netcdffile->closed = 1;
588
585
  } else {
589
586
  rb_warn("file %s is already closed", Netcdffile->name);
@@ -602,10 +599,9 @@ NetCDF_def_dim(VALUE file,VALUE dim_name,VALUE length)
602
599
  struct Netcdf *Netcdffile;
603
600
  struct NetCDFDim *Netcdf_dim;
604
601
  VALUE Dimension;
605
-
606
- rb_secure(3);
602
+
607
603
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
608
-
604
+
609
605
  Check_Type(dim_name,T_STRING);
610
606
  c_dim_name=RSTRING_PTR(dim_name);
611
607
  c_length=NUM2UINT(length);
@@ -696,19 +692,19 @@ NetCDF_put_att_numeric(int ncid, char *name,VALUE value,VALUE atttype, int varid
696
692
  len = na_val->total;
697
693
  ptr = na_val->ptr;
698
694
  switch(na_typecode){
699
- case NA_BYTE:
695
+ case NA_BYTE:
700
696
  status = nc_put_att_uchar(ncid,varid,name,NC_BYTE,len,(unsigned char *)ptr);
701
697
  break;
702
- case NA_SINT:
698
+ case NA_SINT:
703
699
  status = nc_put_att_short(ncid,varid,name,NC_SHORT,len,(short *)ptr);
704
700
  break;
705
- case NA_LINT:
701
+ case NA_LINT:
706
702
  status = nc_put_att_int(ncid,varid,name,NC_INT,len,(int *)ptr);
707
703
  break;
708
- case NA_SFLOAT:
704
+ case NA_SFLOAT:
709
705
  status = nc_put_att_float(ncid,varid,name,NC_FLOAT,len,(float *)ptr);
710
706
  break;
711
- case NA_DFLOAT:
707
+ case NA_DFLOAT:
712
708
  status = nc_put_att_double(ncid,varid,name,NC_DOUBLE,len,(double*)ptr);
713
709
  break;
714
710
  default:
@@ -746,7 +742,6 @@ NetCDF_put_att(VALUE file,VALUE att_name,VALUE value,VALUE atttype)
746
742
  struct Netcdf *ncfile;
747
743
  char *name;
748
744
 
749
- rb_secure(3);
750
745
  Data_Get_Struct(file,struct Netcdf,ncfile);
751
746
  Check_Type(att_name,T_STRING);
752
747
  name = RSTRING_PTR(att_name);
@@ -764,7 +759,6 @@ NetCDF_put_att_var(VALUE var,VALUE att_name,VALUE value,VALUE atttype)
764
759
  struct NetCDFVar *ncvar;
765
760
  char *name;
766
761
 
767
- rb_secure(3);
768
762
  Data_Get_Struct(var,struct NetCDFVar,ncvar);
769
763
  Check_Type(att_name,T_STRING);
770
764
  name = RSTRING_PTR(att_name);
@@ -791,20 +785,19 @@ NetCDF_def_var(VALUE file,VALUE var_name,VALUE vartype,VALUE dimensions)
791
785
  struct NetCDFDim *Netcdf_dim;
792
786
  VALUE Var;
793
787
 
794
- rb_secure(3);
795
788
  Check_Type(var_name,T_STRING);
796
789
  Check_Type(dimensions,T_ARRAY);
797
790
 
798
791
  c_var_name=RSTRING_PTR(var_name);
799
792
  c_ndims=RARRAY_LEN(dimensions);
800
-
793
+
801
794
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
802
795
  ncid=Netcdffile->ncid;
803
796
 
804
797
  if (TYPE(vartype) == T_STRING){
805
- xtype = natype2nctype(RSTRING_PTR(vartype));
798
+ xtype = natype2nctype(RSTRING_PTR(vartype));
806
799
  } else if (TYPE(vartype) == T_FIXNUM){
807
- xtype = natypecode2nctype(NUM2INT(vartype));
800
+ xtype = natypecode2nctype(NUM2INT(vartype));
808
801
  } else {
809
802
  rb_raise(rb_eNetcdfError,
810
803
  "type specfication must be by a string or nil");
@@ -827,12 +820,12 @@ NetCDF_def_var(VALUE file,VALUE var_name,VALUE vartype,VALUE dimensions)
827
820
  rb_raise(rb_eNetcdfError, "No such object of the netCDF dimension class.");
828
821
  }
829
822
  }
830
-
823
+
831
824
  status = nc_def_var(ncid,c_var_name,xtype,c_ndims,c_dimids,&varidp);
832
825
  if(status != NC_NOERR) NC_RAISE(status);
833
-
826
+
834
827
  Netcdf_var = NetCDF_var_init(ncid,varidp,file);
835
-
828
+
836
829
  Var=Data_Wrap_Struct(cNetCDFVar,nc_mark_obj,NetCDF_var_free,Netcdf_var);
837
830
  return Var;
838
831
  }
@@ -852,10 +845,10 @@ NetCDF_dim(VALUE file,VALUE dim_name)
852
845
  ncid=Netcdffile->ncid;
853
846
  Check_Type(dim_name,T_STRING);
854
847
  c_dim_name=RSTRING_PTR(dim_name);
855
-
848
+
856
849
  status = nc_inq_dimid(ncid,c_dim_name,&dimidp);
857
850
  if(status !=NC_NOERR){
858
- if(status == NC_EBADDIM){
851
+ if(status == NC_EBADDIM){
859
852
  return(Qnil); /*2003/08/27 back to orig (from changes on 2003/02/03)*/
860
853
  } else{
861
854
  NC_RAISE(status);
@@ -863,14 +856,14 @@ NetCDF_dim(VALUE file,VALUE dim_name)
863
856
  }
864
857
 
865
858
  Netcdf_dim=NetCDF_dim_init(ncid,dimidp);
866
-
859
+
867
860
  Dimension = Data_Wrap_Struct(cNetCDFDim,0,NetCDF_dim_free,Netcdf_dim);
868
861
  return Dimension;
869
862
  }
870
863
 
871
- VALUE
864
+ VALUE
872
865
  NetCDF_var(VALUE file,VALUE var_name)
873
- {
866
+ {
874
867
  int ncid;
875
868
  int status;
876
869
  int varidp;
@@ -883,16 +876,16 @@ NetCDF_var(VALUE file,VALUE var_name)
883
876
  ncid=Netcdffile->ncid;
884
877
  Check_Type(var_name,T_STRING);
885
878
  c_var_name=RSTRING_PTR(var_name);
886
-
879
+
887
880
  status=nc_inq_varid(ncid,c_var_name,&varidp);
888
881
  if(status != NC_NOERR){
889
882
  if(status == NC_ENOTVAR){
890
883
  return(Qnil); /*2003/08/27 back to orig (from changes on 2003/02/03)*/
891
- } else{
884
+ } else{
892
885
  NC_RAISE(status);
893
886
  }
894
887
  }
895
-
888
+
896
889
  Netcdf_var = NetCDF_var_init(ncid,varidp,file);
897
890
  Variable = Data_Wrap_Struct(cNetCDFVar,nc_mark_obj,NetCDF_var_free,Netcdf_var);
898
891
  return Variable;
@@ -913,7 +906,7 @@ NetCDF_att(VALUE file,VALUE att_name)
913
906
  ncid=Netcdffile->ncid;
914
907
  Check_Type(att_name,T_STRING);
915
908
  c_att_name=RSTRING_PTR(att_name);
916
-
909
+
917
910
 
918
911
  status = nc_inq_attid(ncid,NC_GLOBAL,c_att_name,&attnump);
919
912
  if(status != NC_NOERR){
@@ -924,11 +917,11 @@ NetCDF_att(VALUE file,VALUE att_name)
924
917
  NC_RAISE(status);
925
918
  }
926
919
  }
927
-
920
+
928
921
  Netcdf_att = NetCDF_att_init(ncid,NC_GLOBAL,c_att_name);
929
-
922
+
930
923
  Attribute = Data_Wrap_Struct(cNetCDFAtt,0,Netcdf_att_free,Netcdf_att);
931
-
924
+
932
925
  return Attribute;
933
926
  }
934
927
  VALUE
@@ -938,7 +931,7 @@ NetCDF_fill(VALUE file,VALUE mode)
938
931
  int status;
939
932
  struct Netcdf *Netcdffile;
940
933
  int old_modep;
941
-
934
+
942
935
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
943
936
  ncid = Netcdffile->ncid;
944
937
  if(mode==Qfalse){
@@ -961,7 +954,6 @@ NetCDF_redef(VALUE file)
961
954
  int status;
962
955
  struct Netcdf *Netcdffile;
963
956
 
964
- rb_secure(3);
965
957
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
966
958
  ncid=Netcdffile->ncid;
967
959
  status = nc_redef(ncid);
@@ -976,18 +968,17 @@ NetCDF_redef(VALUE file)
976
968
  return Qtrue;
977
969
  }
978
970
 
979
- VALUE
971
+ VALUE
980
972
  NetCDF_enddef(VALUE file)
981
973
  {
982
974
  int ncid;
983
975
  int status;
984
976
  struct Netcdf *Netcdffile;
985
977
 
986
- rb_secure(3);
987
978
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
988
979
  ncid=Netcdffile->ncid;
989
980
  status = nc_enddef(ncid);
990
- if(status !=NC_NOERR){
981
+ if(status !=NC_NOERR){
991
982
  if(status == NC_ENOTINDEFINE){
992
983
  return Qnil;
993
984
  }
@@ -998,7 +989,7 @@ NetCDF_enddef(VALUE file)
998
989
  return Qtrue;
999
990
  }
1000
991
 
1001
- VALUE
992
+ VALUE
1002
993
  NetCDF_whether_in_define_mode(VALUE file)
1003
994
  {
1004
995
  /* returns true if the NetCDF object is currently in the define mode,
@@ -1010,7 +1001,6 @@ NetCDF_whether_in_define_mode(VALUE file)
1010
1001
  int status;
1011
1002
  struct Netcdf *Netcdffile;
1012
1003
 
1013
- rb_secure(3);
1014
1004
  Data_Get_Struct(file,struct Netcdf,Netcdffile);
1015
1005
  ncid=Netcdffile->ncid;
1016
1006
  status = nc_redef(ncid);
@@ -1030,7 +1020,7 @@ NetCDF_whether_in_define_mode(VALUE file)
1030
1020
  }
1031
1021
 
1032
1022
  VALUE
1033
- NetCDF_open(VALUE mod,VALUE filename,VALUE omode)
1023
+ NetCDF_open(VALUE mod,VALUE filename,VALUE omode)
1034
1024
  {
1035
1025
  int status;
1036
1026
  int ncid;
@@ -1044,7 +1034,7 @@ NetCDF_open(VALUE mod,VALUE filename,VALUE omode)
1044
1034
  c_filename=RSTRING_PTR(filename);
1045
1035
  Check_Type(omode,T_FIXNUM);
1046
1036
  c_omode=NUM2INT(omode);
1047
-
1037
+
1048
1038
  status = nc_open(c_filename,c_omode,&ncid);
1049
1039
  if(status !=NC_NOERR){NC_RAISE2(status,c_filename);}
1050
1040
 
@@ -1061,13 +1051,13 @@ NetCDF_create(VALUE mod,VALUE filename,VALUE cmode)
1061
1051
  char* c_filename;
1062
1052
  int c_cmode;
1063
1053
  struct Netcdf *ncfile;
1064
-
1054
+
1065
1055
  Check_Type(filename,T_STRING);
1066
1056
  SafeStringValue(filename);
1067
1057
  c_filename=RSTRING_PTR(filename);
1068
1058
  Check_Type(cmode,T_FIXNUM);
1069
1059
  c_cmode=NUM2INT(cmode);
1070
-
1060
+
1071
1061
  status = nc_create(c_filename,c_cmode,&ncid);
1072
1062
  if(status != NC_NOERR) NC_RAISE2(status, c_filename);
1073
1063
 
@@ -1075,7 +1065,7 @@ NetCDF_create(VALUE mod,VALUE filename,VALUE cmode)
1075
1065
  return( Data_Wrap_Struct(cNetCDF,0,NetCDF_free,ncfile) );
1076
1066
  }
1077
1067
 
1078
- VALUE
1068
+ VALUE
1079
1069
  NetCDF_ndims(VALUE file)
1080
1070
  {
1081
1071
  int ncid;
@@ -1092,7 +1082,7 @@ NetCDF_ndims(VALUE file)
1092
1082
  return Integer;
1093
1083
  }
1094
1084
 
1095
- VALUE
1085
+ VALUE
1096
1086
  NetCDF_nvars(VALUE file)
1097
1087
  {
1098
1088
  int ncid;
@@ -1108,7 +1098,7 @@ NetCDF_nvars(VALUE file)
1108
1098
  return Integer;
1109
1099
  }
1110
1100
 
1111
- VALUE
1101
+ VALUE
1112
1102
  NetCDF_natts(VALUE file)
1113
1103
  {
1114
1104
  int ncid;
@@ -1139,10 +1129,10 @@ NetCDF_unlimited(VALUE file)
1139
1129
  ncid=ncfile->ncid;
1140
1130
  status=nc_inq_unlimdim(ncid,&unlimdimidp);
1141
1131
  if(status !=NC_NOERR) NC_RAISE(status);
1142
-
1132
+
1143
1133
  Netcdf_dim = NetCDF_dim_init(ncid,unlimdimidp);
1144
-
1145
- /* If unlimdimidp=-1,No unlimited dimension is defined in the netCDF dataset */
1134
+
1135
+ /* If unlimdimidp=-1,No unlimited dimension is defined in the netCDF dataset */
1146
1136
  if(unlimdimidp != -1)
1147
1137
  {
1148
1138
  Dimension = Data_Wrap_Struct(cNetCDFDim,0,NetCDF_dim_free,Netcdf_dim);
@@ -1153,7 +1143,31 @@ NetCDF_unlimited(VALUE file)
1153
1143
  return Qnil;
1154
1144
  }
1155
1145
  }
1156
-
1146
+
1147
+ #if NCVER >= 400
1148
+
1149
+ VALUE
1150
+ NetCDF_format(VALUE file)
1151
+ {
1152
+ int ncid;
1153
+ int formatp;
1154
+ int status;
1155
+ VALUE Integer;
1156
+ struct Netcdf *ncfile;
1157
+
1158
+ Data_Get_Struct(file,struct Netcdf,ncfile);
1159
+ ncid=ncfile->ncid;
1160
+ status=nc_inq_format(ncid,&formatp);
1161
+ if(status != NC_NOERR) NC_RAISE (status);
1162
+ Integer = INT2NUM(formatp);
1163
+ /* one of NC_FORMAT_CLASSIC (1), NC_FORMAT_64BIT (2), NC_FORMAT_NETCDF4 (3),
1164
+ NC_FORMAT_NETCDF4_CLASSIC (4)
1165
+ */
1166
+ return Integer;
1167
+ }
1168
+
1169
+ #endif
1170
+
1157
1171
  VALUE
1158
1172
  NetCDF_sync(VALUE file)
1159
1173
  {
@@ -1161,7 +1175,6 @@ NetCDF_sync(VALUE file)
1161
1175
  int status;
1162
1176
  struct Netcdf *ncfile;
1163
1177
 
1164
- rb_secure(3);
1165
1178
  Data_Get_Struct(file,struct Netcdf,ncfile);
1166
1179
  ncid=ncfile->ncid;
1167
1180
  status = nc_sync(ncid);
@@ -1174,7 +1187,7 @@ NetCDF_path(VALUE file)
1174
1187
  {
1175
1188
  char *path;
1176
1189
  struct Netcdf *ncfile;
1177
-
1190
+
1178
1191
  Data_Get_Struct(file,struct Netcdf,ncfile);
1179
1192
  path=ncfile->name;
1180
1193
  return(rb_str_new2(path));
@@ -1188,14 +1201,14 @@ NetCDF_dim_length(VALUE Dim)
1188
1201
  int dimid;
1189
1202
  size_t lengthp;
1190
1203
  struct NetCDFDim *Netcdf_dim;
1191
-
1204
+
1192
1205
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
1193
1206
  ncid=Netcdf_dim->ncid;
1194
1207
  dimid=Netcdf_dim->dimid;
1195
1208
 
1196
1209
  status = nc_inq_dimlen(ncid,dimid,&lengthp);
1197
1210
  if(status != NC_NOERR) NC_RAISE(status);
1198
-
1211
+
1199
1212
  return(INT2NUM(lengthp));
1200
1213
  }
1201
1214
 
@@ -1207,8 +1220,7 @@ NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
1207
1220
  int dimid;
1208
1221
  char *c_dim_name;
1209
1222
  struct NetCDFDim *Netcdf_dim;
1210
-
1211
- rb_secure(3);
1223
+
1212
1224
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
1213
1225
  ncid=Netcdf_dim->ncid;
1214
1226
  dimid=Netcdf_dim->dimid;
@@ -1217,7 +1229,7 @@ NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
1217
1229
 
1218
1230
  status = nc_rename_dim(ncid,dimid,c_dim_name);
1219
1231
  if(status !=NC_NOERR) NC_RAISE(status);
1220
-
1232
+
1221
1233
  return Qnil;
1222
1234
  }
1223
1235
 
@@ -1230,14 +1242,14 @@ NetCDF_dim_inqname(VALUE Dim)
1230
1242
  char c_dim_name[NC_MAX_NAME];
1231
1243
  struct NetCDFDim *Netcdf_dim;
1232
1244
  VALUE str;
1233
-
1245
+
1234
1246
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
1235
1247
  ncid=Netcdf_dim->ncid;
1236
1248
  dimid=Netcdf_dim->dimid;
1237
-
1249
+
1238
1250
  status = nc_inq_dimname(ncid,dimid,c_dim_name);
1239
1251
  if(status !=NC_NOERR) NC_RAISE(status);
1240
-
1252
+
1241
1253
  str = rb_str_new2(c_dim_name);
1242
1254
  OBJ_TAINT(str);
1243
1255
  return(str);
@@ -1249,7 +1261,7 @@ NetCDF_dim_whether_unlimited(VALUE Dim)
1249
1261
  int status;
1250
1262
  int uldid;
1251
1263
  struct NetCDFDim *Netcdf_dim;
1252
-
1264
+
1253
1265
  Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
1254
1266
  status=nc_inq_unlimdim(Netcdf_dim->ncid,&uldid);
1255
1267
  if(status !=NC_NOERR) NC_RAISE(status);
@@ -1269,7 +1281,7 @@ NetCDF_att_inq_name(VALUE Att)
1269
1281
 
1270
1282
  Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
1271
1283
  c_att_name=Netcdf_att->name;
1272
-
1284
+
1273
1285
  str = rb_str_new2(c_att_name);
1274
1286
  OBJ_TAINT(str);
1275
1287
  return(str);
@@ -1287,16 +1299,16 @@ NetCDF_att_rename(VALUE Att,VALUE new_att_name)
1287
1299
  Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
1288
1300
  ncid=Netcdf_att->ncid;
1289
1301
  varid=Netcdf_att->varid;
1290
-
1302
+
1291
1303
  c_att_name=Netcdf_att->name;
1292
-
1304
+
1293
1305
  Check_Type(new_att_name,T_STRING);
1294
1306
  SafeStringValue(new_att_name);
1295
1307
  c_new_att_name=StringValueCStr(new_att_name);
1296
-
1308
+
1297
1309
  status = nc_rename_att(ncid,varid,c_att_name,c_new_att_name);
1298
1310
  if(status != NC_NOERR) NC_RAISE(status);
1299
-
1311
+
1300
1312
  strcpy(Netcdf_att->name,c_new_att_name);
1301
1313
  return Qnil;
1302
1314
  }
@@ -1327,7 +1339,7 @@ NetCDF_id2var(VALUE file,VALUE varid)
1327
1339
  struct Netcdf *ncfile;
1328
1340
  struct NetCDFVar *Netcdf_var;
1329
1341
  VALUE Var;
1330
-
1342
+
1331
1343
  Data_Get_Struct(file,struct Netcdf,ncfile);
1332
1344
  ncid=ncfile->ncid;
1333
1345
  Check_Type(varid,T_FIXNUM);
@@ -1349,7 +1361,7 @@ NetCDF_id2att(VALUE file,VALUE attnum)
1349
1361
  char *c_att_name;
1350
1362
  VALUE Att;
1351
1363
  c_att_name=ALLOCA_N(char,NC_MAX_NAME);
1352
-
1364
+
1353
1365
  Data_Get_Struct(file,struct Netcdf,ncfile);
1354
1366
  ncid=ncfile->ncid;
1355
1367
 
@@ -1377,7 +1389,7 @@ NetCDF_var_deflate(int argc, VALUE *argv, VALUE Var)
1377
1389
  struct NetCDFVar *Netcdf_var;
1378
1390
 
1379
1391
  int shuffle;
1380
- /* If non-zero, turn on the shuffle filter.
1392
+ /* If non-zero, turn on the shuffle filter.
1381
1393
 
1382
1394
  http://www.unidata.ucar.edu/software/netcdf/papers/AMS_2008.pdf :
1383
1395
  The shuffle algorithm changes the byte order in the data stream;
@@ -1397,7 +1409,7 @@ NetCDF_var_deflate(int argc, VALUE *argv, VALUE Var)
1397
1409
  level specified by the deflate_level parameter.
1398
1410
  */
1399
1411
 
1400
- if (argc>2 || argc<1) rb_raise(rb_eArgError,
1412
+ if (argc>2 || argc<1) rb_raise(rb_eArgError,
1401
1413
  "wrong # of arguments (%d). It must be 1 or 2", argc);
1402
1414
 
1403
1415
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
@@ -1433,7 +1445,7 @@ NetCDF_var_deflate_params(VALUE Var)
1433
1445
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1434
1446
  ncid = Netcdf_var->ncid;
1435
1447
  varid = Netcdf_var->varid;
1436
- status = nc_inq_var_deflate(ncid, varid, &shufflep, &deflatep,
1448
+ status = nc_inq_var_deflate(ncid, varid, &shufflep, &deflatep,
1437
1449
  &deflate_levelp);
1438
1450
  if(status != NC_NOERR) NC_RAISE(status);
1439
1451
  if (shufflep==0) {sh=Qfalse;} else {sh=Qtrue;}
@@ -1484,7 +1496,7 @@ NetCDF_var_id2att(VALUE Var,VALUE attnum)
1484
1496
  struct NetCDFAtt *Netcdf_att;
1485
1497
  char *c_att_name;
1486
1498
  VALUE Att;
1487
-
1499
+
1488
1500
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1489
1501
  ncid=Netcdf_var->ncid;
1490
1502
  c_varid=Netcdf_var->varid;
@@ -1496,7 +1508,7 @@ NetCDF_var_id2att(VALUE Var,VALUE attnum)
1496
1508
 
1497
1509
  status = nc_inq_attname(ncid,c_varid,c_attnum,c_att_name);
1498
1510
  if(status != NC_NOERR) NC_RAISE(status);
1499
-
1511
+
1500
1512
  Netcdf_att=NetCDF_att_init(ncid,c_varid,c_att_name);
1501
1513
  Att=Data_Wrap_Struct(cNetCDFAtt,0,Netcdf_att_free,Netcdf_att);
1502
1514
  return(Att);
@@ -1521,7 +1533,7 @@ NetCDF_var_dims(VALUE Var)
1521
1533
  Dims = rb_ary_new();
1522
1534
  for(i=0;i<ndims;i++){
1523
1535
  Netcdf_dim = NetCDF_dim_init(ncid,dimids[ndims-1-i]);
1524
- rb_ary_push(Dims,
1536
+ rb_ary_push(Dims,
1525
1537
  Data_Wrap_Struct(cNetCDFDim,0,NetCDF_dim_free,Netcdf_dim));
1526
1538
  }
1527
1539
  return(Dims);
@@ -1565,7 +1577,6 @@ NetCDF_att_copy(VALUE Att,VALUE Var_or_File)
1565
1577
  struct Netcdf *ncfile;
1566
1578
  struct NetCDFAtt *Netcdf_att_out;
1567
1579
 
1568
- rb_secure(3);
1569
1580
  Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
1570
1581
  ncid_in=Netcdf_att->ncid;
1571
1582
  varid_in=Netcdf_att->varid;
@@ -1611,7 +1622,7 @@ NetCDF_att_atttype(VALUE Att)
1611
1622
  Attname = nctype2natype(xtypep);
1612
1623
  return(rb_str_new2(Attname));
1613
1624
  }
1614
-
1625
+
1615
1626
  VALUE
1616
1627
  NetCDF_att_typecode(VALUE Att)
1617
1628
  {
@@ -1629,10 +1640,10 @@ NetCDF_att_typecode(VALUE Att)
1629
1640
 
1630
1641
  status = nc_inq_atttype(ncid,varid,att_name,&xtypep);
1631
1642
  if(status != NC_NOERR) NC_RAISE(status);
1632
-
1643
+
1633
1644
  return(INT2NUM(nctype2natypecode(xtypep)));
1634
1645
  }
1635
-
1646
+
1636
1647
  VALUE
1637
1648
  NetCDF_att_delete(VALUE Att)
1638
1649
  {
@@ -1642,7 +1653,6 @@ NetCDF_att_delete(VALUE Att)
1642
1653
  char *c_att_name;
1643
1654
  struct NetCDFAtt *Netcdf_att;
1644
1655
 
1645
- rb_secure(3);
1646
1656
  Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
1647
1657
 
1648
1658
  ncid=Netcdf_att->ncid;
@@ -1651,7 +1661,7 @@ NetCDF_att_delete(VALUE Att)
1651
1661
 
1652
1662
  status = nc_del_att(ncid,varid,c_att_name);
1653
1663
  if(status != NC_NOERR) NC_RAISE(status);
1654
-
1664
+
1655
1665
  return Qnil;
1656
1666
  }
1657
1667
 
@@ -1663,13 +1673,12 @@ NetCDF_att_put(VALUE Att,VALUE value,VALUE atttype)
1663
1673
  */
1664
1674
  {
1665
1675
  struct NetCDFAtt *ncatt;
1666
-
1667
- rb_secure(3);
1676
+
1668
1677
  Data_Get_Struct(Att,struct NetCDFAtt,ncatt);
1669
- return( NetCDF_put_att__(ncatt->ncid, ncatt->name, value,
1678
+ return( NetCDF_put_att__(ncatt->ncid, ncatt->name, value,
1670
1679
  atttype, ncatt->varid) );
1671
1680
  }
1672
-
1681
+
1673
1682
  VALUE
1674
1683
  NetCDF_att_get(VALUE Att)
1675
1684
  {
@@ -1716,7 +1725,7 @@ NetCDF_att_get(VALUE Att)
1716
1725
 
1717
1726
  attlen[0]=lenp;
1718
1727
  Cbyte_to_NArray(NArray,1,attlen,up);
1719
-
1728
+
1720
1729
  status = nc_get_att_uchar(ncid,varid,c_attname,up);
1721
1730
  if(status != NC_NOERR) NC_RAISE(status);
1722
1731
 
@@ -1729,7 +1738,7 @@ NetCDF_att_get(VALUE Att)
1729
1738
 
1730
1739
  attlen[0]=lenp;
1731
1740
  Csint_to_NArray(NArray,1,attlen,sp);
1732
-
1741
+
1733
1742
  status = nc_get_att_short(ncid,varid,c_attname,sp);
1734
1743
  if(status != NC_NOERR) NC_RAISE(status);
1735
1744
  OBJ_TAINT(NArray);
@@ -1738,10 +1747,10 @@ NetCDF_att_get(VALUE Att)
1738
1747
  case NC_INT:
1739
1748
  status = nc_inq_attlen(ncid,varid,c_attname,&lenp);
1740
1749
  if(status != NC_NOERR) NC_RAISE(status);
1741
-
1750
+
1742
1751
  attlen[0]=lenp;
1743
1752
  Clint_to_NArray(NArray,1,attlen,ip);
1744
-
1753
+
1745
1754
  status = nc_get_att_int(ncid,varid,c_attname,ip);
1746
1755
  if(status != NC_NOERR) NC_RAISE(status);
1747
1756
 
@@ -1754,7 +1763,7 @@ NetCDF_att_get(VALUE Att)
1754
1763
 
1755
1764
  attlen[0]=lenp;
1756
1765
  Cfloat_to_NArray(NArray,1,attlen,fp);
1757
-
1766
+
1758
1767
  status = nc_get_att_float(ncid,varid,c_attname,fp);
1759
1768
  if(status != NC_NOERR) NC_RAISE(status);
1760
1769
 
@@ -1767,7 +1776,7 @@ NetCDF_att_get(VALUE Att)
1767
1776
 
1768
1777
  attlen[0]=lenp;
1769
1778
  Cdouble_to_NArray(NArray,1,attlen,dp);
1770
-
1779
+
1771
1780
  status = nc_get_att_double(ncid,varid,c_attname,dp);
1772
1781
  if(status != NC_NOERR) NC_RAISE(status);
1773
1782
  OBJ_TAINT(NArray);
@@ -1779,7 +1788,7 @@ NetCDF_att_get(VALUE Att)
1779
1788
  return Qnil;
1780
1789
  }
1781
1790
 
1782
-
1791
+
1783
1792
  VALUE
1784
1793
  NetCDF_var_inq_name(VALUE Var)
1785
1794
  {
@@ -1796,7 +1805,7 @@ NetCDF_var_inq_name(VALUE Var)
1796
1805
  varid=Netcdf_var->varid;
1797
1806
  status = nc_inq_varname(ncid,varid,c_var_name);
1798
1807
  if(status != NC_NOERR) NC_RAISE(status);
1799
-
1808
+
1800
1809
  Var_name=rb_str_new2(c_var_name);
1801
1810
  OBJ_TAINT(Var_name);
1802
1811
  return Var_name;
@@ -1813,7 +1822,7 @@ NetCDF_var_ndims(VALUE Var)
1813
1822
  VALUE Var_ndims;
1814
1823
 
1815
1824
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1816
-
1825
+
1817
1826
  ncid=Netcdf_var->ncid;
1818
1827
  varid=Netcdf_var->varid;
1819
1828
  status = nc_inq_varndims(ncid,varid,&ndimsp);
@@ -1831,15 +1840,15 @@ NetCDF_var_vartype(VALUE Var)
1831
1840
  nc_type xtypep;
1832
1841
  struct NetCDFVar *Netcdf_var;
1833
1842
  const char *Vartype;
1834
-
1843
+
1835
1844
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1836
-
1845
+
1837
1846
  ncid=Netcdf_var->ncid;
1838
1847
  varid=Netcdf_var->varid;
1839
1848
 
1840
1849
  status = nc_inq_vartype(ncid,varid,&xtypep);
1841
1850
  if(status != NC_NOERR) NC_RAISE(status);
1842
-
1851
+
1843
1852
  Vartype=nctype2natype(xtypep);
1844
1853
  return(rb_str_new2(Vartype));
1845
1854
  }
@@ -1852,19 +1861,19 @@ NetCDF_var_typecode(VALUE Var)
1852
1861
  int varid;
1853
1862
  nc_type xtypep;
1854
1863
  struct NetCDFVar *Netcdf_var;
1855
-
1864
+
1856
1865
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1857
-
1866
+
1858
1867
  ncid=Netcdf_var->ncid;
1859
1868
  varid=Netcdf_var->varid;
1860
1869
 
1861
1870
  status = nc_inq_vartype(ncid,varid,&xtypep);
1862
1871
  if(status != NC_NOERR) NC_RAISE(status);
1863
-
1872
+
1864
1873
  return(INT2NUM(nctype2natypecode(xtypep)));
1865
1874
  }
1866
1875
 
1867
-
1876
+
1868
1877
  VALUE
1869
1878
  NetCDF_var_natts(VALUE Var)
1870
1879
  {
@@ -1874,16 +1883,16 @@ NetCDF_var_natts(VALUE Var)
1874
1883
  int nattsp;
1875
1884
  struct NetCDFVar *Netcdf_var;
1876
1885
  VALUE Var_natts;
1877
-
1886
+
1878
1887
 
1879
1888
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1880
-
1889
+
1881
1890
  ncid=Netcdf_var->ncid;
1882
1891
  varid=Netcdf_var->varid;
1883
-
1892
+
1884
1893
  status= nc_inq_varnatts(ncid,varid,&nattsp);
1885
1894
  if(status !=NC_NOERR) NC_RAISE(status);
1886
-
1895
+
1887
1896
  Var_natts=INT2FIX(nattsp);
1888
1897
  return Var_natts;
1889
1898
  }
@@ -1894,7 +1903,7 @@ NetCDF_var_file(VALUE Var)
1894
1903
  struct NetCDFVar *Netcdf_var;
1895
1904
  /* VALUE file; */
1896
1905
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1897
-
1906
+
1898
1907
  return (Netcdf_var->file);
1899
1908
  }
1900
1909
 
@@ -1906,15 +1915,14 @@ NetCDF_var_rename(VALUE Var,VALUE var_new_name)
1906
1915
  int varid;
1907
1916
  char *c_var_new_name;
1908
1917
  struct NetCDFVar *Netcdf_var;
1909
-
1910
- rb_secure(3);
1918
+
1911
1919
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1912
1920
  ncid=Netcdf_var->ncid;
1913
1921
  varid=Netcdf_var->varid;
1914
1922
 
1915
1923
  Check_Type(var_new_name,T_STRING);
1916
1924
  c_var_new_name=StringValueCStr(var_new_name);
1917
-
1925
+
1918
1926
  status = nc_rename_var(ncid,varid,c_var_new_name);
1919
1927
  if(status !=NC_NOERR) NC_RAISE(status);
1920
1928
 
@@ -1934,13 +1942,13 @@ NetCDF_var_att(VALUE Var,VALUE att_name)
1934
1942
  VALUE Att;
1935
1943
 
1936
1944
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
1937
-
1945
+
1938
1946
  ncid=Netcdf_var->ncid;
1939
1947
  varid=Netcdf_var->varid;
1940
1948
 
1941
1949
  Check_Type(att_name,T_STRING);
1942
1950
  c_att_name=StringValueCStr(att_name);
1943
-
1951
+
1944
1952
  status = nc_inq_attid(ncid,varid,c_att_name,&c_attnump);
1945
1953
  if(status == NC_NOERR){
1946
1954
  Netcdf_att=NetCDF_att_init(ncid,varid,c_att_name);
@@ -1958,17 +1966,17 @@ NetCDF_var_att(VALUE Var,VALUE att_name)
1958
1966
 
1959
1967
  /* Redifinition of the "==" and "eql?" methods */
1960
1968
 
1961
- VALUE
1969
+ VALUE
1962
1970
  NetCDF_eql(VALUE filea,VALUE fileb)
1963
1971
  {
1964
1972
  struct Netcdf *ncfilea;
1965
1973
  struct Netcdf *ncfileb;
1966
-
1974
+
1967
1975
  if( rb_obj_is_kind_of(fileb, cNetCDF) ){
1968
1976
  Data_Get_Struct(filea,struct Netcdf,ncfilea);
1969
1977
  Data_Get_Struct(fileb,struct Netcdf,ncfileb);
1970
-
1971
- if(ncfilea->ncid == ncfileb->ncid &&
1978
+
1979
+ if(ncfilea->ncid == ncfileb->ncid &&
1972
1980
  strcmp(ncfilea->name,ncfileb->name)==0){
1973
1981
  return Qtrue;
1974
1982
  } else {
@@ -1984,12 +1992,12 @@ NetCDF_var_eql(VALUE Vara,VALUE Varb)
1984
1992
  {
1985
1993
  struct NetCDFVar *Netcdf_vara;
1986
1994
  struct NetCDFVar *Netcdf_varb;
1987
-
1995
+
1988
1996
  if( rb_obj_is_kind_of(Varb, cNetCDFVar) ){
1989
1997
  Data_Get_Struct(Vara,struct NetCDFVar,Netcdf_vara);
1990
1998
  Data_Get_Struct(Varb,struct NetCDFVar,Netcdf_varb);
1991
1999
 
1992
- if(Netcdf_vara->ncid == Netcdf_varb->ncid &&
2000
+ if(Netcdf_vara->ncid == Netcdf_varb->ncid &&
1993
2001
  Netcdf_vara->varid == Netcdf_varb->varid){
1994
2002
  return Qtrue;
1995
2003
  } else {
@@ -2000,7 +2008,7 @@ NetCDF_var_eql(VALUE Vara,VALUE Varb)
2000
2008
  }
2001
2009
  }
2002
2010
 
2003
- VALUE
2011
+ VALUE
2004
2012
  NetCDF_dim_eql(VALUE Dima,VALUE Dimb)
2005
2013
  {
2006
2014
  struct NetCDFDim *Netcdf_dima;
@@ -2009,8 +2017,8 @@ NetCDF_dim_eql(VALUE Dima,VALUE Dimb)
2009
2017
  if( rb_obj_is_kind_of(Dimb, cNetCDFDim) ){
2010
2018
  Data_Get_Struct(Dima,struct NetCDFDim,Netcdf_dima);
2011
2019
  Data_Get_Struct(Dimb,struct NetCDFDim,Netcdf_dimb);
2012
-
2013
- if(Netcdf_dima->ncid == Netcdf_dimb->ncid &&
2020
+
2021
+ if(Netcdf_dima->ncid == Netcdf_dimb->ncid &&
2014
2022
  Netcdf_dima->dimid == Netcdf_dimb->dimid){
2015
2023
  return Qtrue;
2016
2024
  } else {
@@ -2026,16 +2034,16 @@ NetCDF_att_eql(VALUE Atta,VALUE Attb)
2026
2034
  {
2027
2035
  struct NetCDFAtt *Netcdf_atta;
2028
2036
  struct NetCDFAtt *Netcdf_attb;
2029
-
2037
+
2030
2038
  if( rb_obj_is_kind_of(Attb, cNetCDFAtt) ){
2031
2039
  Data_Get_Struct(Atta,struct NetCDFAtt,Netcdf_atta);
2032
2040
  Data_Get_Struct(Attb,struct NetCDFAtt,Netcdf_attb);
2033
-
2034
- if(Netcdf_atta->ncid == Netcdf_atta->ncid &&
2035
- Netcdf_atta->varid == Netcdf_attb->varid &&
2041
+
2042
+ if(Netcdf_atta->ncid == Netcdf_atta->ncid &&
2043
+ Netcdf_atta->varid == Netcdf_attb->varid &&
2036
2044
  strcmp(Netcdf_atta->name,Netcdf_attb->name)==0){
2037
2045
  return Qtrue;
2038
- } else {
2046
+ } else {
2039
2047
  return Qfalse;
2040
2048
  }
2041
2049
  } else {
@@ -2080,7 +2088,7 @@ NetCDF_get_var_char(VALUE Var)
2080
2088
  }
2081
2089
 
2082
2090
  Cbyte_to_NArray(NArray,ndimsp,shape,ptr);
2083
-
2091
+
2084
2092
  status = nc_get_var_text(ncid,varid,(char *)ptr);
2085
2093
  if(status != NC_NOERR) NC_RAISE(status);
2086
2094
 
@@ -2124,7 +2132,7 @@ NetCDF_get_var_byte(VALUE Var)
2124
2132
  }
2125
2133
 
2126
2134
  Cbyte_to_NArray(NArray,ndimsp,shape,ptr);
2127
-
2135
+
2128
2136
  status = nc_get_var_uchar(ncid,varid,ptr);
2129
2137
  if(status != NC_NOERR) NC_RAISE(status);
2130
2138
 
@@ -2168,7 +2176,7 @@ NetCDF_get_var_sint(VALUE Var)
2168
2176
  }
2169
2177
 
2170
2178
  Csint_to_NArray(NArray,ndimsp,shape,ptr);
2171
-
2179
+
2172
2180
  status = nc_get_var_short(ncid,varid,ptr);
2173
2181
  if(status != NC_NOERR) NC_RAISE(status);
2174
2182
 
@@ -2212,7 +2220,7 @@ NetCDF_get_var_int(VALUE Var)
2212
2220
  }
2213
2221
 
2214
2222
  Clint_to_NArray(NArray,ndimsp,shape,ptr);
2215
-
2223
+
2216
2224
  status = nc_get_var_int(ncid,varid,ptr);
2217
2225
  if(status != NC_NOERR) NC_RAISE(status);
2218
2226
 
@@ -2300,7 +2308,7 @@ NetCDF_get_var_double(VALUE Var)
2300
2308
  }
2301
2309
 
2302
2310
  Cdouble_to_NArray(NArray,ndimsp,shape,ptr);
2303
-
2311
+
2304
2312
  status = nc_get_var_double(ncid,varid,ptr);
2305
2313
  if(status != NC_NOERR) NC_RAISE(status);
2306
2314
 
@@ -2308,7 +2316,7 @@ NetCDF_get_var_double(VALUE Var)
2308
2316
  return NArray;
2309
2317
  }
2310
2318
 
2311
- VALUE
2319
+ VALUE
2312
2320
  NetCDF_get_var1_char(VALUE Var,VALUE start)
2313
2321
  {
2314
2322
  int ncid;
@@ -2325,7 +2333,7 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
2325
2333
  na_shape_t *c_count;
2326
2334
  VALUE NArray;
2327
2335
 
2328
-
2336
+
2329
2337
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
2330
2338
  ncid = Netcdf_var->ncid;
2331
2339
  varid = Netcdf_var->varid;
@@ -2334,12 +2342,12 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
2334
2342
  if(ndims == 0) {
2335
2343
  rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
2336
2344
  }
2337
-
2345
+
2338
2346
  Check_Type(start,T_ARRAY);
2339
2347
  if(RARRAY_LEN(start) < ndims) {
2340
2348
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
2341
2349
  }
2342
-
2350
+
2343
2351
  c_start=ALLOCA_N(size_t,ndims);
2344
2352
  c_count=ALLOCA_N(na_shape_t,ndims);
2345
2353
  for(i=0;i<ndims;i++){
@@ -2352,13 +2360,13 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
2352
2360
  l_start += dimlen;
2353
2361
  }
2354
2362
  c_start[i]=l_start;
2355
-
2363
+
2356
2364
  c_count[i]=1;
2357
2365
  }
2358
-
2359
-
2360
-
2361
-
2366
+
2367
+
2368
+
2369
+
2362
2370
  Cbyte_to_NArray(NArray,ndims,c_count,ptr);
2363
2371
  status = nc_get_var1_text(ncid,varid,c_start,(char *)ptr);
2364
2372
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2368,7 +2376,7 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
2368
2376
 
2369
2377
  }
2370
2378
 
2371
- VALUE
2379
+ VALUE
2372
2380
  NetCDF_get_var1_byte(VALUE Var,VALUE start)
2373
2381
  {
2374
2382
  int ncid;
@@ -2385,7 +2393,7 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
2385
2393
  na_shape_t *c_count;
2386
2394
  VALUE NArray;
2387
2395
 
2388
-
2396
+
2389
2397
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
2390
2398
  ncid = Netcdf_var->ncid;
2391
2399
  varid = Netcdf_var->varid;
@@ -2394,12 +2402,12 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
2394
2402
  if(ndims == 0) {
2395
2403
  rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
2396
2404
  }
2397
-
2405
+
2398
2406
  Check_Type(start,T_ARRAY);
2399
2407
  if(RARRAY_LEN(start) < ndims) {
2400
2408
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
2401
2409
  }
2402
-
2410
+
2403
2411
  c_start=ALLOCA_N(size_t,ndims);
2404
2412
  c_count=ALLOCA_N(na_shape_t,ndims);
2405
2413
  for(i=0;i<ndims;i++){
@@ -2412,13 +2420,13 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
2412
2420
  l_start += dimlen;
2413
2421
  }
2414
2422
  c_start[i]=l_start;
2415
-
2423
+
2416
2424
  c_count[i]=1;
2417
2425
  }
2418
-
2419
-
2420
-
2421
-
2426
+
2427
+
2428
+
2429
+
2422
2430
  Cbyte_to_NArray(NArray,ndims,c_count,ptr);
2423
2431
  status = nc_get_var1_uchar(ncid,varid,c_start,ptr);
2424
2432
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2428,7 +2436,7 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
2428
2436
 
2429
2437
  }
2430
2438
 
2431
- VALUE
2439
+ VALUE
2432
2440
  NetCDF_get_var1_sint(VALUE Var,VALUE start)
2433
2441
  {
2434
2442
  int ncid;
@@ -2453,12 +2461,12 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
2453
2461
  if(ndims == 0) {
2454
2462
  rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
2455
2463
  }
2456
-
2464
+
2457
2465
  Check_Type(start,T_ARRAY);
2458
2466
  if(RARRAY_LEN(start) < ndims) {
2459
2467
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
2460
2468
  }
2461
-
2469
+
2462
2470
  c_start=ALLOCA_N(size_t,ndims);
2463
2471
  c_count=ALLOCA_N(na_shape_t,ndims);
2464
2472
  for(i=0;i<ndims;i++){
@@ -2473,9 +2481,9 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
2473
2481
  c_start[i]=l_start;
2474
2482
  c_count[i]=1;
2475
2483
  }
2476
-
2484
+
2477
2485
  Csint_to_NArray(NArray,ndims,c_count,ptr);
2478
-
2486
+
2479
2487
  status = nc_get_var1_short(ncid,varid,c_start,ptr);
2480
2488
  if(status != NC_NOERR) NC_RAISE(status);
2481
2489
 
@@ -2484,7 +2492,7 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
2484
2492
 
2485
2493
  }
2486
2494
 
2487
- VALUE
2495
+ VALUE
2488
2496
  NetCDF_get_var1_int(VALUE Var,VALUE start)
2489
2497
  {
2490
2498
  int ncid;
@@ -2509,12 +2517,12 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
2509
2517
  if(ndims == 0) {
2510
2518
  rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
2511
2519
  }
2512
-
2520
+
2513
2521
  Check_Type(start,T_ARRAY);
2514
2522
  if(RARRAY_LEN(start) < ndims) {
2515
2523
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
2516
2524
  }
2517
-
2525
+
2518
2526
  c_start=ALLOCA_N(size_t,ndims);
2519
2527
  c_count=ALLOCA_N(na_shape_t,ndims);
2520
2528
  for(i=0;i<ndims;i++){
@@ -2529,9 +2537,9 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
2529
2537
  c_start[i]=l_start;
2530
2538
  c_count[i]=1;
2531
2539
  }
2532
-
2540
+
2533
2541
  Clint_to_NArray(NArray,ndims,c_count,ptr);
2534
-
2542
+
2535
2543
  status = nc_get_var1_int(ncid,varid,c_start,ptr);
2536
2544
  if(status != NC_NOERR) NC_RAISE(status);
2537
2545
 
@@ -2540,7 +2548,7 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
2540
2548
 
2541
2549
  }
2542
2550
 
2543
- VALUE
2551
+ VALUE
2544
2552
  NetCDF_get_var1_float(VALUE Var,VALUE start)
2545
2553
  {
2546
2554
  int ncid;
@@ -2565,12 +2573,12 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
2565
2573
  if(ndims == 0) {
2566
2574
  rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
2567
2575
  }
2568
-
2576
+
2569
2577
  Check_Type(start,T_ARRAY);
2570
2578
  if(RARRAY_LEN(start) < ndims) {
2571
2579
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
2572
2580
  }
2573
-
2581
+
2574
2582
  c_start=ALLOCA_N(size_t,ndims);
2575
2583
  c_count=ALLOCA_N(na_shape_t,ndims);
2576
2584
  for(i=0;i<ndims;i++){
@@ -2585,9 +2593,9 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
2585
2593
  c_start[i]=l_start;
2586
2594
  c_count[i]=1;
2587
2595
  }
2588
-
2596
+
2589
2597
  Cfloat_to_NArray(NArray,ndims,c_count,ptr);
2590
-
2598
+
2591
2599
  status = nc_get_var1_float(ncid,varid,c_start,ptr);
2592
2600
  if(status != NC_NOERR) NC_RAISE(status);
2593
2601
 
@@ -2596,7 +2604,7 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
2596
2604
 
2597
2605
  }
2598
2606
 
2599
- VALUE
2607
+ VALUE
2600
2608
  NetCDF_get_var1_double(VALUE Var,VALUE start)
2601
2609
  {
2602
2610
  int ncid;
@@ -2621,12 +2629,12 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
2621
2629
  if(ndims == 0) {
2622
2630
  rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
2623
2631
  }
2624
-
2632
+
2625
2633
  Check_Type(start,T_ARRAY);
2626
2634
  if(RARRAY_LEN(start) < ndims) {
2627
2635
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
2628
2636
  }
2629
-
2637
+
2630
2638
  c_start=ALLOCA_N(size_t,ndims);
2631
2639
  c_count=ALLOCA_N(na_shape_t,ndims);
2632
2640
  for(i=0;i<ndims;i++){
@@ -2641,9 +2649,9 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
2641
2649
  c_start[i]=l_start;
2642
2650
  c_count[i]=1;
2643
2651
  }
2644
-
2652
+
2645
2653
  Cdouble_to_NArray(NArray,ndims,c_count,ptr);
2646
-
2654
+
2647
2655
  status = nc_get_var1_double(ncid,varid,c_start,ptr);
2648
2656
  if(status != NC_NOERR) NC_RAISE(status);
2649
2657
 
@@ -2674,7 +2682,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
2674
2682
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
2675
2683
  ncid = Netcdf_var->ncid;
2676
2684
  varid = Netcdf_var->varid;
2677
-
2685
+
2678
2686
  status = nc_inq_varndims(ncid,varid,&ndims);
2679
2687
  if(status != NC_NOERR) NC_RAISE(status);
2680
2688
  if(ndims == 0) {
@@ -2684,7 +2692,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
2684
2692
  dimids = ALLOCA_N(int,ndims);
2685
2693
  status = nc_inq_vardimid(ncid,varid,dimids);
2686
2694
  if(status != NC_NOERR) NC_RAISE(status);
2687
-
2695
+
2688
2696
  Check_Type(start,T_ARRAY);
2689
2697
  if(RARRAY_LEN(start) < ndims){
2690
2698
  rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
@@ -2692,7 +2700,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
2692
2700
  c_start = ALLOCA_N(size_t,ndims);
2693
2701
  for(i=0; i<ndims; i++){
2694
2702
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2695
-
2703
+
2696
2704
  if(l_start < 0) {
2697
2705
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
2698
2706
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2745,14 +2753,14 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
2745
2753
  }
2746
2754
  }
2747
2755
 
2748
-
2756
+
2749
2757
  shape = ALLOCA_N(na_shape_t,ndims);
2750
2758
  for(i=0;i<ndims;i++){
2751
2759
  shape[ndims-1-i]=c_count[i];
2752
2760
  }
2753
-
2761
+
2754
2762
  Cbyte_to_NArray(NArray,ndims,shape,ptr);
2755
-
2763
+
2756
2764
  status = nc_get_vars_text(ncid,varid,c_start,c_count,c_stride,(char *)ptr);
2757
2765
  if(status != NC_NOERR) NC_RAISE(status);
2758
2766
 
@@ -2782,7 +2790,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
2782
2790
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
2783
2791
  ncid = Netcdf_var->ncid;
2784
2792
  varid = Netcdf_var->varid;
2785
-
2793
+
2786
2794
  status = nc_inq_varndims(ncid,varid,&ndims);
2787
2795
  if(status != NC_NOERR) NC_RAISE(status);
2788
2796
  if(ndims == 0) {
@@ -2792,7 +2800,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
2792
2800
  dimids = ALLOCA_N(int,ndims);
2793
2801
  status = nc_inq_vardimid(ncid,varid,dimids);
2794
2802
  if(status != NC_NOERR) NC_RAISE(status);
2795
-
2803
+
2796
2804
  Check_Type(start,T_ARRAY);
2797
2805
  if(RARRAY_LEN(start) < ndims){
2798
2806
  rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
@@ -2800,7 +2808,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
2800
2808
  c_start = ALLOCA_N(size_t,ndims);
2801
2809
  for(i=0; i<ndims; i++){
2802
2810
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2803
-
2811
+
2804
2812
  if(l_start < 0) {
2805
2813
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
2806
2814
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2853,14 +2861,14 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
2853
2861
  }
2854
2862
  }
2855
2863
 
2856
-
2864
+
2857
2865
  shape = ALLOCA_N(na_shape_t,ndims);
2858
2866
  for(i=0;i<ndims;i++){
2859
2867
  shape[ndims-1-i]=c_count[i];
2860
2868
  }
2861
-
2869
+
2862
2870
  Cbyte_to_NArray(NArray,ndims,shape,ptr);
2863
-
2871
+
2864
2872
  status = nc_get_vars_uchar(ncid,varid,c_start,c_count,c_stride,ptr);
2865
2873
  if(status != NC_NOERR) NC_RAISE(status);
2866
2874
 
@@ -2890,7 +2898,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
2890
2898
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
2891
2899
  ncid = Netcdf_var->ncid;
2892
2900
  varid = Netcdf_var->varid;
2893
-
2901
+
2894
2902
  status = nc_inq_varndims(ncid,varid,&ndims);
2895
2903
  if(status != NC_NOERR) NC_RAISE(status);
2896
2904
  if(ndims == 0) {
@@ -2900,7 +2908,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
2900
2908
  dimids = ALLOCA_N(int,ndims);
2901
2909
  status = nc_inq_vardimid(ncid,varid,dimids);
2902
2910
  if(status != NC_NOERR) NC_RAISE(status);
2903
-
2911
+
2904
2912
  Check_Type(start,T_ARRAY);
2905
2913
  if(RARRAY_LEN(start) < ndims){
2906
2914
  rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
@@ -2908,7 +2916,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
2908
2916
  c_start = ALLOCA_N(size_t,ndims);
2909
2917
  for(i=0; i<ndims; i++){
2910
2918
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
2911
-
2919
+
2912
2920
  if(l_start < 0) {
2913
2921
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
2914
2922
  if(status != NC_NOERR) NC_RAISE(status);
@@ -2960,19 +2968,19 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
2960
2968
  c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
2961
2969
  }
2962
2970
  }
2963
-
2964
-
2971
+
2972
+
2965
2973
  shape = ALLOCA_N(na_shape_t,ndims);
2966
2974
  for(i=0;i<ndims;i++){
2967
2975
  shape[ndims-1-i]=c_count[i];
2968
2976
  }
2969
2977
 
2970
2978
  Csint_to_NArray(NArray,ndims,shape,ptr);
2971
-
2979
+
2972
2980
 
2973
2981
  status = nc_get_vars_short(ncid,varid,c_start,c_count,c_stride,ptr);
2974
2982
  if(status != NC_NOERR) NC_RAISE(status);
2975
-
2983
+
2976
2984
  OBJ_TAINT(NArray);
2977
2985
  return NArray;
2978
2986
  }
@@ -2999,7 +3007,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
2999
3007
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3000
3008
  ncid = Netcdf_var->ncid;
3001
3009
  varid = Netcdf_var->varid;
3002
-
3010
+
3003
3011
  status = nc_inq_varndims(ncid,varid,&ndims);
3004
3012
  if(status != NC_NOERR) NC_RAISE(status);
3005
3013
  if(ndims == 0) {
@@ -3009,7 +3017,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
3009
3017
  dimids = ALLOCA_N(int,ndims);
3010
3018
  status = nc_inq_vardimid(ncid,varid,dimids);
3011
3019
  if(status != NC_NOERR) NC_RAISE(status);
3012
-
3020
+
3013
3021
  Check_Type(start,T_ARRAY);
3014
3022
  if(RARRAY_LEN(start) < ndims){
3015
3023
  rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
@@ -3017,7 +3025,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
3017
3025
  c_start = ALLOCA_N(size_t,ndims);
3018
3026
  for(i=0; i<ndims; i++){
3019
3027
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3020
-
3028
+
3021
3029
  if(l_start < 0) {
3022
3030
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
3023
3031
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3070,14 +3078,14 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
3070
3078
  }
3071
3079
  }
3072
3080
 
3073
-
3081
+
3074
3082
  shape = ALLOCA_N(na_shape_t,ndims);
3075
3083
  for(i=0;i<ndims;i++){
3076
3084
  shape[ndims-1-i]=c_count[i];
3077
3085
  }
3078
3086
 
3079
3087
  Clint_to_NArray(NArray,ndims,shape,ptr);
3080
-
3088
+
3081
3089
 
3082
3090
  status = nc_get_vars_int(ncid,varid,c_start,c_count,c_stride,ptr);
3083
3091
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3108,7 +3116,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
3108
3116
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3109
3117
  ncid = Netcdf_var->ncid;
3110
3118
  varid = Netcdf_var->varid;
3111
-
3119
+
3112
3120
  status = nc_inq_varndims(ncid,varid,&ndims);
3113
3121
  if(status != NC_NOERR) NC_RAISE(status);
3114
3122
  if(ndims == 0) {
@@ -3118,7 +3126,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
3118
3126
  dimids = ALLOCA_N(int,ndims);
3119
3127
  status = nc_inq_vardimid(ncid,varid,dimids);
3120
3128
  if(status != NC_NOERR) NC_RAISE(status);
3121
-
3129
+
3122
3130
  Check_Type(start,T_ARRAY);
3123
3131
  if(RARRAY_LEN(start) < ndims){
3124
3132
  rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
@@ -3126,7 +3134,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
3126
3134
  c_start = ALLOCA_N(size_t,ndims);
3127
3135
  for(i=0; i<ndims; i++){
3128
3136
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3129
-
3137
+
3130
3138
  if(l_start < 0) {
3131
3139
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
3132
3140
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3178,16 +3186,16 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
3178
3186
  c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
3179
3187
  }
3180
3188
  }
3181
-
3189
+
3182
3190
 
3183
3191
  shape = ALLOCA_N(na_shape_t,ndims);
3184
3192
  for(i=0;i<ndims;i++){
3185
3193
  shape[ndims-1-i]=c_count[i];
3186
3194
  }
3187
-
3195
+
3188
3196
  Cfloat_to_NArray(NArray,ndims,shape,ptr);
3189
-
3190
-
3197
+
3198
+
3191
3199
  status = nc_get_vars_float(ncid,varid,c_start,c_count,c_stride,ptr);
3192
3200
  if(status != NC_NOERR) NC_RAISE(status);
3193
3201
 
@@ -3217,7 +3225,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
3217
3225
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3218
3226
  ncid = Netcdf_var->ncid;
3219
3227
  varid = Netcdf_var->varid;
3220
-
3228
+
3221
3229
  status = nc_inq_varndims(ncid,varid,&ndims);
3222
3230
  if(status != NC_NOERR) NC_RAISE(status);
3223
3231
  if(ndims == 0) {
@@ -3227,7 +3235,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
3227
3235
  dimids = ALLOCA_N(int,ndims);
3228
3236
  status = nc_inq_vardimid(ncid,varid,dimids);
3229
3237
  if(status != NC_NOERR) NC_RAISE(status);
3230
-
3238
+
3231
3239
  Check_Type(start,T_ARRAY);
3232
3240
  if(RARRAY_LEN(start) < ndims){
3233
3241
  rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
@@ -3235,7 +3243,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
3235
3243
  c_start = ALLOCA_N(size_t,ndims);
3236
3244
  for(i=0; i<ndims; i++){
3237
3245
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3238
-
3246
+
3239
3247
  if(l_start < 0) {
3240
3248
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
3241
3249
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3287,15 +3295,15 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
3287
3295
  c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
3288
3296
  }
3289
3297
  }
3290
-
3298
+
3291
3299
 
3292
3300
  shape = ALLOCA_N(na_shape_t,ndims);
3293
3301
  for(i=0;i<ndims;i++){
3294
3302
  shape[ndims-1-i]=c_count[i];
3295
3303
  }
3296
-
3304
+
3297
3305
  Cdouble_to_NArray(NArray,ndims,shape,ptr);
3298
-
3306
+
3299
3307
  status = nc_get_vars_double(ncid,varid,c_start,c_count,c_stride,ptr);
3300
3308
  if(status != NC_NOERR) NC_RAISE(status);
3301
3309
 
@@ -3319,13 +3327,12 @@ NetCDF_put_var_char(VALUE Var,VALUE NArray)
3319
3327
  size_t lengthp;
3320
3328
  char *var_name;
3321
3329
 
3322
- rb_secure(3);
3323
3330
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3324
3331
  ncid=Netcdf_var->ncid;
3325
3332
  varid=Netcdf_var->varid;
3326
3333
 
3327
3334
  Array_to_Cbyte_len(NArray,ptr,len);
3328
-
3335
+
3329
3336
  status = nc_inq_varndims(ncid,varid,&ndimsp);
3330
3337
  if(status != NC_NOERR) NC_RAISE(status);
3331
3338
  for(i=0;i<ndimsp;i++){
@@ -3364,13 +3371,12 @@ NetCDF_put_var_byte(VALUE Var,VALUE NArray)
3364
3371
  size_t lengthp;
3365
3372
  char *var_name;
3366
3373
 
3367
- rb_secure(3);
3368
3374
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3369
3375
  ncid=Netcdf_var->ncid;
3370
3376
  varid=Netcdf_var->varid;
3371
3377
 
3372
3378
  Array_to_Cbyte_len(NArray,ptr,len);
3373
-
3379
+
3374
3380
  status = nc_inq_varndims(ncid,varid,&ndimsp);
3375
3381
  if(status != NC_NOERR) NC_RAISE(status);
3376
3382
  for(i=0;i<ndimsp;i++){
@@ -3409,12 +3415,11 @@ NetCDF_put_var_short(VALUE Var,VALUE NArray)
3409
3415
  size_t lengthp;
3410
3416
  char *var_name;
3411
3417
 
3412
- rb_secure(3);
3413
3418
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3414
3419
  ncid=Netcdf_var->ncid;
3415
3420
  varid=Netcdf_var->varid;
3416
3421
  Array_to_Csint_len(NArray,ptr,len);
3417
-
3422
+
3418
3423
  status = nc_inq_varndims(ncid,varid,&ndimsp);
3419
3424
  if(status != NC_NOERR) NC_RAISE(status);
3420
3425
  for(i=0;i<ndimsp;i++){
@@ -3454,7 +3459,6 @@ NetCDF_put_var_int(VALUE Var,VALUE NArray)
3454
3459
  size_t lengthp;
3455
3460
  char *var_name;
3456
3461
 
3457
- rb_secure(3);
3458
3462
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3459
3463
  ncid=Netcdf_var->ncid;
3460
3464
  varid=Netcdf_var->varid;
@@ -3479,8 +3483,8 @@ NetCDF_put_var_int(VALUE Var,VALUE NArray)
3479
3483
  if(status != NC_NOERR) NC_RAISE(status);
3480
3484
  rb_raise(rb_eNetcdfError,"Length of NArray don't equal to length of total array length in the '%s'\n",var_name);
3481
3485
  }
3482
-
3483
-
3486
+
3487
+
3484
3488
  status = nc_put_var_int(ncid,varid,ptr);
3485
3489
  if(status !=NC_NOERR) NC_RAISE(status);
3486
3490
  return Qnil;
@@ -3501,15 +3505,14 @@ NetCDF_put_var_float(VALUE Var,VALUE NArray)
3501
3505
  int dimids[NC_MAX_DIMS];
3502
3506
  size_t lengthp;
3503
3507
  char *var_name;
3504
-
3505
-
3506
- rb_secure(3);
3508
+
3509
+
3507
3510
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3508
3511
  ncid=Netcdf_var->ncid;
3509
3512
  varid=Netcdf_var->varid;
3510
3513
 
3511
3514
  Array_to_Cfloat_len(NArray,ptr,len);
3512
-
3515
+
3513
3516
  status = nc_inq_varndims(ncid,varid,&ndimsp);
3514
3517
  if(status != NC_NOERR) NC_RAISE(status);
3515
3518
  for(i=0;i<ndimsp;i++){
@@ -3550,7 +3553,6 @@ NetCDF_put_var_double(VALUE Var,VALUE NArray)
3550
3553
  char *var_name;
3551
3554
 
3552
3555
 
3553
- rb_secure(3);
3554
3556
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3555
3557
  ncid=Netcdf_var->ncid;
3556
3558
  varid=Netcdf_var->varid;
@@ -3595,19 +3597,18 @@ NetCDF_put_var1_char(VALUE Var,VALUE NArray,VALUE start)
3595
3597
  int ndims;
3596
3598
  int *dimids;
3597
3599
  size_t dimlen;
3598
-
3599
- rb_secure(3);
3600
+
3600
3601
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3601
3602
  ncid=Netcdf_var->ncid;
3602
3603
  varid=Netcdf_var->varid;
3603
3604
  status = nc_inq_varndims(ncid,varid,&ndims);
3604
3605
  if(status != NC_NOERR) NC_RAISE(status);
3605
3606
 
3606
-
3607
+
3607
3608
  dimids = ALLOCA_N(int,ndims);
3608
3609
  status = nc_inq_vardimid(ncid,varid,dimids);
3609
3610
  if(status != NC_NOERR) NC_RAISE(status);
3610
-
3611
+
3611
3612
  Check_Type(start,T_ARRAY);
3612
3613
  if(RARRAY_LEN(start) <ndims) {
3613
3614
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
@@ -3616,7 +3617,7 @@ NetCDF_put_var1_char(VALUE Var,VALUE NArray,VALUE start)
3616
3617
  c_start=ALLOCA_N(size_t,ndims);
3617
3618
  for(i=0;i<ndims;i++){
3618
3619
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3619
-
3620
+
3620
3621
  if(l_start < 0) {
3621
3622
  status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
3622
3623
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3646,19 +3647,18 @@ NetCDF_put_var1_byte(VALUE Var,VALUE NArray,VALUE start)
3646
3647
  int ndims;
3647
3648
  int *dimids;
3648
3649
  size_t dimlen;
3649
-
3650
- rb_secure(3);
3650
+
3651
3651
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3652
3652
  ncid=Netcdf_var->ncid;
3653
3653
  varid=Netcdf_var->varid;
3654
3654
  status = nc_inq_varndims(ncid,varid,&ndims);
3655
3655
  if(status != NC_NOERR) NC_RAISE(status);
3656
3656
 
3657
-
3657
+
3658
3658
  dimids = ALLOCA_N(int,ndims);
3659
3659
  status = nc_inq_vardimid(ncid,varid,dimids);
3660
3660
  if(status != NC_NOERR) NC_RAISE(status);
3661
-
3661
+
3662
3662
  Check_Type(start,T_ARRAY);
3663
3663
  if(RARRAY_LEN(start) <ndims) {
3664
3664
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
@@ -3667,7 +3667,7 @@ NetCDF_put_var1_byte(VALUE Var,VALUE NArray,VALUE start)
3667
3667
  c_start=ALLOCA_N(size_t,ndims);
3668
3668
  for(i=0;i<ndims;i++){
3669
3669
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3670
-
3670
+
3671
3671
  if(l_start < 0) {
3672
3672
  status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
3673
3673
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3697,19 +3697,18 @@ NetCDF_put_var1_sint(VALUE Var,VALUE NArray,VALUE start)
3697
3697
  int ndims;
3698
3698
  int *dimids;
3699
3699
  size_t dimlen;
3700
-
3701
- rb_secure(3);
3700
+
3702
3701
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3703
3702
  ncid=Netcdf_var->ncid;
3704
3703
  varid=Netcdf_var->varid;
3705
3704
  status = nc_inq_varndims(ncid,varid,&ndims);
3706
3705
  if(status != NC_NOERR) NC_RAISE(status);
3707
3706
 
3708
-
3707
+
3709
3708
  dimids = ALLOCA_N(int,ndims);
3710
3709
  status = nc_inq_vardimid(ncid,varid,dimids);
3711
3710
  if(status != NC_NOERR) NC_RAISE(status);
3712
-
3711
+
3713
3712
  Check_Type(start,T_ARRAY);
3714
3713
  if(RARRAY_LEN(start) <ndims) {
3715
3714
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
@@ -3718,7 +3717,7 @@ NetCDF_put_var1_sint(VALUE Var,VALUE NArray,VALUE start)
3718
3717
  c_start=ALLOCA_N(size_t,ndims);
3719
3718
  for(i=0;i<ndims;i++){
3720
3719
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3721
-
3720
+
3722
3721
  if(l_start < 0) {
3723
3722
  status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
3724
3723
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3747,19 +3746,18 @@ NetCDF_put_var1_int(VALUE Var,VALUE NArray,VALUE start)
3747
3746
  int ndims;
3748
3747
  int *dimids;
3749
3748
  size_t dimlen;
3750
-
3751
- rb_secure(3);
3749
+
3752
3750
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3753
3751
  ncid=Netcdf_var->ncid;
3754
3752
  varid=Netcdf_var->varid;
3755
3753
  status = nc_inq_varndims(ncid,varid,&ndims);
3756
3754
  if(status != NC_NOERR) NC_RAISE(status);
3757
3755
 
3758
-
3756
+
3759
3757
  dimids = ALLOCA_N(int,ndims);
3760
3758
  status = nc_inq_vardimid(ncid,varid,dimids);
3761
3759
  if(status != NC_NOERR) NC_RAISE(status);
3762
-
3760
+
3763
3761
  Check_Type(start,T_ARRAY);
3764
3762
  if(RARRAY_LEN(start) <ndims) {
3765
3763
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
@@ -3768,7 +3766,7 @@ NetCDF_put_var1_int(VALUE Var,VALUE NArray,VALUE start)
3768
3766
  c_start=ALLOCA_N(size_t,ndims);
3769
3767
  for(i=0;i<ndims;i++){
3770
3768
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3771
-
3769
+
3772
3770
  if(l_start < 0) {
3773
3771
  status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
3774
3772
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3798,19 +3796,18 @@ NetCDF_put_var1_float(VALUE Var,VALUE NArray,VALUE start)
3798
3796
  int ndims;
3799
3797
  int *dimids;
3800
3798
  size_t dimlen;
3801
-
3802
- rb_secure(3);
3799
+
3803
3800
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3804
3801
  ncid=Netcdf_var->ncid;
3805
3802
  varid=Netcdf_var->varid;
3806
3803
  status = nc_inq_varndims(ncid,varid,&ndims);
3807
3804
  if(status != NC_NOERR) NC_RAISE(status);
3808
3805
 
3809
-
3806
+
3810
3807
  dimids = ALLOCA_N(int,ndims);
3811
3808
  status = nc_inq_vardimid(ncid,varid,dimids);
3812
3809
  if(status != NC_NOERR) NC_RAISE(status);
3813
-
3810
+
3814
3811
  Check_Type(start,T_ARRAY);
3815
3812
  if(RARRAY_LEN(start) <ndims) {
3816
3813
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
@@ -3819,7 +3816,7 @@ NetCDF_put_var1_float(VALUE Var,VALUE NArray,VALUE start)
3819
3816
  c_start=ALLOCA_N(size_t,ndims);
3820
3817
  for(i=0;i<ndims;i++){
3821
3818
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3822
-
3819
+
3823
3820
  if(l_start < 0) {
3824
3821
  status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
3825
3822
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3849,19 +3846,18 @@ NetCDF_put_var1_double(VALUE Var,VALUE NArray,VALUE start)
3849
3846
  int ndims;
3850
3847
  int *dimids;
3851
3848
  size_t dimlen;
3852
-
3853
- rb_secure(3);
3849
+
3854
3850
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3855
3851
  ncid=Netcdf_var->ncid;
3856
3852
  varid=Netcdf_var->varid;
3857
3853
  status = nc_inq_varndims(ncid,varid,&ndims);
3858
3854
  if(status != NC_NOERR) NC_RAISE(status);
3859
3855
 
3860
-
3856
+
3861
3857
  dimids = ALLOCA_N(int,ndims);
3862
3858
  status = nc_inq_vardimid(ncid,varid,dimids);
3863
3859
  if(status != NC_NOERR) NC_RAISE(status);
3864
-
3860
+
3865
3861
  Check_Type(start,T_ARRAY);
3866
3862
  if(RARRAY_LEN(start) <ndims) {
3867
3863
  rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
@@ -3870,7 +3866,7 @@ NetCDF_put_var1_double(VALUE Var,VALUE NArray,VALUE start)
3870
3866
  c_start=ALLOCA_N(size_t,ndims);
3871
3867
  for(i=0;i<ndims;i++){
3872
3868
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3873
-
3869
+
3874
3870
  if(l_start < 0) {
3875
3871
  status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
3876
3872
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3906,7 +3902,6 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3906
3902
  int *dimids;
3907
3903
  size_t dimlen;
3908
3904
 
3909
- rb_secure(3);
3910
3905
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
3911
3906
  ncid=Netcdf_var->ncid;
3912
3907
  varid=Netcdf_var->varid;
@@ -3919,12 +3914,12 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3919
3914
 
3920
3915
  Check_Type(start,T_ARRAY);
3921
3916
  if(RARRAY_LEN(start) < ndims) {
3922
- rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
3917
+ rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
3923
3918
  }
3924
3919
  c_start=ALLOCA_N(size_t,ndims);
3925
3920
  for(i=0; i<ndims; i++){
3926
3921
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
3927
-
3922
+
3928
3923
  if(l_start < 0) {
3929
3924
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
3930
3925
  if(status != NC_NOERR) NC_RAISE(status);
@@ -3932,7 +3927,7 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3932
3927
  }
3933
3928
  c_start[i]=l_start;
3934
3929
  }
3935
-
3930
+
3936
3931
  c_stride=ALLOCA_N(ptrdiff_t,ndims);
3937
3932
  switch(TYPE(stride)){
3938
3933
  case T_NIL:
@@ -3943,12 +3938,12 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3943
3938
  default:
3944
3939
  Check_Type(stride,T_ARRAY);
3945
3940
  if(RARRAY_LEN(stride) < ndims) {
3946
- rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
3941
+ rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
3947
3942
  }
3948
3943
  for(i=0; i<ndims; i++){
3949
3944
  c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
3950
3945
  if(c_stride[i]==0) {
3951
- rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
3946
+ rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
3952
3947
  }
3953
3948
  }
3954
3949
  }
@@ -3966,7 +3961,7 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3966
3961
  default:
3967
3962
  Check_Type(end,T_ARRAY);
3968
3963
  if(RARRAY_LEN(end) < ndims) {
3969
- rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
3964
+ rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
3970
3965
  }
3971
3966
  for(i=0; i<ndims; i++){
3972
3967
  l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
@@ -3983,11 +3978,11 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
3983
3978
  ptr = ALLOCA_N(unsigned char,c_count_all);
3984
3979
  for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
3985
3980
  } else if(len != c_count_all) {
3986
- rb_raise(rb_eNetcdfError,
3987
- "lengh of the array does not agree with that of the subset\n");
3988
- }
3989
- }
3990
-
3981
+ rb_raise(rb_eNetcdfError,
3982
+ "lengh of the array does not agree with that of the subset\n");
3983
+ }
3984
+ }
3985
+
3991
3986
  status = nc_put_vars_text(ncid,varid,c_start,c_count,c_stride,(char *)ptr);
3992
3987
  if(status != NC_NOERR) NC_RAISE(status);
3993
3988
  return Qnil;
@@ -4012,7 +4007,6 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4012
4007
  int *dimids;
4013
4008
  size_t dimlen;
4014
4009
 
4015
- rb_secure(3);
4016
4010
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4017
4011
  ncid=Netcdf_var->ncid;
4018
4012
  varid=Netcdf_var->varid;
@@ -4025,12 +4019,12 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4025
4019
 
4026
4020
  Check_Type(start,T_ARRAY);
4027
4021
  if(RARRAY_LEN(start) < ndims) {
4028
- rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4022
+ rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4029
4023
  }
4030
4024
  c_start=ALLOCA_N(size_t,ndims);
4031
4025
  for(i=0; i<ndims; i++){
4032
4026
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
4033
-
4027
+
4034
4028
  if(l_start < 0) {
4035
4029
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
4036
4030
  if(status != NC_NOERR) NC_RAISE(status);
@@ -4038,7 +4032,7 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4038
4032
  }
4039
4033
  c_start[i]=l_start;
4040
4034
  }
4041
-
4035
+
4042
4036
  c_stride=ALLOCA_N(ptrdiff_t,ndims);
4043
4037
  switch(TYPE(stride)){
4044
4038
  case T_NIL:
@@ -4049,12 +4043,12 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4049
4043
  default:
4050
4044
  Check_Type(stride,T_ARRAY);
4051
4045
  if(RARRAY_LEN(stride) < ndims) {
4052
- rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4046
+ rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4053
4047
  }
4054
4048
  for(i=0; i<ndims; i++){
4055
4049
  c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
4056
4050
  if(c_stride[i]==0) {
4057
- rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4051
+ rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4058
4052
  }
4059
4053
  }
4060
4054
  }
@@ -4072,7 +4066,7 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4072
4066
  default:
4073
4067
  Check_Type(end,T_ARRAY);
4074
4068
  if(RARRAY_LEN(end) < ndims) {
4075
- rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4069
+ rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4076
4070
  }
4077
4071
  for(i=0; i<ndims; i++){
4078
4072
  l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
@@ -4089,11 +4083,11 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4089
4083
  ptr = ALLOCA_N(unsigned char,c_count_all);
4090
4084
  for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
4091
4085
  } else if(len != c_count_all) {
4092
- rb_raise(rb_eNetcdfError,
4093
- "lengh of the array does not agree with that of the subset\n");
4094
- }
4095
- }
4096
-
4086
+ rb_raise(rb_eNetcdfError,
4087
+ "lengh of the array does not agree with that of the subset\n");
4088
+ }
4089
+ }
4090
+
4097
4091
  status = nc_put_vars_uchar(ncid,varid,c_start,c_count,c_stride,ptr);
4098
4092
  if(status != NC_NOERR) NC_RAISE(status);
4099
4093
  return Qnil;
@@ -4118,7 +4112,6 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4118
4112
  int *dimids;
4119
4113
  size_t dimlen;
4120
4114
 
4121
- rb_secure(3);
4122
4115
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4123
4116
  ncid=Netcdf_var->ncid;
4124
4117
  varid=Netcdf_var->varid;
@@ -4131,12 +4124,12 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4131
4124
 
4132
4125
  Check_Type(start,T_ARRAY);
4133
4126
  if(RARRAY_LEN(start) < ndims) {
4134
- rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4127
+ rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4135
4128
  }
4136
4129
  c_start=ALLOCA_N(size_t,ndims);
4137
4130
  for(i=0; i<ndims; i++){
4138
4131
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
4139
-
4132
+
4140
4133
  if(l_start < 0) {
4141
4134
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
4142
4135
  if(status != NC_NOERR) NC_RAISE(status);
@@ -4144,7 +4137,7 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4144
4137
  }
4145
4138
  c_start[i]=l_start;
4146
4139
  }
4147
-
4140
+
4148
4141
  c_stride=ALLOCA_N(ptrdiff_t,ndims);
4149
4142
  switch(TYPE(stride)){
4150
4143
  case T_NIL:
@@ -4155,12 +4148,12 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4155
4148
  default:
4156
4149
  Check_Type(stride,T_ARRAY);
4157
4150
  if(RARRAY_LEN(stride) < ndims) {
4158
- rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4151
+ rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4159
4152
  }
4160
4153
  for(i=0; i<ndims; i++){
4161
4154
  c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
4162
4155
  if(c_stride[i]==0) {
4163
- rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4156
+ rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4164
4157
  }
4165
4158
  }
4166
4159
  }
@@ -4178,7 +4171,7 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4178
4171
  default:
4179
4172
  Check_Type(end,T_ARRAY);
4180
4173
  if(RARRAY_LEN(end) < ndims) {
4181
- rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4174
+ rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4182
4175
  }
4183
4176
  for(i=0; i<ndims; i++){
4184
4177
  l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
@@ -4195,8 +4188,8 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4195
4188
  ptr = ALLOCA_N(short,c_count_all);
4196
4189
  for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
4197
4190
  } else if(len != c_count_all) {
4198
- rb_raise(rb_eNetcdfError,
4199
- "lengh of the array does not agree with that of the subset\n");
4191
+ rb_raise(rb_eNetcdfError,
4192
+ "lengh of the array does not agree with that of the subset\n");
4200
4193
  }
4201
4194
  }
4202
4195
 
@@ -4225,7 +4218,6 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4225
4218
  int *dimids;
4226
4219
  size_t dimlen;
4227
4220
 
4228
- rb_secure(3);
4229
4221
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4230
4222
  ncid=Netcdf_var->ncid;
4231
4223
  varid=Netcdf_var->varid;
@@ -4238,12 +4230,12 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4238
4230
 
4239
4231
  Check_Type(start,T_ARRAY);
4240
4232
  if(RARRAY_LEN(start) < ndims) {
4241
- rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4233
+ rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4242
4234
  }
4243
4235
  c_start=ALLOCA_N(size_t,ndims);
4244
4236
  for(i=0; i<ndims; i++){
4245
4237
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
4246
-
4238
+
4247
4239
  if(l_start < 0) {
4248
4240
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
4249
4241
  if(status != NC_NOERR) NC_RAISE(status);
@@ -4251,7 +4243,7 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4251
4243
  }
4252
4244
  c_start[i]=l_start;
4253
4245
  }
4254
-
4246
+
4255
4247
  c_stride=ALLOCA_N(ptrdiff_t,ndims);
4256
4248
  switch(TYPE(stride)){
4257
4249
  case T_NIL:
@@ -4262,12 +4254,12 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4262
4254
  default:
4263
4255
  Check_Type(stride,T_ARRAY);
4264
4256
  if(RARRAY_LEN(stride) < ndims) {
4265
- rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4257
+ rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4266
4258
  }
4267
4259
  for(i=0; i<ndims; i++){
4268
4260
  c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
4269
4261
  if(c_stride[i]==0) {
4270
- rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4262
+ rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4271
4263
  }
4272
4264
  }
4273
4265
  }
@@ -4285,7 +4277,7 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4285
4277
  default:
4286
4278
  Check_Type(end,T_ARRAY);
4287
4279
  if(RARRAY_LEN(end) < ndims) {
4288
- rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4280
+ rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4289
4281
  }
4290
4282
  for(i=0; i<ndims; i++){
4291
4283
  l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
@@ -4302,8 +4294,8 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4302
4294
  ptr = ALLOCA_N(int,c_count_all);
4303
4295
  for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
4304
4296
  } else if(len != c_count_all) {
4305
- rb_raise(rb_eNetcdfError,
4306
- "length of the array does not agree with that of the subset\n");
4297
+ rb_raise(rb_eNetcdfError,
4298
+ "length of the array does not agree with that of the subset\n");
4307
4299
  }
4308
4300
  }
4309
4301
 
@@ -4332,7 +4324,6 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4332
4324
  int *dimids;
4333
4325
  size_t dimlen;
4334
4326
 
4335
- rb_secure(3);
4336
4327
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4337
4328
  ncid=Netcdf_var->ncid;
4338
4329
  varid=Netcdf_var->varid;
@@ -4345,12 +4336,12 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4345
4336
 
4346
4337
  Check_Type(start,T_ARRAY);
4347
4338
  if(RARRAY_LEN(start) < ndims) {
4348
- rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4339
+ rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4349
4340
  }
4350
4341
  c_start=ALLOCA_N(size_t,ndims);
4351
4342
  for(i=0; i<ndims; i++){
4352
4343
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
4353
-
4344
+
4354
4345
  if(l_start < 0) {
4355
4346
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
4356
4347
  if(status != NC_NOERR) NC_RAISE(status);
@@ -4358,7 +4349,7 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4358
4349
  }
4359
4350
  c_start[i]=l_start;
4360
4351
  }
4361
-
4352
+
4362
4353
  c_stride=ALLOCA_N(ptrdiff_t,ndims);
4363
4354
  switch(TYPE(stride)){
4364
4355
  case T_NIL:
@@ -4369,12 +4360,12 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4369
4360
  default:
4370
4361
  Check_Type(stride,T_ARRAY);
4371
4362
  if(RARRAY_LEN(stride) < ndims) {
4372
- rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4363
+ rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4373
4364
  }
4374
4365
  for(i=0; i<ndims; i++){
4375
4366
  c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
4376
4367
  if(c_stride[i]==0) {
4377
- rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4368
+ rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4378
4369
  }
4379
4370
  }
4380
4371
  }
@@ -4392,7 +4383,7 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4392
4383
  default:
4393
4384
  Check_Type(end,T_ARRAY);
4394
4385
  if(RARRAY_LEN(end) < ndims) {
4395
- rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4386
+ rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4396
4387
  }
4397
4388
  for(i=0; i<ndims; i++){
4398
4389
  l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
@@ -4409,8 +4400,8 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
4409
4400
  ptr = ALLOCA_N(float,c_count_all);
4410
4401
  for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
4411
4402
  } else if(len != c_count_all) {
4412
- rb_raise(rb_eNetcdfError,
4413
- "lengh of the array does not agree with that of the subset\n");
4403
+ rb_raise(rb_eNetcdfError,
4404
+ "lengh of the array does not agree with that of the subset\n");
4414
4405
  }
4415
4406
  }
4416
4407
 
@@ -4439,7 +4430,6 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
4439
4430
  int *dimids;
4440
4431
  size_t dimlen;
4441
4432
 
4442
- rb_secure(3);
4443
4433
  Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
4444
4434
  ncid=Netcdf_var->ncid;
4445
4435
  varid=Netcdf_var->varid;
@@ -4452,12 +4442,12 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
4452
4442
 
4453
4443
  Check_Type(start,T_ARRAY);
4454
4444
  if(RARRAY_LEN(start) < ndims) {
4455
- rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4445
+ rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
4456
4446
  }
4457
4447
  c_start=ALLOCA_N(size_t,ndims);
4458
4448
  for(i=0; i<ndims; i++){
4459
4449
  l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
4460
-
4450
+
4461
4451
  if(l_start < 0) {
4462
4452
  status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
4463
4453
  if(status != NC_NOERR) NC_RAISE(status);
@@ -4465,7 +4455,7 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
4465
4455
  }
4466
4456
  c_start[i]=l_start;
4467
4457
  }
4468
-
4458
+
4469
4459
  c_stride=ALLOCA_N(ptrdiff_t,ndims);
4470
4460
  switch(TYPE(stride)){
4471
4461
  case T_NIL:
@@ -4476,12 +4466,12 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
4476
4466
  default:
4477
4467
  Check_Type(stride,T_ARRAY);
4478
4468
  if(RARRAY_LEN(stride) < ndims) {
4479
- rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4469
+ rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
4480
4470
  }
4481
4471
  for(i=0; i<ndims; i++){
4482
4472
  c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
4483
4473
  if(c_stride[i]==0) {
4484
- rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4474
+ rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
4485
4475
  }
4486
4476
  }
4487
4477
  }
@@ -4499,7 +4489,7 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
4499
4489
  default:
4500
4490
  Check_Type(end,T_ARRAY);
4501
4491
  if(RARRAY_LEN(end) < ndims) {
4502
- rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4492
+ rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
4503
4493
  }
4504
4494
  for(i=0; i<ndims; i++){
4505
4495
  l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
@@ -4516,8 +4506,8 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
4516
4506
  ptr = ALLOCA_N(double,c_count_all);
4517
4507
  for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
4518
4508
  } else if(len != c_count_all) {
4519
- rb_raise(rb_eNetcdfError,
4520
- "lengh of the array does not agree with that of the subset\n");
4509
+ rb_raise(rb_eNetcdfError,
4510
+ "lengh of the array does not agree with that of the subset\n");
4521
4511
  }
4522
4512
  }
4523
4513
 
@@ -4565,7 +4555,7 @@ Init_netcdfraw(void)
4565
4555
  rb_eNetcdfEdge = rb_define_class("NetcdfEdge",rb_eNetcdfError);
4566
4556
  rb_eNetcdfStride = rb_define_class("NetcdfStride",rb_eNetcdfError);
4567
4557
  rb_eNetcdfBadname = rb_define_class("NetcdfBadname",rb_eNetcdfError);
4568
- /* N.B. following must match value in ncx.h */
4558
+ /* N.B. following must match value in ncx.h */
4569
4559
  rb_eNetcdfRange = rb_define_class("NetcdfRange",rb_eNetcdfError);
4570
4560
  rb_eNetcdfNomem = rb_define_class("NetcdfNomem",rb_eNetcdfError);
4571
4561
  /* Global error status */
@@ -4583,16 +4573,21 @@ Init_netcdfraw(void)
4583
4573
  rb_define_const(cNetCDF, "NC_NOCLOBBER", INT2FIX(NC_NOCLOBBER));
4584
4574
  #if NCVER >= 400
4585
4575
  rb_define_const(cNetCDF, "NC_64BIT_OFFSET", INT2FIX(NC_64BIT_OFFSET));
4586
- /* NC_64BIT_OFFSET supports large files in the class data format */
4576
+ /* NC_64BIT_OFFSET supports large files in the class data format */
4587
4577
  rb_define_const(cNetCDF, "NC_NETCDF4", INT2FIX(NC_NETCDF4));
4588
4578
  rb_define_const(cNetCDF, "NC_CLASSIC_MODEL", INT2FIX(NC_CLASSIC_MODEL));
4589
- /* for use as ( NC_NETCDF4 | NC_CLASSIC_MODEL ) to ensure the classic
4579
+ /* for use as ( NC_NETCDF4 | NC_CLASSIC_MODEL ) to ensure the classic
4590
4580
  data model in NetCDF4 by disabling new features like groups */
4591
4581
  rb_define_const(cNetCDF, "NC_ENDIAN_NATIVE", INT2FIX(NC_ENDIAN_NATIVE));
4592
4582
  rb_define_const(cNetCDF, "NC_ENDIAN_LITTLE", INT2FIX(NC_ENDIAN_LITTLE));
4593
4583
  rb_define_const(cNetCDF, "NC_ENDIAN_BIG", INT2FIX(NC_ENDIAN_BIG));
4584
+
4585
+ rb_define_const(cNetCDF, "NC_FORMAT_CLASSIC", INT2FIX(NC_FORMAT_CLASSIC));
4586
+ rb_define_const(cNetCDF, "NC_FORMAT_64BIT", INT2FIX(NC_FORMAT_64BIT));
4587
+ rb_define_const(cNetCDF, "NC_FORMAT_NETCDF4", INT2FIX(NC_FORMAT_NETCDF4));
4588
+ rb_define_const(cNetCDF, "NC_FORMAT_NETCDF4_CLASSIC", INT2FIX(NC_FORMAT_NETCDF4_CLASSIC));
4594
4589
  #endif
4595
-
4590
+
4596
4591
  #ifdef NARRAY_BIGMEM
4597
4592
  rb_define_const(cNetCDF, "SUPPORT_BIGMEM", Qtrue);
4598
4593
  #else
@@ -4617,6 +4612,9 @@ Init_netcdfraw(void)
4617
4612
  rb_define_method(cNetCDF,"ndims",NetCDF_ndims,0);
4618
4613
  rb_define_method(cNetCDF,"nvars",NetCDF_nvars,0);
4619
4614
  rb_define_method(cNetCDF,"natts",NetCDF_natts,0);
4615
+ #if NCVER >= 400
4616
+ rb_define_method(cNetCDF,"format",NetCDF_format,0);
4617
+ #endif
4620
4618
  rb_define_method(cNetCDF,"sync",NetCDF_sync,0);
4621
4619
  rb_define_method(cNetCDF,"path",NetCDF_path,0);
4622
4620
  rb_define_method(cNetCDF,"dim",NetCDF_dim,1);
@@ -4626,7 +4624,7 @@ Init_netcdfraw(void)
4626
4624
  rb_define_private_method(cNetCDF,"id2var",NetCDF_id2var,1);
4627
4625
  rb_define_private_method(cNetCDF,"id2dim",NetCDF_id2dim,1);
4628
4626
  rb_define_private_method(cNetCDF,"id2att",NetCDF_id2att,1);
4629
- rb_define_method(cNetCDF,"==",NetCDF_eql,1);
4627
+ rb_define_method(cNetCDF,"==",NetCDF_eql,1);
4630
4628
  /* rb_define_method(cNetCDF,"eql?",NetCDF_eql,1); */
4631
4629
 
4632
4630
  /* The methods of the NetCDFDim class */
@@ -4704,7 +4702,7 @@ Init_netcdfraw(void)
4704
4702
  rb_define_method(cNetCDFVar,"get_var_int",NetCDF_get_var_int,0);
4705
4703
  rb_define_method(cNetCDFVar,"get_var_sfloat",NetCDF_get_var_float,0);
4706
4704
  rb_define_method(cNetCDFVar,"get_var_float",NetCDF_get_var_double,0);
4707
-
4705
+
4708
4706
  rb_define_method(cNetCDFVar,"get_vars_char",NetCDF_get_vars_char,3);
4709
4707
  rb_define_method(cNetCDFVar,"get_vars_byte",NetCDF_get_vars_byte,3);
4710
4708
  rb_define_method(cNetCDFVar,"get_vars_sint",NetCDF_get_vars_sint,3);