   PROGRAM Main

   REAL,    DIMENSION(3, 3) :: A
   LOGICAL, DIMENSION(3, 3) :: MASK
   REAL,    DIMENSION(4)    :: B

   DATA A / 1, 2, 3, 4, 5, 6, 7, 8, 9 /
   DATA MASK /  .true., .true., .false., &
		.false., .false., .false., &
		.false., .true., .true. /

   print *, "Matrix A: "
   DO i = 1, SIZE(A, 1) 
     print *, A(i, :)
   END DO
   print *

   print *, "Matrix MASK: "
   DO i = 1, SIZE(MASK, 1) 
     print *, MASK(i, :)
   END DO
   print *

   B = PACK(A, MASK)

   print *, "B = PACK(A, MASK, B)"
   print *, B

   print *

   END

