j3-fortran / fortran_proposals

Proposals for the Fortran Standard Committee
178 stars 15 forks source link

Allow ABSTRACT INTERFACE to define submodule procedure interfaces #120

Open qolin1 opened 4 years ago

qolin1 commented 4 years ago

Consider a series of procedures in a number of SUBMODULEs. Each procedure requires its interface to be defined in the ancestor module.

The following refers to code in the ancestor module only, It does not refer to any changes in the submodules.

If many of these procedures have an identical interface (apart from the procedure name), it would be useful if the interfaces could be defined in a single ABSTRACT INTERFACE, and the resulting named interface used in subsequent PROCEDURE statements.

I asked in the Intel Fortran Forum if this were possible, but it appears it is not: see https://software.intel.com/en-us/forums/intel-fortran-compiler/topic/842383

I have attached the example file showing my existing code.

test.f90.txt

sblionel commented 4 years ago

This really isn't related to submodules - what you'd like to do is use PROCEDURE(abstract_interface) instead of SUBROUTINE/FUNCTION in an interface block or a procedure definition. I can think of uses for this without submodules. (Note that in a submodule, you can simply say MODULE PROCEDURE xxx with the interface having been defined in the parent module.)

Given that compilers already have to support MODULE PROCEDURE, I don't see this as a difficult thing. The downside is that a reader has to go looking elsewhere for the declarations of the dummy arguments, something I find annoying.

Jellby commented 4 years ago

The downside is that a reader has to go looking elsewhere for the declarations of the dummy arguments, something I find annoying.

Not more annoying than having to repeat and modify the same dummy argument declaration tens of times. Without this feature, the developer will use preprocessor include files... which doesn't make it less annoying for the reader.