json_module Module

module~~json_module~~UsesGraph module~json_module json_module iso_fortran_env iso_fortran_env iso_fortran_env->module~json_module
Help

JSON-Fortran:

A Fortran 2008 JSON (JavaScript Object Notation) API.

This module provides an interface for reading and writing JSON files.

License

JSON-Fortran License:

JSON-Fortran: A Fortran 2008 JSON API

http://github.com/jacobwilliams/json-fortran

Copyright (c) 2014-2015, Jacob Williams

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
  list of conditions and the following disclaimer in the documentation and/or
  other materials provided with the distribution.
* The names of its contributors may not be used to endorse or promote products
  derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Original FSON License:

Copyright (c) 2012 Joseph A. Levin

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

History

  • Joseph A. Levin : March 2012 : Original FSON code [retrieved on 12/2/2013].
  • Jacob Williams : 2/8/2014 : Extensive modifications to the original FSON code. The original F95 code was split into four files: fson_path_m.f95, fson_string_m.f95, fson_value_m.f95, and fson.f95. The new code has been extensively updated, refactored and combined into this one module (json_module.f90). Various Fortran 2003/2008 features are now used (e.g., allocatable strings, newunit, generic, class, and abstract interface).
  • Development continues at: Github

See also

Used By

module~~json_module~~UsedByGraph module~json_module json_module module~jf_test_10_mod jf_test_10_mod module~json_module->module~jf_test_10_mod module~jf_test_13_mod jf_test_13_mod module~json_module->module~jf_test_13_mod module~jf_test_5_mod jf_test_5_mod module~json_module->module~jf_test_5_mod module~jf_test_9_mod jf_test_9_mod module~json_module->module~jf_test_9_mod module~jf_test_7_mod jf_test_7_mod module~json_module->module~jf_test_7_mod module~jf_test_3_mod jf_test_3_mod module~json_module->module~jf_test_3_mod module~jf_test_14_mod jf_test_14_mod module~json_module->module~jf_test_14_mod module~jf_test_12_mod jf_test_12_mod module~json_module->module~jf_test_12_mod module~jf_test_11_mod jf_test_11_mod module~json_module->module~jf_test_11_mod module~jf_test_4_mod jf_test_4_mod module~json_module->module~jf_test_4_mod module~jf_test_8_mod jf_test_8_mod module~json_module->module~jf_test_8_mod module~jf_test_6_mod jf_test_6_mod module~json_module->module~jf_test_6_mod module~jf_test_1_mod jf_test_1_mod module~json_module->module~jf_test_1_mod module~jf_test_2_mod jf_test_2_mod module~json_module->module~jf_test_2_mod program~jf_test_10 jf_test_10 module~jf_test_10_mod->program~jf_test_10 program~jf_test_13 jf_test_13 module~jf_test_13_mod->program~jf_test_13 program~jf_test_5 jf_test_5 module~jf_test_5_mod->program~jf_test_5 program~jf_test_9 jf_test_9 module~jf_test_9_mod->program~jf_test_9 program~jf_test_7 jf_test_7 module~jf_test_7_mod->program~jf_test_7 program~jf_test_3 jf_test_3 module~jf_test_3_mod->program~jf_test_3 program~jf_test_14 jf_test_14 module~jf_test_14_mod->program~jf_test_14 program~jf_test_12 jf_test_12 module~jf_test_12_mod->program~jf_test_12 program~jf_test_11 jf_test_11 module~jf_test_11_mod->program~jf_test_11 program~jf_test_4 jf_test_4 module~jf_test_4_mod->program~jf_test_4 program~jf_test_8 jf_test_8 module~jf_test_8_mod->program~jf_test_8 program~jf_test_6 jf_test_6 module~jf_test_6_mod->program~jf_test_6 program~jf_test_1 jf_test_1 module~jf_test_1_mod->program~jf_test_1 program~jf_test_2 jf_test_2 module~jf_test_2_mod->program~jf_test_2
Help

Variables

TypeVisibility AttributesNameInitial
integer, private, parameter:: RK =real64

Default real kind [8 bytes]

integer, private, parameter:: IK =int32

Default integer kind [4 bytes].

integer, public, parameter:: CDK =selected_char_kind("0")

Processor dependendant 'DEFAULT' character kind. This is 1 byte for the Intel and Gfortran compilers.

integer, private, parameter:: LK =logical_kinds(min(3,size(logical_kinds)))

Default logical kind. This is 4 bytes for the Intel and Gfortran compilers (and perhaps others). The declaration ensures a valid kind if the compiler doesn't have a logical_kinds(3).

character(kind=CDK,len=*), private, parameter:: json_fortran_string_kind ='DEFAULT'

String kind preprocessor macro.

this is the string kind to use unless compiling with GFortran AND UCS4/ISO 10646 support is requested

integer, public, parameter:: CK =selected_char_kind(json_fortran_string_kind)

Default character kind used by JSON-Fortran. If ISO 10646 (UCS4) support is available, use that, otherwise, gracefully fall back on 'DEFAULT' characters. Currently only gfortran >= 4.9.2 will correctly support UCS4 which is stored in 4 bytes. (and perhaps others).

logical, private, parameter:: use_unformatted_stream =.true.

If Unicode is not enabled, then JSON files are opened using access='STREAM' and form='UNFORMATTED'. This allows the file to be read faster.

character(kind=CDK,len=*), private, parameter:: access_spec ='STREAM'

If Unicode is not enabled, then JSON files are opened using access='STREAM' and form='UNFORMATTED'. This allows the file to be read faster.

character(kind=CDK,len=*), private, parameter:: form_spec ='UNFORMATTED'

If Unicode is not enabled, then JSON files are opened using access='STREAM' and form='UNFORMATTED'. This allows the file to be read faster.

integer(kind=IK), public, parameter:: json_unknown =0

Unknown JSON data type (see json_file_variable_info and json_info)

integer(kind=IK), public, parameter:: json_null =1

Null JSON data type (see json_file_variable_info and json_info)

integer(kind=IK), public, parameter:: json_object =2

Object JSON data type (see json_file_variable_info and json_info)

integer(kind=IK), public, parameter:: json_array =3

Array JSON data type (see json_file_variable_info and json_info)

integer(kind=IK), public, parameter:: json_logical =4

Logical JSON data type (see json_file_variable_info and json_info)

integer(kind=IK), public, parameter:: json_integer =5

Integer JSON data type (see json_file_variable_info and json_info)

integer(kind=IK), public, parameter:: json_double =6

Double JSON data type (see json_file_variable_info and json_info)

integer(kind=IK), public, parameter:: json_string =7

String JSON data type

character(kind=CDK,len=*), public, parameter:: json_ext ='.json'

JSON file extension

character(kind=CK,len=*), private, parameter:: space =' '
character(kind=CK,len=*), private, parameter:: start_object ='{'
character(kind=CK,len=*), private, parameter:: end_object ='}'
character(kind=CK,len=*), private, parameter:: start_array ='['
character(kind=CK,len=*), private, parameter:: end_array =']'
character(kind=CK,len=*), private, parameter:: delimiter =','
character(kind=CK,len=*), private, parameter:: colon_char =':'
character(kind=CK,len=*), private, parameter:: bspace =achar(8)
character(kind=CK,len=*), private, parameter:: horizontal_tab =achar(9)
character(kind=CK,len=*), private, parameter:: newline =achar(10)
character(kind=CK,len=*), private, parameter:: formfeed =achar(12)
character(kind=CK,len=*), private, parameter:: carriage_return =achar(13)
character(kind=CK,len=*), private, parameter:: quotation_mark =achar(34)
character(kind=CK,len=*), private, parameter:: slash =achar(47)
character(kind=CK,len=*), private, parameter:: backslash =achar(92)
character(kind=CK,len=4), private :: null_str ='null'
character(kind=CK,len=4), private :: true_str ='true'
character(kind=CK,len=5), private :: false_str ='false'
integer, private :: i_
character(kind=CK,len=*), private, parameter:: control_chars(32) =[(achar(i_), i_=1, 31), achar(127)]
integer(kind=IK), private, parameter:: spaces_per_tab =2
logical(kind=LK), private :: compact_real =.true.

to use the "compact" form of real numbers for output

