Skip to content

Commit a32204c

Browse files
committed
additional refactoring.
Disabled coverage in travis to see if tests will pass without it.
1 parent e2c03dd commit a32204c

File tree

3 files changed

+39
-36
lines changed

3 files changed

+39
-36
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ env:
4141
DEPLOY_DOCUMENTATION="no"
4242
4343
# build with build.sh, make documentation, run unit tests and perform coverage analysis
44+
# JW note: disabled coverage for testing purposes !!!! need to fix !!!!
4445
- >
45-
BUILD_SCRIPT="./build.sh --coverage --skip-documentation &&
46-
./build.sh --coverage --enable-unicode"
47-
CODE_COVERAGE="yes"
46+
BUILD_SCRIPT="./build.sh --skip-documentation &&
47+
./build.sh --enable-unicode"
48+
CODE_COVERAGE="no"
4849
DEPLOY_DOCUMENTATION="yes"
4950
5051
install:

src/json_parameters.F90

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ module json_parameters
2323
character(kind=CK,len=*),parameter :: end_array = ']'
2424
character(kind=CK,len=*),parameter :: delimiter = ','
2525
character(kind=CK,len=*),parameter :: colon_char = ':'
26+
character(kind=CK,len=*),parameter :: start_array_alt = '(' !! for [[json_get_by_path]]
27+
character(kind=CK,len=*),parameter :: end_array_alt = ')' !! for [[json_get_by_path]]
28+
character(kind=CK,len=*),parameter :: root = '$' !! for [[json_get_by_path]]
29+
character(kind=CK,len=*),parameter :: this = '@' !! for [[json_get_by_path]]
30+
character(kind=CK,len=*),parameter :: child = '.' !! for [[json_get_by_path]]
2631
character(kind=CK,len=*),parameter :: bspace = achar(8)
2732
character(kind=CK,len=*),parameter :: horizontal_tab = achar(9)
2833
character(kind=CK,len=*),parameter :: newline = achar(10)
@@ -34,9 +39,9 @@ module json_parameters
3439

3540
!These were parameters, but gfortran bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65141)
3641
!necessitates moving them here to be variables
37-
character(kind=CK,len=4) :: null_str = 'null'
38-
character(kind=CK,len=4) :: true_str = 'true'
39-
character(kind=CK,len=5) :: false_str = 'false'
42+
character(kind=CK,len=4),protected :: null_str = 'null'
43+
character(kind=CK,len=4),protected :: true_str = 'true'
44+
character(kind=CK,len=5),protected :: false_str = 'false'
4045

4146
integer, private :: i_ !! just a counter for control_chars array
4247
character(kind=CK,len=*),dimension(32),parameter :: control_chars = &
@@ -68,5 +73,7 @@ module json_parameters
6873
!! output to strings rather than files.
6974
!! See 9.5.6.12 in the F2003/08 standard
7075

76+
integer(IK),parameter,public :: seq_chunk_size = 256 !! chunk size for reading sequential files
77+
7178
end module json_parameters
7279
!*****************************************************************************************

src/json_value_module.F90

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,12 @@ end subroutine traverse_callback_func
264264
module procedure MAYBEWRAP(json_value_add_logical_vec)
265265
module procedure MAYBEWRAP(json_value_add_string)
266266
module procedure MAYBEWRAP(json_value_add_string_vec)
267-
# ifdef USE_UCS4
267+
#ifdef USE_UCS4
268268
module procedure json_value_add_string_name_ascii
269269
module procedure json_value_add_string_val_ascii
270270
module procedure json_value_add_string_vec_name_ascii
271271
module procedure json_value_add_string_vec_val_ascii
272-
# endif
272+
#endif
273273
end interface json_add
274274
!*************************************************************************************
275275

@@ -289,10 +289,10 @@ end subroutine traverse_callback_func
289289
MAYBEWRAP(json_update_double),&
290290
MAYBEWRAP(json_update_integer),&
291291
MAYBEWRAP(json_update_string)
292-
# ifdef USE_UCS4
292+
#ifdef USE_UCS4
293293
module procedure json_update_string_name_ascii
294294
module procedure json_update_string_val_ascii
295-
# endif
295+
#endif
296296
end interface json_update
297297
!*************************************************************************************
298298

@@ -784,11 +784,14 @@ subroutine json_initialize(verbose,compact_reals,print_signs,real_format)
784784
!clear any errors from previous runs:
785785
call json_clear_exceptions()
786786

787-
!JW note: do we need this?.....
787+
!
788+
!JW comment out for now (these are now protected variables in another module)
789+
! for thread-save version, we won't be able to have global variables.........
790+
!
788791
!Ensure gfortran bug work around "parameters" are set properly
789-
null_str = 'null'
790-
true_str = 'true'
791-
false_str = 'false'
792+
!null_str = 'null'
793+
!true_str = 'true'
794+
!false_str = 'false'
792795

