<?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: Fortran subroutine dummy arguments mismatch calling arguments in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041462#M35924</link>
    <description>I guess my recollection is a little foggy and I must be thinking of the fatal execution error that occurs when code in a subroutine tries to use a dummy argument for which no actual argument was supplied.&lt;BR /&gt;&lt;BR /&gt;Maybe my colleagues and I have become so skilled that instances of argument mismatches have become increasingly rare over the years and this problem has not attracted our attention! I will share these comments with them and suggest we adopt the /warn=argument_check usage.&lt;BR /&gt;&lt;BR /&gt;We are a small group, set in our ways, and until I started investigating this behavior, had never been exposed to the "Interface" structure and some of the other more modern ideas expressed above. I do appreciate everyone's contribution here.&lt;BR /&gt;&lt;BR /&gt;Pat G.</description>
    <pubDate>Fri, 20 Apr 2007 09:45:17 GMT</pubDate>
    <dc:creator>Patrick Grealy</dc:creator>
    <dc:date>2007-04-20T09:45:17Z</dc:date>
    <item>
      <title>Fortran subroutine dummy arguments mismatch calling arguments</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041457#M35919</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have always thought that in Fortran if a calling statement used a different number of arguments than the number of dummy arguments in the subroutine that a compiler warning and/or fatal execution error occurred. However, I was suprised to learn recently that this is not the case.&lt;BR /&gt;&lt;BR /&gt;If the calling statement has two arguments and the subroutine has three dummy arguments there is no compiler warning nor execution error unless the subroutine tries to use dummy arg 3; then there is an execution error. If the calling statement has three arguments and the subroutine has two dummy arguments there is no warning and no execution error.&lt;BR /&gt;&lt;BR /&gt;Our system is OpenVMS 7.3-1 and we have HP Fortran V7.6-3276 installed. I have looked in the documentation and found the compiler switch "/warn=argument_checking" that should help quite a bit. It will force compilation warnings when the calling module and subroutine are "compiled together" and argument counts are mismatched. However, if the subroutine is in a linked library this would not help.&lt;BR /&gt;&lt;BR /&gt;I have a couple of questions. Is there some other option that I am overlooking? Did this behavior change in transitioning from Fortran 77(DEC) to Fortran 95(HP)? Finally, is there a way I could make our Fortran installation default to "/warn=argument_checking"?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Pat Grealy</description>
      <pubDate>Thu, 19 Apr 2007 16:17:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041457#M35919</guid>
      <dc:creator>Patrick Grealy</dc:creator>
      <dc:date>2007-04-19T16:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran subroutine dummy arguments mismatch calling arguments</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041458#M35920</link>
      <description>&lt;!--!*#--&gt;My Fortran 77 V7.1-156 compiler does not output warnings for this even when using /WARNING=ARGUMENT_CHECKING.&lt;BR /&gt;&lt;BR /&gt;There is an advantage to the default non-checking behaviour, at least for the case of an extra dummy argument in the subroutine.  At our site we add new arguments to subroutines sometimes when we want to add new options to them.  However so that we don't have to find and modify all old code that calls the subroutine the default behaviour stays the same if the new argument is missing.  We use the DEC-extension IARGCOUNT intrinsic to check of the new argument was passed or not before using it.  Of course this practice is not standard Fortran.&lt;BR /&gt;&lt;BR /&gt;Just to make clear what the documentation means when it says /WARN=ARGUMENT_CHECKING only applies if the two routines are "compiled together".  Either the two routines must be in the same source module, or if they are in separate modules they must be compiled with one command line that lists both source files with a + between them, as in:&lt;BR /&gt;&lt;BR /&gt;$ F90 /WARN=ARGUMENT_CHECKING MAIN.F+SUB.F&lt;BR /&gt;&lt;BR /&gt;This is one of the few cases in VMS where using a + instead of a , between two files in a list makes a difference.&lt;BR /&gt;&lt;BR /&gt;Also you obviously can not use the qualifer /SEPARATE_COMPILE (normally that is only used when creating object libraries from one source module with mulitple routines).</description>
      <pubDate>Thu, 19 Apr 2007 17:47:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041458#M35920</guid>
      <dc:creator>Jess Goodman</dc:creator>
      <dc:date>2007-04-19T17:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran subroutine dummy arguments mismatch calling arguments</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041459#M35921</link>
      <description>Hi Pat,&lt;BR /&gt;&lt;BR /&gt;When an explicit interface is present between calling and called procedures, warning messages about argument mismatches are reported whether or not you specify -warn argument_checking.&lt;BR /&gt;Defining explicit interface such as INTERFACE ...END INTERFACE is available in F77?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Archunan</description>
      <pubDate>Thu, 19 Apr 2007 19:24:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041459#M35921</guid>
      <dc:creator>Arch_Muthiah</dc:creator>
      <dc:date>2007-04-19T19:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran subroutine dummy arguments mismatch calling arguments</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041460#M35922</link>
      <description>Pat,&lt;BR /&gt;&lt;BR /&gt;  The behaviour has not changed. That's the way Fortran has been forever on VMS (indeed, many people have exploited the lack of argument checking to implement/hack variable argument lists). Excess arguments are always tolerated. See the OpenVMS calling standard to help understand why.&lt;BR /&gt;&lt;BR /&gt;  Fortran is showing its age! The issue here is the nature of the languge. Fortran originally compiled modules in complete isolation, so the compiler had to believe whatever you claimed about external objects, in particular argument lists. Over time some limited checking/enforcment features have been added.&lt;BR /&gt;&lt;BR /&gt;  If the compiler can see both modules at the same time, then /WARN=ARGUMENT_CHECKING is feasible. As Jess has explained that requires the routines to either be in the same source file, or the compiler parameters "added" with "+" rather than ",".&lt;BR /&gt; Although there is some capability for the linker to check argument lists, it's not widely used by compilers (and can cause trouble as there are many cases where argument lists can vary).&lt;BR /&gt;&lt;BR /&gt;  If you use Fortran modules, with interface definitions and the USE sttement to import modules, you can give the compiler the information it needs to check routine interfaces, without having to compile everything together. Note that this will require a fairly significant change in programming style. (some would say for the better, but others would say, if you want to code like that, switch to Pascal or Ada)</description>
      <pubDate>Thu, 19 Apr 2007 20:03:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041460#M35922</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2007-04-19T20:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran subroutine dummy arguments mismatch calling arguments</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041461#M35923</link>
      <description>&lt;!--!*#--&gt;(I hate to say it, but) A.M. probably has the&lt;BR /&gt;best answer here.  You can put an INTERFACE&lt;BR /&gt;spec into a header file, and then INCLUDE&lt;BR /&gt;that file into the file with the subprogram&lt;BR /&gt;itself, and into the file where the&lt;BR /&gt;subprogram is invoked.  The compiler will&lt;BR /&gt;check the subprogram definition or its&lt;BR /&gt;invocation against the included INTERFACE&lt;BR /&gt;spec, and complain as warranted.&lt;BR /&gt;&lt;BR /&gt;My Fortran is extremely rusty, but a crude&lt;BR /&gt;example follows.&lt;BR /&gt;&lt;BR /&gt;alp $ type A.FH&lt;BR /&gt;C     Interface specification for function a( b, c)&lt;BR /&gt;&lt;BR /&gt;      interface&lt;BR /&gt;        function a( b, c)&lt;BR /&gt;          integer* 4 a&lt;BR /&gt;          integer* 4 b&lt;BR /&gt;          real* 8 c&lt;BR /&gt;        end function&lt;BR /&gt;      end interface&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;alp $ type A_SUB.FOR&lt;BR /&gt;C     Useless function a( b, c), with explicit interface.&lt;BR /&gt;&lt;BR /&gt;      function a( b, c)&lt;BR /&gt;&lt;BR /&gt;      implicit none&lt;BR /&gt;&lt;BR /&gt;      include 'a.fh'&lt;BR /&gt;&lt;BR /&gt;        integer* 4 a&lt;BR /&gt;        integer* 4 b&lt;BR /&gt;        real* 8 c&lt;BR /&gt;&lt;BR /&gt;      a = b* c&lt;BR /&gt;&lt;BR /&gt;      end function&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;alp $ type A_MAIN.FOR&lt;BR /&gt;C     Useless main program.&lt;BR /&gt;&lt;BR /&gt;      program a_main&lt;BR /&gt;&lt;BR /&gt;      implicit none&lt;BR /&gt;&lt;BR /&gt;      include 'a.fh'&lt;BR /&gt;&lt;BR /&gt;      integer* 4 x&lt;BR /&gt;      integer* 4 y&lt;BR /&gt;      real* 8 z&lt;BR /&gt;&lt;BR /&gt;      y = 3&lt;BR /&gt;      z = 4.&lt;BR /&gt;      x = a( y, z)&lt;BR /&gt;&lt;BR /&gt;      print *, " x = ", x&lt;BR /&gt;&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;alp $ for A_SUB&lt;BR /&gt;alp $ for A_MAIN&lt;BR /&gt;alp $ link A_MAIN, A_SUB&lt;BR /&gt;alp $ run A_MAIN&lt;BR /&gt; x =           12&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Try to use the function with a bad argument&lt;BR /&gt;list:&lt;BR /&gt;&lt;BR /&gt;alp $ for B_MAIN&lt;BR /&gt;&lt;BR /&gt;      x = a( y)&lt;BR /&gt;..........^&lt;BR /&gt;%F90-E-ERROR, A non-optional actual argument must be present when invoking a pro&lt;BR /&gt;cedure with an explicit interface.   [C]&lt;BR /&gt;at line number 15 in file ALP$DKA0:[SMS]B_MAIN.FOR;8&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Forget to include the header file:&lt;BR /&gt;&lt;BR /&gt;alp $ for C_MAIN&lt;BR /&gt;&lt;BR /&gt;      x = a( y, z)&lt;BR /&gt;..........^&lt;BR /&gt;%F90-E-ERROR, This name does not have a type, and must have an explicit type.&lt;BR /&gt;[A]&lt;BR /&gt;at line number 15 in file ALP$DKA0:[SMS]C_MAIN.FOR;2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hardly an exhaustive test, but perhaps a fair&lt;BR /&gt;demonstration of the scheme.  Note that with&lt;BR /&gt;IMPLICIT NONE (one of the best ideas ever),&lt;BR /&gt;no special compiler options are needed to&lt;BR /&gt;generate either of these complaints.&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Apr 2007 23:42:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041461#M35923</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-04-19T23:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran subroutine dummy arguments mismatch calling arguments</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041462#M35924</link>
      <description>I guess my recollection is a little foggy and I must be thinking of the fatal execution error that occurs when code in a subroutine tries to use a dummy argument for which no actual argument was supplied.&lt;BR /&gt;&lt;BR /&gt;Maybe my colleagues and I have become so skilled that instances of argument mismatches have become increasingly rare over the years and this problem has not attracted our attention! I will share these comments with them and suggest we adopt the /warn=argument_check usage.&lt;BR /&gt;&lt;BR /&gt;We are a small group, set in our ways, and until I started investigating this behavior, had never been exposed to the "Interface" structure and some of the other more modern ideas expressed above. I do appreciate everyone's contribution here.&lt;BR /&gt;&lt;BR /&gt;Pat G.</description>
      <pubDate>Fri, 20 Apr 2007 09:45:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041462#M35924</guid>
      <dc:creator>Patrick Grealy</dc:creator>
      <dc:date>2007-04-20T09:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran subroutine dummy arguments mismatch calling arguments</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041463#M35925</link>
      <description>&amp;gt; [...] had never been exposed to the&lt;BR /&gt;&amp;gt; "Interface" structure &lt;BR /&gt;&lt;BR /&gt;It was news to me, too.  I haven't done any&lt;BR /&gt;Fortran work since it was still FORTRAN, and&lt;BR /&gt;names longer than six characters were new and&lt;BR /&gt;exotic.  I don't think that I'd ever seen a&lt;BR /&gt;message which started out "%F90-".&lt;BR /&gt;&lt;BR /&gt;Looking around, it appears that my (old)&lt;BR /&gt;"header" files were confined to COMMON&lt;BR /&gt;declarations.  (It's nice if everyone agrees&lt;BR /&gt;on what's in COMMON, too.)  I always assumed&lt;BR /&gt;that "Fortran" had a bunch more modern&lt;BR /&gt;features than "FORTRAN", but I haven't needed&lt;BR /&gt;to deal with the stuff for a decade or so, so&lt;BR /&gt;I never learned any of the more modern stuff.&lt;BR /&gt;Maybe someday when everything else works&lt;BR /&gt;right, ...</description>
      <pubDate>Fri, 20 Apr 2007 10:35:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-subroutine-dummy-arguments-mismatch-calling-arguments/m-p/5041463#M35925</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2007-04-20T10:35:30Z</dc:date>
    </item>
  </channel>
</rss>

