We will now include our dotProduct function in a module. Create the file dotProductModule.f90:

Now compile the module (with the -c switch so as not to generate an executable but rather an object for linking):

Check that dotProductModule.o and dotproduct_module.mod have been created (note, the capital P is converted to lowercase in the .mod file name). Now, create dotProductFromMod.f90 and edit it to contain this:

As indicated, the correct position of the use statement is immediately after the program dotProductFromMod line, prior to all the variable declarations (and even the implicit none line). Now we can compile and link, and then run:

 
©  |   Cornell University    |   Center for Advanced Computing    |   Copyright Statement    |   Access Statement