From 67392555814373aac63979ef8ccd8e2fd1444ae3 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Thu, 4 Mar 2021 11:47:23 +0000 Subject: [PATCH] Move checkFmt to top of file to avoid compiler bug 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 https://github.com/andreww/fox/issues/57 --- fsys/fox_m_fsys_format.F90 | 47 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/fsys/fox_m_fsys_format.F90 b/fsys/fox_m_fsys_format.F90 index 4508cde9..dbf11d37 100644 --- a/fsys/fox_m_fsys_format.F90 +++ b/fsys/fox_m_fsys_format.F90 @@ -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 @@ -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