Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
33 Views

USE statement in a module procedure interface

Using Intel XE 16 Update 3, the following code compiles without error. It looks as if the USE statement in the first procedure interface is visible to the second interface - I am not sure if this is as expected or if it is a bug.

MODULE M1
IMPLICIT NONE
TYPE T
    INTEGER :: I
END TYPE T
END MODULE M1


MODULE M2
IMPLICIT NONE
INTERFACE

    MODULE SUBROUTINE S1(V)
    USE M1
    TYPE(T) :: V
    END SUBROUTINE S1

    MODULE SUBROUTINE S2(W)
    TYPE(T) :: W
    END SUBROUTINE S2

END INTERFACE
END MODULE M2


 

0 Kudos
7 Replies
Highlighted
33 Views

This sounds vaguely familiar. Let me look into it.

0 Kudos
Highlighted
33 Views

Definitely a bug. It's sort of like another issue we saw earlier, but not the same. Escalated as issue DPD200413983.

0 Kudos
Highlighted
Beginner
33 Views

When you fix it, can you make it optionnal ?

Otherwise I will have to go to many of my programs and add the USEs in many subroutines

0 Kudos
Highlighted
33 Views

jmloriot, no - it won't be optional. But maybe you misunderstand the issue here. I think this problem is related to the use of submodules (that's what MODULE SUBROUTINE is doing here.) Can you provide an example of what you're doing now that you think will break?

0 Kudos
Highlighted
Beginner
33 Views

I have noticed for a long time that if you write subroutines in sequence you don’t have to repeat the USE statement, at least for TYPE definitions. I was aware that it might be a bug, but I took advantage of it. Now if you fix it, I will have to go through all my programs and add the USE statement in the subsequent subroutines. No big deal ! A other bug you fixed some time ago and I think you should not have done it : I have a module with all the INTERFACEs to all my subroutines, but I cannot use it to compile the subroutines themselves. Long time ago it did work, and I think it was easier and better as it did check the INTERFACE against the subroutine itself. Now if I change one calling parameter of a subroutine and I forgot to change the INTERFACE, it is going to take me some time to find what’s wrong. I went around it by using $defined, but that does not include the checking of the subroutine. Thank you for such a good FORTRAN
0 Kudos
Highlighted
Valued Contributor III
33 Views

@jmloriot  #6. If you use submodules the interfaces will self check with probably only minimal changes to your code.

0 Kudos
Highlighted
33 Views

It's even better to not use INTERFACE at all for Fortran code except when using submodules. But, yes, "interface to self" is not allowed by the standard and we properly diagnose it.

0 Kudos