<?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: referencing actual arguments in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764502#M19239</link>
    <description>&lt;P&gt;I appreciate the replies.&lt;/P&gt;
&lt;P&gt;"it is possible for the the program to have multiple symbolic references (aliases) to the same storage locations. As long as you are aware of this and take proper actions you should not get into trouble."&lt;/P&gt;
&lt;P&gt;That is what I thought, but from a previous post:&lt;/P&gt;
&lt;P&gt;"The compiler's optimizer takes advantage of the standards prohibition against referencing an aliased argument if the routine causes the aliased variable to be redefined or become undefined."&lt;/P&gt;
&lt;P&gt;The sort of thing that pops up in my code is like the following example:&lt;/P&gt;
&lt;P&gt;MODULE MOD_A&lt;BR /&gt; REAL NodeArray(10)&lt;BR /&gt;END MODULE MOD_A&lt;/P&gt;
&lt;P&gt;PROGRAM TEST&lt;BR /&gt;USE MOD_A&lt;BR /&gt; CALL SUB_1 (NodeArray(3))&lt;BR /&gt; ...&lt;BR /&gt;END PROGRAM TEST&lt;/P&gt;
&lt;P&gt;SUBROUTINE SUB_1 (Node)&lt;BR /&gt; REAL Node&lt;BR /&gt; ...&lt;BR /&gt; CALL SUB_2 (Node)&lt;BR /&gt;END SUBROUTINE SUB_1&lt;/P&gt;
&lt;P&gt;SUBROUTINE SUB_2 (Node)&lt;BR /&gt; USE MOD_A&lt;BR /&gt; REAL Node&lt;BR /&gt; ...&lt;BR /&gt; Node = 5.0&lt;BR /&gt; NodeArray(3) = NodeArray(3) + 10.0&lt;BR /&gt;END SUBROUTINE SUB_2&lt;/P&gt;
&lt;P&gt;I initially passed one element of an array (which could actually be an allocatablederived structure) down through some child subroutines. Later, in one of the child subroutines, I wanted to reference other elements of the array, so I added a use module statement back in, but left the dummy arguments in place. Is this problematic?&lt;/P&gt;
&lt;P&gt;Regarding likely problems&lt;/P&gt;
&lt;P&gt;a) Execution with un-initialized variables (often related to implicit variables)&lt;BR /&gt;b) Linking in the wrong runtime library (different calling conventions)&lt;BR /&gt;c) Stack limits different between Debug and Release mode&lt;BR /&gt;d) different .DLLs being loaded.&lt;BR /&gt;e) optimization issues&lt;/P&gt;
&lt;P&gt;a) Caused me problems when I switched from CVF to Intel. I've put a lot of time into this one. However, neither a, b, nor c explain why my old code fails with a newer compilor, and my new code works with an old compilor. I'm not explicitly loading or linking any DLLs (static libraries, yes, DLLs no). So this would only be an issue if the compilors after 9.1.3291 load different DLLs.&lt;/P&gt;
&lt;P&gt;e) seems to be the answer. I can start with a realease configuration and switch the Optimization setting from "maximise speed" to "disable" and the run time problems go away. Maximise speed is the /O2 setting? I'm running Intel under Visual Studio. What is the syntax to add the maximise speed setting to a single file?&lt;/P&gt;
&lt;P&gt;Thanks once again.&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Nov 2007 19:23:28 GMT</pubDate>
    <dc:creator>jarvusluntatintel</dc:creator>
    <dc:date>2007-11-08T19:23:28Z</dc:date>
    <item>
      <title>referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764486#M19223</link>
      <description>The 10.0.027 compiler quide quotes &lt;BR /&gt;"Similarly, if any part of the actual argument is defined through a dummy 
