Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oop 同一模块中的子例程找不到模块中的Fortran函数_Oop_Fortran_Gfortran - Fatal编程技术网

Oop 同一模块中的子例程找不到模块中的Fortran函数

Oop 同一模块中的子例程找不到模块中的Fortran函数,oop,fortran,gfortran,Oop,Fortran,Gfortran,我正在用Fortran90编写一个模块,主要是在模块内部定义了一个函数,以及一个使用该函数的子程序。这是本模块的摘录 module Mesh_io implicit none private contains integer function findkey ( ) content of this function end function subroutine getNumber_Mesh () integer :: findkey content

我正在用Fortran90编写一个模块,主要是在模块内部定义了一个函数,以及一个使用该函数的子程序。这是本模块的摘录

module Mesh_io
  implicit none
  private
contains
  integer function findkey ( )
    content of this function
  end function
  subroutine getNumber_Mesh ()
    integer :: findkey
    content of the routine
  end subroutine getNumber_Mesh
end module
编译时,我得到以下输出:

objects/Main.o: In function `__mesh_io_MOD_getnumber_mesh':
Main.f90:(.text+0x9e): undefined reference to `findkey_'

正如您所看到的,函数包含在模块中,但由于某些原因,编译器无法找到它

使用子例程
getNumber\u Mesh()
中的findkey声明,您正在创建一个隐藏函数的局部变量
findkey


对于模块,不需要声明函数(模块函数)的返回值。简单地删除声明就可以了

谢谢你的回答@Alexander Vogt。模块的使用对我来说真的很新。这个反馈真的很有帮助。由于链接器找不到函数
findkey
,也找不到所需的
findkey
,因此
getNumber\u Mesh
中的其他内容可能意味着它声明的是一个外部函数,而不是局部变量。相关