麻烦前辈看看我这个简单的Fortran程序有什么问题?
programaimplicitnoneinteger::i=1,c,b(2)commoni,b,cb(2)=1calladdwrite(*.*)cstopendsubr...
program a
implicit none
integer::i=1,c,b(2)
common i,b,c
b(2)=1
call add
write(*.*) c
stop
end
subroutine add
implicit
c=i+b(2)
end
错误提示:
--------------------Configuration: ceshi - Win32 Debug--------------------
Compiling Fortran...
D:\chengxu\ceshi\cs.f90
D:\chengxu\ceshi\cs.f90(9) : Error: Syntax error, found '.' when expecting one of: , )
write(*.*) c
-------^
D:\chengxu\ceshi\cs.f90(14) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: NONE TYPE COMPLEX BYTE CHARACTER DOUBLE DOUBLECOMPLEX DOUBLEPRECISION INTEGER ...
implicit
--------^
D:\chengxu\ceshi\cs.f90(15) : Error: Syntax error, found IDENTIFIER 'C' when expecting one of: ( : % . = =>
integer c=i+b(2)
--------^
D:\chengxu\ceshi\cs.f90(15) : Error: This variable or component must be of a derived or structure type [INTEGER]
integer c=i+b(2)
^
D:\chengxu\ceshi\cs.f90(15) : Error: This is not a field name that is defined in the encompassing structure. [C]
integer c=i+b(2)
--------^
Error executing df.exe.
cs.obj - 5 error(s), 0 warning(s) 展开
implicit none
integer::i=1,c,b(2)
common i,b,c
b(2)=1
call add
write(*.*) c
stop
end
subroutine add
implicit
c=i+b(2)
end
错误提示:
--------------------Configuration: ceshi - Win32 Debug--------------------
Compiling Fortran...
D:\chengxu\ceshi\cs.f90
D:\chengxu\ceshi\cs.f90(9) : Error: Syntax error, found '.' when expecting one of: , )
write(*.*) c
-------^
D:\chengxu\ceshi\cs.f90(14) : Error: Syntax error, found END-OF-STATEMENT when expecting one of: NONE TYPE COMPLEX BYTE CHARACTER DOUBLE DOUBLECOMPLEX DOUBLEPRECISION INTEGER ...
implicit
--------^
D:\chengxu\ceshi\cs.f90(15) : Error: Syntax error, found IDENTIFIER 'C' when expecting one of: ( : % . = =>
integer c=i+b(2)
--------^
D:\chengxu\ceshi\cs.f90(15) : Error: This variable or component must be of a derived or structure type [INTEGER]
integer c=i+b(2)
^
D:\chengxu\ceshi\cs.f90(15) : Error: This is not a field name that is defined in the encompassing structure. [C]
integer c=i+b(2)
--------^
Error executing df.exe.
cs.obj - 5 error(s), 0 warning(s) 展开
1个回答
展开全部
program a
implicit none
integer::i,c,b(2) !// common 里的变量不能初始化,不能 i=1
common i,b,c
i = 1 !// i=1需要写入执行语句
b(2)=1
call add
write(*,*) c !//这里是逗号
stop
end
subroutine add
integer::i,c,b(2) !// common 需要使用的话,需要再定义
common i , b , c !// 同上
!implicit !// 这句删除或补充完整
c=i+b(2)
end
implicit none
integer::i,c,b(2) !// common 里的变量不能初始化,不能 i=1
common i,b,c
i = 1 !// i=1需要写入执行语句
b(2)=1
call add
write(*,*) c !//这里是逗号
stop
end
subroutine add
integer::i,c,b(2) !// common 需要使用的话,需要再定义
common i , b , c !// 同上
!implicit !// 这句删除或补充完整
c=i+b(2)
end
追问
program a
implicit none
integer::i,c,b(2)
common i,b,c
i=1
b(2)=1
call add
write(*,*) c
stop
end
subroutine add
implicit none
c=i+b(2)
end
还是不行,说c,i,a未定义
追答
我已经说过了:
subroutine add
integer::i,c,b(2) !// common 需要使用的话,需要再定义
common i , b , c !// 同上
!implicit !// 这句删除或补充完整
c=i+b(2)
end
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询