In this exercise we declare simple arrays, perform an operation on them, and then declare that operation as a function in a separate file.

The basic function performs a dot product on vectors with two integer components:

Write that to dotProduct.f90 and compile and run it.

You are prompted to enter two vectors by component, and then given the dot product of the two vectors. Check that the answer is right!

Now we will do the same thing, but with dotProduct inside a function in a separate file. Call our first file calcDotProduct.f90:

Call this next file, the one where we are moving the function, dotProductFunc.f90:

Now compile them together, then run it.

It should behave the same as before.

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