The lay-out in memory for a derived type is contiguous, but the amount of memory used may not be as expected since the compiler is free to pad memory as needed to honor word boundaries.
The following example shows a typical Cartesian vector type, and defines what the `+' operation will do between two such types. The advantages are that such code can be isolated and rigorously tested, leading to more robust and less buggy code overall. The derived-type modules then can be re-used in other coding projects.
IMHO: derived-types add 'fun' to the language as it gives you the ability to create useful and meaningful components.
Code examples