home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / adaptor / examples / dalib / move / move2.f next >
Encoding:
Text File  |  1993-03-23  |  1.6 KB  |  77 lines

  1.       program move2
  2. c
  3. c     moving two dimensional sections
  4. c
  5.       real a(10,10), ha(10,10), ha1(10,10)
  6. cmf$  layout ha(:host), ha1(:host)
  7.  
  8.       real b(10), hb(10), hb1(10)
  9. cmf$  layout hb(:host), hb1(:host)
  10.  
  11.       integer i, j, k, errors, switch
  12.  
  13.       call cmf_random (a)
  14.       call cmf_random (b)
  15.  
  16.       ha = a
  17.       hb = b
  18.  
  19.       print *, 'Initialisation is ready'
  20.       print *, 'Chosse switch (1-4) : '
  21.       read  *, switch
  22.  
  23. c     now operate on distributed arrays, make the same with host
  24.  
  25.       if (switch .eq. 1) then
  26.          print * , 'many -> many'
  27.          a(2,5:8) = b(3:6)
  28.          ha(2,5:8) = hb(3:6)
  29.       end if
  30. c
  31.       if (switch .eq. 2) then
  32.          print *, 'one -> many b(2:10) = a(1:9,4)'
  33.          b(2:10) = a(1:9,4)
  34.          hb(2:10) = ha(1:9,4)
  35.       end if
  36. c
  37.       if (switch .eq. 3) then
  38.          print *, 'many -> one'
  39.          a(3:8,5) = b(1:6)
  40.          ha(3:8,5) = hb(1:6)
  41.       end if
  42. c
  43.       if (switch .eq. 4) then
  44.          print *, 'one -> one'
  45.          a(8,9) = a(9,3)
  46.          ha(8,9) = ha(9,3)
  47.          b(1) = a(7,4)
  48.          hb(1) = ha(7,4)
  49.       end if
  50.  
  51. c     now compare distributed arrays with host arrays
  52.  
  53.       print *,'Operations are finished'
  54.  
  55.       ha1 = a
  56.       hb1 = b
  57. c
  58. c     ha1 == ha ?,  hb1 == b ?
  59.  
  60.       print *,'Now checking'
  61.  
  62.       errors = 0
  63.       do j = 1, 10
  64.         do i = 1, 10
  65.           if (ha(i,j) .ne. ha1(i,j)) then
  66.              errors = errors + 1
  67.           end if
  68.         end do
  69.         if (hb(j) .ne. hb1(j)) then
  70.              errors = errors + 1
  71.         end if
  72.       end do
  73.  
  74.       print *, 'Errors = ', errors
  75.  
  76.       end
  77.