- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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 moduleSubmodule:
submodule (moduleA) moduleAImplementation
contains
implicit none
module procedure subA
print *, var
end
end submoduleI 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.
Lien copié
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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.
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable