summaryrefslogtreecommitdiffstats
path: root/test/gen_new_array.c
blob: d623db88a15f6a5e060d4a30338ce186f19def0f (plain)
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
/*
 * Copyright (C) 2000 NCSA
 *                    All rights reserved.
 *
 * Programmer:  Quincey Koziol <koziol@ncsa.uiuc.edu>
 *              Thursday, November 09, 2000
 *
 * Purpose:	Create a two datasets, one with a compound datatypes with array
 *      fields (which should be stored in the newer version (version 2)) and
 *      one with an array datatype.
 *		This program is used to create the test file `tarrnew.h5' which has a
 *      datatypes stored in the newer (version 2) style in the object headers.
 *		To build the test file, this program MUST be compiled and linked with
 *      the hdf5-1.3+ series of libraries and the generated test file must be
 *      put into the 'test' directory in the 1.2.x branch of the library.
 *      The test file should be generated on a little-endian machine with
 *      16-bit shorts, 32-bit floats, 32-bit ints and 64-bit doubles.
 */
#include "hdf5.h"

#define TESTFILE   "tarrnew.h5"

/* 1-D array datatype */
#define ARRAY1_RANK	1
#define ARRAY1_DIM1 4

/* 2-D dataset with fixed dimensions */
#define SPACE1_RANK	2
#define SPACE1_DIM1	8
#define SPACE1_DIM2	9


/*-------------------------------------------------------------------------
 * Function:	main
 *
 * Purpose:	
 *
 * Return:	Success:	
 *
 *		Failure:	
 *
 * Programmer:	Robb Matzke
 *              Monday, October 26, 1998
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
int
main(void)
{
    typedef struct {        /* Typedef for compound datatype */
        short i;
        float f[ARRAY1_DIM1];
        long l[ARRAY1_DIM1];
        double d;
    } s3_t;
    hid_t	file, space, type, arr_type, dset;
    hsize_t		tdims1[] = {ARRAY1_DIM1};
    hsize_t	cur_dim[SPACE1_RANK]={SPACE1_DIM1,SPACE1_DIM2};
    herr_t		ret;		/* Generic return value		*/

    /* Create the file */
    file = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    if(file<0)
        printf("file<0!\n");

    /* Create the dataspace (for both datasets) */
    space = H5Screate_simple(SPACE1_RANK, cur_dim, NULL);
    if(space<0)
        printf("space<0!\n");

    /* Create the compound datatype with array fields */
    type = H5Tcreate(H5T_COMPOUND, sizeof(s3_t));
    if(type<0)
        printf("type<0!\n");

    /* Insert integer field */
    ret = H5Tinsert (type, "i", HOFFSET(s3_t,i), H5T_NATIVE_SHORT);
    if(ret<0)
        printf("field 1 insert<0!\n");

    /* Creat the array datatype */
    arr_type=H5Tarray_create(H5T_NATIVE_FLOAT,ARRAY1_RANK,tdims1,NULL);
    if(arr_type<0)
        printf("arr_type<0!\n");

    /* Insert float array field */
    ret = H5Tinsert (type, "f", HOFFSET(s3_t,f), arr_type);
    if(ret<0)
        printf("field 3 insert<0!\n");

    /* Close array datatype */
    ret = H5Tclose (arr_type);
    if(ret<0)
        printf("field 3 array close<0!\n");

    /* Creat the array datatype */
    arr_type=H5Tarray_create(H5T_NATIVE_LONG,ARRAY1_RANK,tdims1,NULL);
    if(arr_type<0)
        printf("arr_type<0!\n");

    /* Insert long array field */
    ret = H5Tinsert (type, "l", HOFFSET(s3_t,l), arr_type);
    if(ret<0)
        printf("field 3 insert<0!\n");

    /* Close array datatype */
    ret = H5Tclose (arr_type);
    if(ret<0)
        printf("field 3 array close<0!\n");

    /* Insert double field */
    ret = H5Tinsert (type, "d", HOFFSET(s3_t,d), H5T_NATIVE_DOUBLE);
    if(ret<0)
        printf("field 4 insert<0!\n");

    /* Create the dataset with compound array fields */
    dset = H5Dcreate(file, "Dataset1", type, space, H5P_DEFAULT);
    if(dset<0)
        printf("dset<0!\n");
    H5Dclose(dset);

    /* Close compound datatype */
    H5Tclose(type);

    /* Create the compound datatype with array fields */
    type = H5Tarray_create(H5T_NATIVE_INT, ARRAY1_RANK, tdims1, NULL);
    if(type<0)
        printf("type<0!\n");

    /* Create the dataset with array datatype */
    dset = H5Dcreate(file, "Dataset2", type, space, H5P_DEFAULT);
    if(dset<0)
        printf("dset<0!\n");
    H5Dclose(dset);

    /* Close array datatype */
    H5Tclose(type);

    H5Sclose(space);
    H5Fclose(file);

    return 0;
}

