Fortran复健(1)
1、关于数组下标
若不加以额外声明,index从1开始,可以通过声明使其从0开始
real ::bin(0:13)
data ::bin/0,600,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,12000,100000/
此时,bin(0)=0
2、continue的用法及循环的署名
The CONTINUE statement is often used as a place to hang a statement label, usually it is the end of a DO loop.
The CONTINUE statement is used primarily as a convenient point for placing a statement label, particularly as the terminal statement in a DO loop. Execution of a CONTINUE statement has no effect.
If the CONTINUE statement is used as the terminal statement of a DO loop, the next statement executed depends on the DO loop exit condition.
如:
do 10021 i=2016,2020
do 10021 j=1,12
……………
10021 continue
do后面的数字指定循环到某一行结束,fortran77中常用continue来结束循环,因为continue这个命令没有实际意义,正好可以用来封装。到fortran90才有end do,但fortran77也可以使用end do而非行号。
也即10021行的continue代替起两个end do的作用,表示循环体到此结束。