argument, the actual argument can only be referenced through that dummy argument 
during execution of the procedure. For example, if the following statements are 
specified:&lt;PRE&gt;&lt;CODE&gt;  MODULE MOD_A&lt;BR /&gt;    REAL :: A, B, C, D&lt;BR /&gt;  END MODULE MOD_A&lt;BR /&gt;&lt;BR /&gt;  PROGRAM TEST&lt;BR /&gt;    USE MOD_A&lt;BR /&gt;    CALL SUB_1 (B)&lt;BR /&gt;    ...&lt;BR /&gt;  END PROGRAM TEST&lt;BR /&gt;&lt;BR /&gt;  SUBROUTINE SUB_1 (F)&lt;BR /&gt;    USE MOD_A&lt;BR /&gt;    ...&lt;BR /&gt;    WRITE (*,*) F&lt;BR /&gt;  END SUBROUTINE SUB_1&lt;BR /&gt;&lt;/CODE&gt;
&lt;/PRE&gt;
&lt;P&gt;Variable B must not be directly referenced during the execution of SUB_1 
because it is being defined through dummy argument F. However, B can be 
indirectly referenced through F (and directly referenced when SUB_1 completes 
execution)."&lt;/P&gt;&lt;P&gt;why then does this program work?&lt;/P&gt;&lt;P&gt; MODULE MOD_A&lt;BR /&gt; REAL :: A, B, C, D&lt;BR /&gt; END MODULE MOD_A&lt;BR /&gt;&lt;BR /&gt; PROGRAM TEST&lt;BR /&gt; USE MOD_A&lt;BR /&gt; b=1.0&lt;BR /&gt; CALL SUB_1 (B)&lt;BR /&gt; write(*,*)B&lt;BR /&gt; END PROGRAM TEST&lt;BR /&gt;&lt;BR /&gt; SUBROUTINE SUB_1 (F)&lt;BR /&gt; USE MOD_A&lt;BR /&gt; B=2.0 &lt;BR /&gt; WRITE (*,*) B,F&lt;BR /&gt; f=3.0&lt;BR /&gt; END SUBROUTINE SUB_1&lt;/P&gt; 2.000000 2.000000&lt;BR /&gt; 3.000000&lt;BR /&gt;Press any key to continue . . .&lt;BR /&gt;should it not give an error? I have written code like subroutine SUB_1 and I am concerned that it is incorrect, even though it seems to work. Have I been getting away with something that is wrong?&lt;BR /&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Nov 2007 13:50:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764486#M19223</guid>
      <dc:creator>Ray_R_1</dc:creator>
      <dc:date>2007-11-02T13:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764487#M19224</link>
      <description>You've been lucky. The compiler's optimizer takes advantage of the standards prohibition against referencing an aliased argument if the routine causes the aliased variable to be redefined or become undefined. Sometimes it will seem to work, other times it will not. This is not something the compiler is required to detect, but I have seen many programs where failure to follow this rule causes wrong results.&lt;BR /&gt;&lt;BR /&gt;Intel Fortran does have an option /assume:dummy_aliases, which lets the compiler know that such aliases may exist and therefore optimizations related to that are inhibited.&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Nov 2007 14:59:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764487#M19224</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-02T14:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764488#M19225</link>
      <description>Thanks for the quick reply. I'm may not of been so lucky, I have had programs that run just fine in debug mode, but not in release mode and could never pin down the problem, this may of been one of the causes. Does the same thing happen with a common block?&lt;BR /&gt;&lt;BR /&gt;Program Main&lt;BR /&gt; real x,y&lt;BR /&gt; common /block1/ x&lt;BR /&gt; equivalence (x,y)&lt;BR /&gt; call sub(y)&lt;BR /&gt;End Program Main&lt;BR /&gt;&lt;BR /&gt;Subroutine Sub(y)&lt;BR /&gt; real x,y&lt;BR /&gt; common /block1/ x&lt;BR /&gt; x=5&lt;BR /&gt; return&lt;BR /&gt;End Subroutine Sub&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Nov 2007 17:04:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764488#M19225</guid>
      <dc:creator>Ray_R_1</dc:creator>
      <dc:date>2007-11-02T17:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764489#M19226</link>
      <description>You betcha, and I've seen MANY failures like this over the years, though as your subroutine doesn't also reference Y it's not really an example of this. As compilers get smarter, some programmer tricks become risky, and this is a major one. Another popular way to get bitten by this is to do something like this:&lt;BR /&gt;&lt;BR /&gt;x = 5.0&lt;BR /&gt;call sub (x,x)&lt;BR /&gt;...&lt;BR /&gt;subroutine sub (x,y)&lt;BR /&gt;x = x + 1.0&lt;BR /&gt;print *, y&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;Now does it print 6 or 5? The answer is that it could print either one, or maybe even 42 (though that is unlikely).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 03 Nov 2007 00:24:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764489#M19226</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-03T00:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764490#M19227</link>
      <description>&lt;P&gt;Roberts,&lt;/P&gt;
