@@ -47,7 +47,7 @@ subroutine read_qcschema(self, unit, error)
4747
4848#if WITH_JSON
4949 class(json_value), allocatable :: root
50- type (json_object), pointer :: object, child
50+ type (json_object), pointer :: object, child, extras, child2
5151 type (json_array), pointer :: array, child_array
5252 type (json_error), allocatable :: parse_error
5353 type (json_keyval), pointer :: val
@@ -58,8 +58,8 @@ subroutine read_qcschema(self, unit, error)
5858 character (len= :), allocatable :: symbol, message, schema_name, comment
5959 character (len= symbol_length), allocatable :: sym(:)
6060 integer , allocatable :: bond(:, :), list(:)
61- real (wp), allocatable , target :: geo(:)
62- real (wp), pointer :: xyz(:, :)
61+ real (wp), allocatable , target :: geo(:), lat(:)
62+ real (wp), pointer :: xyz(:, :), lattice(:, :)
6363
6464 call json_load(root, unit, config= json_parser_config(context_detail= 1 ), &
6565 & context= ctx, error= parse_error)
@@ -222,8 +222,45 @@ subroutine read_qcschema(self, unit, error)
222222 end do
223223 end if
224224
225+ nullify(lattice)
226+ nullify(array)
227+ call get_value(child, " extras" , extras, stat= stat, origin= origin)
228+ if (stat /= json_stat% success) then
229+ call fatal_error(error, ctx% report(" Could not read extras" , origin= origin, &
230+ & label= " Expected object" ))
231+ return
232+ end if
233+ call get_value(extras, " periodic" , child2, requested= .false. , stat= stat, origin= origin)
234+ if (stat /= json_stat% success) then
235+ call fatal_error(error, ctx% report(" Could not read periodic extras" , origin= origin, &
236+ & label= " Expected object with 'lattice' key" ))
237+ return
238+ end if
239+ if (associated (child2)) then
240+ call get_value(child2, " lattice" , array, requested= .false. , stat= stat, origin= origin)
241+ if (stat /= json_stat% success) then
242+ call fatal_error(error, ctx% report(" Could not read lattice from extras" , origin= origin, &
243+ & label= " Expected array with 9 elements" ))
244+ return
245+ end if
246+ end if
247+ if (associated (array)) then
248+ call get_value(array, lat, stat= stat, origin= origin)
249+ if (stat /= json_stat% success) then
250+ call fatal_error(error, ctx% report(" Could not read lattice from extras" , origin= origin, &
251+ & label= " Expected array with 9 elements" ))
252+ return
253+ end if
254+ if (size (lat) /= 9 ) then
255+ call fatal_error(error, ctx% report(" Lattice must have 9 elements" , origin= array% origin, &
256+ & label= " Got " // to_string(size (lat))// " elements" ))
257+ return
258+ end if
259+ lattice(1 :3 , 1 :3 ) = > lat(1 :9 )
260+ end if
261+
225262 xyz(1 :3 , 1 :size (geo)/ 3 ) = > geo
226- call new (self, sym, xyz, charge= real (charge, wp), uhf= multiplicity-1 )
263+ call new (self, sym, xyz, charge= real (charge, wp), uhf= multiplicity-1 , lattice = lattice )
227264 if (len (comment) > 0 ) self% comment = comment
228265 if (allocated (bond)) then
229266 self% nbd = size (bond, 2 )
0 commit comments