Hi, <br> It runs fine with the "-localonly" and "-localroot" option. <br> Really don't understand why it cannot call dll using "-n 1" option. (This program should be run in multiple computers).<br>
Regards,<br>Vivian<br><br><div class="gmail_quote">On Fri, Dec 5, 2008 at 6:01 PM, Jayesh Krishna <span dir="ltr"><<a href="mailto:jayesh@mcs.anl.gov">jayesh@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span>Hi,</span></font></div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span> Can you also try whether the program runs fine
with the "-localroot" option ?</span></font></div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span>Regards,</span></font></div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span>Jayesh</span></font></div><br>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font size="2" face="Tahoma"><b>From:</b> Vivian [mailto:<a href="mailto:viviantj@gmail.com" target="_blank">viviantj@gmail.com</a>]
<br><b>Sent:</b> Friday, December 05, 2008 11:30 AM<br><b>To:</b> Jayesh
Krishna<br><b>Cc:</b> <a href="mailto:mpich-discuss@mcs.anl.gov" target="_blank">mpich-discuss@mcs.anl.gov</a><br><b>Subject:</b> Re:
[mpich-discuss] problem of calling .dll in mpich<br></font><br></div><div><div></div><div class="Wj3C7c">
<div></div>Hi, <br> I attached the
sample test program which fails to call dll when it is run by "mpiexec -n 1
application name". <br> (Btw, when using "mpiexec
-localonly application name", dll can be
called.)<br> <br>The DLL called in the
program is
a Dynamic Link Library (DLL) provided by ArcView ( a GIS software) for use with
WinHelp that lets you run a script. The DLL contains two functions that you can
use as WinHelp macros.
<p>AVRun -- this macro sends an Avenue statement from Help to
ArcView. For example, you might send a statement to make a particular view the
active document or run a script contained in the current project.</p>
<p>
</p>
<p>AVScript -- this macro runs a given script regardless of what
ArcView project is open. The script, in this case, is stored as part of the Help
file and not in an ArcView project.</p>
<p><br></p>Here's how you could run a script in the current
ArcView project file and pass an argument to it. In this case, the number 5 is
passed as an argument to a script, named script1, in the
project:<br>AVRun(`av.Run("script1", 5)')
<p></p>
<p><br></p>
<p> Here is the sample test
code<br></p>------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>#include<iostream><br>#include
<windows.h> <br><br>/*Some users may get error messages such
as<br> SEEK_SET is #defined but must not be
for the C++ binding of MPI<br> The problem is that both stdio.h and
the MPI C++ interface use SEEK_SET, SEEK_CUR, and SEEK_END. <br>
This is really a bug in the MPI-2 standard. You can try adding the following
three lines before mpi.h is included<br>*/<br>#undef SEEK_SET<br>#undef
SEEK_END<br>#undef SEEK_CUR<br>#include "mpi.h"<br><br>typedef char (__stdcall
*AVRUN) (char[100]); <br>HINSTANCE ArcviewDLL;<br>AVRUN AVRun;<br><br>int
main(int argc,char **argv)<br>{<br><br> //load avhelp.dll
<br> ArcviewDLL= LoadLibraryA("Avhelp.dll");
//It needs a Unicode string. Therefore, we use LoadLibraryA() instead of
LoadLibrary() <br> if
(ArcviewDLL==NULL)<br>
{<br> printf("cannot load the
Avhelp.dll.\n");<br> printf("Make sure
that the Avhelp.dll is in your \\windows\\system
"<br>
"directory or in the program's directory.\n");<br>
}<br><br> //get the adress of the AVRun function
<br> AVRun = (AVRUN) GetProcAddress(ArcviewDLL,
"AVRun");<br><br> //================================== Start
MPI =======================================//<br> //MPI :
Declar Variables<br> int my_rank;
// Rank of process
<br> int num_proc;
// Number of
processers<br>
<br> //MPI :
Initialize<br> MPI_Init(&argc,
&argv);<br> MPI_Comm_rank(MPI_COMM_WORLD,
&my_rank);<br> MPI_Comm_size(MPI_COMM_WORLD,
&num_proc);<br><br><br> // -------- master Program
----------------//<br> if (my_rank==0)
// Master processor<br>
{<br> //-------------Start call dll
--------------// <br>
ArcviewDLL= LoadLibraryA("Avhelp.dll");
<br> AVRun = (AVRUN)
GetProcAddress(ArcviewDLL,
"AVRun");<br> std::cout<<"Start
Calling DLL"<<std::endl;<br>
AVRun("av.run(\"HAO_script3\",\"\")");<br>
std::cout<<"End Calling DLL"<<std::endl;<br><br>
//MasterWork_MPI();<br>
//-------------End call dll---------------//<br>
}<br><br> // --------slave Program
------------------//<br> else<br>
{
<br>
//SlaveWork_MPI();<br> }<br><br>
MPI_Finalize(); <br><br> //================================
End MPI ====================================//<br> return
0;<br>}<br><br> <br>
<span style="font-size: 10.5pt; font-family: 'Times New Roman';"></span>Vivian<br>12/05/2008<br><br><br><br>
<div class="gmail_quote">On Fri, Dec 5, 2008 at 10:03 AM, Jayesh Krishna <span dir="ltr"><<a href="mailto:jayesh@mcs.anl.gov" target="_blank">jayesh@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span>Hi,</span></font></div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span> Can
you send us a sample test program that fails ?</span></font></div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span>Regards,</span></font></div>
<div dir="ltr" align="left"><font size="2" color="#0000ff" face="Arial"><span>Jayesh</span></font></div><font size="2" color="#0000ff" face="Arial"></font><br>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font size="2" face="Tahoma"><b>From:</b> <a href="mailto:mpich-discuss-bounces@mcs.anl.gov" target="_blank">mpich-discuss-bounces@mcs.anl.gov</a> [mailto:<a href="mailto:mpich-discuss-bounces@mcs.anl.gov" target="_blank">mpich-discuss-bounces@mcs.anl.gov</a>] <b>On Behalf Of
</b>Vivian<br><b>Sent:</b> Friday, December 05, 2008 12:05 AM<br><b>To:</b> <a href="mailto:mpich-discuss@mcs.anl.gov" target="_blank">mpich-discuss@mcs.anl.gov</a><br><b>Subject:</b> [mpich-discuss]
problem of calling .dll in mpich<br></font><br></div>
<div>
<div></div>
<div>
<div></div>Hi,<br> I met some problems when I
was trying to call a dll in a mpich program (Language:VS
2005).<br> (1) MPICH seems to only support
calling convention _cdecl. <br> When I
change the project setting to _stdcall, the code cannot be successfully
built.<br> So I set the
project setting back to _cdecl and force the calling convention of the
function pointer to my function on the DLL to be "_stdcall". This time the
program is built. <br>
Under debugging mode or directly run in command window ( c:>test.ext),
there is no problem to call dll in the code.<br>
Here is the code:<br>
--------------------------------------------------------------------------------
<br> typedef char (__stdcall *AVRUN)
(char[100]); <br> HINSTANCE ArcviewDLL;
<br> AVRUN AVRun;<br>
ArcviewDLL= LoadLibraryA("Avhelp.dll");
<br> AVRun = (AVRUN) GetProcAddress(ArcviewDLL,
"AVRun");<br><br>
AVRun("av.run(\"HAO_script3\",\"\")");<br>
-------------------------------------------------------------------------------<br><br>
(2) However, the program fails to call dll when I use "mpiexec" to run it.
(c:>mpiexec -n 1
test.exe).<br> It
seems to "stop" right before this line<br>
-------------------------------------------------------------<br>
AVRun("av.run(\"HAO_script3\",\"\")");<br>
-------------------------------------------------------------<br>
Is there anyone having any idea why this happens?<br clear="all"><br>--<br>Vivian<br></div></div></div></blockquote></div><br></div></div></div>
</blockquote></div>