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: Pointers, Targets, and Dynamic Data Structures
Pointers are the part of Fortran where the reference material matters most, because the rules on
association, dangling, and contiguous are precise and easy to half-remember. 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 reference books
- Metcalf, Reid, and Cohen, Modern Fortran Explained (Oxford University Press). The authoritative
account of pointers, targets, association status, and the
contiguousattribute, with the exact rules the standard imposes. When you need to know precisely what is and is not allowed — what may be a pointer target, when a section is "simply contiguous" — this is the book. Tier 1. - Stephen Chapman, Fortran for Scientists and Engineers (McGraw-Hill). A gentler, example-driven treatment of pointers and dynamic data structures, including worked linked lists; good for a second explanation in a different voice. Tier 1.
- Milan Curcic, Modern Fortran: Building Efficient Parallel Applications (Manning). Strong on why
modern Fortran prefers
allocatable, and on writing dynamic, efficient code in the current style — the spirit of §11.4. Tier 1.
On the "prefer allocatable" wisdom and dynamic structures
- The Fortran standard, ISO/IEC 1539-1:2018. The definitive source for pointer association, the
associatedintrinsic's exact semantics,move_alloc, andis_contiguous. Terse, but final. Tier 1. fortran-lang.orglearning pages and the Fortran Discourse (fortran-lang.discourse.group). The community has written repeatedly and well on the allocatable-versus-pointer question and on building growable arrays; searching the Discourse for "pointer vs allocatable" surfaces working scientists making exactly the argument of this chapter. Tier 1.- The Fortran stdlib (
stdlib.fortran-lang.org). Read how a maintained library implements dynamic containers — it is the growable-array idea of Case Study 2, hardened for production. Tier 1.
On why arrays beat pointer-chasing (the performance case)
- Ulrich Drepper, "What Every Programmer Should Know About Memory." A long, superb technical article on caches, prefetching, and why scattered, pointer-linked memory access is slow — the hardware reality behind §11.3's "arrays usually win." Not Fortran-specific, and all the better for it. Tier 2.
- C. A. R. Hoare, "Null References: The Billion Dollar Mistake" (talk, QCon London 2009). The source of
this chapter's epigraph; a short, honest reflection by a founder of the field on why unchecked references
cause so much damage — useful perspective on why Fortran's
allocatable-first design is a safety feature. Tier 2.
Tools
- Compiler Explorer (
godbolt.org), gfortran. Paste acontiguous-annotated sweep and a plain one and compare the generated assembly; you will see the vectorized version the promise unlocks. By Chapter 27 this will read clearly. Tier 1. valgrindandgfortran -fcheck=all. The practical safety net for pointer code:valgrindfinds leaks and use-after-free (dangling) bugs, and-fcheck=allcatches many misuses at run time. We fold both into the debugging discipline of Chapter 13. Tier 1.
Suggested order
- Write and break the code first: type
code/example-01-pointer-basics.f90, then deliberately remove the=> null()initializer and thedeallocatein a list, and see whatvalgrindsays. - Read Metcalf/Reid/Cohen on pointers and
contiguousfor the exact rules, keeping Chapman beside it for a second angle on linked lists. - Skim Drepper on memory to feel why the contiguous array wins — it will make the §11.3 argument visceral rather than abstract.
- Browse the fortran-lang Discourse and stdlib to see the community's growable containers, then return to Case Study 2 and compare your buffer to theirs.