<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri, sans-serif" size="2">
<div>Hello, I have a question regarding how to set up the IFunction for TSSetIFunction. Please see the detailed illustration below:</div>
<div> </div>
<div>Inside my IFunction, I have one of the f equations defined as:</div>
<div> </div>
<div>if (i >= xstart && i < xstart+xlen) {</div>
<div> f[i+2] = sin(x[i])*x[i+2] + cos(x[i])*x[i+3];</div>
<div> for (k = 0; k < n; k++) {</div>
<div> f[i+2] += -(cos(x[k])*a[k])*b) - (sin(x[k])*c[k])*d); (1)</div>
<div> }</div>
<div>}</div>
<div style="text-indent: 9pt; "><font face="Times New Roman, serif"> </font></div>
<div>Where x is an distributed array, a and c are constant arrays, b and d are constants. n is the length of the global length of x.</div>
<div style="text-indent: 9pt; "><font face="Times New Roman, serif"> </font></div>
<div>The problem is, since x is distributed across all the processes, each process only owns a piece of items of x, when I do (1) as written above, no matter which processor f[i+2] is on, it has to grab all the x array data from other processors, which means
I have to do a scattering of x array in advance to make the x[k] value available. This is quite an inefficient way given the scattering of vector would happen in each iteration when the IFuntion is called.</div>
<div> </div>
<div>I am wondering if this is the only way I have to deal with this problem, or am I trapped in a wrong direction?</div>
<div> </div>
<div>Your comments are highly appreciated!</div>
<div> </div>
<div>Thanks,</div>
<div>Shuangshuang</div>
<div><font face="Times New Roman, serif"> </font></div>
<div><font face="Times New Roman, serif"> </font></div>
</font>
</body>
</html>