Fortran中這句if語句如何理解
這是Fortran中Arithmetic IF Statement即算術if語句,它的含義就是:當if中的值,分別是 0時,按相應順序goto到后面的語句。具體到你的例子,就是:
當a =0時,goto 100比如:
read(*,*) a
if (a) 120, 100, 100
120 print *, "= 0"
200 continue運行結果:
-1
= 0
Fortran中這句if語句如何理解
這是Fortran中Arithmetic IF Statement即算術if語句,它的含義就是:當if中的值,分別是<,=,> 0時,按相應順序goto到后面的語句。
具體到你的例子,就是: 當a < 0時, goto 120當 a >=0時,goto 100比如: read(*,*) a if (a) 120, 100, 100120 print *, "< 0" print *, "---" goto 200100 print *, ">= 0"200 continue運行結果: -1 < 0 ---而 1 >= 0。
轉載請注明出處華閱文章網 » fortranif語句