Python Read Fortran Binary File
<p>I'm trying to read a binary file output from Fortran code below, but the results are not the same from output file.</p>

<p>Fortran 77 code:</p>

<pre><code>    program test
    implicit none
    integer i,j,k,l
    real*4       pcp(2,3,4)
    open(10, file='pcp.bin', form='unformatted')
    l = 0
    do i=1,2
      do j=1,2
        do k=1,2
          print*,k+l*2
          pcp(i,j,k)=k+l*2
          l = l + 1
        enddo
      enddo
    enddo
    do k=1,4
       write(10)pcp(:,:,k)
    enddo
    close(10)
    stop
    end
</code></pre>

<p>I'm trying to use the Python code below:</p>

<pre><code>from scipy.io import FortranFile
f = FortranFile('pcp.bin', 'r')
a = f.read_reals(dtype=float)
print(a)
</code></pre>