&lt;P&gt;Your code is "correct" and the output is what was directed by the code, however, the output may not be what you intended.&lt;/P&gt;
&lt;P&gt;The documentation is grammatically incorrect: "can only" implies it would be impossible to do otherwise. As you have seen, this is not so. Replace "can only" with "should only". i.e. as a good programming practice directive and not a statement of fact.&lt;/P&gt;
&lt;P&gt;As Steve points out, it is possible that a good compiler could detect this and issue a warning. But do not rely on this as SUB_1 might be compiled in a sperate assembly and not available during the compilation time of program TEST.&lt;/P&gt;
&lt;P&gt;Steve, please comment on the following:&lt;/P&gt;
&lt;P&gt;As a measure to protect against this (subroutine compiled separately), consider using an interface declaration for the subroutine that contains the ONLY clause to protect B&lt;/P&gt;
&lt;P&gt;INTERFACE&lt;BR /&gt;SUBROUTINE SUB_1(F)&lt;BR /&gt;USE MOD_A, ONLY: B&lt;BR /&gt;REAL :: F&lt;BR /&gt;END SUBROUTINE SUB_1&lt;BR /&gt;END INTERFACE&lt;/P&gt;
&lt;P&gt;From the above interface it is implicit that B, from within MOD_A, will be referenced by SUB_1. And therefore any code calling SUB_1 (and using the INTERFACE declaration) could warn you if B were to be used as a dummy argument to SUB_1. And it could do so without having access to the source code of SUB_1.&lt;/P&gt;
&lt;P&gt;Note, you may still have a good reason to pass B in the call so I do not think the code should insist on not permitting B as a calling argument. I haven't tested the above interfaceto see if IVF does perform this warning service. I'll leave that up to you.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2007 02:18:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764490#M19227</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2007-11-04T02:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764491#M19228</link>
      <description>Jim,&lt;BR /&gt;&lt;BR /&gt;It is not sufficient that the variable be "referenced" in order to violate the stamdard here, it must also be stored to or have its definition status change. As this could be in conditional code, it would have to be a run-time check. Intel Fortran does not do this check.&lt;BR /&gt;</description>
      <pubDate>Sun, 04 Nov 2007 04:22:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764491#M19228</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-04T04:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764492#M19229</link>
      <description>&lt;P&gt;Well...,&lt;/P&gt;
&lt;P&gt;I wouldn't want it to be an automaticruntime check as this would produce an Ab-End in a distributed runtime library. The programmer could write a sanity check, perhaps using LOC() to verify the arguments are safe to use, and if not take the appropriate action.&lt;/P&gt;
&lt;P&gt;The real place for the warning is at compile time, as this is where the programming error is.&lt;/P&gt;
&lt;P&gt;I suppose the ONLY construction could be expanded to include a different keyword for this purpose (NOARG?)&lt;/P&gt;
&lt;P&gt;INTERFACE&lt;BR /&gt;SUBROUTINE FOO(F)&lt;BR /&gt;USE SomeMod, NOARG: A&lt;BR /&gt;REAL::F&lt;BR /&gt;END SUBROUTINE FOO&lt;BR /&gt;END INTERFACE&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2007 19:56:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764492#M19229</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2007-11-04T19:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764493#M19230</link>
      <description>But there's nothing wrong with passing A (in your example) as an argument. The trouble comes when a variable's storage is accessed two different ways in a routine AND it is modified. &lt;BR /&gt;</description>
      <pubDate>Sun, 04 Nov 2007 22:26:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764493#M19230</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-04T22:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764494#M19231</link>
      <description>Is the problem that, when the variable is passed as an arugment it might get stuck in a register and therefore does not share the same memory location as the variable in the common or module while the subprogram is excuting, and are therefore independant? At the return from the subprogram the variable in the register can have a differnet value than the variable in the common and will overwrite the common variable on return? &lt;BR /&gt;&lt;BR /&gt;If this is sort of what is happening, another question comes to mind. If I pass a variable (scalar, array, or array segment) to a subroutine and then use the %loc function in the subroutine to get the address of that variable, am I sure that I'm getting the address of the variable or could I be getting the address of a register or temp array? &lt;BR /&gt;&lt;BR /&gt;Program MainPrg&lt;BR /&gt; real x&lt;BR /&gt; integer address&lt;BR /&gt; call sub1(x,address)&lt;BR /&gt;End Program MainPrg&lt;BR /&gt;&lt;BR /&gt;Subroutine sub1(x,address)&lt;BR /&gt; real x&lt;BR /&gt; integer address&lt;BR /&gt; address=%loc(x)&lt;BR /&gt;End Subroutine sub1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Nov 2007 15:06:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764494#M19231</guid>
      <dc:creator>Ray_R_1</dc:creator>
      <dc:date>2007-11-05T15:06:35Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764495#M19232</link>
      <description>Yes, the compiler may choose to put a copy of one of the arguments in a register. If you use %loc, you'll always get the address of the argument as passed in, not any local copy the compiler may have made.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Nov 2007 15:26:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764495#M19232</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-05T15:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764496#M19233</link>
      <description>&lt;P&gt;A sanity check in your program could use %loc to test for improper argument usage.&lt;/P&gt;
