title: 6 dimensional integral by Trapezoid in Fortran using Fortran 90
body: <p>I need to calculate six dimensional integrals using Trapezoid in Fortran 90 in an efficient way. Here is an example of what I need to do:</p>
  
  <p><img src="https://i.stack.imgur.com/U3W1Z.png" alt="The integral expression"></p>
  
  <p>Where F is a numerical (e.g. not analytical) function which is to be integrated over x1 to x6, variables. I have initially coded a one dimension subroutine:</p>
  
  <pre><code>  SUBROUTINE trapzd(f,mass,x,nstep,deltam) 
        INTEGER nstep,i
        DOUBLE PRECISION mass(nstep+1),f(nstep+1),x,deltam
        x=0.d0
        do i=1,nstep
            x=x+deltam*(f(i)+f(i+1))/2.d0
        end do
    return
    END
  </code></pre>
  
  <p>Which seems to work fine with one dimension, however, I don't know how to scale this up to six dimensions. Can I re-use this six times, once for every dimension or shall I write a new subroutine?</p>
  
  <p>If you have a <em>fully coded (no library/API use)</em> version of this in another language like Python, MATLAB or Java, I'd be very glad to have a look and get some ideas.</p>
  
  <p>P.S. This is not school homework. I am a PhD student in Biomedicine and this is part of my research in modeling stem cell activities. I do not have a deep background of coding and mathematics.</p>
  
  <p>Thank you in advance.</p>