print_mpi_datatype (user access to mpi data types)

David Taylor (taylor@Think.COM)
Mon, 28 Aug 95 13:23:45 EDT

As mentioned in my previous message, I have implemented a function
print_mpi_datatype which given an MPI datatype will print (rather than
return) a slight variation of the BNF syntax described in Section 3.5
"Proposal of Leslie Hart and Tom Henderson" in the August 7, 1995 draft
of "MPI-2: Extensions to the Message-Passing Interface".

It uses the functions:

MPI_Type_count
MPI_Type_elements

for all internal MPI information.

Since I implemented this solely for the purpose of testing the above two
functions, I wasn't too worried about strict adherence to the proposed
BNF; but, I believe the only variations are:

I changed:

<basicTypeRef> ::= <nonNegInt>:(<typeDesc>)
to:
<basicTypeRef> ::= U<nonNegInt>(<typeDesc>)

and added:

b | P | LD | L

(byte, packed, long double, logical) to the list of basic types.

Additionally, it has no memory of which types have been encountered, so
it always prints the type description of a derived type -- if it
encounters it twice, it'll print it twice.

Here's the output of examples 3.20, 3.21, 3.22, 3.23, 3.24, and 3.26 in
the 1.1 spec:

example_3_20:
U594704(3U594608(S:2:d/1/0,c/1/8))

example_3_21:
U594704(HV:U594608(S:2:d/1/0,c/1/8):2:3:36)

example_3_22:
U594704(HV:U594608(S:2:d/1/0,c/1/8):3:1:-18)

example_3_23:
U594704(X:U594608(S:2:d/1/0,c/1/8):2:3/36,1/0)

example_3_24:
U594704(S:3:f/2/0,U594608(S:2:d/1/0,c/1/8)/1/16)

example_3_26:
U594704(2U594608(S:2:LB/1/-3,i/1/0))

[The big numbers after the 'U's are simply the values of the
MPI_Datatype's (which in MPICH are pointers) printed in decimal. The
reason why examples 3.21 and 3.22 have 'HV' rather than 'V' is because
MPICH internally calls MPI_Type_hvector from MPI_Type_vector.]