<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic This code is almost right., in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929791#M87541</link>
    <description>&lt;P&gt;This code is almost right., First, you don't need /iface here. Second, when you use BIND(C), there are no hidden arguments, so you have declared it right. The only thing I see as a problem is that get_command_argument will not put a NUL at the end of the string, which the C code will want. Since you're getting the length back in nlen, you can use that.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Feb 2013 17:54:10 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2013-02-13T17:54:10Z</dc:date>
    <item>
      <title>Cross compiling problem of getarg</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929778#M87528</link>
      <description />
      <pubDate>Thu, 31 Jan 2013 20:50:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929778#M87528</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-01-31T20:50:45Z</dc:date>
    </item>
    <item>
      <title>Why are you calling the</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929779#M87529</link>
      <description>&lt;P&gt;Why are you calling the Fortran internal&amp;nbsp; run-time library routines from C?&amp;nbsp; That's not supported.&lt;/P&gt;
&lt;P&gt;I think your prototype of for_getarg is wrong. I'd expect there to be four arguments to it (the character argument takes an address and length, and you need to supply a NULL for the status argument if not using it. Why you use "short" I also don't understand.&lt;/P&gt;
&lt;P&gt;If you want the Fortran functionality, write a Fortran routine that calls getarg and call that - or use GET_COMMAND_ARGUMENT.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 21:02:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929779#M87529</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-01-31T21:02:22Z</dc:date>
    </item>
    <item>
      <title>Could you drop the legacy</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929780#M87530</link>
      <description>&lt;P&gt;Could you drop the legacy hacks and use get_command_argument ?&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 21:06:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929780#M87530</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2013-01-31T21:06:22Z</dc:date>
    </item>
    <item>
      <title>Quote:Steve Lionel (Intel)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929781#M87531</link>
      <description>&lt;P&gt;removed&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 21:29:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929781#M87531</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-01-31T21:29:00Z</dc:date>
    </item>
    <item>
      <title>Quote:TimP (Intel) wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929782#M87532</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;TimP (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Could you drop the legacy hacks and use get_command_argument ?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi TimP.&amp;nbsp;I am compiling a library and there is a same error. That's not my idea.&lt;/P&gt;
&lt;P&gt;Trust me. I'd use getarg/get_command_argument, not the functions in my post for my own code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for the confuse.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 21:36:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929782#M87532</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-01-31T21:36:24Z</dc:date>
    </item>
    <item>
      <title>That's the correct page for</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929783#M87533</link>
      <description>&lt;P&gt;That's the correct page for the GETARG intrinsic. But the internal routine it calls will actually have four arguments - the argument number, address of character string, address of status argument (or 0 if omitted), and a "size_t" integer for the length of the character argument, passed by value. You are passing the wrong datatypes and passing the length by reference rather than value. You're lucky you got an access violation given how wrong this code is. &lt;/P&gt;
&lt;P&gt;Rather than trying to patch it over, please do it right.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 22:09:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929783#M87533</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-01-31T22:09:52Z</dc:date>
    </item>
    <item>
      <title>Quote:Steve Lionel (Intel)</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929784#M87534</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;Steve Lionel (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;That's the correct page for the GETARG intrinsic. But the internal routine it calls will actually have four arguments - the argument number, address of character string, address of status argument (or 0 if omitted), and a "size_t" integer for the length of the character argument, passed by value. You are passing the wrong datatypes and passing the length by reference rather than value. You're lucky you got an access violation given how wrong this code is.&lt;/P&gt;
&lt;P&gt;Rather than trying to patch it over, please do it right.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks Steve. Now I get it.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 22:17:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929784#M87534</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-01-31T22:17:29Z</dc:date>
    </item>
    <item>
      <title>In line with what Steve said,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929785#M87535</link>
      <description>&lt;P&gt;In line with what Steve said, internal implementations of the legacy getarg function will differ among various Fortran implementations; besides, a web search shows open source implementations with little documentation which may have been copied from libf2c (an early implementation of F77 runtime).&amp;nbsp; Although that was last used with g77, normal usage would not have involved calling the internal C implementation directly, even when using Fortran compilation based on f2c.&amp;nbsp; So, using poorly conceived open source which depends on a particular seldom used interface has limitations.&amp;nbsp; libf2c functions will conflict with the run-time libraries of current Fortran compilers.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 22:40:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929785#M87535</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2013-01-31T22:40:04Z</dc:date>
    </item>
    <item>
      <title>Quote:TimP (Intel) wrote:</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929786#M87536</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;TimP (Intel) wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;In line with what Steve said, internal implementations of the legacy getarg function will differ among various Fortran implementations; besides, a web search shows open source implementations with little documentation which may have been copied from libf2c (an early implementation of F77 runtime).&amp;nbsp; Although that was last used with g77, normal usage would not have involved calling the internal C implementation directly, even when using Fortran compilation based on f2c.&amp;nbsp; So, using poorly conceived open source which depends on a particular seldom used interface has limitations.&amp;nbsp; libf2c functions will conflict with the run-time libraries of current Fortran compilers.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks TimP. I don't know much about libf2c. I am not sure whether the code that I am compiling has any relationship to libf2c. But thanks for telling me the knowledge. Here is the link for the code (maybe you want to take a look):&amp;nbsp;https://bitbucket.org/petsc/petsc-3.3/src/70ed804d1752b201e3262bb8d1826a110fee28fe/src/sys/ftn-custom/zstart.c&lt;/P&gt;
