Skip to content

Commit eeedbcf

Browse files
committed
testing workaround for gfortran bug.
1 parent d87619d commit eeedbcf

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

src/json_value_module.F90

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,12 @@ end subroutine json_matrix_info
12001200
!@note If `found` is present, no exceptions will be thrown if an
12011201
! error occurs. Otherwise, an exception will be thrown if the
12021202
! variable is not found.
1203+
!
1204+
!@warning There is a bug in gfortran-6.1.0 (and likely others) if using
1205+
! the `name` output and Unicode. The name will not be returned
1206+
! properly. It seems like setting an initial non-blank value
1207+
! before calling this routine can fix the issue in some cases.
1208+
! See `jf_test_19.F90`.
12031209

12041210
subroutine json_matrix_info_by_path(json,p,path,is_matrix,found,&
12051211
var_type,n_sets,set_size,name)
@@ -1241,18 +1247,19 @@ subroutine json_matrix_info_by_path(json,p,path,is_matrix,found,&
12411247
if (present(set_size)) set_size = 0
12421248
if (present(name)) name = ''
12431249
else
1244-
!get info:
12451250

12461251
!get info about the variable:
1247-
#if defined __GFORTRAN__
1248-
! [note: passing name directory to this routine seems
1249-
! to have a bug on older gfortran versions...
1250-
call json%matrix_info(p_var,is_matrix,var_type,n_sets,set_size,p_name)
1251-
if (present(name)) name = p_name
1252-
if (allocated(p_name)) deallocate(p_name)
1253-
#else
1252+
!#if defined __GFORTRAN__
1253+
! ! [note: passing name directory to this routine seems
1254+
! ! to have a bug on older gfortran versions...
1255+
! ! ... it also seems to be failing with unicode build ...
1256+
! ! ... this doesn't seem to fix the problem ...
1257+
! call json%matrix_info(p_var,is_matrix,var_type,n_sets,set_size,p_name)
1258+
! if (present(name)) name = p_name
1259+
! if (allocated(p_name)) deallocate(p_name)
1260+
!#else
12541261
call json%matrix_info(p_var,is_matrix,var_type,n_sets,set_size,name)
1255-
#endif
1262+
!#endif
12561263
if (json%failed() .and. present(found)) then
12571264
found = .false.
12581265
call json%clear_exceptions()

src/tests/jf_test_19.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ subroutine test_19(error_cnt)
9393
end if
9494

9595
! now, test by path:
96+
#if defined __GFORTRAN__
97+
!stupid workaround for gfortran bugs
98+
name = 'Hello!' ! just assign something before calling info routine
99+
#endif
96100
call json%matrix_info(p,'matrix',is_matrix,&
97101
var_type=var_type,n_sets=n_sets,&
98102
set_size=set_size,name=name)

0 commit comments

Comments
 (0)