@@ -851,7 +851,7 @@ end subroutine json_file_move_pointer
851
851
! end program main
852
852
! ```
853
853
854
- subroutine json_file_load (me , filename , unit )
854
+ subroutine json_file_load (me , filename , unit , destroy_pointer )
855
855
856
856
implicit none
857
857
@@ -860,8 +860,14 @@ subroutine json_file_load(me, filename, unit)
860
860
integer (IK),intent (in ),optional :: unit ! ! the unit number to use
861
861
! ! (if not present, a newunit
862
862
! ! is used)
863
+ logical (LK),intent (in ),optional :: destroy_pointer ! ! destroy the pointer before
864
+ ! ! loading (default is True)
863
865
864
- call me% destroy()
866
+ if (present (destroy_pointer)) then
867
+ if (destroy_pointer) call me% destroy()
868
+ else ! by default it is destroyed
869
+ call me% destroy()
870
+ end if
865
871
call me% core% load(file= filename, p= me% p, unit= unit)
866
872
867
873
end subroutine json_file_load
@@ -881,14 +887,20 @@ end subroutine json_file_load
881
887
! call f%deserialize('{ "name": "Leonidas" }')
882
888
! ```
883
889
884
- subroutine json_file_load_from_string (me , str )
890
+ subroutine json_file_load_from_string (me , str , destroy_pointer )
885
891
886
892
implicit none
887
893
888
894
class(json_file),intent (inout ) :: me
889
895
character (kind= CK,len=* ),intent (in ) :: str ! ! string to load JSON data from
896
+ logical (LK),intent (in ),optional :: destroy_pointer ! ! destroy the pointer before
897
+ ! ! loading (default is True)
890
898
891
- call me% destroy()
899
+ if (present (destroy_pointer)) then
900
+ if (destroy_pointer) call me% destroy()
901
+ else ! by default it is destroyed
902
+ call me% destroy()
903
+ end if
892
904
call me% core% deserialize(me% p, str)
893
905
894
906
end subroutine json_file_load_from_string
0 commit comments