Reputation: 57
In case of developing a static lib using fortran:
The lib is consist of multiple modules, e.g. "module a", "module b" etc..
Each of the modules has public variables, types and procedures.
Now, want to use the lib in program "test".
One possible method is to use each of the modules, and providing the *.a lib file during linking. e.g.:
program test
use a
use b
...
end program
But it would be better if only one module/*.h needs to be used/included. e.g.:
program test
use all
...
end program
One possible solution is to copy all public variables, types and interface of procedures into "module all", and use "module all" instead of the individual modules.
But if any of the individual module is modified, "module all" also needs to be modified to meet the change.
Is there a more appropriate method to work around, or is there an automatic tool to generate the "module all"?
Thank you very much for any input.
Upvotes: 1
Views: 380
Reputation: 57
It seems that the ultimate solution is to use submodule
, which unfortunately has not been supported by gcc.
See: http://fortranwiki.org/fortran/show/Submodules
Upvotes: 2
Reputation: 29391
I wouldn't copy code from the individual modules into module "all", because, as you say, that leads to extra work when code is changed. And possibility of error. Instead, "use" those modules in module "all". Then when you want them all you "use module all". When you want a particular module you use that one. What you have to guard against because it is forbidden is circular module references: A uses B uses C uses A is not allowed.
Upvotes: 3