Fortran错误;福尔特:严重(408):堡垒(2)

Fortran错误;福尔特:严重(408):堡垒(2),fortran,intel-fortran,Fortran,Intel Fortran,我可以很好地构建我的项目(IA-32操作系统,Windows 7.Intel Visual Fortran 11.1.048与Microsoft Visual Studio 2008集成)。运行.exe文件时,会出现以下错误: forrtl: severe (408): fort(2): Subscript #1 of the array dProductIDev has value 5 which is greater than the upper bound of 4 它还表示,在最后一行

我可以很好地构建我的项目(IA-32操作系统,Windows 7.Intel Visual Fortran 11.1.048与Microsoft Visual Studio 2008集成)。运行.exe文件时,会出现以下错误:

forrtl: severe (408): fort(2): Subscript #1 of the array dProductIDev has value 5 which is greater than the upper bound of 4
它还表示,在最后一行中计算
clcMatA
时,函数
clcMatA
中发生了错误(我已标记了错误,请参见下文)。功能代码为:

        function clcMatA(cStress,D,I_dev,dtime,props,ndi,ntens)

        implicit none

        integer :: ndi,ntens
        real*8 :: Z(2,ntens), dProductIDev(ntens,ntens), &
        clcMatA(ntens,ntens),D(ntens,ntens),I_dev(ntens,ntens),&
        cStress(ntens),dProductSigmadev2(ntens,ntens),&
        sigmaDevDyadicProduct(ntens,ntens),identity(ntens,ntens),&
        sigmaDev(ntens),props(5),alpha, beta,dtime,coeff_1,coeff_2,coeff_3


        call identityMatrix(identity,ntens)

        if (normm(cStress,ntens)==0) then

            clcMatA = identity

        else
            alpha = expValVolume/(2*expValDStran)
            beta = (6*expValVolume/(pi*expValPStran))**(1/props(4))*props(3)
            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

            dProductSigmadev2 = matmul(D,sigmaDevDyadicProduct)


            call zVals(Z,sigmaDev,props,ntens)

            do i=1,ntens
                do j=1,ntens
                    clcMatA(i,j) = identity(i,j) + dtime*( (alpha+beta* &
                    normm(sigmaDev,ntens)**(1./props(4)-1.))*dProductIDev(i,j) + & ! The line causing the error
                    beta*(1./props(4)-1.)*normm(sigmaDev,ntens)**(1./props(4)-3.)* &
                    dProductSigmadev2(i,j) )
                end do    
            end do

        end if

        end function
变量
i
j
expValVolume
expValDStran
expValPStran
在包含函数
clcMatA
dev
identityMatrix
normm
的模块中定义

ntens
value是下标的上限,它被传递给值为4的函数。我还检查了它在中断模式,它检查出来。我还用
4
替换了
NTES
!!!在计算clcMatA时,我得到了相同的错误

我打印了传递给函数的参数,然后遇到了一些奇怪的事情
D
应为对称矩阵,并具有以下组件:

 D:
   174999994368.000        74999996416.0000        74999996416.0000       0.000000000000000E+000
   74999996416.0000        174999994368.000        74999996416.0000       0.000000000000000E+000
   74999996416.0000        74999996416.0000        174999994368.000       0.000000000000000E+000
  0.000000000000000E+000  0.000000000000000E+000  0.000000000000000E+000   49999998976.0000 

 D:
   174999994368.000        74999996416.0000        74999996416.0000       1.853911331209891E-307
   74999996416.0000        174999994368.000        74999996416.0000       2.228101728310706E-312
   74999996416.0000        74999996416.0000        174999994368.000       7.115376174740906E-307
  1.879376978297863E-307  0.000000000000000E+000  0.000000000000000E+000   49999998976.0000 
所以我也把D改成了它应该是什么,但又犯了同样的错误

(我必须使用这种类型的变量,因为这个函数是由商业有限元软件(ABAQUS)间接调用的,交换变量的类型应该匹配。我也尝试了real(8),但没有改变。)


我不知道那里发生了什么事。有什么想法吗?

总结:应该是本地的变量被声明为模块变量。这导致在使用模块(使用关联)或模块内部(主机关联)的不同范围内使用相同的变量


独立于特定范围(如过程)的变量应在该特定范围内声明。否则,调用的不同过程可能会无意中更改调用范围中使用的值

有两个变量没有在任何地方定义。他们从哪里来?”expvaldstran''expvalvolume''i''j'和其他。等等,循环索引变量
i
j
是模块变量吗?那不可能。谢谢你的评论。我在代码后面添加了解释。它们来自包含
clcMatA
和其他函数的模块。等等,循环索引变量i和j是模块变量?那不可能是对的。正如我在帖子中补充的,是的。为什么不可能是正确的呢?