[J3] Order of statements Table 5.1 and 5.2

Shafran, Aury aury.shafran at intel.com
Tue Aug 13 17:47:38 UTC 2024


Right below 5.1 it says "Table 5.1 shows the ordering rules for statements and applies to all program units, subprograms, and interface bodies."  So in a sense, 5.1 is recursive/nested. Where it says "internal subprogram" and "module subprogram", another entire copy of 5.1 can be inserted there. In other words, the "missing" CONTAINS in 5.1 is implied by/part of the term "module subprogram" itself.

Also note that a subprogram contained within a module subprogram or external subprogram is an internal subprogram. There is a constraint that prohibits internal subprograms from having a CONTAINS, so (excluding interface bodies) this is the maximum nesting of table 5.1:

module a
contains
    subroutine b()  ! module procedure
    contains
        subroutine c()  ! internal procedure
        end subroutine
    end subroutine
end module

Thanks,
Aury

-----Original Message-----
From: J3 <j3-bounces at mailman.j3-fortran.org> On Behalf Of Steven G. Kargl via J3
Sent: Tuesday, August 13, 2024 10:23 AM
To: J3 Fortran <j3 at mailman.j3-fortran.org>
Cc: Steven G. Kargl <kargl at uw.edu>
Subject: [J3] Order of statements Table 5.1 and 5.2

Is there a conflict in the Table 5.1 and 5.2?
5.1 suggests that a CONTAINS statement occurs
before a module subprogram, and that a CONTAINS
cannot appear in a module subprogram.  5.2 indicates
that it can.

Table 5.1

------------------------
CONTAINS
------------------------
Internal subprograms
module subprograms
------------------------
END statement

Should this be

------------------------
CONTAINS
-----------------------------------------
Internal subprograms | module subprograms   
                     | CONTAINS   
------------------------------------------
END statement

-- 
Steve



More information about the J3 mailing list