I have been trying to figure out from first principles the

algorithm for determining the size parameter to give to

H5Tcreate. I need this to support access by an interpretive

language.

My general hypothesis is as follows.

1. construct a C language type corresponding to the type to be created

(call it T1).

2. replace all occurrences of variable length types (including strings?)

in T1 with the following struct.

typedef struct {

size_t size;

void* data;

} hvl_t;

3. the size of T1 is the same as the sizeof function

applied to the corresponding C type.

I converted the above to an algorithm that assumes maximal

field packing (i.e. no padding) for simplicity. The

algorithm is below. Is this the correct algorithm (assuming

you can figure it out from my cryptic representation)? Is

this documented anywhere (I could not find it)? Where in

the code is this computed (I assume it is there somewhere)?

=Dennis Heimbigner

## ···

-------------------------

Algorithm:

T represents an arbitrary type defined using the HDF type system

(primitive or user defined).

A star (*) indicated variable length.

sizeof(byte) = 1

sizeof(short) = 2

...

sizeof(double) = 8

sizeof(ENUM) = sizeof(unsigned int) // 32 bit int

sizeof(STRING) = sizeof(hvl_t)

sizeof(OPAQUE(n)) = n

sizeof(T(*)) = sizeof(hvl_t) // VLEN of T

sizeof(T[n1]) = sizeof(T)*n1 // 1-d array: n1 an integer

sizeof(T[n1,n2]) = sizeof(T)*(n1*n2) // 2-d array: n1,n2 are integers

sizeof(T[n1,n2,n3]) = sizeof(T)*(n1*n2*n3) // 3-d array: n1,n2,n3 are integers

...

sizeof(T[*]) = sizeof(T(*)) // equivalent to VLEN

sizeof(T[*,n1]) = sizeof(T(*))

sizeof(T[n1,*]) = n1*sizeof(T(*))

sizeof(T[n1,*,n2]) = n1*sizeof(T(*))

...

sizeof(struct{T1 f1, T2 f2}) = sizeof(T1) + sizeof(T2) // assume packed

sizeof(struct{T1 f1, T2 f2, T3 f3}) = sizeof(T1) + sizeof(T2)

+ sizeof(T3)

...

----------------------------------------------------------------------

This mailing list is for HDF software users discussion.

To subscribe to this list, send a message to hdf-forum-subscribe@hdfgroup.org.

To unsubscribe, send a message to hdf-forum-unsubscribe@hdfgroup.org.