Skip to content

Commit 097f876

Browse files
committed
Merge branch 'master' of https://github.com/scottza/fortran-csv-module into develop
2 parents 9da22bf + b8cab27 commit 097f876

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/csv_module.F90

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
226226
!! (0 if no header specified)
227227
character(len=1) :: tmp !! for skipping a row
228228

229-
call me%destroy()
230229
arrays_allocated = .false.
231230

232231
open(newunit=iunit, file=filename, status='OLD', iostat=istat)
@@ -287,7 +286,9 @@ subroutine read_csv_file(me,filename,header_row,skip_rows,status_ok)
287286
! columns.
288287
n_cols = size(row_data)
289288
me%n_cols = n_cols
289+
if(allocated(me%csv_data)) deallocate(me%csv_data)
290290
allocate(me%csv_data(n_rows,n_cols))
291+
if(allocated(me%header)) deallocate(me%header)
291292
if (iheader/=0) allocate(me%header(n_cols))
292293
arrays_allocated = .true.
293294
end if
@@ -339,8 +340,6 @@ subroutine open_csv_file(me,filename,n_cols,status_ok,append)
339340
logical :: append_flag !! local copy of `append` argument
340341
logical :: file_exists !! if the file exists
341342

342-
call me%destroy()
343-
344343
me%n_cols = n_cols
345344

346345
! optional append argument:

0 commit comments

Comments
 (0)