>2009-08-141-3/+3 | |/ | | | | | | | | | | Task-number: 255853 Reviewed-by: Trust Me I'm-trusting: The information in the task :-) | * Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qtDavid Boddie2009-08-14357-8753/+20007 | |\ | | * QVariant: more work on avoinding conversion between float and doublesThierry Bastian2009-08-145-16/+16 | | | | | | | | | | | | we call QVariant::toReal instead of toDouble when needed | | * Fixed Coverity defect CID 1528.Gabriel de Dietrich2009-08-141-1/+1 | | | | | | | | | | | | Reviewed-by: Olivier | | * Removing some unused variables.Alessandro Portale2009-08-146-16/+0 | | | | | * QCssParser: reordering initializers to match declarationThierry Bastian2009-08-141-1/+1 | | | | | * Fixed coverity warningsThierry Bastian2009-08-1416-37/+26 | | | | | | | | | | | | | | | Some dead code removed Some member not initialized missing | | * QVariant: added toFloat and toRealThierry Bastian2009-08-1414-48/+90 | | | | | | | | | | | | | | | | | | | | | | | | Made better use of qreal all over the place. We were previously using QVariant::toDouble a lot. That is triggering unnecessary conversions between float and double on embedded. Reviewed-by: ogoffart | | * Set the QMAKE_BUNDLE_LOCATION to 'Contents/MacOS' only if it's not setTor Arne Vestbø2009-08-141-1/+1 | | | | | | | | | | | | | | | | | | This matches the logic for the 'lib' template to the one for 'app'. Reviewed-by: Simon Hausmann | | * Cocoa: Fix several issues with the event dispatcherRichard Moe Gustavsen2009-08-146-193/+308 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Autotest: qcoreapplication, qapplication, qtimer qwidget_window, qwidget Issue 1: stacking order of modal windows was not working correctly. With this patch, we remove the need for rebuilding modal sessions all the time, and when we do, we rebuild them all in the correct order. Issue 2: When running the event processor manually (that is, just calling processEvents in a loop), we sometimes spendt 100% cpu if a window was pending to become modal. The reason was that we need to keep reposting the QCocoaRequestModal event until we could block the calling thread (that is, one of the exec flags was given to processEvents). With this patch, the need for posting QCocoaRequestModal is completly removed in favor of an 'interrupt' approach instead. Issue 3: If using Qt as a plugin, or just add widget to a native cocoa application, it would often lead to closing down the application. The reason is that the event dispatcher needs to restart [NSApp run] now and then. But this approach fails if Qt was not the code that started [NSApp run] in the first place. This patch removes the need to restart NSApp in this situation, at the cost of modal windows not beeing modal if Qt is not spinning the event dispatcher. Normal QDialog::exec etc will always work. | | * Our modifications to freetypeHarald Fernengel2009-08-148-23/+292 | | | | | * Add freetype 2.3.9Harald Fernengel2009-08-14661-0/+292236 | | | | | * Deleted freetype 2.3.6Harald Fernengel2009-08-14650-282668/+0 | | | | | * Simplify WebKit import into src/3rdparty/webkitSimon Hausmann2009-08-141-2/+2 | | | | | | | | | | | | | | | | | | Limit the changelog to WebKit/qt. Reviewed-by: Trust me | | * QTextFormat: better use QVariant::userType over QVariant::typeThierry Bastian2009-08-141-15/+15 | | | | | | | | | | | | | | | it was even a bug when checking against QMetaType::Float because Float is a user type so it could never be true | | * Fix WebKit import into src/3rdparty/webkitSimon Hausmann2009-08-141-0/+3 | | | | | | | | | | | | | | | | | | Exclude platform/wince and platform/graphics/haiku Reviewed-by: Trust me | | * Fix trailing space in snippet file for gesture documentation.Peter Yard2009-08-141-1/+1 | | | | | * Gesture Overview DocumentationPeter Yard2009-08-145-0/+1163 | | | | | | | | | | | | | | | | | | | | | Overview of QGesture class and reference to QStandardGestures Gesture overview using ImageViewer example to demonstrate use of class by implementer. | | * Make Qt::NoGesture visible. Needed for QGesture subclassing.Peter Yard2009-08-141-1/+1 | | | | | * Add stringbuilder auto test to auto.prohjk2009-08-141-0/+1 | | | | | | | | | | | | Reviewed-by: trustme | | * Fix MLS testWarwick Allison2009-08-141-1/+2 | | | | | | | | | | | | "sm"+ellipsis (...) is same length as "small" in some fonts | | * spelWarwick Allison2009-08-144-14/+14 | | | | | * Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qtWarwick Allison2009-08-14