| operation or concept |
Fortran |
| statement terminator |
newline and ; |
| comment character |
! |
| program structure |
program chi
...
contains
...
end program chi
|
| module structure |
module euler
...
contains
...
end module euler
|
| precision |
integer, parameter :: long = selected_real_kind(9,99)
...
real(kind=long) :: a
...
a = 3.14_long
|
| array declarations |
integer, parameter :: n = 100
real(kind=long), dimension(n) :: x
|
| array operations |
most operations that can be carried on
reals, plus reduction operations
such as MAXVAL, MINVAL,
PRODUCT, SUM, MINLOC,
MAXLOC, shifts, masking,
reshaping, and other
|
| IO |
integer, parameter :: output = 20
integer :: status
...
open (unit=output, file='chi.out', status='replace', action='write', iostat=status, err=99)
...
write(output, '(4f8.3)') x(i), y(i), sigma(i), y_prime(i)
...
close (unit=output)
...
99 continue
write(*, '(1a, $)') 'error: cannot open file chi.out'
...
|
| Formatted IO |
write(*, '(/, 2(1a, 1f7.3))') 'a = ', a, ' +- ', sigma_a
write(*, '(1a, 1i6)') 'IO status = ', status
write(*, *) a, b, c
|
| Function definition |
real(kind=long) function gamma(a)
real(kind=long), intent(in) :: a
gamma = ...
end function gamma
|
| Generic interface |
interface
function d_lgamma(x)
double precision :: d_lgamma
double precision, intent(in) :: x
end function d_lgamma
end interface
|
| Iterations |
integer :: i
integer, parameter :: n = 300
real(kind=long) :: g, g_sum
real(kind=long), parameter :: epsilon = 1.0E-9
...
do i = 1, n
...
end do
...
do while (abs(g) .gt. abs(g_sum) * epsilon)
...
end do
|
| Conditions |
real(kind=long) :: x
...
if (x .lt. 0.0_long) then
...
else
...
end if
|
|