The real statement is used to declare variables of type real. Real variables are floating point numbers that will by default have seven decimal digits of precision on most computers. These variables will also have a default exponent range from ten to the negative thirty eighth power to ten to the thirty eighth power. Also, different attributes can be given to these variables within the real declaration.
Declaring real variables is an easy thing to do. However, before you begin declaring any variables to be of any type, make sure that you use the implicit none statement to disable the archaic FORTRAN feature that will automatically assume that all variables that begin with the letters a through h and o through z are REAL variables while those that begin with the variables i through n are of type INTEGER. Failure to do this can sometimes result in improper results being returned by your program if you are not careful typing in your variables.
Having used the implicit none statement you can now begin declaring variable types. There is no specific order in which the different data types have to be declared in so you can begin with any type. However, since this is written to describe real data types, that is the only thing that will be dealt here. To find out more about the other data types go to the section on type declaration. Now that all of that is said and done, the actual real declaration is very simple. It starts out with the real statement followed by any attributes to be attached to the data types and then finally the names of the variables themselves. Therefore your real statements will take on a form similar to one of the statements that are illustrated in the examples below.
real rho, gamma, radius real, allocatable, target :: velocity(:) real, pointer :: p1(:)
At some point in your programming career the accuracy of the results that are obtained by using the default seven decimal digits of precision will not be satisfactory. To get better answers you will then want to use either the double precision type declaration or the FORTRAN intrinsic function selected_real_kind. in combination with the KIND property for variable types. These two topics are covered elsewhere so I'm not going to go into detail about them. Just be aware that they can increase the accuracy of your real variables.
The following is a list of attribute specifiers that will work with the real statement. These are attributes that appear in the FORTRAN 90 standard and are universally accepted. There are usually a handful of machine dependent attributes that will only be valid on certain systems. Therefore, you will have to obtain a manual on the specific system that you are using to find out exactly what they are. allocatable, dimension, external, intent, intrinsic,
parameter, pointer, private, public, and target
roof.f and where.f
Written by Jason Wehr : firstname.lastname@example.org and Maintained by John Mahaffy : email@example.com