&lt;P&gt;Also, even if the argument is not registerized the code may have temporal issues where the compiler would not know if two variable names reference the same memory location(s) and the optimization removes seamingly removable statements. Assume F is dummy that references A&lt;/P&gt;
&lt;P&gt;F=A+B&lt;BR /&gt; Y=A+Z&lt;BR /&gt;&lt;BR /&gt;The optimization code would likely remember A for the second statementand not knowA wasmodified by F=.&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2007 18:33:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764496#M19233</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2007-11-05T18:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764497#M19234</link>
      <description>If your program wants to do such aliasing, compile with /assume:dummy_aliases and then you won't have to worry about it.&lt;BR /&gt;</description>
      <pubDate>Mon, 05 Nov 2007 20:00:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764497#M19234</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-05T20:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764498#M19235</link>
      <description>&lt;P&gt;&amp;gt;&amp;gt; If your program wants to do such aliasing, compile with /assume:dummy_aliases and then you won't have to worry about it.&lt;/P&gt;
&lt;P&gt;That would be a partial fix since I would guess that the option effectively makes the dummies volatile (i.e. code always reaches into memory as opposed to keeping a copy in a register). &lt;/P&gt;
&lt;P&gt;The reason this won't always work is that if you have multiple dummies the adverse interaction can span over multiple statements. To fix this would require some rather obtuse programming on the part of the compiler (e.g. a ring buffer for each variable). Additionally, the programmer may want or require the adverse interaction and the compiler wouldn't know the true intentions of the programmer.&lt;/P&gt;
&lt;P&gt;These types of problems are particularly nasty to debug.&lt;/P&gt;
&lt;P&gt;If the subroutine permits it, consider using pass by value or copy to local temps.&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2007 05:30:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764498#M19235</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2007-11-07T05:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764499#M19236</link>
      <description>&lt;P&gt;Was there a change in the optimization during version 9.1 that relates to module variables also being referenced as dummies?&lt;/P&gt;
