What are submodules and how are they used?

Exascale

I don't quite understand the purpose of submodules. I know there's very little support for them in most compilers but the concept is interesting. I think I understand the basic concept but all the examples I've seen (Fortran Wiki, Modern Fortran Explained, the technical report) are simplistic, use exactly the same example (point type all within the same file) and don't show their actual use when calling the function. In what situations would you want to use submodules? When you want to use a submodule do you include a use statement? I'd really like if someone could provide an example.

IanH

The simple answer is that you put code into submodules when you want to have less code in the parent module or submodule.

You might want to have less source code in the parent module or submodule because the source code for the parent is getting too long.

Before submodules, the only way this could be done was to move source code out of the module into a different module or external procedure. But this wasn't always possible if the source code to be moved referenced PRIVATE things or components that were to remain in the original module. Submodules can access the things declared in their parent module or submodule by host association - the source code can still access PRIVATE things in the same way that it could if it was still part of the physical source code of the parent.

You might also want to split source code out of the parent module in order to avoid compilation cascades, if relevant to your processor. Changes to a module typically require recompilation of that module (and its descendants), and then recompilation of all program units that use that module (and their descendants), repeatedly cascading to further recompilation where any recompiled program units are themselves modules. Changes to a submodule typically only require recompilation of that submodule and any of its descendant submodules.

The hierarchical nature of submodules may also suit a hierarchical code arrangement - where you do not want siblings at the same level of the hierarchy to be able to directly access the entities and procedures that they define.

The USE statement is only used where you want to access things in a scope that are provided by a module. You cannot "use" a submodule in a USE statement (though a procedure with its INTERFACE defined in a module may have its body defined in a submodule).

A submodule of a module does not USE the parent module (it cannot - that is a bit like a module trying to USE itself) and it doesn't need to - it already has access to the things in the module by host association. The submodule statement that starts a submodule program unit identifies the module (and perhaps another submodule) that it extends. There is nothing in the source of a module proper that tells it how many submodules there may be extending it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

What is decltype and how is it used?

From Dev

What is a cookbook? and how is it used?

From Java

What is polymorphism, what is it for, and how is it used?

From Dev

is git submodules what I need?

From Dev

How to pull submodules in .gitmodule?

From Dev

How to use Submodules with EGit

From Dev

What is rake and how it is used in rails?

From Dev

What is OpenStack? And how can it be used?

From Dev

What is the proper way to split a python module into submodules?

From Dev

What are shadow registers in MIPS and how are they used?

From Dev

What is a parallel for loop, and how/when should it be used?

From Java

In Flask, What is request.args and how is it used?

From Dev

How to know what icon is being used in the dock?

From Dev

What are static methods? How and when are they used?

From Dev

What are AssemblyKeys used for, and how to import them?

From Dev

What exactly is txPower for Bluetooth LE and how is it used?

From Dev

What is stdin and how is it being used with fscanf?

From Dev

How to know what encryption is used by WebRTC connections?

From Dev

What is LoggingEventData ? How and where should it be used?

From Dev

What is Cometd ? Why it is used and how to work on that

From Dev

What is an AsyncTask (or AsyncResult) and how is it typically used for Android?

From Dev

How to check what the data type is being used?

From Dev

How to know what icon is being used in the dock?

From Dev

What is the value and how is the model parameter being used?

From Dev

What is the use of this public async method? how it is used?

From Dev

How to know what encryption is used by WebRTC connections?

From Dev

How to find out what modules are used in DNN?

From Dev

How to find what custom config is used by iptables?

From Dev

how the Main method is used and what it's purpose is?

Related Related

  1. 1

    What is decltype and how is it used?

  2. 2

    What is a cookbook? and how is it used?

  3. 3

    What is polymorphism, what is it for, and how is it used?

  4. 4

    is git submodules what I need?

  5. 5

    How to pull submodules in .gitmodule?

  6. 6

    How to use Submodules with EGit

  7. 7

    What is rake and how it is used in rails?

  8. 8

    What is OpenStack? And how can it be used?

  9. 9

    What is the proper way to split a python module into submodules?

  10. 10

    What are shadow registers in MIPS and how are they used?

  11. 11

    What is a parallel for loop, and how/when should it be used?

  12. 12

    In Flask, What is request.args and how is it used?

  13. 13

    How to know what icon is being used in the dock?

  14. 14

    What are static methods? How and when are they used?

  15. 15

    What are AssemblyKeys used for, and how to import them?

  16. 16

    What exactly is txPower for Bluetooth LE and how is it used?

  17. 17

    What is stdin and how is it being used with fscanf?

  18. 18

    How to know what encryption is used by WebRTC connections?

  19. 19

    What is LoggingEventData ? How and where should it be used?

  20. 20

    What is Cometd ? Why it is used and how to work on that

  21. 21

    What is an AsyncTask (or AsyncResult) and how is it typically used for Android?

  22. 22

    How to check what the data type is being used?

  23. 23

    How to know what icon is being used in the dock?

  24. 24

    What is the value and how is the model parameter being used?

  25. 25

    What is the use of this public async method? how it is used?

  26. 26

    How to know what encryption is used by WebRTC connections?

  27. 27

    How to find out what modules are used in DNN?

  28. 28

    How to find what custom config is used by iptables?

  29. 29

    how the Main method is used and what it's purpose is?

HotTag

Archive