この小さなプログラムは、ファイルが1つの2次元の変数が含まれています。名前はexecのライン、すなわち./a.out Jet0500上の最初の引数である(.MATファイルを読み込み
!compile with gfortran Read_mesh.f90
Module Mat_Read
real, allocatable :: omega(:,:)
contains
Subroutine Read_mesh
implicit none
integer :: unitno=10
integer :: kx,ncolumn,nrow
character (len=30) :: filename
call getarg(1,filename)
open(unit=unitno,file=filename,form="formatted",&
&status="old",action="read")
do kx=1,3 ! read by 3 lines
read(unitno,fmt="(A1)")
end do
read(unitno,fmt="(8x,i14)")nrow
read(unitno,fmt="(10x,i14)")ncolumn
allocate (omega(nrow,ncolumn))
do kx=1,nrow
read(unitno,*) omega(kx,:)
end do
close(unitno)
End Subroutine Read_mesh
End Module Mat_Read
Program test_Read_mesh
use Mat_Read
call Read_mesh
print *,omega(1,1)
End Program test_Read_mesh
私はあなたの質問があると思いますMATLAB開発者の正式な回答:https://www.mathworks.com/help/matlab/read-and-write-matlab-mat-files-in-cc-and-fortran.html – King