The Intel® Parallel Studio XE 2016 or later versions for Fortran Windows* and Linux* have a feature enhancement supporting the Fortran 2008 standard SUBMODULE program unit.
This feature supports the isolation of a module subroutine/function interface from its implementation. It can minimize the impact of code modifications in a module subroutine/function implementation, provided that the interface does not change.
For example:
A module file containing lots of routines/functions
module bigmod
…
contains
subroutine sub1
…<implementation of sub1>
function func2
…<implementation of func2>
subroutine sub47
…<implementation of sub47>
…
end module bigmod
Multiple source files use the module subroutines/functions
! Source source1.f90
use bigmod
…
Call sub1
! Source source2.f90
use bigmod
…
x = func2(…)
! Source source47.f90
use bigmod
…
call sub47
When an edit is made inside the module, for example with a subroutine “sub47”; it could be a comment, new code, or fixing an existing implementation. Once the edit is complete you must recompile the module source and ALL source files that USE the module. This includes even if the interface did not change and even if the routine that USEs the module does not call the module routine that changed. For large apps users can experience a large cascade of time-consuming re-compilations.
With SUBMODULE support the module subroutines/functions can isolate their implementation from their interface by submodule program unit in separated source files. For the above example it can be re-written as:
Module source file
module bigmod
…
interface
module subroutine sub1 ! MODULE SUBROUTINE or MODULE FUNCTION in interface body
…
module function func2
…
module subroutine sub47
…
end interface
end module bigmod
A submodule source file containing the implementation of some subroutines/functions of the module
submodule (bigmod) bigmod_submod ! SUBMODULE(parent-id) submodule-name
contains
module subroutine sub1
… implementation of sub1
module function func2
… implementation of func2
…
module subroutine sub3
… implementation of sub3
end submodule bigmod_submod
Now the changes in module subroutine/function don’t force recompilation of uses of the module as long as the interface doesn’t change.
A submodule can extend a module or another submodule so a tree structure of submodules can be constructed. The declarations in a submodule are visible only to itself and its children submodule. A parent module should be compiled before its submodules. When a submodule is compiled, a file named as modname@submodname.smod will be created, along with the object file. A submodule can’t be referenced by USE statement.
Refer to the Intel® Parallel Studio XE 2019 for Fortran product documentation for additional details.
Have questions?
See our Get Help page for your support options.