This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
collections_data.f90
779 lines (684 loc) · 26.4 KB
/
collections_data.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
! collections_data.f90
submodule (collections) collections_data
use fcore_constants
contains
! ------------------------------------------------------------------------------
module subroutine dt_clear(this)
! Arguments
class(data_table), intent(inout) :: this
! Local Variables
integer(int32) :: i, j
! Quick Return
if (.not.allocated(this%m_table)) return
! Process
do j = 1, size(this%m_table, 2)
do i = 1, size(this%m_table, 1)
if (associated(this%m_table(i,j)%item)) then
deallocate(this%m_table(i,j)%item)
end if
end do
end do
deallocate(this%m_table)
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_final(this)
type(data_table), intent(inout) :: this
call this%clear()
end subroutine
! ------------------------------------------------------------------------------
pure module function dt_get_row_count(this) result(rst)
class(data_table), intent(in) :: this
integer(int32) :: rst
if (allocated(this%m_table)) then
rst = size(this%m_table, 1)
else
rst = 0
end if
end function
! ------------------------------------------------------------------------------
pure module function dt_get_column_count(this) result(rst)
class(data_table), intent(in) :: this
integer(int32) :: rst
if (allocated(this%m_table)) then
rst = size(this%m_table, 2)
else
rst = 0
end if
end function
! ------------------------------------------------------------------------------
module subroutine dt_initialize(this, m, n, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: m, n
class(errors), intent(inout), optional, target :: err
! Local Variables
integer(int32) :: flag
class(errors), pointer :: errmgr
type(errors), target :: deferr
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Check the inputs
if (m <= 0) then
call errmgr%report_error("dt_initialize", "The number of " // &
"rows must be a positive integer.", FCORE_INVALID_INPUT_ERROR)
return
end if
if (n <= 0) then
call errmgr%report_error("dt_initialize", "The number of " // &
"columns must be a positive integer.", &
FCORE_INVALID_INPUT_ERROR)
return
end if
! Clear the contents
call this%clear()
! Process
allocate(this%m_table(m, n), stat = flag)
if (flag /= 0) then
call errmgr%report_error("dt_initialize", "There is " // &
"insufficient memory available for this operation.", &
FCORE_OUT_OF_MEMORY_ERROR)
return
end if
end subroutine
! ------------------------------------------------------------------------------
module function dt_get(this, i, j, err) result(rst)
! Arguments
class(data_table), intent(in) :: this
integer(int32) :: i, j
class(errors), intent(inout), optional, target :: err
class(*), pointer :: rst
! Local Variables
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Quick Return
if (.not.allocated(this%m_table)) then
nullify(rst)
return
end if
! Bounds Checking
if (i <= 0 .or. i > size(this%m_table, 1)) then
write(errmsg, '(AI0AI0A)') "Row index outside the bounds " // &
"of the array. Found: ", i, ", but must lie between 1 and ", &
size(this%m_table, 1), "."
call errmgr%report_error("dt_get", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (j <= 0 .or. j > size(this%m_table, 2)) then
write(errmsg, '(AI0AI0A)') "Column index outside the bounds " // &
"of the array. Found: ", j, ", but must lie between 1 and ", &
size(this%m_table, 2), "."
call errmgr%report_error("dt_get", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
! Process
rst => this%m_table(i,j)%item
end function
! --------------------
module subroutine dt_set(this, i, j, x, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: i, j
class(*), intent(in) :: x
class(errors), intent(inout), optional, target :: err
! Local Variables
integer(int32) :: flag
class(*), pointer :: cpy
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Ensure we've got an array to work with
if (.not.allocated(this%m_table)) then
call errmgr%report_error("dt_set", "The data table has not " // &
"yet been initialized.", FCORE_NULL_REFERENCE_ERROR)
return
end if
! Bounds Checking
if (i <= 0 .or. i > size(this%m_table, 1)) then
write(errmsg, '(AI0AI0A)') "Row index outside the bounds " // &
"of the array. Found: ", i, ", but must lie between 1 and ", &
size(this%m_table, 1), "."
call errmgr%report_error("dt_set", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (j <= 0 .or. j > size(this%m_table, 2)) then
write(errmsg, '(AI0AI0A)') "Column index outside the bounds " // &
"of the array. Found: ", j, ", but must lie between 1 and ", &
size(this%m_table, 2), "."
call errmgr%report_error("dt_set", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
! Clear the existing item, and store the new item
if (associated(this%m_table(i,j)%item)) then
deallocate(this%m_table(i,j)%item)
end if
allocate(cpy, source = x, stat = flag)
if (flag /= 0) then
call errmgr%report_error("dt_set", &
"Insufficient memory available.", FCORE_OUT_OF_MEMORY_ERROR)
return
end if
this%m_table(i, j)%item => cpy
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_insert_rows(this, rstart, x, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: rstart
class(*), intent(in), dimension(:,:) :: x
class(errors), intent(inout), optional, target :: err
! Local Variables
integer(int32) :: i, j, k, mnew, m, n, flag
type(container), allocatable, dimension(:,:) :: copy
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Initialization
m = this%get_row_count()
n = this%get_column_count()
mnew = m + size(x, 1)
! Input Check
if (rstart < 1) then
call errmgr%report_error("dt_insert_rows", &
"The insertion index must be at least 1.", &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (rstart > 1 + m) then
write(errmsg, '(AI0AI0A)') "The insertion index must not be " // &
"greater than ", m + 1, ", but was found to be ", rstart, "."
call errmgr%report_error("dt_insert_rows", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (allocated(this%m_table) .and. size(x, 2) /= n) then
write(errmsg, '(AI0AI0A)') "The input data set was expected " // &
"to have ", n, " columns, but was found to have ", &
size(x, 2), "."
call errmgr%report_error("dt_insert_rows", trim(errmsg), &
FCORE_ARRAY_SIZE_ERROR)
return
end if
! If the array is not allocated, allocate and store as the input array
! will define the table structure
if (.not.allocated(this%m_table)) then
call this%initialize(size(x, 1), size(x, 2), err = errmgr)
if (errmgr%has_error_occurred()) return
do j = 1, size(x, 2)
do i = 1, size(x, 1)
call this%set(i, j, x(i,j), err = errmgr)
if (errmgr%has_error_occurred()) return
end do
end do
return
end if
! If we're here, there was already a properly allocated matrix, and the
! size of X is OK. Start by copying m_table, and then reallocate
! m_table to allow fitting of the new data
allocate(copy(m, n), stat = flag)
if (flag /= 0) go to 100
copy = this%m_table
deallocate(this%m_table)
allocate(this%m_table(mnew, n), stat = flag)
if (flag /= 0) then
! Put copy back to m_table, and then handle the error
this%m_table = copy
go to 100
end if
! Copy back the contents into m_table
do j = 1, n
do i = 1, rstart - 1
this%m_table(i, j) = copy(i, j)
end do
k = rstart
do i = 1, size(x, 1)
call this%set(k, j, x(i, j), err = errmgr)
if (errmgr%has_error_occurred()) return
k = k + 1
end do
do i = rstart, m
this%m_table(k, j) = copy(i, j)
k = k + 1
end do
end do
return
100 continue
! Deal with memory errors
call errmgr%report_error("dt_insert_rows", &
"Insufficient memory available.", FCORE_OUT_OF_MEMORY_ERROR)
return
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_insert_row(this, i, x, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: i
class(*), intent(in), dimension(:) :: x
class(errors), intent(inout), optional, target :: err
! Local Variables
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Check the length of x
if (allocated(this%m_table) .and. &
size(x) /= this%get_column_count()) &
then
write(errmsg, '(AI0AI0A)') "The number of items in the array " // &
"to insert ,", size(x), ", must match the number of " // &
"columns in the table ", this%get_column_count(), "."
call errmgr%report_error("dt_insert_row", trim(errmsg), &
FCORE_ARRAY_SIZE_ERROR)
return
end if
! Insert the array
call this%insert_rows(i, reshape(x, [1, size(x)]), err = errmgr)
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_insert_columns(this, cstart, x, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: cstart
class(*), intent(in), dimension(:,:) :: x
class(errors), intent(inout), optional, target :: err
! Local Variables
integer(int32) :: i, j, k, m, n, nnew, flag
type(container), allocatable, dimension(:,:) :: copy
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Initialization
m = this%get_row_count()
n = this%get_column_count()
nnew = n + size(x, 2)
! Input Check
if (cstart < 1) then
call errmgr%report_error("dt_insert_columnss", &
"The insertion index must be at least 1.", &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (cstart > 1 + n) then
write(errmsg, '(AI0AI0A)') "The insertion index must not be " // &
"greater than ", n + 1, ", but was found to be ", cstart, "."
call errmgr%report_error("dt_insert_columns", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (allocated(this%m_table) .and. size(x, 1) /= m) then
write(errmsg, '(AI0AI0A)') "The input data set was expected " // &
"to have ", m, " rows, but was found to have ", &
size(x, 1), "."
call errmgr%report_error("dt_insert_columns", trim(errmsg), &
FCORE_ARRAY_SIZE_ERROR)
return
end if
! If the array is not allocated, allocate and store as the input array
! will define the table structure
if (.not.allocated(this%m_table)) then
call this%initialize(size(x, 1), size(x, 2), err = errmgr)
if (errmgr%has_error_occurred()) return
do j = 1, size(x, 2)
do i = 1, size(x, 1)
call this%set(i, j, x(i,j), err = errmgr)
if (errmgr%has_error_occurred()) return
end do
end do
return
end if
! If we're here, there was already a properly allocated matrix, and the
! size of X is OK. Start by copying m_table, and then reallocate
! m_table to allow fitting of the new data
allocate(copy(m, n), stat = flag)
if (flag /= 0) go to 100
copy = this%m_table
deallocate(this%m_table)
allocate(this%m_table(m, nnew), stat = flag)
if (flag /= 0) then
! Put copy back to m_table, and then handle the error
this%m_table = copy
go to 100
end if
! Copy back the contents into m_table
do j = 1, cstart - 1
do i = 1, m
this%m_table(i, j) = copy(i, j)
end do
end do
k = cstart
do j = 1, size(x, 2)
do i = 1, m
call this%set(i, k, x(i, j), err = errmgr)
if (errmgr%has_error_occurred()) return
end do
k = k + 1
end do
do j = cstart, n
do i = 1, m
this%m_table(i, k) = copy(i, j)
end do
k = k + 1
end do
return
100 continue
! Deal with memory errors
call errmgr%report_error("dt_insert_columns", &
"Insufficient memory available.", FCORE_OUT_OF_MEMORY_ERROR)
return
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_insert_column(this, i, x, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: i
class(*), intent(in), dimension(:) :: x
class(errors), intent(inout), optional, target :: err
! Local Variables
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Check the length of x
if (allocated(this%m_table) .and. &
size(x) /= this%get_row_count()) &
then
write(errmsg, '(AI0AI0A)') "The number of items in the array " // &
"to insert ,", size(x), ", must match the number of " // &
"rows in the table ", this%get_row_count(), "."
call errmgr%report_error("dt_insert_column", trim(errmsg), &
FCORE_ARRAY_SIZE_ERROR)
return
end if
! Insert the array
call this%insert_columns(i, reshape(x, [size(x), 1]), err = errmgr)
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_append_rows(this, x, err)
! Arguments
class(data_table), intent(inout) :: this
class(*), intent(in), dimension(:,:) :: x
class(errors), intent(inout), optional, target :: err
! Process
call this%insert_rows(this%get_row_count() + 1, x, err)
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_append_row(this, x, err)
! Arguments
class(data_table), intent(inout) :: this
class(*), intent(in), dimension(:) :: x
class(errors), intent(inout), optional, target :: err
! Process
call this%insert_row(this%get_row_count() + 1, x, err)
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_append_columns(this, x, err)
! Arguments
class(data_table), intent(inout) :: this
class(*), intent(in), dimension(:,:) :: x
class(errors), intent(inout), optional, target :: err
! Process
call this%insert_columns(this%get_column_count() + 1, x, err)
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_append_column(this, x, err)
! Arguments
class(data_table), intent(inout) :: this
class(*), intent(in), dimension(:) :: x
class(errors), intent(inout), optional, target :: err
! Process
call this%insert_column(this%get_column_count() + 1, x, err)
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_remove_rows(this, rstart, nrows, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: rstart, nrows
class(errors), intent(inout), optional, target :: err
! Local Variables
integer(int32) :: i, j, k, m, n, mnew, flag
type(container), allocatable, dimension(:,:) :: copy
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Initialization
m = this%get_row_count()
n = this%get_column_count()
mnew = m - nrows
! Input Check
if (.not.allocated(this%m_table)) then
call errmgr%report_error("dt_remove_rows", &
"The table has not been initialized.", &
FCORE_UNINITIALIZED_OBJECT_ERROR)
return
end if
if (nrows < 1) then
call errmgr%report_error("dt_remove_rows", &
"It is expected that at least 1 row be removed when " // &
"calling this routine.", FCORE_INVALID_INPUT_ERROR)
return
end if
if (rstart < 1) then
call errmgr%report_error("dt_remove_rows", &
"The index of the row(s) to remove must be at least 1.", &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (mnew < 0) then
write(errmsg, '(AI0AI0A)') "The request to remove ", nrows, &
" exceeds the size of the table (", this%get_row_count(), ")."
call errmgr%report_error("dt_remove_rows", trim(errmsg), &
FCORE_INVALID_INPUT_ERROR)
return
end if
if (rstart > mnew) then
write(errmsg, '(AI0AI0AI0A)') &
"The combination of starting index (", rstart, &
") and the number of rows to remove (", nrows, &
") exceeds the number of rows in the current table (", &
this%get_row_count(), ")."
call errmgr%report_error("dt_remove_rows", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
! Quick Return
if (mnew == 0) then
! Wipe out the whole table
call this%clear()
return
end if
! Create a copy of the table
allocate(copy(m, n), stat = flag)
if (flag /= 0) go to 100
copy = this%m_table
deallocate(this%m_table)
allocate(this%m_table(mnew, n), stat = flag)
if (flag /= 0) then
! Put copy back to m_table, and then handle the error
this%m_table = copy
go to 100
end if
! Copy back the contents into m_table - also be sure to deallocate
! memory associated with the removed items
do j = 1, n
do i = 1, rstart - 1
this%m_table(i, j) = copy(i, j)
end do
k = rstart
do i = 1, nrows
if (associated(this%m_table(k, j)%item)) then
deallocate(this%m_table(k, j)%item)
end if
k = k + 1
end do
k = rstart + nrows
do i = rstart, mnew
this%m_table(i, j) = copy(k, j)
k = k + 1
end do
end do
return
100 continue
! Handle any memory errors
call errmgr%report_error("dt_remove_rows", &
"Insufficient memory available.", FCORE_OUT_OF_MEMORY_ERROR)
return
end subroutine
! ------------------------------------------------------------------------------
module subroutine dt_remove_columns(this, cstart, ncols, err)
! Arguments
class(data_table), intent(inout) :: this
integer(int32), intent(in) :: cstart, ncols
class(errors), intent(inout), optional, target :: err
! Local Variables
integer(int32) :: i, j, k, m, n, nnew, flag
type(container), allocatable, dimension(:,:) :: copy
class(errors), pointer :: errmgr
type(errors), target :: deferr
character(len = 256) :: errmsg
! Set up error handling
if (present(err)) then
errmgr => err
else
errmgr => deferr
end if
! Initialization
m = this%get_row_count()
n = this%get_column_count()
nnew = n - ncols
! Input Check
if (.not.allocated(this%m_table)) then
call errmgr%report_error("dt_remove_columns", &
"The table has not been initialized.", &
FCORE_UNINITIALIZED_OBJECT_ERROR)
return
end if
if (ncols < 1) then
call errmgr%report_error("dt_remove_columns", &
"It is expected that at least 1 column be removed " // &
"when calling this routine.", FCORE_INVALID_INPUT_ERROR)
return
end if
if (cstart < 1) then
call errmgr%report_error("dt_remove_columns", &
"The index of the column(s) to remove must be at least 1.", &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
if (nnew < 0) then
write(errmsg, '(AI0AI0A)') "The request to remove ", ncols, &
" exceeds the size of the table (", this%get_column_count(), &
")."
call errmgr%report_error("dt_remove_columns", trim(errmsg), &
FCORE_INVALID_INPUT_ERROR)
return
end if
if (cstart > nnew) then
write(errmsg, '(AI0AI0AI0A)') &
"The combination of starting index (", cstart, &
") and the number of columns to remove (", ncols, &
") exceeds the number of columns in the current table (", &
this%get_column_count(), ")."
call errmgr%report_error("dt_remove_columns", trim(errmsg), &
FCORE_INDEX_OUT_OF_RANGE_ERROR)
return
end if
! Quick Return
if (nnew == 0) then
! Wipe out the whole table
call this%clear()
return
end if
! Create a copy of the table
allocate(copy(m, n), stat = flag)
if (flag /= 0) go to 100
copy = this%m_table
! Resize the table
deallocate(this%m_table)
allocate(this%m_table(m, nnew), stat = flag)
if (flag /= 0) then
! Put copy back to m_table, and then handle the error
this%m_table = copy
go to 100
end if
! Copy back the contents into m_table - also be sure to deallocate
! memory associated with the removed items
do j = 1, cstart - 1
do i = 1, m
this%m_table(i, j) = copy(i, j)
end do
end do
k = cstart
do j = 1, ncols
do i = 1, m
if (associated(this%m_table(i, k)%item)) then
deallocate(this%m_table(i, k)%item)
end if
end do
k = k + 1
end do
do j = cstart, nnew
do i = 1, m
this%m_table(i, j) = copy(i, k)
end do
k = k + 1
end do
return
100 continue
! Handle any memory errors
call errmgr%report_error("dt_remove_rows", &
"Insufficient memory available.", FCORE_OUT_OF_MEMORY_ERROR)
return
end subroutine
! ------------------------------------------------------------------------------
! ------------------------------------------------------------------------------
! ------------------------------------------------------------------------------
! ------------------------------------------------------------------------------
end submodule