Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Keyword arguments

rahzan
New Contributor I
2,976 Views
According to the help files to use a keyword argument one needs an interface. This is annoying enough since he interface is right there on top of the procedure. But if the procedure is inside a module then cvf 6.6b still gives an error:
"The name of the module procedure conflicts with a name in the encompassing scoping unit."

here is the interface

interface
subroutine HHT_createTable(table_Name,TimeSeries)
character(*),intent(in):: table_Name
logical,intent(in),optional:: TimeSeries
end subroutine HHT_createTable
end interface

First I assume this interface has to be in the module not the caller program.

Second, where is name conflict, when the routine in the interface and the real one are identical
are these names case sensitive or decorated or...?
Seems I'm missing something obvious.

Thanks in advance.
Tim
0 Kudos
5 Replies
Steven_L_Intel1
Employee
2,976 Views
You don't show an entire source, so I'm not sure what you've done.

If you are using a module procedure, you don't use an INTERFACE block. The module procedure is its own explicit interface. If you have both, that's probably why you get the error.

See my article on the topic for more details.

Steve
0 Kudos
rahzan
New Contributor I
2,976 Views
Here is a QD version.
I can't even get this one to acknowledge the interface, much less the error I posted before.
It might be that before I had the module in a different file which is the way I have to do things.

Can you see the problem(s) this?

use m
real(4):: y2=1
call x(y2,z=4.)
end


module m
interface
subroutine x(y,z)
real(4),intent(in):: y
real(4),intent(in),optional:: z
end subroutine x
end interface

contains
subroutine x(y,z)
real(4),intent(in):: y
real(4),intent(in),optional:: z
if(present(z))write(*,*)z,y
pause
end subroutine x
end module m
0 Kudos
Steven_L_Intel1
Employee
2,976 Views
1. Get rid of the INTERFACE block in the module. As I said above, a module procedure is its own explicit interface. You don't need it twice (and in fact CAN'T).

2. You can't compile the main program until after the module has been compiled.

Steve
0 Kudos
rahzan
New Contributor I
2,976 Views
The way I have it is to keep the module in a separate file. I compile the mod file first. If there is no interface (which is fine by me), then I end up back where I started

Error: Keyword arguments are invalid without an explicit interface.

Is this simply not possible then?

Tim
0 Kudos
rahzan
New Contributor I
2,976 Views
After some unrelated fooling around, I set up the calls the way they were, (no interface block), and now I no longer get the interface-required error.

I don't know what I had done to get the error in the first place.

Sorry!
0 Kudos
Reply