Merge commit 'v2.0.2-1616-gc017b6ee'

This commit is contained in:
Test User 2019-01-29 22:02:19 +01:00
commit 23a97ec15f
2 changed files with 29 additions and 26 deletions

View File

@ -186,10 +186,9 @@ recursive function IO_recursiveRead(fileName,cnt) result(fileContent)
fileUnit, & fileUnit, &
startPos, endPos, & startPos, endPos, &
myTotalLines, & !< # lines read from file without include statements myTotalLines, & !< # lines read from file without include statements
includedLines, & !< # lines included from other file(s)
missingLines, & !< # lines missing from current file
l,i, & l,i, &
myStat myStat
logical :: warned
if (present(cnt)) then if (present(cnt)) then
if (cnt>10_pInt) call IO_error(106_pInt,ext_msg=trim(fileName)) if (cnt>10_pInt) call IO_error(106_pInt,ext_msg=trim(fileName))
@ -207,37 +206,39 @@ recursive function IO_recursiveRead(fileName,cnt) result(fileContent)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! count lines to allocate string array ! count lines to allocate string array
myTotalLines = 0_pInt myTotalLines = 1_pInt
do l=1_pInt, len(rawData) do l=1_pInt, len(rawData)
if (rawData(l:l) == new_line('') .or. l==len(rawData)) myTotalLines = myTotalLines+1 ! end of line or end of file without new line if (rawData(l:l) == new_line('')) myTotalLines = myTotalLines+1
enddo enddo
allocate(fileContent(myTotalLines)) allocate(fileContent(myTotalLines))
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! split raw data at end of line and handle includes ! split raw data at end of line and handle includes
warned = .false.
startPos = 1_pInt startPos = 1_pInt
endPos = 0_pInt l = 1_pInt
do while (l <= myTotalLines)
endPos = merge(startPos + scan(rawData(startPos:),new_line('')) - 2_pInt,len(rawData),l /= myTotalLines)
if (endPos - startPos > 255_pInt) then
line = rawData(startPos:startPos+255_pInt)
if (.not. warned) then
call IO_warning(207_pInt,ext_msg=trim(fileName),el=l)
warned = .true.
endif
else
line = rawData(startPos:endpos)
endif
startPos = endPos + 2_pInt ! jump to next line start
includedLines=0_pInt recursion: if (scan(trim(adjustl(line)),'{') == 1 .and. scan(trim(line),'}') > 2) then
l=0_pInt
do while (startPos <= len(rawData))
l = l + 1_pInt
endPos = endPos + scan(rawData(startPos:),new_line(''))
if(endPos < startPos) endPos = len(rawData) ! end of file without end of line
if(endPos - startPos >256) call IO_error(107_pInt,ext_msg=trim(fileName))
line = rawData(startPos:endPos-1_pInt)
startPos = endPos + 1_pInt
recursion: if(scan(trim(line),'{') < scan(trim(line),'}')) then
myTotalLines = myTotalLines - 1_pInt
includedContent = IO_recursiveRead(trim(line(scan(line,'{')+1_pInt:scan(line,'}')-1_pInt)), & includedContent = IO_recursiveRead(trim(line(scan(line,'{')+1_pInt:scan(line,'}')-1_pInt)), &
merge(cnt,1_pInt,present(cnt))) ! to track recursion depth merge(cnt,1_pInt,present(cnt))) ! to track recursion depth
includedLines = includedLines + size(includedContent) fileContent = [ fileContent(1:l-1_pInt), includedContent, [(dummy,i=1,myTotalLines-l)] ] ! add content and grow array
missingLines = myTotalLines + includedLines - size(fileContent(1:l-1)) -size(includedContent) myTotalLines = myTotalLines - 1_pInt + size(includedContent)
fileContent = [ fileContent(1:l-1_pInt), includedContent, [(dummy,i=1,missingLines)] ] ! add content and grow array
l = l - 1_pInt + size(includedContent) l = l - 1_pInt + size(includedContent)
else recursion else recursion
fileContent(l) = line fileContent(l) = line
l = l + 1_pInt
endif recursion endif recursion
enddo enddo
@ -1498,6 +1499,8 @@ subroutine IO_warning(warning_ID,el,ip,g,ext_msg)
msg = 'invalid character in string chunk' msg = 'invalid character in string chunk'
case (203_pInt) case (203_pInt)
msg = 'interpretation of string chunk failed' msg = 'interpretation of string chunk failed'
case (207_pInt)
msg = 'line truncated'
case (600_pInt) case (600_pInt)
msg = 'crystallite responds elastically' msg = 'crystallite responds elastically'
case (601_pInt) case (601_pInt)