c cdimtest.f c c

      program dimtest
c
c     test the DIM optional argument for Fortran 90
c     intrinsic function  sum, minval, maxval
c
c      John Mahaffy 3/31/96
c
       real a(4,3), asum1(3), asum2(4), amx1(3), amx2(4),
     $      amn1(3), amn2(4), cshft1(4,3), cshft2(4,3)
       integer ish1(3), ish2(4)
c 
      data a/1,2,3,4,1,2,3,4,5,6,7,8/, ish1/3*-2/,
c 
     $ ish2/4*-1/
c    
      asum1 = sum(a, dim=1)
      asum2 = sum (a, dim=2)
c     
c     
      amx1 = maxval(a, dim=1)
      amx2 = maxval( a, dim=2)
c     
c     
      amn1 = minval ( a, dim=1)
      amn2 = minval( a, dim=2)
c     
c     
      cshft1 = cshift(a,shift=ish1,dim=1)
      cshft2 = cshift(a,shift=ish2, dim=2)
c     
      write(*,*) ' a = '
      do i=1,4
         write( *, 2000) (a(i,j),j=1,3)
      enddo
      write(*,"(/, 'Sum along the first dimension = ')")
      write(*,2000) asum1
      write(*,"(/, 'Sum along the second dimension = ')")
      write(*,2000) asum2
      write(*,"(/, 'Maximum along the first dimension = ')")
      write(*,2000) amx1
      write(*,"(/, 'Maximum along the second dimension = ')")
      write(*,2000) amx2
      write(*,"(/, 'Minimum along the first dimension = ')")
      write(*,2000) amn1
      write(*,"(/, 'Minimum along the second dimension = ')")
      write(*,2000) amn2
      write(*,"(/, 'Circular Shift up 2 along the 1st dimension = ')")
      write(*,2000) cshft1
      write(*,"(/, 'Circular shift up 1 along the 2nd dimension = ')")
      write(*,2000) cshft2
 2000 format(4x,4f8.1)
      stop
      end
c
c c