fortran 循环控制变量为实型时编译老有Warning
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/05 16:57:38
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
如题,比如说有段代码如下
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.
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循环,
fortran语言 循环问题
Fortran关于循环的问题
恳求fortran大神帮忙编译一小段简单程序
fortran里面的do循环问题
fortran中do循环应用问题.
以下用fortran循环语句怎样输出 * *** ***** *** ***
fortran循环语句的数组输出
Altium Designer 中,编译原理图,出现warning:off grid power……还有error:ha
3.1415为什么不是实型常量,.871为什么是实型常量,实型常量与浮点型常量有什么区别?
循环控制变量 'for' 无效,只有7分了,没有办法.
循环控制变量在循环体内被重新赋值是如何改变循环次数的?