Error #6404: This name does not have a type, and must have an explicit type

匿名 (未验证) 提交于 2019-12-03 00:57:01

问题:

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 

回答1:

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.



回答2:

Your functions norm and dev are unknown to clcMatA as subprograms. You have to tell it what they are with:

real*8, external :: dev, norm 

However, this is not enough, as both function dev and norm require an explicit interface, because dev returns an array-valued result, and norm has a dummy argument with the allocatable attribute (read this page from top to bottom). So, you will either have to write that explicit interface, so your clcMatA knows more about them, or put them in a module.

EDIT: fixed wrong link



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!