793796
!Just in case, clear these global variables also:
794797
pushed_index = 0
@@ -797,11 +800,11 @@ subroutine json_initialize(verbose,compact_reals,print_signs,real_format)
797800
line_count = 1
798801
ipos = 1
799802

800-
# ifdef USE_UCS4
803+
#ifdef USE_UCS4
801804
! reopen stdout and stderr with utf-8 encoding
802805
open(output_unit,encoding='utf-8')
803806
open(error_unit, encoding='utf-8')
804-
# endif
807+
#endif
805808

806809
!verbose error printing:
807810
if (present(verbose)) is_verbose = verbose
@@ -1055,7 +1058,8 @@ recursive subroutine json_value_destroy(me,destroy_next)
10551058
implicit none
10561059

10571060
type(json_value),pointer :: me
1058-
logical(LK),intent(in),optional :: destroy_next !! if true, then me%next is also destroyed (default is true)
1061+
logical(LK),intent(in),optional :: destroy_next !! if true, then me%next
1062+
!! is also destroyed (default is true)
10591063

10601064
logical(LK) :: des_next
10611065
type(json_value), pointer :: p
@@ -1819,7 +1823,7 @@ subroutine json_value_add_logical_vec(me, name, val)
18191823
logical(LK),dimension(:),intent(in) :: val !! value
18201824

18211825
type(json_value),pointer :: var
1822-
integer(IK) :: i !counter
1826+
integer(IK) :: i !! counter
18231827

18241828
!create the variable as an array:
18251829
call json_value_create(var)
@@ -2727,13 +2731,9 @@ subroutine json_get_by_path(me, path, p, found)
27272731
type(json_value),pointer,intent(out) :: p
27282732
logical(LK),intent(out),optional :: found !! true if it was found
27292733

2730-
character(kind=CK,len=1),parameter :: start_array_alt = '('
2731-
character(kind=CK,len=1),parameter :: end_array_alt = ')'
2732-
character(kind=CK,len=1),parameter :: root = '$'
2733-
character(kind=CK,len=1),parameter :: this = '@'
2734-
character(kind=CK,len=1),parameter :: child = '.'
2735-
2736-
integer(IK) :: i,length,child_i
2734+
integer(IK) :: i
2735+
integer(IK) :: length
2736+
integer(IK) :: child_i
27372737
character(kind=CK,len=1) :: c
27382738
logical(LK) :: array
27392739
type(json_value),pointer :: tmp
@@ -4358,10 +4358,7 @@ subroutine get_current_line_from_file_sequential(iunit,line)
43584358
integer(IK),intent(in) :: iunit !! file unit number
43594359
character(kind=CK,len=:),allocatable,intent(out) :: line !! current line
43604360

4361-
integer(IK),parameter :: n_chunk = 256 ! chunk size [arbitrary]
4362-
character(kind=CDK,len=*),parameter :: nfmt = '(A256)' ! corresponding format statement
4363-
4364-
character(kind=CK,len=n_chunk) :: chunk
4361+
character(kind=CK,len=seq_chunk_size) :: chunk
43654362
integer(IK) :: istat,isize
43664363

43674364
!initialize:
@@ -4374,12 +4371,12 @@ subroutine get_current_line_from_file_sequential(iunit,line)
43744371
![the line is read in chunks until the end of the line is reached]
43754372
if (istat==0) then
43764373
do
4377-
isize=0
4378-
read(iunit,fmt=nfmt,advance='NO',size=isize,iostat=istat) chunk
4374+
isize = 0
4375+
read(iunit,fmt='(A)',advance='NO',size=isize,iostat=istat) chunk
43794376
if (istat==0) then
43804377
line = line//chunk
43814378
else
4382-
if (isize>0 .and. isize<=n_chunk) line = line//chunk(1:isize)
4379+
if (isize>0 .and. isize<=seq_chunk_size) line = line//chunk(1:isize)
43834380
exit
43844381
end if
43854382
end do
@@ -4405,8 +4402,6 @@ subroutine get_current_line_from_file_stream(iunit,line)
44054402
integer(IK) :: istart,iend,ios
44064403
character(kind=CK,len=1) :: c
44074404

4408-
!updated for the new STREAM version:
4409-
44104405
istart = ipos
44114406
do
44124407
if (istart<=1) then
@@ -4446,8 +4441,8 @@ recursive subroutine parse_value(unit, str, value)
44464441

44474442
logical(LK) :: eof
44484443
character(kind=CK,len=1) :: c
4449-
character(kind=CK,len=:),allocatable :: tmp !this is a work-around for a bug
4450-
! in the gfortran 4.9 compiler.
4444+
character(kind=CK,len=:),allocatable :: tmp !! this is a work-around for a bug
4445+
!! in the gfortran 4.9 compiler.
44514446

44524447
if (.not. exception_thrown) then
44534448

0 commit comments

Comments
 (0)