title: Fortran Error; forrtl: severe (408): fort(2)
body: <p>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:</p>
  
  <pre><code>forrtl: severe (408): fort(2): Subscript #1 of the array dProductIDev has value 5 which is greater than the upper bound of 4
  </code></pre>
  
  <p>It says also the error is happening in the function <code>clcMatA</code> when calculating <code>clcMatA</code> in the final lines (I have marked the see below). The function code is:</p>
  
  <pre><code>        function clcMatA(cStress,D,I_dev,dtime,props,ndi,ntens)
  
          implicit none
  
          integer :: ndi,ntens
          real*8 :: Z(2,ntens), dProductIDev(ntens,ntens), &amp;
          clcMatA(ntens,ntens),D(ntens,ntens),I_dev(ntens,ntens),&amp;
          cStress(ntens),dProductSigmadev2(ntens,ntens),&amp;
          sigmaDevDyadicProduct(ntens,ntens),identity(ntens,ntens),&amp;
          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* &amp;
                      normm(sigmaDev,ntens)**(1./props(4)-1.))*dProductIDev(i,j) + &amp; ! The line causing the error
                      beta*(1./props(4)-1.)*normm(sigmaDev,ntens)**(1./props(4)-3.)* &amp;
                      dProductSigmadev2(i,j) )
                  end do    
              end do
  
          end if
  
          end function
  </code></pre>
  
  <p>Variables <code>i</code>,<code>j</code>,<code>expValVolume</code>,<code>expValDStran</code> and <code>expValPStran</code> are defined in a module in which the function <code>clcMatA</code>, <code>dev</code>, <code>identityMatrix</code> and <code>normm</code> are contained.</p>
  
  <p><code>ntens</code> 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 <code>ntens</code> with <code>4</code>!!! in calculating <code>clcMatA</code> but I got the same error.</p>
  
  <p>I printed the parameters passed to the function and I came accross something weird. <code>D</code> should be a symmetric matrix and have the following components:</p>
  
  <pre><code> 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 
  </code></pre>
  
  <p>So I also changed D to what it should be, but got the same error again.</p>
  
  <p>(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.)</p>
  
  <p>I don't know what is happeining there. Any idea?</p>