@@ -259,15 +259,15 @@ module json_module
259
259
!
260
260
! The types of JSON data.
261
261
!
262
- integer (IK),parameter ,public :: json_unknown = 0 ! ! Unknown JSON data type
262
+ integer (IK),parameter ,public :: json_unknown = 0 ! ! Unknown JSON data type
263
263
! ! (see [[json_file_variable_info]] and [[json_info]])
264
264
integer (IK),parameter ,public :: json_null = 1 ! ! Null JSON data type
265
265
! ! (see [[json_file_variable_info]] and [[json_info]])
266
266
integer (IK),parameter ,public :: json_object = 2 ! ! Object JSON data type
267
267
! ! (see [[json_file_variable_info]] and [[json_info]])
268
268
integer (IK),parameter ,public :: json_array = 3 ! ! Array JSON data type
269
269
! ! (see [[json_file_variable_info]] and [[json_info]])
270
- integer (IK),parameter ,public :: json_logical = 4 ! ! Logical JSON data type
270
+ integer (IK),parameter ,public :: json_logical = 4 ! ! Logical JSON data type
271
271
! ! (see [[json_file_variable_info]] and [[json_info]])
272
272
integer (IK),parameter ,public :: json_integer = 5 ! ! Integer JSON data type
273
273
! ! (see [[json_file_variable_info]] and [[json_info]])
@@ -464,7 +464,7 @@ module json_module
464
464
465
465
! *************************************************************************************
466
466
abstract interface
467
-
467
+
468
468
subroutine array_callback_func (element , i , count )
469
469
! ! Array element callback function. Used by [[json_get_array]]
470
470
import :: json_value,IK
@@ -473,15 +473,15 @@ subroutine array_callback_func(element, i, count)
473
473
integer (IK),intent (in ) :: i ! index
474
474
integer (IK),intent (in ) :: count ! size of array
475
475
end subroutine array_callback_func
476
-
476
+
477
477
subroutine traverse_callback_func (p ,finished )
478
478
! ! Callback function used by [[json_traverse]]
479
479
import :: json_value,LK
480
480
implicit none
481
481
type (json_value),pointer ,intent (in ) :: p
482
482
logical (LK),intent (out ) :: finished
483
483
end subroutine traverse_callback_func
484
-
484
+
485
485
end interface
486
486
! *************************************************************************************
487
487
@@ -668,7 +668,7 @@ end subroutine traverse_callback_func
668
668
module procedure MAYBEWRAP(json_value_remove_if_present)
669
669
end interface
670
670
! *************************************************************************************
671
-
671
+
672
672
! *************************************************************************************
673
673
! >
674
674
! Allocate a [[json_value]] pointer and make it a double variable.
@@ -889,9 +889,9 @@ end subroutine traverse_callback_func
889
889
integer (IK),parameter :: spaces_per_tab = 2
890
890
891
891
! Variables for real string printing:
892
-
892
+
893
893
logical (LK) :: compact_real = .true. ! ! to use the "compact" form of real numbers for output
894
-
894
+
895
895
! find out the precision of the floating point number system
896
896
! and set safety factors
897
897
integer (IK),parameter :: rp_safety_factor = 1
@@ -906,7 +906,7 @@ end subroutine traverse_callback_func
906
906
real (max (maxexp,abs (maxexp)),&
907
907
kind= RK) ) )
908
908
909
- integer (IK),parameter :: max_numeric_str_len = real_precision + real_exponent_digits + 6
909
+ integer (IK),parameter :: max_numeric_str_len = real_precision + real_exponent_digits + 6
910
910
! ! 6 = sign + leading 0 + decimal + 'E' + exponent sign + 1 extra
911
911
character (kind= CDK,len=* ),parameter :: int_fmt = ' (ss,I0)' ! ! minimum width format for integers
912
912
character (kind= CK, len=* ),parameter :: star = ' *' ! ! for invalid numbers and list-directed real output
@@ -919,7 +919,7 @@ end subroutine traverse_callback_func
919
919
920
920
! exception handling [private variables]
921
921
logical (LK) :: is_verbose = .false. ! ! if true, all exceptions are immediately printed to console
922
- logical (LK) :: exception_thrown = .true. ! ! the error flag (by default, this is true to
922
+ logical (LK) :: exception_thrown = .true. ! ! the error flag (by default, this is true to
923
923
! ! make sure that [[json_initialize]] is called.
924
924
character (kind= CK,len= :),allocatable :: err_message ! ! the error message
925
925
@@ -966,12 +966,12 @@ subroutine json_clone(from,to)
966
966
implicit none
967
967
968
968
type (json_value),pointer :: from ! ! this is the structure to clone
969
- type (json_value),pointer :: to ! ! the clone is put here
969
+ type (json_value),pointer :: to ! ! the clone is put here
970
970
! ! (it must not already be associated)
971
-
971
+
972
972
! call the main function:
973
- call json_value_clone_func(from,to )
974
-
973
+ call json_value_clone_func(from,to )
974
+
975
975
end subroutine json_clone
976
976
! *****************************************************************************************
977
977
@@ -981,30 +981,30 @@ end subroutine json_clone
981
981
!
982
982
! Recursive deep copy function called by [[json_clone]].
983
983
!
984
- ! @note If new data is added to the [[json_value]] type,
984
+ ! @note If new data is added to the [[json_value]] type,
985
985
! then this would need to be updated.
986
-
986
+
987
987
recursive subroutine json_value_clone_func (from ,to ,parent ,previous ,next ,children ,tail )
988
988
989
989
implicit none
990
990
991
991
type (json_value),pointer :: from ! ! this is the structure to clone
992
- type (json_value),pointer :: to ! ! the clone is put here
992
+ type (json_value),pointer :: to ! ! the clone is put here
993
993
! ! (it must not already be associated)
994
994
type (json_value),pointer ,optional :: parent ! ! to%parent
995
995
type (json_value),pointer ,optional :: previous ! ! to%previous
996
996
type (json_value),pointer ,optional :: next ! ! to%next
997
997
type (json_value),pointer ,optional :: children ! ! to%children
998
998
logical ,optional :: tail ! ! if "to" is the tail of its parent's children
999
-
999
+
1000
1000
nullify(to )
1001
1001
1002
1002
if (associated (from)) then
1003
-
1003
+
1004
1004
allocate (to )
1005
-
1005
+
1006
1006
! copy over the data variables:
1007
- ! [note: the allocate() statements don't work here for the
1007
+ ! [note: the allocate() statements don't work here for the
1008
1008
! deferred-length characters in gfortran-4.9]
1009
1009
if (allocated (from% name)) to % name = from% name
1010
1010
if (allocated (from% dbl_value)) allocate (to % dbl_value,source= from% dbl_value)
@@ -1013,17 +1013,17 @@ recursive subroutine json_value_clone_func(from,to,parent,previous,next,children
1013
1013
if (allocated (from% int_value)) allocate (to % int_value,source= from% int_value)
1014
1014
to % var_type = from% var_type
1015
1015
to % n_children = from% n_children
1016
-
1016
+
1017
1017
! allocate and associate the pointers as necessary:
1018
-
1018
+
1019
1019
if (present (parent)) to % parent = > parent
1020
1020
if (present (previous)) to % previous = > previous
1021
1021
if (present (next)) to % next = > next
1022
1022
if (present (children)) to % children = > children
1023
1023
if (present (tail)) then
1024
1024
if (tail) to % parent% tail = > to
1025
1025
end if
1026
-
1026
+
1027
1027
if (associated (from% next)) then
1028
1028
allocate (to % next)
1029
1029
call json_value_clone_func(from% next,&
@@ -1038,9 +1038,9 @@ recursive subroutine json_value_clone_func(from,to,parent,previous,next,children
1038
1038
call json_value_clone_func(from% children,&
1039
1039
to % children,&
1040
1040
parent= to ,&
1041
- tail= (.not. associated (from% children% next)))
1041
+ tail= (.not. associated (from% children% next)))
1042
1042
end if
1043
-
1043
+
1044
1044
end if
1045
1045
1046
1046
end subroutine json_value_clone_func
@@ -1053,9 +1053,9 @@ end subroutine json_value_clone_func
1053
1053
! Cast a [[json_value]] object as a [[json_file(type)]] object
1054
1054
1055
1055
function initialize_json_file (p ) result(file_object)
1056
-
1056
+
1057
1057
implicit none
1058
-
1058
+
1059
1059
type (json_value),pointer ,optional ,intent (in ) :: p ! ! `json_value` object to cast
1060
1060
! ! as a `json_file` object
1061
1061
type (json_file) :: file_object
@@ -1819,7 +1819,7 @@ subroutine json_initialize(verbose,compact_reals,print_signs,real_format)
1819
1819
present (compact_reals) .or. &
1820
1820
present (print_signs) .or. &
1821
1821
present (real_format) ) then
1822
-
1822
+
1823
1823
! allow the special case where real format is '*':
1824
1824
! [this overrides the other options]
1825
1825
if (present (real_format)) then
@@ -1830,7 +1830,7 @@ subroutine json_initialize(verbose,compact_reals,print_signs,real_format)
1830
1830
end if
1831
1831
end if
1832
1832
1833
- if (present (compact_reals)) compact_real = compact_reals
1833
+ if (present (compact_reals)) compact_real = compact_reals
1834
1834
1835
1835
! set defaults
1836
1836
sgn_prnt = .false.
@@ -3382,9 +3382,9 @@ subroutine json_get_parent(me,p)
3382
3382
3383
3383
type (json_value),pointer ,intent (in ) :: me ! ! JSON object
3384
3384
type (json_value),pointer ,intent (out ) :: p ! ! pointer to parent
3385
-
3385
+
3386
3386
p = > me% parent
3387
-
3387
+
3388
3388
end subroutine json_get_parent
3389
3389
! *****************************************************************************************
3390
3390
@@ -3401,9 +3401,9 @@ subroutine json_get_next(me,p)
3401
3401
3402
3402
type (json_value),pointer ,intent (in ) :: me ! ! JSON object
3403
3403
type (json_value),pointer ,intent (out ) :: p ! ! pointer to next
3404
-
3404
+
3405
3405
p = > me% next
3406
-
3406
+
3407
3407
end subroutine json_get_next
3408
3408
! *****************************************************************************************
3409
3409
@@ -3420,9 +3420,9 @@ subroutine json_get_previous(me,p)
3420
3420
3421
3421
type (json_value),pointer ,intent (in ) :: me ! ! JSON object
3422
3422
type (json_value),pointer ,intent (out ) :: p ! ! pointer to previous
3423
-
3423
+
3424
3424
p = > me% previous
3425
-
3425
+
3426
3426
end subroutine json_get_previous
3427
3427
! *****************************************************************************************
3428
3428
@@ -3439,9 +3439,9 @@ subroutine json_get_tail(me,p)
3439
3439
3440
3440
type (json_value),pointer ,intent (in ) :: me ! ! JSON object
3441
3441
type (json_value),pointer ,intent (out ) :: p ! ! pointer to tail
3442
-
3442
+
3443
3443
p = > me% tail
3444
-
3444
+
3445
3445
end subroutine json_get_tail
3446
3446
! *****************************************************************************************
3447
3447
@@ -4152,16 +4152,16 @@ function string_to_double(str) result(rval)
4152
4152
integer (IK) :: ierr
4153
4153
4154
4154
if (.not. exception_thrown) then
4155
-
4155
+
4156
4156
! string to double
4157
- read (str,fmt=* ,iostat= ierr) rval
4158
-
4157
+ read (str,fmt=* ,iostat= ierr) rval
4158
+
4159
4159
if (ierr/= 0 ) then ! if there was an error
4160
4160
rval = 0.0_RK
4161
4161
call throw_exception(' Error in string_to_double:' // &
4162
4162
' string cannot be converted to a double: ' // trim (str))
4163
4163
end if
4164
-
4164
+
4165
4165
end if
4166
4166
4167
4167
end function string_to_double
@@ -5195,7 +5195,7 @@ end subroutine json_get_array
5195
5195
! date: 09/02/2015
5196
5196
!
5197
5197
! Traverse a JSON structure.
5198
- ! This routine calls the user-specified [[traverse_callback_func]]
5198
+ ! This routine calls the user-specified [[traverse_callback_func]]
5199
5199
! for each element of the structure.
5200
5200
!
5201
5201
recursive subroutine json_traverse (me ,traverse_callback )
0 commit comments