home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adaptor.zip / adapt.zip / adaptor / examples / dalib / transp / transps.f < prev   
Text File  |  1993-06-15  |  1KB  |  61 lines

  1.       program transtest
  2.  
  3.       parameter (N=250, M=200)
  4.  
  5.       real A(N,M), SA(N,M), B(M,N)
  6.       logical ERRS(N,M)
  7.       integer errors, number
  8.  
  9.       forall (j=1:M, i=1:N)
  10.         A(i,j) = 100*i + j
  11.       end forall
  12.  
  13.       print *, 'input number of iterations : '
  14.       read *, number
  15.  
  16.       SA = A + number         ! save values of A
  17.  
  18.       ! transpose A to B
  19.  
  20.       call cm_timer_clear (0)
  21.       call cm_timer_start (0)
  22.  
  23.       do k = 1, number
  24.  
  25. c        B = transpose (A)
  26.          forall (j=1:M, i=1:N)
  27.             B(j,i) = A(i,j)
  28.          end forall
  29.    
  30.          ! add 1 to all elements of B
  31.  
  32.          B = B + 1
  33.  
  34. c        A = transpose (B)
  35.          forall (j=1:M, i=1:N)
  36.             A(i,j) = B(j,i)
  37.          end forall
  38.  
  39.       end do
  40.  
  41.       call cm_timer_stop (0)
  42.  
  43.       ! compare against SA
  44.  
  45.       ERRS = (A .ne. SA)
  46.       errors = count (ERRS)
  47.  
  48.       print *, 'Errors = ', errors
  49.  
  50.       if (errors .gt. 0) then
  51.          do i = 1, N
  52.             do j = 1, M
  53.                print *, I, J, A(I,J), SA(I,J), B(J,I)
  54.             end do
  55.          end do
  56.       end if
  57.  
  58.       print *, number, ' * 2 transpose of size ',N,' x ',M,' needs : '
  59.       call cm_timer_print (0)
  60.       end
  61.