<?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 Re: array-valued function with VBA in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887172#M77057</link>
    <description>&lt;P&gt;Try the following &lt;C&gt;&lt;/C&gt;&lt;/P&gt;
&lt;P&gt;VBA&lt;/P&gt;
&lt;P&gt;Public Declare Functionfunc Lib "C:Winntsystem32yourfortran.dll"&lt;BR /&gt;(A1 As integer) As double&lt;/P&gt;
&lt;P&gt;FORTRAN (note:Fortran makes everything UPPERCASE by default, so the ALIAS attribute is required tosupply a lowercaseentry 'func' in the Dll's exported symbol table that VBA needs, otherwise you need to make 'func' UPPERCASE in the VBA 'Public Declare' statement.]&lt;/P&gt;
&lt;P&gt;REAL*8 FUNCTIONFUNC (N )&lt;BR /&gt;!DEC$ ATTRIBUTES DLLEXPORT,STDCALL,REFERENCE,ALIAS:'func' ::FUNC&lt;BR /&gt;INTEGER(4) N&lt;BR /&gt;.......&lt;BR /&gt;.......&lt;BR /&gt;FUNC=&lt;BR /&gt;....&lt;BR /&gt;END FUNCTION FUNC&lt;/P&gt;</description>
    <pubDate>Tue, 27 Nov 2007 12:48:09 GMT</pubDate>
    <dc:creator>anthonyrichards</dc:creator>
    <dc:date>2007-11-27T12:48:09Z</dc:date>
    <item>
      <title>array-valued function with VBA</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887171#M77056</link>
      <description>&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;I have some array-valued function in a fortran dll and &lt;SPAN&gt;&lt;/SPAN&gt;I like to use this function in VBA. &lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;function func(n) result (y)&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;implicit none&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;integer(4) :: n&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;real(8), dimension(n) :: y&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;..&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;..&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;end function func&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;Is it possible to call/declare such an array-valued function and does someone know how to do this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;Aid&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class="MsoNormal"&gt;&lt;SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2007 11:29:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887171#M77056</guid>
      <dc:creator>aid-usman</dc:creator>
      <dc:date>2007-11-27T11:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: array-valued function with VBA</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887172#M77057</link>
      <description>&lt;P&gt;Try the following &lt;C&gt;&lt;/C&gt;&lt;/P&gt;
&lt;P&gt;VBA&lt;/P&gt;
&lt;P&gt;Public Declare Functionfunc Lib "C:Winntsystem32yourfortran.dll"&lt;BR /&gt;(A1 As integer) As double&lt;/P&gt;
&lt;P&gt;FORTRAN (note:Fortran makes everything UPPERCASE by default, so the ALIAS attribute is required tosupply a lowercaseentry 'func' in the Dll's exported symbol table that VBA needs, otherwise you need to make 'func' UPPERCASE in the VBA 'Public Declare' statement.]&lt;/P&gt;
&lt;P&gt;REAL*8 FUNCTIONFUNC (N )&lt;BR /&gt;!DEC$ ATTRIBUTES DLLEXPORT,STDCALL,REFERENCE,ALIAS:'func' ::FUNC&lt;BR /&gt;INTEGER(4) N&lt;BR /&gt;.......&lt;BR /&gt;.......&lt;BR /&gt;FUNC=&lt;BR /&gt;....&lt;BR /&gt;END FUNCTION FUNC&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2007 12:48:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887172#M77057</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2007-11-27T12:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: array-valued function with VBA</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887173#M77058</link>
      <description>&lt;P&gt;I have just realised that the above will not work for ARRAYs as Visual Basic uses 'Safe arrays', which are structures that are not easily represented in Fortran.&lt;/P&gt;
&lt;P&gt;As Steve mentions below, you could examine the SAFEARRAY sample code which shows you how to convert a 2 dimensional Fortran array into a safearray. After you have generated your Fortran array of data, you could then call this code to generate a safearray from it, whose address you can then return to the calling VB program as Steve suggests, using a SUBROUTINE call rather than a FUNCTION call.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2007 14:12:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887173#M77058</guid>
      <dc:creator>anthonyrichards</dc:creator>
      <dc:date>2007-11-27T14:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: array-valued function with VBA</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887174#M77059</link>
      <description>This is harder than you think. A Fortran function returning an array looks like a subroutine with a "hidden" first argument that is the array return location. I don't think you can map this onto a VB function call returning an array. If you wanted it to look like a VB array function, you'll probably have to locate the SAFEARRAY descriptor that VB passes and fill it in. You can see an example of SAFEARRAY code in the MixedLanguageVB.NET-Safearray sample.&lt;BR /&gt;&lt;BR /&gt;It would be easier if you called this from VB as a subroutine passing the first element of the array "return" as the first argument.&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Nov 2007 14:16:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/array-valued-function-with-VBA/m-p/887174#M77059</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-27T14:16:10Z</dc:date>
    </item>
  </channel>
</rss>

