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.

profiler.py and block_analysis.py form the statement-classification tier of the pipeline. profiler.py reads every Fortran source file and classifies each logical statement into one of five groups — calculation, control flow, I/O, legacy, and declarations — producing both a per-unit density summary and a per-file audit CSV for every source file. block_analysis.py then takes those audit CSVs and constructs a hierarchical view of control-flow block nesting per unit, useful for understanding structural depth without reading raw source. Together, these two steps feed five later analyzers that all depend on the audit/ directory.
profiler.py must complete before complexity.py, common_blocks.py, symbols.py, derived_types.py, and equivalences.py — all five read the audit/*_DEBUG.csv files it produces.

profiler.py — Statement Density Analysis

profiler.py is step 3 of the pipeline.

Inputs

  • <FORT_OUT>/inventory_report.csv
  • Fortran source files in FORT_SRC

Outputs

<FORT_OUT>/report_density.csv — one row per program unit.
ColumnDescription
FileSource file name
UnitUnit name
TypeUnit type
Total_StatementsTotal classified statements in this unit
Total_CalcStatements in the calculation group
Total_ControlStatements in the control-flow group
Total_IOStatements in the I/O group
Total_LegacyStatements in the legacy group
Total_DeclStatements in the declaration group
Pct_CalcTotal_Calc / Total_Statements × 100
Pct_ControlTotal_Control / Total_Statements × 100
Pct_IOTotal_IO / Total_Statements × 100
Pct_LegacyTotal_Legacy / Total_Statements × 100
Pct_DeclTotal_Decl / Total_Statements × 100
N_CommonCount of COMMON statements
N_EquivCount of EQUIVALENCE statements
N_PrintCount of PRINT statements
N_WriteCount of WRITE statements
<FORT_OUT>/audit/<filename>_DEBUG.csv — one file per source file, one row per logical line.
ColumnDescription
LinePhysical start line number
KindStatement kind (e.g. IF_CONSTRUCT, DO_CONSTRUCT, ASSIGNMENT_STMT, COMMON_STMT, IO_STMT, COMMENT, …)
ContentFirst 120 characters of the logical line text

Statement Groups

GroupStatement Kinds Included
CALCASSIGNMENT_STMT and calculation actions (ALLOCATE, DEALLOCATE, POINTER_ACTION, …)
CONTROLIF_CONSTRUCT, DO_CONSTRUCT, SELECT_CONSTRUCT, ASSOCIATE_CONSTRUCT, WHERE_CONSTRUCT, FORALL_CONSTRUCT, CONTROL_STMT, ELSE_STMT, CASE_STMT
IOIO_STMT
LEGACYCOMMON_STMT, EQUIVALENCE_STMT, DATA_STMT, NAMELIST_STMT
DECLVAR_DECLARATION, PARAMETER_STMT, IMPLICIT_STMT, USE_STMT, IMPORT_STMT, TYPE_DEFINITION, ENUM_DEF, INTERFACE_BLOCK, CONTAINS_STMT, END_BLOCK_STMT
The statement group taxonomy (CALC, CONTROL, IO, LEGACY, DECL) is a project-defined classification designed to characterize Fortran code for migration analysis. It is not based on a published classification standard.

block_analysis.py — Control-Flow Block Topology

block_analysis.py is step 4 of the pipeline. It has no single script invocation in the pipeline — the pipeline batch-runs it once per source file automatically.

Inputs

  • <FORT_OUT>/audit/<filename>_DEBUG.csv files (produced by profiler.py)
  • <FORT_OUT>/inventory_report.csv (loaded via load_inventory() for unit line ranges)

Output

<FORT_OUT>/blocks/<filename>_blocks.txt — one file per source file. Shows the control-flow block nesting tree per unit. Each line reports: start_line - end_line | depth | tree_indent type | top_3_kinds. Example output:
STRUCTURAL ANALYSIS: solver_main.f90
================================================================================

>> UNIT: solver_main (SUBROUTINE)
    1-   45 |  0 |                              IF_CONSTRUCT        | IF_CONSTRUCT:12, ...
   45-  120 |  1 | |_                          DO_CONSTRUCT        | DO_CONSTRUCT:8, ...
  120-  145 |  2 | | |_                        SELECT_CONSTRUCT    | CASE_STMT:5, ...

Constructs Tracked

Block Openers

IF_CONSTRUCT, DO_CONSTRUCT, DO_WHILE_CONSTRUCT, SELECT_CONSTRUCT, SELECT_TYPE_CONSTRUCT, BLOCK_CONSTRUCT, INTERFACE_BLOCK, TYPE_DEFINITION, ASSOCIATE_CONSTRUCT, FORALL_CONSTRUCT, WHERE_CONSTRUCT, CRITICAL_CONSTRUCT

Block Closers

END_IF_STMT, END_DO_STMT, END_SELECT_STMT, END_BLOCK_STMT, END_ASSOCIATE_STMT, END_FORALL_STMT, END_WHERE_STMT, END_CRITICAL_STMT, END_INTERFACE_STMT, END_TYPE_STMT, END_FUNCTION_STMT, END_SUBROUTINE_STMT, END_MODULE_STMT, END_PROGRAM_STMT

Manual Invocation

When running block_analysis.py outside the pipeline, pass a single audit file directly:
# Analyze one file and print to stdout
python -m forti4d.analyzers.block_analysis results/audit/solver_main.f90_DEBUG.csv

# Save output manually
python -m forti4d.analyzers.block_analysis results/audit/solver_main.f90_DEBUG.csv \
    > results/blocks/solver_main.f90_blocks.txt

# Run all files via the pipeline
forti4d --only blocks
Manual invocation via python -m forti4d.analyzers.block_analysis is a temporary workaround. A dedicated CLI subcommand for scripts with file arguments is planned.

Build docs developers (and LLMs) love