@@ -698,9 +698,9 @@ subroutine json_file_load_from_string(me, str)
698
698
699
699
class(json_file),intent (inout ) :: me
700
700
character (kind= CK,len=* ),intent (in ) :: str
701
-
701
+
702
702
call json_parse(str= str, p= me% p)
703
-
703
+
704
704
end subroutine json_file_load_from_string
705
705
! *****************************************************************************************
706
706
@@ -3979,7 +3979,7 @@ subroutine json_parse(file, p, unit, str)
3979
3979
3980
3980
! clear any exceptions and initialize:
3981
3981
call json_initialize()
3982
-
3982
+
3983
3983
if (present (unit) .and. present (file) .and. .not. present (str)) then
3984
3984
3985
3985
if (unit== 0 ) then
@@ -4217,8 +4217,8 @@ recursive subroutine parse_value(unit, str, value)
4217
4217
select case (value% var_type)
4218
4218
case (json_string)
4219
4219
call parse_string(unit, str, tmp) ! write to a tmp variable because of
4220
- value% str_value = tmp ! a bug in 4.9 gfortran compiler.
4221
- deallocate (tmp)
4220
+ value% str_value = tmp ! a bug in 4.9 gfortran compiler.
4221
+ deallocate (tmp) !
4222
4222
end select
4223
4223
4224
4224
case (true_str(1 :1 ))
@@ -4778,7 +4778,7 @@ recursive subroutine parse_object(unit, str, parent)
4778
4778
else if (quotation_mark == c) then
4779
4779
call json_value_create(pair)
4780
4780
call parse_string(unit, str, tmp) ! write to a tmp variable because of
4781
- pair % name = tmp ! a bug in 4.9 gfortran compiler.
4781
+ pair % name = tmp ! a bug in 4.9 gfortran compiler.
4782
4782
deallocate (tmp)
4783
4783
if (exception_thrown) then
4784
4784
call json_destroy(pair)
@@ -4810,8 +4810,8 @@ recursive subroutine parse_object(unit, str, parent)
4810
4810
return
4811
4811
end if
4812
4812
4813
- ! another possible pair
4814
- c = pop_char(unit, str= str, eof = eof, skip_ws = .true. )
4813
+ ! another possible pair
4814
+ c = pop_char(unit, str= str, eof = eof, skip_ws = .true. )
4815
4815
if (eof) then
4816
4816
call throw_exception(' Error in parse_object: ' // &
4817
4817
' End of file encountered when parsing an object' )
@@ -4938,7 +4938,7 @@ subroutine parse_string(unit, str, string)
4938
4938
4939
4939
! get the next character from the file:
4940
4940
c = pop_char(unit, str= str, eof = eof, skip_ws = .false. )
4941
-
4941
+
4942
4942
if (eof) then
4943
4943
4944
4944
call throw_exception(' Error in parse_string: Expecting end of string' )
@@ -5174,6 +5174,7 @@ recursive function pop_char(unit, str, eof, skip_ws) result(popped)
5174
5174
character (kind= CK,len= 1 ) :: c
5175
5175
logical (LK) :: ignore
5176
5176
integer (IK) :: str_len
5177
+ character (kind= CK,len= :),allocatable :: tmp ! workaround for bug in gfortran 4.9.2 compiler
5177
5178
5178
5179
if (.not. exception_thrown) then
5179
5180
@@ -5197,14 +5198,17 @@ recursive function pop_char(unit, str, eof, skip_ws) result(popped)
5197
5198
if (unit/= 0 ) then ! read from the file
5198
5199
read (unit = unit, fmt = ' (A1)' , advance = ' NO' , iostat = ios) c
5199
5200
else ! read from the string
5200
- str_len = len (str) ! length of the string
5201
+ tmp = str ! !! copy to a temp variable to workaround a bug in gfortran 4.9.2
5202
+ str_len = len (tmp) ! length of the string
5201
5203
if (str_len> 0 ) then
5202
- c = str (1 :1 )
5204
+ c = tmp (1 :1 )
5203
5205
if (str_len> 1 ) then
5204
- str = str (2 :str_len) ! remove the character that was read
5206
+ tmp = tmp (2 :str_len) ! remove the character that was read
5205
5207
else
5206
- str = ' ' ! that was the last one
5208
+ tmp = ' ' ! that was the last one
5207
5209
end if
5210
+ str = tmp
5211
+ deallocate (tmp) ! !!
5208
5212
ios = 0
5209
5213
else
5210
5214
ios = IOSTAT_END ! end of the string
0 commit comments