Skip to content

Commit

Permalink
Move checkFmt to top of file to avoid compiler bug
Browse files Browse the repository at this point in the history
Some versions of gfortran ICE with the function in
the body of the file. Defining it first seems to be
fine and should be valid Fortran 2008.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85138
and #57
  • Loading branch information
andreww committed Mar 4, 2021
1 parent 6f60cf1 commit 6739255
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions fsys/fox_m_fsys_format.F90
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ module fox_m_fsys_format
contains

#ifndef DUMMYLIB
! NB: we need checkFmt at the top of the file
! to work around a bug in some Gfortran versions
! see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85138
pure function checkFmt(fmt) result(good)
character(len=*), intent(in) :: fmt
logical :: good

! should be ([rs]\d*)?

if (len(fmt) > 0) then
if (fmt(1:1) == "r" .or. fmt(1:1) == "s") then
if (len(fmt) > 1) then
good = (verify(fmt(2:), digit) == 0)
else
good = .true.
endif
else
good = .false.
endif
else
good = .true.
endif
end function checkFmt

! NB: The len generic module procedure is used in
! many initialisation statments (to set the
! length of the output string needed for the
Expand Down Expand Up @@ -2216,29 +2240,6 @@ pure function str_complex_dp_matrix(ca) result(s)
#endif
end function str_complex_dp_matrix

#ifndef DUMMYLIB
pure function checkFmt(fmt) result(good)
character(len=*), intent(in) :: fmt
logical :: good

! should be ([rs]\d*)?

if (len(fmt) > 0) then
if (fmt(1:1) == "r" .or. fmt(1:1) == "s") then
if (len(fmt) > 1) then
good = (verify(fmt(2:), digit) == 0)
else
good = .true.
endif
else
good = .false.
endif
else
good = .true.
endif
end function checkFmt
#endif

pure function concat_str_int(s1, s2) result(s3)
character(len=*), intent(in) :: s1
integer, intent(in) :: s2
Expand Down

0 comments on commit 6739255

Please sign in to comment.