00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <config.h>
00010 #include <nc4internal.h>
00011 #include <netcdf.h>
00012 #include <nc_tests.h>
00013
00014 extern NC_FILE_INFO_T *nc_file;
00015 void test_redef(int format);
00016
00017 #define FILE_NAME "tst_files.nc"
00018 #define ATT1_NAME "MoneyOwned"
00019 #define ATT2_NAME "Number_of_Shoes"
00020 #define ATT3_NAME "att3"
00021 #define DIM1_NAME "Character_Growth"
00022 #define DIM1_LEN 10
00023 #define DIM2_NAME "TimeInMonths"
00024 #define DIM2_LEN 15
00025 #define VAR1_NAME "HuckFinn"
00026 #define VAR2_NAME "TomSawyer"
00027 #define VAR3_NAME "Jim"
00028
00029 int
00030 main(int argc, char **argv)
00031 {
00032 printf("\n*** Testing netcdf-4 file functions.\n");
00033 {
00034 char str[NC_MAX_NAME+1];
00035
00036
00037
00038 if (strlen(nc_inq_libvers()) > NC_MAX_NAME) ERR;
00039 strcpy(str, nc_inq_libvers());
00040 if (strcmp(str, PACKAGE_VERSION)) ERR;
00041 printf("*** testing version %s...", str);
00042 }
00043 SUMMARIZE_ERR;
00044
00045 printf("*** testing with bad inputs...");
00046 {
00047 int ncid;
00048
00049
00050
00051
00052
00053 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00054 if (nc_close(ncid)) ERR;
00055
00056
00057 if (nc_open(FILE_NAME, NC_CLASSIC_MODEL, &ncid) != NC_EINVAL) ERR;
00058 if (nc_open(FILE_NAME, NC_MPIIO|NC_MPIPOSIX, &ncid) != NC_EINVAL) ERR;
00059 if (nc_open(FILE_NAME, NC_NOCLOBBER, &ncid) != NC_EINVAL) ERR;
00060
00061
00062 if (nc_create(FILE_NAME, NC_WRITE, &ncid) != NC_EINVAL) ERR;
00063 if (nc_create(FILE_NAME, NC_64BIT_OFFSET|NC_NETCDF4, &ncid) != NC_EINVAL) ERR;
00064 if (nc_create(FILE_NAME, NC_64BIT_OFFSET|NC_CLASSIC_MODEL, &ncid) != NC_EINVAL) ERR;
00065 if (nc_create(FILE_NAME, NC_CLASSIC_MODEL, &ncid) != NC_EINVAL) ERR;
00066 if (nc_create(FILE_NAME, NC_CLASSIC_MODEL|NC_MPIIO|NC_MPIPOSIX, &ncid) != NC_EINVAL) ERR;
00067 if (nc_create(FILE_NAME, NC_MPIIO|NC_MPIPOSIX, &ncid) != NC_EINVAL) ERR;
00068 }
00069 SUMMARIZE_ERR;
00070
00071 printf("*** testing simple opens and creates...");
00072 {
00073 int ncid, varid, dimids[2];
00074 int ndims, nvars, natts, unlimdimid;
00075 int dimids_var[1], var_type;
00076 size_t dim_len;
00077 char dim_name[NC_MAX_NAME+1], var_name[NC_MAX_NAME+1];
00078 unsigned char uchar_out[DIM1_LEN] = {0, 128, 255};
00079
00080
00081
00082
00083 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00084 if (nc_close(ncid)) ERR;
00085
00086
00087 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00088 if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
00089 if (nc_def_dim(ncid, DIM2_NAME, DIM2_LEN, &dimids[1])) ERR;
00090 if (nc_def_var(ncid, VAR1_NAME, NC_INT, 1, dimids, &varid)) ERR;
00091 if (nc_enddef(ncid)) ERR;
00092 if (nc_def_var(ncid, VAR2_NAME, NC_UINT, 2, dimids, &varid)) ERR;
00093 if (nc_close(ncid)) ERR;
00094
00095
00096
00097
00098 if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
00099 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00100 if (ndims != 2 || nvars != 2 || natts != 0 || unlimdimid != -1) ERR;
00101 if (nc_redef(ncid)) ERR;
00102 if (nc_enddef(ncid)) ERR;
00103 if (nc_def_var(ncid, VAR3_NAME, NC_INT, 2, dimids, &varid)) ERR;
00104 if (nc_close(ncid)) ERR;
00105
00106
00107 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00108 if (nc_close(ncid)) ERR;
00109
00110
00111 if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
00112 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00113 if (ndims != 0 || nvars != 0 || natts != 0 || unlimdimid != -1) ERR;
00114 if (nc_close(ncid)) ERR;
00115
00116
00117 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00118 if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
00119 if (nc_enddef(ncid)) ERR;
00120 if (nc_close(ncid)) ERR;
00121
00122
00123 if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
00124 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00125 if (ndims != 1 || nvars != 0 || natts != 0 || unlimdimid != -1) ERR;
00126 if (nc_inq_dim(ncid, 0, dim_name, &dim_len)) ERR;
00127 if (dim_len != DIM1_LEN || strcmp(dim_name, DIM1_NAME)) ERR;
00128 if (nc_close(ncid)) ERR;
00129
00130
00131 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00132 if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
00133 if (nc_def_var(ncid, VAR1_NAME, NC_BYTE, 1, dimids, &varid)) ERR;
00134 if (nc_enddef(ncid)) ERR;
00135 if (nc_put_var_uchar(ncid, varid, uchar_out) != NC_ERANGE) ERR;
00136 if (nc_close(ncid)) ERR;
00137
00138
00139 if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
00140 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00141 if (ndims != 1 || nvars != 1 || natts != 0 || unlimdimid != -1) ERR;
00142 if (nc_inq_dim(ncid, 0, dim_name, &dim_len)) ERR;
00143 if (dim_len != DIM1_LEN || strcmp(dim_name, DIM1_NAME)) ERR;
00144 if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00145 if (ndims != 1 || strcmp(var_name, VAR1_NAME) || var_type != NC_BYTE ||
00146 dimids_var[0] != dimids[0] || natts != 0) ERR;
00147 if (nc_close(ncid)) ERR;
00148
00149
00150 if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
00151 if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
00152 if (nc_def_var(ncid, VAR1_NAME, NC_BYTE, 1, dimids, &varid)) ERR;
00153 if (nc_enddef(ncid)) ERR;
00154 if (nc_put_var_uchar(ncid, varid, uchar_out)) ERR;
00155 if (nc_close(ncid)) ERR;
00156
00157
00158 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00159 if (nc_close(ncid)) ERR;
00160 if (nc_create(FILE_NAME, NC_NETCDF4|NC_NOCLOBBER, &ncid) != NC_EEXIST) ERR;
00161
00162
00163 if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
00164 if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
00165 if (nc_def_dim(ncid, DIM2_NAME, DIM2_LEN, &dimids[1])) ERR;
00166 if (nc_def_var(ncid, VAR1_NAME, NC_INT, 1, dimids, &varid)) ERR;
00167 if (nc_enddef(ncid)) ERR;
00168 if (nc_def_var(ncid, VAR2_NAME, NC_UINT, 2, dimids, &varid)) ERR;
00169 if (nc_close(ncid)) ERR;
00170
00171
00172
00173
00174 if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
00175 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00176 if (ndims != 2 || nvars != 2 || natts != 0 || unlimdimid != -1) ERR;
00177 if (nc_redef(ncid)) ERR;
00178 if (nc_enddef(ncid)) ERR;
00179 if (nc_def_var(ncid, VAR3_NAME, NC_INT, 2, dimids, &varid)) ERR;
00180 if (nc_close(ncid)) ERR;
00181
00182
00183 if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
00184 if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
00185 if (nc_def_var(ncid, VAR1_NAME, NC_INT, 1, dimids, &varid)) ERR;
00186 if (nc_enddef(ncid)) ERR;
00187 if (nc_close(ncid)) ERR;
00188
00189
00190 if (nc_open(FILE_NAME, 0, &ncid)) ERR;
00191 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00192 if (ndims != 1 || nvars != 1 || natts != 0 || unlimdimid != -1) ERR;
00193 if (nc_def_var(ncid, VAR2_NAME, NC_UINT, 2, dimids, &varid) != NC_ENOTINDEFINE) ERR;
00194 if (nc_close(ncid)) ERR;
00195
00196
00197
00198
00199 if (nc_open(FILE_NAME, 0, &ncid)) ERR;
00200 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00201 if (nc_inq_dim(ncid, 0, dim_name, &dim_len)) ERR;
00202 if (dim_len != DIM1_LEN || strcmp(dim_name, DIM1_NAME)) ERR;
00203 if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00204 if (ndims != 1 || strcmp(var_name, VAR1_NAME) || var_type != NC_INT ||
00205 dimids_var[0] != dimids[0] || natts != 0) ERR;
00206 if (nc_close(ncid)) ERR;
00207 }
00208
00209 SUMMARIZE_ERR;
00210 printf("*** testing more complex opens and creates...");
00211 {
00212 int ncid, varid, dimids[2];
00213 int ndims, nvars, natts, unlimdimid;
00214 int dimids_var[2], var_type;
00215 size_t dim_len;
00216 char dim_name[NC_MAX_NAME+1], var_name[NC_MAX_NAME+1];
00217 float float_in, float_out = 99.99;
00218 int int_in, int_out = -9999;
00219
00220
00221 if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLOBBER, &ncid)) ERR;
00222 if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR;
00223 if (nc_def_dim(ncid, DIM2_NAME, DIM2_LEN, &dimids[1])) ERR;
00224 if (nc_def_var(ncid, VAR1_NAME, NC_INT, 2, dimids, &varid)) ERR;
00225 if (nc_def_var(ncid, VAR2_NAME, NC_UINT, 2, dimids, &varid)) ERR;
00226 if (nc_put_att_float(ncid, NC_GLOBAL, ATT1_NAME, NC_FLOAT, 1, &float_out)) ERR;
00227 if (nc_put_att_int(ncid, NC_GLOBAL, ATT2_NAME, NC_INT, 1, &int_out)) ERR;
00228 if (nc_close(ncid)) ERR;
00229
00230
00231 if (nc_open(FILE_NAME, 0, &ncid)) ERR;
00232 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00233 if (ndims != 2 || nvars != 2 || natts != 2 || unlimdimid != -1) ERR;
00234 if (nc_close(ncid)) ERR;
00235
00236
00237 if (nc_open(FILE_NAME, 0, &ncid)) ERR;
00238 if (nc_inq_dim(ncid, 0, dim_name, &dim_len)) ERR;
00239 if (dim_len != DIM1_LEN || strcmp(dim_name, DIM1_NAME)) ERR;
00240 if (nc_inq_dim(ncid, 1, dim_name, &dim_len)) ERR;
00241 if (dim_len != DIM2_LEN || strcmp(dim_name, DIM2_NAME)) ERR;
00242 if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00243 if (ndims != 2 || strcmp(var_name, VAR1_NAME) || var_type != NC_INT ||
00244 dimids_var[0] != dimids[0] || natts != 0) ERR;
00245 if (nc_inq_var(ncid, 1, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00246 if (ndims != 2 || strcmp(var_name, VAR2_NAME) || var_type != NC_UINT ||
00247 dimids_var[1] != dimids[1] || natts != 0) ERR;
00248 if (nc_get_att_float(ncid, NC_GLOBAL, ATT1_NAME, &float_in)) ERR;
00249 if (float_in != float_out) ERR;
00250 if (nc_get_att_int(ncid, NC_GLOBAL, ATT2_NAME, &int_in)) ERR;
00251 if (int_in != int_out) ERR;
00252 if (nc_close(ncid)) ERR;
00253 }
00254
00255 SUMMARIZE_ERR;
00256
00257 printf("*** testing redef for netCDF classic...");
00258 test_redef(NC_FORMAT_CLASSIC);
00259 SUMMARIZE_ERR;
00260 printf("*** testing redef for netCDF 64-bit offset...");
00261 test_redef(NC_FORMAT_64BIT);
00262 SUMMARIZE_ERR;
00263 printf("*** testing redef for netCDF-4 ...");
00264 test_redef(NC_FORMAT_NETCDF4);
00265 SUMMARIZE_ERR;
00266 printf("*** testing redef for netCDF-4, with strict netCDF-3 rules...");
00267 test_redef(NC_FORMAT_NETCDF4_CLASSIC);
00268 SUMMARIZE_ERR;
00269
00270 printf("*** testing different formats...");
00271 {
00272 int ncid;
00273 int format;
00274
00275
00276 if (nc_create(FILE_NAME, NC_CLOBBER, &ncid)) ERR;
00277 if (nc_inq_format(ncid, &format)) ERR;
00278 if (format != NC_FORMAT_CLASSIC) ERR;
00279 if (nc_close(ncid)) ERR;
00280
00281
00282 if (nc_create(FILE_NAME, NC_64BIT_OFFSET|NC_CLOBBER, &ncid)) ERR;
00283 if (nc_inq_format(ncid, &format)) ERR;
00284 if (format != NC_FORMAT_64BIT) ERR;
00285 if (nc_close(ncid)) ERR;
00286
00287
00288 if (nc_create(FILE_NAME, NC_NETCDF4|NC_CLOBBER, &ncid)) ERR;
00289 if (nc_inq_format(ncid, &format)) ERR;
00290 if (format != NC_FORMAT_NETCDF4) ERR;
00291 if (nc_close(ncid)) ERR;
00292 }
00293
00294 nc_exit();
00295
00296 SUMMARIZE_ERR;
00297
00298 FINAL_RESULTS;
00299 }
00300
00301 #define REDEF_ATT1_NAME "CANTERBURY"
00302 #define REDEF_ATT2_NAME "ELY"
00303 #define REDEF_ATT3_NAME "KING_HENRY_V"
00304 #define REDEF_DIM1_NAME "performance_length"
00305 #define REDEF_DIM1_LEN 101
00306 #define REDEF_NAME_ILLEGAL "?"
00307 #define REDEF_DIM2_NAME "ZZ_number_of_performers_or_perhaps_actors_or_maybe_I_should_say_players_or_one_could_call_them_artists_but_one_doesnt_like_to_get"
00308
00309 #define REDEF_DIM2_LEN 999
00310 #define REDEF_VAR1_NAME "Royal_Shakespeare_Company_season_of_2004"
00311 #define REDEF_VAR2_NAME "Ms_Beths_Kindergardern_class_of_2003"
00312 #define REDEF_VAR3_NAME "Costumed_Mice_in_my_Garage_in_the_Winter_of_my_Discontent"
00313 #define REDEF_NDIMS 2
00314
00315 void
00316 test_redef(int format)
00317 {
00318 int ncid, varid, dimids[REDEF_NDIMS], dimids_in[REDEF_NDIMS];
00319 int ndims, nvars, natts, unlimdimid;
00320 int dimids_var[REDEF_NDIMS], var_type;
00321 int cflags = 0;
00322 size_t dim_len;
00323 char dim_name[NC_MAX_NAME+1], var_name[NC_MAX_NAME+1];
00324 float float_in;
00325 double double_out = 99E99;
00326 int int_in;
00327 unsigned char uchar_in, uchar_out = 255;
00328 short short_out = -999;
00329 nc_type xtype_in;
00330 int ret;
00331
00332 if (format == NC_FORMAT_64BIT)
00333 cflags |= NC_64BIT_OFFSET;
00334 else if (format == NC_FORMAT_NETCDF4_CLASSIC)
00335 cflags |= (NC_NETCDF4|NC_CLASSIC_MODEL);
00336 else if (format == NC_FORMAT_NETCDF4)
00337 cflags |= NC_NETCDF4;
00338
00339
00340 if (nc_create(FILE_NAME, cflags|NC_CLOBBER, &ncid)) ERR;
00341
00342
00343 if ((ret = nc_def_dim(ncid, REDEF_NAME_ILLEGAL, REDEF_DIM2_LEN, &dimids[1])) != NC_EBADNAME) ERR;
00344
00345 if (nc_def_dim(ncid, REDEF_DIM1_NAME, REDEF_DIM1_LEN, &dimids[0])) ERR;
00346 if (nc_def_dim(ncid, REDEF_DIM2_NAME, REDEF_DIM2_LEN, &dimids[1])) ERR;
00347 if (nc_def_var(ncid, REDEF_VAR1_NAME, NC_INT, REDEF_NDIMS, dimids, &varid)) ERR;
00348 if (nc_def_var(ncid, REDEF_VAR2_NAME, NC_BYTE, REDEF_NDIMS, dimids, &varid)) ERR;
00349 if (nc_put_att_double(ncid, NC_GLOBAL, REDEF_ATT1_NAME, NC_DOUBLE, 1, &double_out)) ERR;
00350 if (nc_put_att_short(ncid, NC_GLOBAL, REDEF_ATT2_NAME, NC_SHORT, 1, &short_out)) ERR;
00351
00352
00353 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00354 if (ndims != REDEF_NDIMS || nvars != 2 || natts != 2 || unlimdimid != -1) ERR;
00355 if (nc_inq_var(ncid, 0, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00356 if (strcmp(var_name, REDEF_VAR1_NAME) || xtype_in != NC_INT || ndims != REDEF_NDIMS ||
00357 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00358 if (nc_inq_var(ncid, 1, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00359 if (strcmp(var_name, REDEF_VAR2_NAME) || xtype_in != NC_BYTE || ndims != REDEF_NDIMS ||
00360 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00361
00362
00363 if (format != NC_FORMAT_NETCDF4)
00364 if (nc_enddef(ncid)) ERR;
00365 if (nc_close(ncid)) ERR;
00366
00367
00368 if (nc_open(FILE_NAME, 0, &ncid)) ERR;
00369 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00370 if (ndims != REDEF_NDIMS || nvars != 2 || natts != 2 || unlimdimid != -1) ERR;
00371 if (nc_inq_var(ncid, 0, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00372 if (strcmp(var_name, REDEF_VAR1_NAME) || xtype_in != NC_INT || ndims != REDEF_NDIMS ||
00373 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00374 if (nc_inq_var(ncid, 1, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00375 if (strcmp(var_name, REDEF_VAR2_NAME) || xtype_in != NC_BYTE || ndims != REDEF_NDIMS ||
00376 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00377
00378
00379 ret = nc_def_var(ncid, REDEF_VAR3_NAME, NC_UBYTE, REDEF_NDIMS,
00380 dimids, &varid);
00381 if ((format != NC_FORMAT_NETCDF4 && ret != NC_ENOTINDEFINE) ||
00382 (format == NC_FORMAT_NETCDF4 && ret != NC_EPERM)) ERR;
00383
00384
00385 if (!nc_put_att_uchar(ncid, NC_GLOBAL, REDEF_ATT3_NAME, NC_CHAR, 1, &uchar_out)) ERR;
00386 if (nc_close(ncid)) ERR;
00387
00388
00389 if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
00390 if (nc_redef(ncid) != NC_EPERM) ERR;
00391
00392
00393 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00394 if (ndims != REDEF_NDIMS || nvars != 2 || natts != 2 || unlimdimid != -1) ERR;
00395 if (nc_inq_var(ncid, 0, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00396 if (strcmp(var_name, REDEF_VAR1_NAME) || xtype_in != NC_INT || ndims != REDEF_NDIMS ||
00397 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00398 if (nc_inq_var(ncid, 1, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00399 if (strcmp(var_name, REDEF_VAR2_NAME) || xtype_in != NC_BYTE || ndims != REDEF_NDIMS ||
00400 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00401
00402 if (nc_close(ncid)) ERR;
00403
00404
00405 if (nc_open(FILE_NAME, NC_WRITE, &ncid)) ERR;
00406
00407
00408 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00409 if (ndims != REDEF_NDIMS || nvars != 2 || natts != 2 || unlimdimid != -1) ERR;
00410
00411
00412 if ((format != NC_FORMAT_NETCDF4) && nc_redef(ncid)) ERR;
00413 if (nc_def_var(ncid, REDEF_VAR3_NAME, NC_BYTE, REDEF_NDIMS, dimids, &varid)) ERR;
00414
00415
00416 ret = nc_put_att_uchar(ncid, NC_GLOBAL, REDEF_ATT3_NAME, NC_BYTE, 1, &uchar_out);
00417 if (format != NC_FORMAT_NETCDF4 && ret) ERR;
00418 else if (format == NC_FORMAT_NETCDF4 && ret != NC_ERANGE) ERR;
00419
00420
00421 if (nc_inq(ncid, &ndims, &nvars, &natts, &unlimdimid)) ERR;
00422 if (ndims != REDEF_NDIMS || nvars != 3 || natts != 3 || unlimdimid != -1) ERR;
00423 if (nc_inq_var(ncid, 0, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00424 if (strcmp(var_name, REDEF_VAR1_NAME) || xtype_in != NC_INT || ndims != REDEF_NDIMS ||
00425 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00426 if (nc_inq_var(ncid, 1, var_name, &xtype_in, &ndims, dimids_in, &natts)) ERR;
00427 if (strcmp(var_name, REDEF_VAR2_NAME) || xtype_in != NC_BYTE || ndims != REDEF_NDIMS ||
00428 dimids_in[0] != dimids[0] || dimids_in[1] != dimids[1]) ERR;
00429 if (nc_inq_var(ncid, 2, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00430 if (ndims != REDEF_NDIMS || strcmp(var_name, REDEF_VAR3_NAME) || var_type != NC_BYTE ||
00431 natts != 0) ERR;
00432
00433 if (nc_close(ncid)) ERR;
00434
00435
00436 if (nc_open(FILE_NAME, 0, &ncid)) ERR;
00437 if (nc_inq_dim(ncid, 0, dim_name, &dim_len)) ERR;
00438 if (dim_len != REDEF_DIM1_LEN || strcmp(dim_name, REDEF_DIM1_NAME)) ERR;
00439 if (nc_inq_dim(ncid, 1, dim_name, &dim_len)) ERR;
00440 if (dim_len != REDEF_DIM2_LEN || strcmp(dim_name, REDEF_DIM2_NAME)) ERR;
00441 if (nc_inq_var(ncid, 0, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00442 if (ndims != REDEF_NDIMS || strcmp(var_name, REDEF_VAR1_NAME) || var_type != NC_INT ||
00443 natts != 0) ERR;
00444 if (nc_inq_var(ncid, 1, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00445 if (ndims != REDEF_NDIMS || strcmp(var_name, REDEF_VAR2_NAME) || var_type != NC_BYTE ||
00446 natts != 0) ERR;
00447 if (nc_inq_var(ncid, 2, var_name, &var_type, &ndims, dimids_var, &natts)) ERR;
00448 if (ndims != REDEF_NDIMS || strcmp(var_name, REDEF_VAR3_NAME) || var_type != NC_BYTE ||
00449 natts != 0) ERR;
00450 if (nc_get_att_float(ncid, NC_GLOBAL, REDEF_ATT1_NAME, &float_in) != NC_ERANGE) ERR;
00451 if (nc_get_att_int(ncid, NC_GLOBAL, REDEF_ATT2_NAME, &int_in)) ERR;
00452 if (int_in != short_out) ERR;
00453 ret = nc_get_att_uchar(ncid, NC_GLOBAL, REDEF_ATT3_NAME, &uchar_in);
00454 if (format == NC_FORMAT_NETCDF4)
00455 {
00456 if (ret != NC_ERANGE) ERR;
00457 }
00458 else if (ret) ERR;
00459
00460 if (uchar_in != uchar_out) ERR;
00461 if (nc_close(ncid)) ERR;
00462
00463 }
00464
00465