回 帖 发 新 帖 刷新版面

主题:[转帖]提示no implicit none

bisection.f90:13.22:

subroutine typ_value(a,b)
                      1
Error: Symbol 'a' at (1) has no IMPLICIT type
bisection.f90:13.24:

subroutine typ_value(a,b)
                        1
Error: Symbol 'b' at (1) has no IMPLICIT type
bisection.f90:28.10:

use globle
          1
Fatal Error: Can't open module file 'globle.mod' for reading at (1): No such file or directory

以下是程序:
module globle
implicit none
real :: a,b,c

contains
real function func(x)
implicit none
real :: x
func=1.0-x*x
return
end function

subroutine typ_value(a,b)
c=(a+b)/2.0
return
end subroutine

subroutine product(m,n)
real :: m,n,pro
pro=func(m)*func(n)
return
end subroutine
end module globle

program bisection
use globle
implicit none
real :: pro1
real,external :: func
write(*,*)'please input two values'
100 read(*,*)a,b
call product(a,b)
pro1=pro
if(pro1<0)then
 call mid()
 call typ_value(a,b)!gain the value of c
 call product(a,c)!gain the value of func(a)*func(c)
 if(pro<0)then
   b=c
   entry mid()
 else if(pro>0)then
   a=b
   entry mid()
 else 
   exit
 end if
else if(pro1>0)then
 write(*,*)'please re-input two values'
 goto 100
else
 if(func(a)==0)then
  c=a
 else
  c=b
 end if
end if 
write(*,*)'the sulution between',a,'and'b,'is'1x,func(c)
end 

回复列表 (共1个回复)

沙发

subroutine typ_value(a,b)
c=(a+b)/2.0
return
end subroutine

这个子程序是包含在模块globle中的,所以虚参最好不要是 a,b,因为a b 已经出现在globle的变量声明里了。

如果真的要叫a,b,需要重新在函数内声明。当然,我不建议这样做。最好是换个名字,比如 aa,bb 都可以,别是 a b  就行。

我来回复

您尚未登录,请登录后再回复。点此登录或注册