15 #include "sll_working_precision.h"
37 sll_int32,
allocatable :: dims(:)
44 sll_real64 :: time = 0.0_f64
67 sll_real64,
intent(in) :: time
75 allocate (self%xml_doc)
78 call self%xml_doc%add_header_line(
"<?xml version='1.0' ?>")
79 call self%xml_doc%add_header_line(
"<!DOCTYPE Xdmf SYSTEM 'Xdmf.dtd' []>")
82 root => self%xml_doc%new_element(
'Xdmf')
83 call root%add_attribute(
'Version',
'2.0')
86 self%xml_domain => root%new_element(
'Domain')
94 character(len=*),
intent(in) :: fname
96 call self%xml_doc%write(fname)
106 self%xml_domain => null()
108 if (
allocated(self%xml_doc))
then
109 call self%xml_doc%delete()
110 deallocate (self%xml_doc)
113 if (
allocated(self%grids))
then
114 deallocate (self%grids)
123 character(len=*),
intent(in) :: grid_name
124 character(len=*),
intent(in) :: x1_path
125 character(len=*),
intent(in) :: x2_path
126 sll_int32,
intent(in) :: dims(2)
127 sll_int32,
intent(out) :: gid
130 character(len=64) :: time_str
131 character(len=:),
allocatable :: dims_str
137 write (time_str,
'(g20.12)') self%time
141 grid => self%xml_domain%new_element(
'Grid')
142 call grid%add_attribute(
'Name', trim(grid_name))
143 call grid%add_attribute(
'GridType',
'Uniform')
146 time => grid%new_element(
'Time')
147 call time%add_attribute(
'Value', trim(adjustl(time_str)))
150 topology => grid%new_element(
'Topology')
151 call topology%add_attribute(
'TopologyType',
'2DSMesh')
152 call topology%add_attribute(
'NumberOfElements', dims_str)
155 geometry => grid%new_element(
'Geometry')
156 call geometry%add_attribute(
'GeometryType',
'X_Y')
159 dataitem => geometry%new_element(
'DataItem')
160 call dataitem%add_attribute(
'Dimensions', dims_str)
161 call dataitem%add_attribute(
'NumberType',
'Float')
162 call dataitem%add_attribute(
'Precision',
'8')
163 call dataitem%add_attribute(
'Format',
'HDF')
164 call dataitem%add_chardata(trim(x1_path))
167 dataitem => geometry%new_element(
'DataItem')
168 call dataitem%add_attribute(
'Dimensions', dims_str)
169 call dataitem%add_attribute(
'NumberType',
'Float')
170 call dataitem%add_attribute(
'Precision',
'8')
171 call dataitem%add_attribute(
'Format',
'HDF')
172 call dataitem%add_chardata(trim(x2_path))
175 if (
allocated(self%grids))
then
176 ng =
size(self%grids)
177 allocate (tmp(ng + 1))
178 tmp(1:ng) = self%grids(1:ng)
185 allocate (tmp(ng + 1)%dims(
size(dims)))
186 tmp(ng + 1)%xml_grid => grid
187 tmp(ng + 1)%dims = dims
188 call move_alloc(from=tmp, to=self%grids)
199 sll_int32,
intent(in) :: grid_id
200 character(len=*),
intent(in) :: field_name
201 character(len=*),
intent(in) :: field_path
203 character(len=:),
allocatable :: dims_str
210 field => self%grids(grid_id)%xml_grid%new_element(
'Attribute')
211 call field%add_attribute(
'Name', trim(field_name))
212 call field%add_attribute(
'AttributeType',
'Scalar')
213 call field%add_attribute(
'Center',
'Node')
216 dataitem => field%new_element(
'DataItem')
217 call dataitem%add_attribute(
'Dimensions', dims_str)
218 call dataitem%add_attribute(
'NumberType',
'Float')
219 call dataitem%add_attribute(
'Precision',
'8')
220 call dataitem%add_attribute(
'Format',
'HDF')
221 call dataitem%add_chardata(trim(adjustl(field_path)))
Collection of functions/subroutines operating on files and strings.
subroutine, public sll_s_ints_to_string(ints, str)
Write an array of integers to a single string: . Numbers are separated by a blank space; ....
Construct the XML component of an XDMF database (sequential).
subroutine t_xdmf__init(self, time)
Initialize XDMF file (set time, allocate storage, store pointer to domain)
subroutine t_xdmf__delete(self)
Delete XDMF file (deallocate storage, nullify pointers)
subroutine t_xdmf__write(self, fname)
Write XML file.
subroutine t_xdmf__add_grid(self, grid_name, x1_path, x2_path, dims, gid)
Add grid to file (new grid ID is returned)
subroutine t_xdmf__add_field(self, grid_id, field_name, field_path)
Add field to grid (selected by its grid ID)
Facilities for constructing an XML tree and printing it to file.