Fortran re-engineering: data statements

The Fortran data statement is a means of initiating values in a variable. For example the statement below assigns the value 3.7 to the variable x.

real :: x
data x/3.7/

It is a very handy method of initializing arrays:

integer, dimension(10) :: aray
data aray/1,2,3,4,5,6,7,8,9,10/

There is nothing inherently wrong with the data statement, but it can easily be replaced with an array initializing statement of the form:

aray = (/1,2,3,4,5,6,7,8,9,10/)

It is not inherently a legacy feature though.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.