1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF. The full HDF copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "tproto.h"
static float64 f64[10][10], tf64[10][10];
static float64 f64scale[10], tf64scale[10];
static float64 f64max = 40.0, f64min = 0.0;
static float64 tf64max, tf64min;
static float32 f32[10][10], tf32[10][10];
static float32 f32scale[10], tf32scale[10];
static float32 f32max = 40.0F, f32min = 0.0F;
static float32 tf32max, tf32min;
static int8 i8[10][10], ti8[10][10];
static int8 i8scale[10], ti8scale[10];
static int8 i8max = 127, i8min = -128;
static int8 ti8max, ti8min;
static uint8 ui8[10][10], tui8[10][10];
static uint8 ui8scale[10], tui8scale[10];
static uint8 ui8max = 255, ui8min = 0;
static uint8 tui8max, tui8min;
static int16 i16[10][10], ti16[10][10];
static int16 i16scale[10], ti16scale[10];
static int16 i16max = 1200, i16min = -1200;
static int16 ti16max, ti16min;
static uint16 ui16[10][10], tui16[10][10];
static uint16 ui16scale[10], tui16scale[10];
static uint16 ui16max = 20000, ui16min = 0;
static uint16 tui16max, tui16min;
static int32 i32[10][10], ti32[10][10];
static int32 i32scale[10], ti32scale[10];
static int32 i32max = 99999999, i32min = -999999999;
static int32 ti32max, ti32min;
static uint32 ui32[10][10], tui32[10][10];
static uint32 ui32scale[10], tui32scale[10];
static uint32 ui32max = 999999999, ui32min = 0;
static uint32 tui32max, tui32min;
void
test_sdnmms(void)
{
int i, j, err, err1, err2, ret;
intn rank;
int32 dims[2];
rank = 2;
dims[0] = 10;
dims[1] = 10;
MESSAGE(5, printf("Creating arrays...\n"););
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
f64[i][j] = (float64)((i * 40) + j); /* range: 0 ~ 4-billion */
f32[i][j] = (float32)((i * 40) + j); /* range: 0 ~ 4-billion */
i8[i][j] = (int8)((i * 10) + j); /* range: 0 ~ 100 */
ui8[i][j] = (uint8)((i * 20) + j); /* range: 0 ~ 200 */
i16[i][j] = (int16)((i * 3000) + j); /* range: 0 ~ 30000 */
ui16[i][j] = (uint16)((i * 6000) + j); /* range: 0 ~ 60000 */
i32[i][j] = (int32)((i * 20) + j); /* range: 0 ~ 2-billion */
ui32[i][j] = (uint32)((i * 40) + j); /* range: 0 ~ 4-billion */
}
f64scale[i] = (float64)((i * 40) + j); /* range: 0 ~ 4-billion */
f32scale[i] = (float32)((i * 40) + j); /* range: 0 ~ 4-billion */
i8scale[i] = (int8)((i * 10) + j); /* range: 0 ~ 100 */
ui8scale[i] = (uint8)((i * 20) + j); /* range: 0 ~ 200 */
i16scale[i] = (int16)((i * 3000) + j); /* range: 0 ~ 30000 */
ui16scale[i] = (uint16)((i * 6000) + j); /* range: 0 ~ 60000 */
i32scale[i] = (int32)((i * 20) + j); /* range: 0 ~ 2-billion */
ui32scale[i] = (uint32)((i * 40) + j); /* range: 0 ~ 4-billion */
}
ret = DFSDsetdims(rank, dims);
RESULT("DFSDsetdims");
MESSAGE(5, printf("Writing arrays to single file...\n"););
ret = DFSDsetNT(DFNT_NFLOAT64);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)f64scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&f64max, (void *)&f64min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)f64);
RESULT("DFSDadddata");
ret = DFSDsetNT(DFNT_NFLOAT32);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)f32scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&f32max, (void *)&f32min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)f32);
RESULT("DFSDadddata");
ret = DFSDsetNT(DFNT_NINT8);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)i8scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&i8max, (void *)&i8min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)i8);
RESULT("DFSDadddata");
ret = DFSDsetNT(DFNT_NUINT8);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)ui8scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&ui8max, (void *)&ui8min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)ui8);
RESULT("DFSDadddata");
ret = DFSDsetNT(DFNT_NINT16);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)i16scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&i16max, (void *)&i16min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)i16);
RESULT("DFSDadddata");
ret = DFSDsetNT(DFNT_NUINT16);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)ui16scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&ui16max, (void *)&ui16min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)ui16);
RESULT("DFSDadddata");
ret = DFSDsetNT(DFNT_NINT32);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)i32scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&i32max, (void *)&i32min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)i32);
RESULT("DFSDadddata");
ret = DFSDsetNT(DFNT_NUINT32);
RESULT("DFSDsetNT");
ret = DFSDsetdimscale(1, (int32)10, (void *)ui32scale);
RESULT("DFSDsetdimscale");
ret = DFSDsetrange((void *)&ui32max, (void *)&ui32min);
RESULT("DFSDsetrange");
ret = DFSDadddata("nntcheck.hdf", rank, dims, (void *)ui32);
RESULT("DFSDadddata");
MESSAGE(5, printf("Reading arrays from single file...\n"););
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)tf64);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)tf64scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&tf64max, (void *)&tf64min);
RESULT("DFSDgetrange");
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)tf32);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)tf32scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&tf32max, (void *)&tf32min);
RESULT("DFSDgetrange");
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)ti8);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)ti8scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&ti8max, (void *)&ti8min);
RESULT("DFSDgetrange");
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)tui8);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)tui8scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&tui8max, (void *)&tui8min);
RESULT("DFSDgetrange");
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)ti16);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)ti16scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&ti16max, (void *)&ti16min);
RESULT("DFSDgetrange");
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)tui16);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)tui16scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&tui16max, (void *)&tui16min);
RESULT("DFSDgetrange");
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)ti32);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)ti32scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&ti32max, (void *)&ti32min);
RESULT("DFSDgetrange");
ret = DFSDgetdata("nntcheck.hdf", rank, dims, (void *)tui32);
RESULT("DFSDgetdata");
ret = DFSDgetdimscale(1, (int32)10, (void *)tui32scale);
RESULT("DFSDgetdimscale");
ret = DFSDgetrange((void *)&tui32max, (void *)&tui32min);
RESULT("DFSDgetrange");
MESSAGE(5, printf("Checking arrays from single file...\n\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (!H4_DBL_ABS_EQUAL(f64[i][j], tf64[i][j]))
err = 1;
if (!H4_DBL_ABS_EQUAL(f64scale[i], tf64scale[i]))
err2 = 1;
}
if (!H4_DBL_ABS_EQUAL(f64max, tf64max) || !H4_DBL_ABS_EQUAL(f64min, tf64min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for float64 array.\n");
else printf("Test passed for float64 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for float64 scales.\n");
else printf("Test passed for float64 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for float64 max/min.\n");
else printf("Test passed for float64 max/min.\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (!H4_FLT_ABS_EQUAL(f32[i][j], tf32[i][j]))
err = 1;
if (!H4_FLT_ABS_EQUAL(f32scale[i], tf32scale[i]))
err2 = 1;
}
if (!H4_FLT_ABS_EQUAL(f32max, tf32max) || !H4_FLT_ABS_EQUAL(f32min, tf32min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for float32 array.\n");
else printf("Test passed for float32 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for float32 scales.\n");
else printf("Test passed for float32 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for float32 max/min.\n");
else printf("Test passed for float32 max/min.\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (i8[i][j] != ti8[i][j])
err = 1;
if (i8scale[i] != ti8scale[i])
err2 = 1;
}
if ((i8max != ti8max) || (i8min != ti8min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for int8 array.\n");
else printf("Test passed for int8 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for int8 scales.\n");
else printf("Test passed for int8 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for int8 max/min.\n");
else printf("Test passed for int8 max/min.\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (ui8[i][j] != tui8[i][j])
err = 1;
if (ui8scale[i] != tui8scale[i])
err2 = 1;
}
if ((ui8max != tui8max) || (ui8min != tui8min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for uint8 array.\n");
else printf("Test passed for uint8 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for uint8 scales.\n");
else printf("Test passed for uint8 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for uint8 max/min.\n");
else printf("Test passed for uint8 max/min.\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (i16[i][j] != ti16[i][j])
err = 1;
if (i16scale[i] != ti16scale[i])
err2 = 1;
}
if ((i16max != ti16max) || (i16min != ti16min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for int16 array.\n");
else printf("Test passed for int16 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for int16 scales.\n");
else printf("Test passed for int16 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for int16 max/min.\n");
else printf("Test passed for int16 max/min.\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (ui16[i][j] != tui16[i][j])
err = 1;
if (ui16scale[i] != tui16scale[i])
err2 = 1;
}
if ((ui16max != tui16max) || (ui16min != tui16min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for uint16 array.\n");
else printf("Test passed for uint16 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for uint16 scales.\n");
else printf("Test passed for uint16 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for uint16 max/min.\n");
else printf("Test passed for uint16 max/min.\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (i32[i][j] != ti32[i][j])
err = 1;
if (i32scale[i] != ti32scale[i])
err2 = 1;
}
if ((i32max != ti32max) || (i32min != ti32min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for int32 array.\n");
else printf("Test passed for int32 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for int32 scales.\n");
else printf("Test passed for int32 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for int32 max/min.\n");
else printf("Test passed for int32 max/min.\n"););
err = 0;
err1 = 0;
err2 = 0;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++)
if (ui32[i][j] != tui32[i][j])
err = 1;
if (ui32scale[i] != tui32scale[i])
err2 = 1;
}
if ((ui32max != tui32max) || (ui32min != tui32min))
err1 = 1;
num_errs += err + err1 + err2;
MESSAGE(5, if (err == 1) printf(">>> Test failed for uint32 array.\n");
else printf("Test passed for uint32 array.\n"););
MESSAGE(5, if (err2 == 1) printf(">>> Test failed for uint32 scales.\n");
else printf("Test passed for uint32 scales.\n"););
MESSAGE(5, if (err1 == 1) printf(">>> Test failed for uint32 max/min.\n");
else printf("Test passed for uint32 max/min.\n"););
}
|