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 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C08%5Cclip_filelist.xml"><style>
<!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-alt:SimSun;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0pt;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        mso-pagination:none;
        font-size:10.5pt;
        mso-bidi-font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:宋体;
        mso-font-kerning:1.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;
        mso-header-margin:36.0pt;
        mso-footer-margin:36.0pt;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style> 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 class="MsoNormal">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 class="MsoNormal"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C09%5Cclip_filelist.xml"><style>
<!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-alt:SimSun;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0pt;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        mso-pagination:none;
        font-size:10.5pt;
        mso-bidi-font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:宋体;
        mso-font-kerning:1.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;
        mso-header-margin:36.0pt;
        mso-footer-margin:36.0pt;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style>
</p><p class="MsoNormal">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 class="MsoNormal"><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 class="MsoNormal"><br></p><p class="MsoNormal"> 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><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 11"><meta name="Originator" content="Microsoft Word 11"><link rel="File-List" href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C07%5Cclip_filelist.xml"><link rel="Edit-Time-Data" href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C07%5Cclip_editdata.mso"><style>
<!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-alt:SimSun;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;
        mso-font-charset:134;
        mso-generic-font-family:auto;
        mso-font-pitch:variable;
        mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0pt;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        mso-pagination:none;
        font-size:10.5pt;
        mso-bidi-font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:宋体;
        mso-font-kerning:1.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;
        mso-header-margin:36.0pt;
        mso-footer-margin:36.0pt;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style><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">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 class="Wj3C7c">
<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>