PROGRAM mpi2io USE MPI IMPLICIT none INTEGER :: myrank, nproc,ierr; INTEGER, PARAMETER :: dim_buf = 10 INTEGER :: buf(dim_buf) INTEGER :: i, intsize; INTEGER(KIND=MPI_OFFSET_KIND) :: offset, file_size INTEGER :: fh INTEGER :: status(MPI_STATUS_SIZE) INTEGER :: filetype CALL MPI_Init(ierr); CALL MPI_Comm_size(MPI_COMM_WORLD,nproc,ierr) CALL MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr) DO i=1,dim_buf buf(i) = myrank*dim_buf+i-1; END DO ! Open the file and write by using individual file pointers: ! - use MPI_File_open to access the file "output.dat"; which access mode? ! - use MPI_File_write for storing data, but first call function MPI_File_seek ! - to define 'offset'; on what values is it depending on? ! - Hint: the function MPI_Type_size may be used to get the data type size ! - do not forget of calling MPI_File_close at the end --- ! Re-open the file and read by using explicit offset: ! - use MPI_File_open to access "output.dat" for reading; which access mode? --- !- use the function MPI_File_get_size to obtain 'file_size' */ --- offset = file_size/nproc*myrank write(6,*) "myid ",myrank,"filesize ", file_size, "offset ", offset ! - use the function MPI_File_read_at for reading ! - do not forget to close the file at the end */ --- ! Write the new file using the mpi_type_create_vector. Use the fileview: ! - now every process has a copy of 'buf' ! - use MPI_File_open to access "output_mod.dat" with the proper access mode ! - and use the right function for defining the new data type with handle 'filetype' --- ! - the function MPI_File_write_all could be used to store data appropriately, ! - but the function MPI_File_set_view must first be called to use 'filetype' ! - How will 'offset' be defined ? ! - the function MPI_File_get_size may be useed to obtain file_size --- write(6,*) "myid ", myrank, "filesize of the second file written", file_size, "offset", offset CALL MPI_Type_free(filetype,ierr) CALL MPI_File_close(fh,ierr) CALL MPI_Finalize(ierr) END PROGRAM mpi2io