Consider the proglet below. Even better, build it and run it under debugger control. Then step through, examining memory as you do so. I thought it was a 4-byte alignment issue at first until I experimented with type triple2.
If it was all within the confines of FORTRAN, it wouldn't matter and I'd probably never even have noticed. But I'm calling a routine written in C, which uses its own version of type triple1. No problem, I thought, I'm using FORTRAN 95 now, I can talk to it in its own language. But evidently not. And obviously I can work around the issue using type triple2, now I know there is an issue to work around. But I am curious to know what on Earth is going on, and why?
Andy
program test_triple_type
type triple1
character x
character y
character z
end type triple1
type triple2
character(len = 3) xyz
end type triple2
type (triple1) triplets1 (2), egtrip1
type (triple2) triplets2 (2), egtrip2
triplets1 (1) = triple1 ('a','b','c')
triplets1 (2) = triple1 ('d','e','f')
triplets2 (1) = triple2 ('abc')
triplets2 (2) = triple2 ('def')
egtrip1 = triplets1 (1)
egtrip2 = triplets2 (1)
stop
end program test_triple_type