&lt;P&gt;In my program, I used to pass everything as dummies. I eventually got tired of doing that and started referencing the variables through modules. It is likely that somewhere I am guitly of referencing the same varible in different ways. So when I saw this thread, I added the assume:dummy_aliases, but it didn't fix the problem, perhaps because of:&lt;/P&gt;
&lt;P&gt;"The reason this won't always work is that if you have multiple dummies the adverse interaction can span over multiple statements"&lt;/P&gt;
&lt;P&gt;which I could be guilty of that also. (Before this thread, it never crossed my mind that a dummy argument might be stored in a different part of memory than the same variable referenced directly in a use module statement.)&lt;/P&gt;
&lt;P&gt;When using a version newer than 9.1.3291.2005 (including version 10) I get the following:&lt;/P&gt;
&lt;P&gt;In debug mode, everything is fine. In release mode, about 1 in 20 data sets causes a memory crash of the, "send report to Microsoft, variety.&lt;/P&gt;
&lt;P&gt;If I stick to 9.1.3291, or older versions, I can run things ok with both debug and release. I don't think it is a recently added bug in my code, because my new code works fine with the older versions. Additionally, my code from more than a year ago (which is widely distributed) has the 1-in-20 problem if compiled with newer versions.&lt;/P&gt;
&lt;P&gt;Something seems to have changed with the compiler. However, my program is around 100,000 lines and it could certainly be a memory leak on my end that is only now being triggered.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Any ideas. Did something change with this optimization after 9.1.3291?&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2007 21:27:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764499#M19236</guid>
      <dc:creator>jarvusluntatintel</dc:creator>
      <dc:date>2007-11-07T21:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764500#M19237</link>
      <description>&lt;P&gt;Fortran is by default "pass by reference" therefore arguments represent the address of the data and not a copy of the data as in a "pass by value" system such a C/C++.&lt;/P&gt;
&lt;P&gt;Due to this, if you pass a global variable (or one who's scope is outside of the subroutine local variables) then it is possible for the the program to have multiple symbolic references (aliases) to the same storage locations. As long as you are aware of this and take proper actions you should not get into trouble. You can also have aliases to local variables in a call if you use the same variable multiple times in the argument list.&lt;/P&gt;
&lt;P&gt;It is not up to the compiler to prohibit you from doing this as it may be perfectly valid for you to do so with your function/subroutine.&lt;/P&gt;
&lt;P&gt;Thecommon reasons of a program running in Debug mode but not in Release mode are:&lt;/P&gt;
&lt;P&gt;a) Execution with un-initialized variables (often related to implicit variables)&lt;BR /&gt;b) Linking in the wrong runtime library (different calling conventions)&lt;BR /&gt;c) Stack limits different between Debug and Release mode&lt;BR /&gt;d) different .DLLs being loaded.&lt;BR /&gt;e) optimization issues&lt;/P&gt;
&lt;P&gt;The easiest reason to test might be e). The suggested strategy is to&lt;/P&gt;
&lt;P&gt;a) Create a new configuration, call it DebugRelease and specify that it is to copy the configuration settings from Debug configuration.&lt;/P&gt;
&lt;P&gt;b) Compile and test the DebugRelease configuration to make sure it runs the same as the Debug configuration.&lt;/P&gt;
&lt;P&gt;c) Selectively enable optimizations (keeping debug info) and test for each project.&lt;/P&gt;
&lt;P&gt;d) When project found that causes problems then disable optimizations on project and then progress selectively through each file (or groups of files in the project) enabling optimizations.&lt;/P&gt;
&lt;P&gt;e) use c) and d) in a manner similar to a binary search (do half of files, then half of half, ...)&lt;/P&gt;
&lt;P&gt;f) if you manage to optimize all the files (with debug info) and if the program still runs then start disabling runtime checks (using the c) d) method)&lt;/P&gt;
&lt;P&gt;g) if you manage to remove all runtime checks and keep optimizations then look consider the possibility of problem in the release mode of the runtime libraries linked into the application (e.g. you are linking in the incorrect RTL)&lt;/P&gt;
&lt;P&gt;Good luck bug hunting&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2007 23:38:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764500#M19237</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2007-11-07T23:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764501#M19238</link>
      <description>Optimization is always being improved. This can cause changes in behavior for an incorrect program. (I remember back in the 1980s people finding that putting variables in COMMON or using separate routines no longer inhibited optimization.)&lt;BR /&gt;&lt;BR /&gt;The Fortran language has rules about what you can and cannot do with aliases. If you violate these rules, the results are unpredictable.&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Nov 2007 16:12:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764501#M19238</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-08T16:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764502#M19239</link>
      <description>&lt;P&gt;I appreciate the replies.&lt;/P&gt;
