- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Is an interface block in a module supposed to honor the implicit none declaration in the module? I find that the "contained" procedures do so (as expected) but not the declarations in the interface block. Is this as per the standard?
A test program is below. (---which has j vs k usage which is kind of obvious but I encountered it in something like iFrom vs iForm. I agree that typically the interface blocks like this are "copied" from other files and /or auto generated; so such errors won't be that common, nevertheless.)
Abhi
---
Module OM
Implicit None
Interface
Subroutine Method(i, j)
!Implicit None ! without this statement there is no compile-time error for "j"
Integer :: i, k
End Subroutine Method
End Interface
Contains
Subroutine Tech(i, j)
Integer :: i, k ! the error for j vs k is caught
i = 1
End Subroutine Tech
End Module OM
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Abhi,
I would say that the observed behaviour makes sense. The interface block in the module provides information about the interface of the subroutine Method(i, j) in this case, which itself is a subroutine outside of the module (right?). So, that subroutine would also not be affected by the implicit none statement inside the module. Everything in between interface ... end interface should not depend on the settings in the module the interface is stated.
Andi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Abhi, you may find it useful to read about the IMPORT statement, see https://software.intel.com/en-us/fortran-compiler-18.0-developer-guide-and-reference-import .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, IMPLICIT NONE does not propagate into the INTERFACE block. The way to view INTERFACE is as a window into the external procedure. Nothing from the enclosing scope is imported unless IMPORT is used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An interface body is its own scoping unit, separate from that of a module or a program unit where it might be present.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the responses.
I do use "import"; it won't change the current behavior i.e. won't make implicit none "visible/applicable" in the scope of the Interface Block. I doubt if there is any (standard) way to get implicit none applied to all methods in the interface block. And that's all right considering the typical usage as mentioned in the original post.
Abhi
p.s. for those who may come to this thread anew, here is a link to somewhat much broader discussion (that I didn't find/read earlier): https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/783797
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page