<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16735" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=304200023-05122008>Hi,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=304200023-05122008> Can you also try whether the program runs fine
with the "-localroot" option ?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=304200023-05122008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=304200023-05122008>Regards,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=304200023-05122008>Jayesh</SPAN></FONT></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Vivian [mailto:viviantj@gmail.com]
<BR><B>Sent:</B> Friday, December 05, 2008 11:30 AM<BR><B>To:</B> Jayesh
Krishna<BR><B>Cc:</B> mpich-discuss@mcs.anl.gov<BR><B>Subject:</B> Re:
[mpich-discuss] problem of calling .dll in mpich<BR></FONT><BR></DIV>
<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
<META content=Word.Document name=ProgId>
<META content="Microsoft Word 11" name=Generator>
<META content="Microsoft Word 11" name=Originator><LINK
href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C08%5Cclip_filelist.xml"
rel=File-List>
<STYLE>UNKNOWN {
        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 content=Word.Document name=ProgId>
<META content="Microsoft Word 11" name=Generator>
<META content="Microsoft Word 11" name=Originator><LINK
href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C09%5Cclip_filelist.xml"
rel=File-List>
<STYLE>UNKNOWN {
        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 content=Word.Document name=ProgId>
<META content="Microsoft Word 11" name=Generator>
<META content="Microsoft Word 11" name=Originator><LINK
href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C07%5Cclip_filelist.xml"
rel=File-List><LINK
href="file:///C:%5CDOCUME%7E1%5CNINGYA%7E1%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C07%5Cclip_editdata.mso"
rel=Edit-Time-Data>
<STYLE>UNKNOWN {
        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="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN>Hi,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN> Can
you send us a sample test program that fails ?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN>Regards,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff
size=2><SPAN>Jayesh</SPAN></FONT></DIV><FONT face=Arial color=#0000ff
size=2></FONT><BR>
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><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></BODY></HTML>