[J3] Is this code standard conforming?
Van Snyder
van.snyder at jpl.nasa.gov
Thu Apr 19 19:24:14 EDT 2018
On Thu, 2018-04-19 at 22:47 +0000, Bill Long via J3 wrote:
> FWIW, the only compiler I tried compiled the code with no messages.
>
> But, an include file with a USE statement? The only function of
> include in Fortran (which would be eliminated if we implement
> templates) is one that would disallow USE statements. Perhaps you
> should include a “no include files” as part of the best practices
> style guide for Fortran.
I routinely put USE statements within BLOCK constructs included by
INCLUDE statements.
As Stan said years ago, about ARITHEMTIC IF etc.: "Go ahead and delete
them; I still have to compile them forever."
> Cheers,
> Bill
>
>
> > On Apr 19, 2018, at 7:35 AM, Clune, Thomas L. (GSFC-6101) via J3 <j3 at mailman.j3-fortran.org> wrote:
> >
> >
> >> On Apr 19, 2018, at 5:37 AM, Robert Corbett via J3 <j3 at mailman.j3-fortran.org> wrote:
> >>
> >>
> >> The code you show appears to be
> >> standard conforming. The last two
> >> USE statements are equivalent to the
> >> penultimate USE statement by itself.
> >> I assume that is the reason for the
> >> warning message you mention.
> >
> > Yes - that was a latent mistake in some bit of code. Not obvious in the real code because an include file brought in one of the use statements. Only noticed it when a compiler update then started generating error messages. The cleaner code is better on all counts, but I was trying to be a good citizen and inform the vendors that it was generating incorrect error messages. Vendor disagreed. Or quite possibly just misunderstood my submission. But I did not want to argue the case without further clarification.
> >
> > Thanks,
> >
> > - Tom
> >
> >>
> >> Robert Corbett
> >>
> >> On Apr 18, 2018, at 11:19 AM, Clune, Thomas L. (GSFC-6101) via J3 <j3 at mailman.j3-fortran.org> wrote:
> >>
> >>> I believe that the attached code is standard conforming but is generating an error with one vendor claiming that the same named entity from different modules or program units cannot be referenced. I disagree with this interpretation, and do not get similar errors with any of the other compilers that I’ve tried.
> >>>
> >>> Full disclosure the attached version is slightly different than the one submitted to the vendor, but it generates the same error message. I have moved the “USE PFUNIT” line from the header of Foo_mod down to the contained subroutine.
> >>>
> >>> Additional details: The error goes away if I eliminate _any_ of the 3 USE statements in the main program. If the latter 2 are both kept, sensible warning messages are generated.
> >>>
> >>> The code:
> >>>
> >>> module pFUnit
> >>> implicit none
> >>>
> >>> interface AssertEqual
> >>> module procedure assertEqual_int_int
> >>> end interface AssertEqual
> >>>
> >>> contains
> >>>
> >>> subroutine assertEqual_int_int(i,j)
> >>> integer, intent(in) :: i
> >>> integer, intent(in) :: j
> >>> end subroutine assertEqual_int_int
> >>>
> >>> end module pFUnit
> >>>
> >>>
> >>> module Foo_mod
> >>> implicit none
> >>> private
> >>>
> >>> public :: Foo
> >>> public :: assertEqual
> >>>
> >>> type Foo
> >>> integer :: i
> >>> contains
> >>> end type Foo
> >>>
> >>> interface assertEqual
> >>> module procedure assertEqual_FooFoo
> >>> end interface assertEqual
> >>>
> >>> contains
> >>>
> >>> subroutine assertEqual_FooFoo(a, b)
> >>> use pFUnit
> >>> class (Foo), intent(in) :: a
> >>> class (Foo), intent(in) :: b
> >>>
> >>> call assertEqual(a%i, b%i)
> >>>
> >>> end subroutine assertEqual_FooFoo
> >>>
> >>>
> >>> end module Foo_mod
> >>>
> >>>
> >>>
> >>> program main
> >>> use pFUnit, only : assertEqual
> >>> use Foo_mod
> >>> use Foo_mod, only: assertEqual
> >>> implicit none
> >>>
> >>> end program main
> >>>
> >
>
> Bill Long longb at cray.com
> Principal Engineer, Fortran Technical Support & voice: 651-605-9024
> Bioinformatics Software Development fax: 651-605-9143
> Cray Inc./ 2131 Lindau Lane/ Suite 1000/ Bloomington, MN 55425
>
>
More information about the J3
mailing list