      program transtest

      parameter (N=250, M=200)

      real A(N,M), SA(N,M), B(M,N)
      logical ERRS(N,M)
      integer errors, number

      forall (j=1:M, i=1:N)
        A(i,j) = 100*i + j
      end forall

      print *, 'input number of iterations : '
      read *, number

      SA = A + number         ! save values of A

      ! transpose A to B

      call cm_timer_clear (0)
      call cm_timer_start (0)

      do k = 1, number

c        B = transpose (A)
         forall (j=1:M, i=1:N)
            B(j,i) = A(i,j)
         end forall
   
         ! add 1 to all elements of B

         B = B + 1

c        A = transpose (B)
         forall (j=1:M, i=1:N)
            A(i,j) = B(j,i)
         end forall

      end do

      call cm_timer_stop (0)

      ! compare against SA

      ERRS = (A .ne. SA)
      errors = count (ERRS)

      print *, 'Errors = ', errors

      if (errors .gt. 0) then
         do i = 1, N
            do j = 1, M
               print *, I, J, A(I,J), SA(I,J), B(J,I)
            end do
         end do
      end if

      print *, number, ' * 2 transpose of size ',N,' x ',M,' needs : '
      call cm_timer_print (0)
      end
