-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mod file completeness #84
Comments
The standard has nothing to say about module files, not even their existence. Is it possible to always "flatten" modules in Fortran into single modules, even in the presence of renaming? |
The problem here is that when you have large, nested modules the module files become enormous and slow down compilation. DEC Fortran started with making each .mod file self-contained, but the impact on build times was intolerable, so it shifted to opening each .mod as needed. For library developers what you usually need to do is separate public and private interfaces and definitions. Submodules can help. As for distributing in binary form, this simply does not work as each compiler has its own binary format and its own API into the support library. |
Why is one combined module file bigger/slower than the combined size of the transitive closure of the module files that it uses? |
This is outside the purview of the current standard. Before something like this can even be considered, a clear vision and scope would need to be developed toward which all aspects of implementation details should be covered by the standard. That is a monumentally difficult thing to pursue. |
@sblionel Thanks a lot. Yes, exactly, I would wish for a good support for exposing only interfaces which are meant to be public. If I think about submodules, then the entire library would have to be a single module (containing the public API of the library) with several sub- and sub-sub-modules containing the actual implementation details. Is this the way you suggest? |
Submodules do not scale in my opinion to large libraries, as explained in #86. The issue #86 was one of the first issues that I had when I joined the committee, but I only created an actual GitHub issue for it now. I got reminded of it, since this issue #84 is very similar to #86. |
Yes, nested modules are a nice idea, I fully support it (see my comment there). But, it still does not solve the problem, that you may need to expose the internal structure of your library (in form of having to provide the mod-files for all modules in it), when it should be imported by a program. In C / C++, you would only install the include file for the public API, which I find much cleaner. But in terms of costs, maybe this proposal would not be worth the effort, indeed. So let's concentrate on nested modules (#86) instead. |
I would support this effort for fortran. A big problem with fortran libraries is the requirement of shipping together the compiled Using compiler |
@zerothi Unfortunately, this proposal would not solve the issue you raised. Since the Fortran libraries compiled with various compilers are not ABI compatible, it still remains, that all modern Fortran libraries your project depends on must be compiled with the same compiler. |
Exactly. :) In addition to what you have here it would be ideal if the module files are not binary files, or at least ensures that different compilers can inspect the interfaces/derived types in a non-compiler specific format. |
The format of module files is not within the purview of the standard. (f18 uses a module file format that any other Fortran compiler could inspect, though; maybe that will help you someday.) |
But why could it not be part of the standard? ;) |
I would find it useful, if the standard required mod-files to be complete / self-contained. Given a library consisting of several modules and a wrapper module exposing the public API
the standard should enforce, that the mod-file generated for the module
library_api
should contain all information necessary to import the module (viause library_api
) in any application.Currently, there is at least one compiler I know (NAG), where
use library_api
requires not just the presence oflibrary_api.mod
, but also all the modfiles for the modules imported bylibrary_api
directly or indirectly. This is annoying, if you want to distribute the library in binary form, and it also unnecessarily exposes the internal structure of the library (and enables the consumer to basically import any module of the library directly and call routines from it).The text was updated successfully, but these errors were encountered: