并且必须具有显式类型

并且必须具有显式类型

本文介绍了错误#6404:此名称没有类型,并且必须具有显式类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在下面的代码中清除这个错误。有3个功能; dev,norm和clcMatA。前两个函数在第三个函数中被调用。但它们不被认为是功能。我已经将它们定义为像我为其他功能所做的那样,但之前我没有收到这样的错误。



错误:

 错误1错误#6404:此名称没有类型,并且必须具有显式类型。 [DEV] D:\ Users \Vahid\Documents\Visual Studio 2008\Projects\Tst\Tst\Source1.for 66 

错误2错误#6404:此名称没有类型,并且必须有明确的类型。 [NORM] D:\ Users \Vahid\Documents\Visual Studio 2008\Projects\Tst\Tst\Source1.for 78

我非常感谢任何帮助。谢谢。



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

 模块参数

隐式无
保存
整数:: i,j

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

结束模块

************* **********************
程序清空

结束程序

**** *******************************
函数规范(矩阵)
使用参数
隐式无
real * 8,可分配,意图(in)::矩阵(:)
实数* 8 ::范数,总和
integer :: dim

dim = size(matrix,1)

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


结束函数
********************* **************
!计算当前压力的偏差部分cStress
函数dev(cStress,I_dev,ntens)
使用参数
隐式无

整数:: ntens
real * 8 :: cStress(ntens),I_dev(ntens,ntens)
real * 8 :: dev(ntens)

$ b dev = matmul(I_dev,cStress)


最终功能

***************************** ******
函数clcMatA(cStress,D,I_dev,dtime,ndi,ntens)
使用参数
隐式无

整型:: ndi, ntens
真实* 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),同一性(ntens,ntens)
4sigmaDev(ntens),α,β,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. / )*
2 norm(sigmaDev)**(1./m-3。))
end do


结束函数
源文件包含一个模块,一个程序和三个函数。您已经在功能中注意使用associate 模块,以便您可以在函数中使用该模块的参数。但是你没有写任何语句,也没有构造你的代码,使得 clcMatA 函数知道 norm dev 。只需将所有三个函数的定义嵌入到相同的源文件中,将不会提供编译器需要的信息。



一个简单的解决方案是将函数包含在模块。在参数声明之后插入包含单词包含的行,然后剪切并过滤之间的函数代码结尾模块



在写信时:



对于使用参数来说似乎很奇怪,在你不真正使用模块中定义的任何实体的函数中。

你的函数 norm 是一种啰嗦的写作方式

$ $ p $ code> norm = sqrt(sum(matrix * matrix))

请注意,我在这里使用名为 sum 的内在函数,我强烈建议您不要使用 sum 作为变量名称。您不会混淆编译器,您可能会迷惑自己。


I having trouble getting rid of this error in the code below. There are 3 functions; dev, norm and clcMatA. The first two functions are called in the third one. But they are not recognized as functions. I have defined them like I do for other functions but I didn't get such errors before.

The errors:

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

I would really appreciate any help. Thanks.

The code (in fixed format; .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
解决方案

Your source file contains one module, one program and three functions. You've taken care to use associate the module in the functions so that you can use the module's parameters in the functions. But you've not written any statements, nor structured your code, such that the function clcMatA has any knowledge of norm or dev. Just chucking the definitions of all three functions into the same source file won't provide the information that the compiler needs.

One easy solution would be to include the functions in the module. Insert a line containing the word contains after the parameter declarations, then cut and past the code of the functions in between contains and end module.

While I'm writing:

Why on earth are you using fixed-form source in 2014 ?

It seems strange to use parameters in functions where you don't actually use any of the entities defined in the module.

Your function norm is a long-winded way of writing

norm = sqrt(sum(matrix*matrix))

Note that I am using the intrinsic function named sum here, I strongly suggest that you don't use sum as a variable name. You won't confuse the compiler, you may confuse yourself.

这篇关于错误#6404:此名称没有类型,并且必须具有显式类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 07:40