[J3] [EXTERNAL] [BULK] Order of statements Table 5.1 and 5.2

Shafran, Aury aury.shafran at intel.com
Tue Aug 13 18:18:39 UTC 2024


Both of those examples are valid*. A "separate-module-subprogram" and a "module-subprogram" are both module subprograms, and both of them may have a CONTAINS with internal subprograms. However, those internal subprograms may NOT further contain more internal subprograms, as specified by C1575.

* Well, there's a few typos, and in the 2nd example "module procedure subroutine s" should just be "module procedure s". But assuming your intent, they're both valid.

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 2:07 PM
To: General J3 interest list <j3 at mailman.j3-fortran.org>
Cc: Steven G. Kargl <kargl at uw.edu>
Subject: Re: [J3] [EXTERNAL] [BULK] Order of statements Table 5.1 and 5.2

It could be me that is confused by the syntax rule.

R1537 indicates a subroutine-subprogram can have a
internal-subprogram-part.   Then, C1575 states that
a "An internal subroutine subprogram shall not contain
an internal-subprogram-part."  Now, if I look at R1408
and R1541,

R1408 module-subprogram  is function-subprogram
                         or subroutine-subprogram
                         or separate-module-subprogram

R1541 separate-module-subprogram is mp-subprogram-stmt
                                    [ specification-part ]
                                    [ execution-part ]
                                    [ internal-subprogram-part ]
                                    end-mp-subprogram-stmt
So, the distinction is

module
  contains
    subroutine s
       constains        ! <-- This is not allowed.
         subroutine t
         end subroutine t
    end subroutine s
end

but

module
  contains
    module procedure subroutine s
       constains        ! <-- This is allowed.
         subroutine t
         end subroutine t
    end subroutine s
end

-- 
steve


On Tue, Aug 13, 2024 at 05:29:42PM +0000, Clune, Thomas L. (GSFC-6101) via J3 wrote:
> Perhaps I’m misunderstanding, but I’m seeing a big “NO” in table 5.2 for CONTAINS with Internal Subprogram?
> 
> 
> 
> From: J3 <j3-bounces at mailman.j3-fortran.org> on behalf of Steven G. Kargl via J3 <j3 at mailman.j3-fortran.org>
> Date: Tuesday, August 13, 2024 at 10:22 AM
> To: J3 Fortran <j3 at mailman.j3-fortran.org>
> Cc: Steven G. Kargl <kargl at uw.edu>
> Subject: [EXTERNAL] [BULK] [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

-- 
Steve


More information about the J3 mailing list