- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The following code does compile, but shouldn't the compiler warn about the completely useless declaration statement for I inside the interface block?
This is with IFX 2024.1.0 (and same with the latest IFORT version).
MODULE M
IMPLICIT NONE (TYPE, EXTERNAL)
INTERFACE
MODULE SUBROUTINE S
IMPLICIT NONE (TYPE, EXTERNAL)
INTEGER :: I
END SUBROUTINE S
END INTERFACE
END MODULE M
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It will, if you request warnings; its doing so when warnings are not requested could be unpleasant or inconvenient.
S:\LANG>ifx /warn /c dontnag.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.2.0 Build 20240602
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
dontnag.f90(6): remark #7712: This variable has not been used. [I]
INTEGER :: I
---------------^
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The standard permits most anything that can be in a specification section inside an interface body; exceptions include FORMAT and DATA. Ideally, you should not be writing interface blocks for Fortran procedures - put them in modules or in a CONTAINS section instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve - our best practice is to declare interfaces (for all our procedures) in modules (or submodules); and have the body of those procedures CONTAINed in submodules of those modules (or submodules).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"Ideally, you should not be writing interface blocks for Fortran procedures". I am not sure I can get behind that. Old style F77 external routines is much more prone to errors and plain modules in larger applications leads to horrendous build cascades so we are forced into submodules and to write lots of interfaces for the exposed module procedures. What other choice is there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, submodules are one of the best things that have happened to Fortran since F2008! They bring so much clarity to our code structures, and they help avoid that dreaded compilation cascade problem! And of course you need to declared interfaces for the module procedures contained in those submodules - a very small price to pay given the overall benefits.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I did say "ideally", and there are of course challenges when trying to modernize old code.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page