PROGRAM posix_io

  IMPLICIT NONE
  INCLUDE 'mpif.h'

  INTEGER :: i, myid, nproc, bufsize, ierr
  INTEGER, ALLOCATABLE :: buf(:), writebuf(:)
  INTEGER :: fp, intsize
  INTEGER(KIND=MPI_OFFSET_KIND) :: disp

  CALL MPI_INIT(ierr)
  CALL MPI_COMM_RANK(MPI_COMM_WORLD, myid, ierr);
  CALL MPI_COMM_SIZE(MPI_COMM_WORLD, nproc, ierr);

  bufsize = 100 / nproc;
  IF (bufsize *nproc /= 100 ) STOP 'Wrong number of processes' 

  ALLOCATE(buf(bufsize))

  buf(:) = (/ (myid*bufsize + i, i=0,bufsize-1) /)

! Begin TODO
! Open a file, and write buf by all processes
! Write also a version where the data is read from the file
  
  CALL MPI_TYPE_SIZE(MPI_INTEGER, intsize, ierr)
  disp = 

  CALL MPI_FILE_CLOSE(fp, ierr)

! End TODO

  CALL MPI_FINALIZE(ierr)

END PROGRAM
