22.03.2013 Views

Self study guide: Fortran 95 - University of Cambridge

Self study guide: Fortran 95 - University of Cambridge

Self study guide: Fortran 95 - University of Cambridge

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

appropriate kind parameter and then use it in the declaration <strong>of</strong> the variable. Here is<br />

a useful recipe:<br />

! find the kind <strong>of</strong> a high precision variable, by finding<br />

! the kind <strong>of</strong> 1.0d0<br />

integer, parameter :: dp=kind(1.0d0)<br />

! use dp to specify new real variables <strong>of</strong> high precision<br />

real(kind=dp) :: x,y<br />

! and complex variables<br />

complex(kind=dp) :: z<br />

! and arrays<br />

real(kind=dp), dimension(30) :: table<br />

The integer parameter dp can now also be used to qualify constants in the context <strong>of</strong><br />

expressions, defining them as double precision, e.g. 0.6_dp<br />

43

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!