integer(kind=IK), private, parameter:: rp_safety_factor =1
integer(kind=IK), private, parameter:: rp_addl_safety =1
integer(kind=IK), private, parameter:: real_precision =rp_safety_factor*precision(1.0_RK)+rp_addl_safety
integer(kind=IK), private, parameter:: maxexp =maxexponent(1.0_RK)
integer(kind=IK), private, parameter:: minexp =minexponent(1.0_RK)
integer(kind=IK), private, parameter:: real_exponent_digits =floor(1+log10(real(max(maxexp,abs(maxexp)),kind=RK)))
integer(kind=IK), private, parameter:: max_numeric_str_len =real_precision+real_exponent_digits+6

6 = sign + leading 0 + decimal + 'E' + exponent sign + 1 extra

character(kind=CDK,len=*), private, parameter:: int_fmt ='(ss,I0)'

minimum width format for integers

character(kind=CK,len=*), private, parameter:: star ='*'

for invalid numbers and list-directed real output

character(kind=CDK,len=:), private, allocatable:: real_fmt

the format string to use for real numbers it is set in json_initialize

logical(kind=LK), private :: is_verbose =.false.

if true, all exceptions are immediately printed to console

logical(kind=LK), private :: exception_thrown =.true.

the error flag (by default, this is true to make sure that json_initialize is called.

character(kind=CK,len=:), private, allocatable:: err_message

the error message

integer(kind=IK), private :: char_count =0
integer(kind=IK), private :: line_count =1
integer(kind=IK), private :: pushed_index =0
character(kind=CK,len=10), private :: pushed_char =''
integer(kind=IK), private, parameter:: chunk_size =100

for allocatable strings: allocate chunks of this size

integer(kind=IK), private :: ipos =1

for allocatable strings: next character to read

integer(kind=IK), private, parameter:: unit2str =-1

unit number to cause stuff to be output to strings rather than files. See 9.5.6.12 in the F2003/08 standard


Interfaces

private interface json_file

Structure constructor to initialize a json_file object with an existing json_value object

  • private function initialize_json_file(p) result(file_object)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), optional pointer:: p

    json_value object to cast as a json_file object

    Return Value type(json_file)

    Description

    Author
    Izaak Beekman
    Date
    07/23/2015

    Cast a json_value object as a json_file object

public interface json_get_child

Get a child, either by index or name string. Both of these return a json_value pointer.

  • private subroutine json_value_get_by_index(me, idx, p)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me

    object or array JSON data

    integer(kind=IK), intent(in) :: idx

    index of the child

    type(json_value), , pointer:: p

    pointer to the child

    Description

    Returns a child in the object or array given the index.

  • private subroutine json_value_get_by_name_chars(me, name, p)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    the name of a child of "me"

    type(json_value), , pointer:: p

    pointer to the child

    Description

    Returns a child in the object or array given the name string.

public interface json_add

Add objects to a linked list of json_values.

  • private subroutine json_value_add_member(me, member)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    type(json_value), , pointer:: member

    the child member to add

    Description

    Adds "member" as a child of "me".

  • private subroutine json_value_add_integer(me, name, val)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name
    integer(kind=IK), intent(in) :: val

    Description

    Author
    Jacob Williams
    Date
    1/20/2014

    Add an integer value child to the json_value variable

  • private subroutine json_value_add_integer_vec(me, name, val)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    name of the variable

    integer(kind=IK), intent(in), dimension(:):: val

    value

    Description

    Author
    Jacob Williams
    Date
    1/20/2014

    Add an integer vector to the structure.

  • private subroutine json_value_add_double(me, name, val)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    variable name

    real(kind=RK), intent(in) :: val

    real value

    Description

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a real value child to the json_value variable

  • private subroutine json_value_add_double_vec(me, name, val)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name
    real(kind=RK), intent(in), dimension(:):: val

    Description

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a real vector to the structure.

  • private subroutine json_value_add_logical(me, name, val)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    name of the variable

    logical(kind=LK), intent(in) :: val

    value

    Description

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a logical value child to the json_value variable

  • private subroutine json_value_add_logical_vec(me, name, val)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    name of the vector

    logical(kind=LK), intent(in), dimension(:):: val

    value

    Description

    Author
    Jacob Williams
    Date
    1/20/2014

    Add a logical vector to the structure.

  • private subroutine json_value_add_string(me, name, val)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    name of the variable

    character(kind=CK,len=*), intent(in) :: val

    value

    Description

    Author
    Jacob Williams
    Date
    1/19/2014

    Add a character string child to the json_value variable.

  • private subroutine json_value_add_string_vec(me, name, val, trim_str, adjustl_str)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    variable name

    character(kind=CK,len=*), intent(in), dimension(:):: val

    array of strings

    logical(kind=LK), intent(in), optional :: trim_str

    if TRIM() should be called for each element

    logical(kind=LK), intent(in), optional :: adjustl_str

    if ADJUSTL() should be called for each element

    Description

    Author
    Jacob Williams
    Date
    1/19/2014

    Add an array of character strings to the structure.

public interface json_update

