13.07.2015 Views

Fortran 90/95 Programming Manual

Fortran 90/95 Programming Manual

Fortran 90/95 Programming Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Fortran</strong> <strong>90</strong>/<strong>95</strong> <strong>Programming</strong> <strong>Manual</strong>Derived data typesWe have seen that the <strong>Fortran</strong> language contains 5 intrinsic types (integer, real, complex,logical, and character). In addition to these, the user can define derived types, which canconsist of data objects of different type.An example of a derived data type:type :: atomcharacter (len=2) :: labelreal :: x, y, zend type atomThis type can hold a 2-character atom name, as well as the atom’s xyz coordinates.An object of a derived data type is called a structure. A structure of type atom can becreated in a type declaration statement like:type(atom) :: carbon1The components of the structure can be accessed using the component selector character(%):carbon1%label = “C”carbon1%x = 0.0000carbon1%y = 1.3567carbon1%z = 2.5000Note that no spaces are allowed before and after the %!One can also make arrays of a derived type:and use it liketype(atom), dimension (10) :: moleculemolecule(1)%type = “C”Arithmetic operatorsThe intrinsic arithmetic operators available in <strong>Fortran</strong> <strong>90</strong> are:======================** exponentiation======================* multiplication/ division======================+ addition− subtraction======================These are grouped in order of precedence, thus, * has a higher precedence than +. Theprecedence can be overridden by using parentheses. For example:3 * 2 + 18

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!