<?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 type, parameter, bind(c,name='myName' :: iConst = 2  in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899442#M80488</link>
    <description>&lt;P&gt;The debugger does not see them either (which is unfortunate at times)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Arjen&lt;/P&gt;</description>
    <pubDate>Fri, 05 Feb 2010 14:36:10 GMT</pubDate>
    <dc:creator>Arjen_Markus</dc:creator>
    <dc:date>2010-02-05T14:36:10Z</dc:date>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899440#M80486</link>
      <description>&lt;P&gt;Interoperability with C for Fortran parameters:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Why can one not use the parameter key word when trying to make a variable seen on the C side.&lt;/P&gt;
&lt;P&gt;This works:&lt;/P&gt;
&lt;P&gt;integer(4), bind(c,name='myName') :: myname&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;This does not (C side can not find the name)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;integer(4), parameter, bind(C,name-'myConst') :: myConst = 3&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2010 14:21:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899440#M80486</guid>
      <dc:creator>john3</dc:creator>
      <dc:date>2010-02-05T14:21:07Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899441#M80487</link>
      <description>I don't expect that to work with parameters at all: a parameter is not a variable, and does not have necessarily any storage associated (i.e. it is a compile-time only thing, linker does not even see it), thus there's nothing to &lt;I&gt;bind&lt;/I&gt; in the general case. However, I'd expect the compiler to complain here. &lt;BR /&gt;</description>
      <pubDate>Fri, 05 Feb 2010 14:31:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899441#M80487</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2010-02-05T14:31:22Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899442#M80488</link>
      <description>&lt;P&gt;The debugger does not see them either (which is unfortunate at times)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Arjen&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2010 14:36:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899442#M80488</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2010-02-05T14:36:10Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899443#M80489</link>
      <description>&lt;P&gt;The debugger can see parameters if you enable the /debug:parameter option.&lt;/P&gt;
&lt;P&gt;Jugoslav has the correct explanation for the original question. He is also correct in saying that the compiler should complain - I will report this.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2010 15:48:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899443#M80489</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-02-05T15:48:29Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899444#M80490</link>
      <description>&lt;P&gt;I did not know that - useful to know, indeed.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Arjen&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2010 15:54:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899444#M80490</guid>
      <dc:creator>Arjen_Markus</dc:creator>
      <dc:date>2010-02-05T15:54:09Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899445#M80491</link>
      <description>&lt;P&gt;OK, that makes sense. So, how would one have the same set of constants on Fortran and C side where they would be specified, say, only on the Fortran side?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2010 16:01:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899445#M80491</guid>
      <dc:creator>john3</dc:creator>
      <dc:date>2010-02-05T16:01:23Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899446#M80492</link>
      <description>&lt;P&gt;There's no way to do that, unless you have some sort of tool that automatically translates C #defines to Fortran PARAMETER. Really, C doesn't have the exact equivalent of PARAMETER.&lt;/P&gt;
&lt;P&gt;I suppose another option is to have a .h file that has the #define declarations and then #include this into Fortran with the preprocessor enabled. It's not quite the same as PARAMETER but may do what you want.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2010 16:13:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899446#M80492</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-02-05T16:13:01Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899447#M80493</link>
      <description>&lt;P&gt;My work around was to use C enum and Fortran enum with a series of parameters. Each side (C and Fortran) then evaluate the enum's to the same values.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;This works. But would not like to rely on having two sets of defined constants.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2010 16:39:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899447#M80493</guid>
      <dc:creator>john3</dc:creator>
      <dc:date>2010-02-05T16:39:18Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899448#M80494</link>
      <description>&lt;P&gt;It seems to work with gcc/gfortran.&lt;/P&gt;
&lt;PRE&gt;[bash]/* constants.c */

const double k_B = 1.38054e-23;
&lt;PRE name="code" class="bash"&gt;/* c_sub.c */
#include &lt;STDIO.H&gt;
extern double k_B;

void c_sub()
{
   printf("k_B = %en", k_B);
}
&lt;PRE name="code" class="bash"&gt;! use_constants.f90
! compilation sequence:
! gcc -Wall -c constants.c
! gcc -Wall -c c_sub.c
! gfortran -Wall use_constants.f90 constants.o c_sub.o -ouse_constants
! Then run the resulting use_constants.exe

module has_constants
   use ISO_C_BINDING
   implicit none
   real(C_DOUBLE), bind(C,name='k_B') :: k_B
end module has_constants

program test
   use has_constants
   implicit none
   interface
      subroutine C_sub() bind(C,name='c_sub')
      end subroutine C_sub
   end interface

   write(*,*) 'k_B = ', k_B
   call c_sub
   k_b = 0
   write(*,*) 'k_B = ', k_B
end program test
[/bash]&lt;/PRE&gt;
&lt;/STDIO.H&gt;&lt;/PRE&gt;
&lt;PRE&gt;[bash]When the resulting use_constants.exe is executed, we get:[/bash]&lt;/PRE&gt;
&lt;PRE&gt;[bash]&lt;P&gt;k_B = 1.38054000000000004E-023&lt;/P&gt;&lt;P&gt;k_B = 1.380540e-023&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With no further output indicating that k_B was indeed linked as a constant, the access violation just didn't get trapped.&lt;/P&gt;&lt;P&gt;Hopefully you can read this even though the formatting didn't work.  I have been too sick to sleep the last two nights so I don't have the energy to puzzle out the forum software.&lt;/P&gt;[/bash]&lt;/PRE&gt;
&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Feb 2010 13:55:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899448#M80494</guid>
      <dc:creator>JVanB</dc:creator>
      <dc:date>2010-02-07T13:55:28Z</dc:date>
    </item>
    <item>
      <title>type, parameter, bind(c,name='myName' :: iConst = 2</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899449#M80495</link>
      <description>&lt;P&gt;"const" in C is not the same as a PARAMETER constant. It is a variable which you are not allowed to change. Fortran has a similar concept called PROTECTED. But if you want to do it this way, it will work in Intel Fortran as well.&lt;/P&gt;
&lt;P&gt;I tried your test case with Intel Visual Fortran and MSVC. I could not get the C definition to "take" in a separate source (the C code couldn't see it either) so I moved it into the C source replacing the "extern". This worked, and an access violation occurred when the Fortran code tried to change it.&lt;/P&gt;</description>
      <pubDate>Sun, 07 Feb 2010 17:07:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/type-parameter-bind-c-name-myName-iConst-2/m-p/899449#M80495</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2010-02-07T17:07:37Z</dc:date>
    </item>
  </channel>
</rss>

