From ef4b7437f3d0805a304a73e35015ac0646ab9cf8 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Thu, 20 Feb 2020 14:01:26 +0100 Subject: [PATCH 1/7] Input arguments of a function to be declared first. --- src/IO.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index 380d907b2..c31ebdfab 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -189,10 +189,10 @@ end function IO_isBlank !-------------------------------------------------------------------------------------------------- pure function IO_getTag(string,openChar,closeChar) - character(len=:), allocatable :: IO_getTag character(len=*), intent(in) :: string !< string to check for tag character, intent(in) :: openChar, & !< indicates beginning of tag closeChar !< indicates end of tag + character(len=:), allocatable :: IO_getTag character(len=*), parameter :: SEP=achar(32)//achar(9)//achar(10)//achar(13) ! whitespaces integer :: left,right @@ -222,8 +222,8 @@ end function IO_getTag !-------------------------------------------------------------------------------------------------- pure function IO_stringPos(string) - integer, dimension(:), allocatable :: IO_stringPos character(len=*), intent(in) :: string !< string in which chunk positions are searched for + integer, dimension(:), allocatable :: IO_stringPos character(len=*), parameter :: SEP=achar(44)//achar(32)//achar(9)//achar(10)//achar(13) ! comma and whitespaces integer :: left, right From e93f5c84ffe17c833e1e6692922a06e00854c23d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 20 Feb 2020 15:05:38 +0100 Subject: [PATCH 2/7] 'buffered' has no effect any more --- processing/post/addCalculation.py | 2 +- processing/post/addEhkl.py | 4 ++-- processing/post/addLinked.py | 11 +++++------ processing/post/addOrientations.py | 2 +- processing/post/addSchmidfactors.py | 7 ++++--- processing/post/binXY.py | 15 ++++++++------- processing/post/filterTable.py | 7 ++++--- processing/post/groupTable.py | 7 ++++--- processing/post/histogram.py | 8 ++++---- processing/post/imageData.py | 8 +++----- processing/post/imageDataDeformed.py | 9 ++++----- processing/post/imageDataRGB.py | 9 ++++----- processing/post/permuteData.py | 3 +-- processing/post/rotateData.py | 6 +++--- processing/post/viewTable.py | 6 +++--- processing/pre/hybridIA_linODFsampling.py | 2 +- .../pre/patchFromReconstructedBoundaries.py | 4 +--- processing/pre/seeds_fromRandom.py | 7 ++++--- 18 files changed, 57 insertions(+), 60 deletions(-) diff --git a/processing/post/addCalculation.py b/processing/post/addCalculation.py index b1eed3c6d..79fdd9455 100755 --- a/processing/post/addCalculation.py +++ b/processing/post/addCalculation.py @@ -66,7 +66,7 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, buffered = False) + table = damask.ASCIItable(name = name) except IOError: continue damask.util.report(scriptName,name) diff --git a/processing/post/addEhkl.py b/processing/post/addEhkl.py index 4cf846814..04c42deb5 100755 --- a/processing/post/addEhkl.py +++ b/processing/post/addEhkl.py @@ -61,8 +61,8 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, buffered = False) - except: + table = damask.ASCIItable(name = name) + except IOError: continue damask.util.report(scriptName,name) diff --git a/processing/post/addLinked.py b/processing/post/addLinked.py index f13f3c632..9b09cb7c7 100755 --- a/processing/post/addLinked.py +++ b/processing/post/addLinked.py @@ -47,9 +47,7 @@ if options.link is None: if options.asciitable is not None and os.path.isfile(options.asciitable): - linkedTable = damask.ASCIItable(name = options.asciitable, - buffered = False, - readonly = True) + linkedTable = damask.ASCIItable(name = options.asciitable, readonly = True) linkedTable.head_read() # read ASCII header info of linked table linkDim = linkedTable.label_dimension(options.link[1]) # dimension of linking column @@ -72,9 +70,10 @@ else: if filenames == []: filenames = [None] for name in filenames: - try: table = damask.ASCIItable(name = name, - buffered = False) - except: continue + try: + table = damask.ASCIItable(name = name) + except IOError: + continue damask.util.report(scriptName,"{} {} <== {} {}".format(name,damask.util.deemph('@ '+options.link[0]), options.asciitable,damask.util.deemph('@ '+options.link[1]))) diff --git a/processing/post/addOrientations.py b/processing/post/addOrientations.py index 2c46ee5ee..137b8121e 100755 --- a/processing/post/addOrientations.py +++ b/processing/post/addOrientations.py @@ -126,7 +126,7 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, buffered = False) + table = damask.ASCIItable(name = name) except IOError: continue damask.util.report(scriptName,name) diff --git a/processing/post/addSchmidfactors.py b/processing/post/addSchmidfactors.py index 30610213e..670824064 100755 --- a/processing/post/addSchmidfactors.py +++ b/processing/post/addSchmidfactors.py @@ -182,9 +182,10 @@ slip_normal /= np.tile(np.linalg.norm(slip_normal ,axis=1),(3,1)).T if filenames == []: filenames = [None] for name in filenames: - try: table = damask.ASCIItable(name = name, - buffered = False) - except: continue + try: + table = damask.ASCIItable(name = name) + except IOError: + continue damask.util.report(scriptName,name) # ------------------------------------------ read header ------------------------------------------ diff --git a/processing/post/binXY.py b/processing/post/binXY.py index baa054dec..e9924a28a 100755 --- a/processing/post/binXY.py +++ b/processing/post/binXY.py @@ -90,13 +90,14 @@ if options.weight is not None: labels += [options.weight] if filenames == []: filenames = [None] for name in filenames: - try: table = damask.ASCIItable(name = name, - outname = os.path.join(os.path.dirname(name), - 'binned-{}-{}_'.format(*options.data) + - ('weighted-{}_'.format(options.weight) if options.weight else '') + - os.path.basename(name)) if name else name, - buffered = False) - except: continue + try: + table = damask.ASCIItable(name = name, + outname = os.path.join(os.path.dirname(name), + 'binned-{}-{}_'.format(*options.data) + + ('weighted-{}_'.format(options.weight) if options.weight else '') + + os.path.basename(name)) if name else name) + except IOError: + continue damask.util.report(scriptName,name) # ------------------------------------------ read header ------------------------------------------ diff --git a/processing/post/filterTable.py b/processing/post/filterTable.py index 2788ccefb..c7f499aca 100755 --- a/processing/post/filterTable.py +++ b/processing/post/filterTable.py @@ -66,9 +66,10 @@ parser.set_defaults(condition = None, if filenames == []: filenames = [None] for name in filenames: - try: table = damask.ASCIItable(name = name, - buffered = False) - except: continue + try: + table = damask.ASCIItable(name = name) + except IOError: + continue damask.util.report(scriptName,name) # ------------------------------------------ assemble info --------------------------------------- diff --git a/processing/post/groupTable.py b/processing/post/groupTable.py index 33c2298b9..f2d1198bc 100755 --- a/processing/post/groupTable.py +++ b/processing/post/groupTable.py @@ -87,9 +87,10 @@ if not hasattr(mapFunction,'__call__'): if filenames == []: filenames = [None] for name in filenames: - try: table = damask.ASCIItable(name = name, - buffered = False) - except: continue + try: + table = damask.ASCIItable(name = name) + except IOError: + continue damask.util.report(scriptName,name) # ------------------------------------------ sanity checks --------------------------------------- diff --git a/processing/post/histogram.py b/processing/post/histogram.py index 1f1c52d4c..20e377116 100755 --- a/processing/post/histogram.py +++ b/processing/post/histogram.py @@ -76,10 +76,10 @@ else: if filenames == []: filenames = [None] for name in filenames: - try: table = damask.ASCIItable(name = name, - buffered = False, - readonly = True) - except: continue + try: + table = damask.ASCIItable(name = name, readonly = True) + except IOError: + continue damask.util.report(scriptName,name) # ------------------------------------------ read header ------------------------------------------ diff --git a/processing/post/imageData.py b/processing/post/imageData.py index 61935514b..2ca3ef6e7 100755 --- a/processing/post/imageData.py +++ b/processing/post/imageData.py @@ -117,11 +117,9 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, - buffered = False, - labeled = options.label is not None, - readonly = True) - except: continue + table = damask.ASCIItable(name = name, labeled = options.label is not None, readonly = True) + except IOError: + continue damask.util.report(scriptName,name) # ------------------------------------------ read header ------------------------------------------ diff --git a/processing/post/imageDataDeformed.py b/processing/post/imageDataDeformed.py index d871f2af9..79f81e29e 100755 --- a/processing/post/imageDataDeformed.py +++ b/processing/post/imageDataDeformed.py @@ -114,11 +114,10 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, - buffered = False, - labeled = options.label is not None, - readonly = True) - except: continue + table = damask.ASCIItable(name = name, readonly = True, + labeled = options.label is not None) + except IOError: + continue table.report_name(scriptName,name) # ------------------------------------------ read header ------------------------------------------ diff --git a/processing/post/imageDataRGB.py b/processing/post/imageDataRGB.py index d80c61e0f..4a1d521b2 100755 --- a/processing/post/imageDataRGB.py +++ b/processing/post/imageDataRGB.py @@ -82,11 +82,10 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, - buffered = False, - labeled = options.label is not None, - readonly = True) - except: continue + table = damask.ASCIItable(name = name, readonly = True, + labeled = options.label is not None) + except IOError: + continue damask.util.report(scriptName,name) # ------------------------------------------ read header ------------------------------------------ diff --git a/processing/post/permuteData.py b/processing/post/permuteData.py index 7da0d1033..a589cb6da 100755 --- a/processing/post/permuteData.py +++ b/processing/post/permuteData.py @@ -51,8 +51,7 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, - buffered = False) + table = damask.ASCIItable(name = name) except IOError: continue damask.util.report(scriptName,name) diff --git a/processing/post/rotateData.py b/processing/post/rotateData.py index aa7c32f79..f56b04236 100755 --- a/processing/post/rotateData.py +++ b/processing/post/rotateData.py @@ -52,9 +52,9 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, - buffered = False) - except: continue + table = damask.ASCIItable(name = name) + except IOError: + continue damask.util.report(scriptName,name) # --- interpret header ---------------------------------------------------------------------------- diff --git a/processing/post/viewTable.py b/processing/post/viewTable.py index 87880d15d..1f134754d 100755 --- a/processing/post/viewTable.py +++ b/processing/post/viewTable.py @@ -60,9 +60,9 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, - buffered = False, labeled = options.labeled, readonly = True) - except: continue + table = damask.ASCIItable(name = name, labeled = options.labeled, readonly = True) + except IOError: + continue details = ', '.join( (['header'] if options.table else []) + (['info'] if options.head or options.info else []) + diff --git a/processing/pre/hybridIA_linODFsampling.py b/processing/pre/hybridIA_linODFsampling.py index 80d82a458..78c70d89c 100755 --- a/processing/pre/hybridIA_linODFsampling.py +++ b/processing/pre/hybridIA_linODFsampling.py @@ -234,7 +234,7 @@ if filenames == []: filenames = [None] for name in filenames: try: - table = damask.ASCIItable(name = name, buffered = False, readonly=True) + table = damask.ASCIItable(name = name, readonly=True) except IOError: continue damask.util.report(scriptName,name) diff --git a/processing/pre/patchFromReconstructedBoundaries.py b/processing/pre/patchFromReconstructedBoundaries.py index b710fb2cb..5f25c3b0d 100755 --- a/processing/pre/patchFromReconstructedBoundaries.py +++ b/processing/pre/patchFromReconstructedBoundaries.py @@ -966,9 +966,7 @@ if any(output in options.output for output in ['spectral','mentat']): if 'spectral' in options.output: fftdata = fftbuild(rcData, options.size, options.xmargin, options.ymargin, options.grid, options.extrusion) - table = damask.ASCIItable(outname = myName+'_'+str(int(fftdata['grid'][0]))+'.geom', - labeled = False, - buffered = False) + table = damask.ASCIItable(outname = myName+'_'+str(int(fftdata['grid'][0]))+'.geom', labeled = False) table.labels_clear() table.info_clear() table.info_append([ diff --git a/processing/pre/seeds_fromRandom.py b/processing/pre/seeds_fromRandom.py index 84c140933..cea6a05ec 100755 --- a/processing/pre/seeds_fromRandom.py +++ b/processing/pre/seeds_fromRandom.py @@ -132,9 +132,10 @@ random.seed(options.randomSeed) if filenames == []: filenames = [None] for name in filenames: - try: table = damask.ASCIItable(outname = name, - buffered = False) - except: continue + try: + table = damask.ASCIItable(outname = name) + except IOError: + continue damask.util.report(scriptName,name) # --- sanity checks ------------------------------------------------------------------------- From d108d76a615cdfecba6b0bdd76c2846a399a8f40 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 20 Feb 2020 15:08:32 +0100 Subject: [PATCH 3/7] was never read probably it was optimized away by the compiler, still confusing --- src/crystallite.f90 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/crystallite.f90 b/src/crystallite.f90 index 79381c63f..c01f9fa67 100644 --- a/src/crystallite.f90 +++ b/src/crystallite.f90 @@ -57,7 +57,6 @@ module crystallite crystallite_Li0, & !< intermediate velocitiy grad at start of FE inc crystallite_partionedLi0 !< intermediate velocity grad at start of homog inc real(pReal), dimension(:,:,:,:,:), allocatable :: & - crystallite_subS0, & !< 2nd Piola-Kirchhoff stress vector at start of crystallite inc crystallite_invFp, & !< inverse of current plastic def grad (end of converged time step) crystallite_subFp0,& !< plastic def grad at start of crystallite inc crystallite_invFi, & !< inverse of current intermediate def grad (end of converged time step) @@ -136,7 +135,6 @@ subroutine crystallite_init allocate(crystallite_S0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_partionedS0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_S(3,3,cMax,iMax,eMax), source=0.0_pReal) - allocate(crystallite_subS0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_P(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_F0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_partionedF0(3,3,cMax,iMax,eMax), source=0.0_pReal) @@ -351,7 +349,6 @@ function crystallite_stress(dummyArgumentToPreventInternalCompilerErrorWithGCC) crystallite_subFi0(1:3,1:3,c,i,e) = crystallite_partionedFi0(1:3,1:3,c,i,e) crystallite_subLi0(1:3,1:3,c,i,e) = crystallite_partionedLi0(1:3,1:3,c,i,e) crystallite_subF0(1:3,1:3,c,i,e) = crystallite_partionedF0(1:3,1:3,c,i,e) - crystallite_subS0(1:3,1:3,c,i,e) = crystallite_partionedS0(1:3,1:3,c,i,e) crystallite_subFrac(c,i,e) = 0.0_pReal crystallite_subStep(c,i,e) = 1.0_pReal/num%subStepSizeCryst crystallite_todo(c,i,e) = .true. @@ -397,7 +394,6 @@ function crystallite_stress(dummyArgumentToPreventInternalCompilerErrorWithGCC) crystallite_subLi0(1:3,1:3,c,i,e) = crystallite_Li (1:3,1:3,c,i,e) crystallite_subFp0(1:3,1:3,c,i,e) = crystallite_Fp (1:3,1:3,c,i,e) crystallite_subFi0(1:3,1:3,c,i,e) = crystallite_Fi (1:3,1:3,c,i,e) - crystallite_subS0 (1:3,1:3,c,i,e) = crystallite_S (1:3,1:3,c,i,e) !if abbrevation, make c and p private in omp plasticState( material_phaseAt(c,e))%subState0(:,material_phaseMemberAt(c,i,e)) & = plasticState(material_phaseAt(c,e))%state( :,material_phaseMemberAt(c,i,e)) From bc1d356d2196ed2adb2ac7cd29b0f526e2f9a167 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 20 Feb 2020 15:24:17 +0100 Subject: [PATCH 4/7] fixing prospector complaints 'except Exception': not really nice, but shell scripts will be remove soon anyway --- processing/post/filterTable.py | 4 ++-- processing/post/groupTable.py | 5 +++-- processing/pre/seeds_fromRandom.py | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/processing/post/filterTable.py b/processing/post/filterTable.py index c7f499aca..494257a60 100755 --- a/processing/post/filterTable.py +++ b/processing/post/filterTable.py @@ -21,7 +21,7 @@ def sortingList(labels,whitelistitems): names = [] for label in labels: - if re.match('^\d+_',label): + if re.match(r'^\d+_',label): indices.append(int(label.split('_',1)[0])) names.append(label.split('_',1)[1]) else: @@ -144,7 +144,7 @@ for name in filenames: try: table.data_readArray(positions+1) # read desired columns (indexed 1,...) table.data_writeArray() # directly write out - except: + except Exception: table.data_rewind() atOnce = False # data contains items that prevent array chunking diff --git a/processing/post/groupTable.py b/processing/post/groupTable.py index f2d1198bc..a73e7d505 100755 --- a/processing/post/groupTable.py +++ b/processing/post/groupTable.py @@ -11,11 +11,12 @@ import damask def periodicAverage(coords, limits): - """Centroid in periodic domain, see https://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions""" + """Centroid in periodic domain, see https://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions.""" theta = 2.0*np.pi * (coords - limits[0])/(limits[1] - limits[0]) theta_avg = np.pi + np.arctan2(-np.sin(theta).mean(axis=0), -np.cos(theta).mean(axis=0)) return limits[0] + theta_avg * (limits[1] - limits[0])/2.0/np.pi + scriptName = os.path.splitext(os.path.basename(__file__))[0] scriptID = ' '.join([scriptName,damask.version]) @@ -73,7 +74,7 @@ try: globals().get(funcModule) or __import__(funcModule), funcName) -except: +except Exception: mapFunction = None if options.label is []: diff --git a/processing/pre/seeds_fromRandom.py b/processing/pre/seeds_fromRandom.py index cea6a05ec..c64e6cc4f 100755 --- a/processing/pre/seeds_fromRandom.py +++ b/processing/pre/seeds_fromRandom.py @@ -14,7 +14,7 @@ scriptID = ' '.join([scriptName,damask.version]) # ------------------------------------------ aux functions --------------------------------- def kdtree_search(cloud, queryPoints): - """Find distances to nearest neighbor among cloud (N,d) for each of the queryPoints (n,d)""" + """Find distances to nearest neighbor among cloud (N,d) for each of the queryPoints (n,d).""" n = queryPoints.shape[0] distances = np.zeros(n,dtype=float) tree = spatial.cKDTree(cloud) @@ -23,7 +23,8 @@ def kdtree_search(cloud, queryPoints): distances[i], index = tree.query(queryPoints[i]) return distances - + + # -------------------------------------------------------------------- # MAIN # -------------------------------------------------------------------- From b1a4ed4cbe25fc69deb9eb5b92acc32f2f89f56c Mon Sep 17 00:00:00 2001 From: Test User Date: Thu, 20 Feb 2020 16:32:19 +0100 Subject: [PATCH 5/7] [skip ci] updated version information after successful test of v2.0.3-1726-gef4b7437 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index fc29e0602..59cceb119 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.3-1639-g81ae6686 +v2.0.3-1726-gef4b7437 From a60831092032dc48de196aead17c5a725452d4f4 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 20 Feb 2020 13:13:05 +0100 Subject: [PATCH 6/7] correct printing of error messages '{}'.format(np.ones(3)) gives only '1', but we want to see '[1 1 1]' --- python/damask/geom.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/python/damask/geom.py b/python/damask/geom.py index bfe475730..640618cd4 100644 --- a/python/damask/geom.py +++ b/python/damask/geom.py @@ -148,7 +148,7 @@ class Geom(): """ if microstructure is not None: if len(microstructure.shape) != 3: - raise ValueError('Invalid microstructure shape {}'.format(*microstructure.shape)) + raise ValueError('Invalid microstructure shape {}'.format(microstructure.shape)) elif microstructure.dtype not in np.sctypes['float'] + np.sctypes['int']: raise TypeError('Invalid data type {} for microstructure'.format(microstructure.dtype)) else: @@ -169,7 +169,7 @@ class Geom(): self.size = grid/np.max(grid) else: if len(size) != 3 or any(np.array(size)<=0): - raise ValueError('Invalid size {}'.format(*size)) + raise ValueError('Invalid size {}'.format(size)) else: self.size = np.array(size) @@ -185,7 +185,7 @@ class Geom(): """ if origin is not None: if len(origin) != 3: - raise ValueError('Invalid origin {}'.format(*origin)) + raise ValueError('Invalid origin {}'.format(origin)) else: self.origin = np.array(origin) @@ -297,7 +297,7 @@ class Geom(): i += len(items) if i != grid.prod(): - raise TypeError('Invalid file: expected {} entries,found {}'.format(grid.prod(),i)) + raise TypeError('Invalid file: expected {} entries, found {}'.format(grid.prod(),i)) microstructure = microstructure.reshape(grid,order='F') if not np.any(np.mod(microstructure.flatten(),1) != 0.0): # no float present @@ -458,7 +458,7 @@ class Geom(): if not all(isinstance(d, str) for d in directions): raise TypeError('Directions are not of type str.') elif not set(directions).issubset(valid): - raise ValueError('Invalid direction specified {}'.format(*set(directions).difference(valid))) + raise ValueError('Invalid direction specified {}'.format(set(directions).difference(valid))) limits = [None,None] if reflect else [-2,0] ms = self.get_microstructure() From d36181b857a4fe73b4f8f678da6e20ad5b1ab078 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 21 Feb 2020 00:45:18 +0100 Subject: [PATCH 7/7] [skip ci] updated version information after successful test of v2.0.3-1732-gab88ffd2 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 59cceb119..fe11c9855 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.3-1726-gef4b7437 +v2.0.3-1732-gab88ffd2