fortran 循环控制变量为实型时编译老有Warning如题,比如说有段代码如下program testimplicit nonereal s,xx=0.1do s=0.1,0.9,0.1x=s+1write(*,*)xend doend编译的话会出现如下编译提示do s=0.1,0.9,0.11Warning:Deleted feature:

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 08:10:04

fortran 循环控制变量为实型时编译老有Warning
如题,比如说有段代码如下
program test
implicit none
real s,x
x=0.1
do s=0.1,0.9,0.1
x=s+1
write(*,*)x
end do
end
编译的话会出现如下编译提示
do s=0.1,0.9,0.1
1
Warning:Deleted feature:Loop variable at (1) must be integer
do.f95:5.6:
do s=0.1,0.9,0.1
1
Warning:Deleted feature:Start expression in DO loop at (1) must be integer
do.f95:5.10:
do s=0.1,0.9,0.1
1
Warning:Deleted feature:End expression in DO loop at (1) must be integer
do.f95:5.14:
do s=0.1,0.9,0.1
1
Warning:Deleted feature:Step expression in DO loop at (1) must be integer
但是会有可执行程序生成.
我想问下为什么会有警告提示,fortran不是支持非整型循环控制变量么?如果没有其他方法避免警告的话怎么加入编译选项使其不提示警告?
PS:本人使用的是编译器是GNU Fortran (Ubuntu 4.4.3-4ubuntu5) 4.4.3

我用的也是gfortran,也碰到这种问题,所以我现在已经用整型来循环了.不过你如果要忽略警告,可以这样子,在编译时加上-std=legacy:
gfortran testloop.f90 -o testloop -std=legacy
不过我的是windows下,不知道你的版本行不行?
下面是手册的原话,关于-std=std
Specify the standard to which the program is expected to conform, which maybe one of ‘f95’, ‘f2003’, ‘gnu’, or ‘legacy’. The default value for std is ‘gnu’,which specifies a superset of the Fortran 95 standard that includes all of the extensions supported by GNU Fortran, although warnings will be given for obsolete extensions not recommended for use in new code. The ‘legacy’ value is equivalent but without the warnings for obsolete extensions, and may be useful for old non-standard programs. The ‘f95’ and ‘f2003’ values specify strict conformance to the Fortran 95 and Fortran 2003 standards, respectively; errors are given for all extensions beyond the relevant language standard, and warnings are given for the Fortran 77 features that are permitted but obsolescent in later standards.

fortran 循环控制变量为实型时编译老有Warning如题,比如说有段代码如下program testimplicit nonereal s,xx=0.1do s=0.1,0.9,0.1x=s+1write(*,*)xend doend编译的话会出现如下编译提示do s=0.1,0.9,0.11Warning:Deleted feature: fortran循环, intel visual fortran 11编译时发现sin log等数学函数不能用 以下用fortran循环语句怎样输出 * *** ***** *** *** 我在看一本C语言的书时遇见了一个问题 3Q是这么写的:许多C编译系统将实型常量作为双精度处理.例如已定义一个实型变量f,有如下语句:f=2.45678*4523.65系统将2.45678和4523.65按双精度数据存储 3.1415为什么不是实型常量,.871为什么是实型常量,实型常量与浮点型常量有什么区别? fortran fortran逻辑表达式(x(1).gt.1).or.(x(2).gt.1).or.(x(3).gt.1).or.(x(4).gt.1不知道哪错了编译时总出错fortran逻辑表达式(x(1).gt.1).or.(x(2).gt.1).or.(x(3).gt.1).or.(x(4).gt.1)不知道哪错了编译时总出错,其我想判断数 循环控制变量在循环体内被重新赋值是如何改变循环次数的?如 For i = 1 to 10 step 1 (此时循环次数为10为什么 如果在下面赋值i = i + 1则循环次数变为 在多重For-Next循环控制结构中,不同层次的循环能使用相同的循环控制变量吗? 在多重for-Next循环控制结构中,不同层次的循环能使用相同的循环控制变量吗? fortran里面的do循环问题do i=1,0,1...;.enddo这种循环会循环一次么?在c里面第一次循环前就要判断,所以上面一次也不会循环,在fortran里面是什么样子? 法拉第在研究电磁感应现象时,应用了什么方法?为什么是控制变量法和转换实验的方法 fortran 判定整数如题,如何用fortran语言判定n是否为整数 在fortran中,单do循环放在if语句里面的时候该怎么办? fortran ran函数如下语句program ranimplicit noneinteger i do i=1,1000print*,i,ran()enddoend program编译通不过去 是什么原因 我用的fortran 90 想用随机函数 物理基础知识何为 等效替代,类比法,控制变量法? 为什么在退出循环后循环变量的值比最后一次循环时循环变量多一个步长?图中程序退出循环值为11