These are like json_add, except if a child with the same name is already present, then its value is simply updated. Note that currently, these only work for scalar variables. These routines can also change the variable's type (but an error will be thrown if the existing variable is not a scalar).

  • private subroutine json_update_logical(p, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: p
    character(kind=CK,len=*), intent(in) :: name
    logical(kind=LK), intent(in) :: val
    logical(kind=LK), intent(out) :: found

    Description

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

  • private subroutine json_update_double(p, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: p
    character(kind=CK,len=*), intent(in) :: name
    real(kind=RK), intent(in) :: val
    logical(kind=LK), intent(out) :: found

    Description

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

  • private subroutine json_update_integer(p, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: p
    character(kind=CK,len=*), intent(in) :: name
    integer(kind=IK), intent(in) :: val
    logical(kind=LK), intent(out) :: found

    Description

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

  • private subroutine json_update_string(p, name, val, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: p
    character(kind=CK,len=*), intent(in) :: name
    character(kind=CK,len=*), intent(in) :: val
    logical(kind=LK), intent(out) :: found

    Description

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

public interface json_get

Get data from a json_value linked list.

  • private subroutine json_get_by_path(me, path, p, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    type(json_value), intent(out), pointer:: p
    logical(kind=LK), intent(out), optional :: found

    true if it was found

    Description

    Returns the json_value pointer given the path string.

  • private subroutine json_get_integer(me, value)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    integer(kind=IK), intent(out) :: value

    Description

    Get an integer value from a json_value.

  • private subroutine json_get_integer_with_path(me, path, value, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    integer(kind=IK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found

    Description

    Get an integer value from a json_value, given the path string.

  • private subroutine json_get_integer_vec(me, vec)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    integer(kind=IK), intent(out), dimension(:), allocatable:: vec

    Description

    Author
    Jacob Williams
    Date
    5/14/2014

    Get an integer vector from a json_value.

  • private subroutine json_get_integer_vec_with_path(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    integer(kind=IK), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found

    Description

    Get an integer vector from a json_value, given the path string.

  • private subroutine json_get_double(me, value)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    real(kind=RK), intent(out) :: value

    Description

    Get a double value from a json_value.

  • private subroutine json_get_double_with_path(me, path, value, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    real(kind=RK), intent(out) :: value
    logical(kind=LK), intent(out), optional :: found

    Description

    Get a double value from a json_value, given the path.

  • private subroutine json_get_double_vec(me, vec)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    real(kind=RK), intent(out), dimension(:), allocatable:: vec

    Description

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a double vector from a json_value.

  • private subroutine json_get_double_vec_with_path(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    real(kind=RK), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found

    Description

    Get a double vector from a json_value, given the path.

  • private subroutine json_get_logical(me, value)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    logical(kind=LK) :: value

    Description

    Get a logical value from a json_value.

  • private subroutine json_get_logical_with_path(me, path, value, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    logical(kind=LK) :: value
    logical(kind=LK), intent(out), optional :: found

    Description

    Get a logical value from a json_value, given the path.

  • private subroutine json_get_logical_vec(me, vec)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    logical(kind=LK), intent(out), dimension(:), allocatable:: vec

    Description

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a logical vector from json_value.

  • private subroutine json_get_logical_vec_with_path(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    logical(kind=LK), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found

    Description

    Get a logical vector from a json_value, given the path.

  • private subroutine json_get_string(me, value)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=:), intent(out), allocatable:: value

    Description

    Get a character string from a json_value.

  • private subroutine json_get_string_with_path(me, path, value, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    character(kind=CK,len=:), intent(out), allocatable:: value
    logical(kind=LK), intent(out), optional :: found

    Description

    Get a character string from a json_value, given the path.

  • private subroutine json_get_string_vec(me, vec)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec

    Description

    Author
    Jacob Williams
    Date
    5/14/2014

    Get a string vector from a json_file.

  • private subroutine json_get_string_vec_with_path(me, path, vec, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec
    logical(kind=LK), intent(out), optional :: found

    Description

    Get a string vector from a json_file, given the path.

  • private subroutine json_get_array(me, array_callback)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    procedure(array_callback_func) :: array_callback

    Description

    This routine calls the user-supplied array_callback_func subroutine for each element in the array.

  • private subroutine json_get_array_with_path(me, path, array_callback, found)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=*), intent(in) :: path
    procedure(array_callback_func) :: array_callback
    logical(kind=LK), intent(out), optional :: found

    Description

    This routine calls the user-supplied array_callback subroutine for each element in the array (specified by the path).

public interface json_print_to_string

Print the json_value structure to an allocatable string.

  • private subroutine json_value_to_string(me, str)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CK,len=:), intent(out), allocatable:: str

    prints structure to this string

    Description

    Author
    Jacob Williams
    Date
    2/12/2014

    Print the json_value structure to an allocatable string.

public interface json_print

Print the json_value to a file.

  • private subroutine json_print_1(me, iunit)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    integer(kind=IK), intent(in) :: iunit

    the file unit (the file must already have been opened, can't be -1).

    Description

    Author
    Jacob Williams
    Date
    6/20/2014

    Print the json_value structure to a file.

  • private subroutine json_print_2(me, filename)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: me
    character(kind=CDK,len=*), intent(in) :: filename

    the filename to print to (should not already be open)

    Description

    Author
    Jacob Williams
    Date
    12/23/2014

    Print the json_value structure to a file.

public interface json_destroy

Destructor routine for a json_value pointer. This must be called explicitly if it is no longer needed, before it goes out of scope. Otherwise, a memory leak will result.

  • private recursivesubroutine json_value_destroy(me, destroy_next)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    logical(kind=LK), intent(in), optional :: destroy_next

    if true, then me%next is also destroyed (default is true)

    Description

    Author
    Jacob Williams
    Date
    1/22/2014

    Destroy a json_value linked-list structure.

public interface json_remove

Remove a json_value from a linked-list structure.

  • private subroutine json_value_remove(me, destroy)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    logical(kind=LK), intent(in), optional :: destroy

    If destroy is not present, it is also destroyed. If destroy is present and true, it is destroyed. If destroy is present and false, it is not destroyed.

    Description

    Author
    Jacob Williams
    Date
    9/9/2014

    Remove a json_value (and all its children) from a linked-list structure, preserving the rest of the structure.

public interface json_remove_if_present

If the child variable is present, then remove it.

  • private subroutine json_value_remove_if_present(p, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: p
    character(kind=CK,len=*), intent(in) :: name

    Description

    Author
    Jacob Williams
    Date
    12/6/2014

    Given the path string, remove the variable from the json_value structure, if it exists.

public interface json_create_double

Allocate a json_value pointer and make it a double variable. The pointer should not already be allocated.

  • private subroutine json_value_create_double(me, val, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    real(kind=RK), intent(in) :: val
    character(kind=CK,len=*), intent(in) :: name

    Description

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a real(RK) variable. The pointer should not already be allocated.

public interface json_create_array

Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.

  • private subroutine json_value_create_array(me, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    Description

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.

public interface json_create_object

Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.

  • private subroutine json_value_create_object(me, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    Description

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.

public interface json_create_null

Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.

  • private subroutine json_value_create_null(me, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: name

    Description

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.

public interface json_create_string

Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.

  • private subroutine json_value_create_string(me, val, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    character(kind=CK,len=*), intent(in) :: val
    character(kind=CK,len=*), intent(in) :: name

    Description

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.

public interface json_create_integer

Allocate a json_value pointer and make it an integer variable. The pointer should not already be allocated.

  • private subroutine json_value_create_integer(me, val, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    integer(kind=IK), intent(in) :: val
    character(kind=CK,len=*), intent(in) :: name

    Description

    Author
    Jacob Williams

    Allocate a json_value pointer and make it an integer(IK) variable. The pointer should not already be allocated.

public interface json_create_logical

Allocate a json_value pointer and make it a logical variable. The pointer should not already be allocated.

  • private subroutine json_value_create_logical(me, val, name)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: me
    logical(kind=LK), intent(in) :: val

    variable value

    character(kind=CK,len=*), intent(in) :: name

    variable name

    Description

    Author
    Jacob Williams

    Allocate a json_value pointer and make it a logical(LK) variable. The pointer should not already be allocated.

public interface json_parse

Parse the JSON file and populate the json_value tree.

  • private subroutine json_parse_file(file, p, unit)

    Arguments

    Type IntentOptional AttributesName
    character(kind=CDK,len=*), intent(in) :: file

    JSON file name

    type(json_value), , pointer:: p

    output structure

    integer(kind=IK), intent(in), optional :: unit

    file unit number (/= 0)

    Description

    Parse the JSON file and populate the json_value tree.

  • private subroutine json_parse_string(p, str)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), , pointer:: p

    output structure

    character(kind=CK,len=*), intent(in) :: str

    string with JSON data

    Description

    Parse the JSON string and populate the json_value tree.

public interface to_unicode

Convert a 'DEFAULT' kind character input to 'ISO_10646' kind and return it

  • private purefunction to_uni(str)

    Arguments

    Type IntentOptional AttributesName
    character(kind=CDK,len=*), intent(in) :: str

    Return Value character(kind=CK,len=len(str))

    Description

    Author
    Izaak Beekman

    Convert string to unicode (CDK to CK).

  • private purefunction to_uni_vec(str)

    Arguments

    Type IntentOptional AttributesName
    character(kind=CDK,len=*), intent(in), dimension(:):: str

    Return Value character(kind=CK,len=len(str)), dimension(size(str))

    Description

    Author
    Izaak Beekman

    Convert array of strings to unicode (CDK to CK).

private interface throw_exception

Throw an exception.

  • private subroutine json_throw_exception(msg)

    Arguments

    Type IntentOptional AttributesName
    character(kind=CK,len=*), intent(in) :: msg

    Description

    Author
    Jacob Williams
    Date
    12/4/2013

    Throw an exception in the JSON module. This routine sets the error flag, and prevents any subsequent routine from doing anything, until json_clear_exceptions is called.


Abstract Interfaces

abstract interface

  • private subroutine array_callback_func(element, i, count)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: element
    integer(kind=IK), intent(in) :: i
    integer(kind=IK), intent(in) :: count

    Description

    Array element callback function. Used by json_get_array

abstract interface

  • private subroutine traverse_callback_func(p, finished)

    Arguments

    Type IntentOptional AttributesName
    type(json_value), intent(in), pointer:: p
    logical(kind=LK), intent(out) :: finished

    Description

    Callback function used by json_traverse


Derived Types

type, public, sequence :: json_value

Components

TypeVisibility AttributesNameInitial
type(json_value), private, pointer:: previous=> null()

previous item in the list

type(json_value), private, pointer:: next=> null()

next item in the list

type(json_value), private, pointer:: parent=> null()

parent item of this

type(json_value), private, pointer:: children=> null()

first child item of this

type(json_value), private, pointer:: tail=> null()

last child item of this

character(kind=CK,len=:), private, allocatable:: name

variable name

real(kind=RK), private, allocatable:: dbl_value

real data for this variable

logical(kind=LK), private, allocatable:: log_value

logical data for this variable

character(kind=CK,len=:), private, allocatable:: str_value

string data for this variable

integer(kind=IK), private, allocatable:: int_value

integer data for this variable

integer(kind=IK), private :: var_type =json_unknown

variable type

integer(kind=IK), private :: n_children =0

number of children

Description

Type used to construct the linked-list JSON structure. Normally, this should always be a pointer variable.

type, public :: json_file

Components

TypeVisibility AttributesNameInitial
type(json_value), private, pointer:: p=> null()

the JSON structure read from the file

Constructor

Structure constructor to initialize a json_file object with an existing json_value object

private function initialize_json_file(p)

Cast a json_value object as a json_file object

Type-Bound Procedures

procedure, public :: load_file => json_file_load
generic, public :: load_from_string => json_file_load_from_string
procedure, public :: destroy => json_file_destroy
procedure, public :: move => json_file_move_pointer
generic, public :: info => json_file_variable_info
procedure, public :: print_to_string => json_file_print_to_string
generic, public :: print_file => json_file_print_to_console, json_file_print_1, json_file_print_2
generic, public :: get => json_file_get_object, json_file_get_integer, json_file_get_double, json_file_get_logical, json_file_get_string, json_file_get_integer_vec, json_file_get_double_vec, json_file_get_logical_vec, json_file_get_string_vec, json_file_get_root
generic, public :: update => json_file_update_integer, json_file_update_logical, json_file_update_real, json_file_update_string
procedure, public :: json_file_load_from_string
procedure, public :: json_file_variable_info
procedure, public :: json_file_get_object
procedure, public :: json_file_get_integer
procedure, public :: json_file_get_double
procedure, public :: json_file_get_logical
procedure, public :: json_file_get_string
procedure, public :: json_file_get_integer_vec
procedure, public :: json_file_get_double_vec
procedure, public :: json_file_get_logical_vec
procedure, public :: json_file_get_string_vec
procedure, public :: json_file_get_root
procedure, public :: json_file_update_integer
procedure, public :: json_file_update_logical
procedure, public :: json_file_update_real
procedure, public :: json_file_update_string
procedure, public :: json_file_print_to_console
procedure, public :: json_file_print_1
procedure, public :: json_file_print_2

Description

The json_file is the main public class that is used to open a file and get data from it.


Functions

private function initialize_json_file(p) result(file_object)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), optional pointer:: p

json_value object to cast as a json_file object

Return Value type(json_file)

Description

Author
Izaak Beekman
Date
07/23/2015

Cast a json_value object as a json_file object

public function json_failed() result(failed)

Arguments

None

Return Value logical(kind=LK)

Description

Author
Jacob Williams
Date
12/5/2013

Logical function to indicate if an exception has been thrown.

public purefunction json_count(me) result(count)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me

Return Value integer(kind=IK)

number of children

Description

Count the number of children.

private function string_to_integer(str) result(ival)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: str

Return Value integer(kind=IK)

Description

Convert a string into an integer.

private function string_to_double(str) result(rval)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: str

Return Value real(kind=RK)

Description

Author
Jacob Williams
Date
1/19/2014

Convert a string into a double.

private recursivefunction pop_char(unit, str, eof, skip_ws) result(popped)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number (if parsing from a file)

character(kind=CK,len=*), intent(in) :: str

JSON string (if parsing from a string) – only used if unit=0

logical(kind=LK), intent(out) :: eof

true if the end of the file has been reached.

logical(kind=LK), intent(in), optional :: skip_ws

to ignore whitespace.

Return Value character(kind=CK,len=1)

the popped character.

Description

Get the next character from the file (or string).

private purefunction valid_json_hex(str) result(valid)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: str

the string to check.

Return Value logical(kind=LK)

is str a value 4-digit hex string

Description

Author
Jacob Williams
Date
6/14/2014

Returns true if the string is a valid 4-digit hex string.

private purefunction to_uni(str)

Arguments

Type IntentOptional AttributesName
character(kind=CDK,len=*), intent(in) :: str

Return Value character(kind=CK,len=len(str))

Description

Author
Izaak Beekman

Convert string to unicode (CDK to CK).

private purefunction to_uni_vec(str)

Arguments

Type IntentOptional AttributesName
character(kind=CDK,len=*), intent(in), dimension(:):: str

Return Value character(kind=CK,len=len(str)), dimension(size(str))

Description

Author
Izaak Beekman

Convert array of strings to unicode (CDK to CK).

private function ucs4_join_default(ucs4_str, def_str) result(res)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: ucs4_str
character(kind=CDK,len=*), intent(in) :: def_str

Return Value character(kind=CK,len=(len(ucs4_str)+len(def_str)))

Description

Author
Izaak Beekman

CK//CDK operator.

private function default_join_ucs4(def_str, ucs4_str) result(res)

Arguments

Type IntentOptional AttributesName
character(kind=CDK,len=*), intent(in) :: def_str
character(kind=CK,len=*), intent(in) :: ucs4_str

Return Value character(kind=CK,len=(len(def_str)+len(ucs4_str)))

Description

Author
Izaak Beekman

CDK//CK operator.

private function ucs4_comp_default(ucs4_str, def_str) result(res)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: ucs4_str
character(kind=CDK,len=*), intent(in) :: def_str

Return Value logical(kind=LK)

Description

Author
Izaak Beekman

CK==CDK operator.

private function default_comp_ucs4(def_str, ucs4_str) result(res)

Arguments

Type IntentOptional AttributesName
character(kind=CDK,len=*), intent(in) :: def_str
character(kind=CK,len=*), intent(in) :: ucs4_str

Return Value logical(kind=LK)

Description

Author
Izaak Beekman

CDK==CK operator.


Subroutines

public subroutine json_clone(from, to)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: from

this is the structure to clone

type(json_value), , pointer:: to

the clone is put here (it must not already be associated)

Description

Author
Jacob Williams
Date
10/31/2015

Create a deep copy of a json_value linked-list structure.

private recursivesubroutine json_value_clone_func(from, to, parent, previous, next, children, tail)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: from

this is the structure to clone

type(json_value), , pointer:: to

the clone is put here (it must not already be associated)

type(json_value), , optional pointer:: parent

to%parent

type(json_value), , optional pointer:: previous

to%previous

type(json_value), , optional pointer:: next

to%next

type(json_value), , optional pointer:: children

to%children

logical , optional :: tail

if "to" is the tail of its parent's children

Description

Author
Jacob Williams
Date
10/31/2015

Recursive deep copy function called by json_clone.

private subroutine destroy_json_data(d)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: d

Description

Author
Jacob Williams

Destroy the data within a json_value, and rest type to json_unknown.

private subroutine json_file_destroy(me)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me

Description

Author
Jacob Williams
Date
12/9/2013

Destroy the json_file.

private subroutine json_file_move_pointer(to, from)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: to
class(json_file), intent(inout) :: from

Description

Author
Jacob Williams
Date
12/5/2014

Move the json_value pointer from one json_file to another. The "from" pointer is then nullified, but not destroyed.

private subroutine json_file_load(me, filename, unit)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: filename

the filename to open

integer(kind=IK), intent(in), optional :: unit

the unit number to use (if not present, a newunit is used)

Description

Author
Jacob Williams
Date
12/9/2013

Load the JSON data from a file.

private subroutine json_file_load_from_string(me, str)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: str

string to load JSON data from

Description

Author
Jacob Williams
Date
1/13/2015

Load the JSON data from a string.

private subroutine wrap_json_file_load_from_string(me, str)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: str

Description

Alternate version of json_file_load_from_string, where "str" is kind=CDK.

private subroutine json_file_print_to_console(me)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me

Description

Author
Jacob Williams
Date
1/11/2015

Print the JSON file to the console.

private subroutine json_file_print_1(me, iunit)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
integer(kind=IK), intent(in) :: iunit

file unit number (must not be -1)

Description

Author
Jacob Williams
Date
12/9/2013

Prints the JSON file to the specified file unit number.

private subroutine json_file_print_2(me, filename)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: filename

filename to print to

Description

Author
Jacob Williams
Date
1/11/2015

Print the JSON structure to the specified filename. The file is opened, printed, and then closed.

private subroutine json_file_print_to_string(me, str)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=:), intent(out), allocatable:: str

string to print JSON data to

Description

Author
Jacob Williams
Date
1/11/2015

Print the JSON file to a string.

private subroutine json_file_variable_info(me, path, found, var_type, n_children)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path

path to the variable

logical(kind=LK), intent(out) :: found

the variable exists in the structure

integer(kind=IK), intent(out) :: var_type

variable type

integer(kind=IK), intent(out) :: n_children

number of children

Description

Author
Jacob Williams
Date
2/3/2014

Returns information about a variable in a json_file.

private subroutine wrap_json_file_variable_info(me, path, found, var_type, n_children)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
logical(kind=LK), intent(out) :: found
integer(kind=IK), intent(out) :: var_type
integer(kind=IK), intent(out) :: n_children

Description

Alternate version of json_file_variable_info, where "path" is kind=CDK.

public subroutine json_info(p, var_type, n_children, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
integer(kind=IK), intent(out), optional :: var_type

variable type

integer(kind=IK), intent(out), optional :: n_children

number of children

character(kind=CK,len=:), intent(out), optional allocatable:: name

variable name

Description

Author
Jacob Williams
Date
2/13/2014

Returns information about a json_value.

private subroutine json_file_get_object(me, path, p, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path

the path to the variable

type(json_value), intent(out), pointer:: p

pointer to the variable

logical(kind=LK), intent(out), optional :: found

if it was really found

Description

Author
Jacob Williams
Date
2/3/2014

Get a json_value pointer to an object from a JSON file.

private subroutine json_file_get_root(me, p)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
type(json_value), intent(out), pointer:: p

pointer to the variable

Description

Author
Izaak Beekman
Date
7/23/2015

Get a json_value pointer to the JSON file root.

private subroutine wrap_json_file_get_object(me, path, p, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
type(json_value), intent(out), pointer:: p
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_object, where "path" is kind=CDK.

private subroutine json_file_get_integer(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path

the path to the variable

integer(kind=IK), intent(out) :: val

value

logical(kind=LK), intent(out), optional :: found

if it was really found

Description

Author
Jacob Williams
Date
12/9/2013

Get an integer value from a JSON file.

private subroutine wrap_json_file_get_integer(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
integer(kind=IK), intent(out) :: val
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_integer, where "path" is kind=CDK.

private subroutine json_file_get_integer_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path

the path to the variable

integer(kind=IK), intent(out), dimension(:), allocatable:: vec

the value vector

logical(kind=LK), intent(out), optional :: found

if it was really found

Description

Author
Jacob Williams
Date
1/20/2014

Get an integer vector from a JSON file.

private subroutine wrap_json_file_get_integer_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
integer(kind=IK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_integer_vec, where "path" is kind=CDK.

private subroutine json_file_get_double(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path
real(kind=RK), intent(out) :: val
logical(kind=LK), intent(out), optional :: found

Description

Author
Jacob Williams
Date
12/9/2013

Get a real(RK) variable value from a JSON file.

private subroutine wrap_json_file_get_double(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
real(kind=RK), intent(out) :: val
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_double, where "path" is kind=CDK.

private subroutine json_file_get_double_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path
real(kind=RK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Author
Jacob Williams
Date
1/19/2014

Get a real(RK) vector from a JSON file.

private subroutine wrap_json_file_get_double_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
real(kind=RK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_double_vec, where "path" is kind=CDK.

private subroutine json_file_get_logical(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path
logical(kind=LK), intent(out) :: val
logical(kind=LK), intent(out), optional :: found

Description

Author
Jacob Williams
Date
12/9/2013

Get a logical(LK) value from a JSON file.

private subroutine wrap_json_file_get_logical(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
logical(kind=LK), intent(out) :: val
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_logical, where "path" is kind=CDK.

private subroutine json_file_get_logical_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path
logical(kind=LK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Author
Jacob Williams
Date
1/20/2014

Get a logical(LK) vector from a JSON file.

private subroutine wrap_json_file_get_logical_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
logical(kind=LK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_logical_vec, where "path" is kind=CDK.

private subroutine json_file_get_string(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path
character(kind=CK,len=:), intent(out), allocatable:: val
logical(kind=LK), intent(out), optional :: found

Description

Author
Jacob Williams
Date
12/9/2013

Get a character string from a json file. The output val is an allocatable character string.

private subroutine wrap_json_file_get_string(me, path, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
character(kind=CK,len=:), intent(out), allocatable:: val
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_string, where "path" is kind=CDK.

private subroutine json_file_get_string_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: path
character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Author
Jacob Williams
Date
1/19/2014

Get a string vector from a JSON file.

private subroutine wrap_json_file_get_string_vec(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: path
character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_file_get_string_vec, where "path" is kind=CDK.

public subroutine json_initialize(verbose, compact_reals, print_signs, real_format)

Arguments

Type IntentOptional AttributesName
logical(kind=LK), intent(in), optional :: verbose

mainly useful for debugging (default is false)

logical(kind=LK), intent(in), optional :: compact_reals

to compact the real number strings for output (default is true)

logical(kind=LK), intent(in), optional :: print_signs

always print numeric sign (default is false)

character(kind=len=*,CDK), intent(in), optional :: real_format

exponential (default), scientific, engineering or general

Description

Author
Jacob Williams
Date
12/4/2013

Initialize the JSON-Fortran module. The routine must be called before any of the routines are used. It can also be called after using the module and encountering exceptions.

public subroutine json_clear_exceptions()

Arguments

None

Description

Author
Jacob Williams
Date
12/4/2013

Clear exceptions in the JSON module.

private subroutine json_throw_exception(msg)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: msg

Description

Author
Jacob Williams
Date
12/4/2013

Throw an exception in the JSON module. This routine sets the error flag, and prevents any subsequent routine from doing anything, until json_clear_exceptions is called.

private subroutine wrap_json_throw_exception(msg)

Arguments

Type IntentOptional AttributesName
character(kind=CDK,len=*), intent(in) :: msg

Description

Alternate version of json_throw_exception, where "msg" is kind=CDK.

public subroutine json_check_for_errors(status_ok, error_msg)

Arguments

Type IntentOptional AttributesName
logical(kind=LK), intent(out) :: status_ok

true if there were no errors

character(kind=CK,len=:), intent(out), allocatable:: error_msg

the error message (if there were errors)

Description

Author
Jacob Williams
Date
12/4/2013

Retrieve error code from the module. This should be called after json_parse to check for errors. If an error is thrown, before using the module again, json_initialize should be called to clean up before it is used again.

private subroutine json_value_create(p)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p

Description

Allocate a json_value pointer variable. This should be called before adding data to it.

private recursivesubroutine json_value_destroy(me, destroy_next)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
logical(kind=LK), intent(in), optional :: destroy_next

if true, then me%next is also destroyed (default is true)

Description

Author
Jacob Williams
Date
1/22/2014

Destroy a json_value linked-list structure.

private subroutine json_value_remove(me, destroy)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
logical(kind=LK), intent(in), optional :: destroy

If destroy is not present, it is also destroyed. If destroy is present and true, it is destroyed. If destroy is present and false, it is not destroyed.

Description

Author
Jacob Williams
Date
9/9/2014

Remove a json_value (and all its children) from a linked-list structure, preserving the rest of the structure.

private subroutine json_value_remove_if_present(p, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CK,len=*), intent(in) :: name

Description

Author
Jacob Williams
Date
12/6/2014

Given the path string, remove the variable from the json_value structure, if it exists.

private subroutine wrap_json_value_remove_if_present(p, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CDK,len=*), intent(in) :: name

Description

Alternate version of json_value_remove_if_present, where "name" is kind=CDK.

private subroutine json_file_update_integer(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: name
integer(kind=IK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
1/10/2015

Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_file_update_integer(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: name
integer(kind=IK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_file_update_integer, where "name" is kind=CDK.

private subroutine json_file_update_logical(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: name
logical(kind=LK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
1/10/2015

Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_file_update_logical(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: name
logical(kind=LK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_file_update_logical, where "name" is kind=CDK.

private subroutine json_file_update_real(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: name
real(kind=RK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
1/10/2015

Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_file_update_real(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: name
real(kind=RK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_file_update_real, where "name" is kind=CDK.

private subroutine json_file_update_string(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: name
character(kind=CK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
1/10/2015

Given the path string, if the variable is present in the file, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_file_update_string(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: name
character(kind=CDK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_file_update_string, where "name" and "val" are kind=CDK.

private subroutine json_file_update_string_name_ascii(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CDK,len=*), intent(in) :: name
character(kind=CK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_file_update_string, where "name" is kind=CDK.

private subroutine json_file_update_string_val_ascii(me, name, val, found)

Arguments

Type IntentOptional AttributesName
class(json_file), intent(inout) :: me
character(kind=CK,len=*), intent(in) :: name
character(kind=CDK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_file_update_string, where "val" is kind=CDK.

private subroutine json_update_logical(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CK,len=*), intent(in) :: name
logical(kind=LK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
12/6/2014

Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_update_logical(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CDK,len=*), intent(in) :: name
logical(kind=LK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_update_logical, where "name" is kind=CDK.

private subroutine json_update_double(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CK,len=*), intent(in) :: name
real(kind=RK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
12/6/2014

Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_update_double(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CDK,len=*), intent(in) :: name
real(kind=RK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_update_double, where "name" is kind=CDK.

private subroutine json_update_integer(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CK,len=*), intent(in) :: name
integer(kind=IK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
12/6/2014

Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_update_integer(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CDK,len=*), intent(in) :: name
integer(kind=IK), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_update_integer, where "name" is kind=CDK.

private subroutine json_update_string(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CK,len=*), intent(in) :: name
character(kind=CK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Author
Jacob Williams
Date
12/6/2014

Given the path string, if the variable is present, and is a scalar, then update its value. If it is not present, then create it and set its value.

private subroutine wrap_json_update_string(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CDK,len=*), intent(in) :: name
character(kind=CDK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_update_string, where "name" and "value" are kind=CDK.

private subroutine json_update_string_name_ascii(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CDK,len=*), intent(in) :: name
character(kind=CK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_update_string, where "name" is kind=CDK.

private subroutine json_update_string_val_ascii(p, name, val, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p
character(kind=CK,len=*), intent(in) :: name
character(kind=CDK,len=*), intent(in) :: val
logical(kind=LK), intent(out) :: found

Description

Alternate version of json_update_string, where "val" is kind=CDK.

private subroutine json_value_add_member(me, member)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
type(json_value), , pointer:: member

the child member to add

Description

Adds "member" as a child of "me".

private subroutine json_value_add_double(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

variable name

real(kind=RK), intent(in) :: val

real value

Description

Author
Jacob Williams
Date
1/19/2014

Add a real value child to the json_value variable

private subroutine wrap_json_value_add_double(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

variable name

real(kind=RK), intent(in) :: val

real value

Description

Alternate version of json_value_add_double where "name" is kind=CDK.

private subroutine json_value_add_double_vec(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name
real(kind=RK), intent(in), dimension(:):: val

Description

Author
Jacob Williams
Date
1/20/2014

Add a real vector to the structure.

private subroutine wrap_json_value_add_double_vec(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name
real(kind=RK), intent(in), dimension(:):: val

Description

Alternate version of json_value_add_double_vec where "name" is kind=CDK.

private subroutine json_value_add_integer(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name
integer(kind=IK), intent(in) :: val

Description

Author
Jacob Williams
Date
1/20/2014

Add an integer value child to the json_value variable

private subroutine wrap_json_value_add_integer(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

name of the variable

integer(kind=IK), intent(in) :: val

value

Description

Alternate version of json_value_add_integer where "name" is kind=CDK.

private subroutine json_value_add_integer_vec(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

name of the variable

integer(kind=IK), intent(in), dimension(:):: val

value

Description

Author
Jacob Williams
Date
1/20/2014

Add an integer vector to the structure.

private subroutine wrap_json_value_add_integer_vec(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

name of the variable

integer(kind=IK), intent(in), dimension(:):: val

value

Description

Alternate version of json_value_add_integer_vec where "name" is kind=CDK.

private subroutine json_value_add_logical(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

name of the variable

logical(kind=LK), intent(in) :: val

value

Description

Author
Jacob Williams
Date
1/20/2014

Add a logical value child to the json_value variable

private subroutine wrap_json_value_add_logical(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

name of the variable

logical(kind=LK), intent(in) :: val

value

Description

Alternate version of json_value_add_logical where "name" is kind=CDK.

private subroutine json_value_add_logical_vec(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

name of the vector

logical(kind=LK), intent(in), dimension(:):: val

value

Description

Author
Jacob Williams
Date
1/20/2014

Add a logical vector to the structure.

private subroutine wrap_json_value_add_logical_vec(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

name of the variable

logical(kind=LK), intent(in), dimension(:):: val

value

Description

Alternate version of json_value_add_logical_vec where "name" is kind=CDK.

private subroutine json_value_add_string(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

name of the variable

character(kind=CK,len=*), intent(in) :: val

value

Description

Author
Jacob Williams
Date
1/19/2014

Add a character string child to the json_value variable.

private subroutine wrap_json_value_add_string(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

name of the variable

character(kind=CDK,len=*), intent(in) :: val

value

Description

Alternate version of json_value_add_string where "name" and "val" are kind=CDK.

private subroutine json_value_add_string_name_ascii(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

name of the variable

character(kind=CK,len=*), intent(in) :: val

value

Description

Alternate version of json_value_add_string where "name" is kind=CDK.

private subroutine json_value_add_string_val_ascii(me, name, val)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

name of the variable

character(kind=CDK,len=*), intent(in) :: val

value

Description

Alternate version of json_value_add_string where "val" is kind=CDK.

private subroutine escape_string(str_in, str_out)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: str_in
character(kind=CK,len=:), intent(out), allocatable:: str_out

Description

Author
Jacob Williams
Date
1/21/2014

Add the escape characters to a string for adding to JSON.

private subroutine json_value_add_string_vec(me, name, val, trim_str, adjustl_str)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

variable name

character(kind=CK,len=*), intent(in), dimension(:):: val

array of strings

logical(kind=LK), intent(in), optional :: trim_str

if TRIM() should be called for each element

logical(kind=LK), intent(in), optional :: adjustl_str

if ADJUSTL() should be called for each element

Description

Author
Jacob Williams
Date
1/19/2014

Add an array of character strings to the structure.

private subroutine wrap_json_value_add_string_vec(me, name, val, trim_str, adjustl_str)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name
character(kind=CDK,len=*), intent(in), dimension(:):: val
logical(kind=LK), intent(in), optional :: trim_str
logical(kind=LK), intent(in), optional :: adjustl_str

Description

Alternate version of json_value_add_string_vec where "name" and "val" are kind=CDK.

private subroutine json_value_add_string_vec_name_ascii(me, name, val, trim_str, adjustl_str)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name
character(kind=CK,len=*), intent(in), dimension(:):: val
logical(kind=LK), intent(in), optional :: trim_str
logical(kind=LK), intent(in), optional :: adjustl_str

Description

Alternate version of json_value_add_string_vec where "name" is kind=CDK.

private subroutine json_value_add_string_vec_val_ascii(me, name, val, trim_str, adjustl_str)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name
character(kind=CDK,len=*), intent(in), dimension(:):: val
logical(kind=LK), intent(in), optional :: trim_str
logical(kind=LK), intent(in), optional :: adjustl_str

Description

Alternate version of json_value_add_string_vec where "val" is kind=CDK.

public subroutine json_get_parent(me, p)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me

JSON object

type(json_value), intent(out), pointer:: p

pointer to parent

Description

Author
Jacob Williams
Date
10/16/2015

Returns a pointer to the parent of a json_value. If there is no parent, then a null() pointer is returned.

public subroutine json_get_next(me, p)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me

JSON object

type(json_value), intent(out), pointer:: p

pointer to next

Description

Author
Jacob Williams
Date
10/31/2015

Returns a pointer to the next of a json_value. If there is no next, then a null() pointer is returned.

public subroutine json_get_previous(me, p)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me

JSON object

type(json_value), intent(out), pointer:: p

pointer to previous

Description

Author
Jacob Williams
Date
10/31/2015

Returns a pointer to the previous of a json_value. If there is no previous, then a null() pointer is returned.

public subroutine json_get_tail(me, p)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me

JSON object

type(json_value), intent(out), pointer:: p

pointer to tail

Description

Author
Jacob Williams
Date
10/31/2015

Returns a pointer to the tail of a json_value. If there is no tail, then a null() pointer is returned.

private subroutine json_value_get_by_index(me, idx, p)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me

object or array JSON data

integer(kind=IK), intent(in) :: idx

index of the child

type(json_value), , pointer:: p

pointer to the child

Description

Returns a child in the object or array given the index.

private subroutine json_value_get_by_name_chars(me, name, p)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: name

the name of a child of "me"

type(json_value), , pointer:: p

pointer to the child

Description

Returns a child in the object or array given the name string.

private subroutine wrap_json_value_get_by_name_chars(me, name, p)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: name
type(json_value), , pointer:: p

Description

Alternate version of json_value_get_by_name_chars where "name" is kind=CDK.

private subroutine json_value_to_string(me, str)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=:), intent(out), allocatable:: str

prints structure to this string

Description

Author
Jacob Williams
Date
2/12/2014

Print the json_value structure to an allocatable string.

private subroutine json_print_1(me, iunit)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
integer(kind=IK), intent(in) :: iunit

the file unit (the file must already have been opened, can't be -1).

Description

Author
Jacob Williams
Date
6/20/2014

Print the json_value structure to a file.

private subroutine json_print_2(me, filename)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: filename

the filename to print to (should not already be open)

Description

Author
Jacob Williams
Date
12/23/2014

Print the json_value structure to a file.

private recursivesubroutine json_value_print(me, iunit, str, indent, need_comma, colon, is_array_element)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
integer(kind=IK), intent(in) :: iunit

file unit to write to (6=console)

character(kind=CK,len=:), intent(inout), allocatable:: str

if iunit==unit2str (-1) then the structure is printed to this string rather than a file. This mode is used by json_value_to_string.

integer(kind=IK), intent(in), optional :: indent

indention level

logical(kind=LK), intent(in), optional :: need_comma

if it needs a comma after it

logical(kind=LK), intent(in), optional :: colon

if the colon was just written

logical(kind=LK), intent(in), optional :: is_array_element

if this is an array element

Description

Print the JSON structure to a string or a file.

private subroutine json_get_by_path(me, path, p, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
type(json_value), intent(out), pointer:: p
logical(kind=LK), intent(out), optional :: found

true if it was found

Description

Returns the json_value pointer given the path string.

private subroutine wrap_json_get_by_path(me, path, p, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: path
type(json_value), intent(out), pointer:: p
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_by_path where "path" is kind=CDK.

private subroutine json_get_integer(me, value)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
integer(kind=IK), intent(out) :: value

Description

Get an integer value from a json_value.

private subroutine json_get_integer_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
integer(kind=IK), intent(out) :: value
logical(kind=LK), intent(out), optional :: found

Description

Get an integer value from a json_value, given the path string.

private subroutine wrap_json_get_integer_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: path
integer(kind=IK), intent(out) :: value
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_integer_with_path, where "path" is kind=CDK.

private subroutine json_get_integer_vec(me, vec)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
integer(kind=IK), intent(out), dimension(:), allocatable:: vec

Description

Author
Jacob Williams
Date
5/14/2014

Get an integer vector from a json_value.

private subroutine json_get_integer_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: path
integer(kind=IK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Get an integer vector from a json_value, given the path string.

private subroutine wrap_json_get_integer_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: path
integer(kind=IK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_integer_vec_with_path, where "path" is kind=CDK

private subroutine json_get_double(me, value)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
real(kind=RK), intent(out) :: value

Description

Get a double value from a json_value.

private subroutine json_get_double_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: path
real(kind=RK), intent(out) :: value
logical(kind=LK), intent(out), optional :: found

Description

Get a double value from a json_value, given the path.

private subroutine wrap_json_get_double_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: path
real(kind=RK), intent(out) :: value
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_double_with_path, where "path" is kind=CDK

private subroutine json_get_double_vec(me, vec)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
real(kind=RK), intent(out), dimension(:), allocatable:: vec

Description

Author
Jacob Williams
Date
5/14/2014

Get a double vector from a json_value.

private subroutine json_get_double_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: path
real(kind=RK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Get a double vector from a json_value, given the path.

private subroutine wrap_json_get_double_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: path
real(kind=RK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_double_vec_with_path, where "path" is kind=CDK

private subroutine json_get_logical(me, value)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
logical(kind=LK) :: value

Description

Get a logical value from a json_value.

private subroutine json_get_logical_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
logical(kind=LK) :: value
logical(kind=LK), intent(out), optional :: found

Description

Get a logical value from a json_value, given the path.

private subroutine wrap_json_get_logical_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: path
logical(kind=LK) :: value
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_logical_with_path, where "path" is kind=CDK

private subroutine json_get_logical_vec(me, vec)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
logical(kind=LK), intent(out), dimension(:), allocatable:: vec

Description

Author
Jacob Williams
Date
5/14/2014

Get a logical vector from json_value.

private subroutine json_get_logical_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
logical(kind=LK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Get a logical vector from a json_value, given the path.

private subroutine wrap_json_get_logical_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: path
logical(kind=LK), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_logical_vec_with_path, where "path" is kind=CDK

private subroutine json_get_string(me, value)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=:), intent(out), allocatable:: value

Description

Get a character string from a json_value.

private subroutine unescape_string(str_in, str_out)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(in) :: str_in

string as stored in a json_value

character(kind=CK,len=:), intent(out), allocatable:: str_out

decoded string

Description

Remove the escape characters from a JSON string and return it.

private subroutine json_get_string_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
character(kind=CK,len=:), intent(out), allocatable:: value
logical(kind=LK), intent(out), optional :: found

Description

Get a character string from a json_value, given the path.

private subroutine wrap_json_get_string_with_path(me, path, value, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: path
character(kind=CK,len=:), intent(out), allocatable:: value
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_string_with_path, where "path" is kind=CDK

private subroutine json_get_string_vec(me, vec)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec

Description

Author
Jacob Williams
Date
5/14/2014

Get a string vector from a json_file.

private subroutine json_get_string_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Get a string vector from a json_file, given the path.

private subroutine wrap_json_get_string_vec_with_path(me, path, vec, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: path
character(kind=CK,len=*), intent(out), dimension(:), allocatable:: vec
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_string_vec_with_path, where "path" is kind=CDK

private subroutine json_get_array(me, array_callback)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
procedure(array_callback_func) :: array_callback

Description

This routine calls the user-supplied array_callback_func subroutine for each element in the array.

public recursivesubroutine json_traverse(me, traverse_callback)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
procedure(traverse_callback_func) :: traverse_callback

Description

Author
Jacob Williams
Date
09/02/2015

Traverse a JSON structure. This routine calls the user-specified traverse_callback_func for each element of the structure.

private subroutine json_get_array_with_path(me, path, array_callback, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CK,len=*), intent(in) :: path
procedure(array_callback_func) :: array_callback
logical(kind=LK), intent(out), optional :: found

Description

This routine calls the user-supplied array_callback subroutine for each element in the array (specified by the path).

private subroutine wrap_json_get_array_with_path(me, path, array_callback, found)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(in), pointer:: me
character(kind=CDK,len=*), intent(in) :: path
procedure(array_callback_func) :: array_callback
logical(kind=LK), intent(out), optional :: found

Description

Alternate version of json_get_array_with_path, where "path" is kind=CDK

private subroutine json_parse_file(file, p, unit)

Arguments

Type IntentOptional AttributesName
character(kind=CDK,len=*), intent(in) :: file

JSON file name

type(json_value), , pointer:: p

output structure

integer(kind=IK), intent(in), optional :: unit

file unit number (/= 0)

Description

Parse the JSON file and populate the json_value tree.

private subroutine json_parse_string(p, str)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p

output structure

character(kind=CK,len=*), intent(in) :: str

string with JSON data

Description

Parse the JSON string and populate the json_value tree.

private subroutine wrap_json_parse_string(p, str)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: p

output structure

character(kind=CDK,len=*), intent(in) :: str

string with JSON data

Description

Alternate version of json_parse_string, where "str" is kind=CDK.

private subroutine annotate_invalid_json(iunit, str)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: iunit

file unit number

character(kind=CK,len=*), intent(in) :: str

string with JSON data

Description

Generate a warning message if there was an error parsing a JSON file or string.

private subroutine get_current_line_from_file_sequential(iunit, line)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: iunit

file unit number

character(kind=CK,len=:), intent(out), allocatable:: line

current line

Description

Author
Jacob Williams

Rewind the file to the beginning of the current line, and return this line. The file is assumed to be opened. This is the SEQUENTIAL version (see also get_current_line_from_file_stream).

private subroutine get_current_line_from_file_stream(iunit, line)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: iunit

file unit number

character(kind=CK,len=:), intent(out), allocatable:: line

current line

Description

Author
Jacob Williams

Rewind the file to the beginning of the current line, and return this line. The file is assumed to be opened. This is the STREAM version (see also get_current_line_from_file_sequential).

private recursivesubroutine parse_value(unit, str, value)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number

character(kind=CK,len=*), intent(in) :: str

string containing JSON data (only used if unit=0)

type(json_value), , pointer:: value

JSON data that is extracted

Description

Core parsing routine.

private subroutine json_value_create_logical(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
logical(kind=LK), intent(in) :: val

variable value

character(kind=CK,len=*), intent(in) :: name

variable name

Description

Author
Jacob Williams

Allocate a json_value pointer and make it a logical(LK) variable. The pointer should not already be allocated.

private subroutine wrap_json_value_create_logical(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
logical(kind=LK), intent(in) :: val
character(kind=CDK,len=*), intent(in) :: name

Description

Author
Izaak Beekman

Wrapper for json_value_create_logical so json_create_logical can be called with name of character kind 'DEFAULT' or 'ISO_10646'

private subroutine json_value_create_integer(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
integer(kind=IK), intent(in) :: val
character(kind=CK,len=*), intent(in) :: name

Description

Author
Jacob Williams

Allocate a json_value pointer and make it an integer(IK) variable. The pointer should not already be allocated.

private subroutine wrap_json_value_create_integer(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
integer(kind=IK), intent(in) :: val
character(kind=CDK,len=*), intent(in) :: name

Description

Author
Izaak Beekman

A wrapper procedure for json_value_create_integer so that json_create_integer may be called with either a 'DEFAULT' or 'ISO_10646' character kind 'name' actual argument.

private subroutine json_value_create_double(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
real(kind=RK), intent(in) :: val
character(kind=CK,len=*), intent(in) :: name

Description

Author
Jacob Williams

Allocate a json_value pointer and make it a real(RK) variable. The pointer should not already be allocated.

private subroutine wrap_json_value_create_double(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
real(kind=RK), intent(in) :: val
character(kind=CDK,len=*), intent(in) :: name

Description

Author
Izaak Beekman

A wrapper for json_value_create_double so that json_create_double may be called with an actual argument corresponding to the dummy argument, 'name' that may be of 'DEFAULT' or 'ISO_10646' character kind.

private subroutine json_value_create_string(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: val
character(kind=CK,len=*), intent(in) :: name

Description

Author
Jacob Williams

Allocate a json_value pointer and make it a string variable. The pointer should not already be allocated.

private subroutine wrap_json_value_create_string(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: val
character(kind=CDK,len=*), intent(in) :: name

Description

Author
Izaak Beekman

Wrap json_value_create_string so that json_create_string may be called with actual character string arguments for 'name' and 'val' that are BOTH of 'DEFAULT' or 'ISO_10646' character kind.

private subroutine json_value_create_null(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

Description

Author
Jacob Williams

Allocate a json_value pointer and make it a null variable. The pointer should not already be allocated.

private subroutine wrap_json_value_create_null(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

Description

Author
Izaak Beekman

Wrap json_value_create_null so that json_create_null may be called with an actual argument corresponding to the dummy argument 'name' that is either of 'DEFAULT' or 'ISO_10646' character kind.

private subroutine json_value_create_object(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

Description

Author
Jacob Williams

Allocate a json_value pointer and make it an object variable. The pointer should not already be allocated.

private subroutine wrap_json_value_create_object(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

Description

Author
Izaak Beekman

Wrap json_value_create_object so that json_create_object may be called with an actual argument corresponding to the dummy argument 'name' that is of either 'DEFAULT' or 'ISO_10646' character kind.

private subroutine json_value_create_array(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CK,len=*), intent(in) :: name

Description

Author
Jacob Williams

Allocate a json_value pointer and make it an array variable. The pointer should not already be allocated.

private subroutine wrap_json_value_create_array(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), , pointer:: me
character(kind=CDK,len=*), intent(in) :: name

Description

Author
Izaak Beekman

A wrapper for json_value_create_array so that json_create_array may be called with an actual argument, corresponding to the dummy argument 'name', that is either of 'DEFAULT' or 'ISO_10646' character kind.

private subroutine to_logical(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: me
logical(kind=LK), intent(in), optional :: val

if the value is also to be set (if not present, then .false. is used).

character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.

Description

Author
Jacob Williams

Change the json_value variable to a logical.

private subroutine to_integer(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: me
integer(kind=IK), intent(in), optional :: val

if the value is also to be set (if not present, then 0 is used).

character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.

Description

Author
Jacob Williams

Change the json_value variable to an integer.

private subroutine to_double(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: me
real(kind=RK), intent(in), optional :: val

if the value is also to be set (if not present, then 0.0_rk is used).

character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.

Description

Author
Jacob Williams

Change the json_value variable to a double.

private subroutine to_string(me, val, name)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: me
character(kind=CK,len=*), intent(in), optional :: val

if the value is also to be set (if not present, then '' is used).

character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.

Description

Author
Jacob Williams

Change the json_value variable to a string.

private subroutine to_null(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: me
character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.

Description

Author
Jacob Williams

Change the json_value variable to a null.

private subroutine to_object(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: me
character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.

Description

Author
Jacob Williams

Change the json_value variable to an object.

private subroutine to_array(me, name)

Arguments

Type IntentOptional AttributesName
type(json_value), intent(inout) :: me
character(kind=CK,len=*), intent(in), optional :: name

if the name is also to be changed.

Description

Author
Jacob Williams

Change the json_value variable to an array.

private recursivesubroutine parse_object(unit, str, parent)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number (if parsing from a file)

character(kind=CK,len=*), intent(in) :: str

JSON string (if parsing from a string)

type(json_value), , pointer:: parent

the parsed object will be added as a child of this

Description

Core parsing routine.

private recursivesubroutine parse_array(unit, str, array)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number (if parsing from a file)

character(kind=CK,len=*), intent(in) :: str

JSON string (if parsing from a string)

type(json_value), , pointer:: array

Description

Core parsing routine.

private subroutine parse_string(unit, str, string)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number (if parsing from a file)

character(kind=CK,len=*), intent(in) :: str

JSON string (if parsing from a string)

character(kind=CK,len=:), intent(out), allocatable:: string

Description

Parses a string while reading a JSON file.

private subroutine parse_for_chars(unit, str, chars)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number (if parsing from a file)

character(kind=CK,len=*), intent(in) :: str

JSON string (if parsing from a string)

character(kind=CK,len=*), intent(in) :: chars

the string to check for.

Description

Core parsing routine.

private subroutine parse_number(unit, str, value)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: unit

file unit number (if parsing from a file)

character(kind=CK,len=*), intent(in) :: str

JSON string (if parsing from a string)

type(json_value), , pointer:: value

Description

Author
Jacob Williams
Date
1/20/2014

Read a numerical value from the file (or string). The routine will determine if it is an integer or a double, and allocate the type accordingly.

private subroutine push_char(c)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=1), intent(in) :: c

Description

Core routine.

private puresubroutine integer_to_string(ival, str)

Arguments

Type IntentOptional AttributesName
integer(kind=IK), intent(in) :: ival

integer value.

character(kind=CK,len=*), intent(out) :: str

ival converted to a string.

Description

Author
Jacob Williams
Date
12/4/2013

Convert an integer to a string.

private subroutine real_to_string(rval, str)

Arguments

Type IntentOptional AttributesName
real(kind=RK), intent(in) :: rval

real value.

character(kind=CK,len=*), intent(out) :: str

rval converted to a string.

Description

Author
Jacob Williams
Date
12/4/2013

Convert a real value to a string.

private subroutine compact_real_string(str)

Arguments

Type IntentOptional AttributesName
character(kind=CK,len=*), intent(inout) :: str

string representation of a real number.

Description

Author
Izaak Beekman
Date
02/24/2015

Compact a string representing a real number, so that the same value is displayed with fewer characters.

public subroutine json_print_error_message(io_unit)

Arguments

Type IntentOptional AttributesName
integer, intent(in), optional :: io_unit

Description

Author
Jacob Williams

Print any error message, and then clear the exceptions.