Software Archive
Read-only legacy content

Modules - why?

Intel_C_Intel
Employee
419 Views
I've read the CVF documentation about Modules, including the advantages section. However, I'm still not sure about when to use them. Why use them over a .lib file for instance...? Am I missing something?
0 Kudos
1 Reply
Steven_L_Intel1
Employee
419 Views
Modules and .lib files are sort of apples and oranges. It's easier to think of modules as an improvement on INCLUDE files. A module allows you to have a self-consistent set of declarations, including constants, types, variables and routines, that is compiled separately. A USE statement makes the public declarations from the module available to your routine, and if you call module routines, the interfaces are checked (something you wouldn't get with just a .LIB file) You can restrict which names are visible from a module, select the names you want to import, and rename others. Modules can USE other modules, so you have nested inheritance.

There are many other advantages of modules - I suggest reading a good book on Fortran 90 to learn more.

Oh, by the way, .LIB files are a great place to put the object files created when you compile a module.

Steve
0 Kudos
Reply