home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adaptor.zip / adapt.zip / adaptor / examples / dalib / move / move4.f < prev    next >
Text File  |  1993-03-23  |  3KB  |  119 lines

  1.       program move4
  2.  
  3.       real a(6,6,6,6), ha(6,6,6,6), ha1(6,6,6,6)
  4. cmf$  layout ha(:host), ha1(:host)
  5.  
  6.       real b(10,10), hb(10,10), hb1(10,10)
  7. cmf$  layout hb(:host), hb1(:host)
  8.  
  9.       integer i, j, k, errors, switch
  10.  
  11.       call cmf_random (a)
  12.       call cmf_random (b)
  13.  
  14.       ha = a
  15.       hb = b
  16.  
  17.       print *, 'Initialisation is ready'
  18.       print *, 'Chosse switch (1-6) : '
  19.       read  *, switch
  20.  
  21. c     now operate on distributed arrays, make the same with host
  22.  
  23.       if (switch .eq. 1) then
  24.          print * , 'one -> one'
  25.          b(3:6,4) = a(1,2:5,5,3)
  26.          hb(3:6,4) = ha(1,2:5,5,3)
  27.       end if
  28. c
  29.       if (switch .eq. 2) then
  30.          print * , 'many -> many'
  31.          b(2:5,2:5) = a(3:6,4,1,3:6)
  32.          hb(2:5,2:5) = ha(3:6,4,1,3:6)
  33.       end if
  34.  
  35.       if (switch .eq. 3) then
  36.          print *, 'many -> one'
  37.          a(1:4,3,2,5) = b(4,6:9)
  38.          ha(1:4,3,2,5) = hb(4,6:9)
  39.          a(3,1:6,2,6) = b(4,5:10)
  40.          ha(3,1:6,2,6) = hb(4,5:10)
  41.          a(3,6,2:5,1) = b(4,1:4)
  42.          ha(3,6,2:5,1) = hb(4,1:4)
  43.       end if
  44.  
  45.       if (switch .eq. 31) then
  46.          print *, 'many -> one'
  47.          a(1:4,3,2,5) = b(4,6:9)
  48.          ha(1:4,3,2,5) = hb(4,6:9)
  49.       end if
  50.  
  51.       if (switch .eq. 32) then
  52.          print *, 'many -> one'
  53.          a(3,1:6,2,6) = b(4,5:10)
  54.          ha(3,1:6,2,6) = hb(4,5:10)
  55.       end if
  56.  
  57.       if (switch .eq. 33) then
  58.          print *, 'many -> one'
  59.          a(3,6,2:5,1) = b(4,1:4)
  60.          ha(3,6,2:5,1) = hb(4,1:4)
  61.       end if
  62.  
  63.       if (switch .eq. 4) then
  64.          print *, 'one -> many'
  65.          b(5:9,2:6) = a(2:6,1:5,4,4)
  66.          hb(5:9,2:6) = ha(2:6,1:5,4,4)
  67.       end if
  68.  
  69.       if (switch .eq. 5) then
  70.          print *, 'shifting in dim1'
  71.          a(2:5,2:5,2:5,1:4) = a(2:5,2:5,2:5,3:6)
  72.          ha(2:5,2:5,2:5,1:4) = ha(2:5,2:5,2:5,3:6)
  73.       end if
  74.  
  75.       if (switch .eq. 6) then
  76.          print *, 'shifting in dim1 + dim2'
  77.          a(2:5,2:5,1:4,1:4) = a(2:5,2:5,3:6,2:5)
  78.          ha(2:5,2:5,1:4,1:4) = ha(2:5,2:5,3:6,2:5)
  79.       end if
  80.  
  81. c     now compare distributed arrays with host arrays
  82.  
  83.       print *,'Operations are finished'
  84.  
  85.       ha1 = a
  86.       hb1 = b
  87. c
  88. c     ha1 == ha ?,  hb1 == b ?
  89.  
  90.       print *,'Now checking'
  91.  
  92.       errors = 0
  93.  
  94.       do j = 1, 10
  95.          do i = 1, 10
  96.          if (hb(i,j) .ne. hb1(i,j)) then
  97.               print *, 'HB for i, j = ', i, j
  98.               errors = errors + 1
  99.          end if
  100.          end do
  101.       end do
  102.  
  103.       do l = 1, 6
  104.        do k = 1, 6
  105.         do j = 1, 6
  106.          do i = 1, 6
  107.            if (ha(i,j,k,l) .ne. ha1(i,j,k,l)) then
  108.               print *, 'HA for i, j, k, l = ', i, j, k, l
  109.               errors = errors + 1
  110.            end if
  111.          end do
  112.         end do
  113.        end do
  114.       end do
  115.  
  116.       print *, 'Errors = ', errors
  117.  
  118.       end
  119.