fortran - 错误 #6404 : This name does not have a type, 并且必须具有显式类型

标签 fortran

我无法消除下面代码中的此错误。有3个功能; dev、norm 和 clcMatA。前两个函数在第三个函数中调用。但它们不被识别为函数。我像定义其他函数一样定义了它们,但之前没有遇到此类错误。

错误:

Error   1    error #6404: This name does not have a type, and must have an explicit type.   [DEV]   D:\Users\Vahid\Documents\Visual Studio 2008\Projects\Tst\Tst\Source1.for    66  

Error   2    error #6404: This name does not have a type, and must have an explicit type.   [NORM]  D:\Users\Vahid\Documents\Visual Studio 2008\Projects\Tst\Tst\Source1.for    78

我真的很感激任何帮助。谢谢。

代码(固定格式;.for):

      module parameters

      implicit none
      save
      integer :: i,j

      real*8 :: pi = 3.14159265358979323846,KP = 5.e-8, M = 0.5 
      real*8 :: expValPStran, expValDStran, expValVolume

      end module

***********************************      
      program empty

      end program

***********************************      
      function norm(matrix)
      use parameters
      implicit none
      real*8, allocatable, intent(in) :: matrix(:)
      real*8 :: norm,sum
      integer :: dim

      dim = size(matrix,1)

      sum = 0.
      do i=1,dim
        sum = sum + matrix(i)**2
      end do
      norm = sqrt(sum)


      end function      
***********************************      
!      calculates the deviatoric part of the current stress cStress
      function dev(cStress,I_dev,ntens)
      use parameters
      implicit none

      integer :: ntens
      real*8 :: cStress(ntens),I_dev(ntens,ntens)
      real*8 :: dev(ntens)


      dev = matmul(I_dev,cStress)


      end function

***********************************      
      function clcMatA(cStress,D,I_dev,dtime,ndi,ntens)
      use parameters
      implicit none

      integer :: ndi,ntens
      real*8 :: Z(2,ntens), dProductIDev(ntens,ntens), 
     1clcMatA(ntens,ntens),D(ntens,ntens),I_dev(ntens,ntens),
     2cStress(ntens),dProductSigmadev2(ntens,ntens),
     3sigmaDevDyadicProduct(ntens,ntens),identity(ntens,ntens),
     4sigmaDev(ntens),alpha, beta,dtime 


      alpha = expValVolume/(2*expValDStran)
      beta = (6*expValVolume/(pi*expValPStran))**(1/M)*KP
      sigmaDev = dev(cStress,I_dev,ntens)
      dProductIDev = matmul(D,I_dev)

      do i=1,ntens
        do j=1,ntens
            sigmaDevDyadicProduct(i,j)= sigmaDev(j)*sigmaDev(i)
        end do
      end do


      do i=1,ntens
        clcMatA(i,:) = dtime*( (alpha+beta*
     1 norm(sigmaDev)**(1./m-1.))*dProductIDev(i,:) + beta*(1./m-1.)*
     2 norm(sigmaDev)**(1./m-3.) )
      end do


      end function

最佳答案

您的源文件包含一个模块、一个程序和三个函数。您已注意在函数中使用关联模块,以便可以在函数中使用模块的参数。但您尚未编写任何语句,也未构建代码,因此函数 clcMatA 具有任何关于 normdev 的知识。仅将所有三个函数的定义放入同一个源文件中不会提供编译器所需的信息。

一个简单的解决方案是将函数包含在模块中。在参数声明后插入包含单词 contains 的行,然后剪切并粘贴 containsend module 之间的函数代码。

当我写作时:

你到底为什么在 2014 年使用固定格式源?

在实际上没有使用模块中定义的任何实体的函数中使用参数似乎很奇怪。

你的函数norm是一种冗长的书写方式

norm = sqrt(sum(matrix*matrix))

请注意,我在这里使用名为 sum 的内部函数,我强烈建议您不要使用 sum 作为变量名。你不会让编译器感到困惑,你可能会让你自己感到困惑。

关于fortran - 错误 #6404 : This name does not have a type, 并且必须具有显式类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22361763/

相关文章:

linker - 针对静态库编译 Fortran 程序时未找到函数(在 Windows 中使用 IFORT)

fortran - 包装函数中的语句标签

c - 如何将常量字符串从 fortran 函数传递到 C

fortran - 无需预处理即可通过子例程实现打印语句的强大功能?

c++ - 同时安装ifort和icc

运行 FORTRAN 代码时出现 Linux 错误,其中包含 'nullify'

compilation - f951 错误 : unrecognized command line option

fortran - 使用 fortran 覆盖文件

python - 将python嵌入到fortran 90中

c++ - dgesv 中的舍入错误?