fortran程序 第一次接触fortran语言,试着编写了一个简单的程序:program tsimplicit noneinteger xx=120call ti(x)endsubroutine ti(x)real*8 xi=xprint *,'i=',xend连接时会有警告:Warning:In the call to TI,actual argument #1 does

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/04 15:16:30
fortran程序 第一次接触fortran语言,试着编写了一个简单的程序:program tsimplicit noneinteger xx=120call ti(x)endsubroutine ti(x)real*8 xi=xprint *,'i=',xend连接时会有警告:Warning:In the call to TI,actual argument #1 does

fortran程序 第一次接触fortran语言,试着编写了一个简单的程序:program tsimplicit noneinteger xx=120call ti(x)endsubroutine ti(x)real*8 xi=xprint *,'i=',xend连接时会有警告:Warning:In the call to TI,actual argument #1 does
fortran程序
第一次接触fortran语言,试着编写了一个简单的程序:
program ts
implicit none
integer x
x=120
call ti(x)
end
subroutine ti(x)
real*8 x
i=x
print *,'i=',x
end
连接时会有警告:Warning:In the call to TI,actual argument #1 does not match the type and kind of the corresponding dummy argument.call ti(x)
但当我把所有的i和x交换,其他不变,就没有问题,能够的到正确的结果.
为什么fortran不能学C那样在形参前面加一个integer 就好?应该怎么改呢?

fortran程序 第一次接触fortran语言,试着编写了一个简单的程序:program tsimplicit noneinteger xx=120call ti(x)endsubroutine ti(x)real*8 xi=xprint *,'i=',xend连接时会有警告:Warning:In the call to TI,actual argument #1 does
错误原因如ls
至于“但当我把所有的i和x交换,其他不变,就没有问题,能够的到正确的结果.”是因为fortran的I-N规则,以字母IJKMLN开头的变量,如果没有定义,默认为整形,交换以后,虚参I是整形,所以就没有问题了