<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body style="word-wrap:break-word" fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div><br>
</div>
<div><br>
</div>
<div>Hi Emmanuel,</div>
<div><br>
</div>
<div>f77 passes arrays by address -- i.e., it passes a pointer to the element</div>
<div>of the array listed, or to the first one if no array index is indicated</div>
<div>in the call. There is no concept of passing a whole array or just part of one</div>
<div>--- you simply pass the pointer to the first element of the array, e.g., as in</div>
<div>"call blah(ta)" or to some other element of the array "call blah(ta(1,1,1,e))"</div>
<div>which, in this case, would pass the pointer to the e-th element of ta.</div>
<div><br>
</div>
<div>Moreover, in f77, the declaration</div>
<div><br>
</div>
<div> real x(3,4)</div>
<div><br>
</div>
<div>implies that x(2,k) comes immediately after x(1,k) in memory (whereas</div>
<div>x(k,3) is _not_ next to x(k,2).)</div>
<div><br>
</div>
<div>Common usage in Nek is therefore to view the block</div>
<div><br>
</div>
<div> x(1,1,1,e),x(2,1,1,e),...,x(lx1,ly1,lz1,e)</div>
<div><br>
</div>
<div>as an "element" All of these variables are adjacent in</div>
<div>memory, assuming that the array index sizes are (lx1,ly1,lz1)</div>
<div>for the first three indices. Given that they are adjacent,</div>
<div>we can pass one element at a time to a routine (but really,</div>
<div>we're just passing a pointer to the "e"th block) via</div>
<div><br>
</div>
<div> integer e</div>
<div><br>
</div>
<div> do e=1,nelv</div>
<div> call blah(x(1,1,1,e))</div>
<div> enddo</div>
<div><br>
</div>
<div>In a case where we operate on an entire field, i.e., all</div>
<div>elements, it suffices to just pass the pointer to the whole</div>
<div>array, as in:</div>
<div><br>
</div>
<div> n=nx1*ny1*nz1*nelv</div>
<div> call rzero(x,n)</div>
<div><br>
</div>
<div>Note that it's critical that each element be completely</div>
<div>full - i.e., that we use all the memory locations in the</div>
<div>x(i,j,k) locacations. That way, we are always accessing</div>
<div>adjacent memory locations and have unit-stride addressing</div>
<div>(see, e.g., Deville,Fischer,Mund chapter 8 or google the</div>
<div>topic). However, we _don't_ have to fill up all the elements.</div>
<div>If we want to declare 10 elements and use only the first 5,</div>
<div>that's ok (though it takes more memory, which may or may not</div>
<div>be an issue). With this approach we have the flexibility</div>
<div>of running the same executable with different processor</div>
<div>counts. Consider the following scenario:</div>
<div><br>
</div>
<div>We have nelg=80 elements in a mesh and we declare lelt=10.</div>
<div><br>
</div>
<div>We can run on:</div>
<div><br>
</div>
<div> 8 processors, lelt=10, nelt=10</div>
<div> 16 processors, lelt=10, nelt= 5</div>
<div> 32 processors, lelt=10, nelt= 2 or 3</div>
<div><br>
</div>
<div>etc. Note that, in the 32 processor case, not all processors</div>
<div>have the same value of nelt. However, they must have the</div>
<div>same value of lelt because they are running the same</div>
<div>executable and nek uses static (i.e., declared at compile-time)</div>
<div>memory allocation.</div>
<div><br>
</div>
<div><br>
</div>
<div>Paul</div>
<div><br>
</div>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF723029" style="direction: ltr;"><font face="Tahoma" size="2" color="#000000"><b>From:</b> nek5000-users-bounces@lists.mcs.anl.gov [nek5000-users-bounces@lists.mcs.anl.gov] on behalf of nek5000-users@lists.mcs.anl.gov [nek5000-users@lists.mcs.anl.gov]<br>
<b>Sent:</b> Tuesday, June 03, 2014 2:52 AM<br>
<b>To:</b> nek5000-users@lists.mcs.anl.gov<br>
<b>Subject:</b> [Nek5000-users] size of arrays and declaration of variables<br>
</font><br>
</div>
<div></div>
<div>Hi Nek team,
<div><br>
</div>
<div>I have a question concerning the size of arrays. I took the routine convab for example. </div>
<div><br>
</div>
<div>TA, such as T, BQ or VTRANS, have a size of lt=lx1*ly1*lz1*lelt. </div>
<div>So why in the call of col2 or subcol3 the parameter n, which should be the size of the arrays cited above, is actually ntot=nx1*ny1*nz1*nelfld(ifield) ?</div>
<div><br>
</div>
<div><br>
</div>
<div>1) I guess that there is a reason for that, but I don’t understand this mismatch of size of arrays. Moreover, ntot refers to the number of nodes on a CPU and LT refers to the total number of node in the full domain, right?</div>
<div><br>
</div>
<div>2) I’m not expert in F77 but could you confirm me that there is no difference between the declaration: TA (LX1,LY1,LZ1,LELT) and TA(LT) with LT=LX1*LY1*LZ1*LELT ? I mean, an argument such as TA(1,1,1,1) will pass the whole array of TA ? </div>
<div><br>
</div>
<div>Thank you !</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div> subroutine convab</div>
<div>C---------------------------------------------------------------</div>
<div>C</div>
<div>C Eulerian scheme, add convection term to forcing function </div>
<div>C at current time step.</div>
<div>C</div>
<div>C---------------------------------------------------------------</div>
<div> include 'SIZE'</div>
<div> include 'SOLN'</div>
<div> include 'MASS'</div>
<div> include ‘TSTEP'</div>
</div>
<div><br>
</div>
<div>
<div> COMMON /SCRUZ/ TA (LX1,LY1,LZ1,LELT)</div>
<div>C</div>
<div> NEL = NELFLD(IFIELD)</div>
<div> NTOT1 = NX1*NY1*NZ1*NEL</div>
<div> CALL CONVOP (TA,T(1,1,1,1,IFIELD-1))</div>
<div> CALL COL2 (TA,VTRANS(1,1,1,1,IFIELD),NTOT1)</div>
<div> CALL SUBCOL3 (BQ(1,1,1,1,IFIELD-1),BM1,TA,NTOT1)</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div>
<div style="color:rgb(0,0,0); letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; word-wrap:break-word">
<div>Best regards,</div>
<div>Emmanuel</div>
</div>
<br class="Apple-interchange-newline">
<br class="Apple-interchange-newline">
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>