ruby-netcdf 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -1
- data/ChangeLog +456 -0
- data/LICENSE.txt +32 -57
- data/ext/numru/netcdfraw.c +287 -321
- data/lib/numru/netcdf/version.rb +1 -1
- data/lib/numru/netcdf.rb +634 -638
- data/ruby-netcdf-bigmem.gemspec +1 -0
- data/ruby-netcdf.gemspec +1 -0
- data/test/aref_aset.rb +63 -33
- data/test/char_var.rb +32 -21
- data/test/clone.rb +46 -51
- data/test/create_tmp.rb +17 -13
- data/test/def_var_with_dim.rb +29 -11
- data/test/factor_offset.rb +77 -46
- data/test/putatt.rb +71 -49
- data/test/test.rb +197 -190
- data/test/type.rb +27 -11
- metadata +18 -4
data/ext/numru/netcdfraw.c
CHANGED
@@ -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);
|
@@ -1156,7 +1146,7 @@ NetCDF_unlimited(VALUE file)
|
|
1156
1146
|
|
1157
1147
|
#if NCVER >= 400
|
1158
1148
|
|
1159
|
-
VALUE
|
1149
|
+
VALUE
|
1160
1150
|
NetCDF_format(VALUE file)
|
1161
1151
|
{
|
1162
1152
|
int ncid;
|
@@ -1177,7 +1167,7 @@ NetCDF_format(VALUE file)
|
|
1177
1167
|
}
|
1178
1168
|
|
1179
1169
|
#endif
|
1180
|
-
|
1170
|
+
|
1181
1171
|
VALUE
|
1182
1172
|
NetCDF_sync(VALUE file)
|
1183
1173
|
{
|
@@ -1185,7 +1175,6 @@ NetCDF_sync(VALUE file)
|
|
1185
1175
|
int status;
|
1186
1176
|
struct Netcdf *ncfile;
|
1187
1177
|
|
1188
|
-
rb_secure(3);
|
1189
1178
|
Data_Get_Struct(file,struct Netcdf,ncfile);
|
1190
1179
|
ncid=ncfile->ncid;
|
1191
1180
|
status = nc_sync(ncid);
|
@@ -1198,7 +1187,7 @@ NetCDF_path(VALUE file)
|
|
1198
1187
|
{
|
1199
1188
|
char *path;
|
1200
1189
|
struct Netcdf *ncfile;
|
1201
|
-
|
1190
|
+
|
1202
1191
|
Data_Get_Struct(file,struct Netcdf,ncfile);
|
1203
1192
|
path=ncfile->name;
|
1204
1193
|
return(rb_str_new2(path));
|
@@ -1212,14 +1201,14 @@ NetCDF_dim_length(VALUE Dim)
|
|
1212
1201
|
int dimid;
|
1213
1202
|
size_t lengthp;
|
1214
1203
|
struct NetCDFDim *Netcdf_dim;
|
1215
|
-
|
1204
|
+
|
1216
1205
|
Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
|
1217
1206
|
ncid=Netcdf_dim->ncid;
|
1218
1207
|
dimid=Netcdf_dim->dimid;
|
1219
1208
|
|
1220
1209
|
status = nc_inq_dimlen(ncid,dimid,&lengthp);
|
1221
1210
|
if(status != NC_NOERR) NC_RAISE(status);
|
1222
|
-
|
1211
|
+
|
1223
1212
|
return(INT2NUM(lengthp));
|
1224
1213
|
}
|
1225
1214
|
|
@@ -1231,8 +1220,7 @@ NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
|
|
1231
1220
|
int dimid;
|
1232
1221
|
char *c_dim_name;
|
1233
1222
|
struct NetCDFDim *Netcdf_dim;
|
1234
|
-
|
1235
|
-
rb_secure(3);
|
1223
|
+
|
1236
1224
|
Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
|
1237
1225
|
ncid=Netcdf_dim->ncid;
|
1238
1226
|
dimid=Netcdf_dim->dimid;
|
@@ -1241,7 +1229,7 @@ NetCDF_dim_name(VALUE Dim,VALUE dimension_newname)
|
|
1241
1229
|
|
1242
1230
|
status = nc_rename_dim(ncid,dimid,c_dim_name);
|
1243
1231
|
if(status !=NC_NOERR) NC_RAISE(status);
|
1244
|
-
|
1232
|
+
|
1245
1233
|
return Qnil;
|
1246
1234
|
}
|
1247
1235
|
|
@@ -1254,14 +1242,14 @@ NetCDF_dim_inqname(VALUE Dim)
|
|
1254
1242
|
char c_dim_name[NC_MAX_NAME];
|
1255
1243
|
struct NetCDFDim *Netcdf_dim;
|
1256
1244
|
VALUE str;
|
1257
|
-
|
1245
|
+
|
1258
1246
|
Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
|
1259
1247
|
ncid=Netcdf_dim->ncid;
|
1260
1248
|
dimid=Netcdf_dim->dimid;
|
1261
|
-
|
1249
|
+
|
1262
1250
|
status = nc_inq_dimname(ncid,dimid,c_dim_name);
|
1263
1251
|
if(status !=NC_NOERR) NC_RAISE(status);
|
1264
|
-
|
1252
|
+
|
1265
1253
|
str = rb_str_new2(c_dim_name);
|
1266
1254
|
OBJ_TAINT(str);
|
1267
1255
|
return(str);
|
@@ -1273,7 +1261,7 @@ NetCDF_dim_whether_unlimited(VALUE Dim)
|
|
1273
1261
|
int status;
|
1274
1262
|
int uldid;
|
1275
1263
|
struct NetCDFDim *Netcdf_dim;
|
1276
|
-
|
1264
|
+
|
1277
1265
|
Data_Get_Struct(Dim,struct NetCDFDim,Netcdf_dim);
|
1278
1266
|
status=nc_inq_unlimdim(Netcdf_dim->ncid,&uldid);
|
1279
1267
|
if(status !=NC_NOERR) NC_RAISE(status);
|
@@ -1293,7 +1281,7 @@ NetCDF_att_inq_name(VALUE Att)
|
|
1293
1281
|
|
1294
1282
|
Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
|
1295
1283
|
c_att_name=Netcdf_att->name;
|
1296
|
-
|
1284
|
+
|
1297
1285
|
str = rb_str_new2(c_att_name);
|
1298
1286
|
OBJ_TAINT(str);
|
1299
1287
|
return(str);
|
@@ -1311,16 +1299,16 @@ NetCDF_att_rename(VALUE Att,VALUE new_att_name)
|
|
1311
1299
|
Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
|
1312
1300
|
ncid=Netcdf_att->ncid;
|
1313
1301
|
varid=Netcdf_att->varid;
|
1314
|
-
|
1302
|
+
|
1315
1303
|
c_att_name=Netcdf_att->name;
|
1316
|
-
|
1304
|
+
|
1317
1305
|
Check_Type(new_att_name,T_STRING);
|
1318
1306
|
SafeStringValue(new_att_name);
|
1319
1307
|
c_new_att_name=StringValueCStr(new_att_name);
|
1320
|
-
|
1308
|
+
|
1321
1309
|
status = nc_rename_att(ncid,varid,c_att_name,c_new_att_name);
|
1322
1310
|
if(status != NC_NOERR) NC_RAISE(status);
|
1323
|
-
|
1311
|
+
|
1324
1312
|
strcpy(Netcdf_att->name,c_new_att_name);
|
1325
1313
|
return Qnil;
|
1326
1314
|
}
|
@@ -1351,7 +1339,7 @@ NetCDF_id2var(VALUE file,VALUE varid)
|
|
1351
1339
|
struct Netcdf *ncfile;
|
1352
1340
|
struct NetCDFVar *Netcdf_var;
|
1353
1341
|
VALUE Var;
|
1354
|
-
|
1342
|
+
|
1355
1343
|
Data_Get_Struct(file,struct Netcdf,ncfile);
|
1356
1344
|
ncid=ncfile->ncid;
|
1357
1345
|
Check_Type(varid,T_FIXNUM);
|
@@ -1373,7 +1361,7 @@ NetCDF_id2att(VALUE file,VALUE attnum)
|
|
1373
1361
|
char *c_att_name;
|
1374
1362
|
VALUE Att;
|
1375
1363
|
c_att_name=ALLOCA_N(char,NC_MAX_NAME);
|
1376
|
-
|
1364
|
+
|
1377
1365
|
Data_Get_Struct(file,struct Netcdf,ncfile);
|
1378
1366
|
ncid=ncfile->ncid;
|
1379
1367
|
|
@@ -1401,7 +1389,7 @@ NetCDF_var_deflate(int argc, VALUE *argv, VALUE Var)
|
|
1401
1389
|
struct NetCDFVar *Netcdf_var;
|
1402
1390
|
|
1403
1391
|
int shuffle;
|
1404
|
-
/* If non-zero, turn on the shuffle filter.
|
1392
|
+
/* If non-zero, turn on the shuffle filter.
|
1405
1393
|
|
1406
1394
|
http://www.unidata.ucar.edu/software/netcdf/papers/AMS_2008.pdf :
|
1407
1395
|
The shuffle algorithm changes the byte order in the data stream;
|
@@ -1421,7 +1409,7 @@ NetCDF_var_deflate(int argc, VALUE *argv, VALUE Var)
|
|
1421
1409
|
level specified by the deflate_level parameter.
|
1422
1410
|
*/
|
1423
1411
|
|
1424
|
-
if (argc>2 || argc<1) rb_raise(rb_eArgError,
|
1412
|
+
if (argc>2 || argc<1) rb_raise(rb_eArgError,
|
1425
1413
|
"wrong # of arguments (%d). It must be 1 or 2", argc);
|
1426
1414
|
|
1427
1415
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
@@ -1457,7 +1445,7 @@ NetCDF_var_deflate_params(VALUE Var)
|
|
1457
1445
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1458
1446
|
ncid = Netcdf_var->ncid;
|
1459
1447
|
varid = Netcdf_var->varid;
|
1460
|
-
status = nc_inq_var_deflate(ncid, varid, &shufflep, &deflatep,
|
1448
|
+
status = nc_inq_var_deflate(ncid, varid, &shufflep, &deflatep,
|
1461
1449
|
&deflate_levelp);
|
1462
1450
|
if(status != NC_NOERR) NC_RAISE(status);
|
1463
1451
|
if (shufflep==0) {sh=Qfalse;} else {sh=Qtrue;}
|
@@ -1508,7 +1496,7 @@ NetCDF_var_id2att(VALUE Var,VALUE attnum)
|
|
1508
1496
|
struct NetCDFAtt *Netcdf_att;
|
1509
1497
|
char *c_att_name;
|
1510
1498
|
VALUE Att;
|
1511
|
-
|
1499
|
+
|
1512
1500
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1513
1501
|
ncid=Netcdf_var->ncid;
|
1514
1502
|
c_varid=Netcdf_var->varid;
|
@@ -1520,7 +1508,7 @@ NetCDF_var_id2att(VALUE Var,VALUE attnum)
|
|
1520
1508
|
|
1521
1509
|
status = nc_inq_attname(ncid,c_varid,c_attnum,c_att_name);
|
1522
1510
|
if(status != NC_NOERR) NC_RAISE(status);
|
1523
|
-
|
1511
|
+
|
1524
1512
|
Netcdf_att=NetCDF_att_init(ncid,c_varid,c_att_name);
|
1525
1513
|
Att=Data_Wrap_Struct(cNetCDFAtt,0,Netcdf_att_free,Netcdf_att);
|
1526
1514
|
return(Att);
|
@@ -1545,7 +1533,7 @@ NetCDF_var_dims(VALUE Var)
|
|
1545
1533
|
Dims = rb_ary_new();
|
1546
1534
|
for(i=0;i<ndims;i++){
|
1547
1535
|
Netcdf_dim = NetCDF_dim_init(ncid,dimids[ndims-1-i]);
|
1548
|
-
rb_ary_push(Dims,
|
1536
|
+
rb_ary_push(Dims,
|
1549
1537
|
Data_Wrap_Struct(cNetCDFDim,0,NetCDF_dim_free,Netcdf_dim));
|
1550
1538
|
}
|
1551
1539
|
return(Dims);
|
@@ -1589,7 +1577,6 @@ NetCDF_att_copy(VALUE Att,VALUE Var_or_File)
|
|
1589
1577
|
struct Netcdf *ncfile;
|
1590
1578
|
struct NetCDFAtt *Netcdf_att_out;
|
1591
1579
|
|
1592
|
-
rb_secure(3);
|
1593
1580
|
Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
|
1594
1581
|
ncid_in=Netcdf_att->ncid;
|
1595
1582
|
varid_in=Netcdf_att->varid;
|
@@ -1635,7 +1622,7 @@ NetCDF_att_atttype(VALUE Att)
|
|
1635
1622
|
Attname = nctype2natype(xtypep);
|
1636
1623
|
return(rb_str_new2(Attname));
|
1637
1624
|
}
|
1638
|
-
|
1625
|
+
|
1639
1626
|
VALUE
|
1640
1627
|
NetCDF_att_typecode(VALUE Att)
|
1641
1628
|
{
|
@@ -1653,10 +1640,10 @@ NetCDF_att_typecode(VALUE Att)
|
|
1653
1640
|
|
1654
1641
|
status = nc_inq_atttype(ncid,varid,att_name,&xtypep);
|
1655
1642
|
if(status != NC_NOERR) NC_RAISE(status);
|
1656
|
-
|
1643
|
+
|
1657
1644
|
return(INT2NUM(nctype2natypecode(xtypep)));
|
1658
1645
|
}
|
1659
|
-
|
1646
|
+
|
1660
1647
|
VALUE
|
1661
1648
|
NetCDF_att_delete(VALUE Att)
|
1662
1649
|
{
|
@@ -1666,7 +1653,6 @@ NetCDF_att_delete(VALUE Att)
|
|
1666
1653
|
char *c_att_name;
|
1667
1654
|
struct NetCDFAtt *Netcdf_att;
|
1668
1655
|
|
1669
|
-
rb_secure(3);
|
1670
1656
|
Data_Get_Struct(Att,struct NetCDFAtt,Netcdf_att);
|
1671
1657
|
|
1672
1658
|
ncid=Netcdf_att->ncid;
|
@@ -1675,7 +1661,7 @@ NetCDF_att_delete(VALUE Att)
|
|
1675
1661
|
|
1676
1662
|
status = nc_del_att(ncid,varid,c_att_name);
|
1677
1663
|
if(status != NC_NOERR) NC_RAISE(status);
|
1678
|
-
|
1664
|
+
|
1679
1665
|
return Qnil;
|
1680
1666
|
}
|
1681
1667
|
|
@@ -1687,13 +1673,12 @@ NetCDF_att_put(VALUE Att,VALUE value,VALUE atttype)
|
|
1687
1673
|
*/
|
1688
1674
|
{
|
1689
1675
|
struct NetCDFAtt *ncatt;
|
1690
|
-
|
1691
|
-
rb_secure(3);
|
1676
|
+
|
1692
1677
|
Data_Get_Struct(Att,struct NetCDFAtt,ncatt);
|
1693
|
-
return( NetCDF_put_att__(ncatt->ncid, ncatt->name, value,
|
1678
|
+
return( NetCDF_put_att__(ncatt->ncid, ncatt->name, value,
|
1694
1679
|
atttype, ncatt->varid) );
|
1695
1680
|
}
|
1696
|
-
|
1681
|
+
|
1697
1682
|
VALUE
|
1698
1683
|
NetCDF_att_get(VALUE Att)
|
1699
1684
|
{
|
@@ -1740,7 +1725,7 @@ NetCDF_att_get(VALUE Att)
|
|
1740
1725
|
|
1741
1726
|
attlen[0]=lenp;
|
1742
1727
|
Cbyte_to_NArray(NArray,1,attlen,up);
|
1743
|
-
|
1728
|
+
|
1744
1729
|
status = nc_get_att_uchar(ncid,varid,c_attname,up);
|
1745
1730
|
if(status != NC_NOERR) NC_RAISE(status);
|
1746
1731
|
|
@@ -1753,7 +1738,7 @@ NetCDF_att_get(VALUE Att)
|
|
1753
1738
|
|
1754
1739
|
attlen[0]=lenp;
|
1755
1740
|
Csint_to_NArray(NArray,1,attlen,sp);
|
1756
|
-
|
1741
|
+
|
1757
1742
|
status = nc_get_att_short(ncid,varid,c_attname,sp);
|
1758
1743
|
if(status != NC_NOERR) NC_RAISE(status);
|
1759
1744
|
OBJ_TAINT(NArray);
|
@@ -1762,10 +1747,10 @@ NetCDF_att_get(VALUE Att)
|
|
1762
1747
|
case NC_INT:
|
1763
1748
|
status = nc_inq_attlen(ncid,varid,c_attname,&lenp);
|
1764
1749
|
if(status != NC_NOERR) NC_RAISE(status);
|
1765
|
-
|
1750
|
+
|
1766
1751
|
attlen[0]=lenp;
|
1767
1752
|
Clint_to_NArray(NArray,1,attlen,ip);
|
1768
|
-
|
1753
|
+
|
1769
1754
|
status = nc_get_att_int(ncid,varid,c_attname,ip);
|
1770
1755
|
if(status != NC_NOERR) NC_RAISE(status);
|
1771
1756
|
|
@@ -1778,7 +1763,7 @@ NetCDF_att_get(VALUE Att)
|
|
1778
1763
|
|
1779
1764
|
attlen[0]=lenp;
|
1780
1765
|
Cfloat_to_NArray(NArray,1,attlen,fp);
|
1781
|
-
|
1766
|
+
|
1782
1767
|
status = nc_get_att_float(ncid,varid,c_attname,fp);
|
1783
1768
|
if(status != NC_NOERR) NC_RAISE(status);
|
1784
1769
|
|
@@ -1791,7 +1776,7 @@ NetCDF_att_get(VALUE Att)
|
|
1791
1776
|
|
1792
1777
|
attlen[0]=lenp;
|
1793
1778
|
Cdouble_to_NArray(NArray,1,attlen,dp);
|
1794
|
-
|
1779
|
+
|
1795
1780
|
status = nc_get_att_double(ncid,varid,c_attname,dp);
|
1796
1781
|
if(status != NC_NOERR) NC_RAISE(status);
|
1797
1782
|
OBJ_TAINT(NArray);
|
@@ -1803,7 +1788,7 @@ NetCDF_att_get(VALUE Att)
|
|
1803
1788
|
return Qnil;
|
1804
1789
|
}
|
1805
1790
|
|
1806
|
-
|
1791
|
+
|
1807
1792
|
VALUE
|
1808
1793
|
NetCDF_var_inq_name(VALUE Var)
|
1809
1794
|
{
|
@@ -1820,7 +1805,7 @@ NetCDF_var_inq_name(VALUE Var)
|
|
1820
1805
|
varid=Netcdf_var->varid;
|
1821
1806
|
status = nc_inq_varname(ncid,varid,c_var_name);
|
1822
1807
|
if(status != NC_NOERR) NC_RAISE(status);
|
1823
|
-
|
1808
|
+
|
1824
1809
|
Var_name=rb_str_new2(c_var_name);
|
1825
1810
|
OBJ_TAINT(Var_name);
|
1826
1811
|
return Var_name;
|
@@ -1837,7 +1822,7 @@ NetCDF_var_ndims(VALUE Var)
|
|
1837
1822
|
VALUE Var_ndims;
|
1838
1823
|
|
1839
1824
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1840
|
-
|
1825
|
+
|
1841
1826
|
ncid=Netcdf_var->ncid;
|
1842
1827
|
varid=Netcdf_var->varid;
|
1843
1828
|
status = nc_inq_varndims(ncid,varid,&ndimsp);
|
@@ -1855,15 +1840,15 @@ NetCDF_var_vartype(VALUE Var)
|
|
1855
1840
|
nc_type xtypep;
|
1856
1841
|
struct NetCDFVar *Netcdf_var;
|
1857
1842
|
const char *Vartype;
|
1858
|
-
|
1843
|
+
|
1859
1844
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1860
|
-
|
1845
|
+
|
1861
1846
|
ncid=Netcdf_var->ncid;
|
1862
1847
|
varid=Netcdf_var->varid;
|
1863
1848
|
|
1864
1849
|
status = nc_inq_vartype(ncid,varid,&xtypep);
|
1865
1850
|
if(status != NC_NOERR) NC_RAISE(status);
|
1866
|
-
|
1851
|
+
|
1867
1852
|
Vartype=nctype2natype(xtypep);
|
1868
1853
|
return(rb_str_new2(Vartype));
|
1869
1854
|
}
|
@@ -1876,19 +1861,19 @@ NetCDF_var_typecode(VALUE Var)
|
|
1876
1861
|
int varid;
|
1877
1862
|
nc_type xtypep;
|
1878
1863
|
struct NetCDFVar *Netcdf_var;
|
1879
|
-
|
1864
|
+
|
1880
1865
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1881
|
-
|
1866
|
+
|
1882
1867
|
ncid=Netcdf_var->ncid;
|
1883
1868
|
varid=Netcdf_var->varid;
|
1884
1869
|
|
1885
1870
|
status = nc_inq_vartype(ncid,varid,&xtypep);
|
1886
1871
|
if(status != NC_NOERR) NC_RAISE(status);
|
1887
|
-
|
1872
|
+
|
1888
1873
|
return(INT2NUM(nctype2natypecode(xtypep)));
|
1889
1874
|
}
|
1890
1875
|
|
1891
|
-
|
1876
|
+
|
1892
1877
|
VALUE
|
1893
1878
|
NetCDF_var_natts(VALUE Var)
|
1894
1879
|
{
|
@@ -1898,16 +1883,16 @@ NetCDF_var_natts(VALUE Var)
|
|
1898
1883
|
int nattsp;
|
1899
1884
|
struct NetCDFVar *Netcdf_var;
|
1900
1885
|
VALUE Var_natts;
|
1901
|
-
|
1886
|
+
|
1902
1887
|
|
1903
1888
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1904
|
-
|
1889
|
+
|
1905
1890
|
ncid=Netcdf_var->ncid;
|
1906
1891
|
varid=Netcdf_var->varid;
|
1907
|
-
|
1892
|
+
|
1908
1893
|
status= nc_inq_varnatts(ncid,varid,&nattsp);
|
1909
1894
|
if(status !=NC_NOERR) NC_RAISE(status);
|
1910
|
-
|
1895
|
+
|
1911
1896
|
Var_natts=INT2FIX(nattsp);
|
1912
1897
|
return Var_natts;
|
1913
1898
|
}
|
@@ -1918,7 +1903,7 @@ NetCDF_var_file(VALUE Var)
|
|
1918
1903
|
struct NetCDFVar *Netcdf_var;
|
1919
1904
|
/* VALUE file; */
|
1920
1905
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1921
|
-
|
1906
|
+
|
1922
1907
|
return (Netcdf_var->file);
|
1923
1908
|
}
|
1924
1909
|
|
@@ -1930,15 +1915,14 @@ NetCDF_var_rename(VALUE Var,VALUE var_new_name)
|
|
1930
1915
|
int varid;
|
1931
1916
|
char *c_var_new_name;
|
1932
1917
|
struct NetCDFVar *Netcdf_var;
|
1933
|
-
|
1934
|
-
rb_secure(3);
|
1918
|
+
|
1935
1919
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1936
1920
|
ncid=Netcdf_var->ncid;
|
1937
1921
|
varid=Netcdf_var->varid;
|
1938
1922
|
|
1939
1923
|
Check_Type(var_new_name,T_STRING);
|
1940
1924
|
c_var_new_name=StringValueCStr(var_new_name);
|
1941
|
-
|
1925
|
+
|
1942
1926
|
status = nc_rename_var(ncid,varid,c_var_new_name);
|
1943
1927
|
if(status !=NC_NOERR) NC_RAISE(status);
|
1944
1928
|
|
@@ -1958,13 +1942,13 @@ NetCDF_var_att(VALUE Var,VALUE att_name)
|
|
1958
1942
|
VALUE Att;
|
1959
1943
|
|
1960
1944
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
1961
|
-
|
1945
|
+
|
1962
1946
|
ncid=Netcdf_var->ncid;
|
1963
1947
|
varid=Netcdf_var->varid;
|
1964
1948
|
|
1965
1949
|
Check_Type(att_name,T_STRING);
|
1966
1950
|
c_att_name=StringValueCStr(att_name);
|
1967
|
-
|
1951
|
+
|
1968
1952
|
status = nc_inq_attid(ncid,varid,c_att_name,&c_attnump);
|
1969
1953
|
if(status == NC_NOERR){
|
1970
1954
|
Netcdf_att=NetCDF_att_init(ncid,varid,c_att_name);
|
@@ -1982,17 +1966,17 @@ NetCDF_var_att(VALUE Var,VALUE att_name)
|
|
1982
1966
|
|
1983
1967
|
/* Redifinition of the "==" and "eql?" methods */
|
1984
1968
|
|
1985
|
-
VALUE
|
1969
|
+
VALUE
|
1986
1970
|
NetCDF_eql(VALUE filea,VALUE fileb)
|
1987
1971
|
{
|
1988
1972
|
struct Netcdf *ncfilea;
|
1989
1973
|
struct Netcdf *ncfileb;
|
1990
|
-
|
1974
|
+
|
1991
1975
|
if( rb_obj_is_kind_of(fileb, cNetCDF) ){
|
1992
1976
|
Data_Get_Struct(filea,struct Netcdf,ncfilea);
|
1993
1977
|
Data_Get_Struct(fileb,struct Netcdf,ncfileb);
|
1994
|
-
|
1995
|
-
if(ncfilea->ncid == ncfileb->ncid &&
|
1978
|
+
|
1979
|
+
if(ncfilea->ncid == ncfileb->ncid &&
|
1996
1980
|
strcmp(ncfilea->name,ncfileb->name)==0){
|
1997
1981
|
return Qtrue;
|
1998
1982
|
} else {
|
@@ -2008,12 +1992,12 @@ NetCDF_var_eql(VALUE Vara,VALUE Varb)
|
|
2008
1992
|
{
|
2009
1993
|
struct NetCDFVar *Netcdf_vara;
|
2010
1994
|
struct NetCDFVar *Netcdf_varb;
|
2011
|
-
|
1995
|
+
|
2012
1996
|
if( rb_obj_is_kind_of(Varb, cNetCDFVar) ){
|
2013
1997
|
Data_Get_Struct(Vara,struct NetCDFVar,Netcdf_vara);
|
2014
1998
|
Data_Get_Struct(Varb,struct NetCDFVar,Netcdf_varb);
|
2015
1999
|
|
2016
|
-
if(Netcdf_vara->ncid == Netcdf_varb->ncid &&
|
2000
|
+
if(Netcdf_vara->ncid == Netcdf_varb->ncid &&
|
2017
2001
|
Netcdf_vara->varid == Netcdf_varb->varid){
|
2018
2002
|
return Qtrue;
|
2019
2003
|
} else {
|
@@ -2024,7 +2008,7 @@ NetCDF_var_eql(VALUE Vara,VALUE Varb)
|
|
2024
2008
|
}
|
2025
2009
|
}
|
2026
2010
|
|
2027
|
-
VALUE
|
2011
|
+
VALUE
|
2028
2012
|
NetCDF_dim_eql(VALUE Dima,VALUE Dimb)
|
2029
2013
|
{
|
2030
2014
|
struct NetCDFDim *Netcdf_dima;
|
@@ -2033,8 +2017,8 @@ NetCDF_dim_eql(VALUE Dima,VALUE Dimb)
|
|
2033
2017
|
if( rb_obj_is_kind_of(Dimb, cNetCDFDim) ){
|
2034
2018
|
Data_Get_Struct(Dima,struct NetCDFDim,Netcdf_dima);
|
2035
2019
|
Data_Get_Struct(Dimb,struct NetCDFDim,Netcdf_dimb);
|
2036
|
-
|
2037
|
-
if(Netcdf_dima->ncid == Netcdf_dimb->ncid &&
|
2020
|
+
|
2021
|
+
if(Netcdf_dima->ncid == Netcdf_dimb->ncid &&
|
2038
2022
|
Netcdf_dima->dimid == Netcdf_dimb->dimid){
|
2039
2023
|
return Qtrue;
|
2040
2024
|
} else {
|
@@ -2050,16 +2034,16 @@ NetCDF_att_eql(VALUE Atta,VALUE Attb)
|
|
2050
2034
|
{
|
2051
2035
|
struct NetCDFAtt *Netcdf_atta;
|
2052
2036
|
struct NetCDFAtt *Netcdf_attb;
|
2053
|
-
|
2037
|
+
|
2054
2038
|
if( rb_obj_is_kind_of(Attb, cNetCDFAtt) ){
|
2055
2039
|
Data_Get_Struct(Atta,struct NetCDFAtt,Netcdf_atta);
|
2056
2040
|
Data_Get_Struct(Attb,struct NetCDFAtt,Netcdf_attb);
|
2057
|
-
|
2058
|
-
if(Netcdf_atta->ncid == Netcdf_atta->ncid &&
|
2059
|
-
Netcdf_atta->varid == Netcdf_attb->varid &&
|
2041
|
+
|
2042
|
+
if(Netcdf_atta->ncid == Netcdf_atta->ncid &&
|
2043
|
+
Netcdf_atta->varid == Netcdf_attb->varid &&
|
2060
2044
|
strcmp(Netcdf_atta->name,Netcdf_attb->name)==0){
|
2061
2045
|
return Qtrue;
|
2062
|
-
} else {
|
2046
|
+
} else {
|
2063
2047
|
return Qfalse;
|
2064
2048
|
}
|
2065
2049
|
} else {
|
@@ -2104,7 +2088,7 @@ NetCDF_get_var_char(VALUE Var)
|
|
2104
2088
|
}
|
2105
2089
|
|
2106
2090
|
Cbyte_to_NArray(NArray,ndimsp,shape,ptr);
|
2107
|
-
|
2091
|
+
|
2108
2092
|
status = nc_get_var_text(ncid,varid,(char *)ptr);
|
2109
2093
|
if(status != NC_NOERR) NC_RAISE(status);
|
2110
2094
|
|
@@ -2148,7 +2132,7 @@ NetCDF_get_var_byte(VALUE Var)
|
|
2148
2132
|
}
|
2149
2133
|
|
2150
2134
|
Cbyte_to_NArray(NArray,ndimsp,shape,ptr);
|
2151
|
-
|
2135
|
+
|
2152
2136
|
status = nc_get_var_uchar(ncid,varid,ptr);
|
2153
2137
|
if(status != NC_NOERR) NC_RAISE(status);
|
2154
2138
|
|
@@ -2192,7 +2176,7 @@ NetCDF_get_var_sint(VALUE Var)
|
|
2192
2176
|
}
|
2193
2177
|
|
2194
2178
|
Csint_to_NArray(NArray,ndimsp,shape,ptr);
|
2195
|
-
|
2179
|
+
|
2196
2180
|
status = nc_get_var_short(ncid,varid,ptr);
|
2197
2181
|
if(status != NC_NOERR) NC_RAISE(status);
|
2198
2182
|
|
@@ -2236,7 +2220,7 @@ NetCDF_get_var_int(VALUE Var)
|
|
2236
2220
|
}
|
2237
2221
|
|
2238
2222
|
Clint_to_NArray(NArray,ndimsp,shape,ptr);
|
2239
|
-
|
2223
|
+
|
2240
2224
|
status = nc_get_var_int(ncid,varid,ptr);
|
2241
2225
|
if(status != NC_NOERR) NC_RAISE(status);
|
2242
2226
|
|
@@ -2324,7 +2308,7 @@ NetCDF_get_var_double(VALUE Var)
|
|
2324
2308
|
}
|
2325
2309
|
|
2326
2310
|
Cdouble_to_NArray(NArray,ndimsp,shape,ptr);
|
2327
|
-
|
2311
|
+
|
2328
2312
|
status = nc_get_var_double(ncid,varid,ptr);
|
2329
2313
|
if(status != NC_NOERR) NC_RAISE(status);
|
2330
2314
|
|
@@ -2332,7 +2316,7 @@ NetCDF_get_var_double(VALUE Var)
|
|
2332
2316
|
return NArray;
|
2333
2317
|
}
|
2334
2318
|
|
2335
|
-
VALUE
|
2319
|
+
VALUE
|
2336
2320
|
NetCDF_get_var1_char(VALUE Var,VALUE start)
|
2337
2321
|
{
|
2338
2322
|
int ncid;
|
@@ -2349,7 +2333,7 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
|
|
2349
2333
|
na_shape_t *c_count;
|
2350
2334
|
VALUE NArray;
|
2351
2335
|
|
2352
|
-
|
2336
|
+
|
2353
2337
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
2354
2338
|
ncid = Netcdf_var->ncid;
|
2355
2339
|
varid = Netcdf_var->varid;
|
@@ -2358,12 +2342,12 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
|
|
2358
2342
|
if(ndims == 0) {
|
2359
2343
|
rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
|
2360
2344
|
}
|
2361
|
-
|
2345
|
+
|
2362
2346
|
Check_Type(start,T_ARRAY);
|
2363
2347
|
if(RARRAY_LEN(start) < ndims) {
|
2364
2348
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
2365
2349
|
}
|
2366
|
-
|
2350
|
+
|
2367
2351
|
c_start=ALLOCA_N(size_t,ndims);
|
2368
2352
|
c_count=ALLOCA_N(na_shape_t,ndims);
|
2369
2353
|
for(i=0;i<ndims;i++){
|
@@ -2376,13 +2360,13 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
|
|
2376
2360
|
l_start += dimlen;
|
2377
2361
|
}
|
2378
2362
|
c_start[i]=l_start;
|
2379
|
-
|
2363
|
+
|
2380
2364
|
c_count[i]=1;
|
2381
2365
|
}
|
2382
|
-
|
2383
|
-
|
2384
|
-
|
2385
|
-
|
2366
|
+
|
2367
|
+
|
2368
|
+
|
2369
|
+
|
2386
2370
|
Cbyte_to_NArray(NArray,ndims,c_count,ptr);
|
2387
2371
|
status = nc_get_var1_text(ncid,varid,c_start,(char *)ptr);
|
2388
2372
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -2392,7 +2376,7 @@ NetCDF_get_var1_char(VALUE Var,VALUE start)
|
|
2392
2376
|
|
2393
2377
|
}
|
2394
2378
|
|
2395
|
-
VALUE
|
2379
|
+
VALUE
|
2396
2380
|
NetCDF_get_var1_byte(VALUE Var,VALUE start)
|
2397
2381
|
{
|
2398
2382
|
int ncid;
|
@@ -2409,7 +2393,7 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
|
|
2409
2393
|
na_shape_t *c_count;
|
2410
2394
|
VALUE NArray;
|
2411
2395
|
|
2412
|
-
|
2396
|
+
|
2413
2397
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
2414
2398
|
ncid = Netcdf_var->ncid;
|
2415
2399
|
varid = Netcdf_var->varid;
|
@@ -2418,12 +2402,12 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
|
|
2418
2402
|
if(ndims == 0) {
|
2419
2403
|
rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
|
2420
2404
|
}
|
2421
|
-
|
2405
|
+
|
2422
2406
|
Check_Type(start,T_ARRAY);
|
2423
2407
|
if(RARRAY_LEN(start) < ndims) {
|
2424
2408
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
2425
2409
|
}
|
2426
|
-
|
2410
|
+
|
2427
2411
|
c_start=ALLOCA_N(size_t,ndims);
|
2428
2412
|
c_count=ALLOCA_N(na_shape_t,ndims);
|
2429
2413
|
for(i=0;i<ndims;i++){
|
@@ -2436,13 +2420,13 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
|
|
2436
2420
|
l_start += dimlen;
|
2437
2421
|
}
|
2438
2422
|
c_start[i]=l_start;
|
2439
|
-
|
2423
|
+
|
2440
2424
|
c_count[i]=1;
|
2441
2425
|
}
|
2442
|
-
|
2443
|
-
|
2444
|
-
|
2445
|
-
|
2426
|
+
|
2427
|
+
|
2428
|
+
|
2429
|
+
|
2446
2430
|
Cbyte_to_NArray(NArray,ndims,c_count,ptr);
|
2447
2431
|
status = nc_get_var1_uchar(ncid,varid,c_start,ptr);
|
2448
2432
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -2452,7 +2436,7 @@ NetCDF_get_var1_byte(VALUE Var,VALUE start)
|
|
2452
2436
|
|
2453
2437
|
}
|
2454
2438
|
|
2455
|
-
VALUE
|
2439
|
+
VALUE
|
2456
2440
|
NetCDF_get_var1_sint(VALUE Var,VALUE start)
|
2457
2441
|
{
|
2458
2442
|
int ncid;
|
@@ -2477,12 +2461,12 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
|
|
2477
2461
|
if(ndims == 0) {
|
2478
2462
|
rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
|
2479
2463
|
}
|
2480
|
-
|
2464
|
+
|
2481
2465
|
Check_Type(start,T_ARRAY);
|
2482
2466
|
if(RARRAY_LEN(start) < ndims) {
|
2483
2467
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
2484
2468
|
}
|
2485
|
-
|
2469
|
+
|
2486
2470
|
c_start=ALLOCA_N(size_t,ndims);
|
2487
2471
|
c_count=ALLOCA_N(na_shape_t,ndims);
|
2488
2472
|
for(i=0;i<ndims;i++){
|
@@ -2497,9 +2481,9 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
|
|
2497
2481
|
c_start[i]=l_start;
|
2498
2482
|
c_count[i]=1;
|
2499
2483
|
}
|
2500
|
-
|
2484
|
+
|
2501
2485
|
Csint_to_NArray(NArray,ndims,c_count,ptr);
|
2502
|
-
|
2486
|
+
|
2503
2487
|
status = nc_get_var1_short(ncid,varid,c_start,ptr);
|
2504
2488
|
if(status != NC_NOERR) NC_RAISE(status);
|
2505
2489
|
|
@@ -2508,7 +2492,7 @@ NetCDF_get_var1_sint(VALUE Var,VALUE start)
|
|
2508
2492
|
|
2509
2493
|
}
|
2510
2494
|
|
2511
|
-
VALUE
|
2495
|
+
VALUE
|
2512
2496
|
NetCDF_get_var1_int(VALUE Var,VALUE start)
|
2513
2497
|
{
|
2514
2498
|
int ncid;
|
@@ -2533,12 +2517,12 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
|
|
2533
2517
|
if(ndims == 0) {
|
2534
2518
|
rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
|
2535
2519
|
}
|
2536
|
-
|
2520
|
+
|
2537
2521
|
Check_Type(start,T_ARRAY);
|
2538
2522
|
if(RARRAY_LEN(start) < ndims) {
|
2539
2523
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
2540
2524
|
}
|
2541
|
-
|
2525
|
+
|
2542
2526
|
c_start=ALLOCA_N(size_t,ndims);
|
2543
2527
|
c_count=ALLOCA_N(na_shape_t,ndims);
|
2544
2528
|
for(i=0;i<ndims;i++){
|
@@ -2553,9 +2537,9 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
|
|
2553
2537
|
c_start[i]=l_start;
|
2554
2538
|
c_count[i]=1;
|
2555
2539
|
}
|
2556
|
-
|
2540
|
+
|
2557
2541
|
Clint_to_NArray(NArray,ndims,c_count,ptr);
|
2558
|
-
|
2542
|
+
|
2559
2543
|
status = nc_get_var1_int(ncid,varid,c_start,ptr);
|
2560
2544
|
if(status != NC_NOERR) NC_RAISE(status);
|
2561
2545
|
|
@@ -2564,7 +2548,7 @@ NetCDF_get_var1_int(VALUE Var,VALUE start)
|
|
2564
2548
|
|
2565
2549
|
}
|
2566
2550
|
|
2567
|
-
VALUE
|
2551
|
+
VALUE
|
2568
2552
|
NetCDF_get_var1_float(VALUE Var,VALUE start)
|
2569
2553
|
{
|
2570
2554
|
int ncid;
|
@@ -2589,12 +2573,12 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
|
|
2589
2573
|
if(ndims == 0) {
|
2590
2574
|
rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
|
2591
2575
|
}
|
2592
|
-
|
2576
|
+
|
2593
2577
|
Check_Type(start,T_ARRAY);
|
2594
2578
|
if(RARRAY_LEN(start) < ndims) {
|
2595
2579
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
2596
2580
|
}
|
2597
|
-
|
2581
|
+
|
2598
2582
|
c_start=ALLOCA_N(size_t,ndims);
|
2599
2583
|
c_count=ALLOCA_N(na_shape_t,ndims);
|
2600
2584
|
for(i=0;i<ndims;i++){
|
@@ -2609,9 +2593,9 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
|
|
2609
2593
|
c_start[i]=l_start;
|
2610
2594
|
c_count[i]=1;
|
2611
2595
|
}
|
2612
|
-
|
2596
|
+
|
2613
2597
|
Cfloat_to_NArray(NArray,ndims,c_count,ptr);
|
2614
|
-
|
2598
|
+
|
2615
2599
|
status = nc_get_var1_float(ncid,varid,c_start,ptr);
|
2616
2600
|
if(status != NC_NOERR) NC_RAISE(status);
|
2617
2601
|
|
@@ -2620,7 +2604,7 @@ NetCDF_get_var1_float(VALUE Var,VALUE start)
|
|
2620
2604
|
|
2621
2605
|
}
|
2622
2606
|
|
2623
|
-
VALUE
|
2607
|
+
VALUE
|
2624
2608
|
NetCDF_get_var1_double(VALUE Var,VALUE start)
|
2625
2609
|
{
|
2626
2610
|
int ncid;
|
@@ -2645,12 +2629,12 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
|
|
2645
2629
|
if(ndims == 0) {
|
2646
2630
|
rb_raise(rb_eNetcdfError,"Cannot specify a subset of a rank-0 scalar\n");
|
2647
2631
|
}
|
2648
|
-
|
2632
|
+
|
2649
2633
|
Check_Type(start,T_ARRAY);
|
2650
2634
|
if(RARRAY_LEN(start) < ndims) {
|
2651
2635
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
2652
2636
|
}
|
2653
|
-
|
2637
|
+
|
2654
2638
|
c_start=ALLOCA_N(size_t,ndims);
|
2655
2639
|
c_count=ALLOCA_N(na_shape_t,ndims);
|
2656
2640
|
for(i=0;i<ndims;i++){
|
@@ -2665,9 +2649,9 @@ NetCDF_get_var1_double(VALUE Var,VALUE start)
|
|
2665
2649
|
c_start[i]=l_start;
|
2666
2650
|
c_count[i]=1;
|
2667
2651
|
}
|
2668
|
-
|
2652
|
+
|
2669
2653
|
Cdouble_to_NArray(NArray,ndims,c_count,ptr);
|
2670
|
-
|
2654
|
+
|
2671
2655
|
status = nc_get_var1_double(ncid,varid,c_start,ptr);
|
2672
2656
|
if(status != NC_NOERR) NC_RAISE(status);
|
2673
2657
|
|
@@ -2698,7 +2682,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2698
2682
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
2699
2683
|
ncid = Netcdf_var->ncid;
|
2700
2684
|
varid = Netcdf_var->varid;
|
2701
|
-
|
2685
|
+
|
2702
2686
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
2703
2687
|
if(status != NC_NOERR) NC_RAISE(status);
|
2704
2688
|
if(ndims == 0) {
|
@@ -2708,7 +2692,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2708
2692
|
dimids = ALLOCA_N(int,ndims);
|
2709
2693
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
2710
2694
|
if(status != NC_NOERR) NC_RAISE(status);
|
2711
|
-
|
2695
|
+
|
2712
2696
|
Check_Type(start,T_ARRAY);
|
2713
2697
|
if(RARRAY_LEN(start) < ndims){
|
2714
2698
|
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
@@ -2716,7 +2700,7 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2716
2700
|
c_start = ALLOCA_N(size_t,ndims);
|
2717
2701
|
for(i=0; i<ndims; i++){
|
2718
2702
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
2719
|
-
|
2703
|
+
|
2720
2704
|
if(l_start < 0) {
|
2721
2705
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
2722
2706
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -2769,14 +2753,14 @@ NetCDF_get_vars_char(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2769
2753
|
}
|
2770
2754
|
}
|
2771
2755
|
|
2772
|
-
|
2756
|
+
|
2773
2757
|
shape = ALLOCA_N(na_shape_t,ndims);
|
2774
2758
|
for(i=0;i<ndims;i++){
|
2775
2759
|
shape[ndims-1-i]=c_count[i];
|
2776
2760
|
}
|
2777
|
-
|
2761
|
+
|
2778
2762
|
Cbyte_to_NArray(NArray,ndims,shape,ptr);
|
2779
|
-
|
2763
|
+
|
2780
2764
|
status = nc_get_vars_text(ncid,varid,c_start,c_count,c_stride,(char *)ptr);
|
2781
2765
|
if(status != NC_NOERR) NC_RAISE(status);
|
2782
2766
|
|
@@ -2806,7 +2790,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2806
2790
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
2807
2791
|
ncid = Netcdf_var->ncid;
|
2808
2792
|
varid = Netcdf_var->varid;
|
2809
|
-
|
2793
|
+
|
2810
2794
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
2811
2795
|
if(status != NC_NOERR) NC_RAISE(status);
|
2812
2796
|
if(ndims == 0) {
|
@@ -2816,7 +2800,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2816
2800
|
dimids = ALLOCA_N(int,ndims);
|
2817
2801
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
2818
2802
|
if(status != NC_NOERR) NC_RAISE(status);
|
2819
|
-
|
2803
|
+
|
2820
2804
|
Check_Type(start,T_ARRAY);
|
2821
2805
|
if(RARRAY_LEN(start) < ndims){
|
2822
2806
|
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
@@ -2824,7 +2808,7 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2824
2808
|
c_start = ALLOCA_N(size_t,ndims);
|
2825
2809
|
for(i=0; i<ndims; i++){
|
2826
2810
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
2827
|
-
|
2811
|
+
|
2828
2812
|
if(l_start < 0) {
|
2829
2813
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
2830
2814
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -2877,14 +2861,14 @@ NetCDF_get_vars_byte(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2877
2861
|
}
|
2878
2862
|
}
|
2879
2863
|
|
2880
|
-
|
2864
|
+
|
2881
2865
|
shape = ALLOCA_N(na_shape_t,ndims);
|
2882
2866
|
for(i=0;i<ndims;i++){
|
2883
2867
|
shape[ndims-1-i]=c_count[i];
|
2884
2868
|
}
|
2885
|
-
|
2869
|
+
|
2886
2870
|
Cbyte_to_NArray(NArray,ndims,shape,ptr);
|
2887
|
-
|
2871
|
+
|
2888
2872
|
status = nc_get_vars_uchar(ncid,varid,c_start,c_count,c_stride,ptr);
|
2889
2873
|
if(status != NC_NOERR) NC_RAISE(status);
|
2890
2874
|
|
@@ -2914,7 +2898,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2914
2898
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
2915
2899
|
ncid = Netcdf_var->ncid;
|
2916
2900
|
varid = Netcdf_var->varid;
|
2917
|
-
|
2901
|
+
|
2918
2902
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
2919
2903
|
if(status != NC_NOERR) NC_RAISE(status);
|
2920
2904
|
if(ndims == 0) {
|
@@ -2924,7 +2908,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2924
2908
|
dimids = ALLOCA_N(int,ndims);
|
2925
2909
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
2926
2910
|
if(status != NC_NOERR) NC_RAISE(status);
|
2927
|
-
|
2911
|
+
|
2928
2912
|
Check_Type(start,T_ARRAY);
|
2929
2913
|
if(RARRAY_LEN(start) < ndims){
|
2930
2914
|
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
@@ -2932,7 +2916,7 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2932
2916
|
c_start = ALLOCA_N(size_t,ndims);
|
2933
2917
|
for(i=0; i<ndims; i++){
|
2934
2918
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
2935
|
-
|
2919
|
+
|
2936
2920
|
if(l_start < 0) {
|
2937
2921
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
2938
2922
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -2984,19 +2968,19 @@ NetCDF_get_vars_sint(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
2984
2968
|
c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
|
2985
2969
|
}
|
2986
2970
|
}
|
2987
|
-
|
2988
|
-
|
2971
|
+
|
2972
|
+
|
2989
2973
|
shape = ALLOCA_N(na_shape_t,ndims);
|
2990
2974
|
for(i=0;i<ndims;i++){
|
2991
2975
|
shape[ndims-1-i]=c_count[i];
|
2992
2976
|
}
|
2993
2977
|
|
2994
2978
|
Csint_to_NArray(NArray,ndims,shape,ptr);
|
2995
|
-
|
2979
|
+
|
2996
2980
|
|
2997
2981
|
status = nc_get_vars_short(ncid,varid,c_start,c_count,c_stride,ptr);
|
2998
2982
|
if(status != NC_NOERR) NC_RAISE(status);
|
2999
|
-
|
2983
|
+
|
3000
2984
|
OBJ_TAINT(NArray);
|
3001
2985
|
return NArray;
|
3002
2986
|
}
|
@@ -3023,7 +3007,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3023
3007
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3024
3008
|
ncid = Netcdf_var->ncid;
|
3025
3009
|
varid = Netcdf_var->varid;
|
3026
|
-
|
3010
|
+
|
3027
3011
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3028
3012
|
if(status != NC_NOERR) NC_RAISE(status);
|
3029
3013
|
if(ndims == 0) {
|
@@ -3033,7 +3017,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3033
3017
|
dimids = ALLOCA_N(int,ndims);
|
3034
3018
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3035
3019
|
if(status != NC_NOERR) NC_RAISE(status);
|
3036
|
-
|
3020
|
+
|
3037
3021
|
Check_Type(start,T_ARRAY);
|
3038
3022
|
if(RARRAY_LEN(start) < ndims){
|
3039
3023
|
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
@@ -3041,7 +3025,7 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3041
3025
|
c_start = ALLOCA_N(size_t,ndims);
|
3042
3026
|
for(i=0; i<ndims; i++){
|
3043
3027
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3044
|
-
|
3028
|
+
|
3045
3029
|
if(l_start < 0) {
|
3046
3030
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
3047
3031
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3094,14 +3078,14 @@ NetCDF_get_vars_int(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3094
3078
|
}
|
3095
3079
|
}
|
3096
3080
|
|
3097
|
-
|
3081
|
+
|
3098
3082
|
shape = ALLOCA_N(na_shape_t,ndims);
|
3099
3083
|
for(i=0;i<ndims;i++){
|
3100
3084
|
shape[ndims-1-i]=c_count[i];
|
3101
3085
|
}
|
3102
3086
|
|
3103
3087
|
Clint_to_NArray(NArray,ndims,shape,ptr);
|
3104
|
-
|
3088
|
+
|
3105
3089
|
|
3106
3090
|
status = nc_get_vars_int(ncid,varid,c_start,c_count,c_stride,ptr);
|
3107
3091
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3132,7 +3116,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3132
3116
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3133
3117
|
ncid = Netcdf_var->ncid;
|
3134
3118
|
varid = Netcdf_var->varid;
|
3135
|
-
|
3119
|
+
|
3136
3120
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3137
3121
|
if(status != NC_NOERR) NC_RAISE(status);
|
3138
3122
|
if(ndims == 0) {
|
@@ -3142,7 +3126,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3142
3126
|
dimids = ALLOCA_N(int,ndims);
|
3143
3127
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3144
3128
|
if(status != NC_NOERR) NC_RAISE(status);
|
3145
|
-
|
3129
|
+
|
3146
3130
|
Check_Type(start,T_ARRAY);
|
3147
3131
|
if(RARRAY_LEN(start) < ndims){
|
3148
3132
|
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
@@ -3150,7 +3134,7 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3150
3134
|
c_start = ALLOCA_N(size_t,ndims);
|
3151
3135
|
for(i=0; i<ndims; i++){
|
3152
3136
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3153
|
-
|
3137
|
+
|
3154
3138
|
if(l_start < 0) {
|
3155
3139
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
3156
3140
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3202,16 +3186,16 @@ NetCDF_get_vars_float(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3202
3186
|
c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
|
3203
3187
|
}
|
3204
3188
|
}
|
3205
|
-
|
3189
|
+
|
3206
3190
|
|
3207
3191
|
shape = ALLOCA_N(na_shape_t,ndims);
|
3208
3192
|
for(i=0;i<ndims;i++){
|
3209
3193
|
shape[ndims-1-i]=c_count[i];
|
3210
3194
|
}
|
3211
|
-
|
3195
|
+
|
3212
3196
|
Cfloat_to_NArray(NArray,ndims,shape,ptr);
|
3213
|
-
|
3214
|
-
|
3197
|
+
|
3198
|
+
|
3215
3199
|
status = nc_get_vars_float(ncid,varid,c_start,c_count,c_stride,ptr);
|
3216
3200
|
if(status != NC_NOERR) NC_RAISE(status);
|
3217
3201
|
|
@@ -3241,7 +3225,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3241
3225
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3242
3226
|
ncid = Netcdf_var->ncid;
|
3243
3227
|
varid = Netcdf_var->varid;
|
3244
|
-
|
3228
|
+
|
3245
3229
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3246
3230
|
if(status != NC_NOERR) NC_RAISE(status);
|
3247
3231
|
if(ndims == 0) {
|
@@ -3251,7 +3235,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3251
3235
|
dimids = ALLOCA_N(int,ndims);
|
3252
3236
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3253
3237
|
if(status != NC_NOERR) NC_RAISE(status);
|
3254
|
-
|
3238
|
+
|
3255
3239
|
Check_Type(start,T_ARRAY);
|
3256
3240
|
if(RARRAY_LEN(start) < ndims){
|
3257
3241
|
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
@@ -3259,7 +3243,7 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3259
3243
|
c_start = ALLOCA_N(size_t,ndims);
|
3260
3244
|
for(i=0; i<ndims; i++){
|
3261
3245
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3262
|
-
|
3246
|
+
|
3263
3247
|
if(l_start < 0) {
|
3264
3248
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
3265
3249
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3311,15 +3295,15 @@ NetCDF_get_vars_double(VALUE Var,VALUE start,VALUE end,VALUE stride)
|
|
3311
3295
|
c_count[i]=(l_end-c_start[i])/c_stride[i]+1;
|
3312
3296
|
}
|
3313
3297
|
}
|
3314
|
-
|
3298
|
+
|
3315
3299
|
|
3316
3300
|
shape = ALLOCA_N(na_shape_t,ndims);
|
3317
3301
|
for(i=0;i<ndims;i++){
|
3318
3302
|
shape[ndims-1-i]=c_count[i];
|
3319
3303
|
}
|
3320
|
-
|
3304
|
+
|
3321
3305
|
Cdouble_to_NArray(NArray,ndims,shape,ptr);
|
3322
|
-
|
3306
|
+
|
3323
3307
|
status = nc_get_vars_double(ncid,varid,c_start,c_count,c_stride,ptr);
|
3324
3308
|
if(status != NC_NOERR) NC_RAISE(status);
|
3325
3309
|
|
@@ -3343,13 +3327,12 @@ NetCDF_put_var_char(VALUE Var,VALUE NArray)
|
|
3343
3327
|
size_t lengthp;
|
3344
3328
|
char *var_name;
|
3345
3329
|
|
3346
|
-
rb_secure(3);
|
3347
3330
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3348
3331
|
ncid=Netcdf_var->ncid;
|
3349
3332
|
varid=Netcdf_var->varid;
|
3350
3333
|
|
3351
3334
|
Array_to_Cbyte_len(NArray,ptr,len);
|
3352
|
-
|
3335
|
+
|
3353
3336
|
status = nc_inq_varndims(ncid,varid,&ndimsp);
|
3354
3337
|
if(status != NC_NOERR) NC_RAISE(status);
|
3355
3338
|
for(i=0;i<ndimsp;i++){
|
@@ -3388,13 +3371,12 @@ NetCDF_put_var_byte(VALUE Var,VALUE NArray)
|
|
3388
3371
|
size_t lengthp;
|
3389
3372
|
char *var_name;
|
3390
3373
|
|
3391
|
-
rb_secure(3);
|
3392
3374
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3393
3375
|
ncid=Netcdf_var->ncid;
|
3394
3376
|
varid=Netcdf_var->varid;
|
3395
3377
|
|
3396
3378
|
Array_to_Cbyte_len(NArray,ptr,len);
|
3397
|
-
|
3379
|
+
|
3398
3380
|
status = nc_inq_varndims(ncid,varid,&ndimsp);
|
3399
3381
|
if(status != NC_NOERR) NC_RAISE(status);
|
3400
3382
|
for(i=0;i<ndimsp;i++){
|
@@ -3433,12 +3415,11 @@ NetCDF_put_var_short(VALUE Var,VALUE NArray)
|
|
3433
3415
|
size_t lengthp;
|
3434
3416
|
char *var_name;
|
3435
3417
|
|
3436
|
-
rb_secure(3);
|
3437
3418
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3438
3419
|
ncid=Netcdf_var->ncid;
|
3439
3420
|
varid=Netcdf_var->varid;
|
3440
3421
|
Array_to_Csint_len(NArray,ptr,len);
|
3441
|
-
|
3422
|
+
|
3442
3423
|
status = nc_inq_varndims(ncid,varid,&ndimsp);
|
3443
3424
|
if(status != NC_NOERR) NC_RAISE(status);
|
3444
3425
|
for(i=0;i<ndimsp;i++){
|
@@ -3478,7 +3459,6 @@ NetCDF_put_var_int(VALUE Var,VALUE NArray)
|
|
3478
3459
|
size_t lengthp;
|
3479
3460
|
char *var_name;
|
3480
3461
|
|
3481
|
-
rb_secure(3);
|
3482
3462
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3483
3463
|
ncid=Netcdf_var->ncid;
|
3484
3464
|
varid=Netcdf_var->varid;
|
@@ -3503,8 +3483,8 @@ NetCDF_put_var_int(VALUE Var,VALUE NArray)
|
|
3503
3483
|
if(status != NC_NOERR) NC_RAISE(status);
|
3504
3484
|
rb_raise(rb_eNetcdfError,"Length of NArray don't equal to length of total array length in the '%s'\n",var_name);
|
3505
3485
|
}
|
3506
|
-
|
3507
|
-
|
3486
|
+
|
3487
|
+
|
3508
3488
|
status = nc_put_var_int(ncid,varid,ptr);
|
3509
3489
|
if(status !=NC_NOERR) NC_RAISE(status);
|
3510
3490
|
return Qnil;
|
@@ -3525,15 +3505,14 @@ NetCDF_put_var_float(VALUE Var,VALUE NArray)
|
|
3525
3505
|
int dimids[NC_MAX_DIMS];
|
3526
3506
|
size_t lengthp;
|
3527
3507
|
char *var_name;
|
3528
|
-
|
3529
|
-
|
3530
|
-
rb_secure(3);
|
3508
|
+
|
3509
|
+
|
3531
3510
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3532
3511
|
ncid=Netcdf_var->ncid;
|
3533
3512
|
varid=Netcdf_var->varid;
|
3534
3513
|
|
3535
3514
|
Array_to_Cfloat_len(NArray,ptr,len);
|
3536
|
-
|
3515
|
+
|
3537
3516
|
status = nc_inq_varndims(ncid,varid,&ndimsp);
|
3538
3517
|
if(status != NC_NOERR) NC_RAISE(status);
|
3539
3518
|
for(i=0;i<ndimsp;i++){
|
@@ -3574,7 +3553,6 @@ NetCDF_put_var_double(VALUE Var,VALUE NArray)
|
|
3574
3553
|
char *var_name;
|
3575
3554
|
|
3576
3555
|
|
3577
|
-
rb_secure(3);
|
3578
3556
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3579
3557
|
ncid=Netcdf_var->ncid;
|
3580
3558
|
varid=Netcdf_var->varid;
|
@@ -3619,19 +3597,18 @@ NetCDF_put_var1_char(VALUE Var,VALUE NArray,VALUE start)
|
|
3619
3597
|
int ndims;
|
3620
3598
|
int *dimids;
|
3621
3599
|
size_t dimlen;
|
3622
|
-
|
3623
|
-
rb_secure(3);
|
3600
|
+
|
3624
3601
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3625
3602
|
ncid=Netcdf_var->ncid;
|
3626
3603
|
varid=Netcdf_var->varid;
|
3627
3604
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3628
3605
|
if(status != NC_NOERR) NC_RAISE(status);
|
3629
3606
|
|
3630
|
-
|
3607
|
+
|
3631
3608
|
dimids = ALLOCA_N(int,ndims);
|
3632
3609
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3633
3610
|
if(status != NC_NOERR) NC_RAISE(status);
|
3634
|
-
|
3611
|
+
|
3635
3612
|
Check_Type(start,T_ARRAY);
|
3636
3613
|
if(RARRAY_LEN(start) <ndims) {
|
3637
3614
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
@@ -3640,7 +3617,7 @@ NetCDF_put_var1_char(VALUE Var,VALUE NArray,VALUE start)
|
|
3640
3617
|
c_start=ALLOCA_N(size_t,ndims);
|
3641
3618
|
for(i=0;i<ndims;i++){
|
3642
3619
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3643
|
-
|
3620
|
+
|
3644
3621
|
if(l_start < 0) {
|
3645
3622
|
status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
|
3646
3623
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3670,19 +3647,18 @@ NetCDF_put_var1_byte(VALUE Var,VALUE NArray,VALUE start)
|
|
3670
3647
|
int ndims;
|
3671
3648
|
int *dimids;
|
3672
3649
|
size_t dimlen;
|
3673
|
-
|
3674
|
-
rb_secure(3);
|
3650
|
+
|
3675
3651
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3676
3652
|
ncid=Netcdf_var->ncid;
|
3677
3653
|
varid=Netcdf_var->varid;
|
3678
3654
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3679
3655
|
if(status != NC_NOERR) NC_RAISE(status);
|
3680
3656
|
|
3681
|
-
|
3657
|
+
|
3682
3658
|
dimids = ALLOCA_N(int,ndims);
|
3683
3659
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3684
3660
|
if(status != NC_NOERR) NC_RAISE(status);
|
3685
|
-
|
3661
|
+
|
3686
3662
|
Check_Type(start,T_ARRAY);
|
3687
3663
|
if(RARRAY_LEN(start) <ndims) {
|
3688
3664
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
@@ -3691,7 +3667,7 @@ NetCDF_put_var1_byte(VALUE Var,VALUE NArray,VALUE start)
|
|
3691
3667
|
c_start=ALLOCA_N(size_t,ndims);
|
3692
3668
|
for(i=0;i<ndims;i++){
|
3693
3669
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3694
|
-
|
3670
|
+
|
3695
3671
|
if(l_start < 0) {
|
3696
3672
|
status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
|
3697
3673
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3721,19 +3697,18 @@ NetCDF_put_var1_sint(VALUE Var,VALUE NArray,VALUE start)
|
|
3721
3697
|
int ndims;
|
3722
3698
|
int *dimids;
|
3723
3699
|
size_t dimlen;
|
3724
|
-
|
3725
|
-
rb_secure(3);
|
3700
|
+
|
3726
3701
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3727
3702
|
ncid=Netcdf_var->ncid;
|
3728
3703
|
varid=Netcdf_var->varid;
|
3729
3704
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3730
3705
|
if(status != NC_NOERR) NC_RAISE(status);
|
3731
3706
|
|
3732
|
-
|
3707
|
+
|
3733
3708
|
dimids = ALLOCA_N(int,ndims);
|
3734
3709
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3735
3710
|
if(status != NC_NOERR) NC_RAISE(status);
|
3736
|
-
|
3711
|
+
|
3737
3712
|
Check_Type(start,T_ARRAY);
|
3738
3713
|
if(RARRAY_LEN(start) <ndims) {
|
3739
3714
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
@@ -3742,7 +3717,7 @@ NetCDF_put_var1_sint(VALUE Var,VALUE NArray,VALUE start)
|
|
3742
3717
|
c_start=ALLOCA_N(size_t,ndims);
|
3743
3718
|
for(i=0;i<ndims;i++){
|
3744
3719
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3745
|
-
|
3720
|
+
|
3746
3721
|
if(l_start < 0) {
|
3747
3722
|
status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
|
3748
3723
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3771,19 +3746,18 @@ NetCDF_put_var1_int(VALUE Var,VALUE NArray,VALUE start)
|
|
3771
3746
|
int ndims;
|
3772
3747
|
int *dimids;
|
3773
3748
|
size_t dimlen;
|
3774
|
-
|
3775
|
-
rb_secure(3);
|
3749
|
+
|
3776
3750
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3777
3751
|
ncid=Netcdf_var->ncid;
|
3778
3752
|
varid=Netcdf_var->varid;
|
3779
3753
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3780
3754
|
if(status != NC_NOERR) NC_RAISE(status);
|
3781
3755
|
|
3782
|
-
|
3756
|
+
|
3783
3757
|
dimids = ALLOCA_N(int,ndims);
|
3784
3758
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3785
3759
|
if(status != NC_NOERR) NC_RAISE(status);
|
3786
|
-
|
3760
|
+
|
3787
3761
|
Check_Type(start,T_ARRAY);
|
3788
3762
|
if(RARRAY_LEN(start) <ndims) {
|
3789
3763
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
@@ -3792,7 +3766,7 @@ NetCDF_put_var1_int(VALUE Var,VALUE NArray,VALUE start)
|
|
3792
3766
|
c_start=ALLOCA_N(size_t,ndims);
|
3793
3767
|
for(i=0;i<ndims;i++){
|
3794
3768
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3795
|
-
|
3769
|
+
|
3796
3770
|
if(l_start < 0) {
|
3797
3771
|
status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
|
3798
3772
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3822,19 +3796,18 @@ NetCDF_put_var1_float(VALUE Var,VALUE NArray,VALUE start)
|
|
3822
3796
|
int ndims;
|
3823
3797
|
int *dimids;
|
3824
3798
|
size_t dimlen;
|
3825
|
-
|
3826
|
-
rb_secure(3);
|
3799
|
+
|
3827
3800
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3828
3801
|
ncid=Netcdf_var->ncid;
|
3829
3802
|
varid=Netcdf_var->varid;
|
3830
3803
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3831
3804
|
if(status != NC_NOERR) NC_RAISE(status);
|
3832
3805
|
|
3833
|
-
|
3806
|
+
|
3834
3807
|
dimids = ALLOCA_N(int,ndims);
|
3835
3808
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3836
3809
|
if(status != NC_NOERR) NC_RAISE(status);
|
3837
|
-
|
3810
|
+
|
3838
3811
|
Check_Type(start,T_ARRAY);
|
3839
3812
|
if(RARRAY_LEN(start) <ndims) {
|
3840
3813
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
@@ -3843,7 +3816,7 @@ NetCDF_put_var1_float(VALUE Var,VALUE NArray,VALUE start)
|
|
3843
3816
|
c_start=ALLOCA_N(size_t,ndims);
|
3844
3817
|
for(i=0;i<ndims;i++){
|
3845
3818
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3846
|
-
|
3819
|
+
|
3847
3820
|
if(l_start < 0) {
|
3848
3821
|
status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
|
3849
3822
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3873,19 +3846,18 @@ NetCDF_put_var1_double(VALUE Var,VALUE NArray,VALUE start)
|
|
3873
3846
|
int ndims;
|
3874
3847
|
int *dimids;
|
3875
3848
|
size_t dimlen;
|
3876
|
-
|
3877
|
-
rb_secure(3);
|
3849
|
+
|
3878
3850
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3879
3851
|
ncid=Netcdf_var->ncid;
|
3880
3852
|
varid=Netcdf_var->varid;
|
3881
3853
|
status = nc_inq_varndims(ncid,varid,&ndims);
|
3882
3854
|
if(status != NC_NOERR) NC_RAISE(status);
|
3883
3855
|
|
3884
|
-
|
3856
|
+
|
3885
3857
|
dimids = ALLOCA_N(int,ndims);
|
3886
3858
|
status = nc_inq_vardimid(ncid,varid,dimids);
|
3887
3859
|
if(status != NC_NOERR) NC_RAISE(status);
|
3888
|
-
|
3860
|
+
|
3889
3861
|
Check_Type(start,T_ARRAY);
|
3890
3862
|
if(RARRAY_LEN(start) <ndims) {
|
3891
3863
|
rb_raise(rb_eNetcdfError,"Length of 'start' is too short\n");
|
@@ -3894,7 +3866,7 @@ NetCDF_put_var1_double(VALUE Var,VALUE NArray,VALUE start)
|
|
3894
3866
|
c_start=ALLOCA_N(size_t,ndims);
|
3895
3867
|
for(i=0;i<ndims;i++){
|
3896
3868
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3897
|
-
|
3869
|
+
|
3898
3870
|
if(l_start < 0) {
|
3899
3871
|
status = nc_inq_dimlen(ncid,dimids[i],&dimlen);
|
3900
3872
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3930,7 +3902,6 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
3930
3902
|
int *dimids;
|
3931
3903
|
size_t dimlen;
|
3932
3904
|
|
3933
|
-
rb_secure(3);
|
3934
3905
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
3935
3906
|
ncid=Netcdf_var->ncid;
|
3936
3907
|
varid=Netcdf_var->varid;
|
@@ -3943,12 +3914,12 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
3943
3914
|
|
3944
3915
|
Check_Type(start,T_ARRAY);
|
3945
3916
|
if(RARRAY_LEN(start) < ndims) {
|
3946
|
-
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
3917
|
+
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
3947
3918
|
}
|
3948
3919
|
c_start=ALLOCA_N(size_t,ndims);
|
3949
3920
|
for(i=0; i<ndims; i++){
|
3950
3921
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
3951
|
-
|
3922
|
+
|
3952
3923
|
if(l_start < 0) {
|
3953
3924
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
3954
3925
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -3956,7 +3927,7 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
3956
3927
|
}
|
3957
3928
|
c_start[i]=l_start;
|
3958
3929
|
}
|
3959
|
-
|
3930
|
+
|
3960
3931
|
c_stride=ALLOCA_N(ptrdiff_t,ndims);
|
3961
3932
|
switch(TYPE(stride)){
|
3962
3933
|
case T_NIL:
|
@@ -3967,12 +3938,12 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
3967
3938
|
default:
|
3968
3939
|
Check_Type(stride,T_ARRAY);
|
3969
3940
|
if(RARRAY_LEN(stride) < ndims) {
|
3970
|
-
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
3941
|
+
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
3971
3942
|
}
|
3972
3943
|
for(i=0; i<ndims; i++){
|
3973
3944
|
c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
|
3974
3945
|
if(c_stride[i]==0) {
|
3975
|
-
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
3946
|
+
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
3976
3947
|
}
|
3977
3948
|
}
|
3978
3949
|
}
|
@@ -3990,7 +3961,7 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
3990
3961
|
default:
|
3991
3962
|
Check_Type(end,T_ARRAY);
|
3992
3963
|
if(RARRAY_LEN(end) < ndims) {
|
3993
|
-
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
3964
|
+
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
3994
3965
|
}
|
3995
3966
|
for(i=0; i<ndims; i++){
|
3996
3967
|
l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
|
@@ -4007,11 +3978,11 @@ NetCDF_put_vars_char(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4007
3978
|
ptr = ALLOCA_N(unsigned char,c_count_all);
|
4008
3979
|
for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
|
4009
3980
|
} else if(len != c_count_all) {
|
4010
|
-
rb_raise(rb_eNetcdfError,
|
4011
|
-
"lengh of the array does not agree with that of the subset\n");
|
4012
|
-
}
|
4013
|
-
}
|
4014
|
-
|
3981
|
+
rb_raise(rb_eNetcdfError,
|
3982
|
+
"lengh of the array does not agree with that of the subset\n");
|
3983
|
+
}
|
3984
|
+
}
|
3985
|
+
|
4015
3986
|
status = nc_put_vars_text(ncid,varid,c_start,c_count,c_stride,(char *)ptr);
|
4016
3987
|
if(status != NC_NOERR) NC_RAISE(status);
|
4017
3988
|
return Qnil;
|
@@ -4036,7 +4007,6 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4036
4007
|
int *dimids;
|
4037
4008
|
size_t dimlen;
|
4038
4009
|
|
4039
|
-
rb_secure(3);
|
4040
4010
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
4041
4011
|
ncid=Netcdf_var->ncid;
|
4042
4012
|
varid=Netcdf_var->varid;
|
@@ -4049,12 +4019,12 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4049
4019
|
|
4050
4020
|
Check_Type(start,T_ARRAY);
|
4051
4021
|
if(RARRAY_LEN(start) < ndims) {
|
4052
|
-
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4022
|
+
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4053
4023
|
}
|
4054
4024
|
c_start=ALLOCA_N(size_t,ndims);
|
4055
4025
|
for(i=0; i<ndims; i++){
|
4056
4026
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
4057
|
-
|
4027
|
+
|
4058
4028
|
if(l_start < 0) {
|
4059
4029
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
4060
4030
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -4062,7 +4032,7 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4062
4032
|
}
|
4063
4033
|
c_start[i]=l_start;
|
4064
4034
|
}
|
4065
|
-
|
4035
|
+
|
4066
4036
|
c_stride=ALLOCA_N(ptrdiff_t,ndims);
|
4067
4037
|
switch(TYPE(stride)){
|
4068
4038
|
case T_NIL:
|
@@ -4073,12 +4043,12 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4073
4043
|
default:
|
4074
4044
|
Check_Type(stride,T_ARRAY);
|
4075
4045
|
if(RARRAY_LEN(stride) < ndims) {
|
4076
|
-
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4046
|
+
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4077
4047
|
}
|
4078
4048
|
for(i=0; i<ndims; i++){
|
4079
4049
|
c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
|
4080
4050
|
if(c_stride[i]==0) {
|
4081
|
-
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4051
|
+
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4082
4052
|
}
|
4083
4053
|
}
|
4084
4054
|
}
|
@@ -4096,7 +4066,7 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4096
4066
|
default:
|
4097
4067
|
Check_Type(end,T_ARRAY);
|
4098
4068
|
if(RARRAY_LEN(end) < ndims) {
|
4099
|
-
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4069
|
+
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4100
4070
|
}
|
4101
4071
|
for(i=0; i<ndims; i++){
|
4102
4072
|
l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
|
@@ -4113,11 +4083,11 @@ NetCDF_put_vars_byte(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4113
4083
|
ptr = ALLOCA_N(unsigned char,c_count_all);
|
4114
4084
|
for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
|
4115
4085
|
} else if(len != c_count_all) {
|
4116
|
-
rb_raise(rb_eNetcdfError,
|
4117
|
-
"lengh of the array does not agree with that of the subset\n");
|
4118
|
-
}
|
4119
|
-
}
|
4120
|
-
|
4086
|
+
rb_raise(rb_eNetcdfError,
|
4087
|
+
"lengh of the array does not agree with that of the subset\n");
|
4088
|
+
}
|
4089
|
+
}
|
4090
|
+
|
4121
4091
|
status = nc_put_vars_uchar(ncid,varid,c_start,c_count,c_stride,ptr);
|
4122
4092
|
if(status != NC_NOERR) NC_RAISE(status);
|
4123
4093
|
return Qnil;
|
@@ -4142,7 +4112,6 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4142
4112
|
int *dimids;
|
4143
4113
|
size_t dimlen;
|
4144
4114
|
|
4145
|
-
rb_secure(3);
|
4146
4115
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
4147
4116
|
ncid=Netcdf_var->ncid;
|
4148
4117
|
varid=Netcdf_var->varid;
|
@@ -4155,12 +4124,12 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4155
4124
|
|
4156
4125
|
Check_Type(start,T_ARRAY);
|
4157
4126
|
if(RARRAY_LEN(start) < ndims) {
|
4158
|
-
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4127
|
+
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4159
4128
|
}
|
4160
4129
|
c_start=ALLOCA_N(size_t,ndims);
|
4161
4130
|
for(i=0; i<ndims; i++){
|
4162
4131
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
4163
|
-
|
4132
|
+
|
4164
4133
|
if(l_start < 0) {
|
4165
4134
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
4166
4135
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -4168,7 +4137,7 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4168
4137
|
}
|
4169
4138
|
c_start[i]=l_start;
|
4170
4139
|
}
|
4171
|
-
|
4140
|
+
|
4172
4141
|
c_stride=ALLOCA_N(ptrdiff_t,ndims);
|
4173
4142
|
switch(TYPE(stride)){
|
4174
4143
|
case T_NIL:
|
@@ -4179,12 +4148,12 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4179
4148
|
default:
|
4180
4149
|
Check_Type(stride,T_ARRAY);
|
4181
4150
|
if(RARRAY_LEN(stride) < ndims) {
|
4182
|
-
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4151
|
+
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4183
4152
|
}
|
4184
4153
|
for(i=0; i<ndims; i++){
|
4185
4154
|
c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
|
4186
4155
|
if(c_stride[i]==0) {
|
4187
|
-
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4156
|
+
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4188
4157
|
}
|
4189
4158
|
}
|
4190
4159
|
}
|
@@ -4202,7 +4171,7 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4202
4171
|
default:
|
4203
4172
|
Check_Type(end,T_ARRAY);
|
4204
4173
|
if(RARRAY_LEN(end) < ndims) {
|
4205
|
-
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4174
|
+
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4206
4175
|
}
|
4207
4176
|
for(i=0; i<ndims; i++){
|
4208
4177
|
l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
|
@@ -4219,8 +4188,8 @@ NetCDF_put_vars_sint(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4219
4188
|
ptr = ALLOCA_N(short,c_count_all);
|
4220
4189
|
for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
|
4221
4190
|
} else if(len != c_count_all) {
|
4222
|
-
rb_raise(rb_eNetcdfError,
|
4223
|
-
"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");
|
4224
4193
|
}
|
4225
4194
|
}
|
4226
4195
|
|
@@ -4249,7 +4218,6 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4249
4218
|
int *dimids;
|
4250
4219
|
size_t dimlen;
|
4251
4220
|
|
4252
|
-
rb_secure(3);
|
4253
4221
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
4254
4222
|
ncid=Netcdf_var->ncid;
|
4255
4223
|
varid=Netcdf_var->varid;
|
@@ -4262,12 +4230,12 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4262
4230
|
|
4263
4231
|
Check_Type(start,T_ARRAY);
|
4264
4232
|
if(RARRAY_LEN(start) < ndims) {
|
4265
|
-
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4233
|
+
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4266
4234
|
}
|
4267
4235
|
c_start=ALLOCA_N(size_t,ndims);
|
4268
4236
|
for(i=0; i<ndims; i++){
|
4269
4237
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
4270
|
-
|
4238
|
+
|
4271
4239
|
if(l_start < 0) {
|
4272
4240
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
4273
4241
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -4275,7 +4243,7 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4275
4243
|
}
|
4276
4244
|
c_start[i]=l_start;
|
4277
4245
|
}
|
4278
|
-
|
4246
|
+
|
4279
4247
|
c_stride=ALLOCA_N(ptrdiff_t,ndims);
|
4280
4248
|
switch(TYPE(stride)){
|
4281
4249
|
case T_NIL:
|
@@ -4286,12 +4254,12 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4286
4254
|
default:
|
4287
4255
|
Check_Type(stride,T_ARRAY);
|
4288
4256
|
if(RARRAY_LEN(stride) < ndims) {
|
4289
|
-
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4257
|
+
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4290
4258
|
}
|
4291
4259
|
for(i=0; i<ndims; i++){
|
4292
4260
|
c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
|
4293
4261
|
if(c_stride[i]==0) {
|
4294
|
-
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4262
|
+
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4295
4263
|
}
|
4296
4264
|
}
|
4297
4265
|
}
|
@@ -4309,7 +4277,7 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4309
4277
|
default:
|
4310
4278
|
Check_Type(end,T_ARRAY);
|
4311
4279
|
if(RARRAY_LEN(end) < ndims) {
|
4312
|
-
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4280
|
+
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4313
4281
|
}
|
4314
4282
|
for(i=0; i<ndims; i++){
|
4315
4283
|
l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
|
@@ -4326,8 +4294,8 @@ NetCDF_put_vars_int(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4326
4294
|
ptr = ALLOCA_N(int,c_count_all);
|
4327
4295
|
for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
|
4328
4296
|
} else if(len != c_count_all) {
|
4329
|
-
rb_raise(rb_eNetcdfError,
|
4330
|
-
"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");
|
4331
4299
|
}
|
4332
4300
|
}
|
4333
4301
|
|
@@ -4356,7 +4324,6 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4356
4324
|
int *dimids;
|
4357
4325
|
size_t dimlen;
|
4358
4326
|
|
4359
|
-
rb_secure(3);
|
4360
4327
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
4361
4328
|
ncid=Netcdf_var->ncid;
|
4362
4329
|
varid=Netcdf_var->varid;
|
@@ -4369,12 +4336,12 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4369
4336
|
|
4370
4337
|
Check_Type(start,T_ARRAY);
|
4371
4338
|
if(RARRAY_LEN(start) < ndims) {
|
4372
|
-
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4339
|
+
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4373
4340
|
}
|
4374
4341
|
c_start=ALLOCA_N(size_t,ndims);
|
4375
4342
|
for(i=0; i<ndims; i++){
|
4376
4343
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
4377
|
-
|
4344
|
+
|
4378
4345
|
if(l_start < 0) {
|
4379
4346
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
4380
4347
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -4382,7 +4349,7 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4382
4349
|
}
|
4383
4350
|
c_start[i]=l_start;
|
4384
4351
|
}
|
4385
|
-
|
4352
|
+
|
4386
4353
|
c_stride=ALLOCA_N(ptrdiff_t,ndims);
|
4387
4354
|
switch(TYPE(stride)){
|
4388
4355
|
case T_NIL:
|
@@ -4393,12 +4360,12 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4393
4360
|
default:
|
4394
4361
|
Check_Type(stride,T_ARRAY);
|
4395
4362
|
if(RARRAY_LEN(stride) < ndims) {
|
4396
|
-
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4363
|
+
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4397
4364
|
}
|
4398
4365
|
for(i=0; i<ndims; i++){
|
4399
4366
|
c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
|
4400
4367
|
if(c_stride[i]==0) {
|
4401
|
-
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4368
|
+
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4402
4369
|
}
|
4403
4370
|
}
|
4404
4371
|
}
|
@@ -4416,7 +4383,7 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4416
4383
|
default:
|
4417
4384
|
Check_Type(end,T_ARRAY);
|
4418
4385
|
if(RARRAY_LEN(end) < ndims) {
|
4419
|
-
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4386
|
+
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4420
4387
|
}
|
4421
4388
|
for(i=0; i<ndims; i++){
|
4422
4389
|
l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
|
@@ -4433,8 +4400,8 @@ NetCDF_put_vars_float(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride)
|
|
4433
4400
|
ptr = ALLOCA_N(float,c_count_all);
|
4434
4401
|
for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
|
4435
4402
|
} else if(len != c_count_all) {
|
4436
|
-
rb_raise(rb_eNetcdfError,
|
4437
|
-
"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");
|
4438
4405
|
}
|
4439
4406
|
}
|
4440
4407
|
|
@@ -4463,7 +4430,6 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
|
|
4463
4430
|
int *dimids;
|
4464
4431
|
size_t dimlen;
|
4465
4432
|
|
4466
|
-
rb_secure(3);
|
4467
4433
|
Data_Get_Struct(Var,struct NetCDFVar,Netcdf_var);
|
4468
4434
|
ncid=Netcdf_var->ncid;
|
4469
4435
|
varid=Netcdf_var->varid;
|
@@ -4476,12 +4442,12 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
|
|
4476
4442
|
|
4477
4443
|
Check_Type(start,T_ARRAY);
|
4478
4444
|
if(RARRAY_LEN(start) < ndims) {
|
4479
|
-
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4445
|
+
rb_raise(rb_eNetcdfError, "Length of 'start' is too short\n");
|
4480
4446
|
}
|
4481
4447
|
c_start=ALLOCA_N(size_t,ndims);
|
4482
4448
|
for(i=0; i<ndims; i++){
|
4483
4449
|
l_start=NUM2INT(RARRAY_PTR(start)[ndims-1-i]);
|
4484
|
-
|
4450
|
+
|
4485
4451
|
if(l_start < 0) {
|
4486
4452
|
status = nc_inq_dimlen(ncid, dimids[i], &dimlen);
|
4487
4453
|
if(status != NC_NOERR) NC_RAISE(status);
|
@@ -4489,7 +4455,7 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
|
|
4489
4455
|
}
|
4490
4456
|
c_start[i]=l_start;
|
4491
4457
|
}
|
4492
|
-
|
4458
|
+
|
4493
4459
|
c_stride=ALLOCA_N(ptrdiff_t,ndims);
|
4494
4460
|
switch(TYPE(stride)){
|
4495
4461
|
case T_NIL:
|
@@ -4500,12 +4466,12 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
|
|
4500
4466
|
default:
|
4501
4467
|
Check_Type(stride,T_ARRAY);
|
4502
4468
|
if(RARRAY_LEN(stride) < ndims) {
|
4503
|
-
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4469
|
+
rb_raise(rb_eNetcdfError, "Length of 'stride' is too short\n");
|
4504
4470
|
}
|
4505
4471
|
for(i=0; i<ndims; i++){
|
4506
4472
|
c_stride[i]=NUM2INT(RARRAY_PTR(stride)[ndims-1-i]);
|
4507
4473
|
if(c_stride[i]==0) {
|
4508
|
-
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4474
|
+
rb_raise(rb_eNetcdfError, "stride cannot be zero\n");
|
4509
4475
|
}
|
4510
4476
|
}
|
4511
4477
|
}
|
@@ -4523,7 +4489,7 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
|
|
4523
4489
|
default:
|
4524
4490
|
Check_Type(end,T_ARRAY);
|
4525
4491
|
if(RARRAY_LEN(end) < ndims) {
|
4526
|
-
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4492
|
+
rb_raise(rb_eNetcdfError, "Length of 'end' is too short\n");
|
4527
4493
|
}
|
4528
4494
|
for(i=0; i<ndims; i++){
|
4529
4495
|
l_end=NUM2INT(RARRAY_PTR(end)[ndims-1-i]);
|
@@ -4540,8 +4506,8 @@ NetCDF_put_vars_double(VALUE Var,VALUE NArray,VALUE start,VALUE end,VALUE stride
|
|
4540
4506
|
ptr = ALLOCA_N(double,c_count_all);
|
4541
4507
|
for(i=0;i<c_count_all;i++){ptr[i]=scalar;}
|
4542
4508
|
} else if(len != c_count_all) {
|
4543
|
-
rb_raise(rb_eNetcdfError,
|
4544
|
-
"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");
|
4545
4511
|
}
|
4546
4512
|
}
|
4547
4513
|
|
@@ -4589,7 +4555,7 @@ Init_netcdfraw(void)
|
|
4589
4555
|
rb_eNetcdfEdge = rb_define_class("NetcdfEdge",rb_eNetcdfError);
|
4590
4556
|
rb_eNetcdfStride = rb_define_class("NetcdfStride",rb_eNetcdfError);
|
4591
4557
|
rb_eNetcdfBadname = rb_define_class("NetcdfBadname",rb_eNetcdfError);
|
4592
|
-
/* N.B. following must match value in ncx.h */
|
4558
|
+
/* N.B. following must match value in ncx.h */
|
4593
4559
|
rb_eNetcdfRange = rb_define_class("NetcdfRange",rb_eNetcdfError);
|
4594
4560
|
rb_eNetcdfNomem = rb_define_class("NetcdfNomem",rb_eNetcdfError);
|
4595
4561
|
/* Global error status */
|
@@ -4607,10 +4573,10 @@ Init_netcdfraw(void)
|
|
4607
4573
|
rb_define_const(cNetCDF, "NC_NOCLOBBER", INT2FIX(NC_NOCLOBBER));
|
4608
4574
|
#if NCVER >= 400
|
4609
4575
|
rb_define_const(cNetCDF, "NC_64BIT_OFFSET", INT2FIX(NC_64BIT_OFFSET));
|
4610
|
-
/* NC_64BIT_OFFSET supports large files in the class data format */
|
4576
|
+
/* NC_64BIT_OFFSET supports large files in the class data format */
|
4611
4577
|
rb_define_const(cNetCDF, "NC_NETCDF4", INT2FIX(NC_NETCDF4));
|
4612
4578
|
rb_define_const(cNetCDF, "NC_CLASSIC_MODEL", INT2FIX(NC_CLASSIC_MODEL));
|
4613
|
-
/* 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
|
4614
4580
|
data model in NetCDF4 by disabling new features like groups */
|
4615
4581
|
rb_define_const(cNetCDF, "NC_ENDIAN_NATIVE", INT2FIX(NC_ENDIAN_NATIVE));
|
4616
4582
|
rb_define_const(cNetCDF, "NC_ENDIAN_LITTLE", INT2FIX(NC_ENDIAN_LITTLE));
|
@@ -4621,7 +4587,7 @@ Init_netcdfraw(void)
|
|
4621
4587
|
rb_define_const(cNetCDF, "NC_FORMAT_NETCDF4", INT2FIX(NC_FORMAT_NETCDF4));
|
4622
4588
|
rb_define_const(cNetCDF, "NC_FORMAT_NETCDF4_CLASSIC", INT2FIX(NC_FORMAT_NETCDF4_CLASSIC));
|
4623
4589
|
#endif
|
4624
|
-
|
4590
|
+
|
4625
4591
|
#ifdef NARRAY_BIGMEM
|
4626
4592
|
rb_define_const(cNetCDF, "SUPPORT_BIGMEM", Qtrue);
|
4627
4593
|
#else
|
@@ -4658,7 +4624,7 @@ Init_netcdfraw(void)
|
|
4658
4624
|
rb_define_private_method(cNetCDF,"id2var",NetCDF_id2var,1);
|
4659
4625
|
rb_define_private_method(cNetCDF,"id2dim",NetCDF_id2dim,1);
|
4660
4626
|
rb_define_private_method(cNetCDF,"id2att",NetCDF_id2att,1);
|
4661
|
-
rb_define_method(cNetCDF,"==",NetCDF_eql,1);
|
4627
|
+
rb_define_method(cNetCDF,"==",NetCDF_eql,1);
|
4662
4628
|
/* rb_define_method(cNetCDF,"eql?",NetCDF_eql,1); */
|
4663
4629
|
|
4664
4630
|
/* The methods of the NetCDFDim class */
|
@@ -4736,7 +4702,7 @@ Init_netcdfraw(void)
|
|
4736
4702
|
rb_define_method(cNetCDFVar,"get_var_int",NetCDF_get_var_int,0);
|
4737
4703
|
rb_define_method(cNetCDFVar,"get_var_sfloat",NetCDF_get_var_float,0);
|
4738
4704
|
rb_define_method(cNetCDFVar,"get_var_float",NetCDF_get_var_double,0);
|
4739
|
-
|
4705
|
+
|
4740
4706
|
rb_define_method(cNetCDFVar,"get_vars_char",NetCDF_get_vars_char,3);
|
4741
4707
|
rb_define_method(cNetCDFVar,"get_vars_byte",NetCDF_get_vars_byte,3);
|
4742
4708
|
rb_define_method(cNetCDFVar,"get_vars_sint",NetCDF_get_vars_sint,3);
|