program ccm_scatter_x2
use ccm
implicit none
real :: i40(40),i3d(5,4,2),got(8)
real,allocatable :: rs(:,:)
integer:: order(3),new_shape(3)
integer:: myid,numprocs,i,j,k
do i=1,40
i40(i)=i
enddo
i3d=reshape(i40,shape(i3d))
call ccm_init(myid,numprocs)
if(myid .eq. 0)then
write(*,*)"3d array of bounds ",shape(i3d)
do k=1,2
write(*,*)"plane ",k
do i=1,5
write(*,"(4f5.0)")(i3d(i,j,k),j=1,4)
enddo
enddo
endif
!
call ccm_barrier(0.95,.true.)
allocate(rs(2,5))
order=(/1,2,3/)
new_shape=(/5,4,2/)
call ccm_scatter(reshape(i3d,shape=new_shape,order=order),rs)
if(myid .eq. 0)write(*,"(/3i3,5x,3i3)")order,new_shape
do i=1,2
if(i.eq. 1)then
write(*,"(i4,(5f5.0))")myid,(rs(i,j),j=1,5)
else
write(*,"(4x,(5f5.0))")(rs(i,j),j=1,5)
endif
enddo
deallocate(rs)
call ccm_barrier(0.95,.true.)
allocate(rs(10,1))
order=(/3,1,2/)
new_shape=(/2,5,4/)
call ccm_scatter(reshape(i3d,shape=new_shape,order=order),rs)
if(myid .eq. 0)write(*,"(/3i3,5x,3i3)")order,new_shape
write(*,"(i4,(10f5.0))")myid,(rs(i,1),i=1,10)
call ccm_barrier(0.95,.true.)
order=(/3,1,2/)
new_shape=(/5,4,2/)
call ccm_scatter(reshape(i3d,shape=new_shape,order=order),rs)
if(myid .eq. 0)write(*,"(/3i3,5x,3i3)")order,new_shape
write(*,"(i4,(10f5.0))")myid,(rs(i,1),i=1,10)
deallocate(rs)
call ccm_barrier(0.95,.true.)
allocate(rs(5,2))
order=(/2,3,1/)
new_shape=(/5,4,2/)
call ccm_scatter(reshape(i3d,shape=new_shape,order=order),rs)
if(myid .eq. 0)write(*,"(/3i3,5x,3i3)")order,new_shape
do j=1,2
if(j.eq. 1)then
write(*,"(i4,(5f5.0))")myid,(rs(i,j),i=1,5)
else
write(*,"(4x,(5f5.0))")(rs(i,j),i=1,5)
endif
enddo
call ccm_barrier(0.95,.true.)
deallocate(rs)
allocate(rs(5,2))
order=(/2,1,3/)
new_shape=(/5,4,2/)
call ccm_scatter(reshape(i3d,shape=new_shape,order=order),rs)
if(myid .eq. 0)write(*,"(/3i3,5x,3i3)")order,new_shape
do j=1,2
if(j.eq. 1)then
write(*,"(i4,(5f5.0))")myid,(rs(i,j),i=1,5)
else
write(*,"(4x,(5f5.0))")(rs(i,j),i=1,5)
endif
enddo
deallocate(rs)
call ccm_close()
end program
|