Next: Some Additional Comments about Up: A Lawyer's View of Previous: Fitting the Universe

## Fortran and Gnuplot: the Summary

Tables 2.3 and 2.4 briefly summarise what we have learnet about Fortran and Gnuplot so far.

Table 2.3: A brief synopsis of selected Fortran constructs
 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

Table 2.4: A brief synopsis of selected Gnuplot constructs
 operation or concept Gnuplot ranges set xrange [0.0:15.0] set yrange [0.0:15.0] labels set label 1 ``0.5'' at 0.5,0.93 set label 3 `` = 10'' at 10.0,0.5 legend set nokey plots plot ``chi.out'' using 1:2:3 with errorbars, ``chi.out'' using 1:4 with lines Postscript output set terminal postscript eps 22 set output ``chi.eps'' replot include in LATEX includegraphics[width=10cm]chi.eps

Next: Some Additional Comments about Up: A Lawyer's View of Previous: Fitting the Universe
Zdzislaw Meglicki
2001-02-26