Fortran Coding Practices
Application skill for Fortran style learning (from the archived awesome-guidelines style capsules). For HPC parallelism (OpenMP/OpenACC), combine with domain stack capsules in skills/*-foundation.
Core Principle
Fortran quality is modern-standard clarity, explicit modules, assumed-shape data, mechanical formatting, and documented public APIs.
When to Use / NOT
- Fortran scientific libraries, stdlib-style packages,
.f90 application code.
- Setting up fprettify, FORD, gfortran/ifx build, and test harness in CI.
NOT when:
- Legacy fixed-form
.f without modernization plan, migrate first or scope narrowly.
- Generated LAPACK interfaces, validate generators.
Workflow
- Layout, fprettify, files, indent (
fortran-style-formatting-layout.md).
- Modules, names, intent, exports (
fortran-style-naming-modules.md).
- Arrays, dp, assumed-shape, storage (
fortran-style-arrays-types.md).
- API, modern std, FORD (
fortran-style-modern-api.md).
- Verify, fprettify,
ford, compiler warnings, tests on changed units.
Red Flags
- Tabs or lines >132 characters
- Missing
intent on dummy arguments
- Blanket
use module without only
- No
implicit none
- Default-public module exporting everything
real*8 or implicit typing
- Obsolescent Fortran (
common, goto, arithmetic if)
dimension(:), allocatable when name(:) suffices
- Wrong stride hot loops (
A(i,:,:))
- Magic floats without
_dp
- Public symbols without FORD docs
- Multiple modules in one file
- Trailing whitespace
Verification
fprettify --diff / project formatter check
ford documentation build (if project uses FORD)
gfortran -std=f2008 -Wall (or project flags) on changed sources
ctest / project test runner
- Capsule checklist on
public :: export lists
References
awesome-guidelines/references/fortran-style-learning-note.md
awesome-guidelines/references/fortran-style-formatting-layout.md
awesome-guidelines/references/fortran-style-naming-modules.md
awesome-guidelines/references/fortran-style-arrays-types.md
awesome-guidelines/references/fortran-style-modern-api.md
1---2name: fortran-coding-practices3description: Use when authoring or reviewing Fortran, fprettify 4-space layout, lowercase snake_case, intent/assumed-shape, dp kind, private modules, FORD docs, modern F2003+ only, and build/fprettify/test in CI.4---56# Fortran Coding Practices78Application skill for Fortran style learning (from the archived `awesome-guidelines` style capsules). For HPC parallelism (OpenMP/OpenACC), combine with domain stack capsules in `skills/*-foundation`.910## Core Principle1112Fortran quality is **modern-standard clarity**, explicit modules, assumed-shape data, mechanical formatting, and documented public APIs.1314## When to Use / NOT1516- Fortran scientific libraries, stdlib-style packages, `.f90` application code.17- Setting up fprettify, FORD, gfortran/ifx build, and test harness in CI.1819**NOT when:**2021- Legacy fixed-form `.f` without modernization plan, migrate first or scope narrowly.22- Generated LAPACK interfaces, validate generators.2324## Workflow25261. **Layout**, fprettify, files, indent (`fortran-style-formatting-layout.md`).272. **Modules**, names, intent, exports (`fortran-style-naming-modules.md`).283. **Arrays**, dp, assumed-shape, storage (`fortran-style-arrays-types.md`).294. **API**, modern std, FORD (`fortran-style-modern-api.md`).305. **Verify**, fprettify, `ford`, compiler warnings, tests on changed units.3132## Red Flags3334- Tabs or lines >132 characters35- Missing `intent` on dummy arguments36- Blanket `use module` without `only`37- No `implicit none`38- Default-public module exporting everything39- `real*8` or implicit typing40- Obsolescent Fortran (`common`, `goto`, arithmetic `if`)41- `dimension(:), allocatable` when `name(:)` suffices42- Wrong stride hot loops (`A(i,:,:)`)43- Magic floats without `_dp`44- Public symbols without FORD docs45- Multiple modules in one file46- Trailing whitespace4748## Verification4950- `fprettify --diff` / project formatter check51- `ford` documentation build (if project uses FORD)52- `gfortran -std=f2008 -Wall` (or project flags) on changed sources53- `ctest` / project test runner54- Capsule checklist on `public ::` export lists555657## References5859- `awesome-guidelines/references/fortran-style-learning-note.md`60- `awesome-guidelines/references/fortran-style-formatting-layout.md`61- `awesome-guidelines/references/fortran-style-naming-modules.md`62- `awesome-guidelines/references/fortran-style-arrays-types.md`63- `awesome-guidelines/references/fortran-style-modern-api.md`