Skip to content

Commit 43deaec

Browse files
committed
some refactoring
added a new print to string routine
1 parent 341eb45 commit 43deaec

File tree

3 files changed

+179
-115
lines changed

3 files changed

+179
-115
lines changed

build.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ BUILDDIR='lib/'
1111
BINDIR='bin/'
1212

1313
FCOMPILER='ifort'
14-
FCOMPILERFLAGS='-O2'
14+
#FCOMPILERFLAGS='-O2'
15+
FCOMPILERFLAGS='-check all -debug full'
1516

1617
ARCHIVER='ar'
1718
ARCHIVERFLAGS='-cq'
@@ -20,7 +21,7 @@ FEXT='.f90'
2021
OBJEXT='.o'
2122
LIBEXT='.a'
2223

23-
LIBOUT='libfson'
24+
LIBOUT='libjson'
2425
EXEOUT='json'
2526

2627
MODCODE='json_module'

src/json_example.f90

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ subroutine memory_leak_test()
150150
write(*,*) ' MEMORY LEAK TEST'
151151
write(*,*) '================================='
152152
write(*,*) ''
153+
154+
i = 0
153155

154156
do
155157

@@ -169,7 +171,10 @@ subroutine test_4()
169171
!**************************************************************
170172
!
171173
! Populate a JSON structure, write it to a file,
172-
! then read it.
174+
! then read it.
175+
!
176+
! Also tests the json_value_to_string routine to write
177+
! the file to a character string.
173178
!
174179
!**************************************************************
175180
implicit none
@@ -180,6 +185,7 @@ subroutine test_4()
180185
integer :: i
181186
character(len=10) :: istr
182187
integer :: iunit
188+
character(len=:),allocatable :: string
183189

184190
write(*,*) ''
185191
write(*,*) '================================='
@@ -205,13 +211,21 @@ subroutine test_4()
205211
nullify(inp)
206212

207213
write(*,*) ''
208-
write(*,*) 'write file'
214+
write(*,*) 'write to file'
209215

210216
!write the file:
211217
open(newunit=iunit, file=dir//filename4, status='REPLACE')
212218
call json_print(p,iunit)
213219
close(iunit)
214220

221+
write(*,*) ''
222+
write(*,*) 'write to string'
223+
write(*,*) ''
224+
!write it to a string, and print to console:
225+
call json_print_to_string(p, string)
226+
write(*,*) string
227+
deallocate(string) !cleanup
228+
215229
!cleanup:
216230
call json_destroy(p)
217231

0 commit comments

Comments
 (0)