summaryrefslogtreecommitdiffstats
path: root/tools/h5import
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2008-09-29 16:15:58 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2008-09-29 16:15:58 (GMT)
commite8630b6e8018989dac031e9e7de93550ef5f8bed (patch)
treef29a7b3f4bc942a223f56e262eb351284ae4f386 /tools/h5import
parent993baa185a62d1a7c6a676d54762102683cee333 (diff)
downloadhdf5-e8630b6e8018989dac031e9e7de93550ef5f8bed.zip
hdf5-e8630b6e8018989dac031e9e7de93550ef5f8bed.tar.gz
hdf5-e8630b6e8018989dac031e9e7de93550ef5f8bed.tar.bz2
[svn-r15718] renamed generated binary files to have the extension .bin and the same name as the associated .conf file
tested: linux
Diffstat (limited to 'tools/h5import')
-rwxr-xr-xtools/h5import/h5importtest.c400
-rwxr-xr-xtools/h5import/h5importtestutil.sh15
2 files changed, 269 insertions, 146 deletions
diff --git a/tools/h5import/h5importtest.c b/tools/h5import/h5importtest.c
index 3c82e81..0b0ba9c 100755
--- a/tools/h5import/h5importtest.c
+++ b/tools/h5import/h5importtest.c
@@ -21,67 +21,65 @@
* h5importtest
*
* Description:
- * This program creates files that can be
+ * This program creates that can be
* used to test the h5import program.
*
*/
-/*
- * Define names for test files
- */
-
int
main(void)
{
- int nrow = 3, ncol = 4, npln = 5;
- int i, j, k;
- FILE *sp;
+ int nrow = 3, ncol = 4, npln = 5;
+ int i, j, k;
+ FILE *sp;
float b32r3[5][3][4];
float row4[3], col4[4], pln4[5];
float rowo4 = (float)11.0e0, colo4 = (float)21.0e0, plno4 = (float)51.0e0;
float rowi4 = (float)1.0e0, coli4 = (float)2.0e0, plni4 = (float)5.0e0;
- int b32i3[5][3][4];
- int row4i[3], col4i[4], pln4i[5];
- int rowo4i = (int)11 , colo4i = (int)21 , plno4i = (int)51 ;
- int rowi4i = (int)1 , coli4i = (int)2 , plni4i = (int)5 ;
+ int b32i3[5][3][4];
+ int row4i[3], col4i[4], pln4i[5];
+ int rowo4i = (int)11 , colo4i = (int)21 , plno4i = (int)51 ;
+ int rowi4i = (int)1 , coli4i = (int)2 , plni4i = (int)5 ;
- long_long b64i2[3][4], b64i3[5][3][4];
- long_long row4i64[3], col4i64[4], pln4i64[5];
- long_long rowo4i64 = (long_long)11 , colo4i64 = (long_long)21 , plno4i64 = (long_long)51 ;
- long_long rowi4i64 = (long_long)1 , coli4i64 = (long_long)2 , plni4i64 = (long_long)5 ;
+#ifndef WIN32
+ long_long b64i2[3][4], b64i3[5][3][4];
+ long_long row4i64[3], col4i64[4], pln4i64[5];
+ long_long rowo4i64 = (long_long)11 , colo4i64 = (long_long)21 , plno4i64 = (long_long)51 ;
+ long_long rowi4i64 = (long_long)1 , coli4i64 = (long_long)2 , plni4i64 = (long_long)5 ;
+#endif
short b16i3[5][3][4];
short row4i16[3], col4i16[4], pln4i16[5];
short rowo4i16 = (short)11 , colo4i16 = (short)21 , plno4i16 = (short)51 ;
short rowi4i16 = (short)1 , coli4i16 = (short)2 , plni4i16 = (short)5 ;
- char b8i3[5][3][4];
- char row4i8[3], col4i8[4], pln4i8[5];
- char rowo4i8 = (char)11 , colo4i8 = (char)21 , plno4i8 = (char)51 ;
- char rowi4i8 = (char)1 , coli4i8 = (char)2 , plni4i8 = (char)5 ;
+ char b8i3[5][3][4];
+ char row4i8[3], col4i8[4], pln4i8[5];
+ char rowo4i8 = (char)11 , colo4i8 = (char)21 , plno4i8 = (char)51 ;
+ char rowi4i8 = (char)1 , coli4i8 = (char)2 , plni4i8 = (char)5 ;
- double b64r3[5][3][4];
- double row8[3], col8[4], pln8[5];
- double rowo8 = 11.0e0, colo8 = 21.0e0, plno8 = 51.0e0;
- double rowi8 = 1.0e0, coli8 = 2.0e0, plni8 = 5.0e0;
+ double b64r3[5][3][4];
+ double row8[3], col8[4], pln8[5];
+ double rowo8 = 11.0e0, colo8 = 21.0e0, plno8 = 51.0e0;
+ double rowi8 = 1.0e0, coli8 = 2.0e0, plni8 = 5.0e0;
/*
- * initialize the row, column, and plane vectors
- *
- * row values start at 11 and increment by 1 => 11, 12, 13
- * column values start at 21 and increment by 2 => 21, 23, 25, 27
- * plane values start at 51 and increment by 5 => 51, 56, 61, 66, 71
- */
+ * initialize the row, column, and plane vectors
+ *
+ * row values start at 11 and increment by 1 => 11, 12, 13
+ * column values start at 21 and increment by 2 => 21, 23, 25, 27
+ * plane values start at 51 and increment by 5 => 51, 56, 61, 66, 71
+ */
/*
- * build array elements - rank 2
- *
- * element value = sum of row value and col values
- */
+ * build array elements - rank 2
+ *
+ * element value = sum of row value and col values
+ */
row4[0] = rowo4;
col4[0] = colo4;
@@ -95,9 +93,11 @@ main(void)
col4i[0] = colo4i;
pln4i[0] = plno4i;
+#ifndef WIN32
row4i64[0] = rowo4i64;
col4i64[0] = colo4i64;
pln4i64[0] = plno4i64;
+#endif
row4i16[0] = rowo4i16;
col4i16[0] = colo4i16;
@@ -112,163 +112,287 @@ main(void)
row4[i] = row4[i - 1] + rowi4;
row8[i] = row8[i - 1] + rowi8;
row4i[i] = row4i[i - 1] + rowi4i;
- row4i64[i] = row4i64[i - 1] + rowi4i64;
- row4i16[i] = row4i16[i - 1] + rowi4i16;
- row4i8[i] = row4i8[i - 1] + rowi4i8;
+#ifndef WIN32
+ row4i64[i] = row4i64[i - 1] + rowi4i64;
+#endif
+ row4i16[i] = row4i16[i - 1] + rowi4i16;
+ row4i8[i] = row4i8[i - 1] + rowi4i8;
}
for (j = 1; j < ncol; j++)
{
- col4[j] = col4[j - 1] + coli4;
- col8[j] = col8[j - 1] + coli8;
- col4i[j] = col4i[j - 1] + coli4i;
- col4i64[j] = col4i64[j - 1] + coli4i64;
- col4i16[j] = col4i16[j - 1] + coli4i16;
- col4i8[j] = col4i8[j - 1] + coli4i8;
+ col4[j] = col4[j - 1] + coli4;
+ col8[j] = col8[j - 1] + coli8;
+ col4i[j] = col4i[j - 1] + coli4i;
+#ifndef WIN32
+ col4i64[j] = col4i64[j - 1] + coli4i64;
+#endif
+ col4i16[j] = col4i16[j - 1] + coli4i16;
+ col4i8[j] = col4i8[j - 1] + coli4i8;
}
for (k = 1; k < npln; k++)
{
- pln4[k] = pln4[k - 1] + plni4;
- pln8[k] = pln8[k - 1] + plni8;
- pln4i[k] = pln4i[k - 1] + plni4i;
- pln4i64[k] = pln4i64[k - 1] + plni4i64;
- pln4i16[k] = pln4i16[k - 1] + plni4i16;
- pln4i8[k] = pln4i8[k - 1] + plni4i8;
- }
-
- for (i = 0; i < nrow; i++)
- {
- for (j = 0; j < ncol; j++)
- {
- b64i2[i][j] = row4i64[i] + col4i64[j];
- }
- }
+ pln4[k] = pln4[k - 1] + plni4;
+ pln8[k] = pln8[k - 1] + plni8;
+ pln4i[k] = pln4i[k - 1] + plni4i;
+#ifndef WIN32
+ pln4i64[k] = pln4i64[k - 1] + plni4i64;
+#endif
+ pln4i16[k] = pln4i16[k - 1] + plni4i16;
+ pln4i8[k] = pln4i8[k - 1] + plni4i8;
+ }
+
+ for (i = 0; i < nrow; i++)
+ {
+ for (j = 0; j < ncol; j++)
+ {
+#ifndef WIN32
+ b64i2[i][j] = row4i64[i] + col4i64[j];
+#endif
+ }
+ }
/*
- * build array elements - rank 3
- *
- * element value = sum of row value, col, and plane values
- */
+ * build array elements - rank 3
+ *
+ * element value = sum of row value, col, and plane values
+ */
for (i = 0; i < nrow; i++)
- {
- for (j = 0; j < ncol; j++)
+ {
+ for (j = 0; j < ncol; j++)
+ {
+ for (k = 0; k < npln; k++)
{
- for (k = 0; k < npln; k++)
- {
- b32r3[k][i][j] = row4[i] + col4[j] + pln4[k];
- b64r3[k][i][j] = row8[i] + col8[j] + pln8[k];
- b32i3[k][i][j] = row4i[i] + col4i[j] + pln4i[k];
- b64i3[k][i][j] = row4i64[i] + col4i64[j] + pln4i64[k];
- b16i3[k][i][j] = row4i16[i] + col4i16[j] + pln4i16[k];
- b8i3[k][i][j] = row4i8[i] + col4i8[j] + pln4i8[k];
- }
+ b32r3[k][i][j] = row4[i] + col4[j] + pln4[k];
+ b64r3[k][i][j] = row8[i] + col8[j] + pln8[k];
+ b32i3[k][i][j] = row4i[i] + col4i[j] + pln4i[k];
+#ifndef WIN32
+ b64i3[k][i][j] = row4i64[i] + col4i64[j] + pln4i64[k];
+#endif
+ b16i3[k][i][j] = row4i16[i] + col4i16[j] + pln4i16[k];
+ b8i3[k][i][j] = row4i8[i] + col4i8[j] + pln4i8[k];
}
- }
+ }
+ }
+
- /*
- * binary 32-bit file - rank 2 & 3
- */
#ifndef UNICOS
- sp = fopen("in16.txt", "w");
- for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
+
+ /*-------------------------------------------------------------------------
+ * TOOLTEST txtin16.txt -c $srcdir/testfiles/txtin16.conf -o txtin16.h5
+ *-------------------------------------------------------------------------
+ */
+
+
+ sp = fopen("txtin16.txt", "w");
+ for (k = 0; k < npln; k++)
+ {
+ for (i = 0; i < nrow; i++)
{
- for (j = 0; j < ncol; j++)
- (void) fprintf(sp, "%10u", b16i3[k][i][j]);
- (void) fprintf(sp, "\n");
+ for (j = 0; j < ncol; j++)
+ (void) fprintf(sp, "%10u", b16i3[k][i][j]);
+ (void) fprintf(sp, "\n");
}
+ }
(void) fclose(sp);
- sp = fopen("in32.txt", "w");
- for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
+ /*-------------------------------------------------------------------------
+ * TOOLTEST txtin32.txt -c $srcdir/testfiles/textin32.conf -o textin32.h5
+ *-------------------------------------------------------------------------
+ */
+
+ sp = fopen("txtin32.txt", "w");
+ for (k = 0; k < npln; k++)
+ {
+ for (i = 0; i < nrow; i++)
{
- for (j = 0; j < ncol; j++)
- (void) fprintf(sp, "%10d", b32i3[k][i][j]);
- (void) fprintf(sp, "\n");
+ for (j = 0; j < ncol; j++)
+ (void) fprintf(sp, "%10d", b32i3[k][i][j]);
+ (void) fprintf(sp, "\n");
}
- (void) fclose(sp);
+ }
+ (void) fclose(sp);
+
+ /*-------------------------------------------------------------------------
+ * TOOLTEST binin32.bin -c $srcdir/testfiles/binin32.conf -o binin32.h5
+ *-------------------------------------------------------------------------
+ */
- sp = fopen("bin32", "w");
+#ifdef WIN32
+ sp = fopen("binin32.bin", "wb");
+#else
+ sp = fopen("binin32.bin", "w");
+#endif
for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
- for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b32i3[k][i][j], sizeof(int), 1, sp);
+ {
+ for (i = 0; i < nrow; i++)
+ {
+ for (j = 0; j < ncol; j++)
+ {
+ (void) fwrite((char *) &b32i3[k][i][j], sizeof(int), 1, sp);
+ }
+ }
+ }
(void) fclose(sp);
+ /*-------------------------------------------------------------------------
+ * TOOLTEST binuin32.bin -c $srcdir/testfiles/binuin32.conf -o binuin32.h5
+ *-------------------------------------------------------------------------
+ */
- sp = fopen("buin32", "w");
+#ifdef WIN32
+ sp = fopen("binuin32.bin", "wb");
+#else
+ sp = fopen("binuin32.bin", "w");
+#endif
for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
- for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b32i3[k][i][j], sizeof(unsigned int), 1, sp);
+ {
+ for (i = 0; i < nrow; i++)
+ {
+ for (j = 0; j < ncol; j++)
+ {
+ (void) fwrite((char *) &b32i3[k][i][j], sizeof(unsigned int), 1, sp);
+ }
+ }
+ }
(void) fclose(sp);
- sp = fopen("bin64-2", "w");
- for (i = 0; i < nrow; i++)
- for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b64i2[i][j], sizeof(long_long), 1, sp);
- (void) fclose(sp);
- sp = fopen("bfp32", "w");
+
+ /*-------------------------------------------------------------------------
+ * TOOLTEST binin16.bin -c $srcdir/testfiles/binin16.conf -o binin16.h5
+ *-------------------------------------------------------------------------
+ */
+
+#ifdef WIN32
+ sp = fopen("binin16.bin", "wb");
+#else
+ sp = fopen("binin16.bin", "w");
+#endif
for (k = 0; k < npln; k++)
+ {
for (i = 0; i < nrow; i++)
+ {
for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b32r3[k][i][j],
- sizeof(float), 1, sp);
+ {
+ (void) fwrite((char *) &b16i3[k][i][j], sizeof(short), 1, sp);
+ }
+ }
+ }
(void) fclose(sp);
- sp = fopen("bin16", "w");
- for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
- for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b16i3[k][i][j], sizeof(short), 1,
- sp);
+ /*-------------------------------------------------------------------------
+ * TOOLTEST binuin16.bin -c $srcdir/testfiles/binuin16.conf -o binuin16.h5
+ *-------------------------------------------------------------------------
+ */
+#ifdef WIN32
+ sp = fopen("binuin16.bin", "wb");
+#else
+ sp = fopen("binuin16.bin", "w");
+#endif
+ for (k = 0; k < npln; k++)
+ {
+ for (i = 0; i < nrow; i++)
+ {
+ for (j = 0; j < ncol; j++)
+ {
+ (void) fwrite((char *) &b16i3[k][i][j], sizeof(unsigned short), 1, sp);
+ }
+ }
+ }
(void) fclose(sp);
- sp = fopen("buin16", "w");
- for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
- for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b16i3[k][i][j], sizeof(unsigned short), 1,
- sp);
- (void) fclose(sp);
- sp = fopen("bin64-3", "w");
- for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
- for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b64i3[k][i][j], sizeof(long_long), 1,
- sp);
- (void) fclose(sp);
+ /*-------------------------------------------------------------------------
+ * TOOLTEST binin8.bin -c $srcdir/testfiles/binin8.conf -o binin8.h5
+ *-------------------------------------------------------------------------
+ */
- sp = fopen("bin8", "w");
+#ifdef WIN32
+ sp = fopen("binin8.bin", "wb");
+#else
+ sp = fopen("binin8.bin", "w");
+#endif
for (k = 0; k < npln; k++)
- for (i = 0; i < nrow; i++)
- for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b8i3[k][i][j], sizeof(char), 1,
- sp);
+ {
+ for (i = 0; i < nrow; i++)
+ {
+ for (j = 0; j < ncol; j++)
+ {
+ (void) fwrite((char *) &b8i3[k][i][j], sizeof(char), 1, sp);
+ }
+ }
+ }
(void) fclose(sp);
-#endif
+#endif /* UNICOS */
- /*
- * binary 64-bit file - rank 2 & 3
- */
- sp = fopen("bfp64", "w");
+
+
+ /*-------------------------------------------------------------------------
+ * TOOLTEST binfp64.bin -c $srcdir/testfiles/binfp64.conf -o binfp64.h5
+ *-------------------------------------------------------------------------
+ */
+
+ /*
+ * binary 64-bit file - rank 2 & 3
+ */
+
+#ifdef WIN32
+ sp = fopen("binfp64.bin", "wb");
+#else
+ sp = fopen("binfp64.bin", "w");
+#endif
for (k = 0; k < npln; k++)
+ {
for (i = 0; i < nrow; i++)
+ {
for (j = 0; j < ncol; j++)
- (void) fwrite((char *) &b64r3[k][i][j],
- sizeof(double), 1, sp);
+ {
+ (void) fwrite((char *) &b64r3[k][i][j], sizeof(double), 1, sp);
+ }
+ }
+ }
(void) fclose(sp);
+
+
+
+ /*-------------------------------------------------------------------------
+ * TOOLTEST binin8w.bin -c $srcdir/testfiles/binin8w.conf -o binin8w.h5
+ *-------------------------------------------------------------------------
+ */
+
+ {
+ /* test CR+LF (13,10) and EOF (26) in windows */
+ char bin8w[4] = {13,10,26,0};
+
+#ifdef WIN32
+ sp = fopen("binin8w.bin", "wb");
+#else
+ sp = fopen("binin8w.bin", "w");
+#endif
+ for (i = 0; i < 4; i++)
+ {
+ char c = bin8w[i];
+ if ( fwrite( &c, sizeof(char), 1, sp) != 1 )
+ printf("error writing file\n");
+ }
+ fclose(sp);
+
+
+ }
+
+
+
+
+
return (0);
}
diff --git a/tools/h5import/h5importtestutil.sh b/tools/h5import/h5importtestutil.sh
index 759a660..cbe7ec6 100755
--- a/tools/h5import/h5importtestutil.sh
+++ b/tools/h5import/h5importtestutil.sh
@@ -81,22 +81,22 @@ TESTING "ASCII F64 - rank 3 - Output BE + CHUNKED+Extended+Compressed "
TOOLTEST $srcdir/testfiles/fp2.txt -c $srcdir/testfiles/textfp64.conf -o test7.h5
TESTING "BINARY F64 - rank 3 - Output LE+CHUNKED+Extended+Compressed "
-TOOLTEST bfp64 -c $srcdir/testfiles/binfp64.conf -o test8.h5
+TOOLTEST binfp64.bin -c $srcdir/testfiles/binfp64.conf -o test8.h5
TESTING "BINARY I16 - rank 3 - Output order LE + CHUNKED + extended "
-TOOLTEST bin16 -c $srcdir/testfiles/binin16.conf -o test9.h5
+TOOLTEST binin16.bin -c $srcdir/testfiles/binin16.conf -o test9.h5
TESTING "BINARY I8 - rank 3 - Output I16LE + Chunked+Extended+Compressed "
-TOOLTEST bin8 -c $srcdir/testfiles/binin8.conf -o test10.h5
+TOOLTEST binin8.bin -c $srcdir/testfiles/binin8.conf -o test10.h5
TESTING "BINARY I32 - rank 3 - Output BE + CHUNKED "
-TOOLTEST bin32 -c $srcdir/testfiles/binin32.conf -o test11.h5
+TOOLTEST binin32.bin -c $srcdir/testfiles/binin32.conf -o test11.h5
TESTING "BINARY UI16 - rank 3 - Output byte BE + CHUNKED "
-TOOLTEST buin16 -c $srcdir/testfiles/binuin16.conf -o test12.h5
+TOOLTEST binuin16.bin -c $srcdir/testfiles/binuin16.conf -o test12.h5
TESTING "BINARY UI32 - rank 3 - Output LE + CHUNKED "
-TOOLTEST buin32 -c $srcdir/testfiles/binuin32.conf -o test13.h5
+TOOLTEST binuin32.bin -c $srcdir/testfiles/binuin32.conf -o test13.h5
TESTING "STR"
TOOLTEST $srcdir/testfiles/str.txt -c $srcdir/testfiles/textstr.conf -o test14.h5
@@ -104,8 +104,7 @@ TOOLTEST $srcdir/testfiles/str.txt -c $srcdir/testfiles/textstr.conf -o test14.h
TESTING "ASCII F64 - rank 1 - INPUT-CLASS TEXTFPE "
TOOLTEST $srcdir/testfiles/in64.txt -c $srcdir/testfiles/textpfe.conf -o test15.h5
-rm -f tx* b* *.dat *.txt
-rm -f test*.h5
+rm -f *.txt *.bin *.h5
rm -rf tmp_testfiles
else
echo "** h5import or h5importtest not available ***"