&lt;P&gt;"it is possible for the the program to have multiple symbolic references (aliases) to the same storage locations. As long as you are aware of this and take proper actions you should not get into trouble."&lt;/P&gt;
&lt;P&gt;That is what I thought, but from a previous post:&lt;/P&gt;
&lt;P&gt;"The compiler's optimizer takes advantage of the standards prohibition against referencing an aliased argument if the routine causes the aliased variable to be redefined or become undefined."&lt;/P&gt;
&lt;P&gt;The sort of thing that pops up in my code is like the following example:&lt;/P&gt;
&lt;P&gt;MODULE MOD_A&lt;BR /&gt; REAL NodeArray(10)&lt;BR /&gt;END MODULE MOD_A&lt;/P&gt;
&lt;P&gt;PROGRAM TEST&lt;BR /&gt;USE MOD_A&lt;BR /&gt; CALL SUB_1 (NodeArray(3))&lt;BR /&gt; ...&lt;BR /&gt;END PROGRAM TEST&lt;/P&gt;
&lt;P&gt;SUBROUTINE SUB_1 (Node)&lt;BR /&gt; REAL Node&lt;BR /&gt; ...&lt;BR /&gt; CALL SUB_2 (Node)&lt;BR /&gt;END SUBROUTINE SUB_1&lt;/P&gt;
&lt;P&gt;SUBROUTINE SUB_2 (Node)&lt;BR /&gt; USE MOD_A&lt;BR /&gt; REAL Node&lt;BR /&gt; ...&lt;BR /&gt; Node = 5.0&lt;BR /&gt; NodeArray(3) = NodeArray(3) + 10.0&lt;BR /&gt;END SUBROUTINE SUB_2&lt;/P&gt;
&lt;P&gt;I initially passed one element of an array (which could actually be an allocatablederived structure) down through some child subroutines. Later, in one of the child subroutines, I wanted to reference other elements of the array, so I added a use module statement back in, but left the dummy arguments in place. Is this problematic?&lt;/P&gt;
&lt;P&gt;Regarding likely problems&lt;/P&gt;
&lt;P&gt;a) Execution with un-initialized variables (often related to implicit variables)&lt;BR /&gt;b) Linking in the wrong runtime library (different calling conventions)&lt;BR /&gt;c) Stack limits different between Debug and Release mode&lt;BR /&gt;d) different .DLLs being loaded.&lt;BR /&gt;e) optimization issues&lt;/P&gt;
&lt;P&gt;a) Caused me problems when I switched from CVF to Intel. I've put a lot of time into this one. However, neither a, b, nor c explain why my old code fails with a newer compilor, and my new code works with an old compilor. I'm not explicitly loading or linking any DLLs (static libraries, yes, DLLs no). So this would only be an issue if the compilors after 9.1.3291 load different DLLs.&lt;/P&gt;
&lt;P&gt;e) seems to be the answer. I can start with a realease configuration and switch the Optimization setting from "maximise speed" to "disable" and the run time problems go away. Maximise speed is the /O2 setting? I'm running Intel under Visual Studio. What is the syntax to add the maximise speed setting to a single file?&lt;/P&gt;
&lt;P&gt;Thanks once again.&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2007 19:23:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764502#M19239</guid>
      <dc:creator>jarvusluntatintel</dc:creator>
      <dc:date>2007-11-08T19:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764503#M19240</link>
      <description>&lt;P&gt;To set properties for a single file in a project, right-click on file name in sloution explorer, the pick properties, optimizations, --- set what you want.&lt;/P&gt;
