Skip to content

compact_reals and real_format='*' can now be used at the same time. #227

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/json_value_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,13 @@ subroutine json_initialize(json,verbose,compact_reals,&
!! and similar routines. If true [default],
!! then the string is returned unescaped.

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

!reset exception to false:
call json%clear_exceptions()
Expand Down Expand Up @@ -776,7 +779,13 @@ subroutine json_initialize(json,verbose,compact_reals,&
! [this overrides the other options]
if (present(real_format)) then
if (real_format==star) then
json%compact_real = .false.
if (present(compact_reals)) then
! we will also allow for compact reals with
! '*' format, if both arguments are present.
json%compact_real = compact_reals
else
json%compact_real = .false.
end if
json%real_fmt = star
return
end if
Expand Down Expand Up @@ -1043,10 +1052,10 @@ subroutine json_info_by_path(json,p,path,found,var_type,n_children,name)
integer(IK),intent(out),optional :: n_children !! number of children
character(kind=CK,len=:),allocatable,intent(out),optional :: name !! variable name

type(json_value),pointer :: p_var
logical(LK) :: ok
type(json_value),pointer :: p_var !! temporary pointer
logical(LK) :: ok !! if the variable was found
#if defined __GFORTRAN__
character(kind=CK,len=:),allocatable :: p_name
character(kind=CK,len=:),allocatable :: p_name !! temporary variable for getting name
#endif

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

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

call json%get(p,path,p_var,found)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/jf_test_1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ subroutine test_1(error_cnt)
write(error_unit,'(A)') ''
write(error_unit,'(A)') 'printing each variable [namelist style]'
write(error_unit,'(A)') ''
call core%initialize(unescape_strings=.false.)
call core%initialize(unescape_strings=.false.,compact_reals=.true.,real_format='*')
call core%traverse(p,print_json_variable)

namelist_style = .false.
Expand Down