Open a random JSON file generated by http://www.json-generator.com
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(out) | :: | error_cnt |
subroutine test_9(error_cnt)
!! Open a random JSON file generated by http://www.json-generator.com
implicit none
integer,intent(out) :: error_cnt
type(json_file) :: f
real :: tstart, tend
character(len=:),allocatable :: str
error_cnt = 0
write(error_unit,'(A)') ''
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ' EXAMPLE 9a '
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ''
write(error_unit,'(A)') ' Load a file using json_file%load_file'
write(error_unit,'(A)') ''
write(error_unit,'(A)') 'Loading file: '//trim(filename)
call cpu_time(tstart)
call f%load_file(dir//filename) ! will automatically call initialize() with defaults
call cpu_time(tend)
write(error_unit,'(A,1X,F10.3,1X,A)') 'Elapsed time: ',tend-tstart,' sec'
if (f%failed()) then
call f%print_error_message(error_unit)
error_cnt = error_cnt + 1
else
write(error_unit,'(A)') 'File successfully read'
end if
write(error_unit,'(A)') ''
!cleanup:
call f%destroy()
write(error_unit,'(A)') ''
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ' EXAMPLE 9b '
write(error_unit,'(A)') '================================='
write(error_unit,'(A)') ''
write(error_unit,'(A)') ' Load a file using json_file%load_from_string'
write(error_unit,'(A)') ''
write(error_unit,'(A)') 'Loading file: '//trim(filename)
call cpu_time(tstart)
call read_file(dir//filename, str)
if (allocated(str)) then
call f%load_from_string(str)
call cpu_time(tend)
write(error_unit,'(A,1X,F10.3,1X,A)') 'Elapsed time to parse: ',tend-tstart,' sec'
if (f%failed()) then
call f%print_error_message(error_unit)
error_cnt = error_cnt + 1
else
write(error_unit,'(A)') 'File successfully read'
end if
write(error_unit,'(A)') ''
!write(error_unit,'(A)') str !!!! test !!!!
!write(error_unit,'(A)') '' !!!! test !!!!
else
write(error_unit,'(A)') 'Error loading file'
end if
!cleanup:
call f%destroy()
end subroutine test_9