&lt;P&gt;For your other problems (aliases)&lt;/P&gt;
&lt;P&gt;I suggest you add conditional compilation code&lt;/P&gt;
&lt;P&gt;!DEC$ IF DEFINED (_DEBUG)&lt;BR /&gt; if((%loc(Node(1)).ge.%loc(NodeArray(1))&lt;BR /&gt;&amp;amp; .and. ((%loc(Node(size(Node))).le.%loc(NodeArray(size(NodeArray))))&lt;BR /&gt;&amp;amp; call Bug()&lt;BR /&gt;!DEC$ ENDIF&lt;BR /&gt; Node = 5.0&lt;BR /&gt; NodeArray(3) = NodeArray(3) + 10.0&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If you have several such places to test then consider creating a subroutine to verify no conflict of arguments.&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2007 19:55:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764503#M19240</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2007-11-08T19:55:04Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764504#M19241</link>
      <description>Offhand, I don't see a problem in the code example you posted. As long as you don't store into the same array element using two different names, you're ok. If you think your application has a problem with aliasing, use /assume:dummy-aliases - that's simpler than Jim's suggestion.&lt;BR /&gt;&lt;BR /&gt;You may want to try a build with the Static Verifier enabled. Please see the 10.0 documentation for details on that. Some of the warnings it give you may be for things that are not problems, but it can point out real errors. I would suggest downloading and installing the just-released 10.1 version if you want to do this, as SV is improved in that release.&lt;BR /&gt;</description>
      <pubDate>Thu, 08 Nov 2007 21:04:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764504#M19241</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2007-11-08T21:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: referencing actual arguments</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764505#M19242</link>
      <description>&lt;P&gt;If you have several (many) instances where you want sanity checks then a good way to perform the test is to make a logical function that takes the derived type and the suspected dummy variable and makes the test. &lt;/P&gt;
&lt;P&gt;subroutine aSub(A, B, C)&lt;BR /&gt;use MOD_FOO&lt;BR /&gt;real :: A, B, C&lt;BR /&gt;ASSERT((.NOT.WITHIN(FOO,A)))&lt;BR /&gt;ASSERT((.NOT.WITHIN(FOO,B)))&lt;BR /&gt;ASSERT((.NOT.WITHIN(FOO,C)))&lt;BR /&gt;! your code here&lt;BR /&gt;...&lt;BR /&gt;end subroutine aSub&lt;BR /&gt;&lt;BR /&gt;Then using the preprocessor #define ASSERT according to your requirements (non-code expansion for Release, call to bounds testing function and error for Debug configuration).&lt;/P&gt;
&lt;P&gt;You can also use ASSERT to test for NaN, valid reference address (e.g. is %LOC(A).EQ.0). All kinds of good tests (sanity checkes) in the debug version of the code. Good testing leads to good coding.&lt;/P&gt;
&lt;P&gt;Hint, note in my prior post FOO is a module derived type variable of Type (TypeFOO) which represents all the variables within MOD_FOO. Consider adding barrier variables to the type.&lt;/P&gt;
&lt;P&gt;type TypeFoo&lt;BR /&gt;sequence&lt;BR /&gt;#ifdef _DEBUG&lt;BR /&gt;CHARACTER(LEN=16) :: _BEGIN_&lt;BR /&gt;#endif&lt;BR /&gt;... ! declare TypeFoo variables&lt;BR /&gt;#ifdef _DEBUG&lt;BR /&gt;CHARACTER(LEN=1) :: _END_&lt;BR /&gt;#endif&lt;BR /&gt; end type TypeFoo&lt;BR /&gt;&lt;BR /&gt;The length of _BEGIN_ was chosen as to not interfere with SSE alignment. This can be UNION'ed with the first variable(s) if you do not wish to take up space. The LEN of _END_ can be adjusted to make TypeFoo a multiple of the largest type or derived type within TypeFoo. You do not have to use _BEGIN_ and _END_. Whatever you use, be consistent with all the derived types that you wish to test for conflict of use.&lt;/P&gt;
&lt;P&gt;Then in your #include header files&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;#define WITHIN(t,v) ((%loc(v) .ge. t%_BEGIN_) .and. (%loc(v) .le. t%_END_))&lt;BR /&gt;&lt;BR /&gt;#ifdef _DEBUG&lt;BR /&gt; #define ASSERT(x) if(.not. (x)) Call AssertFailure(__FILE__, __LINE__)&lt;BR /&gt; #else&lt;BR /&gt; #define ASSERT(x)&lt;BR /&gt;#endif&lt;/P&gt;
&lt;P&gt;Macro WITHIN always gets declared, macro ASSERT is declared or not depending on your needs. You can have your F90 source code free of the !DEC$ conditional assemblies and have clean looking code, yet at the same time the same code is suitable for Debug and Release configurations.&lt;/P&gt;
&lt;P&gt;It is not unusual to have two different ASSERT's one for Debugging and one for Release. You may want to test in your release code at least through Beta and some of the earlier revisions. In your production run, when performance matters configure such as to make ASSERT insert no code.&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Jim Dempsey&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2007 00:28:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/referencing-actual-arguments/m-p/764505#M19242</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2007-11-10T00:28:10Z</dc:date>
    </item>
  </channel>
</rss>

