<?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 Problem on passing contained procedure as an argument in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769209#M21717</link>
    <description>When you get the Debug Assertion Failed error, look at the application's console window, which may be hidden behind Visual Studio, to see if there is a more descriptive error. If you can't figure it out, consider contacting Intel Premier Support and supplying the complete application.</description>
    <pubDate>Wed, 06 Apr 2011 17:37:15 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2011-04-06T17:37:15Z</dc:date>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769208#M21716</link>
      <description>I got a 'Debug Assertion Failed' error when one module subroutine of my working code tries tocalla procedure passed in as an argument at run-time.&lt;BR /&gt;&lt;BR /&gt;I can not findany codingproblem, so I decide to create a smaller test case, see if I canreproduce the error. I followed the exact logic in myworking code, but I can not get the error in the test.&lt;BR /&gt;&lt;BR /&gt;For your info, I attached my test here:&lt;BR /&gt;&lt;BR /&gt;file1:&lt;BR /&gt;------------&lt;BR /&gt;&lt;P&gt;program testproc&lt;/P&gt;&lt;P&gt;use test&lt;/P&gt;&lt;P&gt;call testmesh&lt;/P&gt;&lt;P&gt;stop&lt;/P&gt;&lt;P&gt;end program testproc&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;file2:&lt;BR /&gt;-----------&lt;/P&gt;&lt;P&gt;module mesh&lt;/P&gt;&lt;P&gt;integer, parameter :: ikd = 4&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;subroutine visit_two_mesh(proc1)&lt;/P&gt;&lt;P&gt;INTERFACE&lt;/P&gt;&lt;P&gt;SUBROUTINE proc1(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;!&amp;lt; [in] subroutine to be called a new element start on either mesh&lt;/P&gt;&lt;P&gt;integer, parameter :: ikd = 4&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: history(:)&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;END SUBROUTINE proc1&lt;/P&gt;&lt;P&gt;END INTERFACE&lt;/P&gt;&lt;P&gt;integer(IKD) :: iel, iel_dest&lt;/P&gt;&lt;P&gt;integer :: lvl, lvl_dest&lt;/P&gt;&lt;P&gt;integer :: hp, hc, ha&lt;/P&gt;&lt;P&gt;logical :: inc&lt;/P&gt;&lt;P&gt;integer :: history(1)&lt;/P&gt;&lt;P&gt;iel = 1&lt;/P&gt;&lt;P&gt;iel_dest = 1&lt;/P&gt;&lt;P&gt;lvl = 0&lt;/P&gt;&lt;P&gt;lvl_dest = 0&lt;/P&gt;&lt;P&gt;hp = 1&lt;/P&gt;&lt;P&gt;hc = 1&lt;/P&gt;&lt;P&gt;ha = 1&lt;/P&gt;&lt;P&gt;inc = .true.&lt;/P&gt;&lt;P&gt;history = 0&lt;/P&gt;&lt;P&gt;call proc1(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;end subroutine visit_two_mesh&lt;/P&gt;&lt;P&gt;end module&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;file3:&lt;BR /&gt;-------------------&lt;/P&gt;&lt;P&gt;module test&lt;/P&gt;&lt;P&gt;use mesh&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;subroutine testmesh&lt;/P&gt;&lt;P&gt;call visit_two_mesh(myproc)&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;subroutine myproc(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: history(:)&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;print *, iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history&lt;/P&gt;&lt;P&gt;end subroutine myproc&lt;/P&gt;&lt;P&gt;end subroutine testmesh&lt;/P&gt;&lt;P&gt;end module test&lt;/P&gt;&lt;P&gt;==============&lt;BR /&gt;&lt;BR /&gt;The real error in my larger codehappenswhen visit_two_meshis calling proc1. The debugger says 'history' has Undefined address. Starting from 'lvl_dest', all arguments are wrong. But everything is fine in the test. The compilor options:&lt;BR /&gt;/nologo /debug:full /Od /fpp /I"C:\\Program Files\\MPICH2\\include" /I"C:\\works\\Phisics\\INSTANT\\lib\\instant2d\\\\..\\..\\src" /I"C:\\works\\Phisics\\INSTANT\\lib\\instant2d\\\\..\\..\\src\\mesh" /Ddim=2 /warn:all /module:"x64\\Debug\\\\" /object:"x64\\Debug\\\\" /Fd"x64\\Debug\\vc90.pdb" /traceback /check:all /libs:static /threads /dbglibs /c&lt;BR /&gt;&lt;BR /&gt;The options used for the test:&lt;BR /&gt;/nologo /debug:full /Od /warn:interfaces /module:"x64\\Debug\\\\" /object:"x64\\Debug\\\\" /Fd"x64\\Debug\\vc90.pdb" /traceback /check:bounds /libs:static /threads /dbglibs /c&lt;BR /&gt;&lt;BR /&gt;In my working code, 'visit_two_mesh' accepts more arguments, but I think it should be irrelavent.&lt;BR /&gt;When I set a breakpoint at the print line in the third file in the test, I see the disassembly:&lt;/P&gt;&lt;P&gt;subroutine myproc(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;00000001400011F6 push rbp &lt;/P&gt;&lt;P&gt;00000001400011F7 sub rsp,150h &lt;/P&gt;&lt;P&gt;00000001400011FE lea rbp,[rsp+30h] &lt;/P&gt;&lt;P&gt;0000000140001203 mov qword ptr [rbp+110h],rsi &lt;/P&gt;&lt;P&gt;000000014000120A mov qword ptr [rbp+108h],rbx &lt;/P&gt;&lt;P&gt;0000000140001211 mov qword ptr [rbp+130h],rcx &lt;/P&gt;&lt;P&gt;0000000140001218 mov qword ptr [rbp+138h],rdx &lt;/P&gt;&lt;P&gt;000000014000121F mov qword ptr [rbp+140h],r8 &lt;/P&gt;&lt;P&gt;0000000140001226 mov qword ptr [rbp+148h],r9 &lt;/P&gt;&lt;P&gt;000000014000122D mov eax,40h &lt;/P&gt;&lt;P&gt;0000000140001232 add rax,qword ptr [rbp+170h] &lt;/P&gt;&lt;P&gt;0000000140001239 mov edx,30h &lt;/P&gt;&lt;P&gt;000000014000123E add rdx,qword ptr [rbp+170h] &lt;/P&gt;&lt;P&gt;0000000140001245 mov rdx,qword ptr [rdx] &lt;/P&gt;&lt;P&gt;0000000140001248 add rdx,qword ptr [rax] &lt;/P&gt;&lt;P&gt;000000014000124B dec rdx &lt;/P&gt;&lt;P&gt;000000014000124E mov qword ptr [rbp+58h],rdx &lt;/P&gt;&lt;P&gt;0000000140001252 mov rax,qword ptr [rbp+58h] &lt;/P&gt;&lt;P&gt;0000000140001256 mov qword ptr [rbp+60h],rax &lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: history(:)&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;print *, iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The disassembly in my working code however:&lt;/P&gt;&lt;P&gt;SUBROUTINE proc11(iell,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;000000014096A022 push rbp &lt;/P&gt;&lt;P&gt;000000014096A023 sub rsp,0F0h &lt;/P&gt;&lt;P&gt;000000014096A02A lea rbp,[rsp+30h] &lt;/P&gt;&lt;P&gt;000000014096A02F mov qword ptr [rbp+0B0h],rsi &lt;/P&gt;&lt;P&gt;000000014096A036 mov qword ptr [rbp+0A8h],rbx &lt;/P&gt;&lt;P&gt;000000014096A03D mov qword ptr [rbp+0D0h],r10 &lt;/P&gt;&lt;P&gt;000000014096A044 mov qword ptr [rbp+0D8h],rcx &lt;/P&gt;&lt;P&gt;000000014096A04B mov qword ptr [rbp+0E0h],rdx &lt;/P&gt;&lt;P&gt;000000014096A052 mov qword ptr [rbp+0E8h],r8 &lt;/P&gt;&lt;P&gt;000000014096A059 mov rax,qword ptr [rbp+0D0h] &lt;/P&gt;&lt;P&gt;000000014096A060 mov qword ptr [rbp+70h],rax &lt;/P&gt;&lt;P&gt;000000014096A064 mov eax,40h &lt;/P&gt;&lt;P&gt;000000014096A069 add rax,qword ptr [rbp+118h] &lt;/P&gt;&lt;P&gt;000000014096A070 mov edx,30h &lt;/P&gt;&lt;P&gt;000000014096A075 add rdx,qword ptr [rbp+118h] &lt;/P&gt;&lt;P&gt;000000014096A07C mov rdx,qword ptr [rdx] &lt;/P&gt;&lt;P&gt;000000014096A07F add rdx,qword ptr [rax] &lt;/P&gt;&lt;P&gt;000000014096A082 dec rdx &lt;/P&gt;&lt;P&gt;000000014096A085 mov qword ptr [rbp+78h],rdx &lt;/P&gt;&lt;P&gt;000000014096A089 mov rax,qword ptr [rbp+78h] &lt;/P&gt;&lt;P&gt;000000014096A08D mov qword ptr [rbp+80h],rax &lt;/P&gt;&lt;P&gt;IMPLICIT NONE&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iell&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: lvl&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: lvl_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: history(:)&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;print *, history&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;, which is different from the one of the test. Is this normal? Any suggestions for me to remove this run-time error?&lt;BR /&gt;&lt;BR /&gt;Many thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2011 15:43:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769208#M21716</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-04-06T15:43:38Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769209#M21717</link>
      <description>When you get the Debug Assertion Failed error, look at the application's console window, which may be hidden behind Visual Studio, to see if there is a more descriptive error. If you can't figure it out, consider contacting Intel Premier Support and supplying the complete application.</description>
      <pubDate>Wed, 06 Apr 2011 17:37:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769209#M21717</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-06T17:37:15Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769210#M21718</link>
      <description>&lt;P&gt;I noticed the following assembly lines are messed up:&lt;BR /&gt;&lt;BR /&gt;000000014096A03D mov qword ptr [rbp+0D0h],r10 &lt;/P&gt;&lt;P&gt;000000014096A044 mov qword ptr [rbp+0D8h],rcx &lt;/P&gt;&lt;P&gt;000000014096A04B mov qword ptr [rbp+0E0h],rdx &lt;/P&gt;&lt;P&gt;000000014096A052 mov qword ptr [rbp+0E8h],r8 &lt;BR /&gt;&lt;BR /&gt;rcx, rdx, r8 and r9 are storing the addresses of iel, iel_dest, lvl, lvl_dest, but the subroutine is using r8 and r10. What can be the reason for this?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2011 19:40:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769210#M21718</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-04-06T19:40:08Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769211#M21719</link>
      <description>Sorry, this isn't the sort of thing we can diagnose from portions of assembly code. If you can provide us with a test case that fails, we can work with that,</description>
      <pubDate>Wed, 06 Apr 2011 19:49:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769211#M21719</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-06T19:49:37Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769212#M21720</link>
      <description>&lt;P&gt;I finally reproduce the error. Change the previous file 2 with the following:&lt;BR /&gt;&lt;BR /&gt;----------------------------&lt;BR /&gt;&lt;BR /&gt;module test&lt;/P&gt;&lt;P&gt;use mesh&lt;/P&gt;&lt;P&gt;implicit none&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;subroutine testmesh&lt;/P&gt;&lt;P&gt;real(8) :: a(10,10)&lt;/P&gt;&lt;P&gt;call visit_two_mesh(myproc, myproc1)&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;SUBROUTINE proc0()&lt;/P&gt;&lt;P&gt;IMPLICIT NONE&lt;/P&gt;&lt;P&gt;a = 0.0_8&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;END SUBROUTINE proc0&lt;/P&gt;&lt;P&gt;subroutine myproc(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: history(:)&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;print *, iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history&lt;/P&gt;&lt;P&gt;end subroutine myproc&lt;/P&gt;&lt;P&gt;subroutine myproc1(iel,iel_dest, hp, hc, ha, inc)&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;print *, iel,iel_dest,hp, hc, ha, inc&lt;/P&gt;&lt;P&gt;end subroutine myproc1&lt;/P&gt;&lt;P&gt;end subroutine testmesh&lt;/P&gt;&lt;P&gt;end module test&lt;BR /&gt;&lt;BR /&gt;=============&lt;BR /&gt;You will see the error with 12.0.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2011 21:25:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769212#M21720</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-04-06T21:25:32Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769213#M21721</link>
      <description>&lt;P&gt;Essentially, the allocated array in stack caused the error. If I use /Qsave, then the error is gone. I am not sure if this is considered a compiler bug or not.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2011 21:32:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769213#M21721</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-04-06T21:32:31Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769214#M21722</link>
      <description>Thanks - I will look at this.</description>
      <pubDate>Wed, 06 Apr 2011 21:52:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769214#M21722</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-06T21:52:02Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769215#M21723</link>
      <description>I'm a bit confused here. The new source you provide would seem to replace file 3, not file 2. Then you have the call to visit_two_mesh passing two arguments, but the routine accepts only one.&lt;BR /&gt;&lt;BR /&gt;Would you please ZIP a folder containing the test sources and the solution/project files, or whatever tells me how you build the sources, and attach it to a reply? That way I can be certain of seeing what you are seeing.</description>
      <pubDate>Wed, 06 Apr 2011 22:05:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769215#M21723</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-06T22:05:46Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769216#M21724</link>
      <description>sorry, Steve. I tried out different ways to fix the problem, the test code is messed up. Let me reattach them here.&lt;BR /&gt;&lt;BR /&gt;file 1:&lt;BR /&gt;===&lt;BR /&gt;&lt;P&gt;program testproc&lt;/P&gt;&lt;P&gt;use test&lt;/P&gt;&lt;P&gt;call testmesh&lt;/P&gt;&lt;P&gt;stop&lt;/P&gt;&lt;P&gt;end program testproc&lt;BR /&gt;&lt;BR /&gt;file 2:&lt;BR /&gt;====&lt;/P&gt;&lt;P&gt;module mesh&lt;/P&gt;&lt;P&gt;integer, parameter :: ikd = 4&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;subroutine visit_two_mesh(proc1, proc2)&lt;/P&gt;&lt;P&gt;INTERFACE&lt;/P&gt;&lt;P&gt;SUBROUTINE proc1(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;!&amp;lt; [in] subroutine to be called a new element start on either mesh&lt;/P&gt;&lt;P&gt;integer, parameter :: ikd = 4&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: history(:)&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;END SUBROUTINE proc1&lt;/P&gt;&lt;P&gt;SUBROUTINE proc2(iel,iel_dest, hp, hc, ha, inc)&lt;/P&gt;&lt;P&gt;!&amp;lt; [in] subroutine to be called a new element start on either mesh&lt;/P&gt;&lt;P&gt;integer, parameter :: ikd = 4&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;END SUBROUTINE proc2&lt;/P&gt;&lt;P&gt;END INTERFACE&lt;/P&gt;&lt;P&gt;integer(IKD) :: iel, iel_dest&lt;/P&gt;&lt;P&gt;integer :: lvl, lvl_dest&lt;/P&gt;&lt;P&gt;integer :: hp, hc, ha&lt;/P&gt;&lt;P&gt;logical :: inc&lt;/P&gt;&lt;P&gt;integer :: history(1)&lt;/P&gt;&lt;P&gt;iel = 1&lt;/P&gt;&lt;P&gt;iel_dest = 1&lt;/P&gt;&lt;P&gt;lvl = 0&lt;/P&gt;&lt;P&gt;lvl_dest = 0&lt;/P&gt;&lt;P&gt;hp = 1&lt;/P&gt;&lt;P&gt;hc = 1&lt;/P&gt;&lt;P&gt;ha = 1&lt;/P&gt;&lt;P&gt;inc = .true.&lt;/P&gt;&lt;P&gt;history = 0&lt;/P&gt;&lt;P&gt;call proc2(iel,iel_dest, hp, hc, ha, inc)&lt;/P&gt;&lt;P&gt;call proc1(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;end subroutine visit_two_mesh&lt;/P&gt;&lt;P&gt;end module&lt;BR /&gt;&lt;BR /&gt;file 3:&lt;BR /&gt;====&lt;/P&gt;&lt;P&gt;module test&lt;/P&gt;&lt;P&gt;use mesh&lt;/P&gt;&lt;P&gt;implicit none&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;subroutine testmesh&lt;/P&gt;&lt;P&gt;real(8) :: a(10,10)&lt;/P&gt;&lt;P&gt;!real(8), save :: a(10,10)&lt;/P&gt;&lt;P&gt;call visit_two_mesh(myproc, myproc1)&lt;/P&gt;&lt;P&gt;contains&lt;/P&gt;&lt;P&gt;SUBROUTINE proc0()&lt;/P&gt;&lt;P&gt;IMPLICIT NONE&lt;/P&gt;&lt;P&gt;a = 0.0_8&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;END SUBROUTINE proc0&lt;/P&gt;&lt;P&gt;subroutine myproc(iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history)&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl&lt;/P&gt;&lt;P&gt;INTEGER, INTENT(IN) :: lvl_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: history(:)&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;print *, iel,iel_dest,lvl,lvl_dest, hp, hc, ha, inc,history&lt;/P&gt;&lt;P&gt;end subroutine myproc&lt;/P&gt;&lt;P&gt;subroutine myproc1(iel,iel_dest, hp, hc, ha, inc)&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel&lt;/P&gt;&lt;P&gt;INTEGER(IKD), INTENT(IN) :: iel_dest&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hp&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: hc&lt;/P&gt;&lt;P&gt;INTEGER , INTENT(IN) :: ha !&lt;/P&gt;&lt;P&gt;LOGICAL , INTENT(IN) :: inc ! true to indicate a new element on the first mesh starts&lt;/P&gt;&lt;P&gt;print *, iel,iel_dest,hp, hc, ha, inc&lt;/P&gt;&lt;P&gt;end subroutine myproc1&lt;/P&gt;&lt;P&gt;end subroutine testmesh&lt;/P&gt;&lt;P&gt;end module test&lt;BR /&gt;&lt;BR /&gt;If I put save attribute on the auto array a, then the error is fixed. But this does not work for my big code. I also tried to allocate a dynamically, it does not work.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2011 22:16:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769216#M21724</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-04-06T22:16:22Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769217#M21725</link>
      <description>Ok, I can see a problem with x64. Investigating.</description>
      <pubDate>Wed, 06 Apr 2011 22:27:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769217#M21725</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-06T22:27:22Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769218#M21726</link>
      <description>Ok, I can see a problem with x64. Investigating.</description>
      <pubDate>Wed, 06 Apr 2011 22:27:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769218#M21726</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-06T22:27:28Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769219#M21727</link>
      <description>What I can see so far is that when "proc1" is called, arguments hc and afterward are shifted one place so that the called routine picks up garbage for the address of the last argument triggering the access violation. I haven't yet figured out if the error is on the caller or called side.&lt;BR /&gt;&lt;BR /&gt;This is an interesting case - it may take me a while to unravel. Changing the declaration of the array simply changes the layout of memory causing random other data to be used for the address which may or may not result in an error. It does not fail on IA-32.</description>
      <pubDate>Thu, 07 Apr 2011 00:11:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769219#M21727</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-07T00:11:39Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769220#M21728</link>
      <description>Steve,&lt;BR /&gt;&lt;BR /&gt;When "proc1" is called back, "proc1" need to be able to see the local varialbes declared in its containing subroutine. I guess the error happens whilethecompiler handles this.&lt;BR /&gt;&lt;BR /&gt;In my working code, when I comment out all statements in "proc1" and use save attribute for a, I can see the arguments are passed correctly with debugger (r8 and r9 are used). Once I add one statement accessing the local data in the containing subroutine, arguments are no longer passed correctly (in this cass, r9 and r10 are used in the assembly).I am desparately wanting a fix of this.&lt;BR /&gt;&lt;BR /&gt;I remembered the code works longbefore, I was using Win32 anyway. I may had a bad memory. I will try Win32 and Linux tomorrow see what will happen.&lt;BR /&gt;&lt;BR /&gt;Best.</description>
      <pubDate>Thu, 07 Apr 2011 02:42:20 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769220#M21728</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-04-07T02:42:20Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769221#M21729</link>
      <description>Yaqi,&lt;BR /&gt;&lt;BR /&gt;I found that there was no problem accessing the host-associated variable. The problem is solely in how the actual arguments are passed to the subroutine, where the first three arguments are passed correctly but after that, positions are offset by one so that the last one picks up garbage. I'm pretty sure that this is related to the way the argument list is "split" on x64 with the first few arguments passed in registers and the rest on the stack. I have escalated this as issue DPD200168169.&lt;BR /&gt;&lt;BR /&gt;I verified that it also fails with the 11.1 compiler on Windows - I haven't tried Linux. It works fine on IA-32 - it's only Intel 64 where the problem appears.</description>
      <pubDate>Fri, 08 Apr 2011 22:45:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769221#M21729</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-04-08T22:45:19Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769222#M21730</link>
      <description>Thanks Steve.&lt;BR /&gt;&lt;BR /&gt;I am assigned to work on something else. Please do let me know when you have a fix.&lt;BR /&gt;&lt;BR /&gt;-Yaqi</description>
      <pubDate>Mon, 11 Apr 2011 18:13:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769222#M21730</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-04-11T18:13:57Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769223#M21731</link>
      <description>Steve,&lt;BR /&gt;&lt;BR /&gt;Has this issue been fixed in update 5 of Composer XE 2011?&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Yaqi</description>
      <pubDate>Mon, 29 Aug 2011 19:43:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769223#M21731</guid>
      <dc:creator>Yaqi_Wang</dc:creator>
      <dc:date>2011-08-29T19:43:34Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769224#M21732</link>
      <description>No, it has not.</description>
      <pubDate>Mon, 29 Aug 2011 20:41:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769224#M21732</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-08-29T20:41:36Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769225#M21733</link>
      <description>There was a related forumreport of passing a procedure (subroutine/function) contains subroutine/function to an "external" routine (via call/dummy argument)and where the Host associated (stack)variables were not (properly) accessible (IOW compiler didn't complain but references pointed to incorrect address). I think this is an issue were any "host" declared contains subroutine/function may only be called (directly) from the "host" declaring said contains routine. Note the "SAVE" variables are accessible because they are globally named. Other than lack of warning message this might not be an error. In the IVF documentation:&lt;BR /&gt;&lt;BR /&gt;&lt;H2 class="sectiontitle"&gt;Description&lt;/H2&gt;&lt;P&gt;Internal procedures are the same as external procedures, except for the following:&lt;/P&gt;&lt;UL type="disc"&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Only the host program unit can use an internal procedure&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;An internal procedure has access to host entities by host association; that is, names declared in the host program unit are useable within the internal procedure.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;In Fortran 95/90, the name of an internal procedure must not be passed as an argument to another procedure.&lt;/STRONG&gt; &lt;SPAN style="color: #007783;"&gt;However, Intel Fortran allows an internal procedure name to be passed as an actual argument to another procedure. &lt;EM&gt;(J.D. I assume this means the procedure address can be saved/restored but not called)&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;An internal procedure must not contain an ENTRY statement.&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Mon, 29 Aug 2011 22:41:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769225#M21733</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2011-08-29T22:41:10Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769226#M21734</link>
      <description>Jim,&lt;BR /&gt;&lt;BR /&gt;Your interpretation is not correct. Intel Fortran supports passing an internal proxedure as an actual argument and calling the procedure via the argument. For some background on how we do that, see my Doctor Fortran post &lt;A target="_blank" href="http://software.intel.com/en-us/blogs/2009/09/02/doctor-fortran-in-think-thank-thunk/"&gt;Think, Thank, Thunk&lt;/A&gt;.&lt;BR /&gt;&lt;BR /&gt;I will note that this feature is now standard in Fortran 2008 - we were just ahead of the curve this time...</description>
      <pubDate>Mon, 29 Aug 2011 23:58:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769226#M21734</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2011-08-29T23:58:53Z</dc:date>
    </item>
    <item>
      <title>Problem on passing contained procedure as an argument</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769227#M21735</link>
      <description>Neet - so you cook the address of the internal subroutine/function to point to a section of code created on the stack which can fetch, as an immediate value, the host context pointer (likely the savedebp or rbp of the host). This would place a caviate on the programmer such that the context of the host proceedure must remain for the duration of time of all subsequent calls to the contained routine. Meaning a host cannot "post" the thunk for later use, exit the host context (RETURN), and some time later something else uses the savedthunk for a call. A second caviate is: should an O/S mark the stack segment to Execute Disable then the thunk techniquewould not work.&lt;BR /&gt;&lt;BR /&gt;This is loosly reminicient of a C++0x lambda function.&lt;BR /&gt;&lt;BR /&gt;Can you clarify in the IVF documentation the requirement of the host context to persist through the duration of any subsequent use of a contains procedure. Also clarify when (if) a contains procedure recursively calls the host (new context or same context).&lt;BR /&gt;&lt;BR /&gt;Jim Dempsey</description>
      <pubDate>Tue, 30 Aug 2011 13:04:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-on-passing-contained-procedure-as-an-argument/m-p/769227#M21735</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2011-08-30T13:04:11Z</dc:date>
    </item>
  </channel>
</rss>

