Ticket #700: test14.f90

File test14.f90, 1.2 KB (added by Ian Culverwell, 3 years ago)

test14.f90

Line 
1! prog=test14
2! compilers="ifort17"
3! compilers="gfortran ifort17 ifort16 nagfor61 pgf95 g95"
4! for compiler in $(echo $compilers) ; do
5! echo $compiler -o ${prog}.exe ${prog}.f90
6! $compiler -o ${prog}.exe ${prog}.f90
7! echo ${prog}.exe
8! ./${prog}.exe
9! echo ""
10! done
11!
12PROGRAM test14
13!
14! Purpose: To emulate mis-dimensioned K array, as seen in ROPP-11.
15!
16
17 IMPLICIT NONE
18
19 INTEGER, PARAMETER :: wp=KIND(1.D0)
20 INTEGER, PARAMETER :: m=3, n=2
21 REAL(wp), DIMENSION(:,:), ALLOCATABLE :: K1, K2
22
23! -------------------------------------------------------------------------
24
25 ALLOCATE( K1(n, m), K2(m, n))
26
27 print*,'SHAPE(K1) = ', SHAPE(K1)
28 print*,'SHAPE(K2) = ', SHAPE(K2)
29
30 K1(1, :) = (/ 1.0_wp, 2.0_wp, 3.0_wp /)
31 K1(2, :) = (/ 4.0_wp, 5.0_wp, 6.0_wp /)
32
33 print*,'K1 = ', K1
34
35 K2 = K1 ! Let's see if this works
36
37 print*,'SHAPE(K2) = ', SHAPE(K2) ! redefined
38 print*,'K2 = ', K2
39
40 print*,'SHAPE( MATMUL(K1, TRANSPOSE(K2)) ) = ', &
41 SHAPE( MATMUL(K1, TRANSPOSE(K2)) )! not defined if Ks keep their original shapes
42
43 print*, 'MATMUL(K1, TRANSPOSE(K2)) = ', MATMUL(K1, TRANSPOSE(K2))
44
45 DEALLOCATE (K2, K1)
46
47END PROGRAM test14