Module question

Module question

I am using CVF 6.6B and struggling to port a program from a UNIX environment. The program comes as a main program with numerous subprogram units. On comment lines at the top of each subprogram the coder has a module name, then lists public & private subroutines, and other modules using it.

To make these subprograms into actual modules, I have done the following:

Module BinFile
Public :: Binopn
Subroutine Binopn (a)
End Subroutine Binopn
End Module BinFile

I have gone to the main file and put in the use statement:

Program Engineer
Use Binfile
Call Executable program
End Program Engineer

When I compile the program it gives me many LNK 2001 errors (unresolved external). The unresolved subroutine comes from another subprogram object file that has a call to the Module Binfile.

I did the foregoing based on the example presented in section 8.2 Modules & Modules Procedures in the Language Manual.

I would appreciate any suggestion to resolve this problem.



4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I'm not sure I get exactly what you have done, but I can tell you that you need the "use BinFile" in any program unit that calls routines in the BinFile module. If you don't do this, you'll get LNK2001 for the calls, as the compiler thinks you're calling some external routine rather than the module procedure.


Retired 12/31/2016

i think he added use statement...
I have similar problem, UNIX fortran source code trying to migrate to w2K.
Source has main program (1st file) and a subroutine (2nd file). The main program doesn't have any use or similar statements. I'm wondering how to call that subroutine as some kind of external sub.
please, if you know something, e-mail to

I'm not sure, but I get the feeling, that Jerald and "dvulin" have the idea that modules are required for subroutines. Maybe I'm wrong with this feeling, but I tell this as warning for needless difficult programs.
A program with subroutines in UNIX, whether they are in one file or not, can be used on the same way in CVF. There is no special requirement to make a module from a subroutine or function.
When you make a module from a subroutine or function you must be aware of the fact that a change in a subroutine (and thus in the module) causes recompilation of all routines that contains a use statement for that module.
I use modules in general for specification of data used in various subroutines (like COMMON) and for module procedures and operator overloading.
I put the subroutines and functions in separate files (NOT modules!) to be protected against needless compilation.


Leave a Comment

Please sign in to add a comment. Not a member? Join today