Re: forall and do loop



"highegg" <highegg@xxxxxxxxx> wrote in message
news:1185545688.715089.193180@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

! transpose 2D array of vectors
forall(i=1:size(a,2),j=1:size(a,3)) a(:,i,j) = a(:,j,i)

C:\Program Files\Microsoft Visual Studio 8\James\clf\transpose_2>type
transpose_
2.f90
program transpose_2
integer a(2,2,2), b(2,2,2)
integer i, j

b = reshape((/(i,i=1,size(b))/),shape(b))
a = b
forall(i=1:size(a,2),j=1:size(a,3)) a(:,i,j) = a(:,j,i)
write(*,*) a
a = b
a = reshape(a,shape(a),order=(/1,3,2/))
write(*,*) a
end program transpose_2

C:\Program Files\Microsoft Visual Studio 8\James\clf\transpose_2>ifort /O3
/QxT
/stand:f95 transpose_2.f90
Intel(R) Fortran Compiler for Intel(R) EM64T-based applications, Version 9.1
Build 20061104
Copyright (C) 1985-2006 Intel Corporation. All rights reserved.

C:\Program Files\Microsoft Visual Studio
8\James\clf\transpose_2\transpose_2.f90
(5) : (col. 4) remark: LOOP WAS VECTORIZED.
C:\Program Files\Microsoft Visual Studio
8\James\clf\transpose_2\transpose_2.f90
(5) : (col. 4) remark: LOOP WAS VECTORIZED.
C:\Program Files\Microsoft Visual Studio
8\James\clf\transpose_2\transpose_2.f90
(6) : (col. 4) remark: LOOP WAS VECTORIZED.
C:\Program Files\Microsoft Visual Studio
8\James\clf\transpose_2\transpose_2.f90
(9) : (col. 4) remark: LOOP WAS VECTORIZED.
C:\Program Files\Microsoft Visual Studio
8\James\clf\transpose_2\transpose_2.f90
(10) : (col. 4) remark: LOOP WAS VECTORIZED.
Microsoft (R) Incremental Linker Version 8.00.40310.39
Copyright (C) Microsoft Corporation. All rights reserved.

-out:transpose_2.exe
-subsystem:console
transpose_2.obj

C:\Program Files\Microsoft Visual Studio 8\James\clf\transpose_2>transpose_2
1 2 5 6 3 4
7 8
1 2 5 6 3 4
7 8

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


.