bugfix (do not keep EOL in last string)
simplified further
This commit is contained in:
parent
1e0cc51db7
commit
f84e5aaaf9
12
src/IO.f90
12
src/IO.f90
|
@ -68,9 +68,8 @@ function IO_read_ASCII(fileName) result(fileContent)
|
||||||
fileLength, &
|
fileLength, &
|
||||||
fileUnit, &
|
fileUnit, &
|
||||||
startPos, endPos, &
|
startPos, endPos, &
|
||||||
N_lines, & !< # lines read from file
|
N_lines, & !< # lines in file
|
||||||
l, &
|
l, &
|
||||||
i, &
|
|
||||||
myStat
|
myStat
|
||||||
logical :: warned
|
logical :: warned
|
||||||
|
|
||||||
|
@ -87,14 +86,9 @@ function IO_read_ASCII(fileName) result(fileContent)
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
! count lines to allocate string array
|
! count lines to allocate string array
|
||||||
N_lines = 0
|
N_lines = 0
|
||||||
i = 0
|
|
||||||
do l=1, len(rawData)
|
do l=1, len(rawData)
|
||||||
if (rawData(l:l) == IO_EOL) then
|
if (rawData(l:l) == IO_EOL) N_lines = N_lines+1
|
||||||
N_lines = N_lines+1
|
|
||||||
i = l
|
|
||||||
endif
|
|
||||||
enddo
|
enddo
|
||||||
if(i+1/=l) N_lines = N_lines+1 ! no EOL in last line
|
|
||||||
allocate(fileContent(N_lines))
|
allocate(fileContent(N_lines))
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
@ -103,7 +97,7 @@ function IO_read_ASCII(fileName) result(fileContent)
|
||||||
startPos = 1
|
startPos = 1
|
||||||
l = 1
|
l = 1
|
||||||
do while (l <= N_lines)
|
do while (l <= N_lines)
|
||||||
endPos = merge(startPos + scan(rawData(startPos:),IO_EOL) - 2,len(rawData),l /= N_lines)
|
endPos = startPos + scan(rawData(startPos:),IO_EOL) - 2
|
||||||
if (endPos - startPos > pStringLen-1) then
|
if (endPos - startPos > pStringLen-1) then
|
||||||
line = rawData(startPos:startPos+pStringLen-1)
|
line = rawData(startPos:startPos+pStringLen-1)
|
||||||
if (.not. warned) then
|
if (.not. warned) then
|
||||||
|
|
Loading…
Reference in New Issue