Closed gh4ag closed 4 years ago
Very odd.
I don't see this behavior using my local gfortran 9.1.0. And the TravisCI is testing 9.2.1 and doesn't seem to have any problems. Maybe it a gfortran compiler bug of some kind with 9.3?
What happens if you run this version of the main program?:
PROGRAM Test
use json_module, ik => json_ik, rk => json_rk, lk => json_lk
type(json_file) :: json
logical(kind=lk) :: found
real(kind=rk), dimension(:), allocatable :: rArray
integer(kind=ik), dimension(:), allocatable :: val !! value
print *, "Reading json..."
! initialize the class
call json%initialize(strict_integer_type_checking=.true.)
if (json%failed()) error stop 'init error'
! read the file
call json%load(filename='file.json')
if (json%failed()) error stop 'load error'
! retreive value from json
call json%get('data.num', val, found)
if (json%failed()) error stop 'get error'
print *, "Num: ", int(val)
! print the file to the console
call json%print()
! clean up
call json%destroy()
if (json%failed()) stop 1
END PROGRAM Test
I can reproduce the issue with 9.3 now, with the binaries provided by homebrew (and also the ones I compile myself).
It seems if I remove the -std=legacy
it works. Can you confirm? JSON-Fortran isn't compiled with this flag and shouldn't need it. It seems as if it is doing something weird.
Note that this only seems to effect the unicode version of the library. When compiled without unicode, it works with or without this -std=legacy
argument.
I would say it's a compiler bug.
You nailed it! Removing the flag -std=legacy
solved the issue as well with the version 8.0 and GCC 9.3.
I had reused a colleague's code that used that flag and I used it to reproduce the issue. As you have mentioned it, it shouldn't be useful anymore and I will update our code accordingly.
If you agree, I would consider this issue closed then.
One thing though, on Homebrew, it is possible for some formulae to access previous version using brew install formula@X.Y
where X.Y is the version number. Would it make sense for json-fortran to offer previous versions in the same manner or you would consider that the installation from source is enough?
Thank you for your swift response!
Full Report
See issue reported here on hombrew for full detail with complete MWE.
Summary:
The error is that any integer greater than 9 will be parsed as 1 when loading a json file when using the version 8 of
json-fortran
.Basically, Homebrew only allows users to install son-fortran version 8 compiled with GCC 9.3 using the following config (https://github.com/Homebrew/homebrew-core/blob/master/Formula/json-fortran.rb) :
Installing the V8 from source resulted to the same behavior.
However, reverting to V7.1 even with GCC 9.3 fixed the issue.