test_9 Subroutine

public subroutine test_9(error_cnt)

Arguments

Type IntentOptional AttributesName
integer, intent(out) :: error_cnt

Description

Open a random JSON file generated by http://www.json-generator.com

Calls

proc~~test_9~~CallsGraph proc~test_9 test_9 proc~json_initialize json_initialize proc~test_9->proc~json_initialize proc~read_file read_file proc~test_9->proc~read_file proc~json_failed json_failed proc~test_9->proc~json_failed proc~json_print_error_message json_print_error_message proc~test_9->proc~json_print_error_message proc~json_clear_exceptions json_clear_exceptions proc~json_initialize->proc~json_clear_exceptions interface~throw_exception throw_exception proc~json_initialize->interface~throw_exception proc~json_print_error_message->proc~json_clear_exceptions proc~json_check_for_errors json_check_for_errors proc~json_print_error_message->proc~json_check_for_errors proc~json_throw_exception json_throw_exception interface~throw_exception->proc~json_throw_exception
Help

Called By

proc~~test_9~~CalledByGraph proc~test_9 test_9 program~jf_test_9 jf_test_9 program~jf_test_9->proc~test_9
Help

Variables

TypeVisibility AttributesNameInitial
type(json_file), public :: f
real, public :: tstart
real, public :: tend
character(len=:), public, allocatable:: str

Source Code

    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
    call json_initialize()
    if (json_failed()) then
        call json_print_error_message(error_unit)
        error_cnt = error_cnt + 1
    end if

    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)
    call cpu_time(tend)
    write(error_unit,'(A,1X,F10.3,1X,A)') 'Elapsed time: ',tend-tstart,' sec'

    if (json_failed()) then
        call json_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 (json_failed()) then
            call json_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