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: Strings and Text Processing

Where to go deeper on Fortran text handling. Strings are a small topic in the standard, so the best references are the general language books (for the exact rules) plus the standard library (for the higher-level string routines this chapter deliberately built by hand). Sources are tagged Tier 1 (confident, recommended) and Tier 2 (real and worth seeking; confirm the current edition/URL).

The character intrinsics and the rules

  • Metcalf, Reid, and Cohen, Modern Fortran Explained (Oxford University Press). The definitive reference for the exact semantics of index, scan, verify, adjustl/adjustr, trim, and — most usefully — the precise rules for deferred-length allocatable characters and automatic reallocation on assignment. When you need to know exactly what an intrinsic returns at an edge case (an empty substring, an all-blank string), this is the book. Tier 1.
  • Stephen Chapman, Fortran for Scientists and Engineers (McGraw-Hill). A gentler, example-driven treatment of the character type, substrings, and formatted internal I/O, pitched at the level of this chapter. Good for a second pass if the intrinsic family did not fully land. Tier 1.

Internal files and formatting

  • The GCC / gfortran documentation — intrinsic procedures and I/O. The manual entries for the character intrinsics and for list-directed and formatted I/O document exactly what the compiler you are using does, including the width rules (i0, iw.m, the asterisk-fill on overflow) that govern internal writes. The authoritative answer for your toolchain. Tier 1.
  • The ISO/IEC 1539-1 Fortran standard (2018), clauses on the character type, intrinsic procedures, and data transfer. The source of truth for internal files and the character intrinsics; dense, but the last word when a book and a compiler seem to disagree. Tier 2 (access varies; drafts circulate freely).

The higher-level tools you built by hand

  • The Fortran Standard Library (stdlib), stdlib_strings and stdlib_string_type modules. The community library provides a string_type and ready-made split, replace_all, starts_with, to_lower, and more — the routines this chapter had you build from scan/verify so you understand them, and which you can reach for in real code once you do. Browse it at stdlib.fortran-lang.org. Tier 1.
  • fortran-lang.org learning resources and the Discourse forum. Practical, current examples of string handling and parsing in modern Fortran, and a place to ask why your verify returned what it did. Tier 1.

For contrast (why this style is worth it)

  • Brian Kernighan and Rob Pike, The Practice of Programming (Addison-Wesley). Not Fortran, but its chapters on text processing and interfaces are the clearest short statement of why tokenizing by content and converting deliberately beats fragile fixed-column parsing — the lesson of this chapter's first case study. Tier 2.

Suggested order

  1. Work this chapter's code/ examples until the scan/verify/internal-file trio is automatic — that is 80% of practical Fortran text handling.
  2. Skim stdlib_strings to see the higher-level routines you can now reach for, and recognize each as something you could write.
  3. Keep Metcalf/Reid/Cohen on the shelf for the one day you hit an edge case (an empty substring, a deferred-length reallocation subtlety) and need the exact rule.
  4. Read the gfortran intrinsic pages for i0 and iw.m before you ship code that formats filenames or fixed-width fields — the width rules are where output bugs hide.