@@ -34,7 +34,9 @@ module fplot_plot_data
3434 procedure , public :: set_datablock_name = > pd_set_datablock_name
3535 procedure , public :: create_unique_datablock_name = > &
3636 pd_create_unique_datablock_name
37+ procedure , public :: clean = > pd_clean
3738 procedure (pd_get_string_result), deferred, public :: get_data_string
39+ procedure (pd_clean_action), deferred, public :: clean_data
3840 end type
3941
4042 interface
@@ -46,6 +48,13 @@ function pd_get_string_result(this) result(x)
4648 character (len = :), allocatable :: x
4749 ! ! The string.
4850 end function
51+
52+ subroutine pd_clean_action (this )
53+ ! ! Performs a cleaning operation.
54+ import plot_data
55+ class(plot_data), intent (inout ) :: this
56+ ! ! The plot_data object.
57+ end subroutine
4958 end interface
5059
5160 type, abstract, extends(plot_data) :: plot_data_colored
@@ -241,13 +250,27 @@ subroutine pd_create_unique_datablock_name(this)
241250 real (real64) :: r, rng
242251 integer (int32) :: count
243252
253+ call random_seed ()
244254 call random_number (r)
245255 r = r * huge (count)
246256 count = floor (r)
247257 str = " PlotData" // to_string(count)
248258 call this% set_datablock_name(char (str))
249259 end subroutine
250260
261+ ! ------------------------------------------------------------------------------
262+ subroutine pd_clean (this )
263+ ! ! Cleans the data set by removing stored data and clearing the
264+ ! ! GNUPLOT datablock name. This routine also calls clean_data to
265+ ! ! ensure the data is cleared from the data set as well as the datablock
266+ ! ! name.
267+ class(plot_data), intent (inout ) :: this
268+ ! ! The plot_data object.
269+
270+ call this% set_datablock_name(" " )
271+ call this% clean_data()
272+ end subroutine
273+
251274! ******************************************************************************
252275! PLOT_DATA_COLORED
253276! ------------------------------------------------------------------------------
0 commit comments