35 subroutine vtk_ini_xml(vtkf, filename, vtk_type)
36 type(
vtk_t),
intent(out) :: vtkf
37 character(len=*),
intent(in) :: filename, vtk_type
40 open(newunit=vtkf%funit, file=trim(filename), form=
'UNFORMATTED', &
41 access=
'STREAM', status=
'REPLACE')
42 open(newunit=vtkf%sunit, form=
'UNFORMATTED', &
43 access=
'STREAM', status=
'SCRATCH')
45 vtkf%filename = filename
50 write(vtkf%funit)
'<?xml version="1.0"?>' // endl
51 write(vtkf%funit)
'<VTKFile type="' // trim(vtk_type) // &
52 '" version="0.1" byte_order="LittleEndian">' // endl
53 vtkf%indent = vtkf%indent + indent_spaces
56 subroutine vtk_unstr_geo_xml(vtkf, coords, n_nodes, n_cells, n_dim, cycl, time)
57 type(
vtk_t),
intent(inout) :: vtkf
58 real(dp),
intent(in) :: coords(:), time
59 real(sp),
allocatable :: wr_coords(:)
60 integer,
intent(in) :: n_nodes, n_cells, n_dim, cycl
61 character(len=buf_len) :: bufstr
64 if (n_dim < 1 .or. n_dim > 3) stop
"n_dim should be between 1-3"
67 allocate(wr_coords(3 * n_nodes))
70 call vtk_dat_xml(vtkf,
"FieldData", .true.)
71 write(vtkf%funit) repeat(
' ',vtkf%indent) //
'<DataArray type="Float64"'// &
72 ' Name="TIME" NumberOfTuples="1" format="ascii">' // endl
73 vtkf%indent = vtkf%indent + indent_spaces
74 write(bufstr, *) repeat(
' ',vtkf%indent), time
75 write(vtkf%funit) trim(bufstr) // endl
76 call vtk_dat_xml(vtkf,
"DataArray", .false.)
77 write(vtkf%funit) repeat(
' ',vtkf%indent) //
'<DataArray type="Int32"'// &
78 ' Name="CYCLE" NumberOfTuples="1" format="ascii">' // endl
79 vtkf%indent = vtkf%indent + indent_spaces
80 write(bufstr, *) repeat(
' ',vtkf%indent), cycl
81 write(vtkf%funit) trim(bufstr) // endl
82 call vtk_dat_xml(vtkf,
"DataArray", .false.)
83 call vtk_dat_xml(vtkf,
"FieldData", .false.)
86 wr_coords(d::3) = real(coords(d::n_dim), sp)
89 write(bufstr, fmt=
"(A,I0,A,I0,A)") repeat(
' ',vtkf%indent) // &
90 '<Piece NumberOfPoints="', n_nodes,
'" NumberOfCells="', n_cells,
'">'
91 write(vtkf%funit) trim(bufstr) // endl
92 vtkf%indent = vtkf%indent + indent_spaces
94 call vtk_dat_xml(vtkf,
"Points", .true.)
96 write(bufstr, fmt=
"(A,I0,A,I0,A)") repeat(
' ',vtkf%indent) // &
97 '<DataArray type="Float32" NumberOfComponents="3" Name="Points"' // &
98 ' format="appended" offset="', vtkf%offset,
'"/>'
99 write(vtkf%funit) trim(bufstr) // endl
102 n_bytes = 3 * n_nodes * bytes_r4
103 vtkf%offset = vtkf%offset + bytes_i4 + n_bytes
104 write(vtkf%sunit) n_bytes, wr_coords
106 call vtk_dat_xml(vtkf,
"Points", .false.)
114 subroutine vtk_unstr_con_xml(vtkf, connects, offsets, cell_types, n_cells)
115 type(
vtk_t),
intent(inout) :: vtkf
116 integer,
intent(IN) :: n_cells
117 integer,
intent(IN) :: connects(:)
118 integer,
intent(IN) :: offsets(:)
119 integer,
intent(IN) :: cell_types(:)
120 character(len=buf_len) :: bufstr
123 call vtk_dat_xml(vtkf,
"Cells", .true.)
125 write(bufstr, fmt=
"(A,I0,A)") repeat(
' ',vtkf%indent) // &
126 '<DataArray type="Int32" Name="connectivity" format="appended" offset="', &
128 write(vtkf%funit) trim(bufstr) // endl
130 n_bytes = offsets(n_cells) * bytes_i4
131 vtkf%offset = vtkf%offset + bytes_i4 + n_bytes
132 write(vtkf%sunit) n_bytes, connects
134 write(bufstr, fmt=
"(A,I0,A)") repeat(
' ',vtkf%indent) // &
135 '<DataArray type="Int32" Name="offsets" format="appended" offset="', &
137 write(vtkf%funit) trim(bufstr) // endl
139 n_bytes = n_cells * bytes_i4
140 vtkf%offset = vtkf%offset + bytes_i4 + n_bytes
141 write(vtkf%sunit) n_bytes, offsets
143 write(bufstr, fmt=
"(A,I0,A)") repeat(
' ',vtkf%indent) // &
144 '<DataArray type="Int32" Name="types" format="appended" offset="', &
146 write(vtkf%funit) trim(bufstr) // endl
148 n_bytes = n_cells * bytes_i4
149 vtkf%offset = vtkf%offset + bytes_i4 + n_bytes
150 write(vtkf%sunit) n_bytes, cell_types
152 call vtk_dat_xml(vtkf,
"Cells", .false.)
171 subroutine vtk_var_r8_xml(vtkf, varname, var, n_data)
172 type(
vtk_t),
intent(inout) :: vtkf
173 integer,
intent(IN) :: n_data
174 character(*),
intent(IN) :: varname
175 real(dp),
intent(IN) :: var(:)
176 character(len=buf_len) :: bufstr
179 write(bufstr, fmt=
"(A,I0,A)") repeat(
' ',vtkf%indent) // &
180 '<DataArray type="Float64" Name="' // trim(varname) // &
181 '" NumberOfComponents="1" format="appended" offset="', &
183 write(vtkf%funit) trim(bufstr) // endl
184 n_bytes = n_data * bytes_r8
185 vtkf%offset = vtkf%offset + bytes_i4 + n_bytes
186 write(vtkf%sunit) n_bytes, var