• "Mistakes in Fortran 90 Programs That Might Surprise You "

    From Lynn McGuire@lynnmcguire5@gmail.com to comp.lang.fortran on Tue Jul 22 16:23:16 2025
    From Newsgroup: comp.lang.fortran

    "Mistakes in Fortran 90 Programs That Might Surprise You"
    https://www.cs.rpi.edu/~szymansk/OOF90/bugs.html

    Oh yeah, I have seen several of these.

    Lynn

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Lawrence D'Oliveiro@ldo@nz.invalid to comp.lang.fortran on Wed Jul 23 00:45:34 2025
    From Newsgroup: comp.lang.fortran

    On Tue, 22 Jul 2025 16:23:16 -0500, Lynn McGuire wrote:

    "Mistakes in Fortran 90 Programs That Might Surprise You"
    https://www.cs.rpi.edu/~szymansk/OOF90/bugs.html

    That first one should really be “Fortran does not do short-cut Boolean evaluation”. That would be a more general issue than just with optional arguments.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Thomas Koenig@tkoenig@netcologne.de to comp.lang.fortran on Wed Jul 23 09:24:15 2025
    From Newsgroup: comp.lang.fortran

    Lynn McGuire <lynnmcguire5@gmail.com> schrieb:
    "Mistakes in Fortran 90 Programs That Might Surprise You"
    https://www.cs.rpi.edu/~szymansk/OOF90/bugs.html

    Oh yeah, I have seen several of these.

    Nice list.

    gfortran catches this one:

    program main
    real, dimension(5) :: x

    x = 0.
    ! THIS IS WRONG
    call incb(x)
    print *, x

    end program main

    subroutine incb(a)
    ! this is a fortran90 style subroutine
    real, dimension(:) :: a
    a = a + 1.
    end subroutine incb

    $ gfortran x.f90
    x.f90:6:15:

    6 | call incb(x)
    | 1
    Error: Explicit interface required for 'incb' at (1): assumed-shape argument

    but only within the same file. Same for this. The error message
    could be better, but at least it points to the problem:

    $ cat y.f90
    program main
    real, dimension(5) :: x

    ! interface to Fortran 77 style routine
    interface
    subroutine inca(a,n)
    integer :: n
    ! THIS IS THE WRONG WAY
    real, dimension(:) :: a
    ! THIS IS THE RIGHT WAY
    ! real, dimension(n) :: a
    end subroutine inca
    end interface

    x = 0.
    call inca(x,5)
    print *, x

    end program main

    subroutine inca(a,n)
    ! this is a fortran77 style subroutine
    dimension a(n)
    do 10 j = 1, n
    a(j) = a(j) + 1.
    10 continue
    return
    end

    $ gfortran y.f90
    y.f90:6:10:

    6 | subroutine inca(a,n)
    | 1~~~~~~~~~~~~~~
    Warning: Interface mismatch in global procedure 'inca' at (1): Shape mismatch in argument 'a'
    --
    This USENET posting was made without artificial intelligence,
    artificial impertinence, artificial arrogance, artificial stupidity,
    artificial flavorings or artificial colorants.
    --- Synchronet 3.21a-Linux NewsLink 1.2