Affiliate disclosure

Book titles on this page link to Amazon. As an Amazon Associate, DataField.Dev earns from qualifying purchases — at no additional cost to you.

Further Reading: Variables, Types, and Arithmetic

Where to go deeper on types, kinds, and numerical arithmetic. Sources are tagged Tier 1 (works we are confident exist and recommend) and Tier 2 (real and worth seeking; confirm the current edition or URL yourself). The deep theory of why floating point is approximate — machine epsilon, cancellation, IEEE 754 — is deliberately deferred to Chapter 20 and its reading list; here the focus is on declaring and computing correctly.

The canonical books

  • Stephen Chapman, Fortran for Scientists and Engineers (McGraw-Hill). Its early chapters on data types, kind parameters, and arithmetic operators are the closest match to this chapter's spirit; the worked examples on integer-vs-real division are especially clear. Tier 1.
  • Metcalf, Reid, and Cohen, Modern Fortran Explained (Oxford University Press). The definitive reference for the exact rules: the intrinsic types, the kind type parameter mechanism, and the precise behavior of mixed-mode expressions and the numeric intrinsics. Reach for it when you need the letter of the standard, not a tutorial. Tier 1.
  • Milan Curcic, Modern Fortran: Building Efficient Parallel Applications (Manning). Models the modern house style this book teaches — real(dp), kind parameters from iso_fortran_env, _dp literals — in the context of real projects, so you see the conventions doing useful work. Tier 1.

Free and online

  • fortran-lang.org — the "Learn" pages and mini-book. Free, current tutorials on variables, types, and operators, with runnable snippets; an excellent second explanation when a concept here has not yet clicked. Tier 1.
  • The GNU Fortran (gfortran) manual — "Intrinsic Procedures" and the ISO_FORTRAN_ENV sections. The authoritative list of what sqrt, mod, modulo, selected_real_kind, precision, range, and the rest actually do on the compiler you are using, including the kind numbers it assigns. Tier 1.

Primary sources

Tools worth opening now

  • Compiler Explorer (godbolt.org), with gfortran selected. Paste the kinds_demo program from §3.2 and watch the compiler resolve selected_real_kind(15, 307) to a concrete kind; a fast, tactile way to see that kind numbers are the compiler's business and precision requests are yours. Tier 1.
  • The Fortran Playground (linked from fortran-lang.org). Run this chapter's small programs in the browser with nothing installed — ideal for confirming your hand-predicted outputs against a real compiler, which is the habit every "type, compile, and run" exercise is training. Tier 1.

Suggested order

  1. Read this chapter's §3.2 and §3.4 again with Chapman's data-types chapter open beside them — those two sections (precision and integer division) are where a second pass pays off most.
  2. Skim the gfortran "Intrinsic Procedures" index so you know what is available before you reach for a library; you will be surprised how much math is built in.
  3. Keep Metcalf, Reid & Cohen on the shelf as the arbiter for any "but what exactly does this expression evaluate to?" question that a compiler alone cannot settle.
  4. Save the IEEE 754 and floating-point references for Chapter 20; trying to absorb them now, before you have written numerical code that misbehaves, is premature.