Commit 346fc3fe authored by Marco Govoni's avatar Marco Govoni
Browse files

Updated Json-test

parent 57e178b3
......@@ -16,18 +16,16 @@ JSON_OBJS = ../Json/libjson.a
TLDEPS= bindir mods libs pw
#all : title tldeps wstat.x
all : title tldeps wstat.x
all : title test.x
wstat.x : $(JSON_OBJS) $(LIBOBJS)
test.x : $(JSONTEST_OBJS) $(LIBOBJS)
$(LD) $(LDFLAGS) -o test.x \
$(JSONTEST_OBJS) $(JSON_OBJS) $(LIBOBJS) $(LIBS)
# - ( cd ../../bin ; ln -fs ../West/Wstat/wstat.x . )
#tldeps:
# test -n "$(TLDEPS)" && ( cd ../.. ; $(MAKE) $(MFLAGS) $(TLDEPS) || exit 1) || :
- ./test.x
- python check.py
clean :
- /bin/rm -f *.x *.o *.a *~ *_tmp.f90 *.d *.mod *.i *.L
# - /bin/rm -f ../../bin/wstat.x
- /bin/rm -f *.x *.o *.a *~ *_tmp.f90 *.d *.mod *.i *.L *.json
title :
@echo " "
......
from __future__ import print_function
import json
with open('input_file.json',"r") as file:
idata = json.load(file)
with open('output_file.json',"r") as file:
odata = json.load(file)
assert( idata == odata )
print("Test passed.")
bar.o : ../../Modules/io_global.o
bar.o : ../../Modules/kind.o
bar.o : io_push.o
destroy_pw_arrays.o : ../../Modules/becmod.o
destroy_pw_arrays.o : ../../Modules/constants.o
destroy_pw_arrays.o : ../../Modules/control_flags.o
destroy_pw_arrays.o : ../../Modules/fft_base.o
destroy_pw_arrays.o : ../../Modules/funct.o
destroy_pw_arrays.o : ../../Modules/io_files.o
destroy_pw_arrays.o : ../../Modules/io_global.o
destroy_pw_arrays.o : ../../Modules/kind.o
destroy_pw_arrays.o : ../../Modules/mp.o
destroy_pw_arrays.o : ../../Modules/mp_global.o
destroy_pw_arrays.o : ../../Modules/noncol.o
destroy_pw_arrays.o : ../../Modules/uspp.o
destroy_pw_arrays.o : ../../Modules/wavefunctions.o
destroy_pw_arrays.o : ../../PW/src/buffers.o
destroy_pw_arrays.o : ../../PW/src/newd.o
destroy_pw_arrays.o : ../../PW/src/pwcom.o
destroy_pw_arrays.o : ../../PW/src/scf_mod.o
do_setup.o : ../../Modules/cell_base.o
do_setup.o : ../../Modules/constants.o
do_setup.o : ../../Modules/control_flags.o
do_setup.o : ../../Modules/io_global.o
do_setup.o : ../../Modules/kind.o
do_setup.o : ../../Modules/mp.o
do_setup.o : ../../Modules/mp_global.o
do_setup.o : ../../Modules/noncol.o
do_setup.o : ../../PW/src/pwcom.o
do_setup.o : io_push.o
get_alpha_pv.o : ../../Modules/kind.o
get_alpha_pv.o : ../../Modules/mp.o
get_alpha_pv.o : ../../Modules/mp_global.o
get_alpha_pv.o : ../../PW/src/pwcom.o
get_nbndval.o : ../../Modules/constants.o
get_nbndval.o : ../../Modules/io_global.o
get_nbndval.o : ../../Modules/kind.o
get_nbndval.o : ../../Modules/noncol.o
get_nbndval.o : ../../PW/src/pwcom.o
human_readable_time.o : ../../Modules/kind.o
init_pw_arrays.o : ../../Modules/becmod.o
init_pw_arrays.o : ../../Modules/constants.o
init_pw_arrays.o : ../../Modules/control_flags.o
init_pw_arrays.o : ../../Modules/fft_base.o
init_pw_arrays.o : ../../Modules/funct.o
init_pw_arrays.o : ../../Modules/io_files.o
init_pw_arrays.o : ../../Modules/io_global.o
init_pw_arrays.o : ../../Modules/kind.o
init_pw_arrays.o : ../../Modules/mp.o
init_pw_arrays.o : ../../Modules/mp_global.o
init_pw_arrays.o : ../../Modules/noncol.o
init_pw_arrays.o : ../../Modules/uspp.o
init_pw_arrays.o : ../../Modules/wavefunctions.o
init_pw_arrays.o : ../../PW/src/buffers.o
init_pw_arrays.o : ../../PW/src/newd.o
init_pw_arrays.o : ../../PW/src/pwcom.o
init_pw_arrays.o : ../../PW/src/scf_mod.o
io_push.o : ../../Modules/io_global.o
io_push.o : ../../Modules/kind.o
linear_algebra_kernel.o : ../../Modules/kind.o
set_iks_l2g.o : ../../Modules/kind.o
set_iks_l2g.o : ../../Modules/mp.o
set_iks_l2g.o : ../../Modules/mp_global.o
set_iks_l2g.o : ../../PW/src/pwcom.o
set_iks_l2g.o : ../../West/Modules/westcom.o
set_isz.o : ../../Modules/cell_base.o
set_isz.o : ../../Modules/constants.o
set_isz.o : ../../Modules/kind.o
set_isz.o : ../../West/Modules/westcom.o
PROGRAM test
USE json_module, ONLY : json_file
PRINT*, "HELLO WORLD!"
INTEGER, PARAMETER :: DP = selected_real_kind(14,200)
TYPE(json_file) :: json
INTEGER :: i
INTEGER :: iiarg, nargs
INTEGER :: numsp
LOGICAL :: found
CHARACTER(LEN=512) :: input_file
CHARACTER(LEN=:),ALLOCATABLE :: cval
REAL(DP) :: rval
INTEGER :: ival
INTEGER,ALLOCATABLE :: ivec(:)
REAL(DP),ALLOCATABLE :: rvec(:)
LOGICAL :: lval
!
INTEGER :: iunit
INTEGER :: i0, i0_
!
CHARACTER(LEN=512),PARAMETER :: ifile="input_file.json"
CHARACTER(LEN=512),PARAMETER :: ofile="output_file.json"
!
! INIT INPUT FILE
!
OPEN( NEWUNIT=iunit, FILE=TRIM(ifile) )
WRITE( iunit, * ) '{ "test" : { "i0" : 100} }'
CLOSE( iunit )
!
! INIT OUTPUT FILE
!
OPEN( NEWUNIT=iunit, FILE=TRIM(ofile) )
WRITE( iunit, * ) '{}'
CLOSE( iunit )
!
! READ
!
CALL json%initialize()
CALL json%load_file(filename = TRIM(ifile))
CALL json%get('test.i0', i0, found)
i0_ = 0
IF( found ) i0_ = i0
CALL json%destroy()
!
! WRITE
!
CALL json%initialize()
CALL json%load_file(filename = TRIM(ofile))
CALL json%add('test.i0', i0_)
!
OPEN( NEWUNIT=iunit, FILE=TRIM(ofile) )
CALL json%print_file( iunit )
CLOSE( iunit )
CALL json%destroy()
END PROGRAM
......@@ -21,7 +21,7 @@ json_test_do:
( cd Json-test ; if test "$(MAKE)" = "" ; then make $(MFLAGS) all; \
else $(MAKE) $(MFLAGS) all ; fi ) ; fi
clean: json_undo base64_undo
clean: json_undo base64_undo json_test_undo
json_undo:
if test -d Json ; then \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment