I believe that you can do this with submodules using Fortran 2008 compilers. Material from FortranWiki:
Submodules are a function of Fortran 2008 that allows a modular procedure to have its own interface defined in a module, having the body of a procedure defined in a separate module, a submodule.
From Wikipedia (highlighted by me)
[Submodules allow] the specification and implementation of the module, which should be expressed in separate program units, which improves the packaging of large libraries, allows you to keep trade secrets when publishing the final interfaces and prevents compilation cascades.
I have no experience with submodules, and they have not yet become widespread, but they should know.
Change Since many compilers do not support submodules, it is probably useful to discuss other options.
This page asks a similar question and has some good links. Especially useful when discussing Google groups (see, in particular, this post ). Thus, one of the options:
Group all library functions / routines in a single file and on their own (i.e. not being part of a module).
Create a module that contains only interfaces for the routines that you want to provide to the end user.
Provide the compiled module and library to end users. The user can then use
module in their programs and contact the library.
This allows you to βhideβ functions / routines that you do not want to provide to the end user.
Sent from a post, I refer to:
Some compilers generate a .mod file (or any other name provided to it by the compiler) and a library file. The .mod file has characters; the library file contains executable code included in the module. In this case, you should distribute both files to your end users.
In addition, some compilers (particularly f95) put characters and executable code into a single .mod file. In this case, you only need to provide the .mod file for your end users.
(final!) edit The Fedora wiki has a useful page :
Ideally, Fortran portable libraries will avoid using modules. The good news is that the Sub-module specification has been defined, which will allow part of the module interface specification to be separated from the source code of the procedure. In [c] e, this is implemented in Fortran compilers, it should be used by all packaged libraries.