Skip to content

Commit 0287608

Browse files
committed
compact_reals and real_format='*' can now be used at the same time.
1 parent 84d42b6 commit 0287608

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/json_value_module.F90

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,13 @@ subroutine json_initialize(json,verbose,compact_reals,&
727727
!! and similar routines. If true [default],
728728
!! then the string is returned unescaped.
729729

730-
character(kind=CDK,len=10) :: w,d,e
731-
character(kind=CDK,len=2) :: sgn, rl_edit_desc
732-
integer(IK) :: istat
733-
logical(LK) :: sgn_prnt
730+
character(kind=CDK,len=10) :: w !! max string length
731+
character(kind=CDK,len=10) :: d !! real precision digits
732+
character(kind=CDK,len=10) :: e !! real exponent digits
733+
character(kind=CDK,len=2) :: sgn !! sign flag: `ss` or `sp`
734+
character(kind=CDK,len=2) :: rl_edit_desc !! `G`, `E`, `EN`, or `ES`
735+
integer(IK) :: istat !! `iostat` flag for write statements
736+
logical(LK) :: sgn_prnt !! print sign flag
734737

735738
!reset exception to false:
736739
call json%clear_exceptions()
@@ -776,7 +779,13 @@ subroutine json_initialize(json,verbose,compact_reals,&
776779
! [this overrides the other options]
777780
if (present(real_format)) then
778781
if (real_format==star) then
779-
json%compact_real = .false.
782+
if (present(compact_reals)) then
783+
! we will also allow for compact reals with
784+
! '*' format, if both arguments are present.
785+
json%compact_real = compact_reals
786+
else
787+
json%compact_real = .false.
788+
end if
780789
json%real_fmt = star
781790
return
782791
end if
@@ -1043,10 +1052,10 @@ subroutine json_info_by_path(json,p,path,found,var_type,n_children,name)
10431052
integer(IK),intent(out),optional :: n_children !! number of children
10441053
character(kind=CK,len=:),allocatable,intent(out),optional :: name !! variable name
10451054

1046-
type(json_value),pointer :: p_var
1047-
logical(LK) :: ok
1055+
type(json_value),pointer :: p_var !! temporary pointer
1056+
logical(LK) :: ok !! if the variable was found
10481057
#if defined __GFORTRAN__
1049-
character(kind=CK,len=:),allocatable :: p_name
1058+
character(kind=CK,len=:),allocatable :: p_name !! temporary variable for getting name
10501059
#endif
10511060

10521061
call json%get(p,path,p_var,found)
@@ -1158,7 +1167,7 @@ subroutine json_matrix_info(json,p,is_matrix,var_type,n_sets,set_size,name)
11581167
integer :: i !! counter
11591168
integer :: j !! counter
11601169
#if defined __GFORTRAN__
1161-
character(kind=CK,len=:),allocatable :: p_name
1170+
character(kind=CK,len=:),allocatable :: p_name !! temporary variable for getting name
11621171
#endif
11631172

11641173
!get info about the variable:
@@ -1273,7 +1282,7 @@ subroutine json_matrix_info_by_path(json,p,path,is_matrix,found,&
12731282
type(json_value),pointer :: p_var
12741283
logical(LK) :: ok
12751284
#if defined __GFORTRAN__
1276-
character(kind=CK,len=:),allocatable :: p_name
1285+
character(kind=CK,len=:),allocatable :: p_name !! temporary variable for getting name
12771286
#endif
12781287

12791288
call json%get(p,path,p_var,found)

0 commit comments

Comments
 (0)