Unformatted Fortran output with each MPI process writing part of an array

In my parallel program there was a big matrix. Each process is calculated and its part is saved. The program then wrote the matrix to a file, allowing each process to write its own part of the matrix in the correct order. The output file is in "unformatted" form. But when I tried to read the file in sequential code (I have selected the correct size of the large matrix), I received an error that I do not understand.

My question is: how do you get a binary file in MPI as the output of a serial version for a large matrix that is stored by various processes?

Here is my attempt:

    if(ThisProcs == RootProcs) then
        open(unit = file_restart%unit, file = file_restart%file, form = 'unformatted')
        write(file_restart%unit)psi
        close(file_restart%unit)
    endif
#ifdef USEMPI
    call mpi_barrier(mpi_comm_world,MPIerr)
#endif
    do i = 1, NProcs - 1
        if(ThisProcs == i) then
            open(unit = file_restart%unit, file = file_restart%file, form = 'unformatted', status = 'old', position = 'append')
            write(file_restart%unit)psi
            close(file_restart%unit)
        endif
#ifdef USEMPI
        call mpi_barrier(mpi_comm_world,MPIerr)
#endif
    enddo

Psi is a large matrix, it stands out as:

Psi(N_lattice_points, NPsiStart:NPsiEnd)

But when I tried to load the file into serial code:

open(2,file=File1,form="unformatted")
read(2)psi

forrtl: severe (67): input statement requires too much data, unit 2 (I am using MSVS 2012+intel fortran 2013)

, ? , MPI, ?

1

. access = "stream", . , , , "" "".

+4
3

, MPI, , .

. , . , , .

. , . , .

, , . . : " ".

, , .

,

open(unit = file_restart%unit, file = file_restart%file,  &
     form = 'unformatted', access='stream')

, :

do i=1, NPROCS
  ! read statement with a slice
end do

, , .

MPI-IO , . . SO.

+4

Fortran . . . , psi , , .

, stream sequential. () . , , . Fortran 2003.

, , MPI , , . , , .

+3

MPI, MPI-IO? MPI_File_set_view, , MPI_FILE_WRITE_ALL. , , ( oh, , 100 .)

+1

All Articles