Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROGRAM Matrizen1
- IMPLICIT NONE ! allow no implicit types
- ! constant integers
- INTEGER, PARAMETER :: Ni = 3, Nj = 4, Nk = 5, MAXR = 4
- ! arrays of float64 value, initialized to zero
- DOUBLE PRECISION :: A(Ni, Nk, Nj) = 0, B(Ni, Nj) = 0, C(Ni, Nk) = 0
- ! loop counters
- INTEGER :: i, j, k
- ! fill in random numbers in interval [0, 1]
- CALL RANDOM_NUMBER(A)
- CALL RANDOM_NUMBER(B)
- ! make random integers in interval [0, MAXR]
- A = FLOOR(A * MAXR)
- B = FLOOR(B * MAXR)
- ! NOTE: array index starts from 1
- DO i = 1, Ni
- DO j = 1, Nj
- DO k = 1, Nk
- C(i, k) = A(i, j, k) * B(i, j)
- PRINT '(A2,I1,A1,I1, A1, I0, A4,F0.3)', 'A[', i, ',', j, ',', k, '] = ', A(i, j, k)
- PRINT '(A2,I1,A1,I1,A4,F6.3)', 'B[', i, ',', j, '] = ', B(i, k)
- PRINT '(A2,I1,A1,I1,A4,F6.3)', 'C[', i, ',', k, '] = ', C(i, k)
- PRINT *
- END DO
- END DO
- END DO
- END PROGRAM Matrizen1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement