Question

I can build my project fine (IA-32 OS, Windows 7. Intel Visual Fortran 11.1.048 integrated with Microsoft Visual Studio 2008). When I run the .exe file it gives the following error:

forrtl: severe (408): fort(2): Subscript #1 of the array dProductIDev has value 5 which is greater than the upper bound of 4

It says also the error is happening in the function clcMatA when calculating clcMatA in the final lines (I have marked the see below). The function code is:

        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

Variables i,j,expValVolume,expValDStran and expValPStran are defined in a module in which the function clcMatA, dev, identityMatrix and normm are contained.

ntens value, the upper bound of the subscripts, is passed on to the function with the value of 4. I also checked it in the break mode and it checks out. I also replaced ntens with 4!!! in calculating clcMatA but I got the same error.

I printed the parameters passed to the function and I came accross something weird. D should be a symmetric matrix and have the following components:

 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 

So I also changed D to what it should be, but got the same error again.

(I have to use this type of variable because this function is called indirectly by a commercial finite element software (ABAQUS) and the type of exchanged variables should match. I also tried real(8), but yet nothing changed.)

I don't know what is happeining there. Any idea?

Was it helpful?

Solution

Summary: The variables that should be local are declared as module variables. That leads of using the same variables in different scopes which use the module (use association) or are inside the module (host association).

Variables, that are independent for particular scope (e.g. a procedure) should be declared in that particular scope. Otherwise a different procedure that is called can inadvertently change the value used in the calling scope.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top