Exercise: Modules and Functions
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:
©
2025
|
Cornell University
|
Center for Advanced Computing
|
Copyright Statement
|
Access Statement
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)
CVW material development is supported by NSF OAC awards 1854828, 2321040, 2323116 (UT Austin) and 2005506 (Indiana University)