fortran-lang / fprettify

auto-formatter for modern fortran source code

Home Page:https://pypi.python.org/pypi/fprettify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some limitations (or bugs in some way)

Jellby opened this issue · comments

After creating #99 and using it for a while, here are some of the limitations or problems I've found (that are not solved with the PR):

  • Keyword arguments to intrinsic functions or similar are not recognized as keywords and changed to upper-/lowercase. I refer to words like kind, inout, iostat or default (in real(kind=real64), intent(inout), open(10,iostat=err) and case default.
  • go to (two words) is not recognized either. See https://stackoverflow.com/a/63451186.
  • The sequence (/ in a format statement is misinterpreted as an array constructor, and causes a misalingment in continuation lines.
  • Numbered do loops (ending in a labeled continue statement) are not properly handled with respect to the indent.
  • Spacing after commas/intrinsics is confused by parentheses (as in implied dos).

A small sample that contains all these cases:

      subroutine foo(strings,flag)
      use iso_fortran_env, only: int32
      implicit none
      character(LeN=10), intent(In) :: strings(3)                               ! len, in
      integer(KiNd=InT32), intent(iN) :: flag                                   ! kind, in
      integer :: i, err
      select case (flag)
         case (1)
            open(10, IoStAt=err)                                                ! iostat
            if (err /= 0) Go To 100                                             ! go to
            write(10,'("(",a,")(",a,")(",a,")")') (strings(i)(1:10),i=1,3)      ! )(
            close(10)
            write(6,200) 'title',(strings(i)(1:10),i=1,3)                       ! ,(
         case DeFaUlT                                                           ! default
            do 20 i=1,10
              write(6,*) i
            20 continue                                                         ! numbered do
            if (flag < 0) then
               write(6,*) 'Negative'
            elseif (flag > 10) then                                             ! feature request: change "elseif" to "else if"
               write(6,*) 'Large'
            end if
      end select
100   return
200   format (/a &                                                              ! (/ misalignment
              /'(',a,')(',a,')(',a,')')
      end subroutine