Derived Datatypes
Data objects can be arranged into structures. These structures can consist of scalar variables, arrays, or even sub-structures. In Fortran, a structure of this sort is called a derived datatype and is very similar to the structs in C. A simple example looks like this:
The components of a structure are accessed through the name of the structure followed by a percent (%
) sign and the name of the component. Example:
A structure can be assigned in one self-contained statement:
Arrays of structures are manipulated like this:
©
|
Cornell University
|
Center for Advanced Computing
|
Copyright Statement
|
Access Statement
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)