To give you an idea of what I meant in my second comment, I made a mock up:
testwrite.f90, compiled with gfortran 4.8.4: It basically writes an unformated, sequential file with the arrays you specified (just a lot smaller, to be able to compare them by eye) filled with arbitrary data.
It also prints the arrays.
implicit none
integer nS, nT, i ,j
parameter (nS = 10)
parameter (nT = 3)
real(8) wn_arr(nS) ! wavenumber [cm^-1]
real(8) temp_arr(nT) ! temperature [K]
real(8) abs_arr(nS,nT) ! absorption coefficient [cm^-1 / amagat^2]
wn_arr = (/ (i, i=1,nS) /)
temp_arr = (/ (270+i, i=1,nT) /)
abs_arr = reshape( (/ ((10*j+i, i=1,nS), j=1,nT) /), (/nS, nT/))
print*, wn_arr
print*, '-----------------'
print*, temp_arr
print*, '-----------------'
print*, abs_arr
print*, '-----------------'
print*, 'abs_arr(5,3) = ', abs_arr(5,3)
open(33,file='test.out',form='unformatted')
write(33) wn_arr
write(33) temp_arr
write(33) abs_arr
close(33)
end
testread.py, tested with Python 2.7.6, then reads the file written above and prints the arrays as well. For me the output of both programs is the same. YMMV.
import numpy as np
rec_delim = 4 # This value depends on the Fortran compiler
nS = 10
nT = 3
with open('test.out', 'rb') as infile:
infile.seek(rec_delim, 1) # begin record
wn_arr = np.fromfile(file=infile, dtype=np.float64, count=nS)
infile.seek(rec_delim, 1) # end record
infile.seek(rec_delim, 1) # begin record
temp_arr = np.fromfile(file=infile, dtype=np.float64, count=nT)
infile.seek(rec_delim, 1) # end record
infile.seek(rec_delim, 1) # begin record
abs_arr = np.fromfile(file=infile,
dtype=np.float64).reshape((nS, nT), order='F')
infile.seek(rec_delim, 1) # end record
print(wn_arr)
print(temp_arr)
print(abs_arr)
# The array has the same shape, but Fortran starts index (per default at least)
# at 1 and Python at 0:
print('abs_arr(5,3) = ' + str(abs_arr[4,2]))
Short explanation: I open the file in a with-block (good practice in Python) and then I step through the file, using the knowledge of how the file is written. This makes it unportable. infile.seek(4, 1) moves the read-pointer of Python forward 4 bytes, from the current position (the option 1), because I know that the file starts with a begin-record marker that is 4 bytes long (gfortran).
Then I use numpy.fromfile to read count=10 values of float64, which is the wavenumber array.
Next I have to skip the end-record and begin-record markers. This could of course be done by infile.seel(8, 1) as well.
Then I read the temperature array, skip end-record and begin-record markers again and read the 2D-array.
The data in the file doesn't know that it's 2D, so I need to reshape it, using the Fortran-order.
The last .seek() is spurious, I just wanted to emphasize the structure.
I strongly suggest again that you do not build a bigger system on code like this. It's fine for a one-off, but terrible for something you have to use again or share.