<?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: Floating point control problem when call fortran dll from R in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850340#M65711</link>
    <description>&lt;P&gt;OK, I'll take you at your word.&lt;/P&gt;
&lt;P&gt;So show me howto export a &lt;STRONG&gt;&lt;FONT size="4"&gt;variable&lt;/FONT&gt;&lt;/STRONG&gt; from a dl, and I don't mean as an argument of an exported procedure. Here's what I'd like to do:&lt;/P&gt;
&lt;P&gt;This is thedll,&lt;/P&gt;
&lt;P&gt;subroutine Let()&lt;/P&gt;
&lt;P&gt;real x&lt;/P&gt;
&lt;P&gt;x = 6.&lt;/P&gt;
&lt;P&gt;end subroutine Let&lt;/P&gt;
&lt;P&gt;I'd like the variable xto be exported by the dll and nothing else. Feel free touse whatever metacommands you deem necessary. When the client loads the dll it should be aware ofthe type and current value of the variable x.&lt;/P&gt;
&lt;P&gt;If you like I, as customer. can submit this toPremier Support but I'm sure you'll be able to handle it off the top.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Gerry&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jul 2008 04:21:53 GMT</pubDate>
    <dc:creator>g_f_thomas</dc:creator>
    <dc:date>2008-07-28T04:21:53Z</dc:date>
    <item>
      <title>Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850330#M65701</link>
      <description>Hey guys, I encountered some problems when I tried to call fortran dll from R, a statistical package. my fortran dll is compiled based on intel fortran 10.x for window, MS visual studio 2005, and IMSL 6.0. when I try to load the dll into R, R report a warnming message "DLL attempted to change FPU control word from 8001f to 9001f". I just googled this problem, and a solution given by &lt;FONT size="2"&gt;&lt;FONT face="Arial MT Black"&gt;Duncan
    Murdoch @ &lt;A href="http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/#fpu" target="_blank"&gt;http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/#fpu&lt;/A&gt; &lt;BR /&gt;is as follows&lt;BR /&gt;"&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;&lt;I&gt;R sets the floating point control word using the R.dll function Rwin_fpset.  This sets the FPU to mask
all exceptions, use 64 bit precision, and round to nearest or even.

&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;R expects all calls to DLLs (including the initializing call) to leave the FPU control word unchanged.  Many
run-time libraries reset the FPU control word during initialization; this will cause problems in R, and will
result in a warning message like "DLL attempted to change FPU control word from 8001f to 9001f".  The
value 8001f that gets reported is in the format expected by the C library routine &lt;TT&gt;_controlfp&lt;/TT&gt;;
the raw value that is used in the FPU register is &lt;TT&gt;037F&lt;/TT&gt;.

&lt;/I&gt;&lt;/P&gt;&lt;I&gt;&lt;B&gt;If you can't tell your compiler to generate a DLL that leaves the FPU alone&lt;/B&gt;, then you need to be sure to
restore it to R's value before returning to R.  See the &lt;A href="http://www.stats.uwo.ca/faculty/murdoch/software/compilingDLLs/pascal.html#registers"&gt;Delphi section&lt;/A&gt;
for an example of how to do this in that language.
&lt;/I&gt;
&lt;FONT size="2"&gt;&lt;FONT face="Arial MT Black"&gt;"&lt;BR /&gt;&lt;BR /&gt;However, I do not quite follow his method. It seems that the best way is to tell intel fortran to generate a DLL that leaves the FPU alone. How can I do that then? Thanks a lot! &lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description>
      <pubDate>Fri, 25 Jul 2008 17:46:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850330#M65701</guid>
      <dc:creator>axm</dc:creator>
      <dc:date>2008-07-25T17:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850331#M65702</link>
      <description>To the best of my knowledge, there's no code added by the Fortran compiler to change the FP status registers except in a main program. I make no promises about IMSL. It would be worth creating a test case that did not call IMSL to test that.&lt;BR /&gt;&lt;BR /&gt;I suppose you could call FOR_GET_FPE at the entry to your DLL, save the value, then call FOR_SET_FPE with that value before returning. That may do the trick. Both of these are documented in the Language Reference.&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jul 2008 18:11:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850331#M65702</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-07-25T18:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850332#M65703</link>
      <description>Intel Fortran should make permanent changes to FPU control word only in a main program, which are done in accordance with Microsoft practice (53-bit precision, for 32-bit mode). I suspect you would have to reset the value explicitly, if you have a Fortran main program. Among the methods for doing that would be C functions which use _controlfp(). I don't know whether the CVF methods for controlling it are still available.&lt;BR /&gt;If you are concerned also about the SSE control, the option /Qftz- (when compiling a Fortran main program) will leave gradual underflow set.&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jul 2008 18:19:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850332#M65703</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2008-07-25T18:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850333#M65704</link>
      <description>Hi Steve, Thanks for your suggestion. I just remove the IMSL function from my testing code, and R do not report warning anymore, but it can still not load the fortran function into R successfully. on the same website I mentioned before they also mentioned this problem as follows&lt;BR /&gt;"&lt;BR /&gt;&lt;A name="badname"&gt;&lt;H3&gt;is.loaded() returning FALSE&lt;/H3&gt;&lt;/A&gt;

&lt;P&gt;When R uses &lt;TT&gt;dyn.load()&lt;/TT&gt; to load a DLL, it relies on the DLL's export
table to find functions.  Many compilers use fairly obscure methods to get a function name into the export
table.  If you don't follow them exactly, your function won't be available to R.

&lt;/P&gt;Some compilers (e.g. g77, as mentioned above)
make changes to the function names before putting them in the export table.  If
you specify the original name, R may not be able to find the entry point."&lt;BR /&gt;&lt;BR /&gt;do you know how intel fortran get a function name into the export table? Thanks!&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jul 2008 18:47:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850333#M65704</guid>
      <dc:creator>axm</dc:creator>
      <dc:date>2008-07-25T18:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850334#M65705</link>
      <description>If you mean the external name of the function, the default for Intel Fortran windows is all uppercase identifier, with no appended underscores. It's controlled by the options /Quppercase or lowercase, and /us. Also, it may be controlled by $DEC directives or iso_c_binding.&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jul 2008 19:09:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850334#M65705</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2008-07-25T19:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850335#M65706</link>
      <description>You need to supply a !DEC$ ATTRIBUTES DLLEXPORT that names the routine. You can optionally use the ALIAS attribute to specify the exact external spelling, otherwise, as Tim notes, you need to know what the conventions are. &lt;BR /&gt;&lt;BR /&gt;There is the notion of a special name for an import library, which is automatically generated by the compiler when you use DLLEXPORT, but that does not apply when doing a dynamic load of the DLL directly, as you are.&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jul 2008 19:14:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850335#M65706</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-07-25T19:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850336#M65707</link>
      <description>&lt;P&gt;Look here&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.geocities.com/yongweiwu/stdcall.htm"&gt;http://www.geocities.com/yongweiwu/stdcall.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and see the part about .def which trumps all.&lt;/P&gt;
&lt;P&gt;Gerry&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jul 2008 23:44:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850336#M65707</guid>
      <dc:creator>g_f_thomas</dc:creator>
      <dc:date>2008-07-25T23:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850337#M65708</link>
      <description>.def cannot be used when exporting a variable from a DLL (or importing same.) It can be used for routines.&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Jul 2008 23:54:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850337#M65708</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-07-25T23:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850338#M65709</link>
      <description>&lt;P&gt;The exports being discussed hereare functions/subroutines from a DLL for which .def's arewell suited, that's why Microsoft introduced them and encourages their use.&lt;/P&gt;
&lt;P&gt;Up to your assertion,I've never heard of anyone exporting or importing a variable from a DLL, with or without .def. It's not done. Perhaps you're alluding to 'sharing' data as discussed in a different thread. Piff...&lt;/P&gt;
&lt;P&gt;Gerry&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jul 2008 01:26:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850338#M65709</guid>
      <dc:creator>g_f_thomas</dc:creator>
      <dc:date>2008-07-26T01:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850339#M65710</link>
      <description>You may not have heard of it, Gerry, but I can assure you that many of our customers do it based on the questions and issues we get on this topic. While it may not be an issue for the issue in this thread, I mentioned it because .def files are not a panacea. With DLLEXPORTed variables, the compiler needs to add an extra level of indirection to each reference and it can't do that if it doesn't see the directive.&lt;BR /&gt;</description>
      <pubDate>Sat, 26 Jul 2008 09:48:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850339#M65710</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-07-26T09:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850340#M65711</link>
      <description>&lt;P&gt;OK, I'll take you at your word.&lt;/P&gt;
&lt;P&gt;So show me howto export a &lt;STRONG&gt;&lt;FONT size="4"&gt;variable&lt;/FONT&gt;&lt;/STRONG&gt; from a dl, and I don't mean as an argument of an exported procedure. Here's what I'd like to do:&lt;/P&gt;
&lt;P&gt;This is thedll,&lt;/P&gt;
&lt;P&gt;subroutine Let()&lt;/P&gt;
&lt;P&gt;real x&lt;/P&gt;
&lt;P&gt;x = 6.&lt;/P&gt;
&lt;P&gt;end subroutine Let&lt;/P&gt;
&lt;P&gt;I'd like the variable xto be exported by the dll and nothing else. Feel free touse whatever metacommands you deem necessary. When the client loads the dll it should be aware ofthe type and current value of the variable x.&lt;/P&gt;
&lt;P&gt;If you like I, as customer. can submit this toPremier Support but I'm sure you'll be able to handle it off the top.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Gerry&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2008 04:21:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850340#M65711</guid>
      <dc:creator>g_f_thomas</dc:creator>
      <dc:date>2008-07-28T04:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850341#M65712</link>
      <description>Here's how you have to do it:&lt;BR /&gt;&lt;BR /&gt;module mymod&lt;BR /&gt;real x&lt;BR /&gt;!dec$ attributes dllexport :: x&lt;BR /&gt;contains&lt;BR /&gt;subroutine Let ()&lt;BR /&gt;!dec$ attributes dllexport :: Let&lt;BR /&gt;x = 6&lt;BR /&gt;end subroutine Let&lt;BR /&gt;end module mymod&lt;BR /&gt;&lt;BR /&gt;Build this into a DLL. Now in your executable project, add:&lt;BR /&gt;&lt;BR /&gt;use mymod&lt;BR /&gt;&lt;BR /&gt;Add to the INCLUDE path of the executable the output directory of the DLL project so that it can see mymod.mod and make the DLL project a dependent of the executable, or add the import library to the executable. Build the executable.&lt;BR /&gt;&lt;BR /&gt;The USE of a module that contains a DLLEXPORT treats it as a DLLIMPORT. The variable and its type will be defined (and the subroutine) as long as you have the USE. I am not sure why you asked for the variable to be exported "and nothing else", though I guess if you are using a .def file you might want to keep that. I'm not sure how .def files mix with DLLIMPORT/EXPORT directives and would suggest you use the directives only.&lt;BR /&gt;&lt;BR /&gt;There is a sample provided, DLLDLL_Shared_Data, which demonstrates this technique.&lt;BR /&gt;&lt;BR /&gt;You can't export a local variable of a subroutine - it has to be something that Fortran considers global. You can also DLLEXPORT a COMMON block.&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Jul 2008 12:34:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850341#M65712</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-07-28T12:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850342#M65713</link>
      <description>&lt;P&gt;Thanks, but I knew all that. However, who says the executable is written in Fortran? What now?&lt;/P&gt;
&lt;P&gt;Gerry&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2008 18:22:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850342#M65713</guid>
      <dc:creator>g_f_thomas</dc:creator>
      <dc:date>2008-07-28T18:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850343#M65714</link>
      <description>Well, if the executable is not Fortran, then the type information is not available. C++ supports DLLimported variables, but most other languages on Windows (VB to name one) do not. Modular programming would have you write access (get and set) routines (which most any language can deal with) rather than make the variable itself visible. This is an approach I prefer, and it even works with managed code. You can, I suppose, write a routine that returns a pointer to the variable and then you use the language's methods for accessing through pointers, but I consider that ugly (and probably fails with managed code.)&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Jul 2008 18:34:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850343#M65714</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-07-28T18:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850344#M65715</link>
      <description>&lt;P&gt;Exactly, that's what I was implying all along. For imported variables, VB6 no, VB.Net, don't know, don't care.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Gerry&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2008 18:41:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850344#M65715</guid>
      <dc:creator>g_f_thomas</dc:creator>
      <dc:date>2008-07-28T18:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850345#M65716</link>
      <description>Well, why didn't you say so? This is a Fortran forum, not a VB forum, after all...&lt;BR /&gt;</description>
      <pubDate>Mon, 28 Jul 2008 19:02:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850345#M65716</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-07-28T19:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Floating point control problem when call fortran dll from R</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850346#M65717</link>
      <description>&lt;P&gt;You are being rude, but what's new!&lt;/P&gt;
&lt;P&gt;I never implied that I was using VB, I don't. FYI, dllexport/import isn't partof C anymore than its a part of Fortran. The OP was clearly interested in Fortran portability, something you failed to appreciate.&lt;/P&gt;
&lt;P&gt;Gerry&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2008 19:57:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Floating-point-control-problem-when-call-fortran-dll-from-R/m-p/850346#M65717</guid>
      <dc:creator>g_f_thomas</dc:creator>
      <dc:date>2008-07-28T19:57:49Z</dc:date>
    </item>
  </channel>
</rss>