&lt;P&gt;You are right. I am compiling it for personal use currently. I am not a pro like you, so I just want to have it compiled...&lt;/P&gt;
&lt;P&gt;The error goes away when I use for_getcmd_arg with four prameters (that I followed Steve's suggestion) instead of for_getarg with three prameters. But I still don't understand how things work. So far it seems that GET_COMMAND_ARGUMENT works like a macro. And will be replaced by for_getarg when there are 3 prameters, by for_getcmd_arg when 4. I don't see why for_getcmd_arg gives no error message but for_getarg does. If you use&amp;nbsp;GET_COMMAND_ARGUMENT in the c code (getarg.c), it will fail when linking.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2013 23:07:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929786#M87536</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-01-31T23:07:36Z</dc:date>
    </item>
    <item>
      <title>GET_COMMAND_ARGUMENT is not a</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929787#M87537</link>
      <description>GET_COMMAND_ARGUMENT is not a macro, it's a standard intrinsic subroutine.  It just happens to do the same thing as GETARG (at least the way we have implemented it), so we may have chosen to use the same library routine for it. I didn't mean that you should use GET_COMMAND_ARGUMENT in the C code, but rather in the Fortran code.

On Windows, you could just call the C getarg and iargc and stop messing with the Fortran internal library.</description>
      <pubDate>Thu, 31 Jan 2013 23:45:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929787#M87537</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-01-31T23:45:47Z</dc:date>
    </item>
    <item>
      <title>Sorry for messing the Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929788#M87538</link>
      <description>&lt;P&gt;Sorry for messing the Fortran internal library. It seems my post makes intel developer feel bad. And I did something improper. I shall remove all of my posts. I wanted to know how, not to hurt you.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2013 00:09:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929788#M87538</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-02-01T00:09:49Z</dc:date>
    </item>
    <item>
      <title>You haven't hurt anyone but</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929789#M87539</link>
      <description>You haven't hurt anyone but yourself. I am certainly not offended in any way - just trying to set you on the right path.</description>
      <pubDate>Fri, 01 Feb 2013 00:16:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929789#M87539</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-02-01T00:16:08Z</dc:date>
    </item>
    <item>
      <title>Hi Steve and Timp,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929790#M87540</link>
      <description>&lt;P&gt;Hi Steve and Timp,&lt;/P&gt;
&lt;P&gt;I read a lot last week. Now I understand you better. Sorry for the misunderstood 2 weeks ago. I didn't have enough knowledge that day when I discuss this problem. So this time, would you please take a look at my code? Hope I did it OK this time. I appreciate your patient and time.&lt;/P&gt;
&lt;P&gt;Fortran side:&lt;/P&gt;
&lt;P&gt;[fortran]&lt;/P&gt;
&lt;P&gt;subroutine getstring(number, name, nlen, status) bind(C,name='mygetarg') &lt;BR /&gt; use, intrinsic :: iso_c_binding&lt;BR /&gt; implicit none&lt;BR /&gt; integer(kind=c_int), intent(IN) :: number&lt;BR /&gt; character(kind=c_char), dimension(256), intent(INOUT) :: name&lt;BR /&gt; integer(kind=c_int), intent(INOUT) :: nlen&lt;BR /&gt; integer(kind=c_int), intent(INOUT) :: status&lt;BR /&gt; character(len=256) :: name_tmp&lt;BR /&gt; &lt;BR /&gt; call get_command_argument(number, name_tmp, nlen, status)&lt;BR /&gt; name=transfer(name_tmp, name)&lt;BR /&gt; end subroutine getstring&lt;/P&gt;
&lt;P&gt;[/fortran]&lt;/P&gt;
&lt;P&gt;c side:&lt;/P&gt;
&lt;P&gt;[cpp]&lt;/P&gt;
&lt;P&gt;extern void mygetarg(int*,char*,int*,int*);&lt;/P&gt;
&lt;P&gt;int nlen, status;&lt;BR /&gt; int ishift = i+1;&lt;/P&gt;
&lt;P&gt;char&amp;nbsp;name[256];&lt;BR /&gt;mygetarg(&amp;amp;ishift,name,&amp;amp;nlen, &amp;amp;status);&lt;/P&gt;
&lt;P&gt;[/cpp]&lt;/P&gt;
&lt;P&gt;fortran code compiled with&amp;nbsp;/iface:cref.&lt;/P&gt;
&lt;P&gt;Here I am not sure about the "Character-length argument passing". Does it mean I have to write subroutine with four arguments in fortran, and extern void mygetarg with 5 arguments in c to make it right? What will happen if they don't match?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2013 17:30:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929790#M87540</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-02-13T17:30:00Z</dc:date>
    </item>
    <item>
      <title>This code is almost right.,</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929791#M87541</link>
      <description>&lt;P&gt;This code is almost right., First, you don't need /iface here. Second, when you use BIND(C), there are no hidden arguments, so you have declared it right. The only thing I see as a problem is that get_command_argument will not put a NUL at the end of the string, which the C code will want. Since you're getting the length back in nlen, you can use that.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2013 17:54:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929791#M87541</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2013-02-13T17:54:10Z</dc:date>
    </item>
    <item>
      <title>Thanks Steve! I'll add a 0 in</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929792#M87542</link>
      <description>&lt;P&gt;Thanks Steve! I'll add a 0 in the end of the string.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2013 20:02:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Cross-compiling-problem-of-getarg/m-p/929792#M87542</guid>
      <dc:creator>FortCpp</dc:creator>
      <dc:date>2013-02-13T20:02:10Z</dc:date>
    </item>
  </channel>
</rss>

