

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Math 248 LABORATORY ASSIGNMENT Run-time Memory Allocation and Array Processing in Fortran 90 (Pruett)
C = A + B
to C = A ∗ B Describe the outcome of this modification. Is this operation the same as a dot product?
PROGRAM arrays_1d ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! Trivial program to demonstrate 1) run-time memory ! allocation, and 2) "broadcasting" initialization of ! 1D arrays (vectors) ! ! AUTHOR: Dr. D. Pruett, JMU Math ! CREDITS: None ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! IMPLICIT NONE INTEGER :: i,n ! ! Vector is declared to be a 1D array, but its dimension ! is left ambiguous at compile time ! REAL, DIMENSION(:), ALLOCATABLE :: Vector
WRITE (,) ’ Enter array length, n ’ READ (,) n ! ! allocate memory for array Vector ! ALLOCATE (Vector(1:n))! size of Vector is established at run time ! ! initialize array Vector ! Vector = 2.1! by "broadcasting" ! ! output array Vector by index ! DO i = 1,n WRITE (,) i, Vector(i) END DO ! ! return allocated memory to the memory pool ! DEALLOCATE (Vector)! be a good citizen; "thanks for the memories"
END PROGRAM arrays_1d