Merge branch 'reverseRange' into development

This commit is contained in:
Chen 2016-11-01 16:45:40 -04:00 committed by chen
commit ae05bdd9fd
3 changed files with 24 additions and 19 deletions

View File

@ -1267,8 +1267,8 @@ integer(pInt) function IO_countContinuousIntValues(fileUnit)
line = IO_read(fileUnit, .true.) ! reset IO_read line = IO_read(fileUnit, .true.) ! reset IO_read
exit exit
elseif (IO_lc(IO_stringValue(line,chunkPos,2_pInt)) == 'to' ) then ! found range indicator elseif (IO_lc(IO_stringValue(line,chunkPos,2_pInt)) == 'to' ) then ! found range indicator
IO_countContinuousIntValues = 1_pInt + IO_intValue(line,chunkPos,3_pInt) & IO_countContinuousIntValues = 1_pInt + abs( IO_intValue(line,chunkPos,3_pInt) &
- IO_intValue(line,chunkPos,1_pInt) - IO_intValue(line,chunkPos,1_pInt))
line = IO_read(fileUnit, .true.) ! reset IO_read line = IO_read(fileUnit, .true.) ! reset IO_read
exit ! only one single range indicator allowed exit ! only one single range indicator allowed
else if (IO_lc(IO_stringValue(line,chunkPos,2_pInt)) == 'of' ) then ! found multiple entries indicator else if (IO_lc(IO_stringValue(line,chunkPos,2_pInt)) == 'of' ) then ! found multiple entries indicator
@ -1321,9 +1321,9 @@ function IO_continuousIntValues(fileUnit,maxN,lookupName,lookupMap,lookupMaxN)
lookupMaxN lookupMaxN
integer(pInt), dimension(:,:), intent(in) :: lookupMap integer(pInt), dimension(:,:), intent(in) :: lookupMap
character(len=64), dimension(:), intent(in) :: lookupName character(len=64), dimension(:), intent(in) :: lookupName
integer(pInt) :: i integer(pInt) :: i,first,last
#ifdef Abaqus #ifdef Abaqus
integer(pInt) :: j,l,c,first,last integer(pInt) :: j,l,c
#endif #endif
integer(pInt), allocatable, dimension(:) :: chunkPos integer(pInt), allocatable, dimension(:) :: chunkPos
@ -1348,7 +1348,9 @@ function IO_continuousIntValues(fileUnit,maxN,lookupName,lookupMap,lookupMaxN)
enddo enddo
exit exit
else if (chunkPos(1) > 2_pInt .and. IO_lc(IO_stringValue(line,chunkPos,2_pInt)) == 'to' ) then ! found range indicator else if (chunkPos(1) > 2_pInt .and. IO_lc(IO_stringValue(line,chunkPos,2_pInt)) == 'to' ) then ! found range indicator
do i = IO_intValue(line,chunkPos,1_pInt),IO_intValue(line,chunkPos,3_pInt) first = IO_intValue(line,chunkPos,1_pInt)
last = IO_intValue(line,chunkPos,3_pInt)
do i = first, last, sign(1_pInt,last-first)
IO_continuousIntValues(1) = IO_continuousIntValues(1) + 1_pInt IO_continuousIntValues(1) = IO_continuousIntValues(1) + 1_pInt
IO_continuousIntValues(1+IO_continuousIntValues(1)) = i IO_continuousIntValues(1+IO_continuousIntValues(1)) = i
enddo enddo

View File

@ -600,8 +600,11 @@ class ASCIItable():
while i < N and self.data_read(): while i < N and self.data_read():
items = self.data items = self.data
if len(items) > 2: if len(items) > 2:
if items[1].lower() == 'of': items = np.ones(datatype(items[0]))*datatype(items[2]) if items[1].lower() == 'of':
elif items[1].lower() == 'to': items = np.arange(datatype(items[0]),1+datatype(items[2])) items = np.ones(datatype(items[0]))*datatype(items[2])
elif items[1].lower() == 'to':
items = np.linspace(datatype(items[0]),datatype(items[2]),
abs(datatype(items[2])-datatype(items[0]))+1,dtype=int)
else: items = list(map(datatype,items)) else: items = list(map(datatype,items))
else: items = list(map(datatype,items)) else: items = list(map(datatype,items))

View File

@ -67,7 +67,7 @@ for name in filenames:
# --- write packed microstructure information ----------------------------------------------------- # --- write packed microstructure information -----------------------------------------------------
type = '' compressType = ''
former = start = -1 former = start = -1
reps = 0 reps = 0
@ -81,25 +81,25 @@ for name in filenames:
else: items = map(int,items) else: items = map(int,items)
for current in items: for current in items:
if current == former+1 and start+reps == former+1: if abs(current - former) == 1 and abs(start-former) == reps - 1:
type = 'to' compressType = 'to'
reps += 1 reps += 1
elif current == former and start == former: elif current == former and start == former:
type = 'of' compressType = 'of'
reps += 1 reps += 1
else: else:
if type == '': if compressType == '':
table.data = [] table.data = []
elif type == '.': elif compressType == '.':
table.data = [former] table.data = [former]
elif type == 'to': elif compressType == 'to':
table.data = [former-reps+1,'to',former] table.data = [start,'to',former]
elif type == 'of': elif compressType == 'of':
table.data = [reps,'of',former] table.data = [reps,'of',former]
outputAlive = table.data_write(delimiter = ' ') # output processed line outputAlive = table.data_write(delimiter = ' ') # output processed line
type = '.' compressType = '.'
start = current start = current
reps = 1 reps = 1
@ -107,9 +107,9 @@ for name in filenames:
table.data = { table.data = {
'.' : [former], '.' : [former],
'to': [former-reps+1,'to',former], 'to': [start,'to',former],
'of': [reps,'of',former], 'of': [reps,'of',former],
}[type] }[compressType]
outputAlive = table.data_write(delimiter = ' ') # output processed line outputAlive = table.data_write(delimiter = ' ') # output processed line