Skip to content

STY002 program-with-module ​

warning opt-in

A file defines both a program and a module.

Why ​

A module in the same file as a program cannot be used by anything else without compiling the program too, and the file mixes a library with its driver. Keep modules in their own files.

Reported ​

fortran
module helpers
end module helpers
program main
end program main

Preferred ​

fortran
! helpers.f90 holds the module, main.f90 the program

Suppressing ​

For one occurrence, with the reason on the same line (or alone on the line before the statement):

fortran
! fobis: ignore[STY002] <why this occurrence is fine>

For the whole project, ignore = STY002 in the fobos [lint] section.

Equivalent ​

Fortitude rule S212 (see Lint Rules).