Exactly the same questions as Create an array with elements of different types, except how to do this in Fortran?
Say I want an array with the first dimension an integer type, the second real and the third character (string) type. Is it possible to create a “struct” in Fortran too?
Thanks.
Here is an example program of a derived type use:
The output is:
EDIT: As per suggestion by Jonathan Dursi:
In order to have an array where each element has a int, float and char element, you would do something like this:
You would then reference your elements as, e.g.
a(i)%ints,a(i)%floats,a(i)%chars.Related answer is given in Allocate dynamic array with interdependent dimensions.