GitLab maintenance scheduled form Friday, 2021-06-18 5:00pm to Satursday, 2021-06-19 10:00pm CT - Services will be unavailable during this time.

simple_array.f90 916 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
! http://www.mcs.anl.gov/research/projects/mpi/usingmpi2/examples/starting/io3f_f90.htm
PROGRAM main 
  use mpi
  
  integer ierr, i, myrank, BUFSIZE, filehandle 
  character(*), parameter :: filepath = "/projects/visualization/ftessier/debug/"
  parameter (BUFSIZE=100) 
  integer buf(BUFSIZE) 
  integer(kind=MPI_OFFSET_KIND) disp 
  
  call MPI_INIT(ierr) 
  call MPI_COMM_RANK(MPI_COMM_WORLD, myrank, ierr) 
  
  do i = 0, BUFSIZE 
     buf(i) = myrank * BUFSIZE + i 
  enddo
  ! filepath//"f90_HACC.dat"
  call MPI_FILE_OPEN(MPI_COMM_WORLD, "f90HACC", & 
       MPI_MODE_WRONLY + MPI_MODE_CREATE, & 
       MPI_INFO_NULL, filehandle, ierr) 

  disp = myrank * BUFSIZE * 4 

  call MPI_FILE_WRITE_AT(filehandle, disp, buf, BUFSIZE, MPI_INTEGER, & 
       MPI_STATUS_IGNORE, ierr) 

  call MPI_BARRIER(MPI_COMM_WORLD, ierr)

  call MPI_FILE_CLOSE(filehandle, ierr) 
  call MPI_FINALIZE(ierr) 
  
END PROGRAM main