PROGRAM ppbm
  IMPLICIT NONE
  INTEGER, PARAMETER :: M=512
  INTEGER :: a(M,M), i,j

  a=0
  a(:, ::7) = 1
  a(::15, :) = 1


  OPEN(17, file="grid.ppbm", status="replace", action="write")

  WRITE(17,"(A)") "P1"
  WRITE(17,"(I0,1X,I0)") M,M

  DO i=1,M
     DO j=1,M
        WRITE(17,"(I1)", advance="no") a(i,j)
        IF (MOD(j,70) == 0) WRITE(17,*)
     END DO
     WRITE(17,*)
  END DO
  
  CLOSE(17)
    
END PROGRAM ppbm
