next up previous contents
Next: Double Precision. Up: Declaration of Variables Previous: Characters.   Contents


The declarations
real X, Y, PI  or  
real :: X, Y, PI
state that X, Y and PI are single precision floating point variables.

A real parameter (whose value cannot be changed subsequently) may be declared with

real PI
parameter (PI=3.141592)
or with
real, parameter :: PI=3.141592

The double colon form is needed for more than one attribute (see above), or for declarations plus initializations

real :: X = 21.5

Application: circle area and perimeter.

program first
implicit none ! disable implicit d.
  real :: R,Pi,a,p
  Pi = 3.1415926
  print*, 'Please give radius:'
  read*, R
  a=Pi**R     ! ** is exponentation operator
  print*, 'Area=',a,' Perimeter=',p
end program first

Adrian Sandu 2001-08-26