我无法在下面的代码中摆脱这个错误.有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
Run Code Online (Sandbox Code Playgroud)
我真的很感激任何帮助.谢谢.
代码(固定格式; .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
Run Code Online (Sandbox Code Playgroud)
您的源文件包含一个模块,一个程序和三个函数.您已经注意在函数中使用关联模块,以便您可以在函数中使用模块的参数.但是你没有编写任何语句,也没有编写代码,这样函数clcMatA就有norm或者知道dev.只是将所有三个函数的定义放入同一个源文件中将无法提供编译器所需的信息.
一个简单的解决方案是将功能包含在模块中.contains在参数声明后插入包含单词的行,然后剪切并经过中间函数的代码contains和end module.
在我写作的时候:
为什么你在2014年使用固定形式的源?
use parameters在您实际上没有使用模块中定义的任何实体的函数中,这似乎很奇怪.
你的功能norm是一种冗长的写作方式
norm = sqrt(sum(matrix*matrix))
Run Code Online (Sandbox Code Playgroud)
请注意,我使用的是sum此处命名的内部函数,我强烈建议您不要将其sum用作变量名.你不会混淆编译器,你可能会迷惑自己.
| 归档时间: |
|
| 查看次数: |
6550 次 |
| 最近记录: |