From 1a56ad7a72d284a91339e0c39a13550099e0b4dc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 29 Oct 2016 10:21:00 +0200 Subject: [PATCH 1/5] no logic change yet --- processing/pre/geom_pack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index cfa329698..106b37b5f 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -93,7 +93,7 @@ for name in filenames: elif type == '.': table.data = [former] elif type == 'to': - table.data = [former-reps+1,'to',former] + table.data = [start,'to',former] elif type == 'of': table.data = [reps,'of',former] From 7e6e2e1c84cf623950ea42c34f671a3f381b16c2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 29 Oct 2016 10:28:34 +0200 Subject: [PATCH 2/5] not using reserverd keyword "type" --- processing/pre/geom_pack.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index 106b37b5f..d251cdf36 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -67,7 +67,7 @@ for name in filenames: # --- write packed microstructure information ----------------------------------------------------- - type = '' + compressType = '' former = start = -1 reps = 0 @@ -82,24 +82,24 @@ for name in filenames: for current in items: if current == former+1 and start+reps == former+1: - type = 'to' + compressType = 'to' reps += 1 elif current == former and start == former: - type = 'of' + compressType = 'of' reps += 1 else: - if type == '': + if compressType == '': table.data = [] - elif type == '.': + elif compressType == '.': table.data = [former] - elif type == 'to': + elif compressType == 'to': table.data = [start,'to',former] - elif type == 'of': + elif compressType == 'of': table.data = [reps,'of',former] outputAlive = table.data_write(delimiter = ' ') # output processed line - type = '.' + compressType = '.' start = current reps = 1 @@ -109,7 +109,7 @@ for name in filenames: '.' : [former], 'to': [former-reps+1,'to',former], 'of': [reps,'of',former], - }[type] + }[compressType] outputAlive = table.data_write(delimiter = ' ') # output processed line From aa3dc5694927b845b0688da240b51d4528cf2d3d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 29 Oct 2016 10:30:42 +0200 Subject: [PATCH 3/5] fixed handling of last line (bug fix for second but last commit) --- processing/pre/geom_pack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index d251cdf36..bf528a052 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -107,7 +107,7 @@ for name in filenames: table.data = { '.' : [former], - 'to': [former-reps+1,'to',former], + 'to': [start,'to',former], 'of': [reps,'of',former], }[compressType] From 8eb93a327410cf43d2d3338fe746d0e508c6ed10 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 29 Oct 2016 10:49:40 +0200 Subject: [PATCH 4/5] python scripts now pack "a a-1 a-2 ... a-n" to "a to a-n" --- lib/damask/asciitable.py | 7 +++++-- processing/pre/geom_pack.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/damask/asciitable.py b/lib/damask/asciitable.py index 3509a5284..d3a7ad693 100644 --- a/lib/damask/asciitable.py +++ b/lib/damask/asciitable.py @@ -600,8 +600,11 @@ class ASCIItable(): while i < N and self.data_read(): items = self.data if len(items) > 2: - if items[1].lower() == 'of': items = np.ones(datatype(items[0]))*datatype(items[2]) - elif items[1].lower() == 'to': items = np.arange(datatype(items[0]),1+datatype(items[2])) + if items[1].lower() == 'of': + 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)) diff --git a/processing/pre/geom_pack.py b/processing/pre/geom_pack.py index bf528a052..286abd180 100755 --- a/processing/pre/geom_pack.py +++ b/processing/pre/geom_pack.py @@ -81,7 +81,7 @@ for name in filenames: else: items = map(int,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: compressType = 'to' reps += 1 elif current == former and start == former: From 97867806f71e17c9ec775f79444c8c4d76050493 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 29 Oct 2016 11:04:19 +0200 Subject: [PATCH 5/5] Fortran code also ready for negative range --- code/IO.f90 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/IO.f90 b/code/IO.f90 index 060fcf01f..894e81852 100644 --- a/code/IO.f90 +++ b/code/IO.f90 @@ -1267,8 +1267,8 @@ integer(pInt) function IO_countContinuousIntValues(fileUnit) line = IO_read(fileUnit, .true.) ! reset IO_read exit 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_intValue(line,chunkPos,1_pInt) + IO_countContinuousIntValues = 1_pInt + abs( IO_intValue(line,chunkPos,3_pInt) & + - IO_intValue(line,chunkPos,1_pInt)) line = IO_read(fileUnit, .true.) ! reset IO_read exit ! only one single range indicator allowed 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 integer(pInt), dimension(:,:), intent(in) :: lookupMap character(len=64), dimension(:), intent(in) :: lookupName - integer(pInt) :: i + integer(pInt) :: i,first,last #ifdef Abaqus - integer(pInt) :: j,l,c,first,last + integer(pInt) :: j,l,c #endif integer(pInt), allocatable, dimension(:) :: chunkPos @@ -1348,7 +1348,9 @@ function IO_continuousIntValues(fileUnit,maxN,lookupName,lookupMap,lookupMaxN) enddo exit 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)) = i enddo