Skip to content

Commit 290f83d

Browse files
committed
Merge pull request #191 from jacobwilliams/gfortran-bugs
Gfortran bugs
2 parents 7e0bf0f + 8710c16 commit 290f83d

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/json_string_utilities.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ pure function valid_json_hex(str) result(valid)
461461
integer(IK) :: n !! length of `str`
462462
integer(IK) :: i !! counter
463463

464-
!an array of the valid hex characters:
464+
!> an array of the valid hex characters
465465
character(kind=CK,len=1),dimension(22),parameter :: valid_chars = &
466466
[ (achar(i),i=48,57), & ! decimal digits
467467
(achar(i),i=65,70), & ! capital A-F

src/json_value_module.F90

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ subroutine json_initialize(json,verbose,compact_reals,&
672672

673673
!
674674
!JW comment out for now (these are now protected variables in another module)
675-
! for thread-save version, we won't be able to have global variables.........
675+
! for thread-safe version, we won't be able to have global variables.........
676676
!
677677
!Ensure gfortran bug work around "parameters" are set properly
678678
!null_str = 'null'
@@ -1001,13 +1001,13 @@ subroutine json_throw_exception(json,msg)
10011001
json%err_message = trim(msg)
10021002

10031003
if (json%is_verbose) then
1004-
write(*,'(A)') '***********************'
1005-
write(*,'(A)') 'JSON-Fortran Exception: '//trim(msg)
1004+
write(output_unit,'(A)') '***********************'
1005+
write(output_unit,'(A)') 'JSON-Fortran Exception: '//trim(msg)
10061006
!call backtrace() ! gfortran (use -fbacktrace -fall-intrinsics flags)
10071007
#ifdef __INTEL_COMPILER
10081008
call tracebackqq(user_exit_code=-1) ! print a traceback and return
10091009
#endif
1010-
write(*,'(A)') '***********************'
1010+
write(output_unit,'(A)') '***********************'
10111011
end if
10121012

10131013
end subroutine json_throw_exception
@@ -4724,8 +4724,10 @@ recursive subroutine parse_value(json, unit, str, value)
47244724

47254725
logical(LK) :: eof
47264726
character(kind=CK,len=1) :: c
4727+
#if defined __GFORTRAN__
47274728
character(kind=CK,len=:),allocatable :: tmp !! this is a work-around for a bug
47284729
!! in the gfortran 4.9 compiler.
4730+
#endif
47294731

47304732
if (.not. json%exception_thrown) then
47314733

@@ -4766,9 +4768,13 @@ recursive subroutine parse_value(json, unit, str, value)
47664768

47674769
select case (value%var_type)
47684770
case (json_string)
4769-
call json%parse_string(unit, str, tmp) !write to a tmp variable because of
4770-
value%str_value = tmp ! a bug in 4.9 gfortran compiler.
4771-
deallocate(tmp) !
4771+
#if defined __GFORTRAN__
4772+
call json%parse_string(unit,str,tmp) ! write to a tmp variable because of
4773+
value%str_value = tmp ! a bug in 4.9 gfortran compiler.
4774+
deallocate(tmp) !
4775+
#else
4776+
call json%parse_string(unit, str, value%str_value)
4777+
#endif
47724778
end select
47734779

47744780
case (CK_'t') !true_str(1:1) gfortran bug work around
@@ -5343,8 +5349,10 @@ recursive subroutine parse_object(json, unit, str, parent)
53435349
type(json_value),pointer :: pair
53445350
logical(LK) :: eof
53455351
character(kind=CK,len=1) :: c
5352+
#if defined __GFORTRAN__
53465353
character(kind=CK,len=:),allocatable :: tmp !! this is a work-around for a bug
53475354
!! in the gfortran 4.9 compiler.
5355+
#endif
53485356

53495357
if (.not. json%exception_thrown) then
53505358

@@ -5366,9 +5374,13 @@ recursive subroutine parse_object(json, unit, str, parent)
53665374
return
53675375
else if (quotation_mark == c) then
53685376
call json_value_create(pair)
5369-
call json%parse_string(unit, str, tmp) !write to a tmp variable because of
5370-
pair % name = tmp ! a bug in 4.9 gfortran compiler.
5377+
#if defined __GFORTRAN__
5378+
call json%parse_string(unit,str,tmp) ! write to a tmp variable because of
5379+
pair%name = tmp ! a bug in 4.9 gfortran compiler.
53715380
deallocate(tmp)
5381+
#else
5382+
call json%parse_string(unit,str,pair%name)
5383+
#endif
53725384
if (json%exception_thrown) then
53735385
call json%destroy(pair)
53745386
return
@@ -5920,7 +5932,7 @@ subroutine json_print_error_message(json,io_unit)
59205932
if (present(io_unit)) then
59215933
write(io_unit,'(A)') error_msg
59225934
else
5923-
write(*,'(A)') error_msg
5935+
write(output_unit,'(A)') error_msg
59245936
end if
59255937
deallocate(error_msg)
59265938
call json%clear_exceptions()

0 commit comments

Comments
 (0)