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

Missing navigation in Visual Studio for submodule procedures

Andrew_Smith
Précieux contributeur I
338 Visites

Some time ago, Fortran introduced the concept of submodules. It allows us to define a procedure interface in the main module, then implement it in a submodule. Very modern and good.

Fortran goes a step beyond c headers though. In Fortran we can skip repeating the argument declarations in the implementer code. Instead of declaring a subroutine or function in the submodule, we declare a procedure.

eg. Module:

module moduleA
   implicit none
   interface
      module subroutine subA(var)
         integer, intent(in) :: var
      end
   end interface
end module

 Submodule:

submodule (moduleA) moduleAImplementation
contains
   implicit none
   module procedure subA
      print *, var
   end
end submodule

I use this a lot because it saves time and eliminates a source of error since only the "header" changes if we change an argument definition.

But when I look at the dropdown list of procedures in the submodule in Visual studio, it is empty.

Andrew_Smith_0-1770809638895.png

 

0 Compliments
1 Répondre
andrew_4619
Contributeur émérite III
319 Visites

Interesting. My personal preference to have the interface details in both locations as I find this much clearer when looking at the code as I do not have to look in two places to understand it. It is more typing and maintenance.  I minimise that by writing the implementation and then just copying the header  into the parent interfaces. 

 

But there is a problem in the VS integration. If you have module functions and module subroutines it lists them all in the left hand drop down, however  it does not recognise module procedure and worse if you add one module procedure all the existing module functions/subroutines disappear from the drop down. I suspect this maybe an easy fix adding module procedure  to a dictionary in that part of the Fortran integrations.

0 Compliments
Répondre