GCC Code Coverage Report


Directory: src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 83.8% 98 / 0 / 117
Functions: 62.5% 5 / 0 / 8
Branches: 41.8% 138 / 0 / 330

diagnostics/m_diagnostics_paraview.F90
Line Branch Exec Source
1 !> @brief Module for ParaView output using VTKFortran (if linked)
2 module m_diagnostics_paraview
3 #include "petsc.fi"
4 use m_common, only: wp
5 #ifdef VTKFORTRAN_IS_LINKED
6 use vtk_fortran
7 #endif
8
9 ! Preprocessor macro for VTK function calls with error checking (similar to PetscCall)
10 ! Automatically handles conditional compilation internally
11 !
12 ! Usage patterns:
13 ! 1. Single line: VTKCall(func(args))
14 ! 2. Multi-line with backslash continuation:
15 ! VTKCall(func(arg1, \
16 ! arg2, \
17 ! arg3))
18 #ifdef VTKFORTRAN_IS_LINKED
19 #define VTKCall(vtk_function_call) \
20 ierr = vtk_function_call; \
21 if (ierr /= 0) error stop "ParaView VTKFortran error code "//trim(int_to_str(ierr))
22 #else
23 #define VTKCall(vtk_function_call)
24 #endif
25
26 use m_mform_basis, only: MFormSpace, MFormFun
27
28 implicit none
29
30 private
31 public :: ParaView
32
33 !> ParaView output handler (wraps around VTKFortran if available, otherwise does nothing)
34 type ParaView
35 integer :: current_file_index = 0
36 character(len=256) :: filename_base
37 logical :: is_initialized = .false.
38 type(MFormSpace) :: space0
39
40 #ifdef VTKFORTRAN_IS_LINKED
41 !> VTK file from VTKFortran
42 type(vtk_file) :: vtkfile
43 #endif
44
45 contains
46 procedure :: init => paraview_init
47 procedure, private :: paraview_write
48 procedure, private :: paraview_write_multiple
49 generic :: write => paraview_write, paraview_write_multiple
50 procedure :: destroy => paraview_destroy
51 ! Private helper methods
52 procedure, private :: write_single_field => paraview_write_single_field
53 end type ParaView
54
55 contains
56
57 #ifdef VTKFORTRAN_IS_LINKED
58 !> Convert integer to string for error messages
59 pure function int_to_str(i) result(int_str)
60 integer, intent(in) :: i
61 character(len=20) :: int_str
62 write (int_str, '(I0)') i
63 end function int_to_str
64 #endif
65
66 !> @brief Initialize ParaView output
67 !>
68 !> @param[in] this ParaView object
69 !> @param[in] filename Base name for output files
70 !> @param[in] space0 The space of 0-forms for which data will be written
71 2 subroutine paraview_init(this, filename, space0)
72 class(ParaView), intent(inout) :: this
73 character(len=*), intent(in) :: filename
74 type(MFormSpace), intent(in) :: space0
75
76 2 this%filename_base = filename
77 2 this%current_file_index = 0
78
5/8
✓ Branch 5 → 6 taken 2 times.
✗ Branch 5 → 9 not taken.
✓ Branch 6 → 7 taken 2 times.
✗ Branch 6 → 8 not taken.
✓ Branch 9 → 10 taken 2 times.
✗ Branch 9 → 12 not taken.
✓ Branch 10 → 11 taken 1 time.
✓ Branch 10 → 12 taken 1 time.
2 this%space0 = space0
79 2 this%is_initialized = .true.
80 #ifndef VTKFORTRAN_IS_LINKED
81 write (*, *) "ParaView::init: VTKFortran not linked, cannot initialize ParaView output."
82 #endif
83
84
1/2
✓ Branch 2 → 3 taken 2 times.
✗ Branch 2 → 4 not taken.
2 end subroutine paraview_init
85
86 !> @brief Write a single field to an already initialized VTK file
87 !>
88 !> @param[in] this ParaView object
89 !> @param[in] mfun The field function to evaluate and write (contains its own name)
90 !> @param[in] nx1, nx2, ny1, ny2, nz1, nz2 Array bounds
91 !> @param[in] xp_coords Logical coordinates for evaluation
92 !> @param[in] yp_coords Logical coordinates for evaluation
93 !> @param[in] zp_coords Logical coordinates for evaluation
94 !> @param[in] coord_transform _(optional)_ The coordinate transformation associated with the m-form
95 8 subroutine paraview_write_single_field(this, mfun, nx1, nx2, ny1, ny2, nz1, nz2, &
96 8 xp_coords, yp_coords, zp_coords, coord_transform)
97 use m_mform, only: evaluate, evaluate_vec
98 use m_coord_transform_abstract, only: CoordTransformAbstract
99
100 class(ParaView), intent(inout) :: this
101 type(MFormFun), intent(in) :: mfun
102 integer, intent(in) :: nx1, nx2, ny1, ny2, nz1, nz2
103 real(wp), intent(in) :: xp_coords(nx1:nx2, ny1:ny2, nz1:nz2)
104 real(wp), intent(in) :: yp_coords(nx1:nx2, ny1:ny2, nz1:nz2)
105 real(wp), intent(in) :: zp_coords(nx1:nx2, ny1:ny2, nz1:nz2)
106 class(CoordTransformAbstract), optional, intent(in) :: coord_transform
107
108 8 real(wp), allocatable :: data_values(:, :, :)
109 8 real(wp), allocatable :: data_values_x(:, :, :), data_values_y(:, :, :), data_values_z(:, :, :)
110
111 integer :: i, j, k, ierr
112 real(wp) :: tmp(3)
113
114
2/2
✓ Branch 2 → 3 taken 4 times.
✓ Branch 2 → 39 taken 4 times.
8 if (mfun%space%m == 0 .or. mfun%space%m == 3) then
115 ! Allocate data for this field
116
10/20
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 4 times.
✓ Branch 5 → 4 taken 4 times.
✗ Branch 5 → 6 not taken.
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 4 times.
✓ Branch 8 → 7 taken 4 times.
✗ Branch 8 → 9 not taken.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 4 times.
✓ Branch 11 → 10 taken 4 times.
✗ Branch 11 → 12 not taken.
✓ Branch 12 → 13 taken 4 times.
✗ Branch 12 → 14 not taken.
✓ Branch 14 → 15 taken 4 times.
✗ Branch 14 → 16 not taken.
✗ Branch 16 → 17 not taken.
✓ Branch 16 → 18 taken 4 times.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 4 times.
20 allocate (data_values(nx1:nx2, ny1:ny2, nz1:nz2))
117
118 ! Evaluate field at all points
119
6/6
✓ Branch 21 → 22 taken 68 times.
✓ Branch 21 → 28 taken 4 times.
✓ Branch 22 → 23 taken 612 times.
✓ Branch 22 → 27 taken 68 times.
✓ Branch 23 → 24 taken 10404 times.
✓ Branch 23 → 25 taken 612 times.
11088 do k = nz1, nz2; do j = ny1, ny2; do i = nx1, nx2
120 data_values(i, j, k) = evaluate(mfun, xp_coords(i, j, k), yp_coords(i, j, k), zp_coords(i, j, k), &
121 11016 coord_transform=coord_transform)
122 end do; end do; end do
123
124 ! Write this field's data to VTK
125
1/4
✗ Branch 29 → 30 not taken.
✓ Branch 29 → 36 taken 4 times.
✗ Branch 33 → 34 not taken.
✗ Branch 33 → 35 not taken.
4 VTKCall(this%vtkfile%xml_writer%write_dataarray(data_name=trim(mfun%name), x=data_values, one_component=.true.))
126
127
1/2
✗ Branch 36 → 37 not taken.
✓ Branch 36 → 38 taken 4 times.
4 deallocate (data_values)
128 else
129 ! Allocate data for vector field
130
10/20
✗ Branch 39 → 40 not taken.
✓ Branch 39 → 41 taken 4 times.
✓ Branch 41 → 40 taken 4 times.
✗ Branch 41 → 42 not taken.
✗ Branch 42 → 43 not taken.
✓ Branch 42 → 44 taken 4 times.
✓ Branch 44 → 43 taken 4 times.
✗ Branch 44 → 45 not taken.
✗ Branch 45 → 46 not taken.
✓ Branch 45 → 47 taken 4 times.
✓ Branch 47 → 46 taken 4 times.
✗ Branch 47 → 48 not taken.
✓ Branch 48 → 49 taken 4 times.
✗ Branch 48 → 50 not taken.
✓ Branch 50 → 51 taken 4 times.
✗ Branch 50 → 52 not taken.
✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 4 times.
✗ Branch 54 → 55 not taken.
✓ Branch 54 → 56 taken 4 times.
20 allocate (data_values_x(nx1:nx2, ny1:ny2, nz1:nz2))
131
8/16
✗ Branch 56 → 57 not taken.
✓ Branch 56 → 58 taken 4 times.
✓ Branch 58 → 57 taken 4 times.
✗ Branch 58 → 59 not taken.
✗ Branch 59 → 60 not taken.
✓ Branch 59 → 61 taken 4 times.
✓ Branch 61 → 60 taken 4 times.
✗ Branch 61 → 62 not taken.
✗ Branch 62 → 63 not taken.
✓ Branch 62 → 64 taken 4 times.
✓ Branch 64 → 63 taken 4 times.
✗ Branch 64 → 65 not taken.
✗ Branch 65 → 66 not taken.
✓ Branch 65 → 67 taken 4 times.
✗ Branch 67 → 68 not taken.
✓ Branch 67 → 69 taken 4 times.
16 allocate (data_values_y(nx1:nx2, ny1:ny2, nz1:nz2))
132
8/16
✗ Branch 69 → 70 not taken.
✓ Branch 69 → 71 taken 4 times.
✓ Branch 71 → 70 taken 4 times.
✗ Branch 71 → 72 not taken.
✗ Branch 72 → 73 not taken.
✓ Branch 72 → 74 taken 4 times.
✓ Branch 74 → 73 taken 4 times.
✗ Branch 74 → 75 not taken.
✗ Branch 75 → 76 not taken.
✓ Branch 75 → 77 taken 4 times.
✓ Branch 77 → 76 taken 4 times.
✗ Branch 77 → 78 not taken.
✗ Branch 78 → 79 not taken.
✓ Branch 78 → 80 taken 4 times.
✗ Branch 80 → 81 not taken.
✓ Branch 80 → 82 taken 4 times.
16 allocate (data_values_z(nx1:nx2, ny1:ny2, nz1:nz2))
133
134
6/6
✓ Branch 83 → 84 taken 68 times.
✓ Branch 83 → 91 taken 4 times.
✓ Branch 84 → 85 taken 612 times.
✓ Branch 84 → 90 taken 68 times.
✓ Branch 85 → 86 taken 10404 times.
✓ Branch 85 → 88 taken 612 times.
11088 do k = nz1, nz2; do j = ny1, ny2; do i = nx1, nx2
135 10404 call evaluate_vec(tmp, mfun, xp_coords(i, j, k), yp_coords(i, j, k), zp_coords(i, j, k), coord_transform=coord_transform)
136 10404 data_values_x(i, j, k) = tmp(1)
137 10404 data_values_y(i, j, k) = tmp(2)
138 11016 data_values_z(i, j, k) = tmp(3)
139 end do; end do; end do
140
141 ! Write vector field to VTK
142
1/4
✗ Branch 92 → 93 not taken.
✓ Branch 92 → 99 taken 4 times.
✗ Branch 96 → 97 not taken.
✗ Branch 96 → 98 not taken.
4 VTKCall(this%vtkfile%xml_writer%write_dataarray(data_name=trim(mfun%name), \
143 x = data_values_x, y = data_values_y, z = data_values_z))
144
145
3/6
✗ Branch 99 → 100 not taken.
✓ Branch 99 → 101 taken 4 times.
✗ Branch 101 → 102 not taken.
✓ Branch 101 → 103 taken 4 times.
✗ Branch 103 → 104 not taken.
✓ Branch 103 → 105 taken 4 times.
4 deallocate (data_values_x, data_values_y, data_values_z)
146 end if
147
148
4/8
✗ Branch 106 → 107 not taken.
✓ Branch 106 → 108 taken 8 times.
✗ Branch 108 → 109 not taken.
✓ Branch 108 → 110 taken 8 times.
✗ Branch 110 → 111 not taken.
✓ Branch 110 → 112 taken 8 times.
✗ Branch 112 → 113 not taken.
✓ Branch 112 → 114 taken 8 times.
8 end subroutine paraview_write_single_field
149
150 !> @brief Write m-form data to a new VTK file
151 !>
152 !> @param[in] this ParaView object
153 !> @param[in] mfun The m-form function to evaluate and write to file
154 !> @param[in] coord_transform _(optional)_ The coordinate transformation associated with the m-form
155 !> @param[in] time _(optional)_ time value to include in output
156 !> @param[in] refine _(optional)_ refinement level in all directions (overrides per direction) for output
157 !> @param[in] refine_x _(optional)_ refinement level in the x-direction for output
158 !> @param[in] refine_y _(optional)_ refinement level in the y-direction for output
159 !> @param[in] refine_z _(optional)_ refinement level in the z-direction for output
160 4 subroutine paraview_write(this, mfun, coord_transform, time, refine, refine_x, refine_y, refine_z)
161 use m_mform, only: get_coords
162 use m_coord_transform_abstract, only: CoordTransformAbstract
163
164 class(ParaView), intent(inout) :: this
165 type(MFormFun), intent(in) :: mfun
166 class(CoordTransformAbstract), optional, intent(in) :: coord_transform
167 real(wp), intent(in), optional :: time
168 integer, intent(in), optional :: refine, refine_x, refine_y, refine_z
169
170 integer :: ierr
171 character(len=256) :: filename
172 4 real(wp), allocatable :: x_coords(:, :, :), y_coords(:, :, :), z_coords(:, :, :)
173 4 real(wp), allocatable :: xp_coords(:, :, :), yp_coords(:, :, :), zp_coords(:, :, :)
174 integer :: nx1, nx2, ny1, ny2, nz1, nz2, sze_tmp
175
176 integer :: refine_x_, refine_y_, refine_z_
177
178
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 4 times.
4 if (.not. this%is_initialized) error stop "ParaView::paraview_write: object not initialized."
179
180
1/2
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 4 times.
4 if (present(refine)) then
181 refine_x_ = refine
182 refine_y_ = refine
183 refine_z_ = refine
184 else
185
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 4 times.
4 if (present(refine_x)) then
186 refine_x_ = refine_x
187 else
188 4 refine_x_ = 0
189 end if
190
1/2
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 4 times.
4 if (present(refine_y)) then
191 refine_y_ = refine_y
192 else
193 4 refine_y_ = 0
194 end if
195
1/2
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 4 times.
4 if (present(refine_z)) then
196 refine_z_ = refine_z
197 else
198 4 refine_z_ = 0
199 end if
200 end if
201
202 4 write (filename, '(A,I5.5,A)') trim(this%filename_base), this%current_file_index, '.vtu'
203
204
1/2
✓ Branch 20 → 21 taken 4 times.
✗ Branch 20 → 110 not taken.
4 if (mfun%tp_funs(1)%shmem_window%leader()) then
205 ! Get coordinates
206 call get_coords(this%space0, x_coords, y_coords, z_coords, &
207 4 refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, coord_transform=coord_transform, node_based=.true.)
208 call get_coords(this%space0, xp_coords, yp_coords, zp_coords, &
209 4 refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, node_based=.true.)
210
211
2/4
✓ Branch 23 → 24 taken 4 times.
✗ Branch 23 → 25 not taken.
✓ Branch 25 → 26 taken 4 times.
✗ Branch 25 → 27 not taken.
8 nx1 = lbound(x_coords, 1); nx2 = ubound(x_coords, 1)
212
2/4
✓ Branch 27 → 28 taken 4 times.
✗ Branch 27 → 29 not taken.
✓ Branch 29 → 30 taken 4 times.
✗ Branch 29 → 31 not taken.
8 ny1 = lbound(x_coords, 2); ny2 = ubound(x_coords, 2)
213
2/4
✓ Branch 31 → 32 taken 4 times.
✗ Branch 31 → 33 not taken.
✓ Branch 33 → 34 taken 4 times.
✗ Branch 33 → 35 not taken.
8 nz1 = lbound(x_coords, 3); nz2 = ubound(x_coords, 3)
214
215
1/2
✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 4 times.
4 if (mfun%space%dimensionality == 2) then
216 nz2 = nz1 ! For 2D spaces, only one layer in z-direction
217 refine_z_ = 0
218 end if
219
220 ! Initialize VTK file
221
1/4
✗ Branch 38 → 39 not taken.
✓ Branch 38 → 45 taken 4 times.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 44 not taken.
4 VTKCall(this%vtkfile%initialize(format='BINARY', \
222 filename = trim(filename), \
223 mesh_topology = 'StructuredGrid', \
224 is_volatile = .false., \
225 nx1 = nx1, nx2 = nx2, \
226 ny1 = ny1, ny2 = ny2, \
227 nz1 = nz1, nz2 = nz2))
228
229 ! Write geometry and open dataarray section
230
1/4
✗ Branch 46 → 47 not taken.
✓ Branch 46 → 54 taken 4 times.
✗ Branch 50 → 51 not taken.
✗ Branch 50 → 52 not taken.
4 VTKCall(this%vtkfile%xml_writer%write_piece(nx1=nx1, nx2=nx2, ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2))
231
2/2
✓ Branch 54 → 53 taken 12 times.
✓ Branch 54 → 55 taken 4 times.
16 sze_tmp = size(x_coords) ! NOTE: this is a workaround to avoid a NVHPC compiler bug:
232 ! https://forums.developer.nvidia.com/t/compiler-bug-allocatable-polymorphic-types-with-tbps-acting-on-allocatable-array
233
1/4
✗ Branch 56 → 57 not taken.
✓ Branch 56 → 63 taken 4 times.
✗ Branch 60 → 61 not taken.
✗ Branch 60 → 62 not taken.
4 VTKCall(this%vtkfile%xml_writer%write_geo(n=sze_tmp, x=x_coords, y=y_coords, z=z_coords))
234
1/4
✗ Branch 64 → 65 not taken.
✓ Branch 64 → 71 taken 4 times.
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 70 not taken.
4 VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='open'))
235
236 ! Write single field using helper method
237 call this%write_single_field(mfun, nx1, nx2, ny1, ny2, nz1, nz2, &
238 4 xp_coords, yp_coords, zp_coords, coord_transform=coord_transform)
239
240 ! Close dataarray section and finalize
241
1/4
✗ Branch 73 → 74 not taken.
✓ Branch 73 → 80 taken 4 times.
✗ Branch 77 → 78 not taken.
✗ Branch 77 → 79 not taken.
4 VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='close'))
242
1/4
✗ Branch 81 → 82 not taken.
✓ Branch 81 → 88 taken 4 times.
✗ Branch 85 → 86 not taken.
✗ Branch 85 → 87 not taken.
4 VTKCall(this%vtkfile%xml_writer%write_piece())
243
1/4
✗ Branch 89 → 90 not taken.
✓ Branch 89 → 96 taken 4 times.
✗ Branch 93 → 94 not taken.
✗ Branch 93 → 95 not taken.
4 VTKCall(this%vtkfile%finalize())
244
245 #ifdef VTKFORTRAN_IS_LINKED
246 4 call this%vtkfile%free()
247 #endif
248
249
3/6
✗ Branch 97 → 98 not taken.
✓ Branch 97 → 99 taken 4 times.
✗ Branch 99 → 100 not taken.
✓ Branch 99 → 101 taken 4 times.
✗ Branch 101 → 102 not taken.
✓ Branch 101 → 103 taken 4 times.
4 deallocate (x_coords, y_coords, z_coords)
250
3/6
✗ Branch 103 → 104 not taken.
✓ Branch 103 → 105 taken 4 times.
✗ Branch 105 → 106 not taken.
✓ Branch 105 → 107 taken 4 times.
✗ Branch 107 → 108 not taken.
✓ Branch 107 → 109 taken 4 times.
4 deallocate (xp_coords, yp_coords, zp_coords)
251 end if
252
253
1/2
✗ Branch 111 → 112 not taken.
✓ Branch 111 → 115 taken 4 times.
4 PetscCallMPI(MPI_Barrier(this%space0%tp_spaces(1)%domain%comm, ierr))
254
255 4 this%current_file_index = this%current_file_index + 1
256
6/24
✗ Branch 113 → 114 not taken.
✗ Branch 113 → 127 not taken.
✗ Branch 115 → 116 not taken.
✓ Branch 115 → 117 taken 4 times.
✗ Branch 117 → 118 not taken.
✓ Branch 117 → 119 taken 4 times.
✗ Branch 119 → 120 not taken.
✓ Branch 119 → 121 taken 4 times.
✗ Branch 121 → 122 not taken.
✓ Branch 121 → 123 taken 4 times.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 4 times.
✗ Branch 125 → 126 not taken.
✓ Branch 125 → 148 taken 4 times.
✗ Branch 129 → 130 not taken.
✗ Branch 129 → 131 not taken.
✗ Branch 133 → 134 not taken.
✗ Branch 133 → 135 not taken.
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 139 not taken.
✗ Branch 141 → 142 not taken.
✗ Branch 141 → 143 not taken.
✗ Branch 145 → 146 not taken.
✗ Branch 145 → 149 not taken.
4 end subroutine paraview_write
257
258 !> @brief Write multiple fields to a new VTK file
259 !>
260 !> @param[in] this ParaView object
261 !> @param[in] mfuns Array of m-form functions to evaluate and write to file
262 !> @param[in] coord_transform _(optional)_ The coordinate transformation associated with the m-forms
263 !> @param[in] time _(optional)_ time value to include in output
264 !> @param[in] refine _(optional)_ refinement level in all directions (overrides per direction) for output
265 !> @param[in] refine_x _(optional)_ refinement level in the x-direction for output
266 !> @param[in] refine_y _(optional)_ refinement level in the y-direction for output
267 !> @param[in] refine_z _(optional)_ refinement level in the z-direction for output
268
1/2
✗ Branch 2 → 3 not taken.
✓ Branch 2 → 4 taken 1 time.
1 subroutine paraview_write_multiple(this, mfuns, coord_transform, time, refine, refine_x, refine_y, refine_z)
269 use m_mform, only: get_coords
270 use m_coord_transform_abstract, only: CoordTransformAbstract
271
272 class(ParaView), intent(inout) :: this
273 type(MFormFun), intent(in) :: mfuns(:) ! Multiple fields (e.g., E-field, B-field)
274 class(CoordTransformAbstract), optional, intent(in) :: coord_transform
275 real(wp), intent(in), optional :: time
276 integer, intent(in), optional :: refine, refine_x, refine_y, refine_z
277
278 integer :: ierr, field_idx
279 character(len=256) :: filename
280 1 real(wp), allocatable :: x_coords(:, :, :), y_coords(:, :, :), z_coords(:, :, :)
281 1 real(wp), allocatable :: xp_coords(:, :, :), yp_coords(:, :, :), zp_coords(:, :, :)
282 integer :: nx1, nx2, ny1, ny2, nz1, nz2, sze_tmp
283
284 integer :: refine_x_, refine_y_, refine_z_
285
286
1/2
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 1 time.
1 if (.not. this%is_initialized) error stop "ParaView::paraview_write_multiple: object not initialized."
287
288
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 1 time.
1 if (present(refine)) then
289 refine_x_ = refine
290 refine_y_ = refine
291 refine_z_ = refine
292 else
293
1/2
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 1 time.
1 if (present(refine_x)) then
294 refine_x_ = refine_x
295 else
296 1 refine_x_ = 0
297 end if
298
1/2
✗ Branch 11 → 12 not taken.
✓ Branch 11 → 13 taken 1 time.
1 if (present(refine_y)) then
299 refine_y_ = refine_y
300 else
301 1 refine_y_ = 0
302 end if
303
1/2
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 16 taken 1 time.
1 if (present(refine_z)) then
304 refine_z_ = refine_z
305 else
306 1 refine_z_ = 0
307 end if
308 end if
309
310
1/2
✓ Branch 17 → 18 taken 1 time.
✗ Branch 17 → 114 not taken.
1 if (mfuns(1)%tp_funs(1)%shmem_window%leader()) then
311
312 1 write (filename, '(A,I5.5,A)') trim(this%filename_base), this%current_file_index, '.vtu'
313
314 ! Get coordinates once (geometry is shared by all fields)
315 call get_coords(this%space0, x_coords, y_coords, z_coords, &
316 1 refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, coord_transform=coord_transform, node_based=.true.)
317 call get_coords(this%space0, xp_coords, yp_coords, zp_coords, &
318 1 refine_x=refine_x_, refine_y=refine_y_, refine_z=refine_z_, node_based=.true.)
319
320
2/4
✓ Branch 25 → 26 taken 1 time.
✗ Branch 25 → 27 not taken.
✓ Branch 27 → 28 taken 1 time.
✗ Branch 27 → 29 not taken.
2 nx1 = lbound(x_coords, 1); nx2 = ubound(x_coords, 1)
321
2/4
✓ Branch 29 → 30 taken 1 time.
✗ Branch 29 → 31 not taken.
✓ Branch 31 → 32 taken 1 time.
✗ Branch 31 → 33 not taken.
2 ny1 = lbound(x_coords, 2); ny2 = ubound(x_coords, 2)
322
2/4
✓ Branch 33 → 34 taken 1 time.
✗ Branch 33 → 35 not taken.
✓ Branch 35 → 36 taken 1 time.
✗ Branch 35 → 37 not taken.
2 nz1 = lbound(x_coords, 3); nz2 = ubound(x_coords, 3)
323
324 ! Initialize VTK file once
325
1/4
✗ Branch 38 → 39 not taken.
✓ Branch 38 → 45 taken 1 time.
✗ Branch 42 → 43 not taken.
✗ Branch 42 → 44 not taken.
1 VTKCall(this%vtkfile%initialize(format='BINARY', \
326 filename = trim(filename), \
327 mesh_topology = 'StructuredGrid', \
328 is_volatile = .false., \
329 nx1 = nx1, nx2 = nx2, \
330 ny1 = ny1, ny2 = ny2, \
331 nz1 = nz1, nz2 = nz2))
332
333 ! Write geometry once
334
1/4
✗ Branch 46 → 47 not taken.
✓ Branch 46 → 54 taken 1 time.
✗ Branch 50 → 51 not taken.
✗ Branch 50 → 52 not taken.
1 VTKCall(this%vtkfile%xml_writer%write_piece(nx1=nx1, nx2=nx2, ny1=ny1, ny2=ny2, nz1=nz1, nz2=nz2))
335
2/2
✓ Branch 54 → 53 taken 3 times.
✓ Branch 54 → 55 taken 1 time.
4 sze_tmp = size(x_coords)
336
1/4
✗ Branch 56 → 57 not taken.
✓ Branch 56 → 63 taken 1 time.
✗ Branch 60 → 61 not taken.
✗ Branch 60 → 62 not taken.
1 VTKCall(this%vtkfile%xml_writer%write_geo(n=sze_tmp, x=x_coords, y=y_coords, z=z_coords))
337
338 ! Open dataarray section
339
1/4
✗ Branch 64 → 65 not taken.
✓ Branch 64 → 71 taken 1 time.
✗ Branch 68 → 69 not taken.
✗ Branch 68 → 70 not taken.
1 VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='open'))
340
341 ! Write all fields using helper method
342
2/2
✓ Branch 72 → 73 taken 4 times.
✓ Branch 72 → 75 taken 1 time.
5 do field_idx = 1, size(mfuns)
343 ! Write this field using helper method (uses mfun%name internally)
344 call this%write_single_field(mfuns(field_idx), &
345 nx1, nx2, ny1, ny2, nz1, nz2, &
346 5 xp_coords, yp_coords, zp_coords, coord_transform=coord_transform)
347 end do
348
349 ! Close dataarray section and finalize
350
1/4
✗ Branch 77 → 78 not taken.
✓ Branch 77 → 84 taken 1 time.
✗ Branch 81 → 82 not taken.
✗ Branch 81 → 83 not taken.
1 VTKCall(this%vtkfile%xml_writer%write_dataarray(location='node', action='close'))
351
1/4
✗ Branch 85 → 86 not taken.
✓ Branch 85 → 92 taken 1 time.
✗ Branch 89 → 90 not taken.
✗ Branch 89 → 91 not taken.
1 VTKCall(this%vtkfile%xml_writer%write_piece())
352
1/4
✗ Branch 93 → 94 not taken.
✓ Branch 93 → 100 taken 1 time.
✗ Branch 97 → 98 not taken.
✗ Branch 97 → 99 not taken.
1 VTKCall(this%vtkfile%finalize())
353
354 #ifdef VTKFORTRAN_IS_LINKED
355 1 call this%vtkfile%free()
356 #endif
357
358
3/6
✗ Branch 101 → 102 not taken.
✓ Branch 101 → 103 taken 1 time.
✗ Branch 103 → 104 not taken.
✓ Branch 103 → 105 taken 1 time.
✗ Branch 105 → 106 not taken.
✓ Branch 105 → 107 taken 1 time.
1 deallocate (x_coords, y_coords, z_coords)
359
3/6
✗ Branch 107 → 108 not taken.
✓ Branch 107 → 109 taken 1 time.
✗ Branch 109 → 110 not taken.
✓ Branch 109 → 111 taken 1 time.
✗ Branch 111 → 112 not taken.
✓ Branch 111 → 113 taken 1 time.
1 deallocate (xp_coords, yp_coords, zp_coords)
360 end if
361
362
1/2
✗ Branch 115 → 116 not taken.
✓ Branch 115 → 119 taken 1 time.
1 PetscCallMPI(MPI_Barrier(this%space0%tp_spaces(1)%domain%comm, ierr))
363
364 1 this%current_file_index = this%current_file_index + 1
365
6/24
✗ Branch 117 → 118 not taken.
✗ Branch 117 → 131 not taken.
✗ Branch 119 → 120 not taken.
✓ Branch 119 → 121 taken 1 time.
✗ Branch 121 → 122 not taken.
✓ Branch 121 → 123 taken 1 time.
✗ Branch 123 → 124 not taken.
✓ Branch 123 → 125 taken 1 time.
✗ Branch 125 → 126 not taken.
✓ Branch 125 → 127 taken 1 time.
✗ Branch 127 → 128 not taken.
✓ Branch 127 → 129 taken 1 time.
✗ Branch 129 → 130 not taken.
✓ Branch 129 → 152 taken 1 time.
✗ Branch 133 → 134 not taken.
✗ Branch 133 → 135 not taken.
✗ Branch 137 → 138 not taken.
✗ Branch 137 → 139 not taken.
✗ Branch 141 → 142 not taken.
✗ Branch 141 → 143 not taken.
✗ Branch 145 → 146 not taken.
✗ Branch 145 → 147 not taken.
✗ Branch 149 → 150 not taken.
✗ Branch 149 → 153 not taken.
1 end subroutine paraview_write_multiple
366
367 2 subroutine paraview_destroy(this)
368 class(ParaView), intent(inout) :: this
369
370 integer :: ierr
371
372 2 this%is_initialized = .false.
373 2 end subroutine paraview_destroy
374
375 end module m_diagnostics_paraview
376