Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/acdeveloper-sci/forti4d/llms.txt

Use this file to discover all available pages before exploring further.

inventory.py is the foundation of the entire Forti4D pipeline. It scans every Fortran source file in your project directory, identifies each program unit — whether a subroutine buried inside a module or a bare executable file with no PROGRAM statement — and records its type, parent scope, physical line range, and any detected legacy or I/O constructs. Every other analyzer in the pipeline depends on inventory_report.csv being present and correct before it can run.
inventory.py is step 1 of the 19-step pipeline. All other scripts depend on its output.

Inputs and Outputs

Input: Fortran source files in FORT_SRC. Processed extensions: .f90, .f95, .f, .for, .f77. Output: <FORT_OUT>/inventory_report.csv — one row per program unit found.

Output Column Reference

ColumnDescription
FileSource file name (basename only)
TypeUnit type: PROGRAM, IMPLICIT-MAIN, MODULE, SUBROUTINE, FUNCTION, BLOCK_DATA, GENERIC_INTERFACE
NameUnit name as declared in source
ParentName of the enclosing unit, or GLOBAL if top-level
Start_LineFirst physical line of the unit
End_LineLast physical line of the unit
Total_LinesEnd_Line - Start_Line + 1
LegacyComma-separated list of legacy constructs found (COMMON, GOTO, EQUIVALENCE, etc.)
IOComma-separated list of I/O statements found (OPEN, READ, WRITE, CLOSE, etc.)
CustomReserved for additional audit flags

Unit Types

PROGRAM

Explicit PROGRAM statement — a named program entry point.

IMPLICIT-MAIN

A file that compiles to an executable with no PROGRAM statement. Detected when a file contains executable statements at the top level but no PROGRAM header.

MODULE

An F90 MODULE block — may contain subroutines, functions, and interface definitions.

SUBROUTINE

A SUBROUTINE definition, nested or top-level.

FUNCTION

A FUNCTION definition, nested or top-level.

BLOCK_DATA

An F77 BLOCK DATA unit — used to initialize named COMMON blocks.

GENERIC_INTERFACE

An INTERFACE block inside a module. End_Line is set equal to Start_Line by design: interfaces are treated as point declarations, not containers.

Scope Resolution

inventory.py uses a stack-based scope resolver to determine the parent of each unit:
1

Push on open

When a unit-opening statement is matched (e.g. SUBROUTINE, MODULE, FUNCTION), a new scope entry is pushed onto the stack.
2

Record parent

The innermost scope already on the stack at the time of the push becomes the Parent of the new unit.
3

Pop on close

When the corresponding END statement is matched, that scope is popped from the stack.
Top-level units (those with no enclosing scope when opened) receive Parent = GLOBAL.

Special Behaviors

GENERIC_INTERFACE line range: End_Line is always set equal to Start_Line. Interface blocks are recorded as point declarations — their internal content is not scanned as a separate unit body.
IMPLICIT-MAIN detection: A file is classified as IMPLICIT-MAIN when it contains executable statements at the top level but has no PROGRAM statement. dependencies.py represents these units as MAIN__<filename> nodes in the call graph.
Run inventory.py before any other analyzer. If inventory_report.csv is missing or stale, downstream scripts will either fail or produce incorrect results.

Build docs developers (and LLMs) love