[J3] dumb question about module use not inheriting into interfaces
Jeff Hammond
jehammond at nvidia.com
Fri Aug 26 11:00:26 UTC 2022
Thanks for both of your answers. Unfortunately, IMPORT does not save me any lines of code versus USE in this case, but it will be helpful in others.
Jeff
On 26Aug 2022, at 1:37 PM, Robert Corbett via J3 <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>> wrote:
External email: Use caution opening links or attachments
Until the IMPORT statement was introduced, interface blocks did not inherit names from the surrounding scoping units. Interface blocks were supposed to have the same meaning regardless of where they appeared. That meant that definitions and declarations from the surrounding scoping units had to be ignored.
Bob Corbett
On Aug 26, 2022, at 3:04 AM, Jeff Hammond via J3 <j3 at mailman.j3-fortran.org<mailto:j3 at mailman.j3-fortran.org>> wrote:
I observe that the following code fails when the line with “REQUIRED” in it is commented-out, but I do not understand it.
Why does the use inclusion of ISO_Fortran_env propagate into the contained subroutine but not the interface block?
It is mildly annoying to have to add a use line to every single interface, when it is used in the module already, but I assume there is some good reason for this.
Thanks,
Jeff
module confused
use, intrinsic :: ISO_Fortran_env
interface
subroutine foo(buffer) bind(C,name="foo")
use, intrinsic :: ISO_Fortran_env ! REQUIRED
implicit none
real(kind=REAL64), dimension(*) :: buffer
end subroutine foo
end interface
contains
subroutine bar(buffer) bind(C,name="bar")
implicit none
real(kind=REAL64), dimension(*) :: buffer
end subroutine bar
end module confused
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20220826/32f79383/attachment-0001.htm>
More information about the J3
mailing list