2007年2月11日星期日

Fortran中判断文件读写末尾

在READ语句中,可以加入一个状态量IOSTAT=整型变量:可选,用于指明输入输出时的状态。
如输入正常,则变量值为零;如出错,为正整数;如遇文件结束无数可读,为负整数。
示例如下:
! this program is used to calculate the order
! you must first input all your error data to a file named 'dat.error'
! then use this program to calculate the order
program main
open(1,file='dat.error')
read(1,*,iostat=ierr) error0
write(*,*) error0
do
read(1,*,iostat=ierr) error1
if(ierr<0) exit
write(*,*) error1,' order: ',log(abs(error0/error1))/log(2.0)
error0=error1
enddo
end program

2 条评论:

匿名 说...

Hi, I do think this is a great site. I stumbledupon it
;) I'm going to return yet again since i have book marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

Feel free to visit my blog post ... bath toys

匿名 说...

Aw, this was an exceptionally nice post. Taking the time and actual effort to
create a top notch article… but what can I say… I put things off a whole
lot and don't manage to get nearly anything done.

Feel free to surf to my web page fred marvin associates