# warn

Specifies diagnostic messages to be issued by the compiler.

## Syntax

Linux: | -warn [keyword[, keyword...]] -nowarn

macOS: | -warn [keyword[, keyword...]] -nowarn

Windows: | /warn[:keyword[, keyword...]] /nowarn

## Arguments

keyword | Specifies the diagnostic messages to be issued. Possible values are:
all | Enables all warning messages except errors and stderrors. This is the default if no keyword is specified. Note that if all is in effect, stderrors are not upgraded to warning level.
[no]alignments | Determines whether warnings occur for data that is not naturally aligned.
[no]declarations | Determines whether warnings occur for any undeclared names.
[no]errors | Determines whether warnings are changed to errors.
[no]externals | Determines whether warnings occur for any dummy procedures or procedure calls that have no explicit interface or have not been declared external.
[no]general | Determines whether warning messages and informational messages are issued by the compiler.
[no]ignore_bounds | Determines whether the compiler issues warnings if it detects at compile time that a constant array subscript is out of the declared bounds of the array.
[no]ignore_loc | Determines whether warnings occur when %LOC is stripped from an actual argument.
[no]interfaces | Determines whether the compiler checks the interfaces of all SUBROUTINEs called and FUNCTIONs invoked in your compilation against an external set of interface blocks.
[no]shape | Determines whether array conformance violations are diagnosed with errors or warnings when used with the check shape option.
[no]stderrors | Determines whether warnings about Fortran standard violations are changed to errors.
[no]truncated_source | Determines whether warnings occur when source exceeds the maximum column width in fixed-format files.
[no]uncalled | Determines whether warnings occur when a statement function is never called
[no]unused | Determines whether warnings occur for declared variables that are never used.
[no]usage | Determines whether warnings occur for questionable programming practices.
none | Disables all warning messages.

## Default

alignments | Warnings are issued about data that is not naturally aligned.
general | All information-level and warning-level messages are enabled.
nodeclarations | No warnings are issued for undeclared names.
noerrors | Warning-level messages are not changed to error-level messages.
noexternals | No warnings are issued when a dummy procedure or external procedure does not have an explicit interface and has not be declared external.
noignore_bounds | The compiler checks array references with constant subscripts and warns if the reference is to an element outside the declared bounds of the array.
noignore_loc | No warnings are issued when %LOC is stripped from an argument.
nointerfaces | The compiler does not check interfaces of SUBROUTINEs called and FUNCTIONs invoked in your compilation against an external set of interface blocks.
noshape | Array conformance violations are issued as errors if the check shape option is specified.
nostderrors | Warning-level messages about Fortran standards violations are not changed to error-level messages.
notruncated_source | No warnings are issued when source exceeds the maximum column width in fixed-format files.
nounused | No warnings are issued for variables that are declared but never used.
uncalled | Warnings are issued when a statement function is not called.
usage | Warnings are issued for questionable programming practices.

## Description

This option specifies the diagnostic messages to be issued by the compiler.

Option | Description
--- | ---
warn none | Disables all warning messages. This is the same as specifying nowarn.
warn noalignments | Disables warnings about data that is not naturally aligned.
warn declarations | Enables warnings about any undeclared names. The compiler will use the default implicit data typing rules for such undeclared names. The IMPLICIT and IMPLICIT NONE statements override this option.
warn errors | Tells the compiler to change all warning-level messages to error-level messages; this includes warnings about Fortran standards violations.
warn externals | Enables warnings about dummy procedures and external procedures that do not have explicit interfaces and have not been declared with the EXTERNAL attribute.
warn nogeneral | Disables all informational-level and warning-level diagnostic messages.
warn ignore_bounds | The compiler does not check array references with constant subscripts and no warnings are issued if the reference is to an element outside the declared bounds of the array.
warn ignore_loc | Enables warnings when %LOC is stripped from an actual argument.
warn interfaces | Tells the compiler to check the interfaces of all SUBROUTINEs called and FUNCTIONs invoked in your compilation against a set of interface blocks stored separately from the source being compiled. The compiler generates a compile-time message if the interface used to invoke a routine does not match the interface defined in a .mod file external to the source (that is, in a .mod generated by option gen-interfaces as opposed to a .mod file USEd in the source). The compiler looks for these .mods in the current directory or in the directory specified by the include (-I) or -module option. If interface mismatches occur, some will result in a compile-time error, others will only generate a warning. By default, warn interfaces turns on option gen-interfaces. You can turn off that option by explicitly specifying option nogen-interfaces.
warn shape | If the check shape option is specified, array conformance violations are issued as warnings rather than as errors.
warn stderrors | Tells the compiler to change all warning-level messages about Fortran standards violations to error-level messages. This option sets the stand option.
warn truncated_source | Enables warnings when a source line exceeds the maximum column width in fixed-format source files. The maximum column width for fixed-format files is 72, 80, or 132, depending on the setting of the extend-source option. The warn truncated_source option has no effect on truncation; lines that exceed the maximum column width are always truncated. This option does not apply to free-format source files.
warn nouncalled | Disables warnings for variables that are declared but never used.
warn unused | Enables warnings for variables that are declared but never used.
warn nousage | Disables warnings about questionable programming practices. Questionable programming practices, although allowed, often are the result of programming errors; for example: a continued character or Hollerith literal whose first part ends before the statement field and appears to end with trailing spaces. Note that the /pad-source option can prevent this error.
warn all | This is the same as specifying warn. This option does not set options warn errors or warn stderrors. To enable all the additional checking to be performed and force the severity of the diagnostic messages to be severe enough to not generate an object file, specify warn all warn errors or warn all warn stderrors. On Windows systems: In the Property Pages, Custom means that diagnostics will be specified on an individual basis.

## IDE Equivalent

Visual Studio: General > Compile Time Diagnostics (/warn:all, /warn:none)

Diagnostics > Treat Warnings as Errors (/warn:[no]errors)

Diagnostics > Treat Fortran Standard Warnings as Errors (/warn:[no]stderrors)

Diagnostics > Language Usage Warnings > Compile Time Diagnostics (/warn:all, /warn:none)

Diagnostics > Warn for Undeclared Symbols (/warn:[no]declarations)

Diagnostics > Warn for Undeclared Externals (/warn:[no]externals)

Diagnostics > Warn for Unused Variables (/warn:[no]unused)

Diagnostics > Warn When Removing %LOC (/warn:[no]ignore_loc)

Diagnostics > Warn When Truncating Source Line (/warn:[no]truncated_source)

Diagnostics > Warn for Unaligned Data (/warn:[no]alignments)

Diagnostics > Warn for Uncalled Statement Function (/warn:[no]uncalled)

Diagnostics > Warn for Array Conformance Violations (/warn:shape)

Diagnostics > Suppress Usage Messages (/warn:[no]usage)

Diagnostics > Check Routine Interfaces (/warn:[no]interfaces)

## Alternate Options

warn none | Linux and macOS: -nowarn, -w, -W0, -warn nogeneral Windows: /nowarn,/w, /W0, /warn:nogeneral
warn declarations | Linux and macOS: -implicitnone, -u Windows: /4Yd
warn nodeclarations | Linux and macOS: None Windows: /4Nd
warn general | Linux and macOS: -W1 Windows: /W1
warn nogeneral | Linux and macOS: -W0, -w, -nowarn, -warn none Windows: /W0, /w, /nowarn, /warn:none
warn stderrors | Linux and macOS: -e90, -e95, -e03, -e08, -e18 Windows: None
warn all | Linux and macOS: -warn Windows: /warn (this is a deprecated option)

Parent topic: Compiler Diagnostic Options