program main
character*200 infile !输入文件名
! !打开输入数据文件------------------
infile="sample1.txt"
!infile="sample.txt"
open(408,file=infile,status='old',form='formatted')
!---------------------------------------------------------------------------------------------
!读取前7行数据并赋值给相应的变量--------------------------------------------------
read(408,'(I)') M
read(408,'(I)') N
read(408,'(I)') iqpart
read(408,'(I)') nhex
read(408,'(f)') U
read(408,'(f)') refr
read(408,'(I)') nray
close(408)
write(*,*) M,N,iqpart
write(*,*) nhex
write(*,*) u,refr,nray
end
1.06 KB, 下载次数: 4
sample.txt
916 Bytes, 下载次数: 3
sample1.txt
program main
Implicit none
character(len=200) :: infile = "sample1.txt" !输入文件名
Integer :: M,N,iqpart,nhex,nray
Real :: U,REFR
open(408,file=infile,status='old',form='formatted')
read(408,*) M
read(408,*) N
read(408,*) iqpart
read(408,*) nhex
read(408,*) U
read(408,*) refr
read(408,*) nray
close(408)
write(*,*) M,N,iqpart
write(*,*) nhex
write(*,*) u,refr